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 SD_VIEW_SHELL_HXX
21 #define SD_VIEW_SHELL_HXX
23 #include <rtl/ref.hxx>
25 #include <vcl/field.hxx>
26 #include <sfx2/viewsh.hxx>
27 #include <vcl/prntypes.hxx>
28 #include <svtools/transfer.hxx>
29 #include <comphelper/implementationreference.hxx>
36 #include <com/sun/star/drawing/XDrawSubController.hpp>
38 #include <boost/shared_ptr.hpp>
42 class SdrOle2Obj
; // for the ones, who have undefined parts of SVDRAW
47 namespace com
{ namespace sun
{ namespace star
{
49 class XEmbeddedObject
;
54 extern const String aEmptyStr
;
65 #undef OUTPUT_DRAWMODE_COLOR
66 #undef OUTPUT_DRAWMODE_CONTRAST
68 /** Base class of the stacked shell hierarchy.
70 <p>Despite its name this class is not a descendant of SfxViewShell
71 but of SfxShell. Its name expresses the fact that it acts like a
72 view shell. Beeing a stacked shell rather then being an actual view shell
73 there can be several instances of this class that
75 <li>all are based on the same view shell and thus show the same
76 document and share common view functionality and</li>
77 <li>are all visible at the same time and live in the same
81 <p>This class replaces the former ViewShell class.</p>
89 ST_DRAW
, // The Draw application.
90 ST_IMPRESS
, // Main view of the Impress application.
99 static const int MAX_HSPLIT_CNT
= 1;
100 static const int MAX_VSPLIT_CNT
= 1;
101 static const int MIN_SCROLLBAR_SIZE
= 50;
103 static const sal_uLong OUTPUT_DRAWMODE_COLOR
= DRAWMODE_DEFAULT
;
104 static const sal_uLong OUTPUT_DRAWMODE_GRAYSCALE
105 = DRAWMODE_GRAYLINE
| DRAWMODE_GRAYFILL
106 | DRAWMODE_BLACKTEXT
| DRAWMODE_GRAYBITMAP
107 | DRAWMODE_GRAYGRADIENT
;
108 static const int OUTPUT_DRAWMODE_BLACKWHITE
109 = DRAWMODE_BLACKLINE
| DRAWMODE_BLACKTEXT
110 | DRAWMODE_WHITEFILL
| DRAWMODE_GRAYBITMAP
111 | DRAWMODE_WHITEGRADIENT
;
112 static const int OUTPUT_DRAWMODE_CONTRAST
113 = DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
114 | DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
;
119 SfxViewFrame
*pFrame
,
120 ::Window
* pParentWindow
,
121 ViewShellBase
& rViewShellBase
,
122 bool bAllowCenter
= true);
123 virtual ~ViewShell (void);
125 /** The Init method has to be called from the outside directly
126 after a new object of this class has been created. It can be
127 used for that part of the initialisation that can be run only
128 after the creation of the new object is finished. This
129 includes registration as listener at event broadcasters.
131 Derived classes should call this method at the head of their
133 @param bIsMainViewShell
134 This flag tells the Init() method whether the new ViewShell will
135 be the main view shell.
137 virtual void Init (bool bIsMainViewShell
);
139 /** The Exit() method has to be called before the destructor so that the
140 view shell is still a valid object and can safely call methods that
143 virtual void Exit (void);
147 /** Return the window that is the parent of all controls of this view
148 shell. This may or may not be the window of the frame.
150 inline ::Window
* GetParentWindow (void) const;
152 inline ::sd::View
* GetView (void) const;
153 inline SdrView
* GetDrawView (void) const;
154 SD_DLLPUBLIC DrawDocShell
* GetDocSh (void) const;
156 SdDrawDocument
* GetDoc (void) const;
158 SD_DLLPUBLIC SfxViewFrame
* GetViewFrame (void) const;
160 /** The active window is usually the mpContentWindow. When there is a
161 show running then the active window is a ShowWindow.
163 ::sd::Window
* GetActiveWindow (void) const;
165 /** Set the active window. When the shell is displayed in the center
166 pane then the window of the ViewShellBase is also set to the given
169 void SetActiveWindow (::sd::Window
* pWindow
);
171 /** Return the rectangle that encloses all windows of the view. That
172 excludes the controls in the frame like rulers, scroll bars, tab
175 The rectangle is returned in screen coordinates, i.e. pixel
176 values relative to the upper left corner of the screen?.
178 const Rectangle
& GetAllWindowRect (void);
180 // Mouse- & Key-Events
181 virtual void PrePaint();
182 virtual void Paint (const Rectangle
& rRect
, ::sd::Window
* pWin
);
183 virtual sal_Bool
KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
);
184 virtual void MouseMove(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
185 virtual void MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
186 virtual void MouseButtonDown(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
187 virtual void Command(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
);
188 virtual sal_Bool
RequestHelp( const HelpEvent
& rEvt
, ::sd::Window
* pWin
);
189 virtual long Notify( NotifyEvent
& rNEvt
, ::sd::Window
* pWin
);
191 virtual bool HandleScrollCommand(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
);
193 virtual void Draw(OutputDevice
&rDev
, const Region
&rReg
);
195 virtual void SetUIUnit(FieldUnit eUnit
);
196 virtual void SetDefTabHRuler( sal_uInt16 nDefTab
);
198 const SfxPoolItem
* GetNumBulletItem(SfxItemSet
& aNewAttr
, sal_uInt16
& nNumItemId
);
200 sal_Bool
HasRuler (void);
201 void SetRuler(sal_Bool bRuler
);
203 /** Set internal values of all scroll bars that determine thumb size and
204 position. The external values like size and position of the scroll
205 bar controls are not modified.
207 virtual void UpdateScrollBars (void);
208 void Scroll(long nX
, long nY
);
209 void ScrollLines(long nX
, long nY
);
210 virtual void SetZoom(long nZoom
);
211 virtual void SetZoomRect(const Rectangle
& rZoomRect
);
212 void InitWindows(const Point
& rViewOrigin
, const Size
& rViewSize
,
213 const Point
& rWinPos
, sal_Bool bUpdate
= sal_False
);
214 void InvalidateWindows();
215 /** This method is still used by the OutlineViewShell to update the
216 model according to the content of the outline view. This in turn
217 updates the previews in the slide sorter.
219 virtual void UpdatePreview (SdPage
* pPage
, sal_Bool bInit
= sal_False
);
221 void DrawMarkRect(const Rectangle
& rRect
) const;
223 void ExecReq( SfxRequest
&rReq
);
225 ZoomList
* GetZoomList (void);
227 FrameView
* GetFrameView (void);
228 /** Setting a frame view triggers ReadFrameViewData() for the new
231 The new frame view that replaces the old one.
233 void SetFrameView (FrameView
* pFrameView
);
234 virtual void ReadFrameViewData(FrameView
* pView
);
235 virtual void WriteFrameViewData();
236 virtual void WriteUserData(String
& rString
);
237 virtual void ReadUserData(const String
& rString
);
239 virtual sal_Bool
ActivateObject(SdrOle2Obj
* pObj
, long nVerb
);
242 current or selected page or 0. This method
243 will fail in master page mode.
245 @deprecated, please use getCurrentPage();
247 virtual SdPage
* GetActualPage() = 0;
250 current or selected page or 0.
252 virtual SdPage
* getCurrentPage() const = 0;
254 FunctionReference
GetOldFunction() const { return mxOldFunction
; }
255 bool HasOldFunction() const { return mxOldFunction
.is(); }
256 FunctionReference
GetCurrentFunction() const { return mxCurrentFunction
; }
257 bool HasCurrentFunction( sal_uInt16 nSID
) { return mxCurrentFunction
.is() && (mxCurrentFunction
->GetSlotID() == nSID
); }
258 bool HasCurrentFunction() { return mxCurrentFunction
.is(); }
260 void SetCurrentFunction(const FunctionReference
& xFunction
);
261 void SetOldFunction(const FunctionReference
& xFunction
);
262 void DeactivateCurrentFunction( bool bPermanent
= false );
264 void SetPageSizeAndBorder(PageKind ePageKind
, const Size
& rNewSize
,
265 long nLeft
, long nRight
, long nUpper
, long nLower
,
266 sal_Bool bScaleAll
, Orientation eOrient
, sal_uInt16 nPaperBin
,
267 sal_Bool bBackgroundFullSize
);
269 void SetStartShowWithDialog( sal_Bool bIn
= sal_True
) { mbStartShowWithDialog
= bIn
; }
270 sal_Bool
IsStartShowWithDialog() const { return mbStartShowWithDialog
; }
272 sal_uInt16
GetPrintedHandoutPageNum (void) const { return mnPrintedHandoutPageNum
; }
273 void SetPrintedHandoutPageNum (sal_uInt16 nPageNumber
) {mnPrintedHandoutPageNum
=nPageNumber
; }
275 sal_uInt16
GetPrintedHandoutPageCount(void) const { return mnPrintedHandoutPageCount
; }
276 void SetPrintedHandoutPageCount (sal_uInt16 nPageCount
) {mnPrintedHandoutPageCount
=nPageCount
; }
278 virtual sal_uInt16
PrepareClose( sal_Bool bUI
= sal_True
, sal_Bool bForBrowsing
= sal_False
);
280 void GetMenuState(SfxItemSet
& rSet
);
282 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
283 ::sd::Window
* pTargetWindow
, sal_uInt16 nPage
, sal_uInt16 nLayer
);
284 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
285 ::sd::Window
* pTargetWindow
, sal_uInt16 nPage
, sal_uInt16 nLayer
);
287 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
288 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
290 /** this method is called when the visible area of the view from this viewshell is changed */
291 virtual void VisAreaChanged(const Rectangle
& rRect
);
293 /** Create an accessible object representing the specified window.
294 Overload this method to provide view mode specific objects. The
295 default implementation returns an empty reference.
297 Make the document displayed in this window accessible.
299 This default implementation returns an empty reference.
301 virtual ::com::sun::star::uno::Reference
<
302 ::com::sun::star::accessibility::XAccessible
>
303 CreateAccessibleDocumentView (::sd::Window
* pWindow
);
305 void SetWinViewPos(const Point
& rWinPos
, bool bUpdate
);
306 Point
GetWinViewPos() const;
307 Point
GetViewOrigin() const;
309 /** Return the window updater of this view shell.
311 In rare circumstances the returned pointer may be <null/>,
312 i.e. when no memory is available anymore.
314 ::sd::WindowUpdater
* GetWindowUpdater (void) const;
316 /** Return the border that is drawn arround the actual document view.
317 The border contains typically rulers and scroll bars.
319 When this flag is <TRUE/> then the border is used for an
320 OuterResizePixel(), i.e. there is a given window size and the
321 border elements are placed inside so that the document view has
322 the given window size minus the border.
323 When the flag is <FALSE/> then the border is used for an
324 InnerResizePixel(), i.e. the document view has a given size and
325 the border is placed outside. In this scenario the parent
326 window has the size of the document view plus the border.
328 SvBorder
GetBorder (bool bOuterResize
);
330 /** Notify the view shell that its parent window has been resized.
331 The ViewShell places and resizes its UI elements accordingly.
332 The new size can be obtained from the parent window.
334 virtual void Resize (void);
336 /** Set the position and size of the area which contains the GUI
337 elements like rulers, sliders, and buttons as well as the document
338 view. Both size and position are expected to be in pixel
339 coordinates. The positions and sizes of the mentioned GUI elements
342 <p> This method is implemented by first setting copying the given
343 values to internal variables and then calling the
344 <type>ArrangeGUIElements</type> method which performs the actual
345 work of sizeing and arranging the UI elements accordingly.</p>
347 The position of the enclosing window relative to the document
348 window. This is only interesting if a Draw/Impress document
349 view is embedded as OLE object into another document view. For
350 normal documents this position is (0,0).
352 The new size in pixel.
354 // This is to be replaced by Resize.
355 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
357 /** Set position and size of the GUI elements that are controllerd by
358 the view shell like rulers and scroll bars as well as the actual
359 document view according to the position and size that were given
360 with the last Resize() call.
362 virtual void ArrangeGUIElements (void);
364 // virtual void OuterResizePixel(const Point &rPos, const Size &rSize);
365 // virtual void InnerResizePixel(const Point &rPos, const Size &rSize);
367 ViewShellBase
& GetViewShellBase (void) const;
369 /** Return <TRUE/> when the called view shell is the main sub shell of
370 its ViewShellBase object, i.e. is display in the center pane. This
371 convenience function is equivalent to comparing the this pointer to
372 the result of ViewShellBase::GetViewShell(PT_CENTER).
374 bool IsMainViewShell (void) const;
376 /** Set or reset the flag that indicates whether the called shell is the
377 one displayed in the center pane. By default this flag is set to
378 <FALSE/>. For the main view shell it thus has to be set to <TRUE/>.
380 void SetIsMainViewShell (bool bIsMainViewShell
);
382 /** Return a sub controller that implements the view shell specific
383 part of the DrawController.
385 virtual css::uno::Reference
<css::drawing::XDrawSubController
> CreateSubController (void) = 0;
387 /** Return the type of the shell.
389 virtual ShellType
GetShellType (void) const;
391 /** This method is more or less an alias to Deactivate(). It is called
392 before an object of this class is taken from the stack of view
395 <p>When this method is not called before a view shell is taken from
396 a stack then the Deactivate() call from the SFX as a response to
397 RemoveSubShell() comes to late when the view shell is not on the
400 virtual void Shutdown (void);
402 /** This function is called from the underlying ViewShellBase
403 object to handle a verb execution request.
405 virtual ErrCode
DoVerb (long nVerb
);
407 virtual void UIActivating( SfxInPlaceClient
* );
408 virtual void UIDeactivated( SfxInPlaceClient
* );
410 /** Show controls of the UI or hide them, depending on the given flag.
411 As a result the border is adapted.
413 virtual void ShowUIControls (bool bVisible
= true);
414 sal_Bool
IsPageFlipMode(void) const;
416 /** Set the given window as new parent window. This is not possible for
417 all views, so the return value tells the caller if the relocation
420 virtual bool RelocateToParentWindow (::Window
* pParentWindow
);
422 void AdaptDefaultsForChart(
423 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
> & xEmbObj
);
425 /** Depending on the given request create a new page or duplicate an
426 existing one. A new page is created behind the given slide.
428 The request as passed to an Execute() method. Its arguments are
429 evaluated. Its slot id determines whether to create or
432 This page is either duplicated or becomes the predecessor of the
433 new slide. If NULL a duplication request is ignored. A new
434 slide is inserted as first slide.
435 @param nInsertPosition
436 When -1 (the default) then insert after pPage. Otherwise insert
437 before the given index (of a standard page).
439 The new slide is returned. If for some reason a new page can
440 not be created then NULL is returned.
442 virtual SdPage
* CreateOrDuplicatePage (
443 SfxRequest
& rRequest
,
446 const sal_Int32 nInsertPosition
= -1);
449 class Implementation
;
452 /** must be called in the beginning of each subclass d'tor.
453 disposes and clears both current and old function. */
454 void DisposeFunctions();
456 friend class ViewShellBase
;
458 /** Window inside the rulers and scroll bars that shows a view of the
462 ::boost::shared_ptr
<sd::Window
> mpContentWindow
;
464 /// Horizontal scroll bar for the current slide is displayed when needed.
465 ::boost::shared_ptr
<ScrollBar
> mpHorizontalScrollBar
;
466 /// Vertical scroll bar for whole document is always visible.
467 ::boost::shared_ptr
<ScrollBar
> mpVerticalScrollBar
;
468 SAL_WNODEPRECATED_DECLARATIONS_PUSH
469 /// Horizontal ruler is not shown by default.
470 ::std::auto_ptr
<SvxRuler
> mpHorizontalRuler
;
471 /// Vertical ruler is not shown by default.
472 ::std::auto_ptr
<SvxRuler
> mpVerticalRuler
;
473 SAL_WNODEPRECATED_DECLARATIONS_POP
474 /// Filler of the little square enclosed by the two scroll bars.
475 ::boost::shared_ptr
<ScrollBarBox
> mpScrollBarBox
;
477 SAL_WNODEPRECATED_DECLARATIONS_PUSH
478 ::std::auto_ptr
<LayerTabBar
> mpLayerTabBar
;
479 SAL_WNODEPRECATED_DECLARATIONS_POP
481 /// This flag controls whether the rulers are visible.
484 /// The active window.
485 ::sd::Window
* mpActiveWindow
;
487 FrameView
* mpFrameView
;
489 FunctionReference mxCurrentFunction
;
490 FunctionReference mxOldFunction
;
491 ZoomList
* mpZoomList
;
497 sal_Bool mbCenterAllowed
; // will be forwarded to window
499 sal_Bool mbStartShowWithDialog
; // presentation is started by dialog
500 sal_uInt16 mnPrintedHandoutPageNum
; // Page number of the handout page that is to be printed.
501 sal_uInt16 mnPrintedHandoutPageCount
; // Page count of the handout pages that are to be printed.
503 //af sal_Bool bPrintDirectSelected; // Print only selected objects in direct print
504 //afString sPageRange; // pagerange if selected objects in direct print
506 /** Area covered by all windows, i.e. the area of the parent window
507 without the controls at the borders like rulers, scroll bars, tab
509 This rectangle may be set in window coordinates (i.e. pixel values
510 relative to the parent window). It is transformed by every call to
511 GetAllWindowRectangle() into screen coordinates (relative to the
512 upper left corner of the screen.
514 Rectangle maAllWindowRectangle
;
516 /// The type of the shell. Returned by GetShellType().
517 ShellType meShellType
;
519 SAL_WNODEPRECATED_DECLARATIONS_PUSH
520 ::std::auto_ptr
<Implementation
> mpImpl
;
521 SAL_WNODEPRECATED_DECLARATIONS_POP
523 // Support methods for centralized UNDO/REDO
524 virtual ::svl::IUndoManager
* ImpGetUndoManager (void) const;
525 void ImpGetUndoStrings(SfxItemSet
&rSet
) const;
526 void ImpGetRedoStrings(SfxItemSet
&rSet
) const;
527 void ImpSidUndo(sal_Bool bDrawViewShell
, SfxRequest
& rReq
);
528 void ImpSidRedo(sal_Bool bDrawViewShell
, SfxRequest
& rReq
);
530 DECL_LINK( HScrollHdl
, ScrollBar
* );
531 DECL_LINK( VScrollHdl
, ScrollBar
* );
533 // virtual scroll handler, here, derivative classes can add themselves here
534 virtual long VirtHScrollHdl(ScrollBar
* pHScroll
);
535 virtual long VirtVScrollHdl(ScrollBar
* pVScroll
);
537 // virtual functions ruler handling
538 virtual SvxRuler
* CreateHRuler(::sd::Window
* pWin
, sal_Bool bIsFirst
);
539 virtual SvxRuler
* CreateVRuler(::sd::Window
* pWin
);
540 virtual void UpdateHRuler();
541 virtual void UpdateVRuler();
543 virtual void Activate(sal_Bool IsMDIActivate
);
544 virtual void Deactivate(sal_Bool IsMDIActivate
);
546 virtual void SetZoomFactor( const Fraction
&rZoomX
,
547 const Fraction
&rZoomY
);
550 This must be called after the ctor, but before anything else.
551 It's the part of construction that is dependent
552 on showing the top-level window.
554 Showing a window with a11y enabled causes various callbacks
557 Due to the "virtual methods are not virtual during constructors"
558 problem, this is a disaster to call from the ctor
560 i.e. construct calls Show, and if a11y is enabled this
561 reenters the not-fully constructed object and calls
562 CreateAccessibleDocumentView, so if construct is called
563 from the ctor then if a derived class is contructed the base-cass
564 CreateAccessibleDocumentView is used, not the derived
565 CreateAccessibleDocumentView. i.e. run smoketest under a11y with
566 debugging assertions enabled
571 ::Window
* mpParentWindow
;
572 /** This window updater is used to keep all relevant windows up to date
573 with reference to the digit langugage used to display digits in text
576 SAL_WNODEPRECATED_DECLARATIONS_PUSH
577 ::std::auto_ptr
< ::sd::WindowUpdater
> mpWindowUpdater
;
578 SAL_WNODEPRECATED_DECLARATIONS_POP
580 /** Code common to all constructors. It generally is a bad idea
581 to call this function from outside a constructor.
583 void construct (void);
585 DECL_LINK(FrameWindowEventListener
, VclSimpleEvent
*);
587 /** Create the rulers.
589 void SetupRulers (void);
595 ::Window
* ViewShell::GetParentWindow (void) const
597 return mpParentWindow
;
600 ::sd::View
* ViewShell::GetView (void) const
605 SdrView
* ViewShell::GetDrawView (void) const
607 return static_cast<SdrView
*>(mpView
);
610 } // end of namespace sd
614 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */