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