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