1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SD_SOURCE_UI_INC_VIEWSHELLBASE_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_VIEWSHELLBASE_HXX
23 #include <com/sun/star/frame/XFrame.hpp>
25 #include "ViewShell.hxx"
28 #include <sfx2/viewsh.hxx>
29 #include <sfx2/viewfac.hxx>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/scoped_ptr.hpp>
36 namespace sd
{ namespace tools
{
37 class EventMultiplexer
;
44 class FormShellManager
;
47 class ViewShellManager
;
50 /** SfxViewShell descendant that the stacked Draw/Impress shells are
53 <p>The "base" part of the name does not mean that this is a base
54 class of some class hierarchy. It rather is the base of the
57 <p>This class starts as a new and relatively small class. Over
58 time as much code as possible should be moved from the stacked
59 shells to this class.</p>
66 SFX_DECL_VIEWFACTORY(ViewShellBase
);
67 SFX_DECL_INTERFACE(SD_IF_SDVIEWSHELLBASE
)
70 /// SfxInterface initializer.
71 static void InitInterface_Impl();
74 /** This constructor is used by the view factory of the SFX macros.
75 Note that LateInit() has to be called after the constructor
76 terminates and before doing anything else.
80 SfxViewShell
* pOldShell
);
82 virtual ~ViewShellBase();
84 /** This method is part of the object construction. It HAS to be called
85 after the constructor has created a new object.
87 void LateInit (const OUString
& rsDefaultView
);
89 ::boost::shared_ptr
<ViewShellManager
> GetViewShellManager() const;
91 /** Return the main view shell stacked on the called ViewShellBase
92 object. This is usually the view shell displayed in the center
95 ::boost::shared_ptr
<ViewShell
> GetMainViewShell() const;
97 /** When given a view frame this static method returns the
98 corresponding sd::ViewShellBase object.
100 When the SfxViewShell of the given frame is not a
101 ViewShellBase object then NULL is returned.
103 static ViewShellBase
* GetViewShellBase (SfxViewFrame
* pFrame
);
105 DrawDocShell
* GetDocShell() const { return mpDocShell
;}
106 SdDrawDocument
* GetDocument() const { return mpDocument
;}
108 /** Callback function for general slot calls. At the moment these are
109 slots for switching the pane docking windows on and off.
111 virtual void Execute (SfxRequest
& rRequest
);
113 /** Callback function for retrieving item values related to certain
114 slots. This is the companion of Execute() and handles the slots
115 concerned with showing the pane docking windows.
117 void GetState (SfxItemSet
& rSet
);
119 /* override these from SfxViewShell */
120 virtual OUString
GetSelectionText(bool) SAL_OVERRIDE
;
121 virtual bool HasSelection(bool) const SAL_OVERRIDE
;
123 SvBorder
GetBorder (bool bOuterResize
);
124 virtual void InnerResizePixel (const Point
& rOrigin
, const Size
& rSize
) SAL_OVERRIDE
;
125 virtual void OuterResizePixel (const Point
& rOrigin
, const Size
& rSize
) SAL_OVERRIDE
;
127 /** This call is forwarded to the main sub-shell.
129 virtual ErrCode
DoVerb (long nVerb
) SAL_OVERRIDE
;
131 /** Return a new renderer that can be used for example for printing the
134 virtual com::sun::star::uno::Reference
<com::sun::star::view::XRenderable
> GetRenderable() SAL_OVERRIDE
;
136 /// Forwarded to the print manager.
137 virtual SfxPrinter
* GetPrinter (bool bCreate
= false) SAL_OVERRIDE
;
139 /// Forwarded to the print manager.
140 virtual sal_uInt16
SetPrinter (
141 SfxPrinter
* pNewPrinter
,
142 SfxPrinterChangeFlags nDiffFlags
= SFX_PRINTER_ALL
, bool bIsApi
=false) SAL_OVERRIDE
;
144 /// Forward methods to main sub shell.
145 virtual void WriteUserDataSequence (
146 ::com::sun::star::uno::Sequence
<
147 ::com::sun::star::beans::PropertyValue
>&,
148 bool bBrowse
= false) SAL_OVERRIDE
;
150 /** Pass the given properties to the main view shell. After that we
151 ensure that the right view shell type is displayed in the center
154 virtual void ReadUserDataSequence (
155 const ::com::sun::star::uno::Sequence
<
156 ::com::sun::star::beans::PropertyValue
>&,
157 bool bBrowse
= false) SAL_OVERRIDE
;
159 virtual void UIActivating( SfxInPlaceClient
* ) SAL_OVERRIDE
;
160 virtual void UIDeactivated( SfxInPlaceClient
* ) SAL_OVERRIDE
;
161 virtual void Activate (bool IsMDIActivate
) SAL_OVERRIDE
;
162 virtual void Deactivate (bool IsMDIActivate
) SAL_OVERRIDE
;
163 virtual void SetZoomFactor (
164 const Fraction
&rZoomX
,
165 const Fraction
&rZoomY
) SAL_OVERRIDE
;
166 virtual bool PrepareClose (bool bUI
= true) SAL_OVERRIDE
;
167 virtual void WriteUserData (OUString
&, bool bBrowse
= false) SAL_OVERRIDE
;
168 virtual void ReadUserData (const OUString
&, bool bBrowse
= false) SAL_OVERRIDE
;
169 virtual SdrView
* GetDrawView() const SAL_OVERRIDE
;
170 virtual void AdjustPosSizePixel (const Point
&rOfs
, const Size
&rSize
) SAL_OVERRIDE
;
172 /** When <TRUE/> is given, then the mouse shape is set to hour glass (or
173 whatever the busy shape looks like on the system.)
175 void SetBusyState (bool bBusy
);
177 /** Call this method when the controls of this view shell or the
178 embedded sub shell need to be rearranged. This is necessary
179 e.g. when the border has been modified (UpdateBorder() calls this
182 This method is like ResizePixel() with no arguments.
186 /** Update the border that is set with SfxViewShell::SetBorderPixel().
187 This is done by adding the border used by the ViewShellBase itself
188 with the border used by the main view shell.
190 @param bForce if true the borders are also updated if old border
191 and new border are same.
193 void UpdateBorder ( bool bForce
= false );
195 /** With this method the UI controls can be turned on or off. It is
196 used by the FuSlideShow to hide the UI controls while showing a
197 non-full-screen or in-window presentation in the center pane.
199 void ShowUIControls (bool bVisible
);
201 /** this method starts the presentation by
202 executing the slot SID_PRESENTATION asynchronous */
203 void StartPresentation();
205 /** Return an event multiplexer. It is a single class that forwards
206 events from various sources. This method must not be called before
207 LateInit() has terminated.
209 ::boost::shared_ptr
<tools::EventMultiplexer
> GetEventMultiplexer();
211 /** returns the complete area of the current view relative to the frame
214 const Rectangle
& getClientRectangle() const;
216 ::boost::shared_ptr
<ToolBarManager
> GetToolBarManager() const;
217 ::boost::shared_ptr
<FormShellManager
> GetFormShellManager() const;
219 DrawController
& GetDrawController() const;
221 void SetViewTabBar (const ::rtl::Reference
<ViewTabBar
>& rViewTabBar
);
223 /** Return the window that is used by the main view shell to display its
224 view and other UI elements, like scroll bars and rulers. Ownership
225 of that window remains with the called ViewShellBase object.
227 vcl::Window
* GetViewWindow();
229 /** returns the ui descriptive name for the given uno slot. The result is taken from the configuration
230 and not cached, so do not use it excessive (f.e. in status updates) */
231 OUString
RetrieveLabelFromCommand( const OUString
& aCmdURL
) const;
236 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
238 virtual void InitializeFramework();
241 class Implementation
;
242 ::boost::scoped_ptr
<Implementation
> mpImpl
;
243 DrawDocShell
* mpDocShell
;
244 SdDrawDocument
* mpDocument
;
246 /** Determine from the properties of the document shell the initial type
247 of the view shell in the center pane. We use this method to avoid
248 starting with the wrong type. When ReadUserDataSequence() is called
249 we check that the right type is active and change again if that is
250 not the case because something went wrong.
252 OUString
GetInitialViewShellType();
255 OUString
ImplRetrieveLabelFromCommand( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const OUString
& aCmdURL
);
258 } // end of namespace sd
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */