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

Generated by: LCOV version 1.10