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