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_HXX 29 #define SD_VIEW_SHELL_HXX 30 31 #include <rtl/ref.hxx> 32 33 #include <vcl/field.hxx> 34 #include <sfx2/viewsh.hxx> 35 #include <vcl/field.hxx> 36 #include <vcl/prntypes.hxx> 37 #include <svtools/transfer.hxx> 38 #include <comphelper/implementationreference.hxx> 39 #include "glob.hxx" 40 #include "pres.hxx" 41 #include "cfgids.hxx" 42 #ifndef _SD_VIEW_HXX 43 #include "View.hxx" 44 #endif 45 #include "sddllapi.h" 46 47 #include <com/sun/star/drawing/XDrawSubController.hpp> 48 #include <memory> 49 #include <boost/shared_ptr.hpp> 50 51 class SdPage; 52 class SvxRuler; 53 class SdrOle2Obj; // fuer die, die Teile von SVDRAW rausdefiniert haben 54 class ScrollBarBox; 55 class SdDrawDocument; 56 class ScrollBar; 57 class FmFormShell; 58 class SdOptionsPrintItem; 59 class MultiSelection; 60 61 extern const String aEmptyStr; 62 63 namespace com { namespace sun { namespace star { 64 namespace embed { 65 class XEmbeddedObject; 66 }}}} 67 68 namespace css = ::com::sun::star; 69 70 namespace sd { 71 72 class Client; 73 class DrawDocShell; 74 class DrawSubController; 75 class FrameView; 76 class FuPoor; 77 class FuSearch; 78 class SlideShow; 79 class LayerTabBar; 80 class View; 81 class ViewShellBase; 82 class ViewTabBar; 83 class Window; 84 class WindowUpdater; 85 class ZoomList; 86 87 #undef OUTPUT_DRAWMODE_COLOR 88 #undef OUTPUT_DRAWMODE_CONTRAST 89 90 /** Base class of the stacked shell hierarchy. 91 92 <p>Despite its name this class is not a descendant of SfxViewShell 93 but of SfxShell. Its name expresses the fact that it acts like a 94 view shell. Beeing a stacked shell rather then being an actual view shell 95 there can be several instances of this class that 96 <ul> 97 <li>all are based on the same view shell and thus show the same 98 document and share common view functionality and</li> 99 <li>are all visible at the same time and live in the same 100 frame.</li> 101 <ul></p> 102 103 <p>This class replaces the former ViewShell class.</p> 104 */ 105 class ViewShell 106 : public SfxShell 107 { 108 public: 109 enum ShellType { 110 ST_NONE, 111 ST_DRAW, // The Draw application. 112 ST_IMPRESS, // Main view of the Impress application. 113 ST_NOTES, 114 ST_HANDOUT, 115 ST_OUTLINE, 116 ST_SLIDE_SORTER, 117 ST_PRESENTATION, 118 ST_TASK_PANE 119 }; 120 static const int MAX_HSPLIT_CNT = 1; 121 static const int MAX_VSPLIT_CNT = 1; 122 static const int MIN_SCROLLBAR_SIZE = 50; 123 124 static const sal_uLong OUTPUT_DRAWMODE_COLOR = DRAWMODE_DEFAULT; 125 static const sal_uLong OUTPUT_DRAWMODE_GRAYSCALE 126 = DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL 127 | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP 128 | DRAWMODE_GRAYGRADIENT; 129 static const int OUTPUT_DRAWMODE_BLACKWHITE 130 = DRAWMODE_BLACKLINE | DRAWMODE_BLACKTEXT 131 | DRAWMODE_WHITEFILL | DRAWMODE_GRAYBITMAP 132 | DRAWMODE_WHITEGRADIENT; 133 static const int OUTPUT_DRAWMODE_CONTRAST 134 = DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL 135 | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT; 136 137 TYPEINFO(); 138 139 ViewShell ( 140 SfxViewFrame *pFrame, 141 ::Window* pParentWindow, 142 ViewShellBase& rViewShellBase, 143 bool bAllowCenter = true); 144 virtual ~ViewShell (void); 145 146 /** The Init method has to be called from the outside directly 147 after a new object of this class has been created. It can be 148 used for that part of the initialisation that can be run only 149 after the creation of the new object is finished. This 150 includes registration as listener at event broadcasters. 151 152 Derived classes should call this method at the head of their 153 Init() methods. 154 @param bIsMainViewShell 155 This flag tells the Init() method whether the new ViewShell will 156 be the main view shell. 157 */ 158 virtual void Init (bool bIsMainViewShell); 159 160 /** The Exit() method has to be called before the destructor so that the 161 view shell is still a valid object and can safely call methods that 162 rely on that. 163 */ 164 virtual void Exit (void); 165 166 void Cancel(); 167 168 /** Return the window that is the parent of all controls of this view 169 shell. This may or may not be the window of the frame. 170 */ 171 inline ::Window* GetParentWindow (void) const; 172 173 inline ::sd::View* GetView (void) const; 174 inline SdrView* GetDrawView (void) const; 175 SD_DLLPUBLIC DrawDocShell* GetDocSh (void) const; 176 177 SdDrawDocument* GetDoc (void) const; 178 179 SD_DLLPUBLIC SfxViewFrame* GetViewFrame (void) const; 180 181 /** The active window is usually the mpContentWindow. When there is a 182 show running then the active window is a ShowWindow. 183 */ 184 ::sd::Window* GetActiveWindow (void) const; 185 186 /** Set the active window. When the shell is displayed in the center 187 pane then the window of the ViewShellBase is also set to the given 188 window. 189 */ 190 void SetActiveWindow (::sd::Window* pWindow); 191 192 /** Return the rectangle that encloses all windows of the view. That 193 excludes the controls in the frame like rulers, scroll bars, tab 194 bar, and buttons. 195 @return 196 The rectangle is returned in screen coordinates, i.e. pixel 197 values relative to the upper left corner of the screen?. 198 */ 199 const Rectangle& GetAllWindowRect (void); 200 201 // Mouse- & Key-Events 202 virtual void PrePaint(); 203 virtual void Paint (const Rectangle& rRect, ::sd::Window* pWin); 204 virtual sal_Bool KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin); 205 virtual void MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin); 206 virtual void MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin); 207 virtual void MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin); 208 virtual void Command(const CommandEvent& rCEvt, ::sd::Window* pWin); 209 virtual sal_Bool RequestHelp( const HelpEvent& rEvt, ::sd::Window* pWin ); 210 virtual long Notify( NotifyEvent& rNEvt, ::sd::Window* pWin ); 211 212 virtual bool HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWin); 213 214 virtual void Draw(OutputDevice &rDev, const Region &rReg); 215 216 virtual void SetUIUnit(FieldUnit eUnit); 217 virtual void SetDefTabHRuler( sal_uInt16 nDefTab ); 218 219 sal_Bool HasRuler (void); 220 void SetRuler(sal_Bool bRuler); 221 222 /** Set internal values of all scroll bars that determine thumb size and 223 position. The external values like size and position of the scroll 224 bar controls are not modified. 225 */ 226 virtual void UpdateScrollBars (void); 227 void Scroll(long nX, long nY); 228 void ScrollLines(long nX, long nY); 229 virtual void SetZoom(long nZoom); 230 virtual void SetZoomRect(const Rectangle& rZoomRect); 231 void InitWindows(const Point& rViewOrigin, const Size& rViewSize, 232 const Point& rWinPos, sal_Bool bUpdate = sal_False); 233 void InvalidateWindows(); 234 /** This method is still used by the OutlineViewShell to update the 235 model according to the content of the outline view. This in turn 236 updates the previews in the slide sorter. 237 */ 238 virtual void UpdatePreview (SdPage* pPage, sal_Bool bInit = sal_False); 239 240 void DrawMarkRect(const Rectangle& rRect) const; 241 242 void ExecReq( SfxRequest &rReq ); 243 244 ZoomList* GetZoomList (void); 245 246 FrameView* GetFrameView (void); 247 /** Setting a frame view triggers ReadFrameViewData() for the new 248 frame. 249 @param pFrameView 250 The new frame view that replaces the old one. 251 */ 252 void SetFrameView (FrameView* pFrameView); 253 virtual void ReadFrameViewData(FrameView* pView); 254 virtual void WriteFrameViewData(); 255 virtual void WriteUserData(String& rString); 256 virtual void ReadUserData(const String& rString); 257 258 virtual sal_Bool ActivateObject(SdrOle2Obj* pObj, long nVerb); 259 260 /** @returns 261 current or selected page or 0. This method 262 will fail in master page mode. 263 264 @deprecated, please use getCurrentPage(); 265 */ 266 virtual SdPage* GetActualPage() = 0; 267 268 /** @returns 269 current or selected page or 0. 270 */ 271 virtual SdPage* getCurrentPage() const = 0; 272 273 FunctionReference GetOldFunction() const { return mxOldFunction; } 274 bool HasOldFunction() const { return mxOldFunction.is(); } 275 FunctionReference GetCurrentFunction() const { return mxCurrentFunction; } 276 bool HasCurrentFunction( sal_uInt16 nSID ) { return mxCurrentFunction.is() && (mxCurrentFunction->GetSlotID() == nSID ); } 277 bool HasCurrentFunction() { return mxCurrentFunction.is(); } 278 279 void SetCurrentFunction(const FunctionReference& xFunction); 280 void SetOldFunction(const FunctionReference& xFunction); 281 void DeactivateCurrentFunction( bool bPermanent = false ); 282 283 void SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize, 284 long nLeft, long nRight, long nUpper, long nLower, 285 sal_Bool bScaleAll, Orientation eOrient, sal_uInt16 nPaperBin, 286 sal_Bool bBackgroundFullSize ); 287 288 void SetStartShowWithDialog( sal_Bool bIn = sal_True ) { mbStartShowWithDialog = bIn; } 289 sal_Bool IsStartShowWithDialog() const { return mbStartShowWithDialog; } 290 291 sal_uInt16 GetPrintedHandoutPageNum (void) const { return mnPrintedHandoutPageNum; } 292 void SetPrintedHandoutPageNum (sal_uInt16 nPageNumber) {mnPrintedHandoutPageNum=nPageNumber; } 293 294 sal_uInt16 GetPrintedHandoutPageCount(void) const { return mnPrintedHandoutPageCount; } 295 void SetPrintedHandoutPageCount (sal_uInt16 nPageCount) {mnPrintedHandoutPageCount=nPageCount; } 296 297 virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False ); 298 299 void GetMenuState(SfxItemSet& rSet); 300 301 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper, 302 ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ); 303 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper, 304 ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ); 305 306 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False ); 307 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False ); 308 309 /** this method is called when the visible area of the view from this viewshell is changed */ 310 virtual void VisAreaChanged(const Rectangle& rRect); 311 312 /** Create an accessible object representing the specified window. 313 Overload this method to provide view mode specific objects. The 314 default implementation returns an empty reference. 315 @param pWindow 316 Make the document displayed in this window accessible. 317 @return 318 This default implementation returns an empty reference. 319 */ 320 virtual ::com::sun::star::uno::Reference< 321 ::com::sun::star::accessibility::XAccessible> 322 CreateAccessibleDocumentView (::sd::Window* pWindow); 323 324 void SetWinViewPos(const Point& rWinPos, bool bUpdate); 325 Point GetWinViewPos() const; 326 Point GetViewOrigin() const; 327 328 /** Return the window updater of this view shell. 329 @return 330 In rare circumstances the returned pointer may be <null/>, 331 i.e. when no memory is available anymore. 332 */ 333 ::sd::WindowUpdater* GetWindowUpdater (void) const; 334 335 /** Return the border that is drawn arround the actual document view. 336 The border contains typically rulers and scroll bars. 337 @param bOuterResize 338 When this flag is <TRUE/> then the border is used for an 339 OuterResizePixel(), i.e. there is a given window size and the 340 border elements are placed inside so that the document view has 341 the given window size minus the border. 342 When the flag is <FALSE/> then the border is used for an 343 InnerResizePixel(), i.e. the document view has a given size and 344 the border is placed outside. In this scenario the parent 345 window has the size of the document view plus the border. 346 */ 347 SvBorder GetBorder (bool bOuterResize); 348 349 /** Notify the view shell that its parent window has been resized. 350 The ViewShell places and resizes its UI elements accordingly. 351 The new size can be obtained from the parent window. 352 */ 353 virtual void Resize (void); 354 355 /** Set the position and size of the area which contains the GUI 356 elements like rulers, sliders, and buttons as well as the document 357 view. Both size and position are expected to be in pixel 358 coordinates. The positions and sizes of the mentioned GUI elements 359 are updated as well. 360 361 <p> This method is implemented by first setting copying the given 362 values to internal variables and then calling the 363 <type>ArrangeGUIElements</type> method which performs the actual 364 work of sizeing and arranging the UI elements accordingly.</p> 365 @param rPos 366 The position of the enclosing window relative to the document 367 window. This is only interesting if a Draw/Impress document 368 view is embedded as OLE object into another document view. For 369 normal documents this position is (0,0). 370 @param rSize 371 The new size in pixel. 372 */ 373 // This is to be replaced by Resize. 374 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize); 375 376 /** Set position and size of the GUI elements that are controllerd by 377 the view shell like rulers and scroll bars as well as the actual 378 document view according to the position and size that were given 379 with the last Resize() call. 380 */ 381 virtual void ArrangeGUIElements (void); 382 383 // virtual void OuterResizePixel(const Point &rPos, const Size &rSize); 384 // virtual void InnerResizePixel(const Point &rPos, const Size &rSize); 385 386 ViewShellBase& GetViewShellBase (void) const; 387 388 /** Return <TRUE/> when the called view shell is the main sub shell of 389 its ViewShellBase object, i.e. is display in the center pane. This 390 convenience function is equivalent to comparing the this pointer to 391 the result of ViewShellBase::GetViewShell(PT_CENTER). 392 */ 393 bool IsMainViewShell (void) const; 394 395 /** Set or reset the flag that indicates whether the called shell is the 396 one displayed in the center pane. By default this flag is set to 397 <FALSE/>. For the main view shell it thus has to be set to <TRUE/>. 398 */ 399 void SetIsMainViewShell (bool bIsMainViewShell); 400 401 /** Return a sub controller that implements the view shell specific 402 part of the DrawController. 403 */ 404 virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void) = 0; 405 406 /** Return the type of the shell. 407 */ 408 virtual ShellType GetShellType (void) const; 409 410 /** This method is more or less an alias to Deactivate(). It is called 411 before an object of this class is taken from the stack of view 412 shells. 413 414 <p>When this method is not called before a view shell is taken from 415 a stack then the Deactivate() call from the SFX as a response to 416 RemoveSubShell() comes to late when the view shell is not on the 417 stack anymore.</p> 418 */ 419 virtual void Shutdown (void); 420 421 /** This function is called from the underlying ViewShellBase 422 object to handle a verb execution request. 423 */ 424 virtual ErrCode DoVerb (long nVerb); 425 426 virtual void UIActivating( SfxInPlaceClient* ); 427 virtual void UIDeactivated( SfxInPlaceClient* ); 428 429 /** Show controls of the UI or hide them, depending on the given flag. 430 As a result the border is adapted. 431 */ 432 virtual void ShowUIControls (bool bVisible = true); 433 sal_Bool IsPageFlipMode(void) const; 434 435 /** Set the given window as new parent window. This is not possible for 436 all views, so the return value tells the caller if the relocation 437 was successfull. 438 */ 439 virtual bool RelocateToParentWindow (::Window* pParentWindow); 440 441 void AdaptDefaultsForChart( 442 const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > & xEmbObj ); 443 444 /** Depending on the given request create a new page or duplicate an 445 existing one. A new page is created behind the given slide. 446 @param rRequest 447 The request as passed to an Execute() method. Its arguments are 448 evaluated. Its slot id determines whether to create or 449 duplicate a slide. 450 @param pPage 451 This page is either duplicated or becomes the predecessor of the 452 new slide. If NULL a duplication request is ignored. A new 453 slide is inserted as first slide. 454 @param nInsertPosition 455 When -1 (the default) then insert after pPage. Otherwise insert 456 before the given index (of a standard page). 457 @return 458 The new slide is returned. If for some reason a new page can 459 not be created then NULL is returned. 460 */ 461 virtual SdPage* CreateOrDuplicatePage ( 462 SfxRequest& rRequest, 463 PageKind ePageKind, 464 SdPage* pPage, 465 const sal_Int32 nInsertPosition = -1); 466 467 468 class Implementation; 469 470 protected: 471 /** must be called in the beginning of each subclass d'tor. 472 disposes and clears both current and old function. */ 473 void DisposeFunctions(); 474 475 friend class ViewShellBase; 476 477 /** Window inside the rulers and scroll bars that shows a view of the 478 document. 479 */ 480 481 ::boost::shared_ptr<sd::Window> mpContentWindow; 482 483 /// Horizontal scroll bar for the current slide is displayed when needed. 484 ::boost::shared_ptr<ScrollBar> mpHorizontalScrollBar; 485 /// Vertical scroll bar for whole document is always visible. 486 ::boost::shared_ptr<ScrollBar> mpVerticalScrollBar; 487 /// Horizontal ruler is not shown by default. 488 ::std::auto_ptr<SvxRuler> mpHorizontalRuler; 489 /// Vertical ruler is not shown by default. 490 ::std::auto_ptr<SvxRuler> mpVerticalRuler; 491 /// Filler of the little square enclosed by the two scroll bars. 492 ::boost::shared_ptr<ScrollBarBox> mpScrollBarBox; 493 /// Layer tab bar. 494 ::std::auto_ptr<LayerTabBar> mpLayerTabBar; 495 496 /// This flag controls whether the rulers are visible. 497 bool mbHasRulers; 498 499 /// The active window. 500 ::sd::Window* mpActiveWindow; 501 ::sd::View* mpView; 502 FrameView* mpFrameView; 503 504 FunctionReference mxCurrentFunction; 505 FunctionReference mxOldFunction; 506 ZoomList* mpZoomList; 507 508 Point maViewPos; 509 Size maViewSize; 510 Size maScrBarWH; 511 512 sal_Bool mbCenterAllowed; // wird an Fenster weitergegeben 513 514 sal_Bool mbStartShowWithDialog; // Praesentation wurde ueber Dialog gestartet 515 sal_uInt16 mnPrintedHandoutPageNum; // Page number of the handout page that is to be printed. 516 sal_uInt16 mnPrintedHandoutPageCount; // Page count of the handout pages that are to be printed. 517 518 //af sal_Bool bPrintDirectSelected; // Print only selected objects in direct print 519 //afString sPageRange; // pagerange if selected objects in direct print 520 521 /** Area covered by all windows, i.e. the area of the parent window 522 without the controls at the borders like rulers, scroll bars, tab 523 bar, buttons. 524 This rectangle may be set in window coordinates (i.e. pixel values 525 relative to the parent window). It is transformed by every call to 526 GetAllWindowRectangle() into screen coordinates (relative to the 527 upper left corner of the screen. 528 */ 529 Rectangle maAllWindowRectangle; 530 531 /// The type of the shell. Returned by GetShellType(). 532 ShellType meShellType; 533 534 ::std::auto_ptr<Implementation> mpImpl; 535 536 // #96090# Support methods for centralized UNDO/REDO 537 virtual ::svl::IUndoManager* ImpGetUndoManager (void) const; 538 void ImpGetUndoStrings(SfxItemSet &rSet) const; 539 void ImpGetRedoStrings(SfxItemSet &rSet) const; 540 void ImpSidUndo(sal_Bool bDrawViewShell, SfxRequest& rReq); 541 void ImpSidRedo(sal_Bool bDrawViewShell, SfxRequest& rReq); 542 543 DECL_LINK( HScrollHdl, ScrollBar * ); 544 DECL_LINK( VScrollHdl, ScrollBar * ); 545 546 // virt. Scroll-Handler, hier koennen sich abgeleitete Klassen einklinken 547 virtual long VirtHScrollHdl(ScrollBar* pHScroll); 548 virtual long VirtVScrollHdl(ScrollBar* pVScroll); 549 550 // virtuelle Funktionen fuer Lineal-Handling 551 virtual SvxRuler* CreateHRuler(::sd::Window* pWin, sal_Bool bIsFirst); 552 virtual SvxRuler* CreateVRuler(::sd::Window* pWin); 553 virtual void UpdateHRuler(); 554 virtual void UpdateVRuler(); 555 556 // Zeiger auf ein zusaetzliches Control im horizontalen ScrollBar 557 // abgeleiteter Klassen (z.B. ein TabBar) zurueckgeben 558 virtual long GetHCtrlWidth(); 559 560 virtual void Activate(sal_Bool IsMDIActivate); 561 virtual void Deactivate(sal_Bool IsMDIActivate); 562 563 virtual void SetZoomFactor( const Fraction &rZoomX, 564 const Fraction &rZoomY ); 565 566 private: 567 ::Window* mpParentWindow; 568 /** This window updater is used to keep all relevant windows up to date 569 with reference to the digit langugage used to display digits in text 570 shapes. 571 */ 572 ::std::auto_ptr< ::sd::WindowUpdater> mpWindowUpdater; 573 574 /** Code common to all constructors. It generally is a bad idea 575 to call this function from outside a constructor. 576 */ 577 void construct (void); 578 579 DECL_LINK(FrameWindowEventListener, VclSimpleEvent*); 580 581 /** Create the rulers. 582 */ 583 void SetupRulers (void); 584 }; 585 586 587 588 589 ::Window* ViewShell::GetParentWindow (void) const 590 { 591 return mpParentWindow; 592 } 593 594 ::sd::View* ViewShell::GetView (void) const 595 { 596 return mpView; 597 } 598 599 SdrView* ViewShell::GetDrawView (void) const 600 { 601 return static_cast<SdrView*>(mpView); 602 } 603 604 } // end of namespace sd 605 606 #endif 607