LCOV - code coverage report
Current view: top level - sd/source/ui/inc - ViewShellManager.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_VIEWSHELLMANAGER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_INC_VIEWSHELLMANAGER_HXX
      22             : 
      23             : #include "ShellFactory.hxx"
      24             : #include <memory>
      25             : #include <boost/shared_ptr.hpp>
      26             : 
      27             : class FmFormShell;
      28             : class SfxShell;
      29             : 
      30             : namespace sd {
      31             : 
      32             : class ViewShell;
      33             : class ViewShellBase;
      34             : 
      35             : /** The ViewShellManager has the responsibility to manage the view shells
      36             :     and sub shells on the SFX shell stack.  They form a two level hierarchy
      37             :     (the underlying ViewShellBase, the only true SfxViewShell descendant,
      38             :     forms a third level.)  On the first level there are the view shells
      39             :     (what formely was called view shell, anyway; nowadays they are derived
      40             :     from SfxShell.) and shells for panes. On the second level there are sub
      41             :     shells (also derived from SfxShell) that usually are tool bars.
      42             : 
      43             :     <p>On the SFX shell stack the regular sub shells are placed above their
      44             :     view shells.  The FormShell is a special case.  With the SetFormShell()
      45             :     method it can be placed directly above or below one of the view
      46             :     shells.</p>
      47             : 
      48             :     <p>Shells managed by this class are created by factories or are given
      49             :     directly to Activate... methods.  For the sub shells there is one
      50             :     factory for every view shell.  Factories are added or removed via the
      51             :     (Add|Remove)SubShellFactory() methods.  The FormShell is managed with the
      52             :     factory of its view shell.</p>
      53             : */
      54             : class ViewShellManager
      55             : {
      56             : public:
      57             :     typedef ::boost::shared_ptr<ShellFactory<SfxShell> > SharedShellFactory;
      58             : 
      59             :     ViewShellManager (ViewShellBase& rBase);
      60             : 
      61             :     /** Before the destructor is called the method Shutdown() has to have
      62             :         been called.
      63             :     */
      64             :     ~ViewShellManager();
      65             : 
      66             :     /** Tell a ViewShellManager object to prepare to be deleted, i.e. to
      67             :         destroy all of its resources and to ignore all following calls.
      68             :         Use this when the owner of the view shell manager is about being
      69             :         destroyed but the view shell manager itself can not yet be deleted.
      70             :     */
      71             :     void Shutdown();
      72             : 
      73             :     /** Set the factory for sub shells of the specified view shell.
      74             :     */
      75             :     void AddSubShellFactory (
      76             :         ViewShell* pViewShell,
      77             :         const SharedShellFactory& rpFactory);
      78             :     void RemoveSubShellFactory (
      79             :         ViewShell* pViewShell,
      80             :         const SharedShellFactory& rpFactory);
      81             : 
      82             :     /** Activate the given view shell.
      83             :     */
      84             :     void ActivateViewShell (ViewShell* pViewShell);
      85             : 
      86             :     /** Activate the given shell which is not a view shell.  For view shells
      87             :         use the ActivateViewShell() method.
      88             :     */
      89             :     void ActivateShell (SfxShell* pShell);
      90             : 
      91             :     /** Deactivate the specified shell, i.e. take it and all of its
      92             :         object bars from the shell stack.
      93             :         @param pShell
      94             :             The shell to deactivate.
      95             :     */
      96             :     void DeactivateViewShell (const ViewShell* pShell);
      97             : 
      98             :     /** Deactivate the specified shell.  The shell is not destroyed.
      99             :     */
     100             :     void DeactivateShell (const SfxShell* pShell);
     101             : 
     102             :     /** Associate the form shell with a view shell and their relative
     103             :         position.  This method does not change the shell stack, it just
     104             :         stores the given values for the next shell stack update.
     105             :         @param pParentShell
     106             :             The view shell of the form shell.
     107             :         @param pFormShell
     108             :             The form shell.
     109             :         @param bAbove
     110             :             When <TRUE/> then the form shell will be placed directly above
     111             :             pViewShell on the SFX shell stack.  Otherwise the form shell is
     112             :             placed directly below the view shell.
     113             :     */
     114             :     void SetFormShell (const ViewShell* pParentShell, FmFormShell* pFormShell, bool bAbove);
     115             : 
     116             :     /** Activate the specified shell as sub shell for the given view shell.
     117             :         The sub shell factory associated with the view shell is used to
     118             :         create the sub shell.
     119             :         @param rParentShell
     120             :             The new sub shell will be placed above this view shell.
     121             :         @param nId
     122             :             This id is used only with the factory registered for the parent
     123             :             view shell.
     124             :     */
     125             :     void ActivateSubShell (const ViewShell& rParentShell, ShellId nId);
     126             : 
     127             :     /** Deactivate the specified sub shell.
     128             :     */
     129             :     void DeactivateSubShell (const ViewShell& rParentShell, ShellId nId);
     130             : 
     131             :     /** Send all sub shells of the specified view shell an Invalidate()
     132             :         call.  This does not modify the shell stack.
     133             :     */
     134             :     void InvalidateAllSubShells (
     135             :         ViewShell* pViewShell);
     136             : 
     137             :     /** Move the specified view shell to the top most position on the stack
     138             :         of view shells in relation to the other view shells.  After this the
     139             :         only shells that are higher on the stack are its object bars.
     140             : 
     141             :         Call this method after a focus change to bring a view mode view
     142             :         shell and is associated tool bar shells to the top of the
     143             :         stack.
     144             : 
     145             :         The mbKeepMainViewShellOnTop flag is not obeyed.
     146             : 
     147             :         @param nId
     148             :             The id of the shell to move to the top.
     149             :     */
     150             :     void MoveToTop (const ViewShell& rShell);
     151             : 
     152             :     /** Return the first, i.e. top most, view shell that has been activated
     153             :         under the given id.
     154             :         @param nId
     155             :             The id of the shell for which to return a pointer.
     156             :         @return
     157             :             When the specified shell is currently not active then NULL is
     158             :             returned.
     159             :     */
     160             :     SfxShell* GetShell (ShellId nId) const;
     161             : 
     162             :     /** Return the top-most shell on the SFX shell stack regardless of
     163             :         whether that is a view shell or a sub shell.
     164             :     */
     165             :     SfxShell* GetTopShell() const;
     166             : 
     167             :     /** Return the top-most active view shell on the internal shell stack.
     168             :     */
     169             :     SfxShell* GetTopViewShell() const;
     170             : 
     171             :     /** Use this class to safely lock updates of the view shell stack.
     172             :     */
     173             :     class UpdateLock
     174             :     {
     175             :     public:
     176        1979 :         UpdateLock (const ::boost::shared_ptr<ViewShellManager>& rpManager)
     177        1979 :             : mpManager(rpManager) {mpManager->LockUpdate();}
     178        1979 :         ~UpdateLock() {mpManager->UnlockUpdate();};
     179             :     private:
     180             :         ::boost::shared_ptr<ViewShellManager> mpManager;
     181             :     };
     182             :     friend class UpdateLock;
     183             : 
     184             : private:
     185             :     class Implementation;
     186             :     ::std::unique_ptr<ViewShellManager::Implementation> mpImpl;
     187             :     bool mbValid;
     188             : 
     189             :     void LockUpdate();
     190             :     void UnlockUpdate();
     191             : };
     192             : 
     193             : } // end of namespace sd
     194             : 
     195             : #endif
     196             : 
     197             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11