1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_VIEW_SHELL_IMPLEMENTATION_HXX
29 #define SD_VIEW_SHELL_IMPLEMENTATION_HXX
30 
31 #include "ViewShell.hxx"
32 #include "ViewShellManager.hxx"
33 #include "ToolBarManager.hxx"
34 
35 #include <boost/shared_ptr.hpp>
36 #include <boost/weak_ptr.hpp>
37 #include <memory>
38 
39 
40 class SvxIMapDlg;
41 
42 namespace sd {
43 
44 class DrawController;
45 
46 /** This class contains (will contain) the implementation of methods that
47     have not be accessible from the outside.
48 */
49 class ViewShell::Implementation
50 {
51 public:
52     bool mbIsShowingUIControls;
53     bool mbIsMainViewShell;
54     /// Set to true when the ViewShell::Init() method has been called.
55     bool mbIsInitialized;
56     /** Set to true while ViewShell::ArrangeGUIElements() is being
57         executed.  It is used as guard against recursive execution.
58     */
59     bool mbArrangeActive;
60 
61     /** Remember a link to the sub shell factory, so that it can be
62         unregistered at the ViewShellManager when a ViewShell is deleted.
63     */
64     ViewShellManager::SharedShellFactory mpSubShellFactory;
65 
66     /** This update lock for the ToolBarManager exists in order to avoid
67         problems with tool bars being displayed while the mouse button is
68         pressed.  Whith docked tool bars this can lead to a size change of
69         the view.  This would change the relative mouse coordinates and thus
70         interpret every mouse click as move command.
71     */
72     class ToolBarManagerLock
73     {
74     public:
75         /** Create a new instance.  This allows the mpSelf member to be set
76             automatically.
77         */
78         static ::boost::shared_ptr<ToolBarManagerLock> Create (
79             const ::boost::shared_ptr<ToolBarManager>& rpManager);
80         /** Release the lock.  When the UI is captured
81             (Application::IsUICaptured() returns <TRUE/>) then the lock is
82             released later asynchronously.
83             @param bForce
84                 When this flag is <TRUE/> then the lock is released even
85                 when IsUICaptured() returns <TRUE/>.
86         */
87         void Release (bool bForce = false);
88         DECL_LINK(TimeoutCallback,Timer*);
89     private:
90         ::std::auto_ptr<ToolBarManager::UpdateLock> mpLock;
91         /** The timer is used both as a safe guard to unlock the update lock
92             when Release() is not called explicitly.  It is also used to
93             defer the release of the lock to a time when the UI is not
94             captured.
95         */
96         Timer maTimer;
97         /** The shared_ptr to this allows the ToolBarManagerLock to control
98             its own lifetime.  This, of course, does work only when no one
99             holds another shared_ptr longer than only temporary.
100         */
101         ::boost::shared_ptr<ToolBarManagerLock> mpSelf;
102         ToolBarManagerLock (const ::boost::shared_ptr<sd::ToolBarManager>& rpManager);
103         ~ToolBarManagerLock (void);
104 
105         class Deleter;
106         friend class Deleter;
107     };
108     // The member is not an auto_ptr because it takes over its own life time
109     // control.
110     ::boost::weak_ptr<ToolBarManagerLock> mpUpdateLockForMouse;
111 
112     Implementation (ViewShell& rViewShell);
113     ~Implementation (void);
114 
115     /** Process the SID_MODIFY slot.
116     */
117     void ProcessModifyPageSlot (
118         SfxRequest& rRequest,
119         SdPage* pCurrentPage,
120         PageKind ePageKind);
121 
122     /** Assign the given layout to the given page.  This method is at the
123         moment merely a front end for ProcessModifyPageSlot.
124         @param pPage
125             If a NULL pointer is given then this call is ignored.
126     */
127     void AssignLayout ( SfxRequest& rRequest, PageKind ePageKind );
128 
129     /** Determine the view id of the view shell.  This corresponds to the
130         view id stored in the SfxViewFrame class.
131 
132         We can not use the view of that class because with the introduction
133         of the multi pane GUI we do not switch the SfxViewShell anymore when
134         switching the view in the center pane.  The view id of the
135         SfxViewFrame is thus not modified and we can not set it from the
136         outside.
137 
138         The view id is still needed for the SFX to determine on start up
139         (e.g. after loading a document) which ViewShellBase sub class to
140         use.  These sub classes--like OutlineViewShellBase--exist only to be
141         used by the SFX as factories.  They only set the initial pane
142         configuration, nothing more.
143 
144         So what we do here in essence is to return on of the
145         ViewShellFactoryIds that can be used to select the factory that
146         creates the ViewShellBase subclass with the initial pane
147         configuration that has in the center pane a view shell of the same
148         type as mrViewShell.
149     */
150     sal_uInt16 GetViewId (void);
151 
152     /** Return a pointer to the image map dialog that is displayed in some
153         child window.
154         @return
155             Returns <NULL/> when the image map dialog is not available.
156     */
157     static SvxIMapDlg* GetImageMapDialog (void);
158 
159 private:
160     ViewShell& mrViewShell;
161 };
162 
163 
164 } // end of namespace sd
165 
166 #endif
167