LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/framework/module - ToolBarModule.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 72 0.0 %
Date: 2012-12-27 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "ToolBarModule.hxx"
      22             : #include "ViewShellBase.hxx"
      23             : #include "DrawController.hxx"
      24             : #include "framework/FrameworkHelper.hxx"
      25             : #include "framework/ConfigurationController.hxx"
      26             : 
      27             : 
      28             : using namespace ::com::sun::star;
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::drawing::framework;
      31             : 
      32             : using ::rtl::OUString;
      33             : using ::sd::framework::FrameworkHelper;
      34             : 
      35             : namespace {
      36             :     static const sal_Int32 gnConfigurationUpdateStartEvent(0);
      37             :     static const sal_Int32 gnConfigurationUpdateEndEvent(1);
      38             :     static const sal_Int32 gnResourceActivationRequestEvent(2);
      39             :     static const sal_Int32 gnResourceDeactivationRequestEvent(3);
      40             : }
      41             : 
      42             : namespace sd { namespace framework {
      43             : 
      44             : //===== ToolBarModule =========================================================
      45             : 
      46           0 : ToolBarModule::ToolBarModule (
      47             :     const Reference<frame::XController>& rxController)
      48             :     : ToolBarModuleInterfaceBase(m_aMutex),
      49             :       mxConfigurationController(),
      50             :       mpBase(NULL),
      51             :       mpToolBarManagerLock(),
      52           0 :       mbMainViewSwitchUpdatePending(false)
      53             : {
      54             :     // Tunnel through the controller to obtain a ViewShellBase.
      55           0 :     Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
      56           0 :     if (xTunnel.is())
      57             :     {
      58             :         ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
      59           0 :             xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
      60           0 :         if (pController != NULL)
      61           0 :             mpBase = pController->GetViewShellBase();
      62             :     }
      63             : 
      64           0 :     Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
      65           0 :     if (xControllerManager.is())
      66             :     {
      67           0 :         mxConfigurationController = xControllerManager->getConfigurationController();
      68           0 :         if (mxConfigurationController.is())
      69             :         {
      70           0 :             mxConfigurationController->addConfigurationChangeListener(
      71             :                 this,
      72             :                 FrameworkHelper::msConfigurationUpdateStartEvent,
      73           0 :                 makeAny(gnConfigurationUpdateStartEvent));
      74           0 :             mxConfigurationController->addConfigurationChangeListener(
      75             :                 this,
      76             :                 FrameworkHelper::msConfigurationUpdateEndEvent,
      77           0 :                 makeAny(gnConfigurationUpdateEndEvent));
      78           0 :             mxConfigurationController->addConfigurationChangeListener(
      79             :                 this,
      80             :                 FrameworkHelper::msResourceActivationRequestEvent,
      81           0 :                 makeAny(gnResourceActivationRequestEvent));
      82           0 :             mxConfigurationController->addConfigurationChangeListener(
      83             :                 this,
      84             :                 FrameworkHelper::msResourceDeactivationRequestEvent,
      85           0 :                 makeAny(gnResourceDeactivationRequestEvent));
      86             :         }
      87           0 :     }
      88           0 : }
      89             : 
      90             : 
      91             : 
      92             : 
      93           0 : ToolBarModule::~ToolBarModule (void)
      94             : {
      95           0 : }
      96             : 
      97             : 
      98             : 
      99             : 
     100           0 : void SAL_CALL ToolBarModule::disposing (void)
     101             : {
     102           0 :     if (mxConfigurationController.is())
     103           0 :         mxConfigurationController->removeConfigurationChangeListener(this);
     104             : 
     105           0 :     mxConfigurationController = NULL;
     106           0 : }
     107             : 
     108             : 
     109             : 
     110             : 
     111           0 : void SAL_CALL ToolBarModule::notifyConfigurationChange (
     112             :     const ConfigurationChangeEvent& rEvent)
     113             :     throw (RuntimeException)
     114             : {
     115           0 :     if (mxConfigurationController.is())
     116             :     {
     117           0 :         sal_Int32 nEventType = 0;
     118           0 :         rEvent.UserData >>= nEventType;
     119           0 :         switch (nEventType)
     120             :         {
     121             :             case gnConfigurationUpdateStartEvent:
     122           0 :                 HandleUpdateStart();
     123           0 :                 break;
     124             : 
     125             :             case gnConfigurationUpdateEndEvent:
     126           0 :                 HandleUpdateEnd();
     127           0 :                 break;
     128             : 
     129             :             case gnResourceActivationRequestEvent:
     130             :             case gnResourceDeactivationRequestEvent:
     131             :                 // Remember the request for the activation or deactivation
     132             :                 // of the center pane view.  When that happens then on end
     133             :                 // of the next configuration update the set of visible tool
     134             :                 // bars will be updated.
     135           0 :                 if ( ! mbMainViewSwitchUpdatePending)
     136           0 :                     if (rEvent.ResourceId->getResourceURL().match(
     137           0 :                         FrameworkHelper::msViewURLPrefix)
     138           0 :                         && rEvent.ResourceId->isBoundToURL(
     139           0 :                             FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
     140             :                     {
     141           0 :                         mbMainViewSwitchUpdatePending = true;
     142             :                     }
     143           0 :                 break;
     144             :         }
     145             :     }
     146           0 : }
     147             : 
     148             : 
     149             : 
     150             : 
     151             : //-----------------------------------------------------------------------------
     152             : 
     153             : 
     154           0 : void ToolBarModule::HandleUpdateStart (void)
     155             : {
     156             :     // Lock the ToolBarManager and tell it to lock the ViewShellManager as
     157             :     // well.  This way the ToolBarManager can optimize the releasing of
     158             :     // locks and arranging of updates of both tool bars and the view shell
     159             :     // stack.
     160           0 :     if (mpBase != NULL)
     161             :     {
     162           0 :         ::boost::shared_ptr<ToolBarManager> pToolBarManager (mpBase->GetToolBarManager());
     163           0 :         mpToolBarManagerLock.reset(new ToolBarManager::UpdateLock(pToolBarManager));
     164           0 :         pToolBarManager->LockViewShellManager();
     165             :     }
     166           0 : }
     167             : 
     168             : 
     169             : 
     170             : 
     171           0 : void ToolBarModule::HandleUpdateEnd (void)
     172             : {
     173           0 :     if (mbMainViewSwitchUpdatePending)
     174             :     {
     175           0 :         mbMainViewSwitchUpdatePending = false;
     176             :         // Update the set of visible tool bars and deactivate those that are
     177             :         // no longer visible.  This is done before the old view shell is
     178             :         // destroyed in order to avoid unnecessary updates of those tool
     179             :         // bars.
     180           0 :         ::boost::shared_ptr<ToolBarManager> pToolBarManager (mpBase->GetToolBarManager());
     181             :         ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (
     182           0 :             FrameworkHelper::Instance(*mpBase));
     183             :         ViewShell* pViewShell
     184           0 :             = pFrameworkHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
     185           0 :         if (pViewShell != NULL)
     186             :         {
     187           0 :             pToolBarManager->MainViewShellChanged(*pViewShell);
     188             :             pToolBarManager->SelectionHasChanged(
     189             :                 *pViewShell,
     190           0 :                 *pViewShell->GetView());
     191           0 :             pToolBarManager->PreUpdate();
     192             :         }
     193             :         else
     194             :         {
     195           0 :             pToolBarManager->MainViewShellChanged(ViewShell::ST_NONE);
     196           0 :             pToolBarManager->PreUpdate();
     197           0 :         }
     198             :     }
     199             : 
     200             :     // Releasing the update lock of the ToolBarManager  will let the
     201             :     // ToolBarManager with the help of the ViewShellManager take care of
     202             :     // updating tool bars and view shell with the minimal amount of
     203             :     // shell stack modifications and tool bar updates.
     204           0 :     mpToolBarManagerLock.reset();
     205           0 : }
     206             : 
     207             : 
     208             : 
     209             : 
     210           0 : void SAL_CALL ToolBarModule::disposing (const lang::EventObject& rEvent)
     211             :     throw (RuntimeException)
     212             : {
     213           0 :     if (mxConfigurationController.is()
     214           0 :         && rEvent.Source == mxConfigurationController)
     215             :     {
     216             :         // Without the configuration controller this class can do nothing.
     217           0 :         mxConfigurationController = NULL;
     218           0 :         dispose();
     219             :     }
     220           0 : }
     221             : 
     222             : 
     223             : 
     224             : 
     225             : } } // end of namespace sd::framework
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10