LCOV - code coverage report
Current view: top level - sd/source/ui/framework/configuration - ConfigurationController.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 170 203 83.7 %
Date: 2014-04-11 Functions: 28 33 84.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10