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

Generated by: LCOV version 1.10