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

Generated by: LCOV version 1.10