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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #include "DrawViewShell.hxx" 28 #include <cppuhelper/implbase1.hxx> 29 #include <comphelper/processfactory.hxx> 30 #ifndef _SVX_SIZEITEM 31 #include <editeng/sizeitem.hxx> 32 #endif 33 #include <svx/svdlayer.hxx> 34 #ifndef _SVX_ZOOMITEM 35 #include <svx/zoomitem.hxx> 36 #endif 37 #include <svx/svdpagv.hxx> 38 #include <svl/ptitem.hxx> 39 #include <svl/stritem.hxx> 40 #include <sfx2/request.hxx> 41 #include <sfx2/dispatch.hxx> 42 #include <svx/svdopath.hxx> 43 #include <sfx2/docfile.hxx> 44 #include <svx/zoomslideritem.hxx> 45 #include <svl/eitem.hxx> 46 47 #ifndef _SVX_DIALOGS_HRC 48 #include <svx/dialogs.hrc> 49 #endif 50 #include <svx/extrusionbar.hxx> 51 #include <svx/fontworkbar.hxx> 52 #include <svx/clipfmtitem.hxx> 53 54 55 #include <sfx2/viewfrm.hxx> 56 #include <svx/fmshell.hxx> 57 #include <sfx2/dispatch.hxx> 58 #include <svtools/cliplistener.hxx> 59 #include <svx/float3d.hxx> 60 #include "helpids.h" 61 62 #include "view/viewoverlaymanager.hxx" 63 #include "app.hrc" 64 #include "helpids.h" 65 #include "strings.hrc" 66 #include "res_bmp.hrc" 67 #include "sdpage.hxx" 68 #include "FrameView.hxx" 69 #include "drawdoc.hxx" 70 #include "sdresid.hxx" 71 #include "DrawDocShell.hxx" 72 #include "Window.hxx" 73 #include "fupoor.hxx" 74 #include "fusel.hxx" 75 #include "drawview.hxx" 76 #include "SdUnoDrawView.hxx" 77 #include "ViewShellBase.hxx" 78 #include "SdUnoDrawView.hxx" 79 #include "slideshow.hxx" 80 #include "ToolBarManager.hxx" 81 #include "annotationmanager.hxx" 82 83 using namespace ::rtl; 84 using namespace ::com::sun::star; 85 using namespace ::com::sun::star::uno; 86 87 namespace { 88 static const ::rtl::OUString MASTER_VIEW_TOOL_BAR_NAME( 89 ::rtl::OUString::createFromAscii("masterviewtoolbar")); 90 } 91 92 namespace sd { 93 94 sal_Bool DrawViewShell::mbPipette = sal_False; 95 96 // ------------------------ 97 // - ScannerEventListener - 98 // ------------------------ 99 100 class ScannerEventListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener > 101 { 102 private: 103 104 DrawViewShell* mpParent; 105 106 public: 107 108 ScannerEventListener( DrawViewShell* pParent ) : mpParent( pParent ) {}; 109 ~ScannerEventListener(); 110 111 // XEventListener 112 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException); 113 114 void ParentDestroyed() { mpParent = NULL; } 115 }; 116 117 // ----------------------------------------------------------------------------- 118 119 ScannerEventListener::~ScannerEventListener() 120 { 121 } 122 123 // ----------------------------------------------------------------------------- 124 125 void SAL_CALL ScannerEventListener::disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException) 126 { 127 if( mpParent ) 128 mpParent->ScannerEvent( rEventObject ); 129 } 130 131 /************************************************************************* 132 |* 133 |* Standard-Konstruktor 134 |* 135 \************************************************************************/ 136 137 DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, ::Window* pParentWindow, PageKind ePageKind, FrameView* pFrameViewArgument ) 138 : ViewShell (pFrame, pParentWindow, rViewShellBase) 139 , maTabControl(this, pParentWindow) 140 , mbIsInSwitchPage(false) 141 { 142 if (pFrameViewArgument != NULL) 143 mpFrameView = pFrameViewArgument; 144 else 145 mpFrameView = new FrameView(GetDoc()); 146 Construct(GetDocSh(), ePageKind); 147 } 148 149 /************************************************************************* 150 |* 151 |* Destruktor 152 |* 153 \************************************************************************/ 154 155 DrawViewShell::~DrawViewShell() 156 { 157 mpAnnotationManager.reset(); 158 mpViewOverlayManager.reset(); 159 160 OSL_ASSERT (GetViewShell()!=NULL); 161 162 if( mxScannerListener.is() ) 163 static_cast< ScannerEventListener* >( mxScannerListener.get() )->ParentDestroyed(); 164 165 // #96642# Remove references to items within Svx3DWin 166 // (maybe do a listening sometime in Svx3DWin) 167 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId(); 168 SfxChildWindow* pWindow = GetViewFrame() ? GetViewFrame()->GetChildWindow(nId) : NULL; 169 if(pWindow) 170 { 171 Svx3DWin* p3DWin = static_cast< Svx3DWin* > (pWindow->GetWindow()); 172 if(p3DWin) 173 p3DWin->DocumentReload(); 174 } 175 176 EndListening (*GetDoc()); 177 EndListening (*GetDocSh()); 178 179 if( SlideShow::IsRunning(*this) ) 180 StopSlideShow(false); 181 182 DisposeFunctions(); 183 184 SdPage* pPage; 185 sal_uInt16 aPageCnt = GetDoc()->GetSdPageCount(mePageKind); 186 187 for (sal_uInt16 i = 0; i < aPageCnt; i++) 188 { 189 pPage = GetDoc()->GetSdPage(i, mePageKind); 190 191 if (pPage == mpActualPage) 192 { 193 GetDoc()->SetSelected(pPage, sal_True); 194 } 195 else 196 { 197 GetDoc()->SetSelected(pPage, sal_False); 198 } 199 } 200 201 if ( mpClipEvtLstnr ) 202 { 203 mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False ); 204 mpClipEvtLstnr->ClearCallbackLink(); // #103849# prevent callback if another thread is waiting 205 mpClipEvtLstnr->release(); 206 } 207 208 delete mpDrawView; 209 // Set mpView to NULL so that the destructor of the ViewShell base class 210 // does not access it. 211 mpView = mpDrawView = NULL; 212 213 mpFrameView->Disconnect(); 214 delete [] mpSlotArray; 215 } 216 217 /************************************************************************* 218 |* 219 |* gemeinsamer Initialisierungsanteil der beiden Konstruktoren 220 |* 221 \************************************************************************/ 222 223 void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind) 224 { 225 mpActualPage = 0; 226 mbMousePosFreezed = sal_False; 227 mbReadOnly = GetDocSh()->IsReadOnly(); 228 mpSlotArray = 0; 229 mpClipEvtLstnr = 0; 230 mbPastePossible = sal_False; 231 mbIsLayerModeActive = false; 232 233 mpFrameView->Connect(); 234 235 OSL_ASSERT (GetViewShell()!=NULL); 236 237 // Array fuer Slot-/ImageMapping: 238 // Gerader Eintrag: Haupt-/ToolboxSlot 239 // Ungerader Eintrag: gemappter Slot 240 // Achtung: Anpassen von GetIdBySubId() !!! 241 // Reihenfolge (insbesondere Zoom) darf nicht geaendert werden !!! 242 mpSlotArray = new sal_uInt16[ SLOTARRAY_COUNT ]; 243 mpSlotArray[ 0 ] = SID_OBJECT_CHOOSE_MODE; 244 mpSlotArray[ 1 ] = SID_OBJECT_ROTATE; 245 mpSlotArray[ 2 ] = SID_OBJECT_ALIGN; 246 mpSlotArray[ 3 ] = SID_OBJECT_ALIGN_LEFT; 247 mpSlotArray[ 4 ] = SID_ZOOM_TOOLBOX; 248 mpSlotArray[ 5 ] = SID_ZOOM_TOOLBOX; 249 mpSlotArray[ 6 ] = SID_DRAWTBX_TEXT; 250 mpSlotArray[ 7 ] = SID_ATTR_CHAR; 251 mpSlotArray[ 8 ] = SID_DRAWTBX_RECTANGLES; 252 mpSlotArray[ 9 ] = SID_DRAW_RECT; 253 mpSlotArray[ 10 ] = SID_DRAWTBX_ELLIPSES; 254 mpSlotArray[ 11 ] = SID_DRAW_ELLIPSE; 255 mpSlotArray[ 12 ] = SID_DRAWTBX_LINES; 256 mpSlotArray[ 13 ] = SID_DRAW_FREELINE_NOFILL; 257 mpSlotArray[ 14 ] = SID_DRAWTBX_3D_OBJECTS; 258 mpSlotArray[ 15 ] = SID_3D_CUBE; 259 mpSlotArray[ 16 ] = SID_DRAWTBX_INSERT; 260 mpSlotArray[ 17 ] = SID_INSERT_DIAGRAM; 261 mpSlotArray[ 18 ] = SID_POSITION; 262 mpSlotArray[ 19 ] = SID_FRAME_TO_TOP; 263 mpSlotArray[ 20 ] = SID_DRAWTBX_CONNECTORS; 264 mpSlotArray[ 21 ] = SID_TOOL_CONNECTOR; 265 mpSlotArray[ 22 ] = SID_DRAWTBX_ARROWS; 266 mpSlotArray[ 23 ] = SID_LINE_ARROW_END; 267 268 SetPool( &GetDoc()->GetPool() ); 269 270 GetDoc()->CreateFirstPages(); 271 272 mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this); 273 mpView = mpDrawView; // Pointer der Basisklasse ViewShell 274 mpDrawView->SetSwapAsynchron(sal_True); // Asynchrones Laden von Graphiken 275 276 // We do not read the page kind from the frame view anymore so we have 277 // to set it in order to resync frame view and this view. 278 mpFrameView->SetPageKind(eInitialPageKind); 279 mePageKind = eInitialPageKind; 280 meEditMode = EM_PAGE; 281 DocumentType eDocType = GetDoc()->GetDocumentType(); // RTTI fasst hier noch nicht 282 switch (mePageKind) 283 { 284 case PK_STANDARD: 285 meShellType = ST_IMPRESS; 286 break; 287 288 case PK_NOTES: 289 meShellType = ST_NOTES; 290 break; 291 292 case PK_HANDOUT: 293 meShellType = ST_HANDOUT; 294 break; 295 } 296 297 Size aPageSize( GetDoc()->GetSdPage(0, mePageKind)->GetSize() ); 298 Point aPageOrg( aPageSize.Width(), aPageSize.Height() / 2); 299 Size aSize(aPageSize.Width() * 3, aPageSize.Height() * 2); 300 InitWindows(aPageOrg, aSize, Point(-1, -1)); 301 302 Point aVisAreaPos; 303 304 if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) 305 { 306 aVisAreaPos = pDocSh->GetVisArea(ASPECT_CONTENT).TopLeft(); 307 } 308 309 mpDrawView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize)); 310 311 // Objekte koennen max. so gross wie die ViewSize werden 312 GetDoc()->SetMaxObjSize(aSize); 313 314 // Split-Handler fuer TabControls 315 maTabControl.SetSplitHdl( LINK( this, DrawViewShell, TabSplitHdl ) ); 316 317 // Damit der richtige EditMode von der FrameView komplett eingestellt 318 // werden kann, wird hier ein aktuell anderer gewaehlt (kleiner Trick) 319 if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE) 320 { 321 meEditMode = EM_MASTERPAGE; 322 } 323 else 324 { 325 meEditMode = EM_PAGE; 326 } 327 328 // Einstellungen der FrameView uebernehmen 329 ReadFrameViewData(mpFrameView); 330 331 if( eDocType == DOCUMENT_TYPE_DRAW ) 332 { 333 SetHelpId( SD_IF_SDGRAPHICVIEWSHELL ); 334 GetActiveWindow()->SetHelpId( HID_SDGRAPHICVIEWSHELL ); 335 GetActiveWindow()->SetUniqueId( HID_SDGRAPHICVIEWSHELL ); 336 } 337 else 338 { 339 if (mePageKind == PK_NOTES) 340 { 341 SetHelpId( SID_NOTESMODE ); 342 GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE ); 343 GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE ); 344 345 // AutoLayouts muessen erzeugt sein 346 GetDoc()->StopWorkStartupDelay(); 347 } 348 else if (mePageKind == PK_HANDOUT) 349 { 350 SetHelpId( SID_HANDOUTMODE ); 351 GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE ); 352 GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE ); 353 354 // AutoLayouts muessen erzeugt sein 355 GetDoc()->StopWorkStartupDelay(); 356 } 357 else 358 { 359 SetHelpId( SD_IF_SDDRAWVIEWSHELL ); 360 GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL ); 361 GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL ); 362 } 363 } 364 365 // Selektionsfunktion starten 366 SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool()); 367 FuPermanent(aReq); 368 mpDrawView->SetFrameDragSingles(sal_True); 369 370 if (pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED) 371 { 372 mbZoomOnPage = sal_False; 373 } 374 else 375 { 376 mbZoomOnPage = sal_True; 377 } 378 379 mbIsRulerDrag = sal_False; 380 381 String aName( RTL_CONSTASCII_USTRINGPARAM("DrawViewShell")); 382 SetName (aName); 383 384 mnLockCount = 0UL; 385 386 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); 387 388 if( xMgr.is() ) 389 { 390 mxScannerManager = ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager >( 391 xMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.scanner.ScannerManager" ) ), 392 ::com::sun::star::uno::UNO_QUERY ); 393 394 if( mxScannerManager.is() ) 395 { 396 mxScannerListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >( 397 static_cast< ::cppu::OWeakObject* >( new ScannerEventListener( this ) ), 398 ::com::sun::star::uno::UNO_QUERY ); 399 } 400 } 401 402 mpAnnotationManager.reset( new AnnotationManager( GetViewShellBase() ) ); 403 mpViewOverlayManager.reset( new ViewOverlayManager( GetViewShellBase() ) ); 404 } 405 406 407 408 409 void DrawViewShell::Init (bool bIsMainViewShell) 410 { 411 ViewShell::Init(bIsMainViewShell); 412 413 StartListening (*GetDocSh()); 414 } 415 416 417 418 419 void DrawViewShell::Shutdown (void) 420 { 421 ViewShell::Shutdown(); 422 423 if(SlideShow::IsRunning( GetViewShellBase() ) ) 424 { 425 // Turn off effects. 426 GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE); 427 } 428 } 429 430 431 432 433 css::uno::Reference<css::drawing::XDrawSubController> DrawViewShell::CreateSubController (void) 434 { 435 css::uno::Reference<css::drawing::XDrawSubController> xSubController; 436 437 if (IsMainViewShell()) 438 { 439 // Create uno sub controller for the main view shell. 440 xSubController = css::uno::Reference<css::drawing::XDrawSubController>( 441 new SdUnoDrawView ( 442 GetViewShellBase().GetDrawController(), 443 *this, 444 *GetView())); 445 } 446 447 return xSubController; 448 } 449 450 451 452 453 bool DrawViewShell::RelocateToParentWindow (::Window* pParentWindow) 454 { 455 // DrawViewShells can not be relocated to a new parent window at the 456 // moment, so return <FALSE/> except when the given parent window is the 457 // parent window that is already in use. 458 return pParentWindow==GetParentWindow(); 459 } 460 461 462 463 464 /************************************************************************* 465 |* 466 |* pruefe ob linienzuege gezeichnet werden muessen 467 |* 468 \************************************************************************/ 469 470 /* 471 linienzuege werden ueber makros als folge von 472 MoveTo (x, y) 473 LineTo (x, y) [oder BezierTo (x, y)] 474 LineTo (x, y) 475 : 476 dargestellt. einen endbefehl fuer die linienzuege 477 gibt es nicht, also muessen alle befehle in den 478 requests nach LineTo (BezierTo) abgetestet und die 479 punktparameter gesammelt werden. 480 der erste nicht-LineTo fuehrt dann dazu, dass aus 481 den gesammelten punkten der linienzug erzeugt wird 482 */ 483 484 void DrawViewShell::CheckLineTo(SfxRequest& rReq) 485 { 486 (void)rReq; 487 #ifdef DBG_UTIL 488 if(rReq.IsAPI()) 489 { 490 if(SID_LINETO == rReq.GetSlot() || SID_BEZIERTO == rReq.GetSlot() || SID_MOVETO == rReq.GetSlot() ) 491 { 492 DBG_ERROR("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported."); 493 } 494 } 495 #endif 496 497 rReq.Ignore (); 498 } 499 500 /************************************************************************* 501 |* 502 |* veraendere die seitemparameter, wenn SID_PAGESIZE oder SID_PAGEMARGIN 503 |* 504 \************************************************************************/ 505 506 void DrawViewShell::SetupPage (Size &rSize, 507 long nLeft, 508 long nRight, 509 long nUpper, 510 long nLower, 511 sal_Bool bSize, 512 sal_Bool bMargin, 513 sal_Bool bScaleAll) 514 { 515 sal_uInt16 nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); 516 sal_uInt16 i; 517 518 for (i = 0; i < nPageCnt; i++) 519 { 520 /********************************************************************** 521 * Erst alle MasterPages bearbeiten 522 **********************************************************************/ 523 SdPage *pPage = GetDoc()->GetMasterSdPage(i, mePageKind); 524 525 if( pPage ) 526 { 527 if( bSize ) 528 { 529 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower); 530 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll); 531 pPage->SetSize(rSize); 532 533 } 534 if( bMargin ) 535 { 536 pPage->SetLftBorder(nLeft); 537 pPage->SetRgtBorder(nRight); 538 pPage->SetUppBorder(nUpper); 539 pPage->SetLwrBorder(nLower); 540 } 541 542 if ( mePageKind == PK_STANDARD ) 543 { 544 GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout(); 545 } 546 547 pPage->CreateTitleAndLayout(); 548 } 549 } 550 551 nPageCnt = GetDoc()->GetSdPageCount(mePageKind); 552 553 for (i = 0; i < nPageCnt; i++) 554 { 555 /********************************************************************** 556 * Danach alle Pages bearbeiten 557 **********************************************************************/ 558 SdPage *pPage = GetDoc()->GetSdPage(i, mePageKind); 559 560 if( pPage ) 561 { 562 if( bSize ) 563 { 564 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower); 565 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll); 566 pPage->SetSize(rSize); 567 } 568 if( bMargin ) 569 { 570 pPage->SetLftBorder(nLeft); 571 pPage->SetRgtBorder(nRight); 572 pPage->SetUppBorder(nUpper); 573 pPage->SetLwrBorder(nLower); 574 } 575 576 if ( mePageKind == PK_STANDARD ) 577 { 578 SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES); 579 pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() ); 580 } 581 582 pPage->SetAutoLayout( pPage->GetAutoLayout() ); 583 } 584 } 585 586 if ( mePageKind == PK_STANDARD ) 587 { 588 SdPage* pHandoutPage = GetDoc()->GetSdPage(0, PK_HANDOUT); 589 pHandoutPage->CreateTitleAndLayout(sal_True); 590 } 591 592 long nWidth = mpActualPage->GetSize().Width(); 593 long nHeight = mpActualPage->GetSize().Height(); 594 595 Point aPageOrg(nWidth, nHeight / 2); 596 Size aSize( nWidth * 3, nHeight * 2); 597 598 InitWindows(aPageOrg, aSize, Point(-1, -1), sal_True); 599 600 Point aVisAreaPos; 601 602 if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) 603 { 604 aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft(); 605 } 606 607 GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize)); 608 609 UpdateScrollBars(); 610 611 Point aNewOrigin(mpActualPage->GetLftBorder(), mpActualPage->GetUppBorder()); 612 GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin); 613 614 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET); 615 616 // auf (neue) Seitengroesse zoomen 617 GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, 618 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); 619 } 620 621 /************************************************************************* 622 |* 623 |* Statuswerte der Statusbar zurueckgeben 624 |* 625 \************************************************************************/ 626 627 void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) 628 { 629 // Zoom-Item 630 // Hier sollte der entsprechende Wert (Optimal ?, Seitenbreite oder 631 // Seite) mit Hilfe des ZoomItems weitergegeben werden !!! 632 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) ) 633 { 634 if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) ) 635 { 636 rSet.DisableItem( SID_ATTR_ZOOM ); 637 } 638 else 639 { 640 SvxZoomItem* pZoomItem; 641 sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom(); 642 643 if( mbZoomOnPage ) 644 pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom ); 645 else 646 pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom ); 647 648 // Bereich einschraenken 649 sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL; 650 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 651 652 if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) ) 653 // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) ) 654 { 655 nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL; 656 } 657 658 pZoomItem->SetValueSet( nZoomValues ); 659 rSet.Put( *pZoomItem ); 660 delete pZoomItem; 661 } 662 } 663 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) ) 664 { 665 rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) ); 666 if (GetDocSh()->IsUIActive() || (xSlideshow.is() && xSlideshow->isRunning()) || !GetActiveWindow() ) 667 { 668 rSet.DisableItem( SID_ATTR_ZOOMSLIDER ); 669 } 670 else 671 { 672 sd::Window * pActiveWindow = GetActiveWindow(); 673 SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ; 674 675 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 676 if( pPageView ) 677 { 678 Point aPagePos(0, 0); 679 Size aPageSize = pPageView->GetPage()->GetSize(); 680 681 aPagePos.X() += aPageSize.Width() / 2; 682 aPageSize.Width() = (long) (aPageSize.Width() * 1.03); 683 684 aPagePos.Y() += aPageSize.Height() / 2; 685 aPageSize.Height() = (long) (aPageSize.Height() * 1.03); 686 aPagePos.Y() -= aPageSize.Height() / 2; 687 688 aPagePos.X() -= aPageSize.Width() / 2; 689 690 Rectangle aFullPageZoomRect( aPagePos, aPageSize ); 691 aZoomItem.AddSnappingPoint( pActiveWindow->GetZoomForRect( aFullPageZoomRect ) ); 692 } 693 aZoomItem.AddSnappingPoint(100); 694 rSet.Put( aZoomItem ); 695 } 696 } 697 698 Point aPos = GetActiveWindow()->PixelToLogic(maMousePos); 699 mpDrawView->GetSdrPageView()->LogicToPagePos(aPos); 700 Fraction aUIScale(GetDoc()->GetUIScale()); 701 aPos.X() = Fraction(aPos.X()) / aUIScale; 702 aPos.Y() = Fraction(aPos.Y()) / aUIScale; 703 704 // Position- und Groesse-Items 705 if ( mpDrawView->IsAction() ) 706 { 707 Rectangle aRect; 708 mpDrawView->TakeActionRect( aRect ); 709 710 if ( aRect.IsEmpty() ) 711 rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) ); 712 else 713 { 714 mpDrawView->GetSdrPageView()->LogicToPagePos(aRect); 715 aPos = aRect.TopLeft(); 716 aPos.X() = Fraction(aPos.X()) / aUIScale; 717 aPos.Y() = Fraction(aPos.Y()) / aUIScale; 718 rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) ); 719 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); 720 aSize.Height() = Fraction(aSize.Height()) / aUIScale; 721 aSize.Width() = Fraction(aSize.Width()) / aUIScale; 722 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) ); 723 } 724 } 725 else 726 { 727 if ( mpDrawView->AreObjectsMarked() ) 728 { 729 Rectangle aRect = mpDrawView->GetAllMarkedRect(); 730 mpDrawView->GetSdrPageView()->LogicToPagePos(aRect); 731 732 // Show the position of the selected shape(s) 733 Point aShapePosition (aRect.TopLeft()); 734 aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale; 735 aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale; 736 rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition)); 737 738 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); 739 aSize.Height() = Fraction(aSize.Height()) / aUIScale; 740 aSize.Width() = Fraction(aSize.Width()) / aUIScale; 741 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) ); 742 } 743 else 744 { 745 rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) ); 746 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) ); 747 } 748 } 749 750 // Display of current page and layer. 751 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) ) 752 { 753 // Allways show the slide/page number. 754 String aString (SdResId( STR_SD_PAGE )); 755 aString += sal_Unicode(' '); 756 aString += UniString::CreateFromInt32( maTabControl.GetCurPageId() ); 757 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " )); 758 aString += UniString::CreateFromInt32( GetDoc()->GetSdPageCount( mePageKind ) ); 759 760 // If in layer mode additionally show the layer that contains all 761 // selected shapes of the page. If the shapes are distributed on 762 // more than one layer, no layer name is shown. 763 if (IsLayerModeActive()) 764 { 765 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); 766 SdrLayerID nLayer = 0, nOldLayer = 0; 767 SdrLayer* pLayer = NULL; 768 SdrObject* pObj = NULL; 769 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 770 sal_uLong nMarkCount = rMarkList.GetMarkCount(); 771 FASTBOOL bOneLayer = sal_True; 772 773 // Use the first ten selected shapes as a (hopefully 774 // representative) sample of all shapes of the current page. 775 // Detect whether they belong to the same layer. 776 for( sal_uLong j = 0; j < nMarkCount && bOneLayer && j < 10; j++ ) 777 { 778 pObj = rMarkList.GetMark( j )->GetMarkedSdrObj(); 779 if( pObj ) 780 { 781 nLayer = pObj->GetLayer(); 782 783 if( j != 0 && nLayer != nOldLayer ) 784 bOneLayer = sal_False; 785 786 nOldLayer = nLayer; 787 } 788 } 789 790 // Append the layer name to the current page number. 791 if( bOneLayer && nMarkCount ) 792 { 793 pLayer = rLayerAdmin.GetLayerPerID( nLayer ); 794 if( pLayer ) 795 { 796 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" )); 797 aString += pLayer->GetName(); 798 aString += sal_Unicode(')'); 799 } 800 } 801 } 802 803 rSet.Put (SfxStringItem (SID_STATUS_PAGE, aString)); 804 } 805 // Layout 806 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) ) 807 { 808 String aString = mpActualPage->GetLayoutName(); 809 aString.Erase( aString.SearchAscii( SD_LT_SEPARATOR ) ); 810 rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) ); 811 } 812 } 813 814 815 816 void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint) 817 { 818 const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* >(&rHint); 819 if (pSimple!=NULL && pSimple->GetId()==SFX_HINT_MODECHANGED) 820 { 821 // Change to selection when turning on read-only mode. 822 if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) ) 823 { 824 SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool()); 825 FuPermanent(aReq); 826 } 827 828 // Turn on design mode when document is not read-only. 829 if (GetDocSh()->IsReadOnly() != mbReadOnly ) 830 { 831 mbReadOnly = GetDocSh()->IsReadOnly(); 832 833 SfxBoolItem aItem( SID_FM_DESIGN_MODE, !mbReadOnly ); 834 GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE, 835 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L ); 836 } 837 } 838 839 } 840 841 void DrawViewShell::ExecuteAnnotation (SfxRequest& rRequest) 842 { 843 if( mpAnnotationManager.get() ) 844 mpAnnotationManager->ExecuteAnnotation( rRequest ); 845 } 846 847 // -------------------------------------------------------------------- 848 849 void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet ) 850 { 851 if( mpAnnotationManager.get() ) 852 mpAnnotationManager->GetAnnotationState( rItemSet ); 853 } 854 855 856 } // end of namespace sd 857