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