LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/view - viewshe2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 142 472 30.1 %
Date: 2013-07-09 Functions: 17 41 41.5 %
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 <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      21             : #include <com/sun/star/beans/XPropertySet.hpp>
      22             : #include <com/sun/star/chart2/XChartDocument.hpp>
      23             : #include <com/sun/star/drawing/FillStyle.hpp>
      24             : #include <com/sun/star/drawing/LineStyle.hpp>
      25             : 
      26             : #include "ViewShell.hxx"
      27             : #include "ViewShellHint.hxx"
      28             : 
      29             : #include "ViewShellImplementation.hxx"
      30             : #include "FactoryIds.hxx"
      31             : 
      32             : #include <svx/svxids.hrc>
      33             : #include <vcl/scrbar.hxx>
      34             : #include <svx/svdpagv.hxx>
      35             : #include <sfx2/dispatch.hxx>
      36             : #include <sfx2/app.hxx>
      37             : #include <svx/ruler.hxx>
      38             : #include <editeng/outliner.hxx>
      39             : #include <svtools/ehdl.hxx>
      40             : #include <svx/svdoole2.hxx>
      41             : #include <svtools/sfxecode.hxx>
      42             : #include <svx/fmshell.hxx>
      43             : #include <rtl/ustrbuf.hxx>
      44             : #include <unotools/moduleoptions.hxx>
      45             : #include <svx/dialogs.hrc>
      46             : #include <comphelper/classids.hxx>
      47             : 
      48             : #include "strings.hrc"
      49             : #include "app.hrc"
      50             : #include "unokywds.hxx"
      51             : 
      52             : #include "sdundogr.hxx"
      53             : #include "FrameView.hxx"
      54             : #include "undopage.hxx"
      55             : #include "sdresid.hxx"
      56             : #include "drawdoc.hxx"
      57             : #include "View.hxx"
      58             : #include "fupoor.hxx"
      59             : #include "Client.hxx"
      60             : #include "DrawDocShell.hxx"
      61             : #include "fusearch.hxx"
      62             : #include "slideshow.hxx"
      63             : #include "sdpage.hxx"
      64             : #include "DrawViewShell.hxx"
      65             : #include "ViewShellBase.hxx"
      66             : 
      67             : #include "Window.hxx"
      68             : 
      69             : #include <sfx2/viewfrm.hxx>
      70             : #include <svtools/soerr.hxx>
      71             : #include <toolkit/helper/vclunohelper.hxx>
      72             : #include <svx/charthelper.hxx>
      73             : 
      74             : using namespace com::sun::star;
      75             : 
      76             : namespace sd {
      77             : 
      78          11 : const String aEmptyStr;
      79             : 
      80             : /**
      81             :  * adjust Thumbpos and VisibleSize
      82             :  */
      83         462 : void ViewShell::UpdateScrollBars()
      84             : {
      85         462 :     if (mpHorizontalScrollBar.get() != NULL)
      86             :     {
      87         448 :         long nW = (long)(mpContentWindow->GetVisibleWidth() * 32000);
      88         448 :         long nX = (long)(mpContentWindow->GetVisibleX() * 32000);
      89         448 :         mpHorizontalScrollBar->SetVisibleSize(nW);
      90         448 :         mpHorizontalScrollBar->SetThumbPos(nX);
      91         448 :         nW = 32000 - nW;
      92         448 :         long nLine = (long) (mpContentWindow->GetScrlLineWidth() * nW);
      93         448 :         long nPage = (long) (mpContentWindow->GetScrlPageWidth() * nW);
      94         448 :         mpHorizontalScrollBar->SetLineSize(nLine);
      95         448 :         mpHorizontalScrollBar->SetPageSize(nPage);
      96             :     }
      97             : 
      98         462 :     if (mpVerticalScrollBar.get() != NULL)
      99             :     {
     100         448 :         long nH = (long)(mpContentWindow->GetVisibleHeight() * 32000);
     101         448 :         long nY = (long)(mpContentWindow->GetVisibleY() * 32000);
     102             : 
     103         448 :         if(IsPageFlipMode()) // ie in zoom mode where no panning
     104             :         {
     105           0 :             SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
     106           0 :             sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) / 2;
     107           0 :             sal_uInt16 nTotalPages = GetDoc()->GetSdPageCount(pPage->GetPageKind());
     108           0 :             mpVerticalScrollBar->SetRange(Range(0,256*nTotalPages));
     109           0 :             mpVerticalScrollBar->SetVisibleSize(256);
     110           0 :             mpVerticalScrollBar->SetThumbPos(256*nCurPage);
     111           0 :             mpVerticalScrollBar->SetLineSize(256);
     112           0 :             mpVerticalScrollBar->SetPageSize(256);
     113             :         }
     114             :         else
     115             :         {
     116         448 :             mpVerticalScrollBar->SetRange(Range(0,32000));
     117         448 :             mpVerticalScrollBar->SetVisibleSize(nH);
     118         448 :             mpVerticalScrollBar->SetThumbPos(nY);
     119         448 :             nH = 32000 - nH;
     120         448 :             long nLine = (long) (mpContentWindow->GetScrlLineHeight() * nH);
     121         448 :             long nPage = (long) (mpContentWindow->GetScrlPageHeight() * nH);
     122         448 :             mpVerticalScrollBar->SetLineSize(nLine);
     123         448 :             mpVerticalScrollBar->SetPageSize(nPage);
     124             :         }
     125             :     }
     126             : 
     127         462 :     if (mbHasRulers)
     128             :     {
     129         330 :         UpdateHRuler();
     130         330 :         UpdateVRuler();
     131             :     }
     132             : 
     133         462 : }
     134             : /**
     135             :  * Handling for horizontal Scrollbars
     136             :  */
     137           2 : IMPL_LINK_INLINE_START(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
     138             : {
     139           2 :     return VirtHScrollHdl(pHScroll);
     140             : }
     141           2 : IMPL_LINK_INLINE_END(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
     142             : 
     143             : /**
     144             :  * virtual scroll handler for horizontal Scrollbars
     145             :  */
     146           2 : long ViewShell::VirtHScrollHdl(ScrollBar* pHScroll)
     147             : {
     148           2 :     long nDelta = pHScroll->GetDelta();
     149             : 
     150           2 :     if (nDelta != 0)
     151             :     {
     152           2 :         double fX = (double) pHScroll->GetThumbPos() / pHScroll->GetRange().Len();
     153             : 
     154             :         // scroll all windows of the column
     155           2 :         ::sd::View* pView = GetView();
     156           2 :         OutlinerView* pOLV = NULL;
     157             : 
     158           2 :         if (pView)
     159           2 :             pOLV = pView->GetTextEditOutlinerView();
     160             : 
     161           2 :         if (pOLV)
     162           0 :             pOLV->HideCursor();
     163             : 
     164           2 :         mpContentWindow->SetVisibleXY(fX, -1);
     165             : 
     166           2 :         Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
     167           2 :         Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
     168           2 :         aVisArea.SetPos(aVisAreaPos);
     169           2 :         GetDocSh()->SetVisArea(aVisArea);
     170             : 
     171           2 :         Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
     172           2 :         Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
     173           2 :         VisAreaChanged(aVisAreaWin);
     174             : 
     175           2 :         if (pView)
     176             :         {
     177           2 :             pView->VisAreaChanged(GetActiveWindow());
     178             :         }
     179             : 
     180           2 :         if (pOLV)
     181           0 :             pOLV->ShowCursor();
     182             : 
     183           2 :         if (mbHasRulers)
     184           2 :             UpdateHRuler();
     185             : 
     186             :     }
     187             : 
     188           2 :     return 0;
     189             : }
     190             : 
     191             : /**
     192             :  * handling for vertical Scrollbars
     193             :  */
     194           0 : IMPL_LINK_INLINE_START(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
     195             : {
     196           0 :     return VirtVScrollHdl(pVScroll);
     197             : }
     198           0 : IMPL_LINK_INLINE_END(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
     199             : 
     200             : /**
     201             :  * handling for vertical Scrollbars
     202             :  */
     203           0 : long ViewShell::VirtVScrollHdl(ScrollBar* pVScroll)
     204             : {
     205           0 :     if(IsPageFlipMode())
     206             :     {
     207           0 :         SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
     208           0 :         sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) >> 1;
     209           0 :         sal_uInt16 nNewPage = (sal_uInt16)pVScroll->GetThumbPos()/256;
     210           0 :         if( nCurPage != nNewPage )
     211           0 :             static_cast<DrawViewShell*>(this)->SwitchPage(nNewPage);
     212             :     }
     213             :     else //panning mode
     214             :     {
     215           0 :         double fY = (double) pVScroll->GetThumbPos() / pVScroll->GetRange().Len();
     216             : 
     217           0 :         ::sd::View* pView = GetView();
     218           0 :         OutlinerView* pOLV = NULL;
     219             : 
     220           0 :         if (pView)
     221           0 :             pOLV = pView->GetTextEditOutlinerView();
     222             : 
     223           0 :         if (pOLV)
     224           0 :             pOLV->HideCursor();
     225             : 
     226           0 :         mpContentWindow->SetVisibleXY(-1, fY);
     227             : 
     228           0 :         Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
     229           0 :         Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
     230           0 :         aVisArea.SetPos(aVisAreaPos);
     231           0 :         GetDocSh()->SetVisArea(aVisArea);
     232             : 
     233           0 :         Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
     234           0 :         Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
     235           0 :         VisAreaChanged(aVisAreaWin);
     236             : 
     237           0 :         if (pView)
     238             :         {
     239           0 :             pView->VisAreaChanged(GetActiveWindow());
     240             :         }
     241             : 
     242           0 :         if (pOLV)
     243           0 :             pOLV->ShowCursor();
     244             : 
     245           0 :         if (mbHasRulers)
     246           0 :             UpdateVRuler();
     247             : 
     248             :     }
     249             : 
     250           0 :     return 0;
     251             : }
     252             : 
     253           0 : SvxRuler* ViewShell::CreateHRuler(::sd::Window* , sal_Bool )
     254             : {
     255           0 :     return NULL;
     256             : }
     257             : 
     258           0 : SvxRuler* ViewShell::CreateVRuler(::sd::Window* )
     259             : {
     260           0 :     return NULL;
     261             : }
     262             : 
     263           0 : void ViewShell::UpdateHRuler()
     264             : {
     265           0 : }
     266             : 
     267           0 : void ViewShell::UpdateVRuler()
     268             : {
     269           0 : }
     270             : 
     271             : /**
     272             :  * Scroll a specific number of lines. Is used in the automatic scrolling
     273             :  * (character/drag).
     274             :  */
     275           0 : void ViewShell::ScrollLines(long nLinesX, long nLinesY)
     276             : {
     277           0 :     if ( nLinesX )
     278             :     {
     279           0 :         nLinesX *= mpHorizontalScrollBar->GetLineSize();
     280             :     }
     281           0 :     if ( nLinesY )
     282             :     {
     283           0 :         nLinesY *= mpVerticalScrollBar->GetLineSize();
     284             :     }
     285             : 
     286           0 :     Scroll(nLinesX, nLinesY);
     287           0 : }
     288             : 
     289           0 : void ViewShell::Scroll(long nScrollX, long nScrollY)
     290             : {
     291           0 :     if (nScrollX)
     292             :     {
     293           0 :         long nNewThumb = mpHorizontalScrollBar->GetThumbPos() + nScrollX;
     294           0 :         mpHorizontalScrollBar->SetThumbPos(nNewThumb);
     295             :     }
     296           0 :     if (nScrollY)
     297             :     {
     298           0 :         long nNewThumb = mpVerticalScrollBar->GetThumbPos() + nScrollY;
     299           0 :         mpVerticalScrollBar->SetThumbPos(nNewThumb);
     300             :     }
     301           0 :     double  fX = (double) mpHorizontalScrollBar->GetThumbPos() /
     302           0 :                             mpHorizontalScrollBar->GetRange().Len();
     303           0 :     double  fY = (double) mpVerticalScrollBar->GetThumbPos() /
     304           0 :                             mpVerticalScrollBar->GetRange().Len();
     305             : 
     306           0 :     GetActiveWindow()->SetVisibleXY(fX, fY);
     307             : 
     308           0 :     Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
     309           0 :     Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
     310           0 :     aVisArea.SetPos(aVisAreaPos);
     311           0 :     GetDocSh()->SetVisArea(aVisArea);
     312             : 
     313           0 :     Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
     314           0 :     Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
     315           0 :     VisAreaChanged(aVisAreaWin);
     316             : 
     317           0 :     ::sd::View* pView = GetView();
     318           0 :     if (pView)
     319             :     {
     320           0 :         pView->VisAreaChanged(GetActiveWindow());
     321             :     }
     322             : 
     323           0 :     if (mbHasRulers)
     324             :     {
     325           0 :         UpdateHRuler();
     326           0 :         UpdateVRuler();
     327             :     }
     328           0 : }
     329             : 
     330             : /**
     331             :  * Set zoom factor for all split windows.
     332             :  */
     333           0 : void ViewShell::SetZoom(long nZoom)
     334             : {
     335           0 :     Fraction aUIScale(nZoom, 100);
     336           0 :     aUIScale *= GetDoc()->GetUIScale();
     337             : 
     338           0 :     if (mpHorizontalRuler.get() != NULL)
     339           0 :         mpHorizontalRuler->SetZoom(aUIScale);
     340             : 
     341           0 :     if (mpVerticalRuler.get() != NULL)
     342           0 :         mpVerticalRuler->SetZoom(aUIScale);
     343             : 
     344           0 :     if (mpContentWindow.get() != NULL)
     345             :     {
     346           0 :         mpContentWindow->SetZoomIntegral(nZoom);
     347             : 
     348             :         // #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
     349             :         // of the window. It needs - like Scroll(SCROLL_CHILDREN) does - also to move
     350             :         // the child windows. I am trying INVALIDATE_CHILDREN here which makes things better,
     351             :         // but does not solve the problem completely. Neet to ask PL.
     352           0 :         mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
     353             :     }
     354             : 
     355           0 :     Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
     356           0 :     Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
     357           0 :     VisAreaChanged(aVisAreaWin);
     358             : 
     359           0 :     ::sd::View* pView = GetView();
     360           0 :     if (pView)
     361             :     {
     362           0 :         pView->VisAreaChanged(GetActiveWindow());
     363             :     }
     364             : 
     365           0 :     UpdateScrollBars();
     366           0 : }
     367             : 
     368             : /**
     369             :  * Set zoom rectangle for active window. Sets all split windows to the same zoom
     370             :  * factor.
     371             :  */
     372         215 : void ViewShell::SetZoomRect(const Rectangle& rZoomRect)
     373             : {
     374         215 :     long nZoom = GetActiveWindow()->SetZoomRect(rZoomRect);
     375         215 :     Fraction aUIScale(nZoom, 100);
     376         215 :     aUIScale *= GetDoc()->GetUIScale();
     377             : 
     378         215 :     Point aPos = GetActiveWindow()->GetWinViewPos();
     379             : 
     380         215 :     if (mpHorizontalRuler.get() != NULL)
     381         156 :         mpHorizontalRuler->SetZoom(aUIScale);
     382             : 
     383         215 :     if (mpVerticalRuler.get() != NULL)
     384         156 :         mpVerticalRuler->SetZoom(aUIScale);
     385             : 
     386         215 :     if (mpContentWindow.get() != NULL)
     387             :     {
     388         215 :         Point aNewPos = mpContentWindow->GetWinViewPos();
     389         215 :         aNewPos.X() = aPos.X();
     390         215 :         aNewPos.Y() = aPos.Y();
     391         215 :         mpContentWindow->SetZoomIntegral(nZoom);
     392         215 :         mpContentWindow->SetWinViewPos(aNewPos);
     393         215 :         mpContentWindow->UpdateMapOrigin();
     394             : 
     395             :         // #i74769# see above
     396         215 :         mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
     397             :     }
     398             : 
     399         215 :     Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
     400         215 :     Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
     401         215 :     VisAreaChanged(aVisAreaWin);
     402             : 
     403         215 :     ::sd::View* pView = GetView();
     404         215 :     if (pView)
     405             :     {
     406         215 :         pView->VisAreaChanged(GetActiveWindow());
     407             :     }
     408             : 
     409         215 :     UpdateScrollBars();
     410         215 : }
     411             : 
     412             : /**
     413             :  * Initialize imaging parameters for all split windows.
     414             :  */
     415          83 : void ViewShell::InitWindows(const Point& rViewOrigin, const Size& rViewSize,
     416             :                               const Point& rWinPos, sal_Bool bUpdate)
     417             : {
     418          83 :     if (mpContentWindow.get() != NULL)
     419             :     {
     420          83 :         mpContentWindow->SetViewOrigin(rViewOrigin);
     421          83 :         mpContentWindow->SetViewSize(rViewSize);
     422          83 :         mpContentWindow->SetWinViewPos(rWinPos);
     423             : 
     424          83 :         if ( bUpdate )
     425             :         {
     426          18 :             mpContentWindow->UpdateMapOrigin();
     427          18 :             mpContentWindow->Invalidate();
     428             :         }
     429             :     }
     430             : 
     431          83 :     Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
     432          83 :     Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
     433          83 :     VisAreaChanged(aVisAreaWin);
     434             : 
     435          83 :     ::sd::View* pView = GetView();
     436          83 :     if (pView)
     437             :     {
     438          83 :         pView->VisAreaChanged(GetActiveWindow());
     439             :     }
     440          83 : }
     441             : 
     442             : /**
     443             :  * Invalidate all split windows below the ?provided rectangle.
     444             :  */
     445          66 : void ViewShell::InvalidateWindows()
     446             : {
     447          66 :     if (mpContentWindow.get() != NULL)
     448          66 :         mpContentWindow->Invalidate();
     449          66 : }
     450             : 
     451             : 
     452             : /**
     453             :  * Draw a selection rectangle with the ?provided pen on all split windows.
     454             :  */
     455           0 : void ViewShell::DrawMarkRect(const Rectangle& rRect) const
     456             : {
     457           0 :     if (mpContentWindow.get() != NULL)
     458             :     {
     459           0 :         mpContentWindow->InvertTracking(rRect, SHOWTRACK_OBJECT | SHOWTRACK_WINDOW);
     460             :     }
     461           0 : }
     462             : 
     463           0 : void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize,
     464             :                                        long nLeft, long nRight,
     465             :                                        long nUpper, long nLower, sal_Bool bScaleAll,
     466             :                                        Orientation eOrientation, sal_uInt16 nPaperBin,
     467             :                                        sal_Bool bBackgroundFullSize)
     468             : {
     469           0 :     SdPage* pPage = 0;
     470           0 :     SdUndoGroup* pUndoGroup = NULL;
     471           0 :     pUndoGroup = new SdUndoGroup(GetDoc());
     472           0 :     String aString(SdResId(STR_UNDO_CHANGE_PAGEFORMAT));
     473           0 :     pUndoGroup->SetComment(aString);
     474           0 :     SfxViewShell* pViewShell = GetViewShell();
     475             :     OSL_ASSERT (pViewShell!=NULL);
     476             : 
     477           0 :     sal_uInt16 i, nPageCnt = GetDoc()->GetMasterSdPageCount(ePageKind);
     478             : 
     479           0 :     Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START));
     480             : 
     481           0 :     for (i = 0; i < nPageCnt; i++)
     482             :     {
     483             :         // first, handle all master pages
     484           0 :         pPage = GetDoc()->GetMasterSdPage(i, ePageKind);
     485             : 
     486             :         SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
     487           0 :                             pPage->GetSize(),
     488           0 :                             pPage->GetLftBorder(), pPage->GetRgtBorder(),
     489           0 :                             pPage->GetUppBorder(), pPage->GetLwrBorder(),
     490           0 :                             pPage->GetOrientation(),
     491           0 :                             pPage->GetPaperBin(),
     492           0 :                             pPage->IsBackgroundFullSize(),
     493             :                             rNewSize,
     494             :                             nLeft, nRight,
     495             :                             nUpper, nLower,
     496             :                             bScaleAll,
     497             :                             eOrientation,
     498             :                             nPaperBin,
     499           0 :                             bBackgroundFullSize);
     500           0 :         pUndoGroup->AddAction(pUndo);
     501             : 
     502           0 :         if (rNewSize.Width() > 0 ||
     503           0 :             nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
     504             :         {
     505           0 :             Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
     506           0 :             pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
     507             : 
     508           0 :             if (rNewSize.Width() > 0)
     509           0 :                 pPage->SetSize(rNewSize);
     510             :         }
     511             : 
     512           0 :         if( nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
     513             :         {
     514           0 :             pPage->SetBorder(nLeft, nUpper, nRight, nLower);
     515             :         }
     516             : 
     517           0 :         pPage->SetOrientation(eOrientation);
     518           0 :         pPage->SetPaperBin( nPaperBin );
     519           0 :         pPage->SetBackgroundFullSize( bBackgroundFullSize );
     520             : 
     521           0 :         if ( ePageKind == PK_STANDARD )
     522           0 :             GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
     523             : 
     524           0 :         pPage->CreateTitleAndLayout();
     525             :     }
     526             : 
     527           0 :     nPageCnt = GetDoc()->GetSdPageCount(ePageKind);
     528             : 
     529           0 :     for (i = 0; i < nPageCnt; i++)
     530             :     {
     531             :         // then, handle all pages
     532           0 :         pPage = GetDoc()->GetSdPage(i, ePageKind);
     533             : 
     534             :         SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
     535           0 :                                 pPage->GetSize(),
     536           0 :                                 pPage->GetLftBorder(), pPage->GetRgtBorder(),
     537           0 :                                 pPage->GetUppBorder(), pPage->GetLwrBorder(),
     538           0 :                                 pPage->GetOrientation(),
     539           0 :                                 pPage->GetPaperBin(),
     540           0 :                                 pPage->IsBackgroundFullSize(),
     541             :                                 rNewSize,
     542             :                                 nLeft, nRight,
     543             :                                 nUpper, nLower,
     544             :                                 bScaleAll,
     545             :                                 eOrientation,
     546             :                                 nPaperBin,
     547           0 :                                 bBackgroundFullSize);
     548           0 :         pUndoGroup->AddAction(pUndo);
     549             : 
     550           0 :         if (rNewSize.Width() > 0 ||
     551           0 :             nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
     552             :         {
     553           0 :             Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
     554           0 :             pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
     555             : 
     556           0 :             if (rNewSize.Width() > 0)
     557           0 :                 pPage->SetSize(rNewSize);
     558             :         }
     559             : 
     560           0 :         if( nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
     561             :         {
     562           0 :             pPage->SetBorder(nLeft, nUpper, nRight, nLower);
     563             :         }
     564             : 
     565           0 :         pPage->SetOrientation(eOrientation);
     566           0 :         pPage->SetPaperBin( nPaperBin );
     567           0 :         pPage->SetBackgroundFullSize( bBackgroundFullSize );
     568             : 
     569           0 :         if ( ePageKind == PK_STANDARD )
     570             :         {
     571           0 :             SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
     572           0 :             pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
     573             :         }
     574             : 
     575           0 :         pPage->SetAutoLayout( pPage->GetAutoLayout() );
     576             :     }
     577             : 
     578             :     // adjust handout page to new format of the standard page
     579           0 :     if( (ePageKind == PK_STANDARD) || (ePageKind == PK_HANDOUT) )
     580           0 :         GetDoc()->GetSdPage(0, PK_HANDOUT)->CreateTitleAndLayout(sal_True);
     581             : 
     582             :     // handed over undo group to undo manager
     583           0 :     pViewShell->GetViewFrame()->GetObjectShell()
     584           0 :         ->GetUndoManager()->AddUndoAction(pUndoGroup);
     585             : 
     586           0 :     long nWidth = pPage->GetSize().Width();
     587           0 :     long nHeight = pPage->GetSize().Height();
     588             : 
     589           0 :     Point aPageOrg = Point(nWidth, nHeight / 2);
     590           0 :     Size aViewSize = Size(nWidth * 3, nHeight * 2);
     591             : 
     592           0 :     InitWindows(aPageOrg, aViewSize, Point(-1, -1), sal_True);
     593             : 
     594           0 :     Point aVisAreaPos;
     595             : 
     596           0 :     if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
     597             :     {
     598           0 :         aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
     599             :     }
     600             : 
     601           0 :     ::sd::View* pView = GetView();
     602           0 :     if (pView)
     603             :     {
     604           0 :         pView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aViewSize));
     605             :     }
     606             : 
     607           0 :     UpdateScrollBars();
     608             : 
     609           0 :     Point aNewOrigin(pPage->GetLftBorder(), pPage->GetUppBorder());
     610             : 
     611           0 :     if (pView)
     612             :     {
     613           0 :         pView->GetSdrPageView()->SetPageOrigin(aNewOrigin);
     614             :     }
     615             : 
     616           0 :     pViewShell->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
     617             : 
     618             :     // zoom onto (new) page size
     619             :     pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
     620           0 :             SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     621             : 
     622           0 :     Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END));
     623           0 : }
     624             : 
     625             : /**
     626             :  * Set zoom factor for InPlace
     627             :  */
     628           0 : void ViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction&)
     629             : {
     630           0 :     long nZoom = (long)((double) rZoomX * 100);
     631           0 :     SetZoom(nZoom);
     632           0 : }
     633             : 
     634             : 
     635             : 
     636         519 : void ViewShell::SetActiveWindow (::sd::Window* pWin)
     637             : {
     638         519 :     SfxViewShell* pViewShell = GetViewShell();
     639             :     OSL_ASSERT (pViewShell!=NULL);
     640             : 
     641         519 :     if (pViewShell->GetWindow() != pWin)
     642             :     {
     643             :         // #i31551# was wrong, it may have been a problem with the repaint at that time.
     644             :         // For transparent form controls, it is necessary to have that flag set, all apps
     645             :         // do set it. Enabling again.
     646         519 :         if (pWin)
     647             :         {
     648         519 :             pWin->EnableChildTransparentMode();
     649             :         }
     650             :     }
     651             : 
     652         519 :     if (mpActiveWindow != pWin)
     653         143 :         mpActiveWindow = pWin;
     654             : 
     655             :     // The rest of this function is not guarded anymore against calling this
     656             :     // method with an already active window because the functions may still
     657             :     // point to the old window when the new one has already been assigned to
     658             :     // pWindow elsewhere.
     659         519 :     ::sd::View* pView = GetView();
     660         519 :     if (pView)
     661             :     {
     662         376 :         pView->SetActualWin(pWin);
     663             :     }
     664         519 :     if(HasCurrentFunction())
     665             :     {
     666         376 :         GetCurrentFunction()->SetWindow(pWin);
     667             :     }
     668         519 : }
     669             : 
     670             : 
     671             : 
     672           0 : sal_Bool ViewShell::RequestHelp(const HelpEvent& rHEvt, ::sd::Window*)
     673             : {
     674           0 :     sal_Bool bReturn = sal_False;
     675             : 
     676           0 :     if (rHEvt.GetMode())
     677             :     {
     678           0 :         if( GetView() )
     679           0 :             bReturn = GetView()->getSmartTags().RequestHelp(rHEvt);
     680             : 
     681           0 :         if(!bReturn && HasCurrentFunction())
     682             :         {
     683           0 :             bReturn = GetCurrentFunction()->RequestHelp(rHEvt);
     684             :         }
     685             :     }
     686             : 
     687           0 :     return(bReturn);
     688             : }
     689             : 
     690             : 
     691             : 
     692             : 
     693         286 : FrameView* ViewShell::GetFrameView (void)
     694             : {
     695         286 :     return mpFrameView;
     696             : }
     697             : 
     698             : 
     699             : 
     700             : 
     701           0 : void ViewShell::SetFrameView (FrameView* pNewFrameView)
     702             : {
     703           0 :     mpFrameView = pNewFrameView;
     704           0 :     ReadFrameViewData (mpFrameView);
     705           0 : }
     706             : 
     707             : 
     708             : 
     709             : 
     710             : /*************************************************************************
     711             : |*
     712             : |* Read FrameViews data and set actual views data
     713             : |*
     714             : \************************************************************************/
     715             : 
     716          13 : void ViewShell::ReadFrameViewData(FrameView*)
     717             : {
     718          13 : }
     719             : 
     720             : 
     721             : 
     722             : /*************************************************************************
     723             : |*
     724             : |* Write actual views data to FrameView
     725             : |*
     726             : \************************************************************************/
     727             : 
     728          39 : void ViewShell::WriteFrameViewData()
     729             : {
     730          39 : }
     731             : 
     732             : 
     733           0 : sal_Bool ViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
     734             : {
     735           0 :     ErrCode aErrCode = 0;
     736             : 
     737           0 :     SfxErrorContext aEC(ERRCTX_SO_DOVERB, GetActiveWindow(), RID_SO_ERRCTX);
     738           0 :     sal_Bool bAbort = sal_False;
     739           0 :     GetDocSh()->SetWaitCursor( sal_True );
     740           0 :     SfxViewShell* pViewShell = GetViewShell();
     741             :     OSL_ASSERT (pViewShell!=NULL);
     742           0 :     bool bChangeDefaultsForChart = false;
     743           0 :     OUString aName;
     744             : 
     745           0 :     uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
     746           0 :     if ( !xObj.is() )
     747             :     {
     748             :         // provide OLE object to empty OLE object
     749           0 :         aName = pObj->GetProgName();
     750           0 :         OUString aObjName;
     751           0 :         SvGlobalName aClass;
     752             : 
     753           0 :         if( aName == "StarChart"  || aName == "StarOrg" )
     754             :         {
     755           0 :             if( SvtModuleOptions().IsChart() )
     756             :             {
     757           0 :                 aClass = SvGlobalName( SO3_SCH_CLASSID );
     758           0 :                 bChangeDefaultsForChart = true;
     759             :             }
     760             :         }
     761           0 :         else if( aName == "StarCalc" )
     762             :         {
     763           0 :             if( SvtModuleOptions().IsCalc() )
     764           0 :                 aClass = SvGlobalName( SO3_SC_CLASSID );
     765             :         }
     766           0 :         else if( aName == "StarMath" )
     767             :         {
     768           0 :             if( SvtModuleOptions().IsMath() )
     769           0 :                 aClass = SvGlobalName( SO3_SM_CLASSID );
     770             :         }
     771             : 
     772           0 :         if ( aClass != SvGlobalName() )
     773           0 :             xObj = GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass.GetByteSequence(), aObjName );
     774             : 
     775           0 :         if( !xObj.is() )
     776             :         {
     777           0 :             aName = "";
     778             : 
     779             :             // call dialog "insert OLE object"
     780           0 :             GetDocSh()->SetWaitCursor( sal_False );
     781             :             pViewShell->GetViewFrame()->GetDispatcher()->Execute(
     782             :                 SID_INSERT_OBJECT,
     783           0 :                 SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
     784           0 :             xObj = pObj->GetObjRef();
     785           0 :             GetDocSh()->SetWaitCursor( sal_True );
     786             : 
     787           0 :             if (!xObj.is())
     788             :             {
     789           0 :                 bAbort = sal_True;
     790             :             }
     791             :         }
     792             : 
     793           0 :         if ( xObj.is() )
     794             :         {
     795             :             // OLE object is no longer empty
     796           0 :             pObj->SetEmptyPresObj(sal_False);
     797           0 :             pObj->SetOutlinerParaObject(NULL);
     798           0 :             pObj->SetGraphic(NULL);
     799             : 
     800             :             // the empty OLE object gets a new IPObj
     801           0 :             if (!aName.isEmpty())
     802             :             {
     803           0 :                 pObj->SetObjRef(xObj);
     804           0 :                 pObj->SetName(aObjName);
     805           0 :                 pObj->SetPersistName(aObjName);
     806             :             }
     807             :             else
     808             :             {
     809             :                 // insertion was done by the dialog
     810           0 :                 pObj->SetObjRef(xObj);
     811             :             }
     812             : 
     813           0 :             Rectangle aRect = pObj->GetLogicRect();
     814             : 
     815           0 :             if ( pObj->GetAspect() != embed::Aspects::MSOLE_ICON )
     816             :             {
     817           0 :                 awt::Size aSz;
     818           0 :                 aSz.Width = aRect.GetWidth();
     819           0 :                 aSz.Height = aRect.GetHeight();
     820           0 :                 xObj->setVisualAreaSize( pObj->GetAspect(), aSz );
     821             :             }
     822             : 
     823           0 :             GetViewShellBase().SetVerbs( xObj->getSupportedVerbs() );
     824             : 
     825           0 :             nVerb = SVVERB_SHOW;
     826             :         }
     827             :         else
     828             :         {
     829           0 :             aErrCode = ERRCODE_SFX_OLEGENERAL;
     830           0 :         }
     831             :     }
     832             : 
     833           0 :     if( aErrCode == 0 )
     834             :     {
     835           0 :         ::sd::View* pView = GetView();
     836             : 
     837           0 :         if (pView->IsTextEdit())
     838             :         {
     839           0 :             pView->SdrEndTextEdit();
     840             :         }
     841             : 
     842             :         SfxInPlaceClient* pSdClient =
     843             :             static_cast<Client*>(pViewShell->FindIPClient(
     844           0 :                 pObj->GetObjRef(), GetActiveWindow()));
     845             : 
     846           0 :         if ( !pSdClient )
     847             :         {
     848           0 :             pSdClient = new Client(pObj, this, GetActiveWindow());
     849             :         }
     850             : 
     851           0 :         Rectangle aRect = pObj->GetLogicRect();
     852             : 
     853             :         {
     854             :             // #i118485# center on BoundRect for activation,
     855             :             // OLE may be sheared/rotated now
     856           0 :             const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
     857           0 :             const Point aDelta(rBoundRect.Center() - aRect.Center());
     858           0 :             aRect.Move(aDelta.X(), aDelta.Y());
     859             :         }
     860             : 
     861           0 :         Size aDrawSize = aRect.GetSize();
     862             : 
     863           0 :         MapMode aMapMode( GetDoc()->GetScaleUnit() );
     864           0 :         Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
     865           0 :         if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example
     866           0 :             aObjAreaSize = aDrawSize;
     867             : 
     868           0 :         Fraction aScaleWidth (aDrawSize.Width(),  aObjAreaSize.Width() );
     869           0 :         Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
     870           0 :         aScaleWidth.ReduceInaccurate(10);       // kompatibel zum SdrOle2Obj
     871           0 :         aScaleHeight.ReduceInaccurate(10);
     872           0 :         pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
     873             : 
     874             :         // visible section is only changed in-place!
     875           0 :         aRect.SetSize(aObjAreaSize);
     876             :         // the object area size must be set after scaling, since it triggers the resizing
     877           0 :         pSdClient->SetObjArea(aRect);
     878             : 
     879           0 :         if( bChangeDefaultsForChart && xObj.is())
     880             :         {
     881           0 :             ChartHelper::AdaptDefaultsForChart( xObj );
     882             :         }
     883             : 
     884           0 :         pSdClient->DoVerb(nVerb);   // if necessary, ErrCode is outputted by Sfx
     885           0 :         pViewShell->GetViewFrame()->GetBindings().Invalidate(
     886           0 :             SID_NAVIGATOR_STATE, sal_True, sal_False);
     887             :     }
     888             : 
     889           0 :     GetDocSh()->SetWaitCursor( sal_False );
     890             : 
     891           0 :     if (aErrCode != 0 && !bAbort)
     892             :     {
     893           0 :         ErrorHandler::HandleError(* new StringErrorInfo(aErrCode, String() ) );
     894             :     }
     895             : 
     896           0 :     return aErrCode == 0;
     897             : }
     898             : 
     899             : /**
     900             :  * @returns enclosing rectangle of all (split-) windows.
     901             :  */
     902           0 : const Rectangle& ViewShell::GetAllWindowRect()
     903             : {
     904             :     maAllWindowRectangle.SetPos(
     905           0 :         mpContentWindow->OutputToScreenPixel(Point(0,0)));
     906           0 :     return maAllWindowRectangle;
     907             : }
     908             : 
     909           0 : void ViewShell::ReadUserData(const String&)
     910             : {
     911             :     // zoom onto VisArea from FrameView
     912             :     GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA,
     913           0 :         SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     914           0 : }
     915             : 
     916             : 
     917           0 : void ViewShell::WriteUserData(String&)
     918             : {
     919             :     // writing of our data is always done in WriteFrameViewData()
     920           0 :     WriteFrameViewData();
     921           0 : }
     922             : 
     923             : 
     924             : /**
     925             :  * Switch ruler on/off
     926             :  */
     927          52 : void ViewShell::SetRuler(sal_Bool bRuler)
     928             : {
     929          52 :     mbHasRulers = ( bRuler && !GetDocSh()->IsPreview() ); // no rulers on preview mode
     930             : 
     931          52 :     if (mpHorizontalRuler.get() != NULL)
     932             :     {
     933           0 :         if (mbHasRulers)
     934             :         {
     935           0 :             mpHorizontalRuler->Show();
     936             :         }
     937             :         else
     938             :         {
     939           0 :             mpHorizontalRuler->Hide();
     940             :         }
     941             :     }
     942             : 
     943          52 :     if (mpVerticalRuler.get() != NULL)
     944             :     {
     945           0 :         if (mbHasRulers)
     946             :         {
     947           0 :             mpVerticalRuler->Show();
     948             :         }
     949             :         else
     950             :         {
     951           0 :             mpVerticalRuler->Hide();
     952             :         }
     953             :     }
     954             : 
     955             :     OSL_ASSERT(GetViewShell()!=NULL);
     956          52 :     if (IsMainViewShell())
     957           0 :         GetViewShell()->InvalidateBorder();
     958          52 : }
     959             : 
     960             : 
     961           0 : sal_Int8 ViewShell::AcceptDrop (
     962             :     const AcceptDropEvent& rEvt,
     963             :     DropTargetHelper& rTargetHelper,
     964             :     ::sd::Window* pTargetWindow,
     965             :     sal_uInt16 nPage,
     966             :     sal_uInt16 nLayer)
     967             : {
     968           0 :     ::sd::View* pView = GetView();
     969           0 :     return( pView ? pView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
     970             : }
     971             : 
     972             : 
     973           0 : sal_Int8 ViewShell::ExecuteDrop (
     974             :     const ExecuteDropEvent& rEvt,
     975             :     DropTargetHelper& rTargetHelper,
     976             :     ::sd::Window* pTargetWindow,
     977             :     sal_uInt16 nPage,
     978             :     sal_uInt16 nLayer)
     979             : {
     980           0 :     ::sd::View* pView = GetView();
     981           0 :     return( pView ? pView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
     982             : }
     983             : 
     984          67 : void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence <
     985             :     ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse)
     986             : {
     987          67 :     const sal_Int32 nIndex = rSequence.getLength();
     988          67 :     rSequence.realloc( nIndex + 1 );
     989             : 
     990             :     OSL_ASSERT (GetViewShell()!=NULL);
     991             :     // Get the view id from the view shell in the center pane.  This will
     992             :     // usually be the called view shell, but to be on the safe side we call
     993             :     // the main view shell explicitly.
     994          67 :     sal_uInt16 nViewID (IMPRESS_FACTORY_ID);
     995          67 :     if (GetViewShellBase().GetMainViewShell().get() != NULL)
     996          67 :         nViewID = GetViewShellBase().GetMainViewShell()->mpImpl->GetViewId();
     997          67 :     rSequence[nIndex].Name = OUString( sUNO_View_ViewId );
     998          67 :     OUStringBuffer sBuffer( "view" );
     999          67 :     sBuffer.append( static_cast<sal_Int32>(nViewID));
    1000          67 :     rSequence[nIndex].Value <<= sBuffer.makeStringAndClear();
    1001             : 
    1002          67 :     mpFrameView->WriteUserDataSequence( rSequence, bBrowse );
    1003          67 : }
    1004             : 
    1005             : 
    1006          65 : void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
    1007             : {
    1008          65 :     mpFrameView->ReadUserDataSequence( rSequence, bBrowse );
    1009          65 : }
    1010             : 
    1011         440 : void ViewShell::VisAreaChanged(const Rectangle& rRect)
    1012             : {
    1013             :     OSL_ASSERT (GetViewShell()!=NULL);
    1014         440 :     GetViewShell()->VisAreaChanged(rRect);
    1015         440 : }
    1016             : 
    1017           0 : void ViewShell::SetWinViewPos(const Point& rWinPos, bool bUpdate)
    1018             : {
    1019           0 :     if (mpContentWindow.get() != NULL)
    1020             :     {
    1021           0 :         mpContentWindow->SetWinViewPos(rWinPos);
    1022             : 
    1023           0 :         if ( bUpdate )
    1024             :         {
    1025           0 :             mpContentWindow->UpdateMapOrigin();
    1026           0 :             mpContentWindow->Invalidate();
    1027             :         }
    1028             :     }
    1029             : 
    1030           0 :     if (mbHasRulers)
    1031             :     {
    1032           0 :         UpdateHRuler();
    1033           0 :         UpdateVRuler();
    1034             :     }
    1035             : 
    1036           0 :     UpdateScrollBars();
    1037             : 
    1038           0 :     Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
    1039           0 :     Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
    1040           0 :     VisAreaChanged(aVisAreaWin);
    1041             : 
    1042           0 :     ::sd::View* pView = GetView();
    1043           0 :     if (pView)
    1044             :     {
    1045           0 :         pView->VisAreaChanged(GetActiveWindow());
    1046             :     }
    1047           0 : }
    1048             : 
    1049           0 : Point ViewShell::GetWinViewPos() const
    1050             : {
    1051           0 :     return mpContentWindow->GetWinViewPos();
    1052             : }
    1053             : 
    1054           0 : Point ViewShell::GetViewOrigin() const
    1055             : {
    1056           0 :     return mpContentWindow->GetViewOrigin();
    1057             : }
    1058             : 
    1059          33 : } // end of namespace sd
    1060             : 
    1061             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10