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