1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #include "DrawViewShell.hxx" 32 #include "ViewShellImplementation.hxx" 33 34 #include "DrawController.hxx" 35 #include <com/sun/star/embed/EmbedStates.hpp> 36 37 #include "comphelper/anytostring.hxx" 38 #include "comphelper/scopeguard.hxx" 39 #include "cppuhelper/exc_hlp.hxx" 40 #include "rtl/ref.hxx" 41 42 #ifndef _SVXIDS_HRC 43 #include <svx/svxids.hrc> 44 #endif 45 #include <svx/svdpagv.hxx> 46 #include <sfx2/viewfrm.hxx> 47 #include <sfx2/bindings.hxx> 48 #include <svx/svdoole2.hxx> 49 #include <sfx2/dispatch.hxx> 50 #include <vcl/scrbar.hxx> 51 #include <svx/svdograf.hxx> 52 #include <svx/svdopage.hxx> 53 #include <vcl/msgbox.hxx> 54 #include <sot/storage.hxx> 55 #include <svx/fmshell.hxx> 56 #include <svx/globl3d.hxx> 57 #include <svx/fmglob.hxx> 58 #include <editeng/outliner.hxx> 59 60 61 #include "misc.hxx" 62 63 #ifdef STARIMAGE_AVAILABLE 64 #ifndef _SIMDLL_HXX 65 #include <sim2/simdll.hxx> 66 #endif 67 #endif 68 69 #include <svx/dialogs.hrc> 70 71 #include "view/viewoverlaymanager.hxx" 72 73 #include "glob.hrc" 74 #include "app.hrc" 75 #include "res_bmp.hrc" 76 #include "strings.hrc" 77 #include "helpids.h" 78 79 #include "app.hxx" 80 #include "fupoor.hxx" 81 #include "sdresid.hxx" 82 #include "fusel.hxx" 83 #include "sdpage.hxx" 84 #include "FrameView.hxx" 85 #include "stlpool.hxx" 86 #include "Window.hxx" 87 #ifndef SD_DRAWVIEW_HXX 88 #include "drawview.hxx" 89 #endif 90 #include "drawdoc.hxx" 91 #include "DrawDocShell.hxx" 92 #include "Ruler.hxx" 93 #include "Client.hxx" 94 #include "slideshow.hxx" 95 #include "optsitem.hxx" 96 #include "fusearch.hxx" 97 #include "Outliner.hxx" 98 #include "AnimationChildWindow.hxx" 99 #include "SdUnoDrawView.hxx" 100 #include "ToolBarManager.hxx" 101 #include "FormShellManager.hxx" 102 #include "ViewShellBase.hxx" 103 #include "LayerDialogChildWindow.hxx" 104 #include "LayerTabBar.hxx" 105 #include "ViewShellManager.hxx" 106 #include "ViewShellHint.hxx" 107 108 #include <sfx2/request.hxx> 109 #include <boost/bind.hpp> 110 111 #ifdef _MSC_VER 112 #if (_MSC_VER < 1400) 113 #pragma optimize ( "", off ) 114 #endif 115 #endif 116 117 using namespace com::sun::star; 118 119 namespace sd { 120 121 void DrawViewShell::Activate(sal_Bool bIsMDIActivate) 122 { 123 ViewShell::Activate(bIsMDIActivate); 124 } 125 126 void DrawViewShell::UIActivating( SfxInPlaceClient* pCli ) 127 { 128 ViewShell::UIActivating(pCli); 129 130 // #94252# Disable own controls 131 maTabControl.Disable(); 132 if (GetLayerTabControl() != NULL) 133 GetLayerTabControl()->Disable(); 134 } 135 136 void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli ) 137 { 138 // #94252# Enable own controls 139 maTabControl.Enable(); 140 if (GetLayerTabControl() != NULL) 141 GetLayerTabControl()->Enable(); 142 143 ViewShell::UIDeactivated(pCli); 144 } 145 146 147 /************************************************************************* 148 |* 149 |* Deactivate() 150 |* 151 \************************************************************************/ 152 153 void DrawViewShell::Deactivate(sal_Bool bIsMDIActivate) 154 { 155 ViewShell::Deactivate(bIsMDIActivate); 156 } 157 158 namespace 159 { 160 class LockUI 161 { 162 private: 163 void Lock(bool bLock); 164 SfxViewFrame *mpFrame; 165 public: 166 LockUI(SfxViewFrame *pFrame) : mpFrame(pFrame) { Lock(true); } 167 ~LockUI() { Lock(false); } 168 169 }; 170 171 void LockUI::Lock(bool bLock) 172 { 173 if (!mpFrame) 174 return; 175 mpFrame->Enable( !bLock ); 176 } 177 } 178 179 /************************************************************************* 180 |* 181 |* Wird gerufen, wenn sich der Selektionszustand der View aendert 182 |* 183 \************************************************************************/ 184 void DrawViewShell::SelectionHasChanged (void) 185 { 186 Invalidate(); 187 188 //Update3DWindow(); // 3D-Controller 189 SfxBoolItem aItem( SID_3D_STATE, sal_True ); 190 GetViewFrame()->GetDispatcher()->Execute( 191 SID_3D_STATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L ); 192 193 SdrOle2Obj* pOleObj = NULL; 194 SdrGrafObj* pGrafObj = NULL; 195 196 if ( mpDrawView->AreObjectsMarked() ) 197 { 198 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 199 200 if (rMarkList.GetMarkCount() == 1) 201 { 202 SdrMark* pMark = rMarkList.GetMark(0); 203 SdrObject* pObj = pMark->GetMarkedSdrObj(); 204 205 sal_uInt32 nInv = pObj->GetObjInventor(); 206 sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier(); 207 208 if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2) 209 { 210 pOleObj = (SdrOle2Obj*) pObj; 211 UpdateIMapDlg( pObj ); 212 } 213 else if (nSdrObjKind == OBJ_GRAF) 214 { 215 pGrafObj = (SdrGrafObj*) pObj; 216 UpdateIMapDlg( pObj ); 217 } 218 } 219 } 220 221 ViewShellBase& rBase = GetViewShellBase(); 222 rBase.SetVerbs( uno::Sequence< embed::VerbDescriptor >() ); 223 224 try 225 { 226 Client* pIPClient = static_cast<Client*>(rBase.GetIPClient()); 227 if ( pIPClient && pIPClient->IsObjectInPlaceActive() ) 228 { 229 /********************************************************************** 230 * Ggf. OLE-Objekt beruecksichtigen und deaktivieren 231 **********************************************************************/ 232 233 // this means we recently deselected an inplace active ole object so 234 // we need to deselect it now 235 if (!pOleObj) 236 { 237 //#i47279# disable frame until after object has completed unload 238 LockUI aUILock(GetViewFrame()); 239 pIPClient->DeactivateObject(); 240 //HMHmpDrView->ShowMarkHdl(); 241 } 242 else 243 { 244 uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef(); 245 if ( xObj.is() ) 246 { 247 rBase.SetVerbs( xObj->getSupportedVerbs() ); 248 } 249 else 250 { 251 rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() ); 252 } 253 } 254 } 255 else 256 { 257 if ( pOleObj ) 258 { 259 uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef(); 260 if ( xObj.is() ) 261 { 262 rBase.SetVerbs( xObj->getSupportedVerbs() ); 263 } 264 else 265 { 266 rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() ); 267 } 268 } 269 else 270 { 271 rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() ); 272 } 273 } 274 } 275 catch( ::com::sun::star::uno::Exception& e ) 276 { 277 (void)e; 278 DBG_ERROR( 279 (rtl::OString("sd::DrawViewShell::SelectionHasChanged(), " 280 "exception caught: ") + 281 rtl::OUStringToOString( 282 comphelper::anyToString( cppu::getCaughtException() ), 283 RTL_TEXTENCODING_UTF8 )).getStr() ); 284 } 285 286 if( HasCurrentFunction() ) 287 { 288 GetCurrentFunction()->SelectionHasChanged(); 289 } 290 else 291 { 292 GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView); 293 } 294 295 // #96124# Invalidate for every subshell 296 GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this); 297 298 mpDrawView->UpdateSelectionClipboard( sal_False ); 299 300 GetViewShellBase().GetDrawController().FireSelectionChangeListener(); 301 } 302 303 304 /************************************************************************* 305 |* 306 |* Zoomfaktor setzen 307 |* 308 \************************************************************************/ 309 310 void DrawViewShell::SetZoom( long nZoom ) 311 { 312 // Make sure that the zoom factor will not be recalculated on 313 // following window resizings. 314 mbZoomOnPage = sal_False; 315 ViewShell::SetZoom( nZoom ); 316 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); 317 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); 318 mpViewOverlayManager->onZoomChanged(); 319 } 320 321 /************************************************************************* 322 |* 323 |* Zoomrechteck fuer aktives Fenster einstellen 324 |* 325 \************************************************************************/ 326 327 void DrawViewShell::SetZoomRect( const Rectangle& rZoomRect ) 328 { 329 ViewShell::SetZoomRect( rZoomRect ); 330 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); 331 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); 332 mpViewOverlayManager->onZoomChanged(); 333 } 334 335 /************************************************************************* 336 |* 337 |* PrepareClose, ggfs. Texteingabe beenden, damit andere Viewshells ein 338 |* aktualisiertes Textobjekt vorfinden 339 |* 340 \************************************************************************/ 341 342 sal_uInt16 DrawViewShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing ) 343 { 344 if ( ViewShell::PrepareClose(bUI, bForBrowsing) != sal_True ) 345 return sal_False; 346 347 sal_Bool bRet = sal_True; 348 349 if( bRet && HasCurrentFunction() ) 350 { 351 sal_uInt16 nID = GetCurrentFunction()->GetSlotID(); 352 if (nID == SID_TEXTEDIT || nID == SID_ATTR_CHAR) 353 { 354 mpDrawView->SdrEndTextEdit(); 355 } 356 } 357 else if( !bRet ) 358 { 359 maCloseTimer.SetTimeoutHdl( LINK( this, DrawViewShell, CloseHdl ) ); 360 maCloseTimer.SetTimeout( 20 ); 361 maCloseTimer.Start(); 362 } 363 364 return bRet; 365 } 366 367 /************************************************************************* 368 |* 369 |* Status (Enabled/Disabled) von Menue-SfxSlots setzen 370 |* 371 \************************************************************************/ 372 373 void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive) 374 { 375 if (meEditMode != eEMode || mbIsLayerModeActive != bIsLayerModeActive) 376 { 377 ViewShellManager::UpdateLock aLock (GetViewShellBase().GetViewShellManager()); 378 379 sal_uInt16 nActualPageNum = 0; 380 381 GetViewShellBase().GetDrawController().FireChangeEditMode (eEMode == EM_MASTERPAGE); 382 GetViewShellBase().GetDrawController().FireChangeLayerMode (bIsLayerModeActive); 383 384 if ( mpDrawView->IsTextEdit() ) 385 { 386 mpDrawView->SdrEndTextEdit(); 387 } 388 389 LayerTabBar* pLayerBar = GetLayerTabControl(); 390 if (pLayerBar != NULL) 391 pLayerBar->EndEditMode(); 392 maTabControl.EndEditMode(); 393 394 if (mePageKind == PK_HANDOUT) 395 { 396 // Bei Handzetteln nur MasterPage zulassen 397 eEMode = EM_MASTERPAGE; 398 } 399 400 meEditMode = eEMode; 401 mbIsLayerModeActive = bIsLayerModeActive; 402 403 // Determine whether to show the master view toolbar. The master 404 // page mode has to be active and the shell must not be a handout 405 // view. 406 bool bShowMasterViewToolbar (meEditMode == EM_MASTERPAGE 407 && GetShellType() != ViewShell::ST_HANDOUT); 408 409 // If the master view toolbar is not shown we hide it before 410 // switching the edit mode. 411 if (::sd::ViewShell::mpImpl->mbIsInitialized 412 && IsMainViewShell() 413 && ! bShowMasterViewToolbar) 414 { 415 GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE); 416 } 417 418 if (meEditMode == EM_PAGE) 419 { 420 /****************************************************************** 421 * PAGEMODE 422 ******************************************************************/ 423 424 maTabControl.Clear(); 425 426 SdPage* pPage; 427 String aPageName; 428 sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind); 429 430 for (sal_uInt16 i = 0; i < nPageCnt; i++) 431 { 432 pPage = GetDoc()->GetSdPage(i, mePageKind); 433 aPageName = pPage->GetName(); 434 maTabControl.InsertPage(i + 1, aPageName); 435 436 if ( pPage->IsSelected() && nActualPageNum == 0 ) 437 { 438 nActualPageNum = i; 439 } 440 } 441 442 maTabControl.SetCurPageId(nActualPageNum + 1); 443 444 SwitchPage(nActualPageNum); 445 } 446 else 447 { 448 /****************************************************************** 449 * MASTERPAGE 450 ******************************************************************/ 451 GetViewFrame()->SetChildWindow( 452 AnimationChildWindow::GetChildWindowId(), sal_False ); 453 454 if (!mpActualPage) 455 { 456 // Sofern es keine mpActualPage gibt, wird die erste genommen 457 mpActualPage = GetDoc()->GetSdPage(0, mePageKind); 458 } 459 460 maTabControl.Clear(); 461 sal_uInt16 nActualMasterPageNum = 0; 462 sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); 463 464 for (sal_uInt16 i = 0; i < nMasterPageCnt; i++) 465 { 466 SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind); 467 String aLayoutName(pMaster->GetLayoutName()); 468 aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR)); 469 470 maTabControl.InsertPage(i + 1, aLayoutName); 471 472 if (&(mpActualPage->TRG_GetMasterPage()) == pMaster) 473 { 474 nActualMasterPageNum = i; 475 } 476 } 477 478 maTabControl.SetCurPageId(nActualMasterPageNum + 1); 479 SwitchPage(nActualMasterPageNum); 480 } 481 482 // If the master view toolbar is to be shown we turn it on after the 483 // edit mode has been changed. 484 if (::sd::ViewShell::mpImpl->mbIsInitialized 485 && IsMainViewShell() 486 && bShowMasterViewToolbar) 487 { 488 GetViewShellBase().GetToolBarManager()->SetToolBar( 489 ToolBarManager::TBG_MASTER_MODE, 490 ToolBarManager::msMasterViewToolBar); 491 } 492 493 if ( ! mbIsLayerModeActive) 494 { 495 maTabControl.Show(); 496 // Set the tab control only for draw pages. For master page 497 // this has been done already above. 498 if (meEditMode == EM_PAGE) 499 maTabControl.SetCurPageId (nActualPageNum + 1); 500 } 501 /*AF: The LayerDialogChildWindow is not used anymore (I hope). 502 if (GetViewFrame()->KnowsChildWindow( 503 LayerDialogChildWindow::GetChildWindowId())) 504 { 505 GetViewFrame()->SetChildWindow( 506 LayerDialogChildWindow::GetChildWindowId(), 507 IsLayerModeActive()); 508 } 509 */ 510 ResetActualLayer(); 511 512 Invalidate( SID_PAGEMODE ); 513 Invalidate( SID_LAYERMODE ); 514 Invalidate( SID_MASTERPAGE ); 515 Invalidate( SID_DELETE_MASTER_PAGE ); 516 Invalidate( SID_DELETE_PAGE ); 517 Invalidate( SID_SLIDE_MASTERPAGE ); 518 Invalidate( SID_TITLE_MASTERPAGE ); 519 Invalidate( SID_NOTES_MASTERPAGE ); 520 Invalidate( SID_HANDOUT_MASTERPAGE ); 521 } 522 } 523 524 525 526 527 bool DrawViewShell::IsLayerModeActive (void) const 528 { 529 return mbIsLayerModeActive; 530 } 531 532 533 534 535 /************************************************************************* 536 |* 537 |* Groesse des TabControls und der ModeButtons zurueckgeben 538 |* 539 \************************************************************************/ 540 541 long DrawViewShell::GetHCtrlWidth() 542 { 543 // return maTabControl.GetSizePixel().Width(); 544 return 0; 545 } 546 547 548 /************************************************************************* 549 |* 550 |* Horizontales Lineal erzeugen 551 |* 552 \************************************************************************/ 553 554 SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, sal_Bool bIsFirst) 555 { 556 Ruler* pRuler; 557 WinBits aWBits; 558 sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT; 559 560 if ( bIsFirst ) 561 { 562 aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD; 563 nFlags |= ( SVXRULER_SUPPORT_SET_NULLOFFSET | 564 SVXRULER_SUPPORT_TABS | 565 SVXRULER_SUPPORT_PARAGRAPH_MARGINS ); // Neu 566 } 567 else 568 aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER; 569 570 pRuler = new Ruler (*this, GetParentWindow(), pWin, nFlags, 571 GetViewFrame()->GetBindings(), aWBits); 572 pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit()); 573 574 // Metric ... 575 sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit(); 576 577 if( nMetric == 0xffff ) 578 nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit(); 579 580 pRuler->SetUnit( FieldUnit( nMetric ) ); 581 582 // ... und auch DefTab am Lineal einstellen 583 pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // Neu 584 585 Fraction aUIScale(pWin->GetMapMode().GetScaleX()); 586 aUIScale *= GetDoc()->GetUIScale(); 587 pRuler->SetZoom(aUIScale); 588 589 return pRuler; 590 } 591 592 /************************************************************************* 593 |* 594 |* Vertikales Lineal erzeugen 595 |* 596 \************************************************************************/ 597 598 SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin) 599 { 600 Ruler* pRuler; 601 WinBits aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER; 602 sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT; 603 604 pRuler = new Ruler(*this, GetParentWindow(), pWin, nFlags, 605 GetViewFrame()->GetBindings(), aWBits); 606 pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit()); 607 608 // #96629# Metric same as HRuler, use document setting 609 sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit(); 610 611 if( nMetric == 0xffff ) 612 nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit(); 613 614 pRuler->SetUnit( FieldUnit( nMetric ) ); 615 616 Fraction aUIScale(pWin->GetMapMode().GetScaleY()); 617 aUIScale *= GetDoc()->GetUIScale(); 618 pRuler->SetZoom(aUIScale); 619 620 return pRuler; 621 } 622 623 /************************************************************************* 624 |* 625 |* Horizontales Lineal aktualisieren 626 |* 627 \************************************************************************/ 628 629 void DrawViewShell::UpdateHRuler() 630 { 631 Invalidate( SID_ATTR_LONG_LRSPACE ); 632 Invalidate( SID_RULER_PAGE_POS ); 633 Invalidate( SID_RULER_OBJECT ); 634 Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT ); 635 636 if (mpHorizontalRuler.get() != NULL) 637 mpHorizontalRuler->ForceUpdate(); 638 } 639 640 /************************************************************************* 641 |* 642 |* Vertikales Lineal aktualisieren 643 |* 644 \************************************************************************/ 645 646 void DrawViewShell::UpdateVRuler() 647 { 648 Invalidate( SID_ATTR_LONG_LRSPACE ); 649 Invalidate( SID_RULER_PAGE_POS ); 650 Invalidate( SID_RULER_OBJECT ); 651 652 if (mpVerticalRuler.get() != NULL) 653 mpVerticalRuler->ForceUpdate(); 654 } 655 656 /************************************************************************* 657 |* 658 |* Metrik setzen 659 |* 660 \************************************************************************/ 661 662 void DrawViewShell::SetUIUnit(FieldUnit eUnit) 663 { 664 ViewShell::SetUIUnit(eUnit); 665 } 666 667 /************************************************************************* 668 |* 669 |* TabControl nach Splitteraenderung aktualisieren 670 |* 671 \************************************************************************/ 672 673 IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab ) 674 { 675 const long int nMax = maViewSize.Width() - maScrBarWH.Width() 676 - maTabControl.GetPosPixel().X() ; 677 678 Size aTabSize = maTabControl.GetSizePixel(); 679 aTabSize.Width() = Min(pTab->GetSplitSize(), (long)(nMax-1)); 680 681 maTabControl.SetSizePixel(aTabSize); 682 GetLayerTabControl()->SetSizePixel(aTabSize); 683 684 Point aPos = maTabControl.GetPosPixel(); 685 aPos.X() += aTabSize.Width(); 686 687 Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height()); 688 mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize); 689 690 return 0; 691 } 692 693 /// inherited from sd::ViewShell 694 SdPage* DrawViewShell::getCurrentPage() const 695 { 696 const sal_Int32 nPageCount = (meEditMode == EM_PAGE)? 697 GetDoc()->GetSdPageCount(mePageKind): 698 GetDoc()->GetMasterSdPageCount(mePageKind); 699 700 sal_Int32 nCurrentPage = maTabControl.GetCurPageId() - 1; 701 DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" ); 702 if( (nPageCount < 0) || (nCurrentPage>=nPageCount) ) 703 nCurrentPage = 0; // play safe here 704 705 if (meEditMode == EM_PAGE) 706 { 707 return GetDoc()->GetSdPage((sal_uInt16)nCurrentPage, mePageKind); 708 } 709 else // EM_MASTERPAGE 710 { 711 return GetDoc()->GetMasterSdPage((sal_uInt16)nCurrentPage, mePageKind); 712 } 713 } 714 715 /************************************************************************* 716 |* 717 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert 718 |* hat (z. B. durch Undo) 719 |* 720 \************************************************************************/ 721 722 void DrawViewShell::ResetActualPage() 723 { 724 sal_uInt16 nCurrentPage = maTabControl.GetCurPageId() - 1; 725 sal_uInt16 nPageCount = (meEditMode == EM_PAGE)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind); 726 if (nPageCount > 0) 727 nCurrentPage = Min((sal_uInt16)(nPageCount - 1), nCurrentPage); 728 else 729 nCurrentPage = 0; 730 731 if (meEditMode == EM_PAGE) 732 { 733 734 // Update fuer TabControl 735 maTabControl.Clear(); 736 737 SdPage* pPage = NULL; 738 String aPageName; 739 740 for (sal_uInt16 i = 0; i < nPageCount; i++) 741 { 742 pPage = GetDoc()->GetSdPage(i, mePageKind); 743 aPageName = pPage->GetName(); 744 maTabControl.InsertPage(i + 1, aPageName); 745 746 // Selektionskennungen der Seiten korrigieren 747 GetDoc()->SetSelected(pPage, i == nCurrentPage); 748 } 749 750 maTabControl.SetCurPageId(nCurrentPage + 1); 751 } 752 else // EM_MASTERPAGE 753 { 754 SdPage* pActualPage = GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind); 755 maTabControl.Clear(); 756 sal_uInt16 nActualMasterPageNum = 0; 757 758 sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); 759 for (sal_uInt16 i = 0; i < nMasterPageCnt; i++) 760 { 761 SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind); 762 String aLayoutName(pMaster->GetLayoutName()); 763 aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR)); 764 maTabControl.InsertPage(i + 1, aLayoutName); 765 766 if (pActualPage == pMaster) 767 nActualMasterPageNum = i; 768 } 769 770 maTabControl.SetCurPageId(nActualMasterPageNum + 1); 771 SwitchPage(nActualMasterPageNum); 772 } 773 774 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE, 775 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); 776 } 777 778 /************************************************************************* 779 |* 780 |* Verb auf OLE-Objekt anwenden 781 |* 782 \************************************************************************/ 783 784 785 ErrCode DrawViewShell::DoVerb(long nVerb) 786 { 787 if ( mpDrawView->AreObjectsMarked() ) 788 { 789 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 790 791 if (rMarkList.GetMarkCount() == 1) 792 { 793 SdrMark* pMark = rMarkList.GetMark(0); 794 SdrObject* pObj = pMark->GetMarkedSdrObj(); 795 796 sal_uInt32 nInv = pObj->GetObjInventor(); 797 sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier(); 798 799 if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2) 800 { 801 ActivateObject( (SdrOle2Obj*) pObj, nVerb); 802 } 803 #ifdef STARIMAGE_AVAILABLE 804 else if (nInv = SdrInventor && nSdrObjKind == OBJ_GRAF && 805 ((SdrGrafObj*) pObj)->GetGraphicType() == GRAPHIC_BITMAP && 806 SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE)) 807 { 808 SdrGrafObj* pSdrGrafObj = (SdrGrafObj*) pObj; 809 short nOK = RET_YES; 810 811 if ( pSdrGrafObj->GetFileName().Len() ) 812 { 813 // Graphik ist gelinkt, soll der Link aufgehoben werden? 814 QueryBox aBox(pWindow, WB_YES_NO | WB_DEF_YES, 815 String( SdResId(STR_REMOVE_LINK) ) ); 816 nOK = aBox.Execute(); 817 818 if (nOK == RET_YES) 819 { 820 // Link aufheben (File- und Filtername zuruecksetzen) 821 pSdrGrafObj->SetGraphicLink(String(), String()); 822 } 823 } 824 825 if (nOK == RET_YES) 826 { 827 /************************************************************** 828 * OLE-Objekt erzeugen, StarImage starten 829 * Grafik-Objekt loeschen (durch OLE-Objekt ersetzt) 830 **************************************************************/ 831 //HMHmpDrView->HideMarkHdl(); 832 833 SvStorageRef aStor = new SvStorage(String()); 834 SvInPlaceObjectRef aNewIPObj = &((SvFactory*)SvInPlaceObject::ClassFactory()) 835 ->CreateAndInit(SimModuleDummy::GetID(SOFFICE_FILEFORMAT_CURRENT), aStor); 836 if ( aNewIPObj.Is() ) 837 { 838 SdrGrafObj* pTempSdrGrafObj = (SdrGrafObj*) pSdrGrafObj->Clone (); 839 840 SvEmbeddedInfoObject * pInfo; 841 pInfo = GetViewFrame()->GetObjectShell()-> 842 InsertObject( aNewIPObj, String() ); 843 844 String aName; 845 if (pInfo) 846 { 847 aName = pInfo->GetObjName(); 848 } 849 850 Rectangle aRect = pObj->GetLogicRect(); 851 SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( aNewIPObj, 852 aName, aRect ); 853 854 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 855 856 pPV->GetObjList()->InsertObject( pSdrOle2Obj ); 857 mpDrawView->ReplaceObjectAtView( pObj, *pPV, pTempSdrGrafObj ); 858 859 pSdrOle2Obj->SetLogicRect(aRect); 860 aNewIPObj->SetVisAreaSize(aRect.GetSize()); 861 862 SimDLL::Update(aNewIPObj, pTempSdrGrafObj->GetGraphic(), pWindow); 863 ActivateObject(pSdrOle2Obj, SVVERB_SHOW); 864 865 Client* pClient = (Client*) GetIPClient(); 866 867 if (pClient) 868 pClient->SetSdrGrafObj( pTempSdrGrafObj ); 869 } 870 } 871 } 872 #endif 873 } 874 } 875 876 return 0; 877 } 878 879 880 /************************************************************************* 881 |* 882 |* OLE-Object aktivieren 883 |* 884 \************************************************************************/ 885 886 sal_Bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb) 887 { 888 sal_Bool bActivated = sal_False; 889 890 if ( !GetDocSh()->IsUIActive() ) 891 { 892 ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager()); 893 894 bActivated = ViewShell::ActivateObject(pObj, nVerb); 895 896 OSL_ASSERT(GetViewShell()!=NULL); 897 Client* pClient = static_cast<Client*>(GetViewShell()->GetIPClient()); 898 if (pClient) 899 pClient->SetSdrGrafObj(NULL); 900 } 901 902 return(bActivated); 903 } 904 905 /************************************************************************* 906 |* 907 |* Auf gewuenschte Seite schalten 908 |* Der Parameter nSelectedPage bezieht sich auf den aktuellen EditMode 909 |* 910 \************************************************************************/ 911 912 void LclResetFlag (bool& rbFlag) {rbFlag = false;} 913 914 sal_Bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage) 915 { 916 /** Under some circumstances there are nested calls to SwitchPage() and 917 may crash the application (activation of form controls when the 918 shell of the edit view is not on top of the shell stack, see issue 919 83888 for details.) Therefore the nested calls are ignored (they 920 would jump to the wrong page anyway.) 921 */ 922 if (mbIsInSwitchPage) 923 return sal_False; 924 mbIsInSwitchPage = true; 925 comphelper::ScopeGuard aGuard (::boost::bind(LclResetFlag, ::boost::ref(mbIsInSwitchPage))); 926 927 if (GetActiveWindow()->IsInPaint()) 928 { 929 // Switching the current page while a Paint is being executed is 930 // dangerous. So, post it for later execution and return. 931 maAsynchronousSwitchPageCall.Post(::boost::bind( 932 ::std::mem_fun(&DrawViewShell::SwitchPage), 933 this, 934 nSelectedPage)); 935 return sal_False; 936 } 937 938 sal_Bool bOK = sal_False; 939 940 // With the current implementation of FuSlideShow there is a problem 941 // when it dsplays the show in a window: When the show is stopped it 942 // returns at one point in time SDRPAGE_NOTFOUND as current page index. 943 // Because FuSlideShow is currently being rewritten this bug is fixed 944 // here. 945 // This is not as bad a hack as it may look because making SwitchPage() 946 // more robust with respect to invalid page numbers is a good thing 947 // anyway. 948 if (nSelectedPage == SDRPAGE_NOTFOUND) 949 { 950 nSelectedPage = 0; 951 } 952 else 953 { 954 // Make sure that the given page index points to an existing page. Move 955 // the index into the valid range if necessary. 956 sal_uInt16 nPageCount = (meEditMode == EM_PAGE) 957 ? GetDoc()->GetSdPageCount(mePageKind) 958 : GetDoc()->GetMasterSdPageCount(mePageKind); 959 if (nSelectedPage >= nPageCount) 960 nSelectedPage = nPageCount-1; 961 } 962 963 if (IsSwitchPageAllowed()) 964 { 965 ModifyGuard aGuard2( GetDoc() ); 966 967 bOK = sal_True; 968 969 if (mpActualPage) 970 { 971 SdPage* pNewPage = NULL; 972 973 if (meEditMode == EM_MASTERPAGE) 974 { 975 if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage ) 976 pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind); 977 978 if( pNewPage ) 979 { 980 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 981 982 String sPageText (pNewPage->GetLayoutName()); 983 sPageText.Erase(sPageText.SearchAscii(SD_LT_SEPARATOR)); 984 if (pPV 985 && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() ) 986 && sPageText == maTabControl.GetPageText(nSelectedPage+1)) 987 { 988 // this slide is already visible 989 return sal_True; 990 } 991 } 992 } 993 else 994 { 995 OSL_ASSERT(mpFrameView!=NULL); 996 mpFrameView->SetSelectedPage(nSelectedPage); 997 998 if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage) 999 pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind); 1000 1001 if (mpActualPage == pNewPage) 1002 { 1003 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 1004 1005 SdPage* pCurrentPage = dynamic_cast< SdPage* >( pPV->GetPage()); 1006 if (pPV 1007 && pNewPage == pCurrentPage 1008 && pNewPage->GetName() == maTabControl.GetPageText(nSelectedPage+1)) 1009 { 1010 // this slide is already visible 1011 return sal_True; 1012 } 1013 } 1014 } 1015 } 1016 1017 if( mpDrawView ) 1018 mpDrawView->SdrEndTextEdit(); 1019 1020 mpActualPage = NULL; 1021 1022 if (meEditMode == EM_PAGE) 1023 { 1024 mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind); 1025 } 1026 else 1027 { 1028 SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind); 1029 1030 // Passt die selektierte Seite zur MasterPage? 1031 sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind); 1032 for (sal_uInt16 i = 0; i < nPageCount; i++) 1033 { 1034 SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); 1035 if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage())) 1036 { 1037 mpActualPage = pPage; 1038 break; 1039 } 1040 } 1041 1042 if (!mpActualPage) 1043 { 1044 // Die erste Seite nehmen, welche zur MasterPage passt 1045 for (sal_uInt16 i = 0; i < nPageCount; i++) 1046 { 1047 SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); 1048 if(pPage && pMaster == &(pPage->TRG_GetMasterPage())) 1049 { 1050 mpActualPage = pPage; 1051 break; 1052 } 1053 } 1054 } 1055 } 1056 1057 for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++) 1058 { 1059 // Alle Seiten deselektieren 1060 GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), sal_False); 1061 } 1062 1063 if (!mpActualPage) 1064 { 1065 // Sofern es keine mpActualPage gibt, wird die erste genommen 1066 mpActualPage = GetDoc()->GetSdPage(0, mePageKind); 1067 } 1068 1069 // diese Seite auch selektieren (mpActualPage zeigt immer auf Zeichenseite, 1070 // nie auf eine Masterpage) 1071 GetDoc()->SetSelected(mpActualPage, sal_True); 1072 1073 rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) ); 1074 if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) ) 1075 { 1076 // VisArea zuziehen, um ggf. Objekte zu deaktivieren 1077 // !!! only if we are not in presentation mode (#96279) !!! 1078 OSL_ASSERT (GetViewShell()!=NULL); 1079 GetViewShell()->DisconnectAllClients(); 1080 VisAreaChanged(Rectangle(Point(), Size(1, 1))); 1081 } 1082 1083 if (meEditMode == EM_PAGE) 1084 { 1085 /********************************************************************** 1086 * PAGEMODE 1087 **********************************************************************/ 1088 GetDoc()->SetSelected(mpActualPage, sal_True); 1089 1090 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 1091 1092 if (pPageView) 1093 { 1094 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() ); 1095 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() ); 1096 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() ); 1097 1098 if (mePageKind == PK_NOTES) 1099 { 1100 mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() ); 1101 } 1102 else if (mePageKind == PK_HANDOUT) 1103 { 1104 mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() ); 1105 } 1106 else 1107 { 1108 mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() ); 1109 } 1110 } 1111 1112 mpDrawView->HideSdrPage(); 1113 mpDrawView->ShowSdrPage(mpActualPage); 1114 GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage); 1115 1116 SdrPageView* pNewPageView = mpDrawView->GetSdrPageView(); 1117 1118 if (pNewPageView) 1119 { 1120 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() ); 1121 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() ); 1122 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() ); 1123 1124 if (mePageKind == PK_NOTES) 1125 { 1126 pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() ); 1127 } 1128 else if (mePageKind == PK_HANDOUT) 1129 { 1130 pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() ); 1131 } 1132 else 1133 { 1134 pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() ); 1135 } 1136 } 1137 1138 maTabControl.SetCurPageId(nSelectedPage+1); 1139 String aPageName = mpActualPage->GetName(); 1140 1141 if (maTabControl.GetPageText(nSelectedPage+1) != aPageName) 1142 { 1143 maTabControl.SetPageText(nSelectedPage+1, aPageName); 1144 } 1145 } 1146 else 1147 { 1148 /********************************************************************** 1149 * MASTERPAGE 1150 **********************************************************************/ 1151 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 1152 1153 if (pPageView) 1154 { 1155 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() ); 1156 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() ); 1157 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() ); 1158 1159 if (mePageKind == PK_NOTES) 1160 { 1161 mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() ); 1162 } 1163 else if (mePageKind == PK_HANDOUT) 1164 { 1165 mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() ); 1166 } 1167 else 1168 { 1169 mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() ); 1170 } 1171 } 1172 1173 mpDrawView->HideSdrPage(); 1174 1175 SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind); 1176 1177 if( !pMaster ) // Falls es diese Page nicht geben sollte 1178 pMaster = GetDoc()->GetMasterSdPage(0, mePageKind); 1179 1180 sal_uInt16 nNum = pMaster->GetPageNum(); 1181 mpDrawView->ShowSdrPage(mpDrawView->GetModel()->GetMasterPage(nNum)); 1182 1183 GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster); 1184 1185 SdrPageView* pNewPageView = mpDrawView->GetSdrPageView(); 1186 1187 if (pNewPageView) 1188 { 1189 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() ); 1190 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() ); 1191 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() ); 1192 1193 if (mePageKind == PK_NOTES) 1194 { 1195 pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() ); 1196 } 1197 else if (mePageKind == PK_HANDOUT) 1198 { 1199 pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() ); 1200 } 1201 else 1202 { 1203 pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() ); 1204 } 1205 } 1206 1207 String aLayoutName(pMaster->GetLayoutName()); 1208 aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR)); 1209 1210 maTabControl.SetCurPageId(nSelectedPage+1); 1211 1212 if (maTabControl.GetPageText(nSelectedPage+1) != aLayoutName) 1213 { 1214 maTabControl.SetPageText(nSelectedPage+1, aLayoutName); 1215 } 1216 1217 if( mePageKind == PK_HANDOUT ) 1218 { 1219 // set pages for all available handout presentation objects 1220 sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList(); 1221 SdrObject* pObj = 0; 1222 1223 while( (pObj = rShapeList.getNextShape(pObj)) != 0 ) 1224 { 1225 if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT ) 1226 { 1227 // #i105146# We want no content to be displayed for PK_HANDOUT, 1228 // so just never set a page as content 1229 static_cast<SdrPageObj*>(pObj)->SetReferencedPage(0); 1230 } 1231 } 1232 } 1233 } 1234 1235 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel(); 1236 Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) ); 1237 VisAreaChanged(aVisAreaWin); 1238 mpDrawView->VisAreaChanged(GetActiveWindow()); 1239 1240 // Damit der Navigator (und das Effekte-Window) das mitbekommt (/-men) 1241 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 1242 rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_False); 1243 rBindings.Invalidate(SID_STATUS_PAGE, sal_True, sal_False); 1244 rBindings.Invalidate(SID_DELETE_MASTER_PAGE, sal_True, sal_False); 1245 rBindings.Invalidate(SID_DELETE_PAGE, sal_True, sal_False); 1246 rBindings.Invalidate(SID_ASSIGN_LAYOUT,sal_True,sal_False); 1247 rBindings.Invalidate(SID_INSERTPAGE,sal_True,sal_False); 1248 UpdatePreview( mpActualPage ); 1249 1250 mpDrawView->AdjustMarkHdl(); 1251 } 1252 1253 return (bOK); 1254 } 1255 1256 1257 /************************************************************************* 1258 |* 1259 |* Pruefen, ob ein Seitenwechsel erlaubt ist 1260 |* 1261 \************************************************************************/ 1262 1263 sal_Bool DrawViewShell::IsSwitchPageAllowed() const 1264 { 1265 bool bOK = true; 1266 1267 FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell(); 1268 if (pFormShell!=NULL && !pFormShell->PrepareClose (sal_False)) 1269 bOK = false; 1270 1271 return bOK; 1272 } 1273 1274 /************************************************************************* 1275 |* 1276 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert 1277 |* hat (z. B. durch Undo) 1278 |* 1279 \************************************************************************/ 1280 1281 void DrawViewShell::ResetActualLayer() 1282 { 1283 LayerTabBar* pLayerBar = GetLayerTabControl(); 1284 if (pLayerBar != NULL) 1285 { 1286 // remember old layer cound and current layer id 1287 // this is needed when one layer is renamed to 1288 // restore current layer 1289 sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount(); 1290 sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId(); 1291 1292 /************************************************************* 1293 * Update fuer LayerTab 1294 *************************************************************/ 1295 pLayerBar->Clear(); 1296 1297 String aName; 1298 String aActiveLayer = mpDrawView->GetActiveLayer(); 1299 String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) ); 1300 String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) ); 1301 String aLayoutLayer( SdResId(STR_LAYER_LAYOUT) ); 1302 String aControlsLayer( SdResId(STR_LAYER_CONTROLS) ); 1303 String aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES) ); 1304 sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND; 1305 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); 1306 sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount(); 1307 1308 for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ ) 1309 { 1310 aName = rLayerAdmin.GetLayer(nLayer)->GetName(); 1311 1312 if ( aName == aActiveLayer ) 1313 { 1314 nActiveLayer = nLayer; 1315 } 1316 1317 if ( aName != aBackgroundLayer ) 1318 { 1319 if (meEditMode == EM_MASTERPAGE) 1320 { 1321 // Layer der Page nicht auf MasterPage anzeigen 1322 if (aName != aLayoutLayer && 1323 aName != aControlsLayer && 1324 aName != aMeasureLinesLayer) 1325 { 1326 pLayerBar->InsertPage(nLayer+1, aName); 1327 1328 TabBarPageBits nBits = 0; 1329 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 1330 1331 if (pPV && !pPV->IsLayerVisible(aName)) 1332 { 1333 // Unsichtbare Layer werden anders dargestellt 1334 nBits = TPB_SPECIAL; 1335 } 1336 1337 pLayerBar->SetPageBits(nLayer+1, nBits); 1338 } 1339 } 1340 else 1341 { 1342 // Layer der MasterPage nicht auf Page anzeigen 1343 if ( aName != aBackgroundObjLayer ) 1344 { 1345 pLayerBar->InsertPage(nLayer+1, aName); 1346 1347 TabBarPageBits nBits = 0; 1348 1349 if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName)) 1350 { 1351 // Unsichtbare Layer werden anders dargestellt 1352 nBits = TPB_SPECIAL; 1353 } 1354 1355 pLayerBar->SetPageBits(nLayer+1, nBits); 1356 } 1357 } 1358 } 1359 } 1360 1361 if ( nActiveLayer == SDRLAYER_NOTFOUND ) 1362 { 1363 if( nOldLayerCnt == pLayerBar->GetPageCount() ) 1364 { 1365 nActiveLayer = nOldLayerId - 1; 1366 } 1367 else 1368 { 1369 nActiveLayer = ( meEditMode == EM_MASTERPAGE ) ? 2 : 0; 1370 } 1371 1372 mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) ); 1373 } 1374 1375 pLayerBar->SetCurPageId(nActiveLayer + 1); 1376 GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER ); 1377 GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER ); 1378 } 1379 } 1380 1381 /************************************************************************* 1382 |* 1383 |* Verzoegertes Close ausfuehren 1384 |* 1385 \************************************************************************/ 1386 1387 IMPL_LINK( DrawViewShell, CloseHdl, Timer*, pTimer ) 1388 { 1389 pTimer->Stop(); 1390 GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN ); 1391 return 0L; 1392 } 1393 1394 /************************************************************************* 1395 |* 1396 |* AcceptDrop 1397 |* 1398 \************************************************************************/ 1399 1400 sal_Int8 DrawViewShell::AcceptDrop ( 1401 const AcceptDropEvent& rEvt, 1402 DropTargetHelper& rTargetHelper, 1403 ::sd::Window* pTargetWindow, 1404 sal_uInt16 nPage, 1405 sal_uInt16 nLayer ) 1406 { 1407 if( nPage != SDRPAGE_NOTFOUND ) 1408 nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum(); 1409 1410 if( SlideShow::IsRunning( GetViewShellBase() ) ) 1411 return DND_ACTION_NONE; 1412 1413 return mpDrawView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ); 1414 } 1415 1416 /************************************************************************* 1417 |* 1418 |* ExecuteDrop 1419 |* 1420 \************************************************************************/ 1421 1422 sal_Int8 DrawViewShell::ExecuteDrop ( 1423 const ExecuteDropEvent& rEvt, 1424 DropTargetHelper& rTargetHelper, 1425 ::sd::Window* pTargetWindow, 1426 sal_uInt16 nPage, 1427 sal_uInt16 nLayer) 1428 { 1429 if( nPage != SDRPAGE_NOTFOUND ) 1430 nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum(); 1431 1432 if( SlideShow::IsRunning( GetViewShellBase() ) ) 1433 return DND_ACTION_NONE; 1434 1435 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START)); 1436 sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer )); 1437 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END)); 1438 1439 return nResult; 1440 } 1441 1442 } // end of namespace sd 1443 1444 #ifdef _MSC_VER 1445 #if (_MSC_VER < 1400) 1446 #pragma optimize ( "", on ) 1447 #endif 1448 #endif 1449 1450