LCOV - code coverage report
Current view: top level - sd/source/ui/framework/configuration - ConfigurationController.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 203 0.0 %
Date: 2014-04-14 Functions: 0 33 0.0 %
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           0 : Reference<XInterface> SAL_CALL ConfigurationController_createInstance (
      47             :     const Reference<XComponentContext>& rxContext)
      48             : {
      49             :     (void)rxContext;
      50           0 :     return static_cast<XWeak*>(new ConfigurationController());
      51             : }
      52             : 
      53             : 
      54             : 
      55             : 
      56           0 : OUString ConfigurationController_getImplementationName (void) throw(RuntimeException)
      57             : {
      58           0 :     return OUString("com.sun.star.comp.Draw.framework.configuration.ConfigurationController");
      59             : }
      60             : 
      61             : 
      62             : 
      63             : 
      64           0 : Sequence<OUString> SAL_CALL ConfigurationController_getSupportedServiceNames (void)
      65             :     throw (RuntimeException)
      66             : {
      67           0 :     static const OUString sServiceName("com.sun.star.drawing.framework.ConfigurationController");
      68           0 :     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           0 : ConfigurationController::Lock::Lock (const Reference<XConfigurationController>& rxController)
     122           0 :     : mxController(rxController)
     123             : {
     124             :     OSL_ASSERT(mxController.is());
     125             : 
     126           0 :     if (mxController.is())
     127           0 :         mxController->lock();
     128           0 : }
     129             : 
     130             : 
     131             : 
     132             : 
     133           0 : ConfigurationController::Lock::~Lock (void)
     134             : {
     135           0 :     if (mxController.is())
     136           0 :         mxController->unlock();
     137           0 : }
     138             : 
     139             : 
     140             : 
     141             : 
     142             : //===== ConfigurationController ===============================================
     143             : 
     144           0 : ConfigurationController::ConfigurationController (void) throw()
     145             :     : ConfigurationControllerInterfaceBase(MutexOwner::maMutex)
     146             :     , mpImplementation()
     147           0 :     , mbIsDisposed(false)
     148             : {
     149           0 : }
     150             : 
     151           0 : ConfigurationController::~ConfigurationController (void) throw()
     152             : {
     153           0 : }
     154             : 
     155             : 
     156           0 : void SAL_CALL ConfigurationController::disposing (void)
     157             : {
     158           0 :     if (mpImplementation.get() == NULL)
     159           0 :         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           0 :     mpImplementation->mpQueueProcessor->Clear();
     166           0 :     restoreConfiguration(new Configuration(this,false));
     167           0 :     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           0 :     mbIsDisposed = true;
     173             : 
     174             :     // Release the listeners.
     175           0 :     lang::EventObject aEvent;
     176           0 :     aEvent.Source = uno::Reference<uno::XInterface>((cppu::OWeakObject*)this);
     177             : 
     178             :     {
     179           0 :         const SolarMutexGuard aSolarGuard;
     180           0 :         mpImplementation->mpBroadcaster->DisposeAndClear();
     181             :     }
     182             : 
     183           0 :     mpImplementation->mpQueueProcessor.reset();
     184           0 :     mpImplementation->mxRequestedConfiguration = NULL;
     185           0 :     mpImplementation.reset();
     186             : }
     187             : 
     188             : 
     189             : 
     190             : 
     191           0 : void ConfigurationController::ProcessEvent (void)
     192             : {
     193           0 :     if (mpImplementation.get() != NULL)
     194             :     {
     195             :         OSL_ASSERT(mpImplementation->mpQueueProcessor.get()!=NULL);
     196             : 
     197           0 :         mpImplementation->mpQueueProcessor->ProcessOneEvent();
     198             :     }
     199           0 : }
     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           0 : 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           0 :     ::osl::MutexGuard aGuard (maMutex);
     225             : 
     226           0 :     ThrowIfDisposed();
     227             :     OSL_ASSERT(mpImplementation.get()!=NULL);
     228           0 :     mpImplementation->mpBroadcaster->AddListener(rxListener, rsEventType, rUserData);
     229           0 : }
     230             : 
     231             : 
     232             : 
     233             : 
     234           0 : void SAL_CALL ConfigurationController::removeConfigurationChangeListener (
     235             :     const Reference<XConfigurationChangeListener>& rxListener)
     236             :     throw (RuntimeException, std::exception)
     237             : {
     238           0 :     ::osl::MutexGuard aGuard (maMutex);
     239             : 
     240           0 :     ThrowIfDisposed();
     241           0 :     mpImplementation->mpBroadcaster->RemoveListener(rxListener);
     242           0 : }
     243             : 
     244             : 
     245             : 
     246             : 
     247           0 : void SAL_CALL ConfigurationController::notifyEvent (
     248             :     const ConfigurationChangeEvent& rEvent)
     249             :     throw (RuntimeException, std::exception)
     250             : {
     251           0 :     ThrowIfDisposed();
     252           0 :     mpImplementation->mpBroadcaster->NotifyListeners(rEvent);
     253           0 : }
     254             : 
     255             : //----- XConfigurationController ----------------------------------------------
     256             : 
     257           0 : 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           0 :     ::osl::MutexGuard aGuard (maMutex);
     264           0 :     ThrowIfDisposed();
     265             : 
     266             : 
     267           0 :     ++mpImplementation->mnLockCount;
     268           0 :     if (mpImplementation->mpConfigurationUpdaterLock.get()==NULL)
     269           0 :         mpImplementation->mpConfigurationUpdaterLock
     270           0 :             = mpImplementation->mpConfigurationUpdater->GetLock();
     271           0 : }
     272             : 
     273             : 
     274             : 
     275             : 
     276           0 : void SAL_CALL ConfigurationController::unlock (void)
     277             :     throw (RuntimeException, std::exception)
     278             : {
     279           0 :     ::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           0 :     if (rBHelper.bDisposed)
     284           0 :         ThrowIfDisposed();
     285             : 
     286             :     OSL_ASSERT(mpImplementation->mnLockCount>0);
     287           0 :     --mpImplementation->mnLockCount;
     288           0 :     if (mpImplementation->mnLockCount == 0)
     289           0 :         mpImplementation->mpConfigurationUpdaterLock.reset();
     290           0 : }
     291             : 
     292             : 
     293             : 
     294             : 
     295           0 : void SAL_CALL ConfigurationController::requestResourceActivation (
     296             :     const Reference<XResourceId>& rxResourceId,
     297             :     ResourceActivationMode eMode)
     298             :     throw (RuntimeException, std::exception)
     299             : {
     300           0 :     ::osl::MutexGuard aGuard (maMutex);
     301           0 :        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           0 :     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           0 :         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           0 :     if (rxResourceId.is())
     321             :     {
     322           0 :         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           0 :                 mpImplementation->mxRequestedConfiguration->getResources(
     328           0 :                     rxResourceId->getAnchor(),
     329           0 :                     rxResourceId->getResourceTypePrefix(),
     330           0 :                     AnchorBindingMode_DIRECT));
     331             : 
     332           0 :             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           0 :                 if (rxResourceId->compareTo(aResourceList[nIndex]) == 0)
     338           0 :                     continue;
     339             : 
     340             :                 // Request the deactivation of a resource and all resources
     341             :                 // linked to it.
     342           0 :                 requestResourceDeactivation(aResourceList[nIndex]);
     343           0 :             }
     344             :         }
     345             : 
     346             :         Reference<XConfigurationChangeRequest> xRequest(
     347             :             new GenericConfigurationChangeRequest(
     348             :                 rxResourceId,
     349           0 :                 GenericConfigurationChangeRequest::Activation));
     350           0 :         postChangeRequest(xRequest);
     351           0 :     }
     352             : }
     353             : 
     354             : 
     355             : 
     356             : 
     357           0 : void SAL_CALL ConfigurationController::requestResourceDeactivation (
     358             :     const Reference<XResourceId>& rxResourceId)
     359             :     throw (RuntimeException, std::exception)
     360             : {
     361           0 :     ::osl::MutexGuard aGuard (maMutex);
     362           0 :     ThrowIfDisposed();
     363             : 
     364             :     SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ConfigurationController::requestResourceDeactivation() " <<
     365             :             OUStringToOString(
     366             :                 FrameworkHelper::ResourceIdToString(rxResourceId), RTL_TEXTENCODING_UTF8).getStr());
     367             : 
     368           0 :     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           0 :             mpImplementation->mxRequestedConfiguration->getResources(
     374             :                 rxResourceId,
     375             :                 OUString(),
     376           0 :                 AnchorBindingMode_DIRECT));
     377           0 :         const sal_Int32 nCount (aLinkedResources.getLength());
     378           0 :         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           0 :             requestResourceDeactivation(aLinkedResources[nIndex]);
     384             :         }
     385             : 
     386             :         // Add a deactivation request for the specified resource.
     387             :         Reference<XConfigurationChangeRequest> xRequest(
     388             :             new GenericConfigurationChangeRequest(
     389             :                 rxResourceId,
     390           0 :                 GenericConfigurationChangeRequest::Deactivation));
     391           0 :         postChangeRequest(xRequest);
     392           0 :     }
     393           0 : }
     394             : 
     395             : 
     396             : 
     397             : 
     398           0 : Reference<XResource> SAL_CALL ConfigurationController::getResource (
     399             :     const Reference<XResourceId>& rxResourceId)
     400             :     throw (RuntimeException, std::exception)
     401             : {
     402           0 :     ::osl::MutexGuard aGuard (maMutex);
     403           0 :     ThrowIfDisposed();
     404             : 
     405             :     ConfigurationControllerResourceManager::ResourceDescriptor aDescriptor (
     406           0 :         mpImplementation->mpResourceManager->GetResource(rxResourceId));
     407           0 :     return aDescriptor.mxResource;
     408             : }
     409             : 
     410             : 
     411             : 
     412             : 
     413           0 : void SAL_CALL ConfigurationController::update (void)
     414             :     throw (RuntimeException, std::exception)
     415             : {
     416           0 :     ::osl::MutexGuard aGuard (maMutex);
     417           0 :     ThrowIfDisposed();
     418             : 
     419           0 :     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           0 :         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           0 :     }
     430           0 : }
     431             : 
     432             : 
     433             : 
     434             : 
     435           0 : sal_Bool SAL_CALL ConfigurationController::hasPendingRequests (void)
     436             :     throw (RuntimeException, std::exception)
     437             : {
     438           0 :     ::osl::MutexGuard aGuard (maMutex);
     439           0 :     ThrowIfDisposed();
     440             : 
     441           0 :     return ! mpImplementation->mpQueueProcessor->IsEmpty();
     442             : }
     443             : 
     444             : 
     445             : 
     446             : 
     447             : 
     448           0 : void SAL_CALL ConfigurationController::postChangeRequest (
     449             :     const Reference<XConfigurationChangeRequest>& rxRequest)
     450             :     throw (RuntimeException, std::exception)
     451             : {
     452           0 :     ::osl::MutexGuard aGuard (maMutex);
     453           0 :     ThrowIfDisposed();
     454             : 
     455           0 :     mpImplementation->mpQueueProcessor->AddRequest(rxRequest);
     456           0 : }
     457             : 
     458             : 
     459             : 
     460             : 
     461           0 : Reference<XConfiguration> SAL_CALL ConfigurationController::getRequestedConfiguration (void)
     462             :     throw (RuntimeException, std::exception)
     463             : {
     464           0 :     ::osl::MutexGuard aGuard (maMutex);
     465           0 :     ThrowIfDisposed();
     466             : 
     467           0 :     if (mpImplementation->mxRequestedConfiguration.is())
     468             :         return Reference<XConfiguration>(
     469           0 :             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           0 : void SAL_CALL ConfigurationController::restoreConfiguration (
     498             :     const Reference<XConfiguration>& rxNewConfiguration)
     499             :     throw (RuntimeException, std::exception)
     500             : {
     501           0 :     ::osl::MutexGuard aGuard (maMutex);
     502           0 :     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           0 :         mpImplementation->mpConfigurationUpdater->GetLock());
     509             : 
     510             :     // Get lists of resources that are to be activated or deactivated.
     511           0 :     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           0 :     ConfigurationClassifier aClassifier (rxNewConfiguration, xCurrentConfiguration);
     518           0 :     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           0 :     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           0 :         aClassifier.GetC2minusC1());
     534           0 :     for (iResource=rResourcesToDeactivate.begin();
     535           0 :          iResource!=rResourcesToDeactivate.end();
     536             :          ++iResource)
     537             :     {
     538           0 :         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           0 :         aClassifier.GetC1minusC2());
     545           0 :     for (iResource=rResourcesToActivate.begin();
     546           0 :          iResource!=rResourcesToActivate.end();
     547             :          ++iResource)
     548             :     {
     549           0 :         requestResourceActivation(*iResource, ResourceActivationMode_ADD);
     550             :     }
     551             : 
     552           0 :     pLock.reset();
     553           0 : }
     554             : 
     555             : 
     556             : 
     557             : 
     558             : //----- XResourceFactoryManager -----------------------------------------------
     559             : 
     560           0 : void SAL_CALL ConfigurationController::addResourceFactory(
     561             :     const OUString& sResourceURL,
     562             :     const Reference<XResourceFactory>& rxResourceFactory)
     563             :     throw (RuntimeException, std::exception)
     564             : {
     565           0 :     ::osl::MutexGuard aGuard (maMutex);
     566           0 :     ThrowIfDisposed();
     567           0 :     mpImplementation->mpResourceFactoryContainer->AddFactory(sResourceURL, rxResourceFactory);
     568           0 : }
     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           0 : void SAL_CALL ConfigurationController::initialize (const Sequence<Any>& aArguments)
     613             :     throw (Exception, RuntimeException, std::exception)
     614             : {
     615           0 :     ::osl::MutexGuard aGuard (maMutex);
     616             : 
     617           0 :     if (aArguments.getLength() == 1)
     618             :     {
     619           0 :         const SolarMutexGuard aSolarGuard;
     620             : 
     621             :         mpImplementation.reset(new Implementation(
     622             :             *this,
     623           0 :             Reference<frame::XController>(aArguments[0], UNO_QUERY_THROW)));
     624           0 :     }
     625           0 : }
     626             : 
     627             : 
     628             : 
     629             : 
     630             : 
     631             : 
     632           0 : void ConfigurationController::ThrowIfDisposed (void) const
     633             :     throw (::com::sun::star::lang::DisposedException)
     634             : {
     635           0 :     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           0 :     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           0 : }
     648             : 
     649             : 
     650             : 
     651             : 
     652             : //===== ConfigurationController::Implementation ===============================
     653             : 
     654           0 : ConfigurationController::Implementation::Implementation (
     655             :     ConfigurationController& rController,
     656             :     const Reference<frame::XController>& rxController)
     657             :     : mxControllerManager(rxController, UNO_QUERY_THROW),
     658           0 :       mpBroadcaster(new ConfigurationControllerBroadcaster(&rController)),
     659           0 :       mxRequestedConfiguration(new Configuration(&rController, true)),
     660             :       mpBase(NULL),
     661           0 :       mpResourceFactoryContainer(new ResourceFactoryManager(mxControllerManager)),
     662             :       mpResourceManager(
     663           0 :           new ConfigurationControllerResourceManager(mpResourceFactoryContainer,mpBroadcaster)),
     664             :       mpConfigurationUpdater(
     665           0 :           new ConfigurationUpdater(mpBroadcaster, mpResourceManager,mxControllerManager)),
     666           0 :       mpQueueProcessor(new ChangeRequestQueueProcessor(&rController,mpConfigurationUpdater)),
     667             :       mpConfigurationUpdaterLock(),
     668           0 :       mnLockCount(0)
     669             : {
     670           0 :     mpQueueProcessor->SetConfiguration(mxRequestedConfiguration);
     671           0 : }
     672             : 
     673             : 
     674             : 
     675             : 
     676           0 : ConfigurationController::Implementation::~Implementation (void)
     677             : {
     678           0 : }
     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