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 } 521 522 523 524 525 bool DrawViewShell::IsLayerModeActive (void) const 526 { 527 return mbIsLayerModeActive; 528 } 529 530 531 532 533 /************************************************************************* 534 |* 535 |* Groesse des TabControls und der ModeButtons zurueckgeben 536 |* 537 \************************************************************************/ 538 539 long DrawViewShell::GetHCtrlWidth() 540 { 541 // return maTabControl.GetSizePixel().Width(); 542 return 0; 543 } 544 545 546 /************************************************************************* 547 |* 548 |* Horizontales Lineal erzeugen 549 |* 550 \************************************************************************/ 551 552 SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, sal_Bool bIsFirst) 553 { 554 Ruler* pRuler; 555 WinBits aWBits; 556 sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT; 557 558 if ( bIsFirst ) 559 { 560 aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD; 561 nFlags |= ( SVXRULER_SUPPORT_SET_NULLOFFSET | 562 SVXRULER_SUPPORT_TABS | 563 SVXRULER_SUPPORT_PARAGRAPH_MARGINS ); // Neu 564 } 565 else 566 aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER; 567 568 pRuler = new Ruler (*this, GetParentWindow(), pWin, nFlags, 569 GetViewFrame()->GetBindings(), aWBits); 570 pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit()); 571 572 // Metric ... 573 sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit(); 574 575 if( nMetric == 0xffff ) 576 nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit(); 577 578 pRuler->SetUnit( FieldUnit( nMetric ) ); 579 580 // ... und auch DefTab am Lineal einstellen 581 pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // Neu 582 583 Fraction aUIScale(pWin->GetMapMode().GetScaleX()); 584 aUIScale *= GetDoc()->GetUIScale(); 585 pRuler->SetZoom(aUIScale); 586 587 return pRuler; 588 } 589 590 /************************************************************************* 591 |* 592 |* Vertikales Lineal erzeugen 593 |* 594 \************************************************************************/ 595 596 SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin) 597 { 598 Ruler* pRuler; 599 WinBits aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER; 600 sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT; 601 602 pRuler = new Ruler(*this, GetParentWindow(), pWin, nFlags, 603 GetViewFrame()->GetBindings(), aWBits); 604 pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit()); 605 606 // #96629# Metric same as HRuler, use document setting 607 sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit(); 608 609 if( nMetric == 0xffff ) 610 nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit(); 611 612 pRuler->SetUnit( FieldUnit( nMetric ) ); 613 614 Fraction aUIScale(pWin->GetMapMode().GetScaleY()); 615 aUIScale *= GetDoc()->GetUIScale(); 616 pRuler->SetZoom(aUIScale); 617 618 return pRuler; 619 } 620 621 /************************************************************************* 622 |* 623 |* Horizontales Lineal aktualisieren 624 |* 625 \************************************************************************/ 626 627 void DrawViewShell::UpdateHRuler() 628 { 629 Invalidate( SID_ATTR_LONG_LRSPACE ); 630 Invalidate( SID_RULER_PAGE_POS ); 631 Invalidate( SID_RULER_OBJECT ); 632 Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT ); 633 634 if (mpHorizontalRuler.get() != NULL) 635 mpHorizontalRuler->ForceUpdate(); 636 } 637 638 /************************************************************************* 639 |* 640 |* Vertikales Lineal aktualisieren 641 |* 642 \************************************************************************/ 643 644 void DrawViewShell::UpdateVRuler() 645 { 646 Invalidate( SID_ATTR_LONG_LRSPACE ); 647 Invalidate( SID_RULER_PAGE_POS ); 648 Invalidate( SID_RULER_OBJECT ); 649 650 if (mpVerticalRuler.get() != NULL) 651 mpVerticalRuler->ForceUpdate(); 652 } 653 654 /************************************************************************* 655 |* 656 |* Metrik setzen 657 |* 658 \************************************************************************/ 659 660 void DrawViewShell::SetUIUnit(FieldUnit eUnit) 661 { 662 ViewShell::SetUIUnit(eUnit); 663 } 664 665 /************************************************************************* 666 |* 667 |* TabControl nach Splitteraenderung aktualisieren 668 |* 669 \************************************************************************/ 670 671 IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab ) 672 { 673 const long int nMax = maViewSize.Width() - maScrBarWH.Width() 674 - maTabControl.GetPosPixel().X() ; 675 676 Size aTabSize = maTabControl.GetSizePixel(); 677 aTabSize.Width() = Min(pTab->GetSplitSize(), (long)(nMax-1)); 678 679 maTabControl.SetSizePixel(aTabSize); 680 GetLayerTabControl()->SetSizePixel(aTabSize); 681 682 Point aPos = maTabControl.GetPosPixel(); 683 aPos.X() += aTabSize.Width(); 684 685 Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height()); 686 mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize); 687 688 return 0; 689 } 690 691 /// inherited from sd::ViewShell 692 SdPage* DrawViewShell::getCurrentPage() const 693 { 694 const sal_Int32 nPageCount = (meEditMode == EM_PAGE)? 695 GetDoc()->GetSdPageCount(mePageKind): 696 GetDoc()->GetMasterSdPageCount(mePageKind); 697 698 sal_Int32 nCurrentPage = maTabControl.GetCurPageId() - 1; 699 DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" ); 700 if( (nPageCount < 0) || (nCurrentPage>=nPageCount) ) 701 nCurrentPage = 0; // play safe here 702 703 if (meEditMode == EM_PAGE) 704 { 705 return GetDoc()->GetSdPage((sal_uInt16)nCurrentPage, mePageKind); 706 } 707 else // EM_MASTERPAGE 708 { 709 return GetDoc()->GetMasterSdPage((sal_uInt16)nCurrentPage, mePageKind); 710 } 711 } 712 713 /************************************************************************* 714 |* 715 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert 716 |* hat (z. B. durch Undo) 717 |* 718 \************************************************************************/ 719 720 void DrawViewShell::ResetActualPage() 721 { 722 sal_uInt16 nCurrentPage = maTabControl.GetCurPageId() - 1; 723 sal_uInt16 nPageCount = (meEditMode == EM_PAGE)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind); 724 if (nPageCount > 0) 725 nCurrentPage = Min((sal_uInt16)(nPageCount - 1), nCurrentPage); 726 else 727 nCurrentPage = 0; 728 729 if (meEditMode == EM_PAGE) 730 { 731 732 // Update fuer TabControl 733 maTabControl.Clear(); 734 735 SdPage* pPage = NULL; 736 String aPageName; 737 738 for (sal_uInt16 i = 0; i < nPageCount; i++) 739 { 740 pPage = GetDoc()->GetSdPage(i, mePageKind); 741 aPageName = pPage->GetName(); 742 maTabControl.InsertPage(i + 1, aPageName); 743 744 // Selektionskennungen der Seiten korrigieren 745 GetDoc()->SetSelected(pPage, i == nCurrentPage); 746 } 747 748 maTabControl.SetCurPageId(nCurrentPage + 1); 749 } 750 else // EM_MASTERPAGE 751 { 752 SdPage* pActualPage = GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind); 753 maTabControl.Clear(); 754 sal_uInt16 nActualMasterPageNum = 0; 755 756 sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); 757 for (sal_uInt16 i = 0; i < nMasterPageCnt; i++) 758 { 759 SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind); 760 String aLayoutName(pMaster->GetLayoutName()); 761 aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR)); 762 maTabControl.InsertPage(i + 1, aLayoutName); 763 764 if (pActualPage == pMaster) 765 nActualMasterPageNum = i; 766 } 767 768 maTabControl.SetCurPageId(nActualMasterPageNum + 1); 769 SwitchPage(nActualMasterPageNum); 770 } 771 772 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE, 773 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); 774 } 775 776 /************************************************************************* 777 |* 778 |* Verb auf OLE-Objekt anwenden 779 |* 780 \************************************************************************/ 781 782 783 ErrCode DrawViewShell::DoVerb(long nVerb) 784 { 785 if ( mpDrawView->AreObjectsMarked() ) 786 { 787 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 788 789 if (rMarkList.GetMarkCount() == 1) 790 { 791 SdrMark* pMark = rMarkList.GetMark(0); 792 SdrObject* pObj = pMark->GetMarkedSdrObj(); 793 794 sal_uInt32 nInv = pObj->GetObjInventor(); 795 sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier(); 796 797 if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2) 798 { 799 ActivateObject( (SdrOle2Obj*) pObj, nVerb); 800 } 801 #ifdef STARIMAGE_AVAILABLE 802 else if (nInv = SdrInventor && nSdrObjKind == OBJ_GRAF && 803 ((SdrGrafObj*) pObj)->GetGraphicType() == GRAPHIC_BITMAP && 804 SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE)) 805 { 806 SdrGrafObj* pSdrGrafObj = (SdrGrafObj*) pObj; 807 short nOK = RET_YES; 808 809 if ( pSdrGrafObj->GetFileName().Len() ) 810 { 811 // Graphik ist gelinkt, soll der Link aufgehoben werden? 812 QueryBox aBox(pWindow, WB_YES_NO | WB_DEF_YES, 813 String( SdResId(STR_REMOVE_LINK) ) ); 814 nOK = aBox.Execute(); 815 816 if (nOK == RET_YES) 817 { 818 // Link aufheben (File- und Filtername zuruecksetzen) 819 pSdrGrafObj->SetGraphicLink(String(), String()); 820 } 821 } 822 823 if (nOK == RET_YES) 824 { 825 /************************************************************** 826 * OLE-Objekt erzeugen, StarImage starten 827 * Grafik-Objekt loeschen (durch OLE-Objekt ersetzt) 828 **************************************************************/ 829 //HMHmpDrView->HideMarkHdl(); 830 831 SvStorageRef aStor = new SvStorage(String()); 832 SvInPlaceObjectRef aNewIPObj = &((SvFactory*)SvInPlaceObject::ClassFactory()) 833 ->CreateAndInit(SimModuleDummy::GetID(SOFFICE_FILEFORMAT_CURRENT), aStor); 834 if ( aNewIPObj.Is() ) 835 { 836 SdrGrafObj* pTempSdrGrafObj = (SdrGrafObj*) pSdrGrafObj->Clone (); 837 838 SvEmbeddedInfoObject * pInfo; 839 pInfo = GetViewFrame()->GetObjectShell()-> 840 InsertObject( aNewIPObj, String() ); 841 842 String aName; 843 if (pInfo) 844 { 845 aName = pInfo->GetObjName(); 846 } 847 848 Rectangle aRect = pObj->GetLogicRect(); 849 SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( aNewIPObj, 850 aName, aRect ); 851 852 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 853 854 pPV->GetObjList()->InsertObject( pSdrOle2Obj ); 855 mpDrawView->ReplaceObjectAtView( pObj, *pPV, pTempSdrGrafObj ); 856 857 pSdrOle2Obj->SetLogicRect(aRect); 858 aNewIPObj->SetVisAreaSize(aRect.GetSize()); 859 860 SimDLL::Update(aNewIPObj, pTempSdrGrafObj->GetGraphic(), pWindow); 861 ActivateObject(pSdrOle2Obj, SVVERB_SHOW); 862 863 Client* pClient = (Client*) GetIPClient(); 864 865 if (pClient) 866 pClient->SetSdrGrafObj( pTempSdrGrafObj ); 867 } 868 } 869 } 870 #endif 871 } 872 } 873 874 return 0; 875 } 876 877 878 /************************************************************************* 879 |* 880 |* OLE-Object aktivieren 881 |* 882 \************************************************************************/ 883 884 sal_Bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb) 885 { 886 sal_Bool bActivated = sal_False; 887 888 if ( !GetDocSh()->IsUIActive() ) 889 { 890 ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager()); 891 892 bActivated = ViewShell::ActivateObject(pObj, nVerb); 893 894 OSL_ASSERT(GetViewShell()!=NULL); 895 Client* pClient = static_cast<Client*>(GetViewShell()->GetIPClient()); 896 if (pClient) 897 pClient->SetSdrGrafObj(NULL); 898 } 899 900 return(bActivated); 901 } 902 903 /************************************************************************* 904 |* 905 |* Auf gewuenschte Seite schalten 906 |* Der Parameter nSelectedPage bezieht sich auf den aktuellen EditMode 907 |* 908 \************************************************************************/ 909 910 void LclResetFlag (bool& rbFlag) {rbFlag = false;} 911 912 sal_Bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage) 913 { 914 /** Under some circumstances there are nested calls to SwitchPage() and 915 may crash the application (activation of form controls when the 916 shell of the edit view is not on top of the shell stack, see issue 917 83888 for details.) Therefore the nested calls are ignored (they 918 would jump to the wrong page anyway.) 919 */ 920 if (mbIsInSwitchPage) 921 return sal_False; 922 mbIsInSwitchPage = true; 923 comphelper::ScopeGuard aGuard (::boost::bind(LclResetFlag, ::boost::ref(mbIsInSwitchPage))); 924 925 if (GetActiveWindow()->IsInPaint()) 926 { 927 // Switching the current page while a Paint is being executed is 928 // dangerous. So, post it for later execution and return. 929 maAsynchronousSwitchPageCall.Post(::boost::bind( 930 ::std::mem_fun(&DrawViewShell::SwitchPage), 931 this, 932 nSelectedPage)); 933 return sal_False; 934 } 935 936 sal_Bool bOK = sal_False; 937 938 // With the current implementation of FuSlideShow there is a problem 939 // when it dsplays the show in a window: When the show is stopped it 940 // returns at one point in time SDRPAGE_NOTFOUND as current page index. 941 // Because FuSlideShow is currently being rewritten this bug is fixed 942 // here. 943 // This is not as bad a hack as it may look because making SwitchPage() 944 // more robust with respect to invalid page numbers is a good thing 945 // anyway. 946 if (nSelectedPage == SDRPAGE_NOTFOUND) 947 { 948 nSelectedPage = 0; 949 } 950 else 951 { 952 // Make sure that the given page index points to an existing page. Move 953 // the index into the valid range if necessary. 954 sal_uInt16 nPageCount = (meEditMode == EM_PAGE) 955 ? GetDoc()->GetSdPageCount(mePageKind) 956 : GetDoc()->GetMasterSdPageCount(mePageKind); 957 if (nSelectedPage >= nPageCount) 958 nSelectedPage = nPageCount-1; 959 } 960 961 if (IsSwitchPageAllowed()) 962 { 963 ModifyGuard aGuard2( GetDoc() ); 964 965 bOK = sal_True; 966 967 if (mpActualPage) 968 { 969 SdPage* pNewPage = NULL; 970 971 if (meEditMode == EM_MASTERPAGE) 972 { 973 if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage ) 974 pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind); 975 976 if( pNewPage ) 977 { 978 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 979 980 String sPageText (pNewPage->GetLayoutName()); 981 sPageText.Erase(sPageText.SearchAscii(SD_LT_SEPARATOR)); 982 if (pPV 983 && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() ) 984 && sPageText == maTabControl.GetPageText(nSelectedPage+1)) 985 { 986 // this slide is already visible 987 return sal_True; 988 } 989 } 990 } 991 else 992 { 993 OSL_ASSERT(mpFrameView!=NULL); 994 mpFrameView->SetSelectedPage(nSelectedPage); 995 996 if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage) 997 pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind); 998 999 if (mpActualPage == pNewPage) 1000 { 1001 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 1002 1003 SdPage* pCurrentPage = dynamic_cast< SdPage* >( pPV->GetPage()); 1004 if (pPV 1005 && pNewPage == pCurrentPage 1006 && pNewPage->GetName() == maTabControl.GetPageText(nSelectedPage+1)) 1007 { 1008 // this slide is already visible 1009 return sal_True; 1010 } 1011 } 1012 } 1013 } 1014 1015 if( mpDrawView ) 1016 mpDrawView->SdrEndTextEdit(); 1017 1018 mpActualPage = NULL; 1019 1020 if (meEditMode == EM_PAGE) 1021 { 1022 mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind); 1023 } 1024 else 1025 { 1026 SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind); 1027 1028 // Passt die selektierte Seite zur MasterPage? 1029 sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind); 1030 for (sal_uInt16 i = 0; i < nPageCount; i++) 1031 { 1032 SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); 1033 if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage())) 1034 { 1035 mpActualPage = pPage; 1036 break; 1037 } 1038 } 1039 1040 if (!mpActualPage) 1041 { 1042 // Die erste Seite nehmen, welche zur MasterPage passt 1043 for (sal_uInt16 i = 0; i < nPageCount; i++) 1044 { 1045 SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); 1046 if(pPage && pMaster == &(pPage->TRG_GetMasterPage())) 1047 { 1048 mpActualPage = pPage; 1049 break; 1050 } 1051 } 1052 } 1053 } 1054 1055 for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++) 1056 { 1057 // Alle Seiten deselektieren 1058 GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), sal_False); 1059 } 1060 1061 if (!mpActualPage) 1062 { 1063 // Sofern es keine mpActualPage gibt, wird die erste genommen 1064 mpActualPage = GetDoc()->GetSdPage(0, mePageKind); 1065 } 1066 1067 // diese Seite auch selektieren (mpActualPage zeigt immer auf Zeichenseite, 1068 // nie auf eine Masterpage) 1069 GetDoc()->SetSelected(mpActualPage, sal_True); 1070 1071 rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) ); 1072 if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) ) 1073 { 1074 // VisArea zuziehen, um ggf. Objekte zu deaktivieren 1075 // !!! only if we are not in presentation mode (#96279) !!! 1076 OSL_ASSERT (GetViewShell()!=NULL); 1077 GetViewShell()->DisconnectAllClients(); 1078 VisAreaChanged(Rectangle(Point(), Size(1, 1))); 1079 } 1080 1081 if (meEditMode == EM_PAGE) 1082 { 1083 /********************************************************************** 1084 * PAGEMODE 1085 **********************************************************************/ 1086 GetDoc()->SetSelected(mpActualPage, sal_True); 1087 1088 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 1089 1090 if (pPageView) 1091 { 1092 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() ); 1093 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() ); 1094 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() ); 1095 1096 if (mePageKind == PK_NOTES) 1097 { 1098 mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() ); 1099 } 1100 else if (mePageKind == PK_HANDOUT) 1101 { 1102 mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() ); 1103 } 1104 else 1105 { 1106 mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() ); 1107 } 1108 } 1109 1110 mpDrawView->HideSdrPage(); 1111 mpDrawView->ShowSdrPage(mpActualPage); 1112 GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage); 1113 1114 SdrPageView* pNewPageView = mpDrawView->GetSdrPageView(); 1115 1116 if (pNewPageView) 1117 { 1118 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() ); 1119 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() ); 1120 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() ); 1121 1122 if (mePageKind == PK_NOTES) 1123 { 1124 pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() ); 1125 } 1126 else if (mePageKind == PK_HANDOUT) 1127 { 1128 pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() ); 1129 } 1130 else 1131 { 1132 pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() ); 1133 } 1134 } 1135 1136 maTabControl.SetCurPageId(nSelectedPage+1); 1137 String aPageName = mpActualPage->GetName(); 1138 1139 if (maTabControl.GetPageText(nSelectedPage+1) != aPageName) 1140 { 1141 maTabControl.SetPageText(nSelectedPage+1, aPageName); 1142 } 1143 } 1144 else 1145 { 1146 /********************************************************************** 1147 * MASTERPAGE 1148 **********************************************************************/ 1149 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 1150 1151 if (pPageView) 1152 { 1153 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() ); 1154 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() ); 1155 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() ); 1156 1157 if (mePageKind == PK_NOTES) 1158 { 1159 mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() ); 1160 } 1161 else if (mePageKind == PK_HANDOUT) 1162 { 1163 mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() ); 1164 } 1165 else 1166 { 1167 mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() ); 1168 } 1169 } 1170 1171 mpDrawView->HideSdrPage(); 1172 1173 SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind); 1174 1175 if( !pMaster ) // Falls es diese Page nicht geben sollte 1176 pMaster = GetDoc()->GetMasterSdPage(0, mePageKind); 1177 1178 sal_uInt16 nNum = pMaster->GetPageNum(); 1179 mpDrawView->ShowSdrPage(mpDrawView->GetModel()->GetMasterPage(nNum)); 1180 1181 GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster); 1182 1183 SdrPageView* pNewPageView = mpDrawView->GetSdrPageView(); 1184 1185 if (pNewPageView) 1186 { 1187 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() ); 1188 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() ); 1189 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() ); 1190 1191 if (mePageKind == PK_NOTES) 1192 { 1193 pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() ); 1194 } 1195 else if (mePageKind == PK_HANDOUT) 1196 { 1197 pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() ); 1198 } 1199 else 1200 { 1201 pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() ); 1202 } 1203 } 1204 1205 String aLayoutName(pMaster->GetLayoutName()); 1206 aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR)); 1207 1208 maTabControl.SetCurPageId(nSelectedPage+1); 1209 1210 if (maTabControl.GetPageText(nSelectedPage+1) != aLayoutName) 1211 { 1212 maTabControl.SetPageText(nSelectedPage+1, aLayoutName); 1213 } 1214 1215 if( mePageKind == PK_HANDOUT ) 1216 { 1217 // set pages for all available handout presentation objects 1218 sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList(); 1219 SdrObject* pObj = 0; 1220 1221 while( (pObj = rShapeList.getNextShape(pObj)) != 0 ) 1222 { 1223 if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT ) 1224 { 1225 // #i105146# We want no content to be displayed for PK_HANDOUT, 1226 // so just never set a page as content 1227 static_cast<SdrPageObj*>(pObj)->SetReferencedPage(0); 1228 } 1229 } 1230 } 1231 } 1232 1233 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel(); 1234 Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) ); 1235 VisAreaChanged(aVisAreaWin); 1236 mpDrawView->VisAreaChanged(GetActiveWindow()); 1237 1238 // Damit der Navigator (und das Effekte-Window) das mitbekommt (/-men) 1239 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 1240 rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_False); 1241 rBindings.Invalidate(SID_STATUS_PAGE, sal_True, sal_False); 1242 rBindings.Invalidate(SID_DELETE_MASTER_PAGE, sal_True, sal_False); 1243 rBindings.Invalidate(SID_DELETE_PAGE, sal_True, sal_False); 1244 rBindings.Invalidate(SID_ASSIGN_LAYOUT,sal_True,sal_False); 1245 rBindings.Invalidate(SID_INSERTPAGE,sal_True,sal_False); 1246 UpdatePreview( mpActualPage ); 1247 1248 mpDrawView->AdjustMarkHdl(); 1249 } 1250 1251 return (bOK); 1252 } 1253 1254 1255 /************************************************************************* 1256 |* 1257 |* Pruefen, ob ein Seitenwechsel erlaubt ist 1258 |* 1259 \************************************************************************/ 1260 1261 sal_Bool DrawViewShell::IsSwitchPageAllowed() const 1262 { 1263 bool bOK = true; 1264 1265 FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell(); 1266 if (pFormShell!=NULL && !pFormShell->PrepareClose (sal_False)) 1267 bOK = false; 1268 1269 return bOK; 1270 } 1271 1272 /************************************************************************* 1273 |* 1274 |* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert 1275 |* hat (z. B. durch Undo) 1276 |* 1277 \************************************************************************/ 1278 1279 void DrawViewShell::ResetActualLayer() 1280 { 1281 LayerTabBar* pLayerBar = GetLayerTabControl(); 1282 if (pLayerBar != NULL) 1283 { 1284 // remember old layer cound and current layer id 1285 // this is needed when one layer is renamed to 1286 // restore current layer 1287 sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount(); 1288 sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId(); 1289 1290 /************************************************************* 1291 * Update fuer LayerTab 1292 *************************************************************/ 1293 pLayerBar->Clear(); 1294 1295 String aName; 1296 String aActiveLayer = mpDrawView->GetActiveLayer(); 1297 String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) ); 1298 String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) ); 1299 String aLayoutLayer( SdResId(STR_LAYER_LAYOUT) ); 1300 String aControlsLayer( SdResId(STR_LAYER_CONTROLS) ); 1301 String aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES) ); 1302 sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND; 1303 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); 1304 sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount(); 1305 1306 for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ ) 1307 { 1308 aName = rLayerAdmin.GetLayer(nLayer)->GetName(); 1309 1310 if ( aName == aActiveLayer ) 1311 { 1312 nActiveLayer = nLayer; 1313 } 1314 1315 if ( aName != aBackgroundLayer ) 1316 { 1317 if (meEditMode == EM_MASTERPAGE) 1318 { 1319 // Layer der Page nicht auf MasterPage anzeigen 1320 if (aName != aLayoutLayer && 1321 aName != aControlsLayer && 1322 aName != aMeasureLinesLayer) 1323 { 1324 pLayerBar->InsertPage(nLayer+1, aName); 1325 1326 TabBarPageBits nBits = 0; 1327 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 1328 1329 if (pPV && !pPV->IsLayerVisible(aName)) 1330 { 1331 // Unsichtbare Layer werden anders dargestellt 1332 nBits = TPB_SPECIAL; 1333 } 1334 1335 pLayerBar->SetPageBits(nLayer+1, nBits); 1336 } 1337 } 1338 else 1339 { 1340 // Layer der MasterPage nicht auf Page anzeigen 1341 if ( aName != aBackgroundObjLayer ) 1342 { 1343 pLayerBar->InsertPage(nLayer+1, aName); 1344 1345 TabBarPageBits nBits = 0; 1346 1347 if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName)) 1348 { 1349 // Unsichtbare Layer werden anders dargestellt 1350 nBits = TPB_SPECIAL; 1351 } 1352 1353 pLayerBar->SetPageBits(nLayer+1, nBits); 1354 } 1355 } 1356 } 1357 } 1358 1359 if ( nActiveLayer == SDRLAYER_NOTFOUND ) 1360 { 1361 if( nOldLayerCnt == pLayerBar->GetPageCount() ) 1362 { 1363 nActiveLayer = nOldLayerId - 1; 1364 } 1365 else 1366 { 1367 nActiveLayer = ( meEditMode == EM_MASTERPAGE ) ? 2 : 0; 1368 } 1369 1370 mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) ); 1371 } 1372 1373 pLayerBar->SetCurPageId(nActiveLayer + 1); 1374 GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER ); 1375 GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER ); 1376 } 1377 } 1378 1379 /************************************************************************* 1380 |* 1381 |* Verzoegertes Close ausfuehren 1382 |* 1383 \************************************************************************/ 1384 1385 IMPL_LINK( DrawViewShell, CloseHdl, Timer*, pTimer ) 1386 { 1387 pTimer->Stop(); 1388 GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN ); 1389 return 0L; 1390 } 1391 1392 /************************************************************************* 1393 |* 1394 |* AcceptDrop 1395 |* 1396 \************************************************************************/ 1397 1398 sal_Int8 DrawViewShell::AcceptDrop ( 1399 const AcceptDropEvent& rEvt, 1400 DropTargetHelper& rTargetHelper, 1401 ::sd::Window* pTargetWindow, 1402 sal_uInt16 nPage, 1403 sal_uInt16 nLayer ) 1404 { 1405 if( nPage != SDRPAGE_NOTFOUND ) 1406 nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum(); 1407 1408 if( SlideShow::IsRunning( GetViewShellBase() ) ) 1409 return DND_ACTION_NONE; 1410 1411 return mpDrawView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ); 1412 } 1413 1414 /************************************************************************* 1415 |* 1416 |* ExecuteDrop 1417 |* 1418 \************************************************************************/ 1419 1420 sal_Int8 DrawViewShell::ExecuteDrop ( 1421 const ExecuteDropEvent& rEvt, 1422 DropTargetHelper& rTargetHelper, 1423 ::sd::Window* pTargetWindow, 1424 sal_uInt16 nPage, 1425 sal_uInt16 nLayer) 1426 { 1427 if( nPage != SDRPAGE_NOTFOUND ) 1428 nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum(); 1429 1430 if( SlideShow::IsRunning( GetViewShellBase() ) ) 1431 return DND_ACTION_NONE; 1432 1433 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START)); 1434 sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer )); 1435 Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END)); 1436 1437 return nResult; 1438 } 1439 1440 } // end of namespace sd 1441 1442 #ifdef _MSC_VER 1443 #if (_MSC_VER < 1400) 1444 #pragma optimize ( "", on ) 1445 #endif 1446 #endif 1447 1448