Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "framework/ConfigurationController.hxx"
30 : : #include "framework/Configuration.hxx"
31 : : #include "framework/FrameworkHelper.hxx"
32 : : #include "ConfigurationUpdater.hxx"
33 : : #include "ConfigurationControllerBroadcaster.hxx"
34 : : #include "ConfigurationTracer.hxx"
35 : : #include "GenericConfigurationChangeRequest.hxx"
36 : : #include "ResourceFactoryManager.hxx"
37 : : #include "UpdateRequest.hxx"
38 : : #include "ChangeRequestQueueProcessor.hxx"
39 : : #include "ConfigurationClassifier.hxx"
40 : : #include "ViewShellBase.hxx"
41 : : #include "DrawController.hxx"
42 : : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
43 : : #include <com/sun/star/util/XURLTransformer.hpp>
44 : :
45 : : #include <comphelper/stl_types.hxx>
46 : : #include <osl/mutex.hxx>
47 : : #include <vcl/svapp.hxx>
48 : :
49 : : using namespace ::com::sun::star;
50 : : using namespace ::com::sun::star::uno;
51 : : using namespace ::com::sun::star::drawing::framework;
52 : : using rtl::OUString;
53 : : using ::sd::framework::FrameworkHelper;
54 : :
55 : : namespace sd { namespace framework {
56 : :
57 : 130 : Reference<XInterface> SAL_CALL ConfigurationController_createInstance (
58 : : const Reference<XComponentContext>& rxContext)
59 : : {
60 : : (void)rxContext;
61 : 130 : return static_cast<XWeak*>(new ConfigurationController());
62 : : }
63 : :
64 : :
65 : :
66 : :
67 : 38 : OUString ConfigurationController_getImplementationName (void) throw(RuntimeException)
68 : : {
69 : 38 : return OUString("com.sun.star.comp.Draw.framework.configuration.ConfigurationController");
70 : : }
71 : :
72 : :
73 : :
74 : :
75 : 16 : Sequence<rtl::OUString> SAL_CALL ConfigurationController_getSupportedServiceNames (void)
76 : : throw (RuntimeException)
77 : : {
78 [ + - ][ + - ]: 16 : static const OUString sServiceName("com.sun.star.drawing.framework.ConfigurationController");
79 : 16 : return Sequence<rtl::OUString>(&sServiceName, 1);
80 : : }
81 : :
82 : :
83 : :
84 : :
85 : : //----- ConfigurationController::Implementation -------------------------------
86 : :
87 : : class ConfigurationController::Implementation
88 : : {
89 : : public:
90 : : Implementation (
91 : : ConfigurationController& rController,
92 : : const Reference<frame::XController>& rxController);
93 : : ~Implementation (void);
94 : :
95 : : Reference<XControllerManager> mxControllerManager;
96 : :
97 : : /** The Broadcaster class implements storing and calling of listeners.
98 : : */
99 : : ::boost::shared_ptr<ConfigurationControllerBroadcaster> mpBroadcaster;
100 : :
101 : : /** The requested configuration which is modifed (asynchronously) by
102 : : calls to requestResourceActivation() and
103 : : requestResourceDeactivation(). The mpConfigurationUpdater makes the
104 : : current configuration reflect the content of this one.
105 : : */
106 : : ::com::sun::star::uno::Reference<
107 : : ::com::sun::star::drawing::framework::XConfiguration> mxRequestedConfiguration;
108 : :
109 : : ViewShellBase* mpBase;
110 : :
111 : : ::boost::shared_ptr<ResourceFactoryManager> mpResourceFactoryContainer;
112 : :
113 : : ::boost::shared_ptr<ConfigurationControllerResourceManager> mpResourceManager;
114 : :
115 : : ::boost::shared_ptr<ConfigurationUpdater> mpConfigurationUpdater;
116 : :
117 : : /** The queue processor ownes the queue of configuration change request
118 : : objects and processes the objects.
119 : : */
120 : : ::boost::scoped_ptr<ChangeRequestQueueProcessor> mpQueueProcessor;
121 : :
122 : : ::boost::shared_ptr<ConfigurationUpdaterLock> mpConfigurationUpdaterLock;
123 : :
124 : : sal_Int32 mnLockCount;
125 : : };
126 : :
127 : :
128 : :
129 : :
130 : : //===== ConfigurationController::Lock =========================================
131 : :
132 : 195 : ConfigurationController::Lock::Lock (const Reference<XConfigurationController>& rxController)
133 : 195 : : mxController(rxController)
134 : : {
135 : : OSL_ASSERT(mxController.is());
136 : :
137 [ + - ]: 195 : if (mxController.is())
138 [ + - ][ + - ]: 195 : mxController->lock();
139 : 195 : }
140 : :
141 : :
142 : :
143 : :
144 : 195 : ConfigurationController::Lock::~Lock (void)
145 : : {
146 [ + - ]: 195 : if (mxController.is())
147 [ + - ][ + - ]: 195 : mxController->unlock();
148 : 195 : }
149 : :
150 : :
151 : :
152 : :
153 : : //===== ConfigurationController ===============================================
154 : :
155 : 130 : ConfigurationController::ConfigurationController (void) throw()
156 : : : ConfigurationControllerInterfaceBase(MutexOwner::maMutex)
157 : : , mpImplementation()
158 : 130 : , mbIsDisposed(false)
159 : : {
160 : 130 : }
161 : :
162 [ + - ][ + - ]: 130 : ConfigurationController::~ConfigurationController (void) throw()
163 : : {
164 [ - + ]: 260 : }
165 : :
166 : :
167 : 130 : void SAL_CALL ConfigurationController::disposing (void)
168 : : {
169 [ + - ]: 130 : if (mpImplementation.get() == NULL)
170 : 130 : return;
171 : :
172 : : SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ConfigurationController::disposing");
173 : : SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": requesting empty configuration");
174 : : // To destroy all resources an empty configuration is requested and then,
175 : : // synchronously, all resulting requests are processed.
176 [ + - ]: 130 : mpImplementation->mpQueueProcessor->Clear();
177 [ + - ][ + - ]: 130 : restoreConfiguration(new Configuration(this,false));
[ + - ][ + - ]
[ + - ]
178 [ + - ]: 130 : mpImplementation->mpQueueProcessor->ProcessUntilEmpty();
179 : : SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": all requests processed");
180 : :
181 : : // Now that all resources have been deactivated, mark the controller as
182 : : // disposed.
183 : 130 : mbIsDisposed = true;
184 : :
185 : : // Release the listeners.
186 [ + - ]: 130 : lang::EventObject aEvent;
187 [ + - ][ + - ]: 130 : aEvent.Source = uno::Reference<uno::XInterface>((cppu::OWeakObject*)this);
188 : :
189 : : {
190 [ + - ]: 130 : const SolarMutexGuard aSolarGuard;
191 [ + - ][ + - ]: 130 : mpImplementation->mpBroadcaster->DisposeAndClear();
192 : : }
193 : :
194 [ + - ]: 130 : mpImplementation->mpQueueProcessor.reset();
195 [ + - ]: 130 : mpImplementation->mxRequestedConfiguration = NULL;
196 [ + - ][ + - ]: 130 : mpImplementation.reset();
197 : : }
198 : :
199 : :
200 : :
201 : :
202 : 598 : void ConfigurationController::ProcessEvent (void)
203 : : {
204 [ + - ]: 598 : if (mpImplementation.get() != NULL)
205 : : {
206 : : OSL_ASSERT(mpImplementation->mpQueueProcessor.get()!=NULL);
207 : :
208 : 598 : mpImplementation->mpQueueProcessor->ProcessOneEvent();
209 : : }
210 : 598 : }
211 : :
212 : :
213 : :
214 : :
215 : 0 : void ConfigurationController::RequestSynchronousUpdate (void)
216 : : {
217 [ # # ]: 0 : if (mpImplementation.get() == NULL)
218 : 0 : return;
219 [ # # ]: 0 : if (mpImplementation->mpQueueProcessor.get() == 0)
220 : 0 : return;
221 : 0 : mpImplementation->mpQueueProcessor->ProcessUntilEmpty();
222 : : }
223 : :
224 : :
225 : :
226 : :
227 : : //----- XConfigurationControllerBroadcaster -----------------------------------
228 : :
229 : 2054 : void SAL_CALL ConfigurationController::addConfigurationChangeListener (
230 : : const Reference<XConfigurationChangeListener>& rxListener,
231 : : const ::rtl::OUString& rsEventType,
232 : : const Any& rUserData)
233 : : throw (RuntimeException)
234 : : {
235 [ + - ]: 2054 : ::osl::MutexGuard aGuard (maMutex);
236 : :
237 [ + - ]: 2054 : ThrowIfDisposed();
238 : : OSL_ASSERT(mpImplementation.get()!=NULL);
239 [ + - ][ + - ]: 2054 : mpImplementation->mpBroadcaster->AddListener(rxListener, rsEventType, rUserData);
240 : 2054 : }
241 : :
242 : :
243 : :
244 : :
245 : 52 : void SAL_CALL ConfigurationController::removeConfigurationChangeListener (
246 : : const Reference<XConfigurationChangeListener>& rxListener)
247 : : throw (RuntimeException)
248 : : {
249 [ + - ]: 52 : ::osl::MutexGuard aGuard (maMutex);
250 : :
251 [ + - ]: 52 : ThrowIfDisposed();
252 [ + - ][ + - ]: 52 : mpImplementation->mpBroadcaster->RemoveListener(rxListener);
253 : 52 : }
254 : :
255 : :
256 : :
257 : :
258 : 1240 : void SAL_CALL ConfigurationController::notifyEvent (
259 : : const ConfigurationChangeEvent& rEvent)
260 : : throw (RuntimeException)
261 : : {
262 : 1240 : ThrowIfDisposed();
263 : 1240 : mpImplementation->mpBroadcaster->NotifyListeners(rEvent);
264 : 1240 : }
265 : :
266 : :
267 : :
268 : :
269 : :
270 : : //----- XConfigurationController ----------------------------------------------
271 : :
272 : 195 : void SAL_CALL ConfigurationController::lock (void)
273 : : throw (RuntimeException)
274 : : {
275 : : OSL_ASSERT(mpImplementation.get()!=NULL);
276 : : OSL_ASSERT(mpImplementation->mpConfigurationUpdater.get()!=NULL);
277 : :
278 [ + - ]: 195 : ::osl::MutexGuard aGuard (maMutex);
279 [ + - ]: 195 : ThrowIfDisposed();
280 : :
281 : :
282 : 195 : ++mpImplementation->mnLockCount;
283 [ + - ]: 195 : if (mpImplementation->mpConfigurationUpdaterLock.get()==NULL)
284 : 195 : mpImplementation->mpConfigurationUpdaterLock
285 [ + - + - ]: 390 : = mpImplementation->mpConfigurationUpdater->GetLock();
[ + - ][ + - ]
286 : 195 : }
287 : :
288 : :
289 : :
290 : :
291 : 195 : void SAL_CALL ConfigurationController::unlock (void)
292 : : throw (RuntimeException)
293 : : {
294 [ + - ]: 195 : ::osl::MutexGuard aGuard (maMutex);
295 : :
296 : : // Allow unlocking while the ConfigurationController is being disposed
297 : : // (but not when that is done and the controller is disposed.)
298 [ - + ]: 195 : if (rBHelper.bDisposed)
299 [ # # ]: 0 : ThrowIfDisposed();
300 : :
301 : : OSL_ASSERT(mpImplementation->mnLockCount>0);
302 : 195 : --mpImplementation->mnLockCount;
303 [ + - ]: 195 : if (mpImplementation->mnLockCount == 0)
304 [ + - ][ + - ]: 195 : mpImplementation->mpConfigurationUpdaterLock.reset();
305 : 195 : }
306 : :
307 : :
308 : :
309 : :
310 : 936 : void SAL_CALL ConfigurationController::requestResourceActivation (
311 : : const Reference<XResourceId>& rxResourceId,
312 : : ResourceActivationMode eMode)
313 : : throw (RuntimeException)
314 : : {
315 [ + - ]: 936 : ::osl::MutexGuard aGuard (maMutex);
316 [ + - ]: 936 : ThrowIfDisposed();
317 : :
318 : : // Check whether we are being disposed. This is handled differently
319 : : // then being completely disposed because the first thing disposing()
320 : : // does is to deactivate all remaining resources. This is done via
321 : : // regular methods which must not throw DisposedExceptions. Therefore
322 : : // we just return silently during that stage.
323 [ - + ]: 936 : if (rBHelper.bInDispose)
324 : : {
325 : : SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ConfigurationController::requestResourceActivation(): ignoring " <<
326 : : OUStringToOString(
327 : : FrameworkHelper::ResourceIdToString(rxResourceId), RTL_TEXTENCODING_UTF8).getStr());
328 : 936 : return;
329 : : }
330 : :
331 : : SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ConfigurationController::requestResourceActivation() " <<
332 : : OUStringToOString(
333 : : FrameworkHelper::ResourceIdToString(rxResourceId), RTL_TEXTENCODING_UTF8).getStr());
334 : :
335 [ + - ]: 936 : if (rxResourceId.is())
336 : : {
337 [ + + ]: 936 : if (eMode == ResourceActivationMode_REPLACE)
338 : : {
339 : : // Get a list of the matching resources and create deactivation
340 : : // requests for them.
341 : : Sequence<Reference<XResourceId> > aResourceList (
342 [ + - ]: 481 : mpImplementation->mxRequestedConfiguration->getResources(
343 [ + - ]: 481 : rxResourceId->getAnchor(),
344 [ + - ]: 481 : rxResourceId->getResourceTypePrefix(),
345 [ + - ][ + - ]: 962 : AnchorBindingMode_DIRECT));
[ + - ]
346 : :
347 [ + + ]: 636 : for (sal_Int32 nIndex=0; nIndex<aResourceList.getLength(); ++nIndex)
348 : : {
349 : : // Do not request the deactivation of the resource for which
350 : : // this method was called. Doing it would not change the
351 : : // outcome but would result in unnecessary work.
352 [ + - ][ + - ]: 155 : if (rxResourceId->compareTo(aResourceList[nIndex]) == 0)
[ + - ][ + + ]
353 : 149 : continue;
354 : :
355 : : // Request the deactivation of a resource and all resources
356 : : // linked to it.
357 [ + - ][ + - ]: 6 : requestResourceDeactivation(aResourceList[nIndex]);
358 [ + - ]: 481 : }
359 : : }
360 : :
361 : : Reference<XConfigurationChangeRequest> xRequest(
362 : : new GenericConfigurationChangeRequest(
363 : : rxResourceId,
364 [ + - ][ + - ]: 936 : GenericConfigurationChangeRequest::Activation));
[ + - ]
365 [ + - ]: 936 : postChangeRequest(xRequest);
366 [ + - ][ + - ]: 936 : }
367 : : }
368 : :
369 : :
370 : :
371 : :
372 : 990 : void SAL_CALL ConfigurationController::requestResourceDeactivation (
373 : : const Reference<XResourceId>& rxResourceId)
374 : : throw (RuntimeException)
375 : : {
376 [ + - ]: 990 : ::osl::MutexGuard aGuard (maMutex);
377 [ + - ]: 990 : ThrowIfDisposed();
378 : :
379 : : SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ConfigurationController::requestResourceDeactivation() " <<
380 : : OUStringToOString(
381 : : FrameworkHelper::ResourceIdToString(rxResourceId), RTL_TEXTENCODING_UTF8).getStr());
382 : :
383 [ + - ]: 990 : if (rxResourceId.is())
384 : : {
385 : : // Request deactivation of all resources linked to the specified one
386 : : // as well.
387 : : const Sequence<Reference<XResourceId> > aLinkedResources (
388 [ + - ]: 990 : mpImplementation->mxRequestedConfiguration->getResources(
389 : : rxResourceId,
390 : : OUString(),
391 [ + - ]: 990 : AnchorBindingMode_DIRECT));
392 : 990 : const sal_Int32 nCount (aLinkedResources.getLength());
393 [ + + ]: 1334 : for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
394 : : {
395 : : // We do not add deactivation requests directly but call this
396 : : // method recursively, so that when one time there are resources
397 : : // linked to linked resources, these are handled correctly, too.
398 [ + - ]: 344 : requestResourceDeactivation(aLinkedResources[nIndex]);
399 : : }
400 : :
401 : : // Add a deactivation request for the specified resource.
402 : : Reference<XConfigurationChangeRequest> xRequest(
403 : : new GenericConfigurationChangeRequest(
404 : : rxResourceId,
405 [ + - ][ + - ]: 990 : GenericConfigurationChangeRequest::Deactivation));
[ + - ]
406 [ + - ][ + - ]: 990 : postChangeRequest(xRequest);
407 [ + - ]: 990 : }
408 : 990 : }
409 : :
410 : :
411 : :
412 : :
413 : 8728 : Reference<XResource> SAL_CALL ConfigurationController::getResource (
414 : : const Reference<XResourceId>& rxResourceId)
415 : : throw (RuntimeException)
416 : : {
417 [ + - ]: 8728 : ::osl::MutexGuard aGuard (maMutex);
418 [ + - ]: 8728 : ThrowIfDisposed();
419 : :
420 : : ConfigurationControllerResourceManager::ResourceDescriptor aDescriptor (
421 [ + - ]: 8728 : mpImplementation->mpResourceManager->GetResource(rxResourceId));
422 [ + - ][ + - ]: 8728 : return aDescriptor.mxResource;
423 : : }
424 : :
425 : :
426 : :
427 : :
428 : 442 : void SAL_CALL ConfigurationController::update (void)
429 : : throw (RuntimeException)
430 : : {
431 [ + - ]: 442 : ::osl::MutexGuard aGuard (maMutex);
432 [ + - ]: 442 : ThrowIfDisposed();
433 : :
434 [ + - ][ + + ]: 442 : if (mpImplementation->mpQueueProcessor->IsEmpty())
435 : : {
436 : : // The queue is empty. Add another request that does nothing but
437 : : // asynchronously trigger a request for an update.
438 [ + - ][ + - ]: 239 : mpImplementation->mpQueueProcessor->AddRequest(new UpdateRequest());
[ + - ]
439 : : }
440 : : else
441 : : {
442 : : // The queue is not empty, so we rely on the queue processor to
443 : : // request an update automatically when the queue becomes empty.
444 [ + - ]: 442 : }
445 : 442 : }
446 : :
447 : :
448 : :
449 : :
450 : 598 : sal_Bool SAL_CALL ConfigurationController::hasPendingRequests (void)
451 : : throw (RuntimeException)
452 : : {
453 [ + - ]: 598 : ::osl::MutexGuard aGuard (maMutex);
454 [ + - ]: 598 : ThrowIfDisposed();
455 : :
456 [ + - ][ + - ]: 598 : return ! mpImplementation->mpQueueProcessor->IsEmpty();
457 : : }
458 : :
459 : :
460 : :
461 : :
462 : :
463 : 1926 : void SAL_CALL ConfigurationController::postChangeRequest (
464 : : const Reference<XConfigurationChangeRequest>& rxRequest)
465 : : throw (RuntimeException)
466 : : {
467 [ + - ]: 1926 : ::osl::MutexGuard aGuard (maMutex);
468 [ + - ]: 1926 : ThrowIfDisposed();
469 : :
470 [ + - ][ + - ]: 1926 : mpImplementation->mpQueueProcessor->AddRequest(rxRequest);
471 : 1926 : }
472 : :
473 : :
474 : :
475 : :
476 : 7428 : Reference<XConfiguration> SAL_CALL ConfigurationController::getRequestedConfiguration (void)
477 : : throw (RuntimeException)
478 : : {
479 [ + - ]: 7428 : ::osl::MutexGuard aGuard (maMutex);
480 [ + - ]: 7428 : ThrowIfDisposed();
481 : :
482 [ + - ]: 7428 : if (mpImplementation->mxRequestedConfiguration.is())
483 : : return Reference<XConfiguration>(
484 [ + - ][ + - ]: 7428 : mpImplementation->mxRequestedConfiguration->createClone(), UNO_QUERY);
[ + - ]
485 : : else
486 [ + - ]: 7428 : return Reference<XConfiguration>();
487 : : }
488 : :
489 : :
490 : :
491 : :
492 : 0 : Reference<XConfiguration> SAL_CALL ConfigurationController::getCurrentConfiguration (void)
493 : : throw (RuntimeException)
494 : : {
495 [ # # ]: 0 : ::osl::MutexGuard aGuard (maMutex);
496 [ # # ]: 0 : ThrowIfDisposed();
497 : :
498 : : Reference<XConfiguration> xCurrentConfiguration(
499 [ # # ]: 0 : mpImplementation->mpConfigurationUpdater->GetCurrentConfiguration());
500 [ # # ]: 0 : if (xCurrentConfiguration.is())
501 [ # # ][ # # ]: 0 : return Reference<XConfiguration>(xCurrentConfiguration->createClone(), UNO_QUERY);
[ # # ]
502 : : else
503 [ # # ]: 0 : return Reference<XConfiguration>();
504 : : }
505 : :
506 : :
507 : :
508 : :
509 : : /** The given configuration is restored by generating the appropriate set of
510 : : activation and deactivation requests.
511 : : */
512 : 130 : void SAL_CALL ConfigurationController::restoreConfiguration (
513 : : const Reference<XConfiguration>& rxNewConfiguration)
514 : : throw (RuntimeException)
515 : : {
516 [ + - ]: 130 : ::osl::MutexGuard aGuard (maMutex);
517 [ + - ]: 130 : ThrowIfDisposed();
518 : :
519 : : // We will probably be making a couple of activation and deactivation
520 : : // requests so lock the configuration controller and let it later update
521 : : // all changes at once.
522 : : ::boost::shared_ptr<ConfigurationUpdaterLock> pLock (
523 [ + - ]: 130 : mpImplementation->mpConfigurationUpdater->GetLock());
524 : :
525 : : // Get lists of resources that are to be activated or deactivated.
526 : 130 : Reference<XConfiguration> xCurrentConfiguration (mpImplementation->mxRequestedConfiguration);
527 : : #if OSL_DEBUG_LEVEL >=1
528 : : SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ConfigurationController::restoreConfiguration(");
529 : : ConfigurationTracer::TraceConfiguration(rxNewConfiguration, "requested configuration");
530 : : ConfigurationTracer::TraceConfiguration(xCurrentConfiguration, "current configuration");
531 : : #endif
532 [ + - ]: 130 : ConfigurationClassifier aClassifier (rxNewConfiguration, xCurrentConfiguration);
533 [ + - ]: 130 : aClassifier.Partition();
534 : : #if OSL_DEBUG_LEVEL >=2
535 : : aClassifier.TraceResourceIdVector(
536 : : "requested but not current resources:\n", aClassifier.GetC1minusC2());
537 : : aClassifier.TraceResourceIdVector(
538 : : "current but not requested resources:\n", aClassifier.GetC2minusC1());
539 : : aClassifier.TraceResourceIdVector(
540 : : "requested and current resources:\n", aClassifier.GetC1andC2());
541 : : #endif
542 : :
543 : 130 : ConfigurationClassifier::ResourceIdVector::const_iterator iResource;
544 : :
545 : : // Request the deactivation of resources that are not requested in the
546 : : // new configuration.
547 : : const ConfigurationClassifier::ResourceIdVector& rResourcesToDeactivate (
548 [ + - ]: 130 : aClassifier.GetC2minusC1());
549 [ + - ][ + + ]: 1488 : for (iResource=rResourcesToDeactivate.begin();
550 : 744 : iResource!=rResourcesToDeactivate.end();
551 : : ++iResource)
552 : : {
553 [ + - ]: 614 : requestResourceDeactivation(*iResource);
554 : : }
555 : :
556 : : // Request the activation of resources that are requested in the
557 : : // new configuration but are not part of the current configuration.
558 : : const ConfigurationClassifier::ResourceIdVector& rResourcesToActivate (
559 [ + - ]: 130 : aClassifier.GetC1minusC2());
560 [ + - ][ - + ]: 260 : for (iResource=rResourcesToActivate.begin();
561 : 130 : iResource!=rResourcesToActivate.end();
562 : : ++iResource)
563 : : {
564 [ # # ]: 0 : requestResourceActivation(*iResource, ResourceActivationMode_ADD);
565 : : }
566 : :
567 [ + - ][ + - ]: 130 : pLock.reset();
[ + - ][ + - ]
568 : 130 : }
569 : :
570 : :
571 : :
572 : :
573 : : //----- XResourceFactoryManager -----------------------------------------------
574 : :
575 : 1926 : void SAL_CALL ConfigurationController::addResourceFactory(
576 : : const OUString& sResourceURL,
577 : : const Reference<XResourceFactory>& rxResourceFactory)
578 : : throw (RuntimeException)
579 : : {
580 [ + - ]: 1926 : ::osl::MutexGuard aGuard (maMutex);
581 [ + - ]: 1926 : ThrowIfDisposed();
582 [ + - ][ + - ]: 1926 : mpImplementation->mpResourceFactoryContainer->AddFactory(sResourceURL, rxResourceFactory);
583 : 1926 : }
584 : :
585 : :
586 : :
587 : :
588 : 0 : void SAL_CALL ConfigurationController::removeResourceFactoryForURL(
589 : : const OUString& sResourceURL)
590 : : throw (RuntimeException)
591 : : {
592 [ # # ]: 0 : ::osl::MutexGuard aGuard (maMutex);
593 [ # # ]: 0 : ThrowIfDisposed();
594 [ # # ][ # # ]: 0 : mpImplementation->mpResourceFactoryContainer->RemoveFactoryForURL(sResourceURL);
595 : 0 : }
596 : :
597 : :
598 : :
599 : :
600 : 0 : void SAL_CALL ConfigurationController::removeResourceFactoryForReference(
601 : : const Reference<XResourceFactory>& rxResourceFactory)
602 : : throw (RuntimeException)
603 : : {
604 [ # # ]: 0 : ::osl::MutexGuard aGuard (maMutex);
605 [ # # ]: 0 : ThrowIfDisposed();
606 [ # # ][ # # ]: 0 : mpImplementation->mpResourceFactoryContainer->RemoveFactoryForReference(rxResourceFactory);
607 : 0 : }
608 : :
609 : :
610 : :
611 : :
612 : 0 : Reference<XResourceFactory> SAL_CALL ConfigurationController::getResourceFactory (
613 : : const OUString& sResourceURL)
614 : : throw (RuntimeException)
615 : : {
616 [ # # ]: 0 : ::osl::MutexGuard aGuard (maMutex);
617 [ # # ]: 0 : ThrowIfDisposed();
618 : :
619 [ # # ][ # # ]: 0 : return mpImplementation->mpResourceFactoryContainer->GetFactory(sResourceURL);
620 : : }
621 : :
622 : :
623 : :
624 : :
625 : : //----- XInitialization -------------------------------------------------------
626 : :
627 : 130 : void SAL_CALL ConfigurationController::initialize (const Sequence<Any>& aArguments)
628 : : throw (Exception, RuntimeException)
629 : : {
630 [ + - ]: 130 : ::osl::MutexGuard aGuard (maMutex);
631 : :
632 [ + - ]: 130 : if (aArguments.getLength() == 1)
633 : : {
634 [ + - ]: 130 : const SolarMutexGuard aSolarGuard;
635 : :
636 : : mpImplementation.reset(new Implementation(
637 : : *this,
638 [ + - ][ + - ]: 130 : Reference<frame::XController>(aArguments[0], UNO_QUERY_THROW)));
[ + - ][ + - ]
[ + - ]
639 [ + - ]: 130 : }
640 : 130 : }
641 : :
642 : :
643 : :
644 : :
645 : : //-----------------------------------------------------------------------------
646 : :
647 : 26645 : void ConfigurationController::ThrowIfDisposed (void) const
648 : : throw (::com::sun::star::lang::DisposedException)
649 : : {
650 [ - + ]: 26645 : if (mbIsDisposed)
651 : : {
652 : : throw lang::DisposedException ("ConfigurationController object has already been disposed",
653 [ # # ][ # # ]: 0 : const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
654 : : }
655 : :
656 [ - + ]: 26645 : if (mpImplementation.get() == NULL)
657 : : {
658 : : OSL_ASSERT(mpImplementation.get() != NULL);
659 : : throw RuntimeException("ConfigurationController not initialized",
660 [ # # ][ # # ]: 0 : const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
661 : : }
662 : 26645 : }
663 : :
664 : :
665 : :
666 : :
667 : : //===== ConfigurationController::Implementation ===============================
668 : :
669 : 130 : ConfigurationController::Implementation::Implementation (
670 : : ConfigurationController& rController,
671 : : const Reference<frame::XController>& rxController)
672 : : : mxControllerManager(rxController, UNO_QUERY_THROW),
673 [ + - ]: 130 : mpBroadcaster(new ConfigurationControllerBroadcaster(&rController)),
674 [ + - ]: 130 : mxRequestedConfiguration(new Configuration(&rController, true)),
675 : : mpBase(NULL),
676 [ + - ]: 130 : mpResourceFactoryContainer(new ResourceFactoryManager(mxControllerManager)),
677 : : mpResourceManager(
678 [ + - ]: 130 : new ConfigurationControllerResourceManager(mpResourceFactoryContainer,mpBroadcaster)),
679 : : mpConfigurationUpdater(
680 [ + - ]: 130 : new ConfigurationUpdater(mpBroadcaster, mpResourceManager,mxControllerManager)),
681 [ + - ]: 130 : mpQueueProcessor(new ChangeRequestQueueProcessor(&rController,mpConfigurationUpdater)),
682 : : mpConfigurationUpdaterLock(),
683 [ + - ][ + - ]: 910 : mnLockCount(0)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
684 : : {
685 [ + - ]: 130 : mpQueueProcessor->SetConfiguration(mxRequestedConfiguration);
686 : 130 : }
687 : :
688 : :
689 : :
690 : :
691 [ + - ][ + - ]: 130 : ConfigurationController::Implementation::~Implementation (void)
[ + - ][ + - ]
[ + - ][ + - ]
692 : : {
693 : 130 : }
694 : :
695 : :
696 : :
697 : :
698 : : } } // end of namespace sd::framework
699 : :
700 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|