LCOV - code coverage report
Current view: top level - sd/source/ui/inc - ToolBarManager.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 3 100.0 %
Date: 2015-06-13 12:38:46 Functions: 2 2 100.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             : #ifndef INCLUDED_SD_SOURCE_UI_INC_TOOLBARMANAGER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_INC_TOOLBARMANAGER_HXX
      22             : 
      23             : #include "ViewShell.hxx"
      24             : #include "ShellFactory.hxx"
      25             : #include <rtl/ustring.hxx>
      26             : #include <com/sun/star/frame/XFrame.hpp>
      27             : 
      28             : #include <sal/types.h>
      29             : #include <boost/scoped_ptr.hpp>
      30             : #include <boost/shared_ptr.hpp>
      31             : #include <boost/enable_shared_from_this.hpp>
      32             : 
      33             : class SdrView;
      34             : 
      35             : namespace sd { namespace tools {
      36             : class EventMultiplexer;
      37             : } }
      38             : 
      39             : namespace sd {
      40             : 
      41             : class ViewShellBase;
      42             : class ViewShellManager;
      43             : 
      44             : /** Manage the set of visible tool bars (and object bars).  Usually they
      45             :     belong to the current view in the center pane.
      46             : 
      47             :     Tool bars are managed in groups.  Each group can be set, reset, or
      48             :     modified independently of the others.  This allows for instance to
      49             :     replace the toolbars associated with the current function independently
      50             :     from those associated with the main view.
      51             : 
      52             :     The ToolBarManager has two high level methods which contain the
      53             :     knowledge about which tool bars to show in a specific context.
      54             :     When the view in the center pane changes then MainViewShellChanged()
      55             :     sets up the tool bars for the new view.  On changes of the selection the
      56             :     SelectionHasChanged() method shows the tool bars for the new context.
      57             : 
      58             :     The update of the actually visible tool bars to the set currently
      59             :     required by the main view shell and its functions is divided into two
      60             :     parts, PreUpdate() and PostUpdate().  This are to be called before
      61             :     respectively after the update of the view shell stack.  The reason for
      62             :     this is to save time by not updating tool bars that will not be visible
      63             :     in a short time on a view shell switch.
      64             : */
      65             : class ToolBarManager
      66             :     : public ::boost::enable_shared_from_this<ToolBarManager>
      67             : {
      68             : public:
      69             :     /** Use this method instead of the constructor to create new objects of
      70             :         this class.
      71             :     */
      72             :     static ::boost::shared_ptr<ToolBarManager> Create (
      73             :         ViewShellBase& rBase,
      74             :         const ::boost::shared_ptr<tools::EventMultiplexer>& rpMultiplexer,
      75             :         const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager);
      76             : 
      77             :     ~ToolBarManager();
      78             : 
      79             :     /** Call this method prior to the destructor to prevent the
      80             :         ToolBarManager from accessing the ViewShellManager or the
      81             :         XLayoutManager when those are possibly not well and alive anymore
      82             :         (like during the destruction of the ViewShellBase.)
      83             :     */
      84             :     void Shutdown();
      85             : 
      86             :     /** When the view in the center pane changes then this method sets up
      87             :         the initial set of tool bars for the new view.
      88             :         The ToolBarManager listenes for view switching itself and then calls
      89             :         MainViewShellChanged().  Calling this method from the outside should
      90             :         not be necessary.
      91             :         @param nShellType
      92             :             The type of the new main view shell.
      93             :     */
      94             :     void MainViewShellChanged (ViewShell::ShellType nShellType);
      95             :     void MainViewShellChanged (const ViewShell& rMainViewShell);
      96             : 
      97             :     /** Call this method when the selection has changed to update the more
      98             :         temporary tool bars (those in the TBG_FUNCTION group.)
      99             :     */
     100             :     void SelectionHasChanged (
     101             :         const ViewShell& rViewShell,
     102             :         const SdrView& rView);
     103             : 
     104             :     /** The set of tool bars that are handled by this manager class.
     105             :     */
     106             :     const static OUString msToolBar;                  // RID_DRAW_TOOLBOX, 23011
     107             :     const static OUString msOptionsToolBar;           // RID_DRAW_OPTIONS_TOOLBOX, 23020
     108             :     const static OUString msCommonTaskToolBar;        // RID_DRAW_COMMONTASK_TOOLBOX, 23021
     109             :     const static OUString msViewerToolBar;            // RID_DRAW_VIEWER_TOOLBOX, 23023
     110             :     const static OUString msSlideSorterToolBar;       // RID_SLIDE_TOOLBOX, 23012
     111             :     const static OUString msSlideSorterObjectBar;     // RID_SLIDE_OBJ_TOOLBOX, 23014
     112             :     const static OUString msOutlineToolBar;           // RID_OUTLINE_TOOLBOX, 23017
     113             :     const static OUString msMasterViewToolBar;        // SID_MASTERPAGE, 27053
     114             :     const static OUString msDrawingObjectToolBar;     // RID_DRAW_OBJ_TOOLBOX, 23013
     115             :     const static OUString msGluePointsToolBar;        // RID_GLUEPOINTS_TOOLBOX, 23019
     116             :     const static OUString msTextObjectBar;            // RID_DRAW_TEXT_TOOLBOX, 23016
     117             :     const static OUString msBezierObjectBar;          // RID_BEZIER_TOOLBOX, 23015
     118             :     const static OUString msGraphicObjectBar;         // RID_DRAW_GRAF_TOOLBOX, 23030
     119             :     const static OUString msMediaObjectBar;           // RID_DRAW_MEDIA_TOOLBOX, 23031
     120             :     const static OUString msTableObjectBar;           // RID_DRAW_TABLE_TOOLBOX
     121             : 
     122             :     /** The set of tool bar groups.
     123             :     */
     124             :     enum ToolBarGroup {
     125             :         TBG__FIRST,
     126             : 
     127             :         TBG_PERMANENT = TBG__FIRST,
     128             :         TBG_FUNCTION,
     129             :         TBG_COMMON_TASK,
     130             :         TBG_MASTER_MODE,
     131             : 
     132             :         TBG__LAST = TBG_MASTER_MODE
     133             :     };
     134             : 
     135             :     /** Reset the set of visible object bars in the specified group.  Tool
     136             :         bars in other groups are not affected.
     137             :         @param rParentShell
     138             :             When this shell is not the main view then the method returns
     139             :             immediately.
     140             :         @param eGroup
     141             :             Only the tool bars in this group are rest.
     142             :     */
     143             :     void ResetToolBars (ToolBarGroup eGroup);
     144             : 
     145             :     /** Reset all tool bars, regardless of the group they belong to.
     146             :         @param rParentShell
     147             :             When this shell is not the main view then the method returns
     148             :             immediately.
     149             :     */
     150             :     void ResetAllToolBars();
     151             : 
     152             :     /** Add the tool bar with the given name to the specified group of tool
     153             :         bars.
     154             :         @param rParentShell
     155             :             When this shell is not the main view then the method returns
     156             :             immediately.
     157             :         @param eGroup
     158             :             The new tool bar is added to this group.
     159             :         @param rsToolBarName
     160             :             The base name of the tool bar.  A proper prefix (like
     161             :             private:resource/toolbar/) is added.  The name may be one of the
     162             :             ones defined above.  Other names are allowed as well.
     163             :     */
     164             :     void AddToolBar (
     165             :         ToolBarGroup eGroup,
     166             :         const OUString& rsToolBarName);
     167             : 
     168             :     /** Add the tool bar shell to the shell stack.  This method basically
     169             :         forwards the call to the ViewShellManager.
     170             :         For some tool bar shells additional tool bars are made visible.
     171             :         @param rParentShell
     172             :             When this shell is not the main view then the method returns
     173             :             immediately.
     174             :         @param eGroup
     175             :             The group is used for the actual tool bars.
     176             :         @param nToolBarId
     177             :             Id of the tool bar shell.
     178             :     */
     179             :     void AddToolBarShell (
     180             :         ToolBarGroup eGroup,
     181             :         ShellId nToolBarId);
     182             : 
     183             :     /** Remove the tool bar with the given name from the specified group.
     184             :         If the tool bar is not visible then nothing happens.
     185             :         If the tool bar is a member of another group then nothing happens
     186             :         either.
     187             :     */
     188             :     void RemoveToolBar (
     189             :         ToolBarGroup eGroup,
     190             :         const OUString& rsToolBarName);
     191             : 
     192             :     /** This is basically a shortcut for ResetToolBars(),AddToolBar().  The
     193             :         main difference is, that all sub shells of the specified parent
     194             :         shell are deactivated as well.
     195             :         @param rParentShell
     196             :             When this shell is not the main view then the method returns
     197             :             immediately.
     198             :         @param eGroup
     199             :             The new tool bar is added to this group.
     200             :         @param rsToolBarName
     201             :             The base name of the tool bar.  A proper prefix (like
     202             :             private:resource/toolbar/) is added.  The name may be one of the
     203             :             ones defined above.  Other names are allowed as well.
     204             :     */
     205             :     void SetToolBar (
     206             :         ToolBarGroup eGroup,
     207             :         const OUString& rsToolBarName);
     208             : 
     209             :     /** This is basically a shortcut for ResetToolBars(),AddToolBar().  The
     210             :         main difference is, that all sub shells of the specified parent
     211             :         shell are deactivated as well.
     212             :         @param rParentShell
     213             :             When this shell is not the main view then the method returns
     214             :             immediately.
     215             :         @param rParentShell
     216             :             When this shell is not the main view then the method returns
     217             :             immediately.
     218             :         @param eGroup
     219             :             The group is currently not used.
     220             :         @param nToolBarId
     221             :             Id of the tool bar shell.
     222             :     */
     223             :     void SetToolBarShell (
     224             :         ToolBarGroup eGroup,
     225             :         ShellId nToolBarId);
     226             : 
     227             :     void PreUpdate();
     228             : 
     229             :     /** Request an update of the active tool bars.  The update is made
     230             :         asynchronously.
     231             :     */
     232             :     void RequestUpdate();
     233             : 
     234             :     /** This is a hint for the ToolBarManager to improve the performance
     235             :         when it updates its tool bars when its own lock is released.  Taking
     236             :         control of the release of the update lock of the ViewShellManager
     237             :         avoids some shell stack modifications and tool bar updates.
     238             :     */
     239             :     void LockViewShellManager();
     240             : 
     241             :     /** Use this class to prevent the visible tool bars from being updated
     242             :         (and thus causing repaints and GUI rearrangements) when several tool
     243             :         bar operations are made in a row.
     244             :     */
     245             :     class UpdateLock { public:
     246        4336 :         UpdateLock(const ::boost::shared_ptr<ToolBarManager>& rpManager)
     247        4336 :             : mpManager(rpManager) { mpManager->LockUpdate(); }
     248        4336 :         ~UpdateLock() { mpManager->UnlockUpdate(); }
     249             :     private:
     250             :         ::boost::shared_ptr<ToolBarManager> mpManager;
     251             :     };
     252             :     friend class UpdateLock;
     253             : 
     254             :     void ToolBarsDestroyed();
     255             : 
     256             : private:
     257             :     class Implementation;
     258             :     ::boost::scoped_ptr<Implementation> mpImpl;
     259             : 
     260             :     /** The ViewShellBase is used to get the XLayoutManager and to determine
     261             :         the plug in mode.
     262             :     */
     263             :     ToolBarManager();
     264             : 
     265             :     void LockUpdate();
     266             :     void UnlockUpdate();
     267             : };
     268             : 
     269             : } // end of namespace sd
     270             : 
     271             : #endif
     272             : 
     273             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11