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