LCOV - code coverage report
Current view: top level - sd/source/ui/view - drviews1.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 387 531 72.9 %
Date: 2015-06-13 12:38:46 Functions: 18 31 58.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "DrawViewShell.hxx"
      21             : #include "ViewShellImplementation.hxx"
      22             : 
      23             : #include "DrawController.hxx"
      24             : #include <com/sun/star/embed/EmbedStates.hpp>
      25             : 
      26             : #include "comphelper/anytostring.hxx"
      27             : #include "comphelper/scopeguard.hxx"
      28             : #include "cppuhelper/exc_hlp.hxx"
      29             : #include "rtl/ref.hxx"
      30             : 
      31             : #include <svx/svxids.hrc>
      32             : #include <svx/svdpagv.hxx>
      33             : #include <sfx2/viewfrm.hxx>
      34             : #include <sfx2/bindings.hxx>
      35             : #include <svx/svdoole2.hxx>
      36             : #include <sfx2/dispatch.hxx>
      37             : #include <vcl/scrbar.hxx>
      38             : #include <svx/svdograf.hxx>
      39             : #include <svx/svdopage.hxx>
      40             : #include <vcl/msgbox.hxx>
      41             : #include <sot/storage.hxx>
      42             : #include <svx/fmshell.hxx>
      43             : #include <svx/globl3d.hxx>
      44             : #include <svx/fmglob.hxx>
      45             : #include <editeng/outliner.hxx>
      46             : #include <svx/dialogs.hrc>
      47             : 
      48             : #include "view/viewoverlaymanager.hxx"
      49             : 
      50             : #include "glob.hrc"
      51             : #include "app.hrc"
      52             : #include "res_bmp.hrc"
      53             : #include "strings.hrc"
      54             : #include "helpids.h"
      55             : 
      56             : #include "sdmod.hxx"
      57             : #include "fupoor.hxx"
      58             : #include "sdresid.hxx"
      59             : #include "fusel.hxx"
      60             : #include "sdpage.hxx"
      61             : #include "FrameView.hxx"
      62             : #include "stlpool.hxx"
      63             : #include "Window.hxx"
      64             : #include "drawview.hxx"
      65             : #include "drawdoc.hxx"
      66             : #include "DrawDocShell.hxx"
      67             : #include "Ruler.hxx"
      68             : #include "Client.hxx"
      69             : #include "slideshow.hxx"
      70             : #include "optsitem.hxx"
      71             : #include "fusearch.hxx"
      72             : #include "Outliner.hxx"
      73             : #include "AnimationChildWindow.hxx"
      74             : #include "SdUnoDrawView.hxx"
      75             : #include "ToolBarManager.hxx"
      76             : #include "FormShellManager.hxx"
      77             : #include "ViewShellBase.hxx"
      78             : #include "LayerTabBar.hxx"
      79             : #include "ViewShellManager.hxx"
      80             : #include "ViewShellHint.hxx"
      81             : 
      82             : #include <sfx2/request.hxx>
      83             : #include <boost/bind.hpp>
      84             : 
      85             : using namespace com::sun::star;
      86             : 
      87             : namespace sd {
      88             : 
      89         202 : void DrawViewShell::Activate(bool bIsMDIActivate)
      90             : {
      91         202 :     ViewShell::Activate(bIsMDIActivate);
      92             : 
      93             :     // When the mode is switched to normal the main view shell grabs focus.
      94             :     // This is done for getting cut/copy/paste commands on slides in the left
      95             :     // pane (slide sorter view shell) to work properly.
      96         202 :     SfxShell* pTopViewShell = this->GetViewShellBase().GetViewShellManager()->GetTopViewShell();
      97         202 :     if (pTopViewShell && pTopViewShell == this)
      98             :     {
      99         202 :         this->GetActiveWindow()->GrabFocus();
     100             :     }
     101         202 : }
     102             : 
     103           0 : void DrawViewShell::UIActivating( SfxInPlaceClient* pCli )
     104             : {
     105           0 :     ViewShell::UIActivating(pCli);
     106             : 
     107             :     // Disable own controls
     108           0 :     maTabControl->Disable();
     109           0 :     if (GetLayerTabControl() != NULL)
     110           0 :         GetLayerTabControl()->Disable();
     111           0 : }
     112             : 
     113           0 : void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli )
     114             : {
     115             :     // Enable own controls
     116           0 :     maTabControl->Enable();
     117           0 :     if (GetLayerTabControl() != NULL)
     118           0 :         GetLayerTabControl()->Enable();
     119             : 
     120           0 :     ViewShell::UIDeactivated(pCli);
     121           0 : }
     122             : 
     123         531 : void DrawViewShell::Deactivate(bool bIsMDIActivate)
     124             : {
     125             :     // Temporarily disable context broadcasting while the Deactivate()
     126             :     // call is forwarded to our base class.
     127         531 :     const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
     128             : 
     129         531 :     ViewShell::Deactivate(bIsMDIActivate);
     130             : 
     131         531 :     SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
     132         531 : }
     133             : 
     134             : namespace
     135             : {
     136             :     class LockUI
     137             :     {
     138             :     private:
     139             :         void Lock(bool bLock);
     140             :         SfxViewFrame *mpFrame;
     141             :     public:
     142           0 :         LockUI(SfxViewFrame *pFrame) : mpFrame(pFrame) { Lock(true); }
     143           0 :         ~LockUI() { Lock(false); }
     144             : 
     145             :     };
     146             : 
     147           0 :     void LockUI::Lock(bool bLock)
     148             :     {
     149           0 :         if (!mpFrame)
     150           0 :             return;
     151           0 :         mpFrame->Enable( !bLock );
     152             :     }
     153             : }
     154             : 
     155             : /**
     156             :  * Called, if state of selection of view is changed
     157             :  */
     158             : 
     159         141 : void DrawViewShell::SelectionHasChanged()
     160             : {
     161         141 :     Invalidate();
     162             : 
     163             :     //Update3DWindow(); // 3D-Controller
     164         141 :     SfxBoolItem aItem( SID_3D_STATE, true );
     165             :     GetViewFrame()->GetDispatcher()->Execute(
     166         141 :         SID_3D_STATE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
     167             : 
     168         141 :     SdrOle2Obj* pOleObj = NULL;
     169             : 
     170         141 :     if ( mpDrawView->AreObjectsMarked() )
     171             :     {
     172           6 :         const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
     173             : 
     174           6 :         if (rMarkList.GetMarkCount() == 1)
     175             :         {
     176           6 :             SdrMark* pMark = rMarkList.GetMark(0);
     177           6 :             SdrObject* pObj = pMark->GetMarkedSdrObj();
     178             : 
     179           6 :             sal_uInt32 nInv = pObj->GetObjInventor();
     180           6 :             sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
     181             : 
     182           6 :             if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
     183             :             {
     184           0 :                 pOleObj = static_cast<SdrOle2Obj*>(pObj);
     185           0 :                 UpdateIMapDlg( pObj );
     186             :             }
     187           6 :             else if (nSdrObjKind == OBJ_GRAF)
     188           0 :                 UpdateIMapDlg( pObj );
     189             :         }
     190             :     }
     191             : 
     192         141 :     ViewShellBase& rBase = GetViewShellBase();
     193         141 :     rBase.SetVerbs( uno::Sequence< embed::VerbDescriptor >() );
     194             : 
     195             :     try
     196             :     {
     197         141 :         Client* pIPClient = static_cast<Client*>(rBase.GetIPClient());
     198         141 :         if ( pIPClient && pIPClient->IsObjectInPlaceActive() )
     199             :         {
     200             :             // as appropriate take ole-objects into account and deactivate
     201             : 
     202             :             // this means we recently deselected an inplace active ole object so
     203             :             // we need to deselect it now
     204           0 :             if (!pOleObj)
     205             :             {
     206             :                 //#i47279# disable frame until after object has completed unload
     207           0 :                 LockUI aUILock(GetViewFrame());
     208           0 :                 pIPClient->DeactivateObject();
     209             :                 //HMHmpDrView->ShowMarkHdl();
     210             :             }
     211             :             else
     212             :             {
     213           0 :                 uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
     214           0 :                 if ( xObj.is() )
     215             :                 {
     216           0 :                     rBase.SetVerbs( xObj->getSupportedVerbs() );
     217             :                 }
     218             :                 else
     219             :                 {
     220           0 :                     rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
     221           0 :                 }
     222             :             }
     223             :         }
     224             :         else
     225             :         {
     226         141 :             if ( pOleObj )
     227             :             {
     228           0 :                 uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
     229           0 :                 if ( xObj.is() )
     230             :                 {
     231           0 :                     rBase.SetVerbs( xObj->getSupportedVerbs() );
     232             :                 }
     233             :                 else
     234             :                 {
     235           0 :                     rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
     236           0 :                 }
     237             :             }
     238             :             else
     239             :             {
     240         141 :                 rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
     241             :             }
     242             :         }
     243             :     }
     244           0 :     catch( ::com::sun::star::uno::Exception& )
     245             :     {
     246             :         OSL_FAIL(
     247             :             OString(OString("sd::DrawViewShell::SelectionHasChanged(), "
     248             :                     "exception caught: ") +
     249             :             OUStringToOString(
     250             :                 comphelper::anyToString( cppu::getCaughtException() ),
     251             :                 RTL_TEXTENCODING_UTF8 )).getStr() );
     252             :     }
     253             : 
     254         141 :     if( HasCurrentFunction() )
     255             :     {
     256           8 :         GetCurrentFunction()->SelectionHasChanged();
     257             :     }
     258             :     else
     259             :     {
     260         133 :         GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
     261             :     }
     262             : 
     263             :     // Invalidate for every subshell
     264         141 :     GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this);
     265             : 
     266         141 :     mpDrawView->UpdateSelectionClipboard( false );
     267             : 
     268         141 :     GetViewShellBase().GetDrawController().FireSelectionChangeListener();
     269         141 : }
     270             : 
     271             : /**
     272             :  * set zoom factor
     273             :  */
     274           0 : void DrawViewShell::SetZoom( long nZoom )
     275             : {
     276             :     // Make sure that the zoom factor will not be recalculated on
     277             :     // following window resizings.
     278           0 :     mbZoomOnPage = false;
     279           0 :     ViewShell::SetZoom( nZoom );
     280           0 :     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
     281           0 :     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
     282           0 :     mpViewOverlayManager->onZoomChanged();
     283           0 : }
     284             : 
     285             : /**
     286             :  * Set zoom rectangle for active window
     287             :  */
     288             : 
     289         430 : void DrawViewShell::SetZoomRect( const Rectangle& rZoomRect )
     290             : {
     291         430 :     ViewShell::SetZoomRect( rZoomRect );
     292         430 :     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
     293         430 :     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
     294         430 :     mpViewOverlayManager->onZoomChanged();
     295         430 : }
     296             : 
     297             : /**
     298             :  * PrepareClose, as appropriate end text input, so other viewshells
     299             :  * discover an refreshed text objext.
     300             :  */
     301             : 
     302         207 : bool DrawViewShell::PrepareClose( bool bUI )
     303             : {
     304         207 :     if ( !ViewShell::PrepareClose(bUI) )
     305           0 :         return false;
     306             : 
     307         207 :     if( HasCurrentFunction() )
     308             :     {
     309         207 :         sal_uInt16 nID = GetCurrentFunction()->GetSlotID();
     310         207 :         if (nID == SID_TEXTEDIT || nID == SID_ATTR_CHAR)
     311             :         {
     312           4 :             mpDrawView->SdrEndTextEdit();
     313             :         }
     314             :     }
     315             : 
     316         207 :     return true;
     317             : }
     318             : 
     319             : /**
     320             :  * Set status (enabled/disabled) of menu SfxSlots
     321             :  */
     322             : 
     323         748 : void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
     324             : {
     325         748 :     if (meEditMode != eEMode || mbIsLayerModeActive != bIsLayerModeActive)
     326             :     {
     327         411 :         ViewShellManager::UpdateLock aLock (GetViewShellBase().GetViewShellManager());
     328             : 
     329         411 :         sal_uInt16 nActualPageNum = 0;
     330             : 
     331         411 :         GetViewShellBase().GetDrawController().FireChangeEditMode (eEMode == EM_MASTERPAGE);
     332         411 :         GetViewShellBase().GetDrawController().FireChangeLayerMode (bIsLayerModeActive);
     333             : 
     334         411 :         if ( mpDrawView->IsTextEdit() )
     335             :         {
     336           0 :             mpDrawView->SdrEndTextEdit();
     337             :         }
     338             : 
     339         411 :         LayerTabBar* pLayerBar = GetLayerTabControl();
     340         411 :         if (pLayerBar != NULL)
     341         222 :             pLayerBar->EndEditMode();
     342         411 :         maTabControl->EndEditMode();
     343             : 
     344         411 :         if (mePageKind == PK_HANDOUT)
     345             :         {
     346             :             // at handouts only allow MasterPage
     347           3 :             eEMode = EM_MASTERPAGE;
     348             :         }
     349             : 
     350         411 :         GetViewShellBase().GetDrawController().BroadcastContextChange();
     351             : 
     352         411 :         meEditMode = eEMode;
     353             : 
     354         411 :         if(pLayerBar)
     355             :         {
     356             :             // #i87182# only switch activation mode of LayerTabBar when there is one,
     357             :             // else it will not get initialized with the current set of Layers as needed
     358         222 :             mbIsLayerModeActive = bIsLayerModeActive;
     359             :         }
     360             : 
     361             :         // Determine whether to show the master view toolbar.  The master
     362             :         // page mode has to be active and the shell must not be a handout
     363             :         // view.
     364         411 :         bool bShowMasterViewToolbar (meEditMode == EM_MASTERPAGE
     365         411 :              && GetShellType() != ViewShell::ST_HANDOUT);
     366         411 :         bool bShowPresentationToolbar (meEditMode != EM_MASTERPAGE
     367         411 :              && GetShellType() != ViewShell::ST_HANDOUT);
     368             : 
     369             :         // If the master view toolbar is not shown we hide it before
     370             :         // switching the edit mode.
     371         822 :         if (::sd::ViewShell::mpImpl->mbIsInitialized
     372         411 :             && IsMainViewShell())
     373             :         {
     374         278 :             if ( !bShowMasterViewToolbar )
     375         274 :                 GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE);
     376         278 :             if ( !bShowPresentationToolbar )
     377           5 :                 GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_COMMON_TASK);
     378             :         }
     379             : 
     380         411 :         if (meEditMode == EM_PAGE)
     381             :         {
     382             :             /******************************************************************
     383             :             * PAGEMODE
     384             :             ******************************************************************/
     385             : 
     386         403 :             maTabControl->Clear();
     387             : 
     388             :             SdPage* pPage;
     389         403 :             sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
     390             : 
     391         843 :             for (sal_uInt16 i = 0; i < nPageCnt; i++)
     392             :             {
     393         440 :                 pPage = GetDoc()->GetSdPage(i, mePageKind);
     394         440 :                 OUString aPageName = pPage->GetName();
     395         440 :                 maTabControl->InsertPage(i + 1, aPageName);
     396             : 
     397         440 :                 if ( pPage->IsSelected() && nActualPageNum == 0 )
     398             :                 {
     399         283 :                     nActualPageNum = i;
     400             :                 }
     401         440 :             }
     402             : 
     403         403 :             maTabControl->SetCurPageId(nActualPageNum + 1);
     404             : 
     405         403 :             SwitchPage(nActualPageNum);
     406             :         }
     407             :         else
     408             :         {
     409             :             /******************************************************************
     410             :             * MASTERPAGE
     411             :             ******************************************************************/
     412             :             GetViewFrame()->SetChildWindow(
     413           8 :                 AnimationChildWindow::GetChildWindowId(), false );
     414             : 
     415           8 :             if (!mpActualPage)
     416             :             {
     417             :                 // as long as there is no mpActualPage, take first
     418           3 :                 mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
     419             :             }
     420             : 
     421           8 :             maTabControl->Clear();
     422           8 :             sal_uInt16 nActualMasterPageNum = 0;
     423           8 :             sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
     424             : 
     425          16 :             for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
     426             :             {
     427           8 :                 SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
     428           8 :                 OUString aLayoutName = pMaster->GetLayoutName();
     429           8 :                 sal_Int32 nPos = aLayoutName.indexOf(SD_LT_SEPARATOR);
     430           8 :                 if (nPos != -1)
     431           8 :                     aLayoutName = aLayoutName.copy(0, nPos);
     432             : 
     433           8 :                 maTabControl->InsertPage(i + 1, aLayoutName);
     434             : 
     435           8 :                 if (&(mpActualPage->TRG_GetMasterPage()) == pMaster)
     436             :                 {
     437           8 :                     nActualMasterPageNum = i;
     438             :                 }
     439           8 :             }
     440             : 
     441           8 :             maTabControl->SetCurPageId(nActualMasterPageNum + 1);
     442           8 :             SwitchPage(nActualMasterPageNum);
     443             :         }
     444             : 
     445             :         // If the master view toolbar is to be shown we turn it on after the
     446             :         // edit mode has been changed.
     447         822 :         if (::sd::ViewShell::mpImpl->mbIsInitialized
     448         411 :             && IsMainViewShell())
     449             :         {
     450         278 :             if (bShowMasterViewToolbar)
     451           4 :                 GetViewShellBase().GetToolBarManager()->SetToolBar(
     452             :                     ToolBarManager::TBG_MASTER_MODE,
     453           4 :                     ToolBarManager::msMasterViewToolBar);
     454         278 :             if (bShowPresentationToolbar)
     455         273 :                 GetViewShellBase().GetToolBarManager()->SetToolBar(
     456             :                     ToolBarManager::TBG_COMMON_TASK,
     457         273 :                     ToolBarManager::msCommonTaskToolBar);
     458             :         }
     459             : 
     460         411 :         if ( ! mbIsLayerModeActive)
     461             :         {
     462         189 :             maTabControl->Show();
     463             :             // Set the tab control only for draw pages.  For master page
     464             :             // this has been done already above.
     465         189 :             if (meEditMode == EM_PAGE)
     466         181 :                 maTabControl->SetCurPageId (nActualPageNum + 1);
     467             :         }
     468             : 
     469         411 :         ResetActualLayer();
     470             : 
     471         411 :         Invalidate( SID_PAGEMODE );
     472         411 :         Invalidate( SID_LAYERMODE );
     473         411 :         Invalidate( SID_MASTERPAGE );
     474         411 :         Invalidate( SID_DELETE_MASTER_PAGE );
     475         411 :         Invalidate( SID_DELETE_PAGE );
     476         411 :         Invalidate( SID_SLIDE_MASTERPAGE );
     477         411 :         Invalidate( SID_TITLE_MASTERPAGE );
     478         411 :         Invalidate( SID_NOTES_MASTERPAGE );
     479         411 :         Invalidate( SID_HANDOUT_MASTERPAGE );
     480             : 
     481         411 :         SetContextName(GetSidebarContextName());
     482             :     }
     483         748 : }
     484             : 
     485             : /**
     486             :  * Generate horizontal ruler
     487             :  */
     488             : 
     489          86 : SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, bool bIsFirst)
     490             : {
     491             :     Ruler* pRuler;
     492             :     WinBits  aWBits;
     493          86 :     SvxRulerSupportFlags nFlags = SvxRulerSupportFlags::OBJECT;
     494             : 
     495          86 :     if ( bIsFirst )
     496             :     {
     497          86 :         aWBits  = WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD;
     498          86 :         nFlags |= ( SvxRulerSupportFlags::SET_NULLOFFSET |
     499             :                     SvxRulerSupportFlags::TABS |
     500          86 :                     SvxRulerSupportFlags::PARAGRAPH_MARGINS ); // Neu
     501             :     }
     502             :     else
     503           0 :         aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER;
     504             : 
     505         172 :     pRuler = VclPtr<Ruler>::Create(*this, GetParentWindow(), pWin, nFlags,
     506         172 :         GetViewFrame()->GetBindings(), aWBits);
     507             : 
     508          86 :     pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
     509             : 
     510             :     // Metric ...
     511          86 :     sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
     512             : 
     513          86 :     if( nMetric == 0xffff )
     514           0 :         nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
     515             : 
     516          86 :     pRuler->SetUnit( FieldUnit( nMetric ) );
     517             : 
     518             :     // ... and also set DefTab at the ruler
     519          86 :     pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // new
     520             : 
     521          86 :     Fraction aUIScale(pWin->GetMapMode().GetScaleX());
     522          86 :     aUIScale *= GetDoc()->GetUIScale();
     523          86 :     pRuler->SetZoom(aUIScale);
     524             : 
     525          86 :     return pRuler;
     526             : }
     527             : 
     528             : /**
     529             :  * Generate vertical ruler
     530             :  */
     531             : 
     532          86 : SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin)
     533             : {
     534             :     Ruler* pRuler;
     535          86 :     WinBits  aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER;
     536          86 :     SvxRulerSupportFlags nFlags = SvxRulerSupportFlags::OBJECT;
     537             : 
     538         172 :     pRuler = VclPtr<Ruler>::Create(*this, GetParentWindow(), pWin, nFlags,
     539         172 :         GetViewFrame()->GetBindings(), aWBits);
     540          86 :     pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
     541             : 
     542             :     // Metric same as HRuler, use document setting
     543          86 :     sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
     544             : 
     545          86 :     if( nMetric == 0xffff )
     546           0 :         nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
     547             : 
     548          86 :     pRuler->SetUnit( FieldUnit( nMetric ) );
     549             : 
     550          86 :     Fraction aUIScale(pWin->GetMapMode().GetScaleY());
     551          86 :     aUIScale *= GetDoc()->GetUIScale();
     552          86 :     pRuler->SetZoom(aUIScale);
     553             : 
     554          86 :     return pRuler;
     555             : }
     556             : 
     557             : /**
     558             :  * Refresh horizontal ruler
     559             :  */
     560             : 
     561         496 : void DrawViewShell::UpdateHRuler()
     562             : {
     563         496 :     Invalidate( SID_ATTR_LONG_LRSPACE );
     564         496 :     Invalidate( SID_RULER_PAGE_POS );
     565         496 :     Invalidate( SID_RULER_OBJECT );
     566         496 :     Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
     567             : 
     568         496 :     if (mpHorizontalRuler.get() != NULL)
     569         496 :         mpHorizontalRuler->ForceUpdate();
     570         496 : }
     571             : 
     572             : /**
     573             :  * Refresh vertical ruler
     574             :  */
     575             : 
     576         494 : void DrawViewShell::UpdateVRuler()
     577             : {
     578         494 :     Invalidate( SID_ATTR_LONG_LRSPACE );
     579         494 :     Invalidate( SID_RULER_PAGE_POS );
     580         494 :     Invalidate( SID_RULER_OBJECT );
     581             : 
     582         494 :     if (mpVerticalRuler.get() != NULL)
     583         494 :         mpVerticalRuler->ForceUpdate();
     584         494 : }
     585             : 
     586             : /**
     587             :  * Set metric
     588             :  */
     589             : 
     590           0 : void DrawViewShell::SetUIUnit(FieldUnit eUnit)
     591             : {
     592           0 :     ViewShell::SetUIUnit(eUnit);
     593           0 : }
     594             : 
     595             : /**
     596             :  * Refresh TabControl on splitter change
     597             :  */
     598             : 
     599           0 : IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab )
     600             : {
     601           0 :     const long int nMax = maViewSize.Width() - maScrBarWH.Width()
     602           0 :         - maTabControl->GetPosPixel().X() ;
     603             : 
     604           0 :     Size aTabSize = maTabControl->GetSizePixel();
     605           0 :     aTabSize.Width() = std::min(pTab->GetSplitSize(), (long)(nMax-1));
     606             : 
     607           0 :     maTabControl->SetSizePixel(aTabSize);
     608             : 
     609           0 :     if(GetLayerTabControl()) // #i87182#
     610             :     {
     611           0 :         GetLayerTabControl()->SetSizePixel(aTabSize);
     612             :     }
     613             : 
     614           0 :     Point aPos = maTabControl->GetPosPixel();
     615           0 :     aPos.X() += aTabSize.Width();
     616             : 
     617           0 :     Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height());
     618           0 :     mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
     619             : 
     620           0 :     return 0;
     621             : }
     622             : 
     623             : /// inherited from sd::ViewShell
     624         404 : SdPage* DrawViewShell::getCurrentPage() const
     625             : {
     626         404 :     const sal_Int32 nPageCount = (meEditMode == EM_PAGE)?
     627         404 :                                     GetDoc()->GetSdPageCount(mePageKind):
     628         808 :                                     GetDoc()->GetMasterSdPageCount(mePageKind);
     629             : 
     630         404 :     sal_Int32 nCurrentPage = maTabControl->GetCurPageId() - 1;
     631             :     DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" );
     632         404 :     if( (nPageCount < 0) || (nCurrentPage>=nPageCount) )
     633           0 :         nCurrentPage = 0; // play safe here
     634             : 
     635         404 :     if (meEditMode == EM_PAGE)
     636             :     {
     637         404 :         return GetDoc()->GetSdPage((sal_uInt16)nCurrentPage, mePageKind);
     638             :     }
     639             :     else // EM_MASTERPAGE
     640             :     {
     641           0 :         return GetDoc()->GetMasterSdPage((sal_uInt16)nCurrentPage, mePageKind);
     642             :     }
     643             : }
     644             : 
     645             : /**
     646             :  * Select new refreshed page, in case of a page order change (eg. by undo)
     647             :  */
     648             : 
     649         435 : void DrawViewShell::ResetActualPage()
     650             : {
     651         435 :     if (!GetDoc())
     652         435 :         return;
     653             : 
     654         435 :     sal_uInt16 nCurrentPage = maTabControl->GetCurPageId() - 1;
     655         435 :     sal_uInt16 nPageCount   = (meEditMode == EM_PAGE)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
     656         435 :     if (nPageCount > 0)
     657         435 :         nCurrentPage = std::min((sal_uInt16)(nPageCount - 1), nCurrentPage);
     658             :     else
     659           0 :         nCurrentPage = 0;
     660             : 
     661         435 :     if (meEditMode == EM_PAGE)
     662             :     {
     663             : 
     664             :         // Update for TabControl
     665         435 :         maTabControl->Clear();
     666             : 
     667         435 :         SdPage* pPage = NULL;
     668             : 
     669        1014 :         for (sal_uInt16 i = 0; i < nPageCount; i++)
     670             :         {
     671         579 :             pPage = GetDoc()->GetSdPage(i, mePageKind);
     672         579 :             OUString aPageName = pPage->GetName();
     673         579 :             maTabControl->InsertPage(i + 1, aPageName);
     674             : 
     675             :             // correct selection recognition of the pages
     676         579 :             GetDoc()->SetSelected(pPage, i == nCurrentPage);
     677         579 :         }
     678             : 
     679         435 :         maTabControl->SetCurPageId(nCurrentPage + 1);
     680             :     }
     681             :     else // EM_MASTERPAGE
     682             :     {
     683           0 :         SdPage* pActualPage = GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind);
     684           0 :         maTabControl->Clear();
     685           0 :         sal_uInt16 nActualMasterPageNum = 0;
     686             : 
     687           0 :         sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
     688           0 :         for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
     689             :         {
     690           0 :             SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
     691           0 :             OUString aLayoutName = pMaster->GetLayoutName();
     692           0 :             sal_Int32 nPos = aLayoutName.indexOf(SD_LT_SEPARATOR);
     693           0 :             if (nPos != -1)
     694           0 :                 aLayoutName = aLayoutName.copy(0, nPos);
     695           0 :             maTabControl->InsertPage(i + 1, aLayoutName);
     696             : 
     697           0 :             if (pActualPage == pMaster)
     698           0 :                 nActualMasterPageNum = i;
     699           0 :         }
     700             : 
     701           0 :         maTabControl->SetCurPageId(nActualMasterPageNum + 1);
     702           0 :         SwitchPage(nActualMasterPageNum);
     703             :     }
     704             : 
     705             :     GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
     706         435 :                 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
     707             : }
     708             : 
     709             : /**
     710             :  * Apply "Verb" on OLE-object.
     711             :  */
     712             : 
     713           0 : ErrCode DrawViewShell::DoVerb(long nVerb)
     714             : {
     715           0 :     if ( mpDrawView->AreObjectsMarked() )
     716             :     {
     717           0 :         const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
     718             : 
     719           0 :         if (rMarkList.GetMarkCount() == 1)
     720             :         {
     721           0 :             SdrMark* pMark = rMarkList.GetMark(0);
     722           0 :             SdrObject* pObj = pMark->GetMarkedSdrObj();
     723             : 
     724           0 :             sal_uInt32 nInv = pObj->GetObjInventor();
     725           0 :             sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
     726             : 
     727           0 :             if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
     728             :             {
     729           0 :                 ActivateObject( static_cast<SdrOle2Obj*>(pObj), nVerb);
     730             :             }
     731             :         }
     732             :     }
     733             : 
     734           0 :     return 0;
     735             : }
     736             : 
     737             : /**
     738             :  * Activate OLE-object
     739             :  */
     740             : 
     741           0 : bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
     742             : {
     743           0 :     bool bActivated = false;
     744             : 
     745           0 :     if ( !GetDocSh()->IsUIActive() )
     746             :     {
     747           0 :         ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager());
     748             : 
     749           0 :         bActivated = ViewShell::ActivateObject(pObj, nVerb);
     750             : 
     751             :         OSL_ASSERT(GetViewShell()!=NULL);
     752           0 :         Client* pClient = static_cast<Client*>(GetViewShell()->GetIPClient());
     753           0 :         if (pClient)
     754           0 :             pClient->SetSdrGrafObj(NULL);
     755             :     }
     756             : 
     757           0 :     return bActivated;
     758             : }
     759             : 
     760             : /**
     761             :  * Switch to desired page.
     762             :  * nSelectPage refers to the current EditMode
     763             :  */
     764             : 
     765         984 : void LclResetFlag (bool& rbFlag) {rbFlag = false;}
     766             : 
     767         984 : bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
     768             : {
     769             :     /** Under some circumstances there are nested calls to SwitchPage() and
     770             :         may crash the application (activation of form controls when the
     771             :         shell of the edit view is not on top of the shell stack, see issue
     772             :         83888 for details.)  Therefore the nested calls are ignored (they
     773             :         would jump to the wrong page anyway.)
     774             :     */
     775         984 :     if (mbIsInSwitchPage)
     776           0 :         return false;
     777         984 :     mbIsInSwitchPage = true;
     778         984 :     comphelper::ScopeGuard aGuard (::boost::bind(LclResetFlag, ::boost::ref(mbIsInSwitchPage)));
     779             : 
     780         984 :     if (GetActiveWindow()->IsInPaint())
     781             :     {
     782             :         // Switching the current page while a Paint is being executed is
     783             :         // dangerous.  So, post it for later execution and return.
     784             :         maAsynchronousSwitchPageCall.Post(::boost::bind(
     785             :             ::std::mem_fun(&DrawViewShell::SwitchPage),
     786             :             this,
     787           0 :             nSelectedPage));
     788           0 :         return false;
     789             :     }
     790             : 
     791         984 :     bool bOK = false;
     792             : 
     793             :     // With the current implementation of FuSlideShow there is a problem
     794             :     // when it dsplays the show in a window: When the show is stopped it
     795             :     // returns at one point in time SDRPAGE_NOTFOUND as current page index.
     796             :     // Because FuSlideShow is currently being rewritten this bug is fixed
     797             :     // here.
     798             :     // This is not as bad a hack as it may look because making SwitchPage()
     799             :     // more robust with respect to invalid page numbers is a good thing
     800             :     // anyway.
     801         984 :     if (nSelectedPage == SDRPAGE_NOTFOUND)
     802             :     {
     803           0 :         nSelectedPage = 0;
     804             :     }
     805             :     else
     806             :     {
     807             :         // Make sure that the given page index points to an existing page.  Move
     808             :         // the index into the valid range if necessary.
     809         984 :         sal_uInt16 nPageCount = (meEditMode == EM_PAGE)
     810         945 :             ? GetDoc()->GetSdPageCount(mePageKind)
     811        1929 :             : GetDoc()->GetMasterSdPageCount(mePageKind);
     812         984 :         if (nSelectedPage >= nPageCount)
     813           0 :             nSelectedPage = nPageCount-1;
     814             :     }
     815             : 
     816         984 :     if (IsSwitchPageAllowed())
     817             :     {
     818         984 :         ModifyGuard aGuard2( GetDoc() );
     819             : 
     820         984 :         bOK = true;
     821             : 
     822         984 :         if (mpActualPage)
     823             :         {
     824         854 :             SdPage* pNewPage = NULL;
     825             : 
     826         854 :             if (meEditMode == EM_MASTERPAGE)
     827             :             {
     828          39 :                 if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage )
     829          39 :                     pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
     830             : 
     831          39 :                 if( pNewPage )
     832             :                 {
     833          39 :                     SdrPageView* pPV = mpDrawView->GetSdrPageView();
     834          39 :                     OUString sPageText(pNewPage->GetLayoutName());
     835          39 :                     sal_Int32 nPos = sPageText.indexOf(SD_LT_SEPARATOR);
     836          39 :                     if (nPos != -1)
     837          39 :                         sPageText = sPageText.copy(0, nPos);
     838          85 :                     if (pPV
     839          36 :                         && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() )
     840         142 :                         && sPageText == maTabControl->GetPageText(nSelectedPage+1))
     841             :                     {
     842             :                         // this slide is already visible
     843          32 :                         return true;
     844           7 :                     }
     845             :                 }
     846             :             }
     847             :             else
     848             :             {
     849             :                 OSL_ASSERT(mpFrameView!=NULL);
     850         815 :                 mpFrameView->SetSelectedPage(nSelectedPage);
     851             : 
     852         815 :                 if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage)
     853         815 :                     pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
     854             : 
     855         815 :                 if (mpActualPage == pNewPage)
     856             :                 {
     857         805 :                     SdrPageView* pPV = mpDrawView->GetSdrPageView();
     858             : 
     859         805 :                     SdPage* pCurrentPage = pPV ? dynamic_cast<SdPage*>(pPV->GetPage()) : NULL;
     860        1613 :                     if (pCurrentPage
     861         805 :                         && pNewPage == pCurrentPage
     862        3214 :                         && maTabControl->GetPageText(nSelectedPage+1).equals(pNewPage->GetName()))
     863             :                     {
     864             :                         // this slide is already visible
     865         802 :                         return true;
     866             :                     }
     867             :                 }
     868             :             }
     869             :         }
     870             : 
     871         150 :         mpDrawView->SdrEndTextEdit();
     872             : 
     873         150 :         mpActualPage = NULL;
     874             : 
     875         150 :         if (meEditMode == EM_PAGE)
     876             :         {
     877         143 :             mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
     878             :         }
     879             :         else
     880             :         {
     881           7 :             SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
     882             : 
     883             :             // does the selected page fit to the masterpage?
     884           7 :             sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind);
     885          14 :             for (sal_uInt16 i = 0; i < nPageCount; i++)
     886             :             {
     887          12 :                 SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
     888          12 :                 if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage()))
     889             :                 {
     890           5 :                     mpActualPage = pPage;
     891           5 :                     break;
     892             :                 }
     893             :             }
     894             : 
     895           7 :             if (!mpActualPage)
     896             :             {
     897             :                 // take the first page, that fits to the masterpage
     898           2 :                 for (sal_uInt16 i = 0; i < nPageCount; i++)
     899             :                 {
     900           2 :                     SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
     901           2 :                     if(pPage && pMaster == &(pPage->TRG_GetMasterPage()))
     902             :                     {
     903           2 :                         mpActualPage = pPage;
     904           2 :                         break;
     905             :                     }
     906             :                 }
     907             :             }
     908             :         }
     909             : 
     910         336 :         for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++)
     911             :         {
     912             :             // deselect all pages
     913         186 :             GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), false);
     914             :         }
     915             : 
     916         150 :         if (!mpActualPage)
     917             :         {
     918             :             // as far as there is no mpActualPage, take the first
     919           0 :             mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
     920             :         }
     921             : 
     922             :         // also select this page (mpActualPage always points at a drawing page,
     923             :         // never at a masterpage)
     924         150 :         GetDoc()->SetSelected(mpActualPage, true);
     925             : 
     926         300 :         rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
     927         150 :         if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) )
     928             :         {
     929             :             // tighten VisArea, to possibly deactivate objects
     930             :             // !!! only if we are not in presentation mode (#96279) !!!
     931             :             OSL_ASSERT (GetViewShell()!=NULL);
     932         150 :             GetViewShell()->DisconnectAllClients();
     933         150 :             VisAreaChanged(Rectangle(Point(), Size(1, 1)));
     934             :         }
     935             : 
     936         150 :         if (meEditMode == EM_PAGE)
     937             :         {
     938             :             /**********************************************************************
     939             :             * PAGEMODE
     940             :             **********************************************************************/
     941         143 :             GetDoc()->SetSelected(mpActualPage, true);
     942             : 
     943         143 :             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
     944             : 
     945         143 :             if (pPageView)
     946             :             {
     947          13 :                 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
     948          13 :                 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
     949          13 :                 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
     950             : 
     951          13 :                 if (mePageKind == PK_NOTES)
     952             :                 {
     953           2 :                     mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
     954             :                 }
     955          11 :                 else if (mePageKind == PK_HANDOUT)
     956             :                 {
     957           0 :                     mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
     958             :                 }
     959             :                 else
     960             :                 {
     961          11 :                     mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
     962             :                 }
     963             :             }
     964             : 
     965         143 :             mpDrawView->HideSdrPage();
     966         143 :             mpDrawView->ShowSdrPage(mpActualPage);
     967         143 :             GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage);
     968             : 
     969         143 :             SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
     970             : 
     971         143 :             if (pNewPageView)
     972             :             {
     973         143 :                 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
     974         143 :                 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
     975         143 :                 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
     976             : 
     977         143 :                 if (mePageKind == PK_NOTES)
     978             :                 {
     979           4 :                     pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
     980             :                 }
     981         139 :                 else if (mePageKind == PK_HANDOUT)
     982             :                 {
     983           0 :                     pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
     984             :                 }
     985             :                 else
     986             :                 {
     987         139 :                     pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
     988             :                 }
     989             :             }
     990             : 
     991         143 :             maTabControl->SetCurPageId(nSelectedPage+1);
     992         143 :             OUString aPageName = mpActualPage->GetName();
     993             : 
     994         143 :             if (maTabControl->GetPageText(nSelectedPage+1) != aPageName)
     995             :             {
     996           0 :                 maTabControl->SetPageText(nSelectedPage+1, aPageName);
     997         143 :             }
     998             :         }
     999             :         else
    1000             :         {
    1001             :             /**********************************************************************
    1002             :             * MASTERPAGE
    1003             :             **********************************************************************/
    1004           7 :             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
    1005             : 
    1006           7 :             if (pPageView)
    1007             :             {
    1008           4 :                 mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
    1009           4 :                 mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
    1010           4 :                 mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
    1011             : 
    1012           4 :                 if (mePageKind == PK_NOTES)
    1013             :                 {
    1014           2 :                     mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
    1015             :                 }
    1016           2 :                 else if (mePageKind == PK_HANDOUT)
    1017             :                 {
    1018           0 :                     mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
    1019             :                 }
    1020             :                 else
    1021             :                 {
    1022           2 :                     mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
    1023             :                 }
    1024             :             }
    1025             : 
    1026           7 :             mpDrawView->HideSdrPage();
    1027             : 
    1028           7 :             SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
    1029             : 
    1030           7 :             if( !pMaster )              // if this page should not exist
    1031           0 :                 pMaster = GetDoc()->GetMasterSdPage(0, mePageKind);
    1032             : 
    1033           7 :             sal_uInt16 nNum = pMaster->GetPageNum();
    1034           7 :             mpDrawView->ShowSdrPage(mpDrawView->GetModel()->GetMasterPage(nNum));
    1035             : 
    1036           7 :             GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster);
    1037             : 
    1038           7 :             SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
    1039             : 
    1040           7 :             if (pNewPageView)
    1041             :             {
    1042           7 :                 pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
    1043           7 :                 pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
    1044           7 :                 pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
    1045             : 
    1046           7 :                 if (mePageKind == PK_NOTES)
    1047             :                 {
    1048           2 :                     pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
    1049             :                 }
    1050           5 :                 else if (mePageKind == PK_HANDOUT)
    1051             :                 {
    1052           2 :                     pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
    1053             :                 }
    1054             :                 else
    1055             :                 {
    1056           3 :                     pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
    1057             :                 }
    1058             :             }
    1059             : 
    1060           7 :             OUString aLayoutName(pMaster->GetLayoutName());
    1061           7 :             sal_Int32 nPos = aLayoutName.indexOf(SD_LT_SEPARATOR);
    1062           7 :             if (nPos != -1)
    1063           7 :                 aLayoutName = aLayoutName.copy(0, nPos);
    1064             : 
    1065           7 :             maTabControl->SetCurPageId(nSelectedPage+1);
    1066             : 
    1067           7 :             if (maTabControl->GetPageText(nSelectedPage+1) != aLayoutName)
    1068             :             {
    1069           0 :                 maTabControl->SetPageText(nSelectedPage+1, aLayoutName);
    1070             :             }
    1071             : 
    1072           7 :             if( mePageKind == PK_HANDOUT )
    1073             :             {
    1074             :                 // set pages for all available handout presentation objects
    1075           2 :                 sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList();
    1076           2 :                 SdrObject* pObj = 0;
    1077           2 :                 rShapeList.seekShape(0);
    1078             : 
    1079          24 :                 while( (pObj = rShapeList.getNextShape()) )
    1080             :                 {
    1081          20 :                     if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT )
    1082             :                     {
    1083             :                         // #i105146# We want no content to be displayed for PK_HANDOUT,
    1084             :                         // so just never set a page as content
    1085          12 :                         static_cast<SdrPageObj*>(pObj)->SetReferencedPage(0);
    1086             :                     }
    1087             :                 }
    1088           7 :             }
    1089             :         }
    1090             : 
    1091         150 :         Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
    1092         150 :         Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
    1093         150 :         VisAreaChanged(aVisAreaWin);
    1094         150 :         mpDrawView->VisAreaChanged(GetActiveWindow());
    1095             : 
    1096             :         // so navigator (and effect window) notice that
    1097         150 :         SfxBindings& rBindings = GetViewFrame()->GetBindings();
    1098         150 :         rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, true, false);
    1099         150 :         rBindings.Invalidate(SID_STATUS_PAGE, true, false);
    1100         150 :         rBindings.Invalidate(SID_DELETE_MASTER_PAGE, true, false);
    1101         150 :         rBindings.Invalidate(SID_DELETE_PAGE, true, false);
    1102         150 :         rBindings.Invalidate(SID_ASSIGN_LAYOUT, true, false);
    1103         150 :         rBindings.Invalidate(SID_INSERTPAGE, true, false);
    1104         150 :         UpdatePreview( mpActualPage );
    1105             : 
    1106         300 :         mpDrawView->AdjustMarkHdl();
    1107             :     }
    1108             : 
    1109         150 :     return bOK;
    1110             : }
    1111             : 
    1112             : /**
    1113             :  * Check if page change is allowed
    1114             :  */
    1115             : 
    1116         984 : bool DrawViewShell::IsSwitchPageAllowed() const
    1117             : {
    1118         984 :     bool bOK = true;
    1119             : 
    1120         984 :     FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
    1121         984 :     if (pFormShell != NULL && !pFormShell->PrepareClose(false))
    1122           0 :         bOK = false;
    1123             : 
    1124         984 :     return bOK;
    1125             : }
    1126             : 
    1127             : /**
    1128             :  * Select new refreshed page, in case of a page order change (eg. by undo)
    1129             :  */
    1130             : 
    1131         545 : void DrawViewShell::ResetActualLayer()
    1132             : {
    1133         545 :     LayerTabBar* pLayerBar = GetLayerTabControl();
    1134         545 :     if (pLayerBar != NULL)
    1135             :     {
    1136             :         // remember old layer cound and current layer id
    1137             :         // this is needed when one layer is renamed to
    1138             :         // restore current layer
    1139         315 :         sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount();
    1140         315 :         sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId();
    1141             : 
    1142             :         /**
    1143             :          * Update for LayerTab
    1144             :          */
    1145         315 :         pLayerBar->Clear();
    1146             : 
    1147         315 :         OUString aName;
    1148         630 :         OUString aActiveLayer = mpDrawView->GetActiveLayer();
    1149         630 :         OUString aBackgroundLayer = SD_RESSTR(STR_LAYER_BCKGRND);
    1150         630 :         OUString aBackgroundObjLayer = SD_RESSTR(STR_LAYER_BCKGRNDOBJ);
    1151         630 :         OUString aLayoutLayer = SD_RESSTR(STR_LAYER_LAYOUT);
    1152         630 :         OUString aControlsLayer = SD_RESSTR(STR_LAYER_CONTROLS);
    1153         630 :         OUString aMeasureLinesLayer = SD_RESSTR(STR_LAYER_MEASURELINES);
    1154         315 :         sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND;
    1155         315 :         SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
    1156         315 :         sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
    1157             : 
    1158        1899 :         for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ )
    1159             :         {
    1160        1584 :             aName = rLayerAdmin.GetLayer(nLayer)->GetName();
    1161             : 
    1162        1584 :             if ( aName == aActiveLayer )
    1163             :             {
    1164         315 :                 nActiveLayer = nLayer;
    1165             :             }
    1166             : 
    1167        1584 :             if ( aName != aBackgroundLayer )
    1168             :             {
    1169        1269 :                 if (meEditMode == EM_MASTERPAGE)
    1170             :                 {
    1171             :                     // don't show page layer onto the masterpage
    1172           0 :                     if (aName != aLayoutLayer   &&
    1173           0 :                         aName != aControlsLayer &&
    1174           0 :                         aName != aMeasureLinesLayer)
    1175             :                     {
    1176           0 :                         pLayerBar->InsertPage(nLayer+1, aName);
    1177             : 
    1178           0 :                         TabBarPageBits nBits = 0;
    1179           0 :                         SdrPageView* pPV = mpDrawView->GetSdrPageView();
    1180             : 
    1181           0 :                         if (pPV && !pPV->IsLayerVisible(aName))
    1182             :                         {
    1183             :                             // invisible layers are displayed differently
    1184           0 :                             nBits = TPB_SPECIAL;
    1185             :                         }
    1186             : 
    1187           0 :                         pLayerBar->SetPageBits(nLayer+1, nBits);
    1188             :                     }
    1189             :                 }
    1190             :                 else
    1191             :                 {
    1192             :                     // don't show masterpage layer onto the page
    1193        1269 :                     if ( aName != aBackgroundObjLayer )
    1194             :                     {
    1195         954 :                         pLayerBar->InsertPage(nLayer+1, aName);
    1196             : 
    1197         954 :                         TabBarPageBits nBits = 0;
    1198             : 
    1199         954 :                         if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName))
    1200             :                         {
    1201             :                             // invisible layers are displayed differently
    1202           0 :                             nBits = TPB_SPECIAL;
    1203             :                         }
    1204             : 
    1205         954 :                         pLayerBar->SetPageBits(nLayer+1, nBits);
    1206             :                     }
    1207             :                 }
    1208             :             }
    1209             :         }
    1210             : 
    1211         315 :         if ( nActiveLayer == SDRLAYER_NOTFOUND )
    1212             :         {
    1213           0 :             if( nOldLayerCnt == pLayerBar->GetPageCount() )
    1214             :             {
    1215           0 :                 nActiveLayer = nOldLayerId - 1;
    1216             :             }
    1217             :             else
    1218             :             {
    1219           0 :                 nActiveLayer = ( meEditMode == EM_MASTERPAGE ) ? 2 : 0;
    1220             :             }
    1221             : 
    1222           0 :             mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) );
    1223             :         }
    1224             : 
    1225         315 :         pLayerBar->SetCurPageId(nActiveLayer + 1);
    1226         315 :         GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER );
    1227         630 :         GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER );
    1228             :     }
    1229         545 : }
    1230             : 
    1231             : /**
    1232             :  * AcceptDrop
    1233             :  */
    1234             : 
    1235           0 : sal_Int8 DrawViewShell::AcceptDrop (
    1236             :     const AcceptDropEvent& rEvt,
    1237             :     DropTargetHelper& rTargetHelper,
    1238             :     ::sd::Window* pTargetWindow,
    1239             :     sal_uInt16 nPage,
    1240             :     sal_uInt16 nLayer )
    1241             : {
    1242           0 :     if( nPage != SDRPAGE_NOTFOUND )
    1243           0 :         nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
    1244             : 
    1245           0 :     if( SlideShow::IsRunning( GetViewShellBase() ) )
    1246           0 :         return DND_ACTION_NONE;
    1247             : 
    1248           0 :     return mpDrawView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer );
    1249             : }
    1250             : 
    1251             : /**
    1252             :  * ExecuteDrop
    1253             :  */
    1254             : 
    1255           0 : sal_Int8 DrawViewShell::ExecuteDrop (
    1256             :     const ExecuteDropEvent& rEvt,
    1257             :     DropTargetHelper& rTargetHelper,
    1258             :     ::sd::Window* pTargetWindow,
    1259             :     sal_uInt16 nPage,
    1260             :     sal_uInt16 nLayer)
    1261             : {
    1262           0 :     if( nPage != SDRPAGE_NOTFOUND )
    1263           0 :         nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
    1264             : 
    1265           0 :     if( SlideShow::IsRunning( GetViewShellBase() ) )
    1266           0 :         return DND_ACTION_NONE;
    1267             : 
    1268           0 :     Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
    1269           0 :     sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ));
    1270           0 :     Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
    1271             : 
    1272           0 :     return nResult;
    1273             : }
    1274             : 
    1275          66 : } // end of namespace sd
    1276             : 
    1277             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11