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_DRAW_VIEW_SHELL_HXX 25 #define SD_DRAW_VIEW_SHELL_HXX 26 27 #include "ViewShell.hxx" 28 #include "tools/AsynchronousCall.hxx" 29 #include <sfx2/viewfac.hxx> 30 #include <sfx2/viewsh.hxx> 31 #include "TabControl.hxx" 32 #include "pres.hxx" 33 #include <com/sun/star/lang/XEventListener.hpp> 34 #include <com/sun/star/scanner/XScannerManager.hpp> 35 36 class SdPage; 37 class DrawDocShell; 38 class SdAnimationWin; 39 class SdRuler; 40 class TabBar; 41 class SdrObject; 42 class SdrPageView; 43 class TransferableDataHelper; 44 class TransferableClipboardListener; 45 class AbstractSvxNameDialog; 46 class SdrLayer; 47 class SvxClipboardFmtItem; 48 49 namespace sd { 50 51 class DrawView; 52 class LayerTabBar; 53 class Ruler; 54 class SdUnoDrawView; 55 class AnnotationManager; 56 class ViewOverlayManager; 57 58 #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax)) 59 60 /** Base class of the stacked shells that provide graphical views to 61 Draw and Impress documents and editing functionality. In contrast 62 to this other stacked shells are responsible for showing an 63 overview over several slides (SlideViewShell) or a textual 64 overview over the text in an Impress document (OutlineViewShell). 65 */ 66 class DrawViewShell 67 : public ViewShell, 68 public SfxListener 69 { 70 public: 71 static const int SLOTARRAY_COUNT = 24; 72 73 TYPEINFO(); 74 75 SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL) 76 77 /** Create a new stackable shell that may take some information 78 (e.g. the frame view) from the given previous shell. 79 @param ePageKind 80 This parameter gives the initial page kind that the new shell 81 will show. 82 @param pFrameView 83 The frame view that makes it possible to pass information from 84 one view shell to the next. 85 */ 86 DrawViewShell ( 87 SfxViewFrame* pFrame, 88 ViewShellBase& rViewShellBase, 89 ::Window* pParentWindow, 90 PageKind ePageKind = PK_STANDARD, 91 FrameView* pFrameView = NULL); 92 93 virtual ~DrawViewShell (void); 94 95 virtual void Init (bool bIsMainViewShell); 96 97 virtual void Shutdown (void); 98 99 void PrePaint(); 100 virtual void Paint(const Rectangle& rRect, ::sd::Window* pWin); 101 102 /** Set the position and size of the area which contains the GUI 103 elements like rulers, sliders, and buttons as well as the document 104 view. Both size and position are expected to be in pixel 105 coordinates. The positions and sizes of the mentioned GUI elements 106 are updated as well. 107 108 <p> This method is implemented by first setting copying the given 109 values to internal variables and then calling the 110 <type>ArrangeGUIElements</type> method which performs the actual 111 work of sizeing and arranging the UI elements accordingly.</p> 112 @param rPos 113 The position of the enclosing window relative to the document 114 window. This is only interesting if a Draw/Impress document 115 view is embedded as OLE object into another document view. For 116 normal documents this position is (0,0). 117 @param rSize 118 The new size in pixel. 119 */ 120 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize); 121 122 /** Arrange and resize the GUI elements like rulers, sliders, and 123 buttons as well as the actual document view according to the size of 124 the enclosing window and current sizes of buttons, rulers, and 125 sliders. 126 */ 127 virtual void ArrangeGUIElements (void); 128 129 void HidePage(); 130 131 virtual sal_Bool KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin); 132 virtual void MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin); 133 virtual void MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin); 134 virtual void MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin); 135 virtual void Command(const CommandEvent& rCEvt, ::sd::Window* pWin); 136 137 virtual void Resize (void); 138 139 void ShowMousePosInfo(const Rectangle& rRect, ::sd::Window* pWin); 140 141 virtual void AddWindow(::sd::Window* pWin); 142 virtual void RemoveWindow(::sd::Window* pWin); 143 144 virtual void ChangeEditMode (EditMode eMode, bool bIsLayerModeActive); 145 146 virtual void SetZoom( long nZoom ); 147 virtual void SetZoomRect( const Rectangle& rZoomRect ); 148 149 void InsertURLField(const String& rURL, const String& rText, const String& rTarget, 150 const Point* pPos); 151 void InsertURLButton(const String& rURL, const String& rText, const String& rTarget, 152 const Point* pPos); 153 154 virtual void SetUIUnit(FieldUnit eUnit); 155 156 void SelectionHasChanged(); 157 void ModelHasChanged(); 158 virtual void Activate(sal_Bool bIsMDIActivate); 159 virtual void Deactivate(sal_Bool IsMDIActivate); 160 virtual void UIActivating( SfxInPlaceClient* ); 161 virtual void UIDeactivated( SfxInPlaceClient* ); 162 virtual String GetSelectionText( sal_Bool bCompleteWords = sal_False ); 163 virtual sal_Bool HasSelection( sal_Bool bText = sal_True ) const; 164 165 void ExecCtrl(SfxRequest& rReq); 166 void GetCtrlState(SfxItemSet& rSet); 167 void GetMenuState(SfxItemSet& rSet); 168 void GetTableMenuState(SfxItemSet& rSet); 169 /** Set the items of the given item set that are related to 170 switching the editing mode to the correct values. 171 <p>This function also sets the states of the mode buttons 172 (those at the upper right corner) accordingly.</p> 173 */ 174 void GetModeSwitchingMenuState (SfxItemSet &rSet); 175 void GetAttrState(SfxItemSet& rSet); 176 void GetSnapItemState(SfxItemSet& rSet); 177 178 void GetState (SfxItemSet& rSet); 179 void Execute (SfxRequest& rReq); 180 181 void ExecStatusBar(SfxRequest& rReq); 182 void GetStatusBarState(SfxItemSet& rSet); 183 184 void ExecOptionsBar(SfxRequest& rReq); 185 void GetOptionsBarState(SfxItemSet& rSet); 186 187 void ExecRuler(SfxRequest& rReq); 188 void GetRulerState(SfxItemSet& rSet); 189 190 void ExecFormText(SfxRequest& rReq); 191 void GetFormTextState(SfxItemSet& rSet); 192 193 void ExecAnimationWin(SfxRequest& rReq); 194 void GetAnimationWinState(SfxItemSet& rSet); 195 196 void ExecNavigatorWin(SfxRequest& rReq); 197 void GetNavigatorWinState(SfxItemSet& rSet); 198 199 void ExecEffectWin(SfxRequest& rReq); 200 201 void Update3DWindow(); 202 void AssignFrom3DWindow(); 203 204 void ExecGallery(SfxRequest& rReq); 205 void GetGalleryState(SfxItemSet& rSet); 206 207 void ExecBmpMask( SfxRequest& rReq ); 208 void GetBmpMaskState( SfxItemSet& rSet ); 209 210 void ExecIMap( SfxRequest& rReq ); 211 void GetIMapState( SfxItemSet& rSet ); 212 213 void FuTemporary(SfxRequest& rReq); 214 void FuPermanent(SfxRequest& rReq); 215 void FuSupport(SfxRequest& rReq); 216 void FuTable(SfxRequest& rReq); 217 218 void AttrExec (SfxRequest& rReq); 219 void AttrState (SfxItemSet& rSet); 220 221 void ExecuteAnnotation (SfxRequest& rRequest); 222 void GetAnnotationState (SfxItemSet& rItemSet); 223 224 void StartRulerDrag ( 225 const Ruler& rRuler, 226 const MouseEvent& rMEvt); 227 228 virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False ); 229 230 PageKind GetPageKind() { return mePageKind; } 231 232 Point GetMousePos() { return maMousePos; } 233 sal_Bool IsMousePosFreezed() { return mbMousePosFreezed; } 234 void SetMousePosFreezed( sal_Bool bIn ) { mbMousePosFreezed = bIn; } 235 236 EditMode GetEditMode() const { return meEditMode; } 237 virtual SdPage* GetActualPage() { return mpActualPage; } 238 239 /// inherited from sd::ViewShell 240 virtual SdPage* getCurrentPage() const; 241 242 void ResetActualPage(); 243 void ResetActualLayer(); 244 sal_Bool SwitchPage(sal_uInt16 nPage); 245 sal_Bool IsSwitchPageAllowed() const; 246 247 sal_Bool GotoBookmark(const String& rBookmark); 248 void MakeVisible(const Rectangle& rRect, ::Window& rWin); 249 250 virtual void ReadFrameViewData(FrameView* pView); 251 virtual void WriteFrameViewData(); 252 253 virtual ErrCode DoVerb(long nVerb); 254 virtual sal_Bool ActivateObject(SdrOle2Obj* pObj, long nVerb); 255 256 void SetZoomOnPage( sal_Bool bZoom = sal_True ) { mbZoomOnPage = bZoom; } 257 sal_Bool IsZoomOnPage() { return mbZoomOnPage; } 258 void CheckLineTo (SfxRequest& rReq); 259 void FuTemp01(SfxRequest& rReq); 260 void FuTemp02(SfxRequest& rReq); 261 void FuTemp03(SfxRequest& rReq); 262 void FuTemp04(SfxRequest& rReq); 263 void SetChildWindowState( SfxItemSet& rSet ); 264 265 void UpdateIMapDlg( SdrObject* pObj ); 266 267 void LockInput(); 268 void UnlockInput(); 269 sal_Bool IsInputLocked() const { return mnLockCount > 0UL; } 270 271 sal_uInt16 GetCurPageId() { return( maTabControl.GetCurPageId() ); } 272 273 /** Show controls of the UI or hide them, depending on the given flag. 274 Do not call this method directly. Call the method at ViewShellBase 275 instead. 276 */ 277 virtual void ShowUIControls (bool bVisible = true); 278 279 void ScannerEvent( const ::com::sun::star::lang::EventObject& rEventObject ); 280 281 bool IsLayerModeActive (void) const; 282 283 sal_uInt16* GetSlotArray() const { return mpSlotArray; } 284 285 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper, 286 ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ); 287 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper, 288 ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ); 289 290 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False ); 291 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False ); 292 293 virtual void VisAreaChanged(const Rectangle& rRect); 294 295 /** Create an accessible object representing the specified window. 296 @param pWindow 297 The returned object makes the document displayed in this window 298 accessible. 299 @return 300 Returns an <type>AccessibleDrawDocumentView</type> object. 301 */ 302 virtual ::com::sun::star::uno::Reference< 303 ::com::sun::star::accessibility::XAccessible> 304 CreateAccessibleDocumentView (::sd::Window* pWindow); 305 306 /** Return the number of layers managed by the layer tab control. This 307 will usually differ from the number of layers managed by the layer 308 administrator. 309 @return 310 The number of layers managed by the layer tab control. The 311 returned value is independent of whether the layer modus is 312 currently active and the tab control is visible. 313 */ 314 virtual int GetTabLayerCount (void) const; 315 316 /** Return the numerical id of the currently active layer as seen by the 317 layer tab control. 318 @return 319 The returned id is a number between zero (inclusive) and the 320 number of layers as returned by the 321 <member>GetTabLayerCount</member> method (exclusive). 322 */ 323 virtual int GetActiveTabLayerIndex (void) const; 324 325 /** Set the active layer at the layer tab control and update the control 326 accordingly to reflect the change on screen. 327 @param nId 328 The id is expected to be a number between zero (inclusive) and 329 the number of layers as returned by the 330 <member>GetTabLayerCount</member> method (exclusive). Note that 331 Invalid values are ignored. No excpetion is thrown in that case. 332 */ 333 virtual void SetActiveTabLayerIndex (int nId); 334 335 /** Return a pointer to the tab control for pages. 336 */ 337 TabControl* GetPageTabControl (void); 338 339 /** Return a pointer to the tab control for layers. 340 */ 341 LayerTabBar* GetLayerTabControl (void); 342 343 /** Renames the given slide using an SvxNameDialog 344 345 @param nPageId the index of the page in the SdTabControl. 346 @param rName the new name of the slide. 347 348 @return false, if the new name is invalid for some reason. 349 350 <p>Implemented in <code>drviews8.cxx</code>.</p> 351 */ 352 bool RenameSlide( sal_uInt16 nPageId, const String & rName ); 353 354 /** modifies the given layer with the given values */ 355 void ModifyLayer( SdrLayer* pLayer, const String& rLayerName, const String& rLayerTitle, const String& rLayerDesc, bool bIsVisible, bool bIsLocked, bool bIsPrintable ); 356 357 virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void); 358 359 DrawView* GetDrawView() const { return mpDrawView; } 360 361 /** Relocation to a new parent window is not supported for DrawViewShell 362 objects so this method always returns <FALSE/>. 363 */ 364 virtual bool RelocateToParentWindow (::Window* pParentWindow); 365 366 protected: 367 DrawView* mpDrawView; 368 SdPage* mpActualPage; 369 Rectangle maMarkRect; 370 Point maMousePos; 371 sal_Bool mbMousePosFreezed; 372 TabControl maTabControl; 373 EditMode meEditMode; 374 PageKind mePageKind; 375 sal_Bool mbZoomOnPage; 376 sal_Bool mbIsRulerDrag; 377 sal_uLong mnLockCount; 378 Timer maCloseTimer; 379 sal_Bool mbReadOnly; 380 sal_uInt16* mpSlotArray; 381 382 static sal_Bool mbPipette; 383 384 DECL_LINK( ClipboardChanged, TransferableDataHelper* ); 385 DECL_LINK( CloseHdl, Timer* pTimer ); 386 DECL_LINK( TabSplitHdl, TabBar * ); 387 DECL_LINK( NameObjectHdl, AbstractSvxNameDialog* ); 388 DECL_LINK( RenameSlideHdl, AbstractSvxNameDialog* ); 389 390 void DeleteActualPage(); 391 void DeleteActualLayer(); 392 393 virtual SvxRuler* CreateHRuler(::sd::Window* pWin, sal_Bool bIsFirst); 394 virtual SvxRuler* CreateVRuler(::sd::Window* pWin); 395 virtual void UpdateHRuler(); 396 virtual void UpdateVRuler(); 397 virtual long GetHCtrlWidth(); 398 virtual void SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY); 399 virtual Size GetOptimalSizePixel() const; 400 401 void SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower, 402 sal_Bool bSize, sal_Bool bMargin, sal_Bool bScaleAll ); 403 404 sal_uInt16 GetIdBySubId( sal_uInt16 nSId ); 405 void MapSlot( sal_uInt16 nSId ); 406 void UpdateToolboxImages( SfxItemSet &rSet, sal_Bool bPermanent = sal_True ); 407 sal_uInt16 GetMappedSlot( sal_uInt16 nSId ); 408 sal_uInt16 GetArrayId( sal_uInt16 nSId ); 409 410 void GetMenuStateSel(SfxItemSet& rSet); 411 412 private: 413 /** This flag controls whether the layer mode is active, i.e. the layer 414 dialog is visible. 415 */ 416 bool mbIsLayerModeActive; 417 418 /** This item contains the clipboard formats of the current clipboard 419 content that are supported both by that content and by the 420 DrawViewShell. 421 */ 422 ::std::auto_ptr<SvxClipboardFmtItem> mpCurrentClipboardFormats; 423 424 /** On some occasions it is necessary to make SwitchPage calls 425 asynchronously. 426 */ 427 tools::AsynchronousCall maAsynchronousSwitchPageCall; 428 429 /** This flag is used to prevent nested calls to SwitchPage(). 430 */ 431 bool mbIsInSwitchPage; 432 433 void Construct (DrawDocShell* pDocSh, PageKind ePageKind); 434 435 /** Depending on the given request create a new page or duplicate an 436 existing one. See ViewShell::CreateOrDuplicatePage() for more 437 information. 438 */ 439 virtual SdPage* CreateOrDuplicatePage ( 440 SfxRequest& rRequest, 441 PageKind ePageKind, 442 SdPage* pPage, 443 const sal_Int32 nInsertPosition = -1); 444 445 ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager > mxScannerManager; 446 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > mxScannerListener; 447 TransferableClipboardListener* mpClipEvtLstnr; 448 sal_Bool mbPastePossible; 449 450 virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint); 451 452 /** Stop a running slide show. The frame the show is running in is 453 destroyed if 454 a) it is running in its own frame, i.e. is a full screen show and 455 b) the given flag bCloseFrame is true. 456 @param bCloseFrame 457 Be carefull with this flag when stopping a full screen show. 458 When called from the destructor the flag has to be <FALSE/> or 459 otherwise we run into a loop of calls to destructors of the view 460 and the frame. 461 When called from other places the flag should be <TRUE/> so that 462 not an empty frame remains. When called with <TRUE/> it is the 463 responsibility of the caller to avoid an illegal reentrant 464 call. 465 */ 466 void StopSlideShow (bool bCloseFrame); 467 468 /** Show the context menu for snap lines and points. Because snap lines 469 can not be selected the index of the snap line/point for which the 470 popup menu is opened has to be passed to the processing slot 471 handlers. This can be done only by manually showing the popup menu. 472 @param rPageView 473 The page view is used to access the help lines. 474 @param nSnapLineIndex 475 Index of the snap line or snap point for which to show the 476 context menu. 477 @param rMouseLocation 478 The mouse location defines the location at which to display the 479 context menu. 480 */ 481 void ShowSnapLineContextMenu ( 482 SdrPageView& rPageView, 483 const sal_uInt16 nSnapLineIndex, 484 const Point& rMouseLocation); 485 486 using ViewShell::Notify; 487 488 ::std::auto_ptr< AnnotationManager > mpAnnotationManager; 489 ::std::auto_ptr< ViewOverlayManager > mpViewOverlayManager; 490 }; 491 492 493 } // end of namespace sd 494 495 #endif 496