LCOV - code coverage report
Current view: top level - sd/source/ui/framework/module - ToolBarModule.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 72 0.0 %
Date: 2014-04-14 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 ::sd::framework::FrameworkHelper;
      33             : 
      34             : namespace {
      35             :     static const sal_Int32 gnConfigurationUpdateStartEvent(0);
      36             :     static const sal_Int32 gnConfigurationUpdateEndEvent(1);
      37             :     static const sal_Int32 gnResourceActivationRequestEvent(2);
      38             :     static const sal_Int32 gnResourceDeactivationRequestEvent(3);
      39             : }
      40             : 
      41             : namespace sd { namespace framework {
      42             : 
      43             : //===== ToolBarModule =========================================================
      44             : 
      45           0 : ToolBarModule::ToolBarModule (
      46             :     const Reference<frame::XController>& rxController)
      47             :     : ToolBarModuleInterfaceBase(m_aMutex),
      48             :       mxConfigurationController(),
      49             :       mpBase(NULL),
      50             :       mpToolBarManagerLock(),
      51           0 :       mbMainViewSwitchUpdatePending(false)
      52             : {
      53             :     // Tunnel through the controller to obtain a ViewShellBase.
      54           0 :     Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
      55           0 :     if (xTunnel.is())
      56             :     {
      57             :         ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
      58           0 :             xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
      59           0 :         if (pController != NULL)
      60           0 :             mpBase = pController->GetViewShellBase();
      61             :     }
      62             : 
      63           0 :     Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
      64           0 :     if (xControllerManager.is())
      65             :     {
      66           0 :         mxConfigurationController = xControllerManager->getConfigurationController();
      67           0 :         if (mxConfigurationController.is())
      68             :         {
      69           0 :             mxConfigurationController->addConfigurationChangeListener(
      70             :                 this,
      71             :                 FrameworkHelper::msConfigurationUpdateStartEvent,
      72           0 :                 makeAny(gnConfigurationUpdateStartEvent));
      73           0 :             mxConfigurationController->addConfigurationChangeListener(
      74             :                 this,
      75             :                 FrameworkHelper::msConfigurationUpdateEndEvent,
      76           0 :                 makeAny(gnConfigurationUpdateEndEvent));
      77           0 :             mxConfigurationController->addConfigurationChangeListener(
      78             :                 this,
      79             :                 FrameworkHelper::msResourceActivationRequestEvent,
      80           0 :                 makeAny(gnResourceActivationRequestEvent));
      81           0 :             mxConfigurationController->addConfigurationChangeListener(
      82             :                 this,
      83             :                 FrameworkHelper::msResourceDeactivationRequestEvent,
      84           0 :                 makeAny(gnResourceDeactivationRequestEvent));
      85             :         }
      86           0 :     }
      87           0 : }
      88             : 
      89             : 
      90             : 
      91             : 
      92           0 : ToolBarModule::~ToolBarModule (void)
      93             : {
      94           0 : }
      95             : 
      96             : 
      97             : 
      98             : 
      99           0 : void SAL_CALL ToolBarModule::disposing (void)
     100             : {
     101           0 :     if (mxConfigurationController.is())
     102           0 :         mxConfigurationController->removeConfigurationChangeListener(this);
     103             : 
     104           0 :     mxConfigurationController = NULL;
     105           0 : }
     106             : 
     107             : 
     108             : 
     109             : 
     110           0 : void SAL_CALL ToolBarModule::notifyConfigurationChange (
     111             :     const ConfigurationChangeEvent& rEvent)
     112             :     throw (RuntimeException, std::exception)
     113             : {
     114           0 :     if (mxConfigurationController.is())
     115             :     {
     116           0 :         sal_Int32 nEventType = 0;
     117           0 :         rEvent.UserData >>= nEventType;
     118           0 :         switch (nEventType)
     119             :         {
     120             :             case gnConfigurationUpdateStartEvent:
     121           0 :                 HandleUpdateStart();
     122           0 :                 break;
     123             : 
     124             :             case gnConfigurationUpdateEndEvent:
     125           0 :                 HandleUpdateEnd();
     126           0 :                 break;
     127             : 
     128             :             case gnResourceActivationRequestEvent:
     129             :             case gnResourceDeactivationRequestEvent:
     130             :                 // Remember the request for the activation or deactivation
     131             :                 // of the center pane view.  When that happens then on end
     132             :                 // of the next configuration update the set of visible tool
     133             :                 // bars will be updated.
     134           0 :                 if ( ! mbMainViewSwitchUpdatePending)
     135           0 :                     if (rEvent.ResourceId->getResourceURL().match(
     136           0 :                         FrameworkHelper::msViewURLPrefix)
     137           0 :                         && rEvent.ResourceId->isBoundToURL(
     138           0 :                             FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
     139             :                     {
     140           0 :                         mbMainViewSwitchUpdatePending = true;
     141             :                     }
     142           0 :                 break;
     143             :         }
     144             :     }
     145           0 : }
     146             : 
     147             : 
     148             : 
     149             : 
     150             : 
     151             : 
     152             : 
     153           0 : void ToolBarModule::HandleUpdateStart (void)
     154             : {
     155             :     // Lock the ToolBarManager and tell it to lock the ViewShellManager as
     156             :     // well.  This way the ToolBarManager can optimize the releasing of
     157             :     // locks and arranging of updates of both tool bars and the view shell
     158             :     // stack.
     159           0 :     if (mpBase != NULL)
     160             :     {
     161           0 :         ::boost::shared_ptr<ToolBarManager> pToolBarManager (mpBase->GetToolBarManager());
     162           0 :         mpToolBarManagerLock.reset(new ToolBarManager::UpdateLock(pToolBarManager));
     163           0 :         pToolBarManager->LockViewShellManager();
     164             :     }
     165           0 : }
     166             : 
     167             : 
     168             : 
     169             : 
     170           0 : void ToolBarModule::HandleUpdateEnd (void)
     171             : {
     172           0 :     if (mbMainViewSwitchUpdatePending)
     173             :     {
     174           0 :         mbMainViewSwitchUpdatePending = false;
     175             :         // Update the set of visible tool bars and deactivate those that are
     176             :         // no longer visible.  This is done before the old view shell is
     177             :         // destroyed in order to avoid unnecessary updates of those tool
     178             :         // bars.
     179           0 :         ::boost::shared_ptr<ToolBarManager> pToolBarManager (mpBase->GetToolBarManager());
     180             :         ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (
     181           0 :             FrameworkHelper::Instance(*mpBase));
     182             :         ViewShell* pViewShell
     183           0 :             = pFrameworkHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
     184           0 :         if (pViewShell != NULL)
     185             :         {
     186           0 :             pToolBarManager->MainViewShellChanged(*pViewShell);
     187             :             pToolBarManager->SelectionHasChanged(
     188             :                 *pViewShell,
     189           0 :                 *pViewShell->GetView());
     190           0 :             pToolBarManager->PreUpdate();
     191             :         }
     192             :         else
     193             :         {
     194           0 :             pToolBarManager->MainViewShellChanged(ViewShell::ST_NONE);
     195           0 :             pToolBarManager->PreUpdate();
     196           0 :         }
     197             :     }
     198             : 
     199             :     // Releasing the update lock of the ToolBarManager  will let the
     200             :     // ToolBarManager with the help of the ViewShellManager take care of
     201             :     // updating tool bars and view shell with the minimal amount of
     202             :     // shell stack modifications and tool bar updates.
     203           0 :     mpToolBarManagerLock.reset();
     204           0 : }
     205             : 
     206             : 
     207             : 
     208             : 
     209           0 : void SAL_CALL ToolBarModule::disposing (const lang::EventObject& rEvent)
     210             :     throw (RuntimeException, std::exception)
     211             : {
     212           0 :     if (mxConfigurationController.is()
     213           0 :         && rEvent.Source == mxConfigurationController)
     214             :     {
     215             :         // Without the configuration controller this class can do nothing.
     216           0 :         mxConfigurationController = NULL;
     217           0 :         dispose();
     218             :     }
     219           0 : }
     220             : 
     221             : 
     222             : 
     223             : 
     224             : } } // end of namespace sd::framework
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10