xref: /trunk/main/sd/source/ui/inc/ViewShellBase.hxx (revision 67e470da)
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_BASE_HXX
25 #define SD_VIEW_SHELL_BASE_HXX
26 
27 #include <com/sun/star/frame/XFrame.hpp>
28 
29 #include "ViewShell.hxx"
30 
31 #include "glob.hxx"
32 #include <sfx2/viewsh.hxx>
33 #include <sfx2/viewfac.hxx>
34 #include <memory>
35 #include <boost/shared_ptr.hpp>
36 #include <boost/scoped_ptr.hpp>
37 
38 #include <set>
39 
40 class SdDrawDocument;
41 class SfxRequest;
42 
43 namespace sd { namespace tools {
44 class EventMultiplexer;
45 } }
46 
47 namespace sd {
48 
49 class DrawController;
50 class DrawDocShell;
51 class FormShellManager;
52 class ToolBarManager;
53 class UpdateLockManager;
54 class ViewShell;
55 class ViewShellManager;
56 
57 /** SfxViewShell descendant that the stacked Draw/Impress shells are
58     based on.
59 
60     <p>The "base" part of the name does not mean that this is a base
61     class of some class hierarchy.  It rather is the base of the
62     stacked shells.</p>
63 
64     <p>This class starts as a new and relatively small class.  Over
65     time as much code as possible should be moved from the stacked
66     shells to this class.</p>
67 */
68 class ViewShellBase
69     : public SfxViewShell
70 {
71 public:
72     TYPEINFO();
73     SFX_DECL_VIEWFACTORY(ViewShellBase);
74     SFX_DECL_INTERFACE(SD_IF_SDVIEWSHELLBASE)
75 
76     /** This constructor is used by the view factory of the SFX macros.
77         Note that LateInit() has to be called after the constructor
78         terminates and before doing anything else.
79     */
80     ViewShellBase (
81         SfxViewFrame *pFrame,
82         SfxViewShell* pOldShell);
83 
84     virtual ~ViewShellBase (void);
85 
86     /** This method is part of the object construction.  It HAS to be called
87         after the constructor has created a new object.
88     */
89     virtual void LateInit (const ::rtl::OUString& rsDefaultView);
90 
91     ::boost::shared_ptr<ViewShellManager> GetViewShellManager (void) const;
92 
93     /** Return the main view shell stacked on the called ViewShellBase
94         object.  This is usually the view shell displayed in the center
95         pane.
96     */
97     ::boost::shared_ptr<ViewShell> GetMainViewShell (void) const;
98 
99     /** When given a view frame this static method returns the
100         corresponding sd::ViewShellBase object.
101         @return
102             When the SfxViewShell of the given frame is not a
103             ViewShellBase object then NULL is returned.
104     */
105     static ViewShellBase* GetViewShellBase (SfxViewFrame* pFrame);
106 
107 	DrawDocShell* GetDocShell (void) const;
108     SdDrawDocument* GetDocument (void) const;
109 
110     /** Callback function for general slot calls.  At the moment these are
111         slots for switching the pane docking windows on and off.
112     */
113     virtual void Execute (SfxRequest& rRequest);
114 
115     /** Callback function for retrieving item values related to certain
116         slots.  This is the companion of Execute() and handles the slots
117         concerned with showing the pane docking windows.
118     */
119     virtual void GetState (SfxItemSet& rSet);
120 
121     SvBorder GetBorder (bool bOuterResize);
122     virtual void InnerResizePixel (const Point& rOrigin, const Size& rSize);
123     virtual void OuterResizePixel (const Point& rOrigin, const Size& rSize);
124 
125     /** This call is forwarded to the main sub-shell.
126     */
127 	virtual ErrCode DoVerb (long nVerb);
128 
129     /** Return a new renderer that can be used for example for printing the
130         document.
131     */
132     virtual com::sun::star::uno::Reference<com::sun::star::view::XRenderable> GetRenderable (void);
133 
134     /// Forwarded to the print manager.
135 	virtual SfxPrinter* GetPrinter (sal_Bool bCreate = sal_False);
136 
137     /// Forwarded to the print manager.
138 	virtual sal_uInt16 SetPrinter (
139         SfxPrinter* pNewPrinter,
140         sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsApi=false);
141 
142     /// Forwarded to the print manager.
143 	virtual SfxTabPage* CreatePrintOptionsPage (
144         ::Window *pParent,
145         const SfxItemSet &rOptions);
146 
147     /// Forward methods to main sub shell.
148     virtual void WriteUserDataSequence (
149         ::com::sun::star::uno::Sequence <
150         ::com::sun::star::beans::PropertyValue >&,
151         sal_Bool bBrowse = sal_False);
152 
153     /** Pass the given properties to the main view shell.  After that we
154         ensure that the right view shell type is displayed in the center
155         pane.
156     */
157     virtual void ReadUserDataSequence (
158         const ::com::sun::star::uno::Sequence <
159         ::com::sun::star::beans::PropertyValue >&,
160         sal_Bool bBrowse = sal_False);
161 
162     virtual void UIActivating( SfxInPlaceClient* );
163     virtual void UIDeactivated( SfxInPlaceClient* );
164 	virtual void Activate (sal_Bool IsMDIActivate);
165 	virtual void Deactivate (sal_Bool IsMDIActivate);
166     virtual void SetZoomFactor (
167         const Fraction &rZoomX,
168         const Fraction &rZoomY);
169     virtual sal_uInt16 PrepareClose (sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False);
170     virtual void WriteUserData (String&, sal_Bool bBrowse = sal_False);
171     virtual void ReadUserData (const String&, sal_Bool bBrowse = sal_False);
172     virtual SdrView* GetDrawView (void) const;
173     virtual void AdjustPosSizePixel (const Point &rOfs, const Size &rSize);
174 
175     /** When <TRUE/> is given, then the mouse shape is set to hour glass (or
176         whatever the busy shape looks like on the system.)
177     */
178     void SetBusyState (bool bBusy);
179 
180     /** Call this method when the controls of this view shell or the
181         embedded sub shell need to be rearranged.  This is necessary
182         e.g. when the border has been modified (UpdateBorder() calls this
183         method).
184 
185         This method is like ResizePixel() with no arguments.
186     */
187     void Rearrange (void);
188 
189     /** Update the border that is set with SfxViewShell::SetBorderPixel().
190         This is done by adding the border used by the ViewShellBase itself
191         with the border used by the main view shell.
192 
193 		@param bForce	if true the borders are also updated if old border
194 						and new border are same.
195     */
196     void UpdateBorder ( bool bForce = false );
197 
198     /** With this method the UI controls can be turned on or off.  It is
199         used by the FuSlideShow to hide the UI controls while showing a
200         non-full-screen or in-window presentation in the center pane.
201     */
202     void ShowUIControls (bool bVisible);
203 
204 	/** this method starts the presentation by
205 		executing the slot SID_PRESENTATION asynchronous */
206 	void StartPresentation();
207 
208     /** Return an event multiplexer.  It is a single class that forwards
209         events from various sources.  This method must not be called before
210         LateInit() has terminated.
211     */
212     ::boost::shared_ptr<tools::EventMultiplexer> GetEventMultiplexer (void);
213 
214     /** returns the complete area of the current view relative to the frame
215         window
216     */
217     const Rectangle& getClientRectangle() const;
218 
219     ::boost::shared_ptr<UpdateLockManager> GetUpdateLockManager (void) const;
220 
221     ::boost::shared_ptr<ToolBarManager> GetToolBarManager (void) const;
222 
223     ::boost::shared_ptr<FormShellManager> GetFormShellManager (void) const;
224 
225     DrawController& GetDrawController (void) const;
226 
227     void SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar);
228 
229     /** Return the window that is used by the main view shell to display its
230         view and other UI elements, like scroll bars and rulers.  Ownership
231         of that window remains with the called ViewShellBase object.
232     */
233     ::Window* GetViewWindow (void);
234 
235 	/** returns the ui descriptive name for the given uno slot. The result is taken from the configuration
236 		and not cached, so do not use it excessive (f.e. in status updates) */
237 	::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) const;
238 
239 protected:
240 	osl::Mutex maMutex;
241 
242 	virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
243 
244     virtual void InitializeFramework (void);
245 
246 private:
247     class Implementation;
248     ::boost::scoped_ptr<Implementation> mpImpl;
249 	DrawDocShell* mpDocShell;
250 	SdDrawDocument* mpDocument;
251 
252     /** Determine from the properties of the document shell the initial type
253         of the view shell in the center pane.  We use this method to avoid
254         starting with the wrong type.  When ReadUserDataSequence() is called
255         we check that the right type is active and change again if that is
256         not the case because something went wrong.
257     */
258     ::rtl::OUString GetInitialViewShellType (void);
259 };
260 
261 class ICustomhandleSupplier
262 {
263 public:
264 	virtual void addCustomHandler( SdrView& rSourceView, ViewShell::ShellType eShellType, SdrHdlList& rHandlerList ) = 0;
265 };
266 
267 } // end of namespace sd
268 
269 #endif
270