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

Generated by: LCOV version 1.11