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