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