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

Generated by: LCOV version 1.10