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