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