LCOV - code coverage report
Current view: top level - sd/source/ui/framework/tools - FrameworkHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 219 376 58.2 %
Date: 2012-08-25 Functions: 40 59 67.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 178 647 27.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <osl/time.h>
      31                 :            : 
      32                 :            : #include "framework/FrameworkHelper.hxx"
      33                 :            : 
      34                 :            : #include "framework/ConfigurationController.hxx"
      35                 :            : #include "framework/ResourceId.hxx"
      36                 :            : #include "framework/ViewShellWrapper.hxx"
      37                 :            : #include "ViewShellBase.hxx"
      38                 :            : #include "FrameView.hxx"
      39                 :            : #include "DrawViewShell.hxx"
      40                 :            : #include "ViewShellHint.hxx"
      41                 :            : #include "DrawController.hxx"
      42                 :            : #include "app.hrc"
      43                 :            : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      44                 :            : #include <cppuhelper/compbase1.hxx>
      45                 :            : #include <svl/lstner.hxx>
      46                 :            : 
      47                 :            : #include <comphelper/stl_types.hxx>
      48                 :            : #include <sfx2/request.hxx>
      49                 :            : #include <sfx2/dispatch.hxx>
      50                 :            : 
      51                 :            : #include "MutexOwner.hxx"
      52                 :            : #include "vcl/svapp.hxx"
      53                 :            : #include <osl/doublecheckedlocking.h>
      54                 :            : #include <osl/getglobalmutex.hxx>
      55                 :            : #include <tools/diagnose_ex.h>
      56                 :            : #include <boost/unordered_map.hpp>
      57                 :            : 
      58                 :            : using namespace ::com::sun::star;
      59                 :            : using namespace ::com::sun::star::uno;
      60                 :            : using namespace ::com::sun::star::drawing::framework;
      61                 :            : 
      62                 :            : using ::rtl::OUString;
      63                 :            : 
      64                 :            : namespace {
      65                 :            : 
      66                 :            : 
      67                 :            : //----- CallbackCaller --------------------------------------------------------
      68                 :            : 
      69                 :            : typedef ::cppu::WeakComponentImplHelper1 <
      70                 :            :     ::com::sun::star::drawing::framework::XConfigurationChangeListener
      71                 :            :     > CallbackCallerInterfaceBase;
      72                 :            : 
      73                 :            : /** A CallbackCaller registers as listener at an XConfigurationController
      74                 :            :     object and waits for the notification of one type of event.  When that
      75                 :            :     event is received, or when the CallbackCaller detects at its
      76                 :            :     construction that the event will not be sent in the near future, the
      77                 :            :     actual callback object is called and the CallbackCaller destroys itself.
      78                 :            : */
      79                 :            : class CallbackCaller
      80                 :            :     : public ::sd::MutexOwner,
      81                 :            :       public CallbackCallerInterfaceBase
      82                 :            : {
      83                 :            : public:
      84                 :            :     /** Create a new CallbackCaller object.  This object controls its own
      85                 :            :         lifetime by acquiring a reference to itself in the constructor.
      86                 :            :         When it detects that the event will not be notified in the near
      87                 :            :         future (because the queue of pending configuration change operations
      88                 :            :         is empty and therefore no event will be sent int the near future, it
      89                 :            :         does not acquires a reference and thus initiates its destruction in
      90                 :            :         the constructor.)
      91                 :            :         @param rBase
      92                 :            :             This ViewShellBase object is used to determine the
      93                 :            :             XConfigurationController at which to register.
      94                 :            :         @param rsEventType
      95                 :            :             The event type which the callback is waiting for.
      96                 :            :         @param pCallback
      97                 :            :             The callback object which is to be notified.  The caller will
      98                 :            :             typically release his reference to the caller so that when the
      99                 :            :             CallbackCaller dies (after having called the callback) the
     100                 :            :             callback is destroyed.
     101                 :            :     */
     102                 :            :     CallbackCaller (
     103                 :            :         ::sd::ViewShellBase& rBase,
     104                 :            :         const OUString& rsEventType,
     105                 :            :         const ::sd::framework::FrameworkHelper::ConfigurationChangeEventFilter& rFilter,
     106                 :            :         const ::sd::framework::FrameworkHelper::Callback& rCallback);
     107                 :            :     virtual ~CallbackCaller (void);
     108                 :            : 
     109                 :            :     virtual void SAL_CALL disposing (void);
     110                 :            :     virtual void SAL_CALL disposing (const lang::EventObject& rEvent)
     111                 :            :         throw (RuntimeException);
     112                 :            :     virtual void SAL_CALL notifyConfigurationChange (const ConfigurationChangeEvent& rEvent)
     113                 :            :         throw (RuntimeException);
     114                 :            : 
     115                 :            : private:
     116                 :            :     OUString msEventType;
     117                 :            :     Reference<XConfigurationController> mxConfigurationController;
     118                 :            :     ::sd::framework::FrameworkHelper::ConfigurationChangeEventFilter maFilter;
     119                 :            :     ::sd::framework::FrameworkHelper::Callback maCallback;
     120                 :            : };
     121                 :            : 
     122                 :            : 
     123                 :            : 
     124                 :            : 
     125                 :            : //----- LifetimeController ----------------------------------------------------
     126                 :            : 
     127                 :            : typedef ::cppu::WeakComponentImplHelper1 <
     128                 :            :     ::com::sun::star::lang::XEventListener
     129                 :            :     > LifetimeControllerInterfaceBase;
     130                 :            : 
     131                 :            : /** This class helps controling the lifetime of the
     132                 :            :     FrameworkHelper. Register at a ViewShellBase object and an XController
     133                 :            :     object and call Dispose() at the associated FrameworkHelper object when
     134                 :            :     one of them and Release() when both of them are destroyed.
     135                 :            : */
     136                 :            : class LifetimeController
     137                 :            :     : public ::sd::MutexOwner,
     138                 :            :       public LifetimeControllerInterfaceBase,
     139                 :            :       public SfxListener
     140                 :            : {
     141                 :            : public:
     142                 :            :     explicit LifetimeController (::sd::ViewShellBase& rBase);
     143                 :            :     virtual ~LifetimeController (void);
     144                 :            : 
     145                 :            :     virtual void SAL_CALL disposing (void);
     146                 :            : 
     147                 :            :     /** XEventListener.  This method is called when the frame::XController
     148                 :            :         is being destroyed.
     149                 :            :     */
     150                 :            :     virtual void SAL_CALL disposing (const lang::EventObject& rEvent)
     151                 :            :         throw (RuntimeException);
     152                 :            : 
     153                 :            :     /** This method is called when the ViewShellBase is being destroyed.
     154                 :            :     */
     155                 :            :     virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint);
     156                 :            : 
     157                 :            : private:
     158                 :            :     ::sd::ViewShellBase& mrBase;
     159                 :            :     bool mbListeningToViewShellBase;
     160                 :            :     bool mbListeningToController;
     161                 :            : 
     162                 :            :     /** When one or both of the mbListeningToViewShellBase and
     163                 :            :         mbListeningToController members were modified then call this method
     164                 :            :         to either dispose or release the associated FrameworkHelper.
     165                 :            :     */
     166                 :            :     void Update (void);
     167                 :            : };
     168                 :            : 
     169                 :            : 
     170                 :            : 
     171                 :            : } // end of anonymous namespace
     172                 :            : 
     173                 :            : namespace sd { namespace framework {
     174                 :            : 
     175                 :            : // Pane URLS.
     176                 :            : 
     177                 :         25 : const OUString FrameworkHelper::msPaneURLPrefix("private:resource/pane/");
     178                 :         25 : const OUString FrameworkHelper::msCenterPaneURL( msPaneURLPrefix + "CenterPane");
     179                 :         25 : const OUString FrameworkHelper::msFullScreenPaneURL( msPaneURLPrefix + "FullScreenPane");
     180                 :         25 : const OUString FrameworkHelper::msLeftImpressPaneURL( msPaneURLPrefix + "LeftImpressPane");
     181                 :         25 : const OUString FrameworkHelper::msLeftDrawPaneURL( msPaneURLPrefix + "LeftDrawPane");
     182                 :         25 : const OUString FrameworkHelper::msRightPaneURL( msPaneURLPrefix + "RightPane");
     183                 :            : 
     184                 :            : 
     185                 :            : // View URLs.
     186                 :            : 
     187                 :         25 : const OUString FrameworkHelper::msViewURLPrefix("private:resource/view/");
     188                 :         25 : const OUString FrameworkHelper::msImpressViewURL( msViewURLPrefix + "ImpressView");
     189                 :         25 : const OUString FrameworkHelper::msDrawViewURL( msViewURLPrefix + "GraphicView");
     190                 :         25 : const OUString FrameworkHelper::msOutlineViewURL( msViewURLPrefix + "OutlineView");
     191                 :         25 : const OUString FrameworkHelper::msNotesViewURL( msViewURLPrefix + "NotesView");
     192                 :         25 : const OUString FrameworkHelper::msHandoutViewURL( msViewURLPrefix + "HandoutView");
     193                 :         25 : const OUString FrameworkHelper::msSlideSorterURL( msViewURLPrefix + "SlideSorter");
     194                 :         25 : const OUString FrameworkHelper::msPresentationViewURL( msViewURLPrefix + "PresentationView");
     195                 :         25 : const OUString FrameworkHelper::msTaskPaneURL( msViewURLPrefix + "TaskPane");
     196                 :            : 
     197                 :            : 
     198                 :            : // Tool bar URLs.
     199                 :            : 
     200                 :         25 : const OUString FrameworkHelper::msToolBarURLPrefix("private:resource/toolbar/");
     201                 :         25 : const OUString FrameworkHelper::msViewTabBarURL( msToolBarURLPrefix + "ViewTabBar");
     202                 :            : 
     203                 :            : 
     204                 :            : // Task panel URLs.
     205                 :         25 : const ::rtl::OUString FrameworkHelper::msTaskPanelURLPrefix("private:resource/toolpanel/DrawingFramework/");
     206                 :         25 : const ::rtl::OUString FrameworkHelper::msMasterPagesTaskPanelURL( msTaskPanelURLPrefix + "MasterPages");
     207                 :         25 : const ::rtl::OUString FrameworkHelper::msLayoutTaskPanelURL( msTaskPanelURLPrefix + "Layouts");
     208                 :         25 : const ::rtl::OUString FrameworkHelper::msTableDesignPanelURL( msTaskPanelURLPrefix + "TableDesign");
     209                 :         25 : const ::rtl::OUString FrameworkHelper::msCustomAnimationTaskPanelURL( msTaskPanelURLPrefix + "CustomAnimations");
     210                 :         25 : const ::rtl::OUString FrameworkHelper::msSlideTransitionTaskPanelURL( msTaskPanelURLPrefix + "SlideTransitions");
     211                 :            : 
     212                 :            : 
     213                 :            : // Event URLs.
     214                 :         25 : const OUString FrameworkHelper::msResourceActivationRequestEvent("ResourceActivationRequested");
     215                 :         25 : const OUString FrameworkHelper::msResourceDeactivationRequestEvent("ResourceDeactivationRequest");
     216                 :         25 : const OUString FrameworkHelper::msResourceActivationEvent("ResourceActivation");
     217                 :         25 : const OUString FrameworkHelper::msResourceDeactivationEvent("ResourceDeactivation");
     218                 :         25 : const OUString FrameworkHelper::msConfigurationUpdateStartEvent("ConfigurationUpdateStart");
     219                 :         25 : const OUString FrameworkHelper::msConfigurationUpdateEndEvent("ConfigurationUpdateEnd");
     220                 :            : 
     221                 :            : 
     222                 :            : // Service names of controllers.
     223                 :         25 : const OUString FrameworkHelper::msModuleControllerService("com.sun.star.drawing.framework.ModuleController");
     224                 :         25 : const OUString FrameworkHelper::msConfigurationControllerService("com.sun.star.drawing.framework.ConfigurationController");
     225                 :            : 
     226                 :            : //----- helper ----------------------------------------------------------------
     227                 :            : namespace
     228                 :            : {
     229                 :       7343 :     static ::boost::shared_ptr< ViewShell > lcl_getViewShell( const Reference< XResource >& i_rViewShellWrapper )
     230                 :            :     {
     231                 :       7343 :         ::boost::shared_ptr< ViewShell > pViewShell;
     232         [ +  + ]:       7343 :         if ( !i_rViewShellWrapper.is() )
     233                 :        520 :             return pViewShell;
     234                 :            : 
     235                 :            :         try
     236                 :            :         {
     237         [ +  - ]:       6823 :             Reference<lang::XUnoTunnel> xViewTunnel( i_rViewShellWrapper, UNO_QUERY_THROW );
     238                 :            :             pViewShell = reinterpret_cast< ViewShellWrapper* >(
     239 [ +  - ][ +  - ]:       6823 :                 xViewTunnel->getSomething( ViewShellWrapper::getUnoTunnelId() ) )->GetViewShell();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ #  # ]
     240                 :            :         }
     241         [ #  # ]:          0 :         catch( const Exception& )
     242                 :            :         {
     243                 :            :             DBG_UNHANDLED_EXCEPTION();
     244                 :            :         }
     245                 :       7343 :         return pViewShell;
     246                 :            :     }
     247                 :       7402 :     Reference< XResource > lcl_getFirstViewInPane( const Reference< XConfigurationController >& i_rConfigController,
     248                 :            :         const Reference< XResourceId >& i_rPaneId )
     249                 :            :     {
     250                 :            :         try
     251                 :            :         {
     252 [ +  - ][ +  - ]:       7402 :             Reference< XConfiguration > xConfiguration( i_rConfigController->getRequestedConfiguration(), UNO_SET_THROW );
                 [ +  - ]
     253         [ +  - ]:       7402 :             Sequence< Reference< XResourceId > > aViewIds( xConfiguration->getResources(
     254         [ +  - ]:       7402 :                 i_rPaneId, FrameworkHelper::msViewURLPrefix, AnchorBindingMode_DIRECT ) );
     255         [ +  + ]:       7402 :             if ( aViewIds.getLength() > 0 )
     256 [ +  - ][ +  - ]:       7402 :                 return i_rConfigController->getResource( aViewIds[0] );
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
                 [ #  # ]
     257                 :            :         }
     258                 :          0 :         catch( const Exception& )
     259                 :            :         {
     260                 :            :             DBG_UNHANDLED_EXCEPTION();
     261                 :            :         }
     262                 :       7402 :         return NULL;
     263                 :            :     }
     264                 :            : }
     265                 :            : 
     266                 :            : 
     267                 :            : //----- FrameworkHelper::ViewURLMap -------------------------------------------
     268                 :            : 
     269                 :            : /** The ViewURLMap is used to translate between the view URLs used by the
     270                 :            :     drawing framework and the enums defined in the ViewShell class.
     271                 :            : */
     272                 :         25 : class FrameworkHelper::ViewURLMap
     273                 :            :     : public ::boost::unordered_map<
     274                 :            :           rtl::OUString,
     275                 :            :           ViewShell::ShellType,
     276                 :            :           ::rtl::OUStringHash,
     277                 :            :           ::comphelper::UStringEqual>
     278                 :            : {
     279                 :            : public:
     280         [ +  - ]:         25 :     ViewURLMap (void) {}
     281                 :            : };
     282                 :            : 
     283                 :            : 
     284                 :            : 
     285                 :            : 
     286                 :            : //----- Framework::DiposeListener ---------------------------------------------
     287                 :            : 
     288                 :            : namespace {
     289                 :            :     typedef ::cppu::WeakComponentImplHelper1 <
     290                 :            :         ::com::sun::star::lang::XEventListener
     291                 :            :         > FrameworkHelperDisposeListenerInterfaceBase;
     292                 :            : }
     293                 :            : 
     294                 :            : class FrameworkHelper::DisposeListener
     295                 :            :     : public ::sd::MutexOwner,
     296                 :            :       public FrameworkHelperDisposeListenerInterfaceBase
     297                 :            : {
     298                 :            : public:
     299                 :            :     DisposeListener (const ::boost::shared_ptr<FrameworkHelper>& rpHelper);
     300                 :            :     ~DisposeListener (void);
     301                 :            : 
     302                 :            :     virtual void SAL_CALL disposing (void);
     303                 :            : 
     304                 :            :     virtual void SAL_CALL disposing (const lang::EventObject& rEventObject)
     305                 :            :         throw(RuntimeException);
     306                 :            : 
     307                 :            : private:
     308                 :            :     ::boost::shared_ptr<FrameworkHelper> mpHelper;
     309                 :            : };
     310                 :            : 
     311                 :            : 
     312                 :            : 
     313                 :            : 
     314                 :            : //----- FrameworkHelper -------------------------------------------------------
     315                 :            : 
     316         [ +  - ]:         25 : ::boost::scoped_ptr<FrameworkHelper::ViewURLMap> FrameworkHelper::mpViewURLMap(new ViewURLMap());
     317                 :            : 
     318                 :            : 
     319                 :         25 : FrameworkHelper::InstanceMap FrameworkHelper::maInstanceMap;
     320                 :            : 
     321                 :            : 
     322                 :            : 
     323                 :        156 : ::boost::shared_ptr<FrameworkHelper> FrameworkHelper::Instance (
     324                 :            :     const Reference<frame::XController>& rxController)
     325                 :            : {
     326                 :            :     // Tunnel through the controller to obtain a ViewShellBase.
     327         [ +  - ]:        156 :     Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
     328         [ +  - ]:        156 :     if (xTunnel.is())
     329                 :            :     {
     330                 :            :         ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
     331 [ +  - ][ +  - ]:        156 :             xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
                 [ +  - ]
     332         [ +  - ]:        156 :         if (pController != NULL)
     333                 :            :         {
     334         [ +  - ]:        156 :             ViewShellBase* pBase = pController->GetViewShellBase();
     335         [ +  - ]:        156 :             if (pBase != NULL)
     336         [ +  - ]:        156 :                 return Instance(*pBase);
     337                 :            :         }
     338                 :            :     }
     339                 :            : 
     340         [ #  # ]:        156 :     return ::boost::shared_ptr<FrameworkHelper>();
     341                 :            : }
     342                 :            : 
     343                 :            : 
     344                 :            : 
     345                 :            : 
     346                 :      10702 : ::boost::shared_ptr<FrameworkHelper> FrameworkHelper::Instance (ViewShellBase& rBase)
     347                 :            : {
     348                 :            : 
     349         [ +  - ]:      10702 :     ::boost::shared_ptr<FrameworkHelper> pHelper;
     350                 :            : 
     351         [ +  - ]:      10702 :     InstanceMap::const_iterator iHelper (maInstanceMap.find(&rBase));
     352         [ +  + ]:      10702 :     if (iHelper == maInstanceMap.end())
     353                 :            :     {
     354                 :            :         ::osl::GetGlobalMutex aMutexFunctor;
     355 [ +  - ][ +  - ]:        130 :         ::osl::MutexGuard aGuard (aMutexFunctor());
     356         [ +  - ]:        130 :         if (iHelper == maInstanceMap.end())
     357                 :            :         {
     358 [ +  - ][ +  - ]:        130 :             pHelper = ::boost::shared_ptr<FrameworkHelper>(new FrameworkHelper(rBase));
         [ +  - ][ +  - ]
                 [ +  - ]
     359         [ +  - ]:        130 :             pHelper->Initialize();
     360                 :            :             OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
     361 [ +  - ][ +  - ]:        130 :             SdGlobalResourceContainer::Instance().AddResource(pHelper);
         [ +  - ][ +  - ]
     362 [ +  - ][ +  - ]:        130 :             maInstanceMap[&rBase] = pHelper;
     363         [ +  - ]:        130 :         }
     364                 :            :     }
     365                 :            :     else
     366                 :            :     {
     367                 :            :         OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
     368         [ +  - ]:      10702 :         pHelper = iHelper->second;
     369                 :            :     }
     370                 :            : 
     371                 :      10702 :     return pHelper;
     372                 :            : }
     373                 :            : 
     374                 :            : 
     375                 :            : 
     376                 :            : 
     377                 :        130 : void FrameworkHelper::DisposeInstance (ViewShellBase& rBase)
     378                 :            : {
     379         [ +  - ]:        130 :     InstanceMap::iterator iHelper (maInstanceMap.find(&rBase));
     380         [ +  - ]:        130 :     if (iHelper != maInstanceMap.end())
     381                 :            :     {
     382         [ +  - ]:        130 :         iHelper->second->Dispose();
     383                 :            :     }
     384                 :        130 : }
     385                 :            : 
     386                 :            : 
     387                 :            : 
     388                 :            : 
     389                 :        130 : void FrameworkHelper::ReleaseInstance (ViewShellBase& rBase)
     390                 :            : {
     391         [ +  - ]:        130 :     InstanceMap::iterator iHelper (maInstanceMap.find(&rBase));
     392         [ +  - ]:        130 :     if (iHelper != maInstanceMap.end())
     393         [ +  - ]:        130 :         maInstanceMap.erase(iHelper);
     394                 :        130 : }
     395                 :            : 
     396                 :            : 
     397                 :            : 
     398                 :            : 
     399                 :        130 : FrameworkHelper::FrameworkHelper (ViewShellBase& rBase)
     400                 :            :     : mrBase(rBase),
     401                 :            :       mxConfigurationController(),
     402                 :        130 :       mxDisposeListener()
     403                 :            : 
     404                 :            : {
     405 [ +  - ][ +  - ]:        130 :     Reference<XControllerManager> xControllerManager (rBase.GetController(), UNO_QUERY);
     406         [ +  - ]:        130 :     if (xControllerManager.is())
     407                 :            :     {
     408 [ +  - ][ +  - ]:        130 :         mxConfigurationController = xControllerManager->getConfigurationController();
                 [ +  - ]
     409                 :            :     }
     410                 :            : 
     411         [ +  - ]:        130 :     new LifetimeController(mrBase);
     412                 :        130 : }
     413                 :            : 
     414                 :            : 
     415                 :            : 
     416                 :            : 
     417                 :        130 : void FrameworkHelper::Initialize (void)
     418                 :            : {
     419 [ +  - ][ +  - ]:        130 :     mxDisposeListener = new DisposeListener(shared_from_this());
                 [ +  - ]
     420                 :        130 : }
     421                 :            : 
     422                 :            : 
     423                 :            : 
     424                 :            : 
     425                 :        130 : FrameworkHelper::~FrameworkHelper (void)
     426                 :            : {
     427         [ -  + ]:        260 : }
     428                 :            : 
     429                 :            : 
     430                 :            : 
     431                 :            : 
     432                 :        130 : void FrameworkHelper::Dispose (void)
     433                 :            : {
     434         [ +  - ]:        130 :     if (mxDisposeListener.is())
     435                 :        130 :         mxDisposeListener->dispose();
     436                 :        130 :     mxConfigurationController = NULL;
     437                 :        130 : }
     438                 :            : 
     439                 :            : 
     440                 :            : 
     441                 :            : 
     442                 :          0 : bool FrameworkHelper::IsValid (void)
     443                 :            : {
     444                 :          0 :     return mxConfigurationController.is();
     445                 :            : }
     446                 :            : 
     447                 :            : 
     448                 :            : 
     449                 :            : 
     450                 :       9301 : ::boost::shared_ptr<ViewShell> FrameworkHelper::GetViewShell (const OUString& rsPaneURL)
     451                 :            : {
     452         [ +  + ]:       9301 :     if ( !mxConfigurationController.is() )
     453         [ +  - ]:       2218 :         return ::boost::shared_ptr<ViewShell>();
     454                 :            : 
     455         [ +  - ]:       7083 :     Reference<XResourceId> xPaneId( CreateResourceId( rsPaneURL ) );
     456 [ +  - ][ +  - ]:       9301 :     return lcl_getViewShell( lcl_getFirstViewInPane( mxConfigurationController, xPaneId ) );
     457                 :            : }
     458                 :            : 
     459                 :            : 
     460                 :            : 
     461                 :            : 
     462                 :        260 : ::boost::shared_ptr<ViewShell> FrameworkHelper::GetViewShell (const Reference<XView>& rxView)
     463                 :            : {
     464         [ +  - ]:        260 :     return lcl_getViewShell( rxView.get() );
     465                 :            : }
     466                 :            : 
     467                 :            : 
     468                 :            : 
     469                 :            : 
     470                 :        319 : Reference<XView> FrameworkHelper::GetView (const Reference<XResourceId>& rxPaneOrViewId)
     471                 :            : {
     472                 :        319 :     Reference<XView> xView;
     473                 :            : 
     474 [ -  + ][ -  + ]:        319 :     if ( ! rxPaneOrViewId.is() || ! mxConfigurationController.is())
                 [ +  - ]
     475         [ #  # ]:          0 :         return NULL;
     476                 :            : 
     477                 :            :     try
     478                 :            :     {
     479 [ +  - ][ +  - ]:        319 :         if (rxPaneOrViewId->getResourceURL().match(msViewURLPrefix))
                 [ -  + ]
     480                 :            :         {
     481 [ #  # ][ #  # ]:          0 :             xView.set( mxConfigurationController->getResource( rxPaneOrViewId ), UNO_QUERY );
                 [ #  # ]
     482                 :            :         }
     483                 :            :         else
     484                 :            :         {
     485 [ +  - ][ +  - ]:        319 :             xView.set( lcl_getFirstViewInPane( mxConfigurationController, rxPaneOrViewId ), UNO_QUERY );
     486                 :            :         }
     487                 :            :     }
     488   [ #  #  #  #  :          0 :     catch (lang::DisposedException&)
                      # ]
     489                 :            :     {
     490         [ #  # ]:          0 :         Dispose();
     491                 :            :     }
     492         [ #  # ]:          0 :     catch (RuntimeException&)
     493                 :            :     {
     494                 :            :     }
     495                 :            : 
     496                 :        319 :     return xView;
     497                 :            : }
     498                 :            : 
     499                 :            : 
     500                 :            : 
     501                 :            : 
     502                 :         26 : Reference<XResourceId> FrameworkHelper::RequestView (
     503                 :            :     const OUString& rsResourceURL,
     504                 :            :     const OUString& rsAnchorURL)
     505                 :            : {
     506                 :         26 :     Reference<XResourceId> xViewId;
     507                 :            : 
     508                 :            :     try
     509                 :            :     {
     510         [ +  - ]:         26 :         if (mxConfigurationController.is())
     511                 :            :         {
     512         [ +  - ]:         26 :             mxConfigurationController->requestResourceActivation(
     513                 :            :                 CreateResourceId(rsAnchorURL),
     514 [ +  - ][ +  - ]:         26 :                 ResourceActivationMode_ADD);
     515 [ +  - ][ +  - ]:         26 :             xViewId = CreateResourceId(rsResourceURL, rsAnchorURL);
     516         [ +  - ]:         26 :             mxConfigurationController->requestResourceActivation(
     517                 :            :                 xViewId,
     518         [ +  - ]:         26 :                 ResourceActivationMode_REPLACE);
     519                 :            :         }
     520                 :            :     }
     521         [ #  # ]:          0 :     catch (lang::DisposedException&)
     522                 :            :     {
     523         [ #  # ]:          0 :         Dispose();
     524         [ #  # ]:          0 :         xViewId = NULL;
     525                 :            :     }
     526   [ #  #  #  #  :          0 :     catch (RuntimeException&)
                      # ]
     527                 :            :     {
     528         [ #  # ]:          0 :         xViewId = NULL;
     529                 :            :     }
     530                 :            : 
     531                 :         26 :     return xViewId;
     532                 :            : }
     533                 :            : 
     534                 :            : 
     535                 :            : 
     536                 :            : 
     537                 :         52 : void FrameworkHelper::RequestTaskPanel (
     538                 :            :     const OUString& rsTaskPanelURL,
     539                 :            :     const bool bEnsureTaskPaneIsVisible)
     540                 :            : {
     541                 :            :     try
     542                 :            :     {
     543         [ +  - ]:         52 :         if (mxConfigurationController.is())
     544                 :            :         {
     545                 :            :             // Check the existence of the task pane.
     546         [ -  + ]:         52 :             if ( ! bEnsureTaskPaneIsVisible)
     547                 :            :             {
     548                 :            :                 Reference<XConfiguration> xConfiguration (
     549 [ #  # ][ #  # ]:          0 :                     mxConfigurationController->getCurrentConfiguration());
     550         [ #  # ]:          0 :             if (xConfiguration.is())
     551   [ #  #  #  # ]:          0 :                 if ( ! xConfiguration->hasResource(
     552 [ #  # ][ #  # ]:          0 :                     CreateResourceId(msTaskPaneURL, msRightPaneURL)))
     553                 :            :                 {
     554                 :            :                     // Task pane does is not active.  Do not force it.
     555                 :         52 :                     return;
     556         [ #  # ]:          0 :                 }
     557                 :            :             }
     558                 :            : 
     559                 :            :             // Create the resource id from URLs for the pane, the task pane
     560                 :            :             // view, and the task panel.
     561         [ +  - ]:         52 :             mxConfigurationController->requestResourceActivation(
     562                 :            :                 CreateResourceId(msRightPaneURL),
     563 [ +  - ][ +  - ]:         52 :                 ResourceActivationMode_ADD);
     564         [ +  - ]:         52 :             mxConfigurationController->requestResourceActivation(
     565                 :            :                 CreateResourceId(msTaskPaneURL, msRightPaneURL),
     566 [ +  - ][ +  - ]:         52 :                 ResourceActivationMode_REPLACE);
     567         [ +  - ]:         52 :             mxConfigurationController->requestResourceActivation(
     568                 :            :                 CreateResourceId(rsTaskPanelURL, msTaskPaneURL, msRightPaneURL),
     569 [ +  - ][ +  - ]:         52 :                 ResourceActivationMode_REPLACE);
     570                 :            :         }
     571                 :            :     }
     572      [ #  #  # ]:          0 :     catch (lang::DisposedException&)
     573                 :            :     {
     574         [ #  # ]:          0 :         Dispose();
     575                 :            :     }
     576                 :          0 :     catch (RuntimeException&)
     577                 :            :     {}
     578                 :            : }
     579                 :            : 
     580                 :            : 
     581                 :            : 
     582                 :            : 
     583                 :        156 : ViewShell::ShellType FrameworkHelper::GetViewId (const rtl::OUString& rsViewURL)
     584                 :            : {
     585         [ +  + ]:        156 :     if (mpViewURLMap->empty())
     586                 :            :     {
     587         [ +  - ]:         16 :         (*mpViewURLMap)[msImpressViewURL] = ViewShell::ST_IMPRESS;
     588         [ +  - ]:         16 :         (*mpViewURLMap)[msDrawViewURL] = ViewShell::ST_DRAW;
     589         [ +  - ]:         16 :         (*mpViewURLMap)[msOutlineViewURL] = ViewShell::ST_OUTLINE;
     590         [ +  - ]:         16 :         (*mpViewURLMap)[msNotesViewURL] = ViewShell::ST_NOTES;
     591         [ +  - ]:         16 :         (*mpViewURLMap)[msHandoutViewURL] = ViewShell::ST_HANDOUT;
     592         [ +  - ]:         16 :         (*mpViewURLMap)[msSlideSorterURL] = ViewShell::ST_SLIDE_SORTER;
     593         [ +  - ]:         16 :         (*mpViewURLMap)[msPresentationViewURL] = ViewShell::ST_PRESENTATION;
     594         [ +  - ]:         16 :         (*mpViewURLMap)[msTaskPaneURL] = ViewShell::ST_TASK_PANE;
     595                 :            :     }
     596         [ +  - ]:        156 :     ViewURLMap::const_iterator iView (mpViewURLMap->find(rsViewURL));
     597 [ +  - ][ +  - ]:        156 :     if (iView != mpViewURLMap->end())
     598         [ +  - ]:        156 :         return iView->second;
     599                 :            :     else
     600                 :        156 :         return ViewShell::ST_NONE;
     601                 :            : }
     602                 :            : 
     603                 :            : 
     604                 :            : 
     605                 :            : 
     606                 :          0 : ::rtl::OUString FrameworkHelper::GetViewURL (ViewShell::ShellType eType)
     607                 :            : {
     608   [ #  #  #  #  :          0 :     switch (eType)
             #  #  #  #  
                      # ]
     609                 :            :     {
     610                 :          0 :         case ViewShell::ST_IMPRESS : return msImpressViewURL;
     611                 :          0 :         case ViewShell::ST_DRAW : return msDrawViewURL;
     612                 :          0 :         case ViewShell::ST_OUTLINE : return msOutlineViewURL;
     613                 :          0 :         case ViewShell::ST_NOTES : return msNotesViewURL;
     614                 :          0 :         case ViewShell::ST_HANDOUT : return msHandoutViewURL;
     615                 :          0 :         case ViewShell::ST_SLIDE_SORTER : return msSlideSorterURL;
     616                 :          0 :         case ViewShell::ST_PRESENTATION : return msPresentationViewURL;
     617                 :          0 :         case ViewShell::ST_TASK_PANE : return msTaskPaneURL;
     618                 :            :         default:
     619                 :          0 :             return OUString();
     620                 :            :     }
     621                 :            : }
     622                 :            : 
     623                 :            : 
     624                 :            : 
     625                 :            : 
     626                 :          0 : void FrameworkHelper::HandleModeChangeSlot (
     627                 :            :     sal_uLong nSlotId,
     628                 :            :     SfxRequest& rRequest)
     629                 :            : {
     630                 :          0 :     sal_Bool bIsActive = sal_True;
     631                 :            : 
     632         [ #  # ]:          0 :     if ( ! mxConfigurationController.is())
     633                 :          0 :         return;
     634                 :            : 
     635         [ #  # ]:          0 :     switch (nSlotId)
     636                 :            :     {
     637                 :            :         case SID_DRAWINGMODE:
     638                 :            :         case SID_NOTESMODE:
     639                 :            :         case SID_HANDOUTMODE:
     640                 :            :         case SID_DIAMODE:
     641                 :            :         case SID_OUTLINEMODE:
     642                 :            :         {
     643                 :          0 :             const SfxItemSet* pRequestArguments = rRequest.GetArgs();
     644         [ #  # ]:          0 :             if (pRequestArguments)
     645                 :            :             {
     646                 :          0 :                 SFX_REQUEST_ARG (rRequest,
     647                 :            :                     pIsActive,
     648                 :            :                     SfxBoolItem,
     649                 :            :                     (sal_uInt16)nSlotId,
     650                 :            :                     sal_False);
     651                 :          0 :                 bIsActive = pIsActive->GetValue ();
     652                 :            :             }
     653                 :            :         }
     654                 :          0 :         break;
     655                 :            :     }
     656                 :            : 
     657                 :            :     try
     658                 :            :     {
     659         [ #  # ]:          0 :         if ( ! mxConfigurationController.is())
     660         [ #  # ]:          0 :             throw RuntimeException();
     661                 :            : 
     662                 :            : 
     663                 :            :         Reference<XResourceId> xPaneId (
     664         [ #  # ]:          0 :             CreateResourceId(framework::FrameworkHelper::msCenterPaneURL));
     665         [ #  # ]:          0 :         Reference<XView> xView (GetView(xPaneId));
     666         [ #  # ]:          0 :         ::boost::shared_ptr<ViewShell> pCenterViewShell (GetViewShell(xView));
     667                 :            : 
     668                 :          0 :         ::rtl::OUString sRequestedView;
     669         [ #  # ]:          0 :         if (bIsActive)
     670                 :            :         {
     671   [ #  #  #  #  :          0 :             switch (nSlotId)
                   #  # ]
     672                 :            :             {
     673                 :            :                 case SID_NORMAL_MULTI_PANE_GUI:
     674                 :            :                 case SID_DRAWINGMODE:
     675                 :          0 :                     sRequestedView = FrameworkHelper::msImpressViewURL;
     676                 :          0 :                     break;
     677                 :            : 
     678                 :            :                 case SID_NOTESMODE:
     679                 :          0 :                     sRequestedView = FrameworkHelper::msNotesViewURL;
     680                 :          0 :                 break;
     681                 :            : 
     682                 :            :                 case SID_HANDOUTMODE:
     683                 :          0 :                     sRequestedView = FrameworkHelper::msHandoutViewURL;
     684                 :          0 :                     break;
     685                 :            : 
     686                 :            :                 case SID_SLIDE_SORTER_MULTI_PANE_GUI:
     687                 :            :                 case SID_DIAMODE:
     688                 :          0 :                     sRequestedView = FrameworkHelper::msSlideSorterURL;
     689                 :          0 :                     break;
     690                 :            : 
     691                 :            :                 case SID_OUTLINEMODE:
     692                 :          0 :                     sRequestedView = FrameworkHelper::msOutlineViewURL;
     693                 :          0 :                     break;
     694                 :            :             }
     695                 :            :         }
     696                 :            : 
     697   [ #  #  #  # ]:          0 :         if (xView.is()
                 [ #  # ]
     698 [ #  # ][ #  # ]:          0 :             && xView->getResourceId()->getResourceURL().equals(sRequestedView))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     699                 :            :         {
     700                 :            :             // We do not have to switch the view shell but maybe the edit mode
     701                 :            :             // has changed.
     702                 :            :             DrawViewShell* pDrawViewShell
     703         [ #  # ]:          0 :                 = dynamic_cast<DrawViewShell*>(pCenterViewShell.get());
     704         [ #  # ]:          0 :             if (pDrawViewShell != NULL)
     705                 :            :             {
     706                 :          0 :                 pCenterViewShell->Broadcast (
     707   [ #  #  #  # ]:          0 :                     ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START));
                 [ #  # ]
     708                 :            : 
     709                 :            :                 pDrawViewShell->ChangeEditMode (
     710 [ #  # ][ #  # ]:          0 :                     EM_PAGE, pDrawViewShell->IsLayerModeActive());
     711                 :            : 
     712                 :          0 :                 pCenterViewShell->Broadcast (
     713   [ #  #  #  # ]:          0 :                     ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END));
                 [ #  # ]
     714                 :            :             }
     715                 :            :         }
     716                 :            :         else
     717                 :            :         {
     718         [ #  # ]:          0 :             mxConfigurationController->requestResourceActivation(
     719                 :            :                 CreateResourceId(sRequestedView, msCenterPaneURL),
     720 [ #  # ][ #  # ]:          0 :                 ResourceActivationMode_REPLACE);
     721 [ #  # ][ #  # ]:          0 :         }
     722                 :            :     }
     723                 :          0 :     catch (RuntimeException&)
     724                 :            :     {
     725                 :            :         DBG_UNHANDLED_EXCEPTION();
     726                 :            :     }
     727                 :            : }
     728                 :            : 
     729                 :            : 
     730                 :            : 
     731                 :            : 
     732                 :          0 : void FrameworkHelper::RunOnConfigurationEvent(
     733                 :            :     const ::rtl::OUString& rsEventType,
     734                 :            :     const Callback& rCallback)
     735                 :            : {
     736                 :            :     RunOnEvent(
     737                 :            :         rsEventType,
     738                 :            :         FrameworkHelperAllPassFilter(),
     739 [ #  # ][ #  # ]:          0 :         rCallback);
                 [ #  # ]
     740                 :          0 : }
     741                 :            : 
     742                 :            : 
     743                 :            : 
     744                 :            : 
     745                 :          0 : void FrameworkHelper::RunOnResourceActivation(
     746                 :            :     const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
     747                 :            :     const Callback& rCallback)
     748                 :            : {
     749   [ #  #  #  # ]:          0 :     if (mxConfigurationController.is()
                 [ #  # ]
     750 [ #  # ][ #  # ]:          0 :         && mxConfigurationController->getResource(rxResourceId).is())
         [ #  # ][ #  # ]
     751                 :            :     {
     752                 :          0 :         rCallback(false);
     753                 :            :     }
     754                 :            :     else
     755                 :            :     {
     756                 :            :         RunOnEvent(
     757                 :            :             msResourceActivationEvent,
     758                 :            :             FrameworkHelperResourceIdFilter(rxResourceId),
     759 [ #  # ][ #  # ]:          0 :             rCallback);
                 [ #  # ]
     760                 :            :     }
     761                 :          0 : }
     762                 :            : 
     763                 :            : 
     764                 :            : 
     765                 :            : 
     766                 :            : /** A callback that sets a flag to a specified value when the callback is
     767                 :            :     called.
     768                 :            : */
     769                 :            : class FlagUpdater
     770                 :            : {
     771                 :            : public:
     772                 :          0 :     FlagUpdater (bool& rFlag) : mrFlag(rFlag) {}
     773                 :          0 :     void operator() (bool) const {mrFlag = true;}
     774                 :            : private:
     775                 :            :     bool& mrFlag;
     776                 :            : };
     777                 :            : 
     778                 :            : 
     779                 :            : 
     780                 :            : 
     781                 :          0 : void FrameworkHelper::RequestSynchronousUpdate (void)
     782                 :            : {
     783                 :            :     rtl::Reference<ConfigurationController> pCC (
     784 [ #  # ][ #  # ]:          0 :         dynamic_cast<ConfigurationController*>(mxConfigurationController.get()));
     785         [ #  # ]:          0 :     if (pCC.is())
     786         [ #  # ]:          0 :         pCC->RequestSynchronousUpdate();
     787                 :          0 : }
     788                 :            : 
     789                 :            : 
     790                 :            : 
     791                 :            : 
     792                 :          0 : void FrameworkHelper::WaitForEvent (const OUString& rsEventType) const
     793                 :            : {
     794                 :          0 :     bool bConfigurationUpdateSeen (false);
     795                 :            : 
     796                 :            :     RunOnEvent(
     797                 :            :         rsEventType,
     798                 :            :         FrameworkHelperAllPassFilter(),
     799 [ #  # ][ #  # ]:          0 :         FlagUpdater(bConfigurationUpdateSeen));
         [ #  # ][ #  # ]
                 [ #  # ]
     800                 :            : 
     801         [ #  # ]:          0 :     sal_uInt32 nStartTime = osl_getGlobalTimer();
     802         [ #  # ]:          0 :     while ( ! bConfigurationUpdateSeen)
     803                 :            :     {
     804         [ #  # ]:          0 :         Application::Reschedule();
     805                 :            : 
     806 [ #  # ][ #  # ]:          0 :         if( (osl_getGlobalTimer() - nStartTime) > 60000  )
     807                 :            :         {
     808                 :            :             OSL_FAIL("FrameworkHelper::WaitForEvent(), no event for a minute? giving up!");
     809                 :          0 :             break;
     810                 :            :         }
     811                 :            :     }
     812                 :          0 : }
     813                 :            : 
     814                 :            : 
     815                 :            : 
     816                 :            : 
     817                 :          0 : void FrameworkHelper::WaitForUpdate (void) const
     818                 :            : {
     819                 :          0 :     WaitForEvent(msConfigurationUpdateEndEvent);
     820                 :          0 : }
     821                 :            : 
     822                 :            : 
     823                 :            : 
     824                 :            : 
     825                 :          0 : void FrameworkHelper::RunOnEvent(
     826                 :            :     const ::rtl::OUString& rsEventType,
     827                 :            :     const ConfigurationChangeEventFilter& rFilter,
     828                 :            :     const Callback& rCallback) const
     829                 :            : {
     830         [ #  # ]:          0 :     new CallbackCaller(mrBase,rsEventType,rFilter,rCallback);
     831                 :          0 : }
     832                 :            : 
     833                 :            : 
     834                 :            : 
     835                 :            : 
     836                 :        130 : void FrameworkHelper::disposing (const lang::EventObject& rEventObject)
     837                 :            : {
     838         [ +  - ]:        130 :     if (rEventObject.Source == mxConfigurationController)
     839                 :        130 :         mxConfigurationController = NULL;
     840                 :        130 : }
     841                 :            : 
     842                 :            : 
     843                 :            : 
     844                 :            : 
     845                 :        624 : void FrameworkHelper::UpdateConfiguration (void)
     846                 :            : {
     847         [ +  + ]:        624 :     if (mxConfigurationController.is())
     848                 :            :     {
     849                 :            :         try
     850                 :            :         {
     851         [ +  - ]:        312 :             if (mxConfigurationController.is())
     852 [ +  - ][ +  - ]:        312 :                 mxConfigurationController->update();
     853                 :            :         }
     854      [ #  #  # ]:          0 :         catch (lang::DisposedException&)
     855                 :            :         {
     856         [ #  # ]:          0 :             Dispose();
     857                 :            :         }
     858                 :          0 :         catch (RuntimeException&)
     859                 :            :         {
     860                 :            :             DBG_UNHANDLED_EXCEPTION();
     861                 :            :         }
     862                 :            :     }
     863                 :        624 : }
     864                 :            : 
     865                 :            : 
     866                 :            : 
     867                 :            : 
     868                 :          0 : OUString FrameworkHelper::ResourceIdToString (const Reference<XResourceId>& rxResourceId)
     869                 :            : {
     870                 :          0 :     OUString sString;
     871         [ #  # ]:          0 :     if (rxResourceId.is())
     872                 :            :     {
     873 [ #  # ][ #  # ]:          0 :         sString += rxResourceId->getResourceURL();
     874 [ #  # ][ #  # ]:          0 :         if (rxResourceId->hasAnchor())
                 [ #  # ]
     875                 :            :         {
     876 [ #  # ][ #  # ]:          0 :             Sequence<OUString> aAnchorURLs (rxResourceId->getAnchorURLs());
     877         [ #  # ]:          0 :             for (sal_Int32 nIndex=0; nIndex < aAnchorURLs.getLength(); ++nIndex)
     878                 :            :             {
     879                 :          0 :                 sString += " | ";
     880         [ #  # ]:          0 :                 sString += aAnchorURLs[nIndex];
     881         [ #  # ]:          0 :             }
     882                 :            :         }
     883                 :            :     }
     884                 :          0 :     return sString;
     885                 :            : }
     886                 :            : 
     887                 :            : 
     888                 :            : 
     889                 :            : 
     890                 :       8331 : Reference<XResourceId> FrameworkHelper::CreateResourceId (const ::rtl::OUString& rsResourceURL)
     891                 :            : {
     892 [ +  - ][ +  - ]:       8331 :     return new ::sd::framework::ResourceId(rsResourceURL);
     893                 :            : }
     894                 :            : 
     895                 :            : 
     896                 :            : 
     897                 :            : 
     898                 :        568 : Reference<XResourceId> FrameworkHelper::CreateResourceId (
     899                 :            :     const OUString& rsResourceURL,
     900                 :            :     const OUString& rsAnchorURL)
     901                 :            : {
     902 [ +  - ][ +  - ]:        568 :     return new ::sd::framework::ResourceId(rsResourceURL, rsAnchorURL);
     903                 :            : }
     904                 :            : 
     905                 :            : 
     906                 :            : 
     907                 :            : 
     908                 :         52 : Reference<XResourceId> FrameworkHelper::CreateResourceId (
     909                 :            :     const OUString& rsResourceURL,
     910                 :            :     const OUString& rsFirstAnchorURL,
     911                 :            :     const OUString& rsSecondAnchorURL)
     912                 :            : {
     913         [ +  - ]:         52 :     ::std::vector<OUString> aAnchorURLs (2);
     914                 :         52 :     aAnchorURLs[0] = rsFirstAnchorURL;
     915                 :         52 :     aAnchorURLs[1] = rsSecondAnchorURL;
     916 [ +  - ][ +  - ]:         52 :     return new ::sd::framework::ResourceId(rsResourceURL, aAnchorURLs);
                 [ +  - ]
     917                 :            : }
     918                 :            : 
     919                 :            : 
     920                 :            : 
     921                 :            : 
     922                 :        234 : Reference<XResourceId> FrameworkHelper::CreateResourceId (
     923                 :            :     const ::rtl::OUString& rsResourceURL,
     924                 :            :     const Reference<XResourceId>& rxAnchorId)
     925                 :            : {
     926         [ +  - ]:        234 :     if (rxAnchorId.is())
     927                 :            :         return new ::sd::framework::ResourceId(
     928                 :            :             rsResourceURL,
     929                 :        234 :             rxAnchorId->getResourceURL(),
     930 [ +  - ][ +  - ]:        234 :             rxAnchorId->getAnchorURLs());
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     931                 :            :     else
     932 [ #  # ][ #  # ]:        234 :         return new ::sd::framework::ResourceId(rsResourceURL);
     933                 :            : }
     934                 :            : 
     935                 :            : 
     936                 :            : 
     937                 :            : 
     938                 :         78 : Reference<XConfigurationController> FrameworkHelper::GetConfigurationController (void) const
     939                 :            : {
     940                 :         78 :     return mxConfigurationController;
     941                 :            : }
     942                 :            : 
     943                 :            : 
     944                 :            : 
     945                 :            : 
     946                 :            : //----- FrameworkHelper::DisposeListener --------------------------------------
     947                 :            : 
     948                 :        130 : FrameworkHelper::DisposeListener::DisposeListener (
     949                 :            :     const ::boost::shared_ptr<FrameworkHelper>& rpHelper)
     950                 :            :     : FrameworkHelperDisposeListenerInterfaceBase(maMutex),
     951         [ +  - ]:        130 :       mpHelper(rpHelper)
     952                 :            : {
     953         [ +  - ]:        130 :     Reference<XComponent> xComponent (mpHelper->mxConfigurationController, UNO_QUERY);
     954         [ +  - ]:        130 :     if (xComponent.is())
     955 [ +  - ][ +  - ]:        130 :         xComponent->addEventListener(this);
                 [ +  - ]
     956                 :        130 : }
     957                 :            : 
     958                 :            : 
     959                 :            : 
     960                 :            : 
     961 [ +  - ][ +  - ]:        130 : FrameworkHelper::DisposeListener::~DisposeListener (void)
     962                 :            : {
     963         [ -  + ]:        260 : }
     964                 :            : 
     965                 :            : 
     966                 :            : 
     967                 :            : 
     968                 :        130 : void SAL_CALL FrameworkHelper::DisposeListener::disposing (void)
     969                 :            : {
     970         [ +  - ]:        130 :     Reference<XComponent> xComponent (mpHelper->mxConfigurationController, UNO_QUERY);
     971         [ -  + ]:        130 :     if (xComponent.is())
     972 [ #  # ][ #  # ]:          0 :         xComponent->removeEventListener(this);
                 [ #  # ]
     973                 :            : 
     974         [ +  - ]:        130 :     mpHelper.reset();
     975                 :        130 : }
     976                 :            : 
     977                 :            : 
     978                 :            : 
     979                 :            : 
     980                 :        130 : void SAL_CALL FrameworkHelper::DisposeListener::disposing (const lang::EventObject& rEventObject)
     981                 :            :     throw(RuntimeException)
     982                 :            : {
     983         [ +  - ]:        130 :     if (mpHelper.get() != NULL)
     984                 :        130 :         mpHelper->disposing(rEventObject);
     985                 :        130 : }
     986                 :            : 
     987                 :            : 
     988                 :            : 
     989                 :            : 
     990                 :            : //===== FrameworkHelperResourceIdFilter =======================================
     991                 :            : 
     992                 :          0 : FrameworkHelperResourceIdFilter::FrameworkHelperResourceIdFilter (
     993                 :            :     const Reference<XResourceId>& rxResourceId)
     994                 :          0 :     : mxResourceId(rxResourceId)
     995                 :            : {
     996                 :          0 : }
     997                 :            : 
     998                 :            : 
     999                 :            : } } // end of namespace sd::framework
    1000                 :            : 
    1001                 :            : namespace {
    1002                 :            : 
    1003                 :            : //===== CallbackCaller ========================================================
    1004                 :            : 
    1005                 :          0 : CallbackCaller::CallbackCaller (
    1006                 :            :     ::sd::ViewShellBase& rBase,
    1007                 :            :     const OUString& rsEventType,
    1008                 :            :     const ::sd::framework::FrameworkHelper::ConfigurationChangeEventFilter& rFilter,
    1009                 :            :     const ::sd::framework::FrameworkHelper::Callback& rCallback)
    1010                 :            :     : CallbackCallerInterfaceBase(MutexOwner::maMutex),
    1011                 :            :       msEventType(rsEventType),
    1012                 :            :       mxConfigurationController(),
    1013                 :            :       maFilter(rFilter),
    1014 [ #  # ][ #  # ]:          0 :       maCallback(rCallback)
    1015                 :            : {
    1016                 :            :     try
    1017                 :            :     {
    1018 [ #  # ][ #  # ]:          0 :         Reference<XControllerManager> xControllerManager (rBase.GetController(), UNO_QUERY_THROW);
    1019 [ #  # ][ #  # ]:          0 :         mxConfigurationController = xControllerManager->getConfigurationController();
                 [ #  # ]
    1020         [ #  # ]:          0 :         if (mxConfigurationController.is())
    1021                 :            :         {
    1022 [ #  # ][ #  # ]:          0 :             if (mxConfigurationController->hasPendingRequests())
                 [ #  # ]
    1023 [ #  # ][ #  # ]:          0 :                 mxConfigurationController->addConfigurationChangeListener(this,msEventType,Any());
                 [ #  # ]
    1024                 :            :             else
    1025                 :            :             {
    1026                 :            :                 // There are no requests waiting to be processed.  Therefore
    1027                 :            :                 // no event, especially not the one we are waiting for, will
    1028                 :            :                 // be sent in the near future and the callback would never be
    1029                 :            :                 // called.
    1030                 :            :                 // Call the callback now and tell him that the event it is
    1031                 :            :                 // waiting for was not sent.
    1032         [ #  # ]:          0 :                 mxConfigurationController = NULL;
    1033         [ #  # ]:          0 :                 maCallback(false);
    1034                 :            :             }
    1035         [ #  # ]:          0 :         }
    1036                 :            :     }
    1037         [ #  # ]:          0 :     catch (RuntimeException&)
    1038                 :            :     {
    1039                 :            :         DBG_UNHANDLED_EXCEPTION();
    1040                 :            :     }
    1041                 :          0 : }
    1042                 :            : 
    1043                 :            : 
    1044                 :            : 
    1045                 :            : 
    1046 [ #  # ][ #  # ]:          0 : CallbackCaller::~CallbackCaller (void)
                 [ #  # ]
    1047                 :            : {
    1048         [ #  # ]:          0 : }
    1049                 :            : 
    1050                 :            : 
    1051                 :            : 
    1052                 :            : 
    1053                 :          0 : void CallbackCaller::disposing (void)
    1054                 :            : {
    1055                 :            :     try
    1056                 :            :     {
    1057         [ #  # ]:          0 :         if (mxConfigurationController.is())
    1058                 :            :         {
    1059                 :          0 :             Reference<XConfigurationController> xCC (mxConfigurationController);
    1060         [ #  # ]:          0 :             mxConfigurationController = NULL;
    1061 [ #  # ][ #  # ]:          0 :             xCC->removeConfigurationChangeListener(this);
         [ #  # ][ #  # ]
    1062                 :            :         }
    1063                 :            :     }
    1064                 :          0 :     catch (RuntimeException&)
    1065                 :            :     {
    1066                 :            :         DBG_UNHANDLED_EXCEPTION();
    1067                 :            :     }
    1068                 :          0 : }
    1069                 :            : 
    1070                 :            : 
    1071                 :            : 
    1072                 :            : 
    1073                 :          0 : void SAL_CALL CallbackCaller::disposing (const lang::EventObject& rEvent)
    1074                 :            :     throw (RuntimeException)
    1075                 :            : {
    1076         [ #  # ]:          0 :     if (rEvent.Source == mxConfigurationController)
    1077                 :            :     {
    1078                 :          0 :         mxConfigurationController = NULL;
    1079                 :          0 :         maCallback(false);
    1080                 :            :     }
    1081                 :          0 : }
    1082                 :            : 
    1083                 :            : 
    1084                 :            : 
    1085                 :            : 
    1086                 :          0 : void SAL_CALL CallbackCaller::notifyConfigurationChange (
    1087                 :            :     const ConfigurationChangeEvent& rEvent)
    1088                 :            :     throw (RuntimeException)
    1089                 :            : {
    1090 [ #  # ][ #  # ]:          0 :     if (rEvent.Type.equals(msEventType) && maFilter(rEvent))
                 [ #  # ]
    1091                 :            :     {
    1092                 :          0 :         maCallback(true);
    1093         [ #  # ]:          0 :         if (mxConfigurationController.is())
    1094                 :            :         {
    1095                 :            :             // Reset the reference to the configuration controller so that
    1096                 :            :             // dispose() will not try to remove the listener a second time.
    1097                 :          0 :             Reference<XConfigurationController> xCC (mxConfigurationController);
    1098         [ #  # ]:          0 :             mxConfigurationController = NULL;
    1099                 :            : 
    1100                 :            :             // Removing this object from the controller may very likely lead
    1101                 :            :             // to its destruction, so no calls after that.
    1102 [ #  # ][ #  # ]:          0 :             xCC->removeConfigurationChangeListener(this);
                 [ #  # ]
    1103                 :            :         }
    1104                 :            :     }
    1105                 :          0 : }
    1106                 :            : 
    1107                 :            : 
    1108                 :            : 
    1109                 :            : 
    1110                 :            : //----- LifetimeController -------------------------------------------------
    1111                 :            : 
    1112                 :        130 : LifetimeController::LifetimeController (::sd::ViewShellBase& rBase)
    1113                 :            :     : LifetimeControllerInterfaceBase(maMutex),
    1114                 :            :       mrBase(rBase),
    1115                 :            :       mbListeningToViewShellBase(false),
    1116         [ +  - ]:        130 :       mbListeningToController(false)
    1117                 :            : {
    1118                 :            :     // Register as listener at the ViewShellBase.  Because that is not done
    1119                 :            :     // via a reference we have to increase the reference count manually.
    1120                 :            :     // This is necessary even though listening to the XController did
    1121                 :            :     // increase the reference count because the controller may release its
    1122                 :            :     // reference to us before the ViewShellBase is destroyed.
    1123         [ +  - ]:        130 :     StartListening(mrBase);
    1124                 :        130 :     acquire();
    1125                 :        130 :     mbListeningToViewShellBase = true;
    1126                 :            : 
    1127 [ +  - ][ +  - ]:        130 :     Reference<XComponent> xComponent (rBase.GetController(), UNO_QUERY);
    1128         [ +  - ]:        130 :     if (xComponent.is())
    1129                 :            :     {
    1130 [ +  - ][ +  - ]:        130 :         xComponent->addEventListener(this);
                 [ +  - ]
    1131                 :        130 :         mbListeningToController = true;
    1132                 :        130 :     }
    1133                 :        130 : }
    1134                 :            : 
    1135                 :            : 
    1136                 :            : 
    1137                 :            : 
    1138 [ +  - ][ +  - ]:        130 : LifetimeController::~LifetimeController (void)
    1139                 :            : {
    1140                 :            :     OSL_ASSERT(!mbListeningToController && !mbListeningToViewShellBase);
    1141         [ -  + ]:        260 : }
    1142                 :            : 
    1143                 :            : 
    1144                 :            : 
    1145                 :            : 
    1146                 :        130 : void LifetimeController::disposing (void)
    1147                 :            : {
    1148                 :        130 : }
    1149                 :            : 
    1150                 :            : 
    1151                 :            : 
    1152                 :            : 
    1153                 :        130 : void SAL_CALL LifetimeController::disposing (const lang::EventObject& rEvent)
    1154                 :            :     throw(RuntimeException)
    1155                 :            : {
    1156                 :            :     (void)rEvent;
    1157                 :        130 :     mbListeningToController = false;
    1158                 :        130 :     Update();
    1159                 :        130 : }
    1160                 :            : 
    1161                 :            : 
    1162                 :            : 
    1163                 :            : 
    1164                 :        130 : void LifetimeController::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint)
    1165                 :            : {
    1166                 :            :     (void)rBroadcaster;
    1167         [ -  + ]:        130 :     const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
    1168 [ +  - ][ +  - ]:        130 :     if (pSimpleHint != NULL && pSimpleHint->GetId() == SFX_HINT_DYING)
                 [ +  - ]
    1169                 :            :     {
    1170                 :        130 :         mbListeningToViewShellBase = false;
    1171                 :        130 :         Update();
    1172                 :        130 :         release();
    1173                 :            :     }
    1174                 :        130 : }
    1175                 :            : 
    1176                 :            : 
    1177                 :            : 
    1178                 :            : 
    1179                 :        260 : void LifetimeController::Update (void)
    1180                 :            : {
    1181 [ +  + ][ -  + ]:        260 :     if (mbListeningToViewShellBase && mbListeningToController)
    1182                 :            :     {
    1183                 :            :         // Both the controller and the ViewShellBase are alive.  Keep
    1184                 :            :         // waiting for their destruction.
    1185                 :            :     }
    1186         [ +  + ]:        260 :     else if (mbListeningToViewShellBase)
    1187                 :            :     {
    1188                 :            :         // The controller has been destroyed but the ViewShellBase is still
    1189                 :            :         // alive.  Dispose the associated FrameworkHelper but keep it around
    1190                 :            :         // so that no new instance is created for the dying framework.
    1191                 :        130 :         ::sd::framework::FrameworkHelper::DisposeInstance(mrBase);
    1192                 :            :     }
    1193                 :            :     else
    1194                 :            :     {
    1195                 :            :         // Both the controller and the ViewShellBase have been destroyed.
    1196                 :            :         // Remove the FrameworkHelper so that the next call its Instance()
    1197                 :            :         // method can create a new instance.
    1198                 :        130 :         ::sd::framework::FrameworkHelper::ReleaseInstance(mrBase);
    1199                 :            :     }
    1200                 :        260 : }
    1201                 :            : 
    1202                 :            : 
    1203                 :            : 
    1204 [ +  - ][ +  - ]:         75 : } // end of anonymous namespace.
    1205                 :            : 
    1206                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10