LCOV - code coverage report
Current view: top level - sd/source/ui/framework/module - ViewTabBarModule.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 78 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "ViewTabBarModule.hxx"
      22             : 
      23             : #include "framework/FrameworkHelper.hxx"
      24             : #include "framework/ConfigurationController.hxx"
      25             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      26             : #include <com/sun/star/drawing/framework/XTabBar.hpp>
      27             : 
      28             : #include "strings.hrc"
      29             : #include "sdresid.hxx"
      30             : 
      31             : 
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::drawing::framework;
      35             : 
      36             : using ::sd::framework::FrameworkHelper;
      37             : 
      38             : namespace {
      39             : 
      40             : static const sal_Int32 ResourceActivationRequestEvent = 0;
      41             : static const sal_Int32 ResourceDeactivationRequestEvent = 1;
      42             : static const sal_Int32 ResourceActivationEvent = 2;
      43             : 
      44             : }
      45             : 
      46             : namespace sd { namespace framework {
      47             : 
      48             : //===== ViewTabBarModule ==================================================
      49             : 
      50           0 : ViewTabBarModule::ViewTabBarModule (
      51             :     const Reference<frame::XController>& rxController,
      52             :     const Reference<XResourceId>& rxViewTabBarId)
      53             :     : ViewTabBarModuleInterfaceBase(MutexOwner::maMutex),
      54             :       mxConfigurationController(),
      55           0 :       mxViewTabBarId(rxViewTabBarId)
      56             : {
      57           0 :     Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
      58             : 
      59           0 :     if (xControllerManager.is())
      60             :     {
      61           0 :         mxConfigurationController = xControllerManager->getConfigurationController();
      62           0 :         if (mxConfigurationController.is())
      63             :         {
      64           0 :             mxConfigurationController->addConfigurationChangeListener(
      65             :                 this,
      66             :                 FrameworkHelper::msResourceActivationRequestEvent,
      67           0 :                 makeAny(ResourceActivationRequestEvent));
      68           0 :             mxConfigurationController->addConfigurationChangeListener(
      69             :                 this,
      70             :                 FrameworkHelper::msResourceDeactivationRequestEvent,
      71           0 :                 makeAny(ResourceDeactivationRequestEvent));
      72             : 
      73           0 :             UpdateViewTabBar(NULL);
      74           0 :             mxConfigurationController->addConfigurationChangeListener(
      75             :                 this,
      76             :                 FrameworkHelper::msResourceActivationEvent,
      77           0 :                 makeAny(ResourceActivationEvent));
      78             :         }
      79           0 :     }
      80           0 : }
      81             : 
      82             : 
      83             : 
      84             : 
      85           0 : ViewTabBarModule::~ViewTabBarModule (void)
      86             : {
      87           0 : }
      88             : 
      89             : 
      90             : 
      91             : 
      92           0 : void SAL_CALL ViewTabBarModule::disposing (void)
      93             : {
      94           0 :     if (mxConfigurationController.is())
      95           0 :         mxConfigurationController->removeConfigurationChangeListener(this);
      96             : 
      97           0 :     mxConfigurationController = NULL;
      98           0 : }
      99             : 
     100             : 
     101             : 
     102             : 
     103           0 : void SAL_CALL ViewTabBarModule::notifyConfigurationChange (
     104             :     const ConfigurationChangeEvent& rEvent)
     105             :     throw (RuntimeException, std::exception)
     106             : {
     107           0 :     if (mxConfigurationController.is())
     108             :     {
     109           0 :         sal_Int32 nEventType = 0;
     110           0 :         rEvent.UserData >>= nEventType;
     111           0 :         switch (nEventType)
     112             :         {
     113             :             case ResourceActivationRequestEvent:
     114           0 :                 if (mxViewTabBarId->isBoundTo(rEvent.ResourceId, AnchorBindingMode_DIRECT))
     115             :                 {
     116           0 :                     mxConfigurationController->requestResourceActivation(
     117             :                         mxViewTabBarId,
     118           0 :                         ResourceActivationMode_ADD);
     119             :                 }
     120           0 :                 break;
     121             : 
     122             :             case ResourceDeactivationRequestEvent:
     123           0 :                 if (mxViewTabBarId->isBoundTo(rEvent.ResourceId, AnchorBindingMode_DIRECT))
     124             :                 {
     125           0 :                     mxConfigurationController->requestResourceDeactivation(mxViewTabBarId);
     126             :                 }
     127           0 :                 break;
     128             : 
     129             :             case ResourceActivationEvent:
     130           0 :                 if (rEvent.ResourceId->compareTo(mxViewTabBarId) == 0)
     131             :                 {
     132           0 :                     UpdateViewTabBar(Reference<XTabBar>(rEvent.ResourceObject,UNO_QUERY));
     133             :                 }
     134             :         }
     135             :     }
     136           0 : }
     137             : 
     138             : 
     139             : 
     140             : 
     141           0 : void SAL_CALL ViewTabBarModule::disposing (
     142             :     const lang::EventObject& rEvent)
     143             :     throw (RuntimeException, std::exception)
     144             : {
     145           0 :     if (mxConfigurationController.is()
     146           0 :         && rEvent.Source == mxConfigurationController)
     147             :     {
     148             :         // Without the configuration controller this class can do nothing.
     149           0 :         mxConfigurationController = NULL;
     150           0 :         disposing();
     151             :     }
     152           0 : }
     153             : 
     154             : 
     155             : 
     156             : 
     157           0 : void ViewTabBarModule::UpdateViewTabBar (const Reference<XTabBar>& rxTabBar)
     158             : {
     159           0 :     if (mxConfigurationController.is())
     160             :     {
     161           0 :         Reference<XTabBar> xBar (rxTabBar);
     162           0 :         if ( ! xBar.is())
     163           0 :             xBar = Reference<XTabBar>(
     164           0 :                 mxConfigurationController->getResource(mxViewTabBarId), UNO_QUERY);
     165             : 
     166           0 :         if (xBar.is())
     167             :         {
     168           0 :             TabBarButton aEmptyButton;
     169             : 
     170           0 :             Reference<XResourceId> xAnchor (mxViewTabBarId->getAnchor());
     171             : 
     172           0 :             TabBarButton aImpressViewButton;
     173           0 :             aImpressViewButton.ResourceId = FrameworkHelper::CreateResourceId(
     174             :                 FrameworkHelper::msImpressViewURL,
     175           0 :                 xAnchor);
     176           0 :             aImpressViewButton.ButtonLabel = SD_RESSTR(STR_DRAW_MODE);
     177           0 :             if ( ! xBar->hasTabBarButton(aImpressViewButton))
     178           0 :                 xBar->addTabBarButtonAfter(aImpressViewButton, aEmptyButton);
     179             : 
     180           0 :             TabBarButton aOutlineViewButton;
     181           0 :             aOutlineViewButton.ResourceId = FrameworkHelper::CreateResourceId(
     182             :                 FrameworkHelper::msOutlineViewURL,
     183           0 :                 xAnchor);
     184           0 :             aOutlineViewButton.ButtonLabel = SD_RESSTR(STR_OUTLINE_MODE);
     185           0 :             if ( ! xBar->hasTabBarButton(aOutlineViewButton))
     186           0 :                 xBar->addTabBarButtonAfter(aOutlineViewButton, aImpressViewButton);
     187             : 
     188           0 :             TabBarButton aNotesViewButton;
     189           0 :             aNotesViewButton.ResourceId = FrameworkHelper::CreateResourceId(
     190             :                 FrameworkHelper::msNotesViewURL,
     191           0 :                 xAnchor);
     192           0 :             aNotesViewButton.ButtonLabel = SD_RESSTR(STR_NOTES_MODE);
     193           0 :             if ( ! xBar->hasTabBarButton(aNotesViewButton))
     194           0 :                 xBar->addTabBarButtonAfter(aNotesViewButton, aOutlineViewButton);
     195             : 
     196           0 :             TabBarButton aHandoutViewButton;
     197           0 :             aHandoutViewButton.ResourceId = FrameworkHelper::CreateResourceId(
     198             :                 FrameworkHelper::msHandoutViewURL,
     199           0 :                 xAnchor);
     200           0 :             aHandoutViewButton.ButtonLabel = SD_RESSTR(STR_HANDOUT_MODE);
     201           0 :             if ( ! xBar->hasTabBarButton(aHandoutViewButton))
     202           0 :                 xBar->addTabBarButtonAfter(aHandoutViewButton, aNotesViewButton);
     203           0 :         }
     204             :     }
     205           0 : }
     206             : 
     207             : 
     208             : 
     209             : 
     210             : } } // end of namespace sd::framework
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10