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