1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ViewShell.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_VIEW_SHELL_HXX
32 #define SD_VIEW_SHELL_HXX
34 #include <rtl/ref.hxx>
36 #include <vcl/field.hxx>
37 #include <sfx2/viewsh.hxx>
38 #include <vcl/field.hxx>
39 #include <vcl/prntypes.hxx>
40 #include <svtools/transfer.hxx>
41 #include <comphelper/implementationreference.hxx>
50 #include <com/sun/star/drawing/XDrawSubController.hpp>
52 #include <boost/shared_ptr.hpp>
56 class SdrOle2Obj
; // fuer die, die Teile von SVDRAW rausdefiniert haben
61 class SdOptionsPrintItem
;
64 extern const String aEmptyStr
;
66 namespace com
{ namespace sun
{ namespace star
{
68 class XEmbeddedObject
;
71 namespace css
= ::com::sun::star
;
77 class DrawSubController
;
90 #undef OUTPUT_DRAWMODE_COLOR
91 #undef OUTPUT_DRAWMODE_CONTRAST
93 /** Base class of the stacked shell hierarchy.
95 <p>Despite its name this class is not a descendant of SfxViewShell
96 but of SfxShell. Its name expresses the fact that it acts like a
97 view shell. Beeing a stacked shell rather then being an actual view shell
98 there can be several instances of this class that
100 <li>all are based on the same view shell and thus show the same
101 document and share common view functionality and</li>
102 <li>are all visible at the same time and live in the same
106 <p>This class replaces the former ViewShell class.</p>
114 ST_DRAW
, // The Draw application.
115 ST_IMPRESS
, // Main view of the Impress application.
123 static const int MAX_HSPLIT_CNT
= 1;
124 static const int MAX_VSPLIT_CNT
= 1;
125 static const int MIN_SCROLLBAR_SIZE
= 50;
127 static const ULONG OUTPUT_DRAWMODE_COLOR
= DRAWMODE_DEFAULT
;
128 static const ULONG OUTPUT_DRAWMODE_GRAYSCALE
129 = DRAWMODE_GRAYLINE
| DRAWMODE_GRAYFILL
130 | DRAWMODE_BLACKTEXT
| DRAWMODE_GRAYBITMAP
131 | DRAWMODE_GRAYGRADIENT
;
132 static const int OUTPUT_DRAWMODE_BLACKWHITE
133 = DRAWMODE_BLACKLINE
| DRAWMODE_BLACKTEXT
134 | DRAWMODE_WHITEFILL
| DRAWMODE_GRAYBITMAP
135 | DRAWMODE_WHITEGRADIENT
;
136 static const int OUTPUT_DRAWMODE_CONTRAST
137 = DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
138 | DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
;
143 SfxViewFrame
*pFrame
,
144 ::Window
* pParentWindow
,
145 ViewShellBase
& rViewShellBase
,
146 bool bAllowCenter
= true);
148 SfxViewFrame
*pFrame
,
149 ::Window
* pParentWindow
,
150 const ViewShell
& rShell
);
151 virtual ~ViewShell (void);
153 /** The Init method has to be called from the outside directly
154 after a new object of this class has been created. It can be
155 used for that part of the initialisation that can be run only
156 after the creation of the new object is finished. This
157 includes registration as listener at event broadcasters.
159 Derived classes should call this method at the head of their
161 @param bIsMainViewShell
162 This flag tells the Init() method whether the new ViewShell will
163 be the main view shell.
165 virtual void Init (bool bIsMainViewShell
);
167 /** The Exit() method has to be called before the destructor so that the
168 view shell is still a valid object and can safely call methods that
171 virtual void Exit (void);
175 /** Return the window that is the parent of all controls of this view
176 shell. This may or may not be the window of the frame.
178 inline ::Window
* GetParentWindow (void) const;
180 inline ::sd::View
* GetView (void) const;
181 inline SdrView
* GetDrawView (void) const;
182 SD_DLLPUBLIC DrawDocShell
* GetDocSh (void) const;
184 SdDrawDocument
* GetDoc (void) const;
186 SD_DLLPUBLIC SfxViewFrame
* GetViewFrame (void) const;
188 /** The active window is usually the mpContentWindow. When there is a
189 show running then the active window is a ShowWindow.
191 ::sd::Window
* GetActiveWindow (void) const;
193 /** Set the active window. When the shell is displayed in the center
194 pane then the window of the ViewShellBase is also set to the given
197 void SetActiveWindow (::sd::Window
* pWindow
);
199 /** Return the rectangle that encloses all windows of the view. That
200 excludes the controls in the frame like rulers, scroll bars, tab
203 The rectangle is returned in screen coordinates, i.e. pixel
204 values relative to the upper left corner of the screen?.
206 const Rectangle
& GetAllWindowRect (void);
208 // Mouse- & Key-Events
209 virtual void PrePaint();
210 virtual void Paint (const Rectangle
& rRect
, ::sd::Window
* pWin
);
211 virtual BOOL
KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
);
212 virtual void MouseMove(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
213 virtual void MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
214 virtual void MouseButtonDown(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
215 virtual void Command(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
);
216 virtual BOOL
RequestHelp( const HelpEvent
& rEvt
, ::sd::Window
* pWin
);
217 virtual long Notify( NotifyEvent
& rNEvt
, ::sd::Window
* pWin
);
219 BOOL
HandleScrollCommand(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
);
221 virtual void Draw(OutputDevice
&rDev
, const Region
&rReg
);
223 virtual void SetUIUnit(FieldUnit eUnit
);
224 virtual void SetDefTabHRuler( UINT16 nDefTab
);
226 BOOL
HasRuler (void);
227 void SetRuler(BOOL bRuler
);
229 /** Set internal values of all scroll bars that determine thumb size and
230 position. The external values like size and position of the scroll
231 bar controls are not modified.
233 virtual void UpdateScrollBars (void);
234 void Scroll(long nX
, long nY
);
235 void ScrollLines(long nX
, long nY
);
236 virtual void SetZoom(long nZoom
);
237 virtual void SetZoomRect(const Rectangle
& rZoomRect
);
238 void InitWindows(const Point
& rViewOrigin
, const Size
& rViewSize
,
239 const Point
& rWinPos
, BOOL bUpdate
= FALSE
);
240 void InvalidateWindows();
241 void UpdateWindows();
242 /** This method is still used by the OutlineViewShell to update the
243 model according to the content of the outline view. This in turn
244 updates the previews in the slide sorter.
246 virtual void UpdatePreview (SdPage
* pPage
, BOOL bInit
= FALSE
);
248 void DrawMarkRect(const Rectangle
& rRect
) const;
249 void DrawFilledRect( const Rectangle
& rRect
, const Color
& rLColor
,
250 const Color
& rFColor
) const;
252 void ExecReq( SfxRequest
&rReq
);
254 ZoomList
* GetZoomList (void);
256 FrameView
* GetFrameView (void);
257 /** Setting a frame view triggers ReadFrameViewData() for the new
260 The new frame view that replaces the old one.
262 void SetFrameView (FrameView
* pFrameView
);
263 virtual void ReadFrameViewData(FrameView
* pView
);
264 virtual void WriteFrameViewData();
265 virtual void WriteUserData(String
& rString
);
266 virtual void ReadUserData(const String
& rString
);
268 virtual BOOL
ActivateObject(SdrOle2Obj
* pObj
, long nVerb
);
271 current or selected page or 0. This method
272 will fail in master page mode.
274 @deprecated, please use getCurrentPage();
276 virtual SdPage
* GetActualPage() = 0;
279 current or selected page or 0.
281 virtual SdPage
* getCurrentPage() const = 0;
283 FunctionReference
GetOldFunction() const { return mxOldFunction
; }
284 bool HasOldFunction() const { return mxOldFunction
.is(); }
285 FunctionReference
GetCurrentFunction() const { return mxCurrentFunction
; }
286 bool HasCurrentFunction( USHORT nSID
) { return mxCurrentFunction
.is() && (mxCurrentFunction
->GetSlotID() == nSID
); }
287 bool HasCurrentFunction() { return mxCurrentFunction
.is(); }
289 void SetCurrentFunction(const FunctionReference
& xFunction
);
290 void SetOldFunction(const FunctionReference
& xFunction
);
291 void DeactivateCurrentFunction( bool bPermanent
= false );
293 void SetPageSizeAndBorder(PageKind ePageKind
, const Size
& rNewSize
,
294 long nLeft
, long nRight
, long nUpper
, long nLower
,
295 BOOL bScaleAll
, Orientation eOrient
, USHORT nPaperBin
,
296 BOOL bBackgroundFullSize
);
298 void SetStartShowWithDialog( BOOL bIn
= TRUE
) { mbStartShowWithDialog
= bIn
; }
299 BOOL
IsStartShowWithDialog() const { return mbStartShowWithDialog
; }
301 USHORT
GetPrintedHandoutPageNum (void) const { return mnPrintedHandoutPageNum
; }
302 void SetPrintedHandoutPageNum (USHORT nPageNumber
) {mnPrintedHandoutPageNum
=nPageNumber
; }
304 USHORT
GetPrintedHandoutPageCount(void) const { return mnPrintedHandoutPageCount
; }
305 void SetPrintedHandoutPageCount (USHORT nPageCount
) {mnPrintedHandoutPageCount
=nPageCount
; }
307 virtual USHORT
PrepareClose( BOOL bUI
= TRUE
, BOOL bForBrowsing
= FALSE
);
309 void GetMenuState(SfxItemSet
& rSet
);
311 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
312 ::sd::Window
* pTargetWindow
, USHORT nPage
, USHORT nLayer
);
313 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
314 ::sd::Window
* pTargetWindow
, USHORT nPage
, USHORT nLayer
);
316 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
317 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
319 /** this method is called when the visible area of the view from this viewshell is changed */
320 virtual void VisAreaChanged(const Rectangle
& rRect
);
322 /** Create an accessible object representing the specified window.
323 Overload this method to provide view mode specific objects. The
324 default implementation returns an empty reference.
326 Make the document displayed in this window accessible.
328 This default implementation returns an empty reference.
330 virtual ::com::sun::star::uno::Reference
<
331 ::com::sun::star::accessibility::XAccessible
>
332 CreateAccessibleDocumentView (::sd::Window
* pWindow
);
334 void SetWinViewPos(const Point
& rWinPos
, bool bUpdate
);
335 Point
GetWinViewPos() const;
336 Point
GetViewOrigin() const;
338 /** Return the window updater of this view shell.
340 In rare circumstances the returned pointer may be <null/>,
341 i.e. when no memory is available anymore.
343 ::sd::WindowUpdater
* GetWindowUpdater (void) const;
345 /** Return the border that is drawn arround the actual document view.
346 The border contains typically rulers and scroll bars.
348 When this flag is <TRUE/> then the border is used for an
349 OuterResizePixel(), i.e. there is a given window size and the
350 border elements are placed inside so that the document view has
351 the given window size minus the border.
352 When the flag is <FALSE/> then the border is used for an
353 InnerResizePixel(), i.e. the document view has a given size and
354 the border is placed outside. In this scenario the parent
355 window has the size of the document view plus the border.
357 SvBorder
GetBorder (bool bOuterResize
);
359 /** Notify the view shell that its parent window has been resized.
360 The ViewShell places and resizes its UI elements accordingly.
361 The new size can be obtained from the parent window.
363 virtual void Resize (void);
365 /** Set the position and size of the area which contains the GUI
366 elements like rulers, sliders, and buttons as well as the document
367 view. Both size and position are expected to be in pixel
368 coordinates. The positions and sizes of the mentioned GUI elements
371 <p> This method is implemented by first setting copying the given
372 values to internal variables and then calling the
373 <type>ArrangeGUIElements</type> method which performs the actual
374 work of sizeing and arranging the UI elements accordingly.</p>
376 The position of the enclosing window relative to the document
377 window. This is only interesting if a Draw/Impress document
378 view is embedded as OLE object into another document view. For
379 normal documents this position is (0,0).
381 The new size in pixel.
383 // This is to be replaced by Resize.
384 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
386 /** Set position and size of the GUI elements that are controllerd by
387 the view shell like rulers and scroll bars as well as the actual
388 document view according to the position and size that were given
389 with the last Resize() call.
391 virtual void ArrangeGUIElements (void);
393 // virtual void OuterResizePixel(const Point &rPos, const Size &rSize);
394 // virtual void InnerResizePixel(const Point &rPos, const Size &rSize);
396 ViewShellBase
& GetViewShellBase (void) const;
398 /** Return <TRUE/> when the called view shell is the main sub shell of
399 its ViewShellBase object, i.e. is display in the center pane. This
400 convenience function is equivalent to comparing the this pointer to
401 the result of ViewShellBase::GetViewShell(PT_CENTER).
403 bool IsMainViewShell (void) const;
405 /** Set or reset the flag that indicates whether the called shell is the
406 one displayed in the center pane. By default this flag is set to
407 <FALSE/>. For the main view shell it thus has to be set to <TRUE/>.
409 void SetIsMainViewShell (bool bIsMainViewShell
);
411 /** Return a sub controller that implements the view shell specific
412 part of the DrawController.
414 virtual css::uno::Reference
<css::drawing::XDrawSubController
> CreateSubController (void) = 0;
416 /** Return the type of the shell.
418 virtual ShellType
GetShellType (void) const;
420 /** This method is more or less an alias to Deactivate(). It is called
421 before an object of this class is taken from the stack of view
424 <p>When this method is not called before a view shell is taken from
425 a stack then the Deactivate() call from the SFX as a response to
426 RemoveSubShell() comes to late when the view shell is not on the
429 virtual void Shutdown (void);
431 /** This function is called from the underlying ViewShellBase
432 object to handle a verb execution request.
434 virtual ErrCode
DoVerb (long nVerb
);
436 virtual void UIActivating( SfxInPlaceClient
* );
437 virtual void UIDeactivated( SfxInPlaceClient
* );
439 /** Show controls of the UI or hide them, depending on the given flag.
440 As a result the border is adapted.
442 virtual void ShowUIControls (bool bVisible
= true);
443 BOOL
IsPageFlipMode(void) const;
445 /** Set the given window as new parent window. This is not possible for
446 all views, so the return value tells the caller if the relocation
449 virtual bool RelocateToParentWindow (::Window
* pParentWindow
);
451 void AdaptDefaultsForChart(
452 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
> & xEmbObj
);
454 class Implementation
;
457 /** must be called in the beginning of each subclass d'tor.
458 disposes and clears both current and old function. */
459 void DisposeFunctions();
461 friend class ViewShellBase
;
463 /** Window inside the rulers and scroll bars that shows a view of the
467 ::boost::shared_ptr
<sd::Window
> mpContentWindow
;
469 /// Horizontal scroll bar for the current slide is displayed when needed.
470 ::boost::shared_ptr
<ScrollBar
> mpHorizontalScrollBar
;
471 /// Vertical scroll bar for whole document is always visible.
472 ::boost::shared_ptr
<ScrollBar
> mpVerticalScrollBar
;
473 /// Horizontal ruler is not shown by default.
474 ::std::auto_ptr
<SvxRuler
> mpHorizontalRuler
;
475 /// Vertical ruler is not shown by default.
476 ::std::auto_ptr
<SvxRuler
> mpVerticalRuler
;
477 /// Filler of the little square enclosed by the two scroll bars.
478 ::boost::shared_ptr
<ScrollBarBox
> mpScrollBarBox
;
480 ::std::auto_ptr
<LayerTabBar
> mpLayerTabBar
;
482 /// This flag controls whether the rulers are visible.
485 /// The active window.
486 ::sd::Window
* mpActiveWindow
;
488 FrameView
* mpFrameView
;
490 FunctionReference mxCurrentFunction
;
491 FunctionReference mxOldFunction
;
492 ZoomList
* mpZoomList
;
498 BOOL mbCenterAllowed
; // wird an Fenster weitergegeben
500 BOOL mbStartShowWithDialog
; // Praesentation wurde ueber Dialog gestartet
501 USHORT mnPrintedHandoutPageNum
; // Page number of the handout page that is to be printed.
502 USHORT mnPrintedHandoutPageCount
; // Page count of the handout pages that are to be printed.
504 //af BOOL bPrintDirectSelected; // Print only selected objects in direct print
505 //afString sPageRange; // pagerange if selected objects in direct print
507 /** Area covered by all windows, i.e. the area of the parent window
508 without the controls at the borders like rulers, scroll bars, tab
510 This rectangle may be set in window coordinates (i.e. pixel values
511 relative to the parent window). It is transformed by every call to
512 GetAllWindowRectangle() into screen coordinates (relative to the
513 upper left corner of the screen.
515 Rectangle maAllWindowRectangle
;
517 /// The type of the shell. Returned by GetShellType().
518 ShellType meShellType
;
520 ::std::auto_ptr
<Implementation
> mpImpl
;
522 // #96090# Support methods for centralized UNDO/REDO
523 virtual SfxUndoManager
* ImpGetUndoManager (void) const;
524 void ImpGetUndoStrings(SfxItemSet
&rSet
) const;
525 void ImpGetRedoStrings(SfxItemSet
&rSet
) const;
526 void ImpSidUndo(BOOL bDrawViewShell
, SfxRequest
& rReq
);
527 void ImpSidRedo(BOOL bDrawViewShell
, SfxRequest
& rReq
);
529 DECL_LINK( HScrollHdl
, ScrollBar
* );
530 DECL_LINK( VScrollHdl
, ScrollBar
* );
532 // virt. Scroll-Handler, hier koennen sich abgeleitete Klassen einklinken
533 virtual long VirtHScrollHdl(ScrollBar
* pHScroll
);
534 virtual long VirtVScrollHdl(ScrollBar
* pVScroll
);
536 // virtuelle Funktionen fuer Lineal-Handling
537 virtual SvxRuler
* CreateHRuler(::sd::Window
* pWin
, BOOL bIsFirst
);
538 virtual SvxRuler
* CreateVRuler(::sd::Window
* pWin
);
539 virtual void UpdateHRuler();
540 virtual void UpdateVRuler();
542 // Zeiger auf ein zusaetzliches Control im horizontalen ScrollBar
543 // abgeleiteter Klassen (z.B. ein TabBar) zurueckgeben
544 virtual long GetHCtrlWidth();
546 virtual void Activate(BOOL IsMDIActivate
);
547 virtual void Deactivate(BOOL IsMDIActivate
);
549 virtual void SetZoomFactor( const Fraction
&rZoomX
,
550 const Fraction
&rZoomY
);
552 /** Depending on the given request create a new page or duplicate an
553 existing one. A new page is created behind the given slide.
555 The request as passed to an Execute() method. Its arguments are
556 evaluated. Its slot id determines whether to create or
559 This page is either duplicated or becomes the predecessor of the
560 new slide. If NULL a duplication request is ignored. A new
561 slide is inserted as first slide.
563 The new slide is returned. If for some reason a new page can
564 not be created then NULL is returned.
566 virtual SdPage
* CreateOrDuplicatePage (
567 SfxRequest
& rRequest
,
572 ::Window
* mpParentWindow
;
573 /** This window updater is used to keep all relevant windows up to date
574 with reference to the digit langugage used to display digits in text
577 ::std::auto_ptr
< ::sd::WindowUpdater
> mpWindowUpdater
;
579 /** Code common to all constructors. It generally is a bad idea
580 to call this function from outside a constructor.
582 void construct (void);
584 DECL_LINK(FrameWindowEventListener
, VclSimpleEvent
*);
586 /** Create the rulers.
588 void SetupRulers (void);
594 ::Window
* ViewShell::GetParentWindow (void) const
596 return mpParentWindow
;
599 ::sd::View
* ViewShell::GetView (void) const
604 SdrView
* ViewShell::GetDrawView (void) const
606 return static_cast<SdrView
*>(mpView
);
609 } // end of namespace sd