1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "precompiled_sd.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "framework/Configuration.hxx"
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx"
33*cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir using namespace ::com::sun::star;
38*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
40*cdf0e10cSrcweir using ::sd::framework::FrameworkHelper;
41*cdf0e10cSrcweir using ::rtl::OUString;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #undef VERBOSE
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace {
46*cdf0e10cSrcweir /** Use the XResourceId::compareTo() method to implement a compare operator
47*cdf0e10cSrcweir     for STL containers.
48*cdf0e10cSrcweir */
49*cdf0e10cSrcweir class XResourceIdLess
50*cdf0e10cSrcweir     : 	public ::std::binary_function <Reference<XResourceId>, Reference<XResourceId>, bool>
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir public:
53*cdf0e10cSrcweir     bool operator () (const Reference<XResourceId>& rId1, const Reference<XResourceId>& rId2) const
54*cdf0e10cSrcweir 	{
55*cdf0e10cSrcweir         return rId1->compareTo(rId2) == -1;
56*cdf0e10cSrcweir     }
57*cdf0e10cSrcweir };
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir } // end of anonymous namespace
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir namespace sd { namespace framework {
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir class Configuration::ResourceContainer
68*cdf0e10cSrcweir     : public ::std::set<Reference<XResourceId>, XResourceIdLess>
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir public:
71*cdf0e10cSrcweir     ResourceContainer (void) {}
72*cdf0e10cSrcweir };
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir //----- Service ---------------------------------------------------------------
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir Reference<XInterface> SAL_CALL Configuration_createInstance (
80*cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext)
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir     (void)rxContext;
83*cdf0e10cSrcweir     return Reference<XInterface>(static_cast<XWeak*>(new Configuration(NULL,false)));
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir OUString Configuration_getImplementationName (void) throw(RuntimeException)
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir     return OUString(RTL_CONSTASCII_USTRINGPARAM(
92*cdf0e10cSrcweir         "com.sun.star.comp.Draw.framework.configuration.Configuration"));
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir Sequence<rtl::OUString> SAL_CALL Configuration_getSupportedServiceNames (void)
99*cdf0e10cSrcweir     throw (RuntimeException)
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir 	static const OUString sServiceName(OUString::createFromAscii(
102*cdf0e10cSrcweir         "com.sun.star.drawing.framework.Configuration"));
103*cdf0e10cSrcweir 	return Sequence<rtl::OUString>(&sServiceName, 1);
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir //===== Configuration =========================================================
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir Configuration::Configuration (
112*cdf0e10cSrcweir     const Reference<XConfigurationControllerBroadcaster>& rxBroadcaster,
113*cdf0e10cSrcweir     bool bBroadcastRequestEvents)
114*cdf0e10cSrcweir     : ConfigurationInterfaceBase(MutexOwner::maMutex),
115*cdf0e10cSrcweir       mpResourceContainer(new ResourceContainer()),
116*cdf0e10cSrcweir       mxBroadcaster(rxBroadcaster),
117*cdf0e10cSrcweir       mbBroadcastRequestEvents(bBroadcastRequestEvents)
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir Configuration::Configuration (
124*cdf0e10cSrcweir     const Reference<XConfigurationControllerBroadcaster>& rxBroadcaster,
125*cdf0e10cSrcweir     bool bBroadcastRequestEvents,
126*cdf0e10cSrcweir     const ResourceContainer& rResourceContainer)
127*cdf0e10cSrcweir     : ConfigurationInterfaceBase(MutexOwner::maMutex),
128*cdf0e10cSrcweir       mpResourceContainer(new ResourceContainer(rResourceContainer)),
129*cdf0e10cSrcweir       mxBroadcaster(rxBroadcaster),
130*cdf0e10cSrcweir       mbBroadcastRequestEvents(bBroadcastRequestEvents)
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir Configuration::~Configuration (void)
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir void SAL_CALL Configuration::disposing (void)
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
147*cdf0e10cSrcweir     mpResourceContainer->clear();
148*cdf0e10cSrcweir     mxBroadcaster = NULL;
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir //----- XConfiguration --------------------------------------------------------
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir void SAL_CALL Configuration::addResource (const Reference<XResourceId>& rxResourceId)
157*cdf0e10cSrcweir     throw (RuntimeException)
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir     ThrowIfDisposed();
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     if ( ! rxResourceId.is() || rxResourceId->getResourceURL().getLength()==0)
162*cdf0e10cSrcweir         throw ::com::sun::star::lang::IllegalArgumentException();
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     if (mpResourceContainer->find(rxResourceId) == mpResourceContainer->end())
165*cdf0e10cSrcweir     {
166*cdf0e10cSrcweir #ifdef VERBOSE
167*cdf0e10cSrcweir     OSL_TRACE("Configuration::addResource() %s",
168*cdf0e10cSrcweir         OUStringToOString(
169*cdf0e10cSrcweir             FrameworkHelper::ResourceIdToString(rxResourceId), RTL_TEXTENCODING_UTF8).getStr());
170*cdf0e10cSrcweir #endif
171*cdf0e10cSrcweir         mpResourceContainer->insert(rxResourceId);
172*cdf0e10cSrcweir         PostEvent(rxResourceId, true);
173*cdf0e10cSrcweir     }
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir void SAL_CALL Configuration::removeResource (const Reference<XResourceId>& rxResourceId)
180*cdf0e10cSrcweir     throw (RuntimeException)
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir     ThrowIfDisposed();
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     if ( ! rxResourceId.is() || rxResourceId->getResourceURL().getLength()==0)
185*cdf0e10cSrcweir         throw ::com::sun::star::lang::IllegalArgumentException();
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     ResourceContainer::iterator iResource (mpResourceContainer->find(rxResourceId));
188*cdf0e10cSrcweir     if (iResource != mpResourceContainer->end())
189*cdf0e10cSrcweir     {
190*cdf0e10cSrcweir #ifdef VERBOSE
191*cdf0e10cSrcweir     OSL_TRACE("Configuration::removeResource() %s",
192*cdf0e10cSrcweir         OUStringToOString(
193*cdf0e10cSrcweir             FrameworkHelper::ResourceIdToString(rxResourceId), RTL_TEXTENCODING_UTF8).getStr());
194*cdf0e10cSrcweir #endif
195*cdf0e10cSrcweir         PostEvent(rxResourceId,false);
196*cdf0e10cSrcweir         mpResourceContainer->erase(iResource);
197*cdf0e10cSrcweir     }
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir Sequence<Reference<XResourceId> > SAL_CALL Configuration::getResources (
204*cdf0e10cSrcweir     const Reference<XResourceId>& rxAnchorId,
205*cdf0e10cSrcweir     const ::rtl::OUString& rsResourceURLPrefix,
206*cdf0e10cSrcweir     AnchorBindingMode eMode)
207*cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
210*cdf0e10cSrcweir     ThrowIfDisposed();
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir     bool bFilterResources (rsResourceURLPrefix.getLength() > 0);
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     // Collect the matching resources in a vector.
215*cdf0e10cSrcweir     ::std::vector<Reference<XResourceId> > aResources;
216*cdf0e10cSrcweir     ResourceContainer::const_iterator iResource;
217*cdf0e10cSrcweir     for (iResource=mpResourceContainer->begin();
218*cdf0e10cSrcweir          iResource!=mpResourceContainer->end();
219*cdf0e10cSrcweir          ++iResource)
220*cdf0e10cSrcweir     {
221*cdf0e10cSrcweir         if ( ! (*iResource)->isBoundTo(rxAnchorId,eMode))
222*cdf0e10cSrcweir             continue;
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir         if (bFilterResources)
226*cdf0e10cSrcweir         {
227*cdf0e10cSrcweir             // Apply the given resource prefix as filter.
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir             // Make sure that the resource is bound directly to the anchor.
230*cdf0e10cSrcweir             if (eMode != AnchorBindingMode_DIRECT
231*cdf0e10cSrcweir                 && ! (*iResource)->isBoundTo(rxAnchorId, AnchorBindingMode_DIRECT))
232*cdf0e10cSrcweir             {
233*cdf0e10cSrcweir                 continue;
234*cdf0e10cSrcweir             }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir             // Make sure that the resource URL matches the given prefix.
237*cdf0e10cSrcweir             if ( ! (*iResource)->getResourceURL().match(rsResourceURLPrefix))
238*cdf0e10cSrcweir             {
239*cdf0e10cSrcweir                 continue;
240*cdf0e10cSrcweir             }
241*cdf0e10cSrcweir         }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir         aResources.push_back(*iResource);
244*cdf0e10cSrcweir     }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     // Copy the resources from the vector into a new sequence.
247*cdf0e10cSrcweir     Sequence<Reference<XResourceId> > aResult (aResources.size());
248*cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<aResources.size(); ++nIndex)
249*cdf0e10cSrcweir         aResult[nIndex] = aResources[nIndex];
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir     return aResult;
252*cdf0e10cSrcweir }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir sal_Bool SAL_CALL Configuration::hasResource (const Reference<XResourceId>& rxResourceId)
258*cdf0e10cSrcweir     throw (RuntimeException)
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
261*cdf0e10cSrcweir     ThrowIfDisposed();
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir     return rxResourceId.is()
264*cdf0e10cSrcweir         && mpResourceContainer->find(rxResourceId) != mpResourceContainer->end();
265*cdf0e10cSrcweir }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir //----- XCloneable ------------------------------------------------------------
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir Reference<util::XCloneable> SAL_CALL Configuration::createClone (void)
273*cdf0e10cSrcweir     throw (RuntimeException)
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
276*cdf0e10cSrcweir     ThrowIfDisposed();
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     Configuration* pConfiguration = new Configuration(
279*cdf0e10cSrcweir         mxBroadcaster,
280*cdf0e10cSrcweir         mbBroadcastRequestEvents,
281*cdf0e10cSrcweir         *mpResourceContainer);
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir     return Reference<util::XCloneable>(pConfiguration);
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir //----- XNamed ----------------------------------------------------------------
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir OUString SAL_CALL Configuration::getName (void)
292*cdf0e10cSrcweir     throw (RuntimeException)
293*cdf0e10cSrcweir {
294*cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
295*cdf0e10cSrcweir     OUString aString;
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
298*cdf0e10cSrcweir         aString += OUString::createFromAscii("DISPOSED ");
299*cdf0e10cSrcweir     aString += OUString::createFromAscii("Configuration[");
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     ResourceContainer::const_iterator iResource;
302*cdf0e10cSrcweir     for (iResource=mpResourceContainer->begin();
303*cdf0e10cSrcweir          iResource!=mpResourceContainer->end();
304*cdf0e10cSrcweir          ++iResource)
305*cdf0e10cSrcweir     {
306*cdf0e10cSrcweir         if (iResource != mpResourceContainer->begin())
307*cdf0e10cSrcweir             aString += OUString::createFromAscii(", ");
308*cdf0e10cSrcweir         aString += FrameworkHelper::ResourceIdToString(*iResource);
309*cdf0e10cSrcweir     }
310*cdf0e10cSrcweir     aString += OUString::createFromAscii("]");
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir     return aString;
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir void SAL_CALL Configuration::setName (const OUString& rsName)
319*cdf0e10cSrcweir     throw (RuntimeException)
320*cdf0e10cSrcweir {
321*cdf0e10cSrcweir     (void)rsName; // rsName is ignored.
322*cdf0e10cSrcweir }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir // ----------------------------------------------------------------------------
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir void Configuration::PostEvent (
331*cdf0e10cSrcweir     const Reference<XResourceId>& rxResourceId,
332*cdf0e10cSrcweir     const bool bActivation)
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir     OSL_ASSERT(rxResourceId.is());
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     if (mxBroadcaster.is())
337*cdf0e10cSrcweir     {
338*cdf0e10cSrcweir         ConfigurationChangeEvent aEvent;
339*cdf0e10cSrcweir         aEvent.ResourceId = rxResourceId;
340*cdf0e10cSrcweir         if (bActivation)
341*cdf0e10cSrcweir             if (mbBroadcastRequestEvents)
342*cdf0e10cSrcweir                 aEvent.Type = FrameworkHelper::msResourceActivationRequestEvent;
343*cdf0e10cSrcweir             else
344*cdf0e10cSrcweir                 aEvent.Type = FrameworkHelper::msResourceActivationEvent;
345*cdf0e10cSrcweir         else
346*cdf0e10cSrcweir             if (mbBroadcastRequestEvents)
347*cdf0e10cSrcweir                 aEvent.Type = FrameworkHelper::msResourceDeactivationRequestEvent;
348*cdf0e10cSrcweir             else
349*cdf0e10cSrcweir                 aEvent.Type = FrameworkHelper::msResourceDeactivationEvent;
350*cdf0e10cSrcweir         aEvent.Configuration = this;
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir         mxBroadcaster->notifyEvent(aEvent);
353*cdf0e10cSrcweir     }
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir void Configuration::ThrowIfDisposed (void) const
360*cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
363*cdf0e10cSrcweir 	{
364*cdf0e10cSrcweir         throw lang::DisposedException (
365*cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(
366*cdf0e10cSrcweir                 "Configuration object has already been disposed")),
367*cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
368*cdf0e10cSrcweir     }
369*cdf0e10cSrcweir }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir //=============================================================================
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir bool AreConfigurationsEquivalent (
377*cdf0e10cSrcweir     const Reference<XConfiguration>& rxConfiguration1,
378*cdf0e10cSrcweir     const Reference<XConfiguration>& rxConfiguration2)
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir     if (rxConfiguration1.is() != rxConfiguration2.is())
381*cdf0e10cSrcweir         return false;
382*cdf0e10cSrcweir     if ( ! rxConfiguration1.is() && ! rxConfiguration2.is())
383*cdf0e10cSrcweir         return true;
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir     // Get the lists of resources from the two given configurations.
386*cdf0e10cSrcweir     const Sequence<Reference<XResourceId> > aResources1(
387*cdf0e10cSrcweir         rxConfiguration1->getResources(
388*cdf0e10cSrcweir             NULL, OUString(), AnchorBindingMode_INDIRECT));
389*cdf0e10cSrcweir     const Sequence<Reference<XResourceId> > aResources2(
390*cdf0e10cSrcweir         rxConfiguration2->getResources(
391*cdf0e10cSrcweir             NULL, OUString(), AnchorBindingMode_INDIRECT));
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     // When the number of resources differ then the configurations can not
394*cdf0e10cSrcweir     // be equivalent.
395*cdf0e10cSrcweir     const sal_Int32 nCount (aResources1.getLength());
396*cdf0e10cSrcweir     const sal_Int32 nCount2 (aResources2.getLength());
397*cdf0e10cSrcweir     if (nCount != nCount2)
398*cdf0e10cSrcweir         return false;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir     // Comparison of the two lists of resource ids relies on their
401*cdf0e10cSrcweir     // ordering.
402*cdf0e10cSrcweir     for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
403*cdf0e10cSrcweir     {
404*cdf0e10cSrcweir         const Reference<XResourceId> xResource1 (aResources1[nIndex]);
405*cdf0e10cSrcweir         const Reference<XResourceId> xResource2 (aResources2[nIndex]);
406*cdf0e10cSrcweir         if (xResource1.is() && xResource2.is())
407*cdf0e10cSrcweir         {
408*cdf0e10cSrcweir             if (xResource1->compareTo(xResource2) != 0)
409*cdf0e10cSrcweir                 return false;
410*cdf0e10cSrcweir         }
411*cdf0e10cSrcweir         else if (xResource1.is() != xResource2.is())
412*cdf0e10cSrcweir         {
413*cdf0e10cSrcweir             return false;
414*cdf0e10cSrcweir         }
415*cdf0e10cSrcweir     }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir     return true;
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir } } // end of namespace sd::framework
421