LCOV - code coverage report
Current view: top level - sd/source/ui/view - drviewsa.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 229 366 62.6 %
Date: 2014-11-03 Functions: 17 22 77.3 %
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 <com/sun/star/scanner/ScannerManager.hpp>
      22             : #include <cppuhelper/implbase1.hxx>
      23             : #include <comphelper/processfactory.hxx>
      24             : #include <editeng/sizeitem.hxx>
      25             : #include <svx/svdlayer.hxx>
      26             : #include <sfx2/zoomitem.hxx>
      27             : #include <svx/svdpagv.hxx>
      28             : #include <svl/ptitem.hxx>
      29             : #include <svl/stritem.hxx>
      30             : #include <sfx2/request.hxx>
      31             : #include <sfx2/dispatch.hxx>
      32             : #include <svx/svdopath.hxx>
      33             : #include <sfx2/docfile.hxx>
      34             : #include <svx/zoomslideritem.hxx>
      35             : #include <svl/eitem.hxx>
      36             : 
      37             : #include <svx/dialogs.hrc>
      38             : #include <svx/extrusionbar.hxx>
      39             : #include <svx/fontworkbar.hxx>
      40             : #include <svx/clipfmtitem.hxx>
      41             : 
      42             : #include <sfx2/viewfrm.hxx>
      43             : #include <svx/fmshell.hxx>
      44             : #include <svtools/cliplistener.hxx>
      45             : #include <svx/float3d.hxx>
      46             : #include <svx/sidebar/SelectionAnalyzer.hxx>
      47             : #include "helpids.h"
      48             : 
      49             : #include "view/viewoverlaymanager.hxx"
      50             : #include "app.hrc"
      51             : #include "strings.hrc"
      52             : #include "res_bmp.hrc"
      53             : #include "sdpage.hxx"
      54             : #include "FrameView.hxx"
      55             : #include "drawdoc.hxx"
      56             : #include "sdresid.hxx"
      57             : #include "DrawDocShell.hxx"
      58             : #include "Window.hxx"
      59             : #include "fupoor.hxx"
      60             : #include "fusel.hxx"
      61             : #include "drawview.hxx"
      62             : #include "SdUnoDrawView.hxx"
      63             : #include "ViewShellBase.hxx"
      64             : #include "slideshow.hxx"
      65             : #include "ToolBarManager.hxx"
      66             : #include "annotationmanager.hxx"
      67             : #include "DrawController.hxx"
      68             : 
      69             : #include <boost/bind.hpp>
      70             : #include <boost/scoped_ptr.hpp>
      71             : 
      72             : using namespace ::com::sun::star;
      73             : using namespace ::com::sun::star::uno;
      74             : using sfx2::sidebar::EnumContext;
      75             : 
      76             : namespace sd {
      77             : 
      78             : bool DrawViewShell::mbPipette = false;
      79             : 
      80             : // - ScannerEventListener -
      81             : 
      82             : class ScannerEventListener : public ::cppu::WeakImplHelper1< lang::XEventListener >
      83             : {
      84             : private:
      85             : 
      86             :     DrawViewShell*      mpParent;
      87             : 
      88             : public:
      89             : 
      90         196 :                             ScannerEventListener( DrawViewShell* pParent ) : mpParent( pParent )  {};
      91             :                             virtual ~ScannerEventListener();
      92             : 
      93             :     // XEventListener
      94             :     virtual void SAL_CALL   disposing( const lang::EventObject& rEventObject ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      95             : 
      96         196 :     void                    ParentDestroyed() { mpParent = NULL; }
      97             : };
      98             : 
      99         392 : ScannerEventListener::~ScannerEventListener()
     100             : {
     101         392 : }
     102             : 
     103           0 : void SAL_CALL ScannerEventListener::disposing( const lang::EventObject& rEventObject ) throw (uno::RuntimeException, std::exception)
     104             : {
     105           0 :     if( mpParent )
     106           0 :         mpParent->ScannerEvent( rEventObject );
     107           0 : }
     108             : 
     109         212 : DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, vcl::Window* pParentWindow, PageKind ePageKind, FrameView* pFrameViewArgument )
     110             :     : ViewShell (pFrame, pParentWindow, rViewShellBase)
     111             :     , maTabControl(this, pParentWindow)
     112             :     , mbIsLayerModeActive(false)
     113             :     , mbIsInSwitchPage(false)
     114             :     , mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
     115             :           ::boost::bind(&DrawViewShell::GetSidebarContextName, this),
     116         212 :           uno::Reference<frame::XController>(&rViewShellBase.GetDrawController()),
     117         424 :           sfx2::sidebar::EnumContext::Context_Default))
     118             : {
     119         212 :     if (pFrameViewArgument != NULL)
     120           0 :         mpFrameView = pFrameViewArgument;
     121             :     else
     122         212 :         mpFrameView = new FrameView(GetDoc());
     123         212 :     Construct(GetDocSh(), ePageKind);
     124             : 
     125         212 :     mpSelectionChangeHandler->Connect();
     126             : 
     127         212 :     SetContextName(GetSidebarContextName());
     128             : 
     129         212 :     doShow();
     130         212 : }
     131             : 
     132         476 : DrawViewShell::~DrawViewShell()
     133             : {
     134         212 :     mpSelectionChangeHandler->Disconnect();
     135             : 
     136         212 :     mpAnnotationManager.reset();
     137         212 :     mpViewOverlayManager.reset();
     138             : 
     139             :     OSL_ASSERT (GetViewShell()!=NULL);
     140             : 
     141         212 :     if( mxScannerListener.is() )
     142         196 :         static_cast< ScannerEventListener* >( mxScannerListener.get() )->ParentDestroyed();
     143             : 
     144             :     // Remove references to items within Svx3DWin
     145             :     // (maybe do a listening sometime in Svx3DWin)
     146         212 :     sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
     147         212 :     SfxChildWindow* pWindow = GetViewFrame() ? GetViewFrame()->GetChildWindow(nId) : NULL;
     148         212 :     if(pWindow)
     149             :     {
     150           0 :         Svx3DWin* p3DWin = static_cast< Svx3DWin* > (pWindow->GetWindow());
     151           0 :         if(p3DWin)
     152           0 :             p3DWin->DocumentReload();
     153             :     }
     154             : 
     155         212 :     EndListening (*GetDoc());
     156         212 :     EndListening (*GetDocSh());
     157             : 
     158         212 :     if( SlideShow::IsRunning(*this) )
     159           0 :         StopSlideShow(false);
     160             : 
     161         212 :     DisposeFunctions();
     162             : 
     163             :     SdPage* pPage;
     164         212 :     sal_uInt16 aPageCnt = GetDoc()->GetSdPageCount(mePageKind);
     165             : 
     166         464 :     for (sal_uInt16 i = 0; i < aPageCnt; i++)
     167             :     {
     168         252 :         pPage = GetDoc()->GetSdPage(i, mePageKind);
     169             : 
     170         252 :         if (pPage == mpActualPage)
     171             :         {
     172         212 :             GetDoc()->SetSelected(pPage, true);
     173             :         }
     174             :         else
     175             :         {
     176          40 :             GetDoc()->SetSelected(pPage, false);
     177             :         }
     178             :     }
     179             : 
     180         212 :     if ( mpClipEvtLstnr )
     181             :     {
     182         111 :         mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), false );
     183         111 :         mpClipEvtLstnr->ClearCallbackLink();        // prevent callback if another thread is waiting
     184         111 :         mpClipEvtLstnr->release();
     185             :     }
     186             : 
     187         212 :     delete mpDrawView;
     188             :     // Set mpView to NULL so that the destructor of the ViewShell base class
     189             :     // does not access it.
     190         212 :     mpView = mpDrawView = NULL;
     191             : 
     192         212 :     mpFrameView->Disconnect();
     193         212 :     delete [] mpSlotArray;
     194         264 : }
     195             : 
     196             : /**
     197             :  * common part of both constructors
     198             :  */
     199         212 : void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind)
     200             : {
     201         212 :     mpActualPage = 0;
     202         212 :     mbMousePosFreezed = false;
     203         212 :     mbReadOnly = GetDocSh()->IsReadOnly();
     204         212 :     mpSlotArray = 0;
     205         212 :     mpClipEvtLstnr = 0;
     206         212 :     mbPastePossible = false;
     207         212 :     mbIsLayerModeActive = false;
     208             : 
     209         212 :     mpFrameView->Connect();
     210             : 
     211             :     OSL_ASSERT (GetViewShell()!=NULL);
     212             : 
     213             :     /* array for slot-/image mapping:
     214             :        even entry: main-/toolbox slot
     215             :        odd entry:  mapped slot
     216             :        Attention: adjust GetIdBySubId() !!!
     217             :        Do not change order (especial zoom) !!! */
     218         212 :     mpSlotArray = new sal_uInt16[ SLOTARRAY_COUNT ];
     219         212 :     mpSlotArray[ 0 ]  = SID_OBJECT_CHOOSE_MODE;
     220         212 :     mpSlotArray[ 1 ]  = SID_OBJECT_ROTATE;
     221         212 :     mpSlotArray[ 2 ]  = SID_OBJECT_ALIGN;
     222         212 :     mpSlotArray[ 3 ]  = SID_OBJECT_ALIGN_LEFT;
     223         212 :     mpSlotArray[ 4 ]  = SID_ZOOM_TOOLBOX;
     224         212 :     mpSlotArray[ 5 ]  = SID_ZOOM_TOOLBOX;
     225         212 :     mpSlotArray[ 6 ]  = SID_DRAWTBX_TEXT;
     226         212 :     mpSlotArray[ 7 ]  = SID_ATTR_CHAR;
     227         212 :     mpSlotArray[ 8 ]  = SID_DRAWTBX_RECTANGLES;
     228         212 :     mpSlotArray[ 9 ]  = SID_DRAW_RECT;
     229         212 :     mpSlotArray[ 10 ] = SID_DRAWTBX_ELLIPSES;
     230         212 :     mpSlotArray[ 11 ] = SID_DRAW_ELLIPSE;
     231         212 :     mpSlotArray[ 12 ] = SID_DRAWTBX_LINES;
     232         212 :     mpSlotArray[ 13 ] = SID_DRAW_FREELINE_NOFILL;
     233         212 :     mpSlotArray[ 14 ] = SID_DRAWTBX_3D_OBJECTS;
     234         212 :     mpSlotArray[ 15 ] = SID_3D_CUBE;
     235         212 :     mpSlotArray[ 16 ] = SID_DRAWTBX_INSERT;
     236         212 :     mpSlotArray[ 17 ] = SID_INSERT_DIAGRAM;
     237         212 :     mpSlotArray[ 18 ] = SID_POSITION;
     238         212 :     mpSlotArray[ 19 ] = SID_FRAME_TO_TOP;
     239         212 :     mpSlotArray[ 20 ] = SID_DRAWTBX_CONNECTORS;
     240         212 :     mpSlotArray[ 21 ] = SID_TOOL_CONNECTOR;
     241         212 :     mpSlotArray[ 22 ] = SID_DRAWTBX_ARROWS;
     242         212 :     mpSlotArray[ 23 ] = SID_LINE_ARROW_END;
     243             : 
     244         212 :     SetPool( &GetDoc()->GetPool() );
     245             : 
     246         212 :     GetDoc()->CreateFirstPages();
     247             : 
     248         212 :     mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this);
     249         212 :     mpView = mpDrawView;             // Pointer of base class ViewShell
     250         212 :     mpDrawView->SetSwapAsynchron(true); // Asynchronous load of graphics
     251             : 
     252             :     // We do not read the page kind from the frame view anymore so we have
     253             :     // to set it in order to resync frame view and this view.
     254         212 :     mpFrameView->SetPageKind(eInitialPageKind);
     255         212 :     mePageKind = eInitialPageKind;
     256         212 :     meEditMode = EM_PAGE;
     257         212 :     DocumentType eDocType = GetDoc()->GetDocumentType(); // RTTI does not work here
     258         212 :     switch (mePageKind)
     259             :     {
     260             :         case PK_STANDARD:
     261         212 :             meShellType = ST_IMPRESS;
     262         212 :             break;
     263             : 
     264             :         case PK_NOTES:
     265           0 :             meShellType = ST_NOTES;
     266           0 :             break;
     267             : 
     268             :         case PK_HANDOUT:
     269           0 :             meShellType = ST_HANDOUT;
     270           0 :             break;
     271             :     }
     272             : 
     273         212 :     Size aPageSize( GetDoc()->GetSdPage(0, mePageKind)->GetSize() );
     274         212 :     Point aPageOrg( aPageSize.Width(), aPageSize.Height() / 2);
     275         212 :     Size aSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
     276         212 :     InitWindows(aPageOrg, aSize, Point(-1, -1));
     277             : 
     278         212 :     Point aVisAreaPos;
     279             : 
     280         212 :     if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
     281             :     {
     282           0 :         aVisAreaPos = pDocSh->GetVisArea(ASPECT_CONTENT).TopLeft();
     283             :     }
     284             : 
     285         212 :     mpDrawView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
     286             : 
     287             :     // objects can not grow bigger than ViewSize
     288         212 :     GetDoc()->SetMaxObjSize(aSize);
     289             : 
     290             :     // Split-Handler for TabControls
     291         212 :     maTabControl.SetSplitHdl( LINK( this, DrawViewShell, TabSplitHdl ) );
     292             : 
     293             :     /* In order to set the correct EditMode of the FrameView, we select another
     294             :        one (small trick).  */
     295         212 :     if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE)
     296             :     {
     297         212 :         meEditMode = EM_MASTERPAGE;
     298             :     }
     299             :     else
     300             :     {
     301           0 :         meEditMode = EM_PAGE;
     302             :     }
     303             : 
     304             :     // Use configuration of FrameView
     305         212 :     ReadFrameViewData(mpFrameView);
     306             : 
     307         212 :     if( eDocType == DOCUMENT_TYPE_DRAW )
     308             :     {
     309         160 :         SetHelpId( SD_IF_SDGRAPHICVIEWSHELL );
     310         160 :         GetActiveWindow()->SetHelpId( HID_SDGRAPHICVIEWSHELL );
     311         160 :         GetActiveWindow()->SetUniqueId( HID_SDGRAPHICVIEWSHELL );
     312             :     }
     313             :     else
     314             :     {
     315          52 :         if (mePageKind == PK_NOTES)
     316             :         {
     317           0 :             SetHelpId( SID_NOTESMODE );
     318           0 :             GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE );
     319           0 :             GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE );
     320             : 
     321             :             // AutoLayouts have to be created
     322           0 :             GetDoc()->StopWorkStartupDelay();
     323             :         }
     324          52 :         else if (mePageKind == PK_HANDOUT)
     325             :         {
     326           0 :             SetHelpId( SID_HANDOUTMODE );
     327           0 :             GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE );
     328           0 :             GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE );
     329             : 
     330             :             // AutoLayouts have to be created
     331           0 :             GetDoc()->StopWorkStartupDelay();
     332             :         }
     333             :         else
     334             :         {
     335          52 :             SetHelpId( SD_IF_SDDRAWVIEWSHELL );
     336          52 :             GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL );
     337          52 :             GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL );
     338             :         }
     339             :     }
     340             : 
     341             :     // start selection function
     342         212 :     SfxRequest aReq(SID_OBJECT_SELECT, SfxCallMode::SLOT, GetDoc()->GetItemPool());
     343         212 :     FuPermanent(aReq);
     344         212 :     mpDrawView->SetFrameDragSingles(true);
     345             : 
     346         212 :     if (pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
     347             :     {
     348           0 :         mbZoomOnPage = false;
     349             :     }
     350             :     else
     351             :     {
     352         212 :         mbZoomOnPage = true;
     353             :     }
     354             : 
     355         212 :     mbIsRulerDrag = false;
     356             : 
     357         424 :     OUString aName( "DrawViewShell" );
     358         212 :     SetName (aName);
     359             : 
     360         212 :     mnLockCount = 0UL;
     361             : 
     362         424 :     uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     363             : 
     364             :     try
     365             :     {
     366         212 :         mxScannerManager = scanner::ScannerManager::create( xContext );
     367             : 
     368         588 :         mxScannerListener = uno::Reference< lang::XEventListener >(
     369         196 :                             static_cast< ::cppu::OWeakObject* >( new ScannerEventListener( this ) ),
     370         196 :                             uno::UNO_QUERY );
     371             :     }
     372          16 :     catch (Exception& exception)
     373             :     {
     374             :         // Eat the exception and log it
     375             :         // We can still continue if scanner manager is not available.
     376             :         SAL_WARN("sd", "Scanner manager exception: " << exception.Message);
     377             :     }
     378             : 
     379         212 :     mpAnnotationManager.reset( new AnnotationManager( GetViewShellBase() ) );
     380         424 :     mpViewOverlayManager.reset( new ViewOverlayManager( GetViewShellBase() ) );
     381         212 : }
     382             : 
     383         212 : void DrawViewShell::Init (bool bIsMainViewShell)
     384             : {
     385         212 :     ViewShell::Init(bIsMainViewShell);
     386             : 
     387         212 :     StartListening (*GetDocSh());
     388         212 : }
     389             : 
     390         212 : void DrawViewShell::Shutdown (void)
     391             : {
     392         212 :     ViewShell::Shutdown();
     393             : 
     394         212 :     if(SlideShow::IsRunning( GetViewShellBase() ) )
     395             :     {
     396             :         // Turn off effects.
     397           0 :         GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE);
     398             :     }
     399         212 : }
     400             : 
     401         212 : css::uno::Reference<css::drawing::XDrawSubController> DrawViewShell::CreateSubController (void)
     402             : {
     403         212 :     css::uno::Reference<css::drawing::XDrawSubController> xSubController;
     404             : 
     405         212 :     if (IsMainViewShell())
     406             :     {
     407             :         // Create uno sub controller for the main view shell.
     408         424 :         xSubController = css::uno::Reference<css::drawing::XDrawSubController>(
     409             :             new SdUnoDrawView (
     410             :                 *this,
     411         424 :                 *GetView()));
     412             :     }
     413             : 
     414         212 :     return xSubController;
     415             : }
     416             : 
     417           0 : bool DrawViewShell::RelocateToParentWindow (vcl::Window* pParentWindow)
     418             : {
     419             :     // DrawViewShells can not be relocated to a new parent window at the
     420             :     // moment, so return <FALSE/> except when the given parent window is the
     421             :     // parent window that is already in use.
     422           0 :     return pParentWindow==GetParentWindow();
     423             : }
     424             : 
     425             : /**
     426             :  * check if we have to draw a polyline
     427             :  */
     428             : 
     429             : /*
     430             :     Polylines are represented by makros as a sequence of:
     431             :         MoveTo (x, y)
     432             :         LineTo (x, y)   [or BezierTo (x, y)]
     433             :         LineTo (x, y)
     434             :             :
     435             :     There is no end command for polylines. Therefore, we have to test all
     436             :     commands in the requests for LineTo (BezierTo) and we have to gather
     437             :     the point-parameter. The first not-LineTo leads to the creation of the
     438             :     polyline from the gathered points.
     439             : */
     440             : 
     441        1688 : void DrawViewShell::CheckLineTo(SfxRequest& rReq)
     442             : {
     443             :     (void)rReq;
     444             : #ifdef DBG_UTIL
     445             :     if(rReq.IsAPI())
     446             :     {
     447             :         if(SID_LINETO == rReq.GetSlot() || SID_BEZIERTO == rReq.GetSlot() || SID_MOVETO == rReq.GetSlot() )
     448             :         {
     449             :             OSL_FAIL("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
     450             :         }
     451             :     }
     452             : #endif
     453             : 
     454        1688 :     rReq.Ignore ();
     455        1688 : }
     456             : 
     457             : /**
     458             :  * Change page parameter if SID_PAGESIZE or SID_PAGEMARGIN
     459             :  */
     460           0 : void DrawViewShell::SetupPage (Size &rSize,
     461             :                                  long nLeft,
     462             :                                  long nRight,
     463             :                                  long nUpper,
     464             :                                  long nLower,
     465             :                                  bool bSize,
     466             :                                  bool bMargin,
     467             :                                  bool bScaleAll)
     468             : {
     469           0 :     sal_uInt16 nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
     470             :     sal_uInt16 i;
     471             : 
     472           0 :     for (i = 0; i < nPageCnt; i++)
     473             :     {
     474             :         // first, handle all master pages
     475           0 :         SdPage *pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
     476             : 
     477           0 :         if( pPage )
     478             :         {
     479           0 :             if( bSize )
     480             :             {
     481           0 :                 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
     482           0 :                 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
     483           0 :                 pPage->SetSize(rSize);
     484             : 
     485             :             }
     486           0 :             if( bMargin )
     487             :             {
     488           0 :                 pPage->SetLftBorder(nLeft);
     489           0 :                 pPage->SetRgtBorder(nRight);
     490           0 :                 pPage->SetUppBorder(nUpper);
     491           0 :                 pPage->SetLwrBorder(nLower);
     492             :             }
     493             : 
     494           0 :             if ( mePageKind == PK_STANDARD )
     495             :             {
     496           0 :                 GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
     497             :             }
     498             : 
     499           0 :             pPage->CreateTitleAndLayout();
     500             :         }
     501             :     }
     502             : 
     503           0 :     nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
     504             : 
     505           0 :     for (i = 0; i < nPageCnt; i++)
     506             :     {
     507             :         // then, handle all pages
     508           0 :         SdPage *pPage = GetDoc()->GetSdPage(i, mePageKind);
     509             : 
     510           0 :         if( pPage )
     511             :         {
     512           0 :             if( bSize )
     513             :             {
     514           0 :                 Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
     515           0 :                 pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
     516           0 :                 pPage->SetSize(rSize);
     517             :             }
     518           0 :             if( bMargin )
     519             :             {
     520           0 :                 pPage->SetLftBorder(nLeft);
     521           0 :                 pPage->SetRgtBorder(nRight);
     522           0 :                 pPage->SetUppBorder(nUpper);
     523           0 :                 pPage->SetLwrBorder(nLower);
     524             :             }
     525             : 
     526           0 :             if ( mePageKind == PK_STANDARD )
     527             :             {
     528           0 :                 SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
     529           0 :                 pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
     530             :             }
     531             : 
     532           0 :             pPage->SetAutoLayout( pPage->GetAutoLayout() );
     533             :         }
     534             :     }
     535             : 
     536           0 :     if ( mePageKind == PK_STANDARD )
     537             :     {
     538           0 :         SdPage* pHandoutPage = GetDoc()->GetSdPage(0, PK_HANDOUT);
     539           0 :         pHandoutPage->CreateTitleAndLayout(true);
     540             :     }
     541             : 
     542           0 :     long nWidth = mpActualPage->GetSize().Width();
     543           0 :     long nHeight = mpActualPage->GetSize().Height();
     544             : 
     545           0 :     Point aPageOrg(nWidth, nHeight / 2);
     546           0 :     Size aSize( nWidth * 3, nHeight * 2);
     547             : 
     548           0 :     InitWindows(aPageOrg, aSize, Point(-1, -1), true);
     549             : 
     550           0 :     Point aVisAreaPos;
     551             : 
     552           0 :     if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
     553             :     {
     554           0 :         aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
     555             :     }
     556             : 
     557           0 :     GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
     558             : 
     559           0 :     UpdateScrollBars();
     560             : 
     561           0 :     Point aNewOrigin(mpActualPage->GetLftBorder(), mpActualPage->GetUppBorder());
     562           0 :     GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin);
     563             : 
     564           0 :     GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
     565             : 
     566             :     // zoom onto (new) page size
     567             :     GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
     568           0 :                         SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
     569           0 : }
     570             : 
     571        1189 : void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
     572             : {
     573             :     /* Zoom-Item
     574             :        Here we should propagate the corresponding value (Optimal ?, page width
     575             :        or page) with the help of the ZoomItems !!!   */
     576        1189 :     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ATTR_ZOOM ) )
     577             :     {
     578         207 :         if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
     579             :         {
     580           0 :             rSet.DisableItem( SID_ATTR_ZOOM );
     581             :         }
     582             :         else
     583             :         {
     584         207 :             boost::scoped_ptr<SvxZoomItem> pZoomItem;
     585         207 :             sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom();
     586             : 
     587         207 :             if( mbZoomOnPage )
     588         207 :                 pZoomItem.reset(new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom ));
     589             :             else
     590           0 :                 pZoomItem.reset(new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom ));
     591             : 
     592             :             // constrain area
     593         207 :             sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
     594         207 :             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
     595             : 
     596         207 :             if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
     597             :                 // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
     598             :             {
     599         163 :                 nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
     600             :             }
     601             : 
     602         207 :             pZoomItem->SetValueSet( nZoomValues );
     603         207 :             rSet.Put( *pZoomItem );
     604             :         }
     605             :     }
     606        1189 :     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
     607             :     {
     608         207 :         rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
     609         207 :         if (GetDocSh()->IsUIActive() || (xSlideshow.is() && xSlideshow->isRunning()) || !GetActiveWindow() )
     610             :         {
     611           0 :             rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
     612             :         }
     613             :         else
     614             :         {
     615         207 :             sd::Window * pActiveWindow = GetActiveWindow();
     616         207 :             SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ;
     617             : 
     618         207 :             SdrPageView* pPageView = mpDrawView->GetSdrPageView();
     619         207 :             if( pPageView )
     620             :             {
     621         207 :                 Point aPagePos(0, 0);
     622         207 :                 Size aPageSize = pPageView->GetPage()->GetSize();
     623             : 
     624         207 :                 aPagePos.X() += aPageSize.Width()  / 2;
     625         207 :                 aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
     626             : 
     627         207 :                 aPagePos.Y() += aPageSize.Height() / 2;
     628         207 :                 aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
     629         207 :                 aPagePos.Y() -= aPageSize.Height() / 2;
     630             : 
     631         207 :                 aPagePos.X() -= aPageSize.Width()  / 2;
     632             : 
     633         207 :                 Rectangle aFullPageZoomRect( aPagePos, aPageSize );
     634         207 :                 aZoomItem.AddSnappingPoint( pActiveWindow->GetZoomForRect( aFullPageZoomRect ) );
     635             :             }
     636         207 :             aZoomItem.AddSnappingPoint(100);
     637         207 :             rSet.Put( aZoomItem );
     638         207 :         }
     639             :     }
     640             : 
     641        1189 :     SdrPageView* pPageView = mpDrawView->GetSdrPageView();
     642        1189 :     if (pPageView)
     643             :     {
     644        1189 :         Point aPos = GetActiveWindow()->PixelToLogic(maMousePos);
     645        1189 :         pPageView->LogicToPagePos(aPos);
     646        1189 :         Fraction aUIScale(GetDoc()->GetUIScale());
     647        1189 :         aPos.X() = Fraction(aPos.X()) / aUIScale;
     648        1189 :         aPos.Y() = Fraction(aPos.Y()) / aUIScale;
     649             : 
     650             :         // position- and size items
     651        1189 :         if ( mpDrawView->IsAction() )
     652             :         {
     653           0 :             Rectangle aRect;
     654           0 :             mpDrawView->TakeActionRect( aRect );
     655             : 
     656           0 :             if ( aRect.IsEmpty() )
     657           0 :                 rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
     658             :             else
     659             :             {
     660           0 :                 pPageView->LogicToPagePos(aRect);
     661           0 :                 aPos = aRect.TopLeft();
     662           0 :                 aPos.X() = Fraction(aPos.X()) / aUIScale;
     663           0 :                 aPos.Y() = Fraction(aPos.Y()) / aUIScale;
     664           0 :                 rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) );
     665           0 :                 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
     666           0 :                 aSize.Height() = Fraction(aSize.Height()) / aUIScale;
     667           0 :                 aSize.Width()  = Fraction(aSize.Width())  / aUIScale;
     668           0 :                 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
     669             :             }
     670             :         }
     671             :         else
     672             :         {
     673        1189 :             if ( mpDrawView->AreObjectsMarked() )
     674             :             {
     675           0 :                 Rectangle aRect = mpDrawView->GetAllMarkedRect();
     676           0 :                 pPageView->LogicToPagePos(aRect);
     677             : 
     678             :                 // Show the position of the selected shape(s)
     679           0 :                 Point aShapePosition (aRect.TopLeft());
     680           0 :                 aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale;
     681           0 :                 aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale;
     682           0 :                 rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition));
     683             : 
     684           0 :                 Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
     685           0 :                 aSize.Height() = Fraction(aSize.Height()) / aUIScale;
     686           0 :                 aSize.Width()  = Fraction(aSize.Width())  / aUIScale;
     687           0 :                 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
     688             :             }
     689             :             else
     690             :             {
     691        1189 :                 rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
     692        1189 :                 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
     693             :             }
     694             :         }
     695             :     }
     696             : 
     697             :     // Display of current page and layer.
     698        1189 :     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_STATUS_PAGE ) )
     699             :     {
     700         209 :         sal_Int32 nPageCount = sal_Int32(GetDoc()->GetSdPageCount(mePageKind));
     701         209 :         sal_Int32 nActivePageCount = sal_Int32(GetDoc()->GetActiveSdPageCount());
     702             :         // Always show the slide/page number.
     703         209 :         OUString aOUString = SD_RESSTR(STR_SD_PAGE);
     704         209 :         aOUString += " ";
     705         209 :         aOUString += OUString::number( maTabControl.GetCurPageId() );
     706         209 :         aOUString += " / " ;
     707         209 :         aOUString += OUString::number( nPageCount );
     708         209 :         if (nPageCount != nActivePageCount)
     709             :         {
     710           0 :             aOUString += " (";
     711           0 :             aOUString += OUString::number( nActivePageCount );
     712           0 :             aOUString += ")";
     713             :         }
     714             : 
     715             :         // If in layer mode additionally show the layer that contains all
     716             :         // selected shapes of the page.  If the shapes are distributed on
     717             :         // more than one layer, no layer name is shown.
     718         209 :         if (IsLayerModeActive())
     719             :         {
     720          13 :             SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
     721          13 :             SdrLayerID nLayer = 0, nOldLayer = 0;
     722          13 :             SdrObject* pObj = NULL;
     723          13 :             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
     724          13 :             const size_t nMarkCount = rMarkList.GetMarkCount();
     725          13 :             bool bOneLayer = true;
     726             : 
     727             :             // Use the first ten selected shapes as a (hopefully
     728             :             // representative) sample of all shapes of the current page.
     729             :             // Detect whether they belong to the same layer.
     730          13 :             for( size_t j = 0; j < nMarkCount && bOneLayer && j < 10; ++j )
     731             :             {
     732           0 :                 pObj = rMarkList.GetMark( j )->GetMarkedSdrObj();
     733           0 :                 if( pObj )
     734             :                 {
     735           0 :                     nLayer = pObj->GetLayer();
     736             : 
     737           0 :                     if( j != 0 && nLayer != nOldLayer )
     738           0 :                         bOneLayer = false;
     739             : 
     740           0 :                     nOldLayer = nLayer;
     741             :                 }
     742             :             }
     743             : 
     744             :             // Append the layer name to the current page number.
     745          13 :             if( bOneLayer && nMarkCount )
     746             :             {
     747           0 :                 SdrLayer* pLayer = rLayerAdmin.GetLayerPerID( nLayer );
     748           0 :                 if( pLayer )
     749             :                 {
     750           0 :                     aOUString += " (" ;
     751           0 :                     aOUString += pLayer->GetName();
     752           0 :                     aOUString += ")";
     753             :                 }
     754             :             }
     755             :         }
     756             : 
     757         209 :         rSet.Put (SfxStringItem (SID_STATUS_PAGE, aOUString));
     758             :     }
     759             :     // Layout
     760        1189 :     if( SfxItemState::DEFAULT == rSet.GetItemState( SID_STATUS_LAYOUT ) )
     761             :     {
     762         209 :         OUString aString = mpActualPage->GetLayoutName();
     763         209 :         sal_Int32 nPos = aString.indexOf(SD_LT_SEPARATOR);
     764         209 :         if (nPos != -1)
     765         209 :             aString = aString.copy(0, nPos);
     766         209 :         rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) );
     767             :     }
     768        1189 : }
     769             : 
     770       80232 : void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint)
     771             : {
     772       80232 :     const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* >(&rHint);
     773       80232 :     if (pSimple!=NULL && pSimple->GetId()==SFX_HINT_MODECHANGED)
     774             :     {
     775             :         // Change to selection when turning on read-only mode.
     776           4 :         if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) )
     777             :         {
     778           0 :             SfxRequest aReq(SID_OBJECT_SELECT, SfxCallMode::SLOT, GetDoc()->GetItemPool());
     779           0 :             FuPermanent(aReq);
     780             :         }
     781             : 
     782             :         // Turn on design mode when document is not read-only.
     783           4 :         if (GetDocSh()->IsReadOnly() != mbReadOnly )
     784             :         {
     785           0 :             mbReadOnly = GetDocSh()->IsReadOnly();
     786             : 
     787           0 :             SfxBoolItem aItem( SID_FM_DESIGN_MODE, !mbReadOnly );
     788             :             GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE,
     789           0 :                 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
     790             :         }
     791             :     }
     792             : 
     793       80232 : }
     794             : 
     795           0 : void DrawViewShell::ExecuteAnnotation (SfxRequest& rRequest)
     796             : {
     797           0 :     if( mpAnnotationManager.get() )
     798           0 :         mpAnnotationManager->ExecuteAnnotation( rRequest );
     799           0 : }
     800             : 
     801           0 : void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet )
     802             : {
     803           0 :     if( mpAnnotationManager.get() )
     804           0 :         mpAnnotationManager->GetAnnotationState( rItemSet );
     805           0 : }
     806             : 
     807        1464 : ::rtl::OUString DrawViewShell::GetSidebarContextName (void) const
     808             : {
     809        1464 :     ::svx::sidebar::SelectionAnalyzer::ViewType eViewType (::svx::sidebar::SelectionAnalyzer::VT_Standard);
     810        1464 :     switch (mePageKind)
     811             :     {
     812             :         case PK_HANDOUT:
     813           0 :             eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Handout;
     814           0 :             break;
     815             :         case PK_NOTES:
     816           0 :             eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Notes;
     817           0 :             break;
     818             :         case PK_STANDARD:
     819        1464 :             if (meEditMode == EM_MASTERPAGE)
     820           0 :                 eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Master;
     821             :             else
     822        1464 :                 eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Standard;
     823        1464 :             break;
     824             :     }
     825             :     return EnumContext::GetContextName(
     826             :         ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SD(
     827        1464 :             mpDrawView->GetMarkedObjectList(),
     828        1464 :             eViewType));
     829             : }
     830             : 
     831         114 : } // end of namespace sd
     832             : 
     833             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10