LCOV - code coverage report
Current view: top level - sc/source/ui/view - prevwsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 302 656 46.0 %
Date: 2012-08-25 Functions: 33 50 66.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 244 921 26.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "scitems.hxx"
      30                 :            : #include <comphelper/string.hxx>
      31                 :            : #include <editeng/eeitem.hxx>
      32                 :            : 
      33                 :            : #include <sfx2/app.hxx>
      34                 :            : #include <editeng/sizeitem.hxx>
      35                 :            : #include <svl/srchitem.hxx>
      36                 :            : #include <svx/zoomslideritem.hxx>
      37                 :            : #include <svx/svdview.hxx>
      38                 :            : #include <sfx2/dispatch.hxx>
      39                 :            : #include <sfx2/objface.hxx>
      40                 :            : #include <sfx2/request.hxx>
      41                 :            : #include <svl/stritem.hxx>
      42                 :            : #include <svl/whiter.hxx>
      43                 :            : #include <vcl/msgbox.hxx>
      44                 :            : #include <vcl/help.hxx>
      45                 :            : #include <tools/urlobj.hxx>
      46                 :            : #include <sfx2/docfile.hxx>
      47                 :            : #include <sfx2/printer.hxx>
      48                 :            : 
      49                 :            : #include "prevwsh.hxx"
      50                 :            : #include "preview.hxx"
      51                 :            : #include "printfun.hxx"
      52                 :            : #include "attrib.hxx"
      53                 :            : #include "scmod.hxx"
      54                 :            : #include "inputhdl.hxx"
      55                 :            : #include "docsh.hxx"
      56                 :            : #include "tabvwsh.hxx"
      57                 :            : #include "stlpool.hxx"
      58                 :            : #include "editutil.hxx"
      59                 :            : #include "scresid.hxx"
      60                 :            : #include "globstr.hrc"
      61                 :            : #include "sc.hrc"
      62                 :            : #include "ViewSettingsSequenceDefines.hxx"
      63                 :            : #include "tpprint.hxx"
      64                 :            : #include "printopt.hxx"
      65                 :            : #include "viewuno.hxx"
      66                 :            : #include <sax/tools/converter.hxx>
      67                 :            : #include <rtl/ustrbuf.hxx>
      68                 :            : 
      69                 :            : #include <svx/svxdlg.hxx>
      70                 :            : #include <svx/dialogs.hrc>
      71                 :            : 
      72                 :            : #include <basegfx/tools/zoomtools.hxx>
      73                 :            : #include <svx/zoom_def.hxx>
      74                 :            : #include <com/sun/star/document/XDocumentProperties.hpp>
      75                 :            : 
      76                 :            : #include "scabstdlg.hxx"
      77                 :            : //  for mouse wheel
      78                 :            : #define MINZOOM_SLIDER 10
      79                 :            : #define MAXZOOM_SLIDER 400
      80                 :            : 
      81                 :            : #define SC_USERDATA_SEP ';'
      82                 :            : 
      83                 :            : using namespace com::sun::star;
      84                 :            : 
      85                 :            : // -----------------------------------------------------------------------
      86                 :            : 
      87                 :            : #define ScPreviewShell
      88                 :            : #include "scslots.hxx"
      89                 :            : 
      90 [ -  + ][ -  + ]:        804 : TYPEINIT1( ScPreviewShell, SfxViewShell );
      91                 :            : 
      92 [ +  + ][ +  - ]:       6014 : SFX_IMPL_INTERFACE( ScPreviewShell, SfxViewShell, ScResId(SCSTR_PREVIEWSHELL) )
         [ +  - ][ +  - ]
      93                 :            : {
      94         [ +  - ]:         51 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|
      95                 :            :                                 SFX_VISIBILITY_SERVER|SFX_VISIBILITY_READONLYDOC,
      96         [ +  - ]:         51 :                                 ScResId(RID_OBJECTBAR_PREVIEW));
      97 [ +  - ][ +  - ]:         51 :     SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_PREVIEW));
      98                 :         51 : }
      99                 :            : 
     100 [ +  - ][ +  - ]:         67 : SFX_IMPL_NAMED_VIEWFACTORY( ScPreviewShell, "PrintPreview" )
     101                 :            : {
     102                 :         51 :     SFX_VIEW_REGISTRATION(ScDocShell);
     103                 :         51 : }
     104                 :            : 
     105                 :            : //------------------------------------------------------------------
     106                 :            : 
     107                 :         16 : void ScPreviewShell::Construct( Window* pParent )
     108                 :            : {
     109                 :            :     // Find the top-most window, and set the close window handler to intercept
     110                 :            :     // the window close event.
     111                 :         16 :     Window* pWin = pParent;
     112         [ +  + ]:         48 :     while (!pWin->IsSystemWindow())
     113                 :            :     {
     114         [ +  - ]:         32 :         if (pWin->GetParent())
     115                 :         32 :             pWin = pWin->GetParent();
     116                 :            :         else
     117                 :          0 :             break;
     118                 :            :     }
     119                 :            : 
     120         [ -  + ]:         16 :     mpFrameWindow = dynamic_cast<SystemWindow*>(pWin);
     121         [ +  - ]:         16 :     if (mpFrameWindow)
     122         [ +  - ]:         16 :         mpFrameWindow->SetCloseHdl(LINK(this, ScPreviewShell, CloseHdl));
     123                 :            : 
     124                 :         16 :     eZoom = SVX_ZOOM_WHOLEPAGE;
     125                 :            : 
     126         [ +  - ]:         16 :     pCorner = new ScrollBarBox( pParent, WB_SIZEABLE );
     127                 :            : 
     128         [ +  - ]:         16 :     pHorScroll = new ScrollBar(pParent, WB_HSCROLL );
     129         [ +  - ]:         16 :     pVerScroll = new ScrollBar(pParent, WB_VSCROLL);
     130                 :            : 
     131                 :            :     // SSA: --- RTL --- no mirroring for horizontal scrollbars
     132                 :         16 :     pHorScroll->EnableRTL( false );
     133                 :            : 
     134                 :         16 :     pHorScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) );
     135                 :         16 :     pVerScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) );
     136                 :            : 
     137         [ +  - ]:         16 :     pPreview = new ScPreview( pParent, pDocShell, this );
     138                 :            : 
     139                 :         16 :     SetPool( &SC_MOD()->GetPool() );
     140                 :         16 :     SetWindow( pPreview );
     141                 :         16 :     StartListening(*pDocShell,sal_True);
     142                 :         16 :     StartListening(*SFX_APP(),sal_True);        // #i62045# #i62046# application is needed for Calc's own hints
     143                 :         16 :     SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster();
     144         [ +  - ]:         16 :     if (pDrawBC)
     145                 :         16 :         StartListening(*pDrawBC);
     146                 :            : 
     147                 :         16 :     pHorScroll->Show( false );
     148                 :         16 :     pVerScroll->Show( false );
     149                 :         16 :     pCorner->Show();
     150                 :         16 :     SetHelpId( HID_SCSHELL_PREVWSH );
     151 [ +  - ][ +  - ]:         16 :     SetName(rtl::OUString("Preview"));
                 [ +  - ]
     152                 :         16 : }
     153                 :            : 
     154                 :         16 : ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
     155                 :            :                                 SfxViewShell* pOldSh ) :
     156                 :            :     SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
     157         [ +  - ]:         16 :     pDocShell( (ScDocShell*)pViewFrame->GetObjectShell() ),
     158                 :            :     mpFrameWindow(NULL),
     159                 :            :     nSourceDesignMode( SC_FORCEMODE_NONE ),
     160         [ +  - ]:         32 :     pAccessibilityBroadcaster( NULL )
     161                 :            : {
     162 [ +  - ][ +  - ]:         16 :     Construct( &pViewFrame->GetWindow() );
     163                 :            : 
     164 [ +  - ][ +  - ]:         16 :     if ( pOldSh && pOldSh->ISA( ScTabViewShell ) )
         [ +  - ][ +  - ]
                 [ +  - ]
     165                 :            :     {
     166                 :            :         //  store view settings, show table from TabView
     167                 :            :         //! store live ScViewData instead, and update on ScTablesHint?
     168                 :            :         //! or completely forget aSourceData on ScTablesHint?
     169                 :            : 
     170                 :         16 :         ScTabViewShell* pTabViewShell = ((ScTabViewShell*)pOldSh);
     171                 :         16 :         const ScViewData* pData = pTabViewShell->GetViewData();
     172         [ +  - ]:         16 :         pData->WriteUserDataSequence( aSourceData );
     173 [ +  - ][ +  - ]:         16 :         pPreview->SetSelectedTabs(pData->GetMarkData());
     174         [ +  - ]:         16 :         InitStartTable( pData->GetTabNo() );
     175                 :            : 
     176                 :            :         //  also have to store the TabView's DesignMode state
     177                 :            :         //  (only if draw view exists)
     178         [ +  - ]:         16 :         SdrView* pDrawView = pTabViewShell->GetSdrView();
     179         [ +  - ]:         16 :         if ( pDrawView )
     180                 :         16 :             nSourceDesignMode = pDrawView->IsDesignMode();
     181                 :            :     }
     182                 :            : 
     183         [ +  - ]:         16 :     new ScPreviewObj(this);
     184                 :         16 : }
     185                 :            : 
     186         [ +  - ]:         16 : ScPreviewShell::~ScPreviewShell()
     187                 :            : {
     188         [ +  - ]:         16 :     if (mpFrameWindow)
     189 [ +  - ][ +  - ]:         16 :         mpFrameWindow->SetCloseHdl(Link()); // Remove close handler.
     190                 :            : 
     191                 :            :     // #108333#; notify Accessibility that Shell is dying and before destroy all
     192 [ +  - ][ +  - ]:         16 :     BroadcastAccessibility( SfxSimpleHint( SFX_HINT_DYING ) );
                 [ +  - ]
     193 [ +  - ][ +  - ]:         16 :     DELETEZ(pAccessibilityBroadcaster);
     194                 :            : 
     195         [ +  - ]:         16 :     SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster();
     196         [ +  - ]:         16 :     if (pDrawBC)
     197         [ +  - ]:         16 :         EndListening(*pDrawBC);
     198 [ +  - ][ +  - ]:         16 :     EndListening(*SFX_APP());
     199         [ +  - ]:         16 :     EndListening(*pDocShell);
     200                 :            : 
     201         [ +  - ]:         16 :     SetWindow(0);
     202 [ +  - ][ +  - ]:         16 :     delete pPreview;
     203 [ +  - ][ +  - ]:         16 :     delete pHorScroll;
     204 [ +  - ][ +  - ]:         16 :     delete pVerScroll;
     205 [ +  - ][ +  - ]:         16 :     delete pCorner;
     206                 :            : 
     207                 :            :     //  normal mode of operation is switching back to default view in the same frame,
     208                 :            :     //  so there's no need to activate any other window here anymore
     209         [ -  + ]:         32 : }
     210                 :            : 
     211                 :         16 : void ScPreviewShell::InitStartTable(SCTAB nTab)
     212                 :            : {
     213                 :         16 :     pPreview->SetPageNo( pPreview->GetFirstPage(nTab) );
     214                 :         16 : }
     215                 :            : 
     216                 :            : //------------------------------------------------------------------
     217                 :            : 
     218                 :          0 : String ScPreviewShell::GetDescription() const
     219                 :            : {
     220         [ #  # ]:          0 :     return rtl::OUString(" ** Test ** ");
     221                 :            : }
     222                 :            : 
     223                 :          0 : Size ScPreviewShell::GetOptimalSizePixel() const
     224                 :            : {
     225                 :          0 :     Size aOptSize(100,100);
     226                 :            : 
     227                 :          0 :     ScTabViewShell*     pViewSh = pDocShell->GetBestViewShell();
     228                 :            : 
     229         [ #  # ]:          0 :     if ( pViewSh )
     230                 :            :     {
     231                 :          0 :         ScViewData*         pViewData   = pViewSh->GetViewData();
     232                 :          0 :         SCTAB               nCurTab     = pViewData->GetTabNo();
     233                 :          0 :         ScDocument*         pDoc        = pDocShell->GetDocument();
     234                 :          0 :         ScStyleSheetPool*   pStylePool  = pDoc->GetStyleSheetPool();
     235                 :            :         SfxStyleSheetBase*  pStyleSheet = pStylePool->Find(
     236                 :            :                                             pDoc->GetPageStyle( nCurTab ),
     237 [ #  # ][ #  # ]:          0 :                                             SFX_STYLE_FAMILY_PAGE );
                 [ #  # ]
     238                 :            : 
     239                 :            :         OSL_ENSURE( pStyleSheet, "PageStyle not found :-/" );
     240                 :            : 
     241         [ #  # ]:          0 :         if ( pStyleSheet )
     242                 :            :         {
     243                 :          0 :             const SfxItemSet&  rSet      = pStyleSheet->GetItemSet();
     244                 :          0 :             const SvxSizeItem& rItem     = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE );
     245                 :          0 :             const Size&        rPageSize = rItem.GetSize();
     246                 :            : 
     247                 :          0 :             aOptSize.Width()  = (long) (rPageSize.Width()  * pViewData->GetPPTX());
     248                 :          0 :             aOptSize.Height() = (long) (rPageSize.Height() * pViewData->GetPPTY());
     249                 :            :         }
     250                 :            :     }
     251                 :            :     else
     252                 :            :     {
     253                 :            :         OSL_FAIL( "TabViewShell not found :-/" );
     254                 :            :     }
     255                 :            : 
     256                 :          0 :     return aOptSize;
     257                 :            : }
     258                 :            : 
     259                 :         16 : void ScPreviewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
     260                 :            : {
     261                 :         16 :     Size aOutSize( rSize );
     262         [ +  - ]:         16 :     pPreview->SetPosSizePixel( rPos, aOutSize );
     263                 :            : 
     264         [ +  - ]:         16 :     if ( SVX_ZOOM_WHOLEPAGE == eZoom )
     265 [ +  - ][ +  - ]:         16 :         pPreview->SetZoom( pPreview->GetOptimalZoom(false) );
     266         [ #  # ]:          0 :     else if ( SVX_ZOOM_PAGEWIDTH == eZoom )
     267 [ #  # ][ #  # ]:          0 :         pPreview->SetZoom( pPreview->GetOptimalZoom(true) );
     268                 :            : 
     269         [ +  - ]:         16 :     UpdateNeededScrollBars();
     270                 :         16 : }
     271                 :            : 
     272                 :          0 : void ScPreviewShell::InnerResizePixel( const Point &rOfs, const Size &rSize )
     273                 :            : {
     274                 :          0 :     AdjustPosSizePixel( rOfs,rSize );
     275                 :          0 : }
     276                 :            : 
     277                 :         16 : void ScPreviewShell::OuterResizePixel( const Point &rOfs, const Size &rSize )
     278                 :            : {
     279                 :         16 :     AdjustPosSizePixel( rOfs,rSize );
     280                 :         16 : }
     281                 :            : 
     282                 :        131 : bool ScPreviewShell::GetPageSize( Size& aPageSize )
     283                 :            : {
     284                 :        131 :     ScDocument* pDoc = pDocShell->GetDocument();
     285                 :        131 :     SCTAB nTab = pPreview->GetTab();
     286                 :            : 
     287                 :        131 :     ScStyleSheetPool*   pStylePool  = pDoc->GetStyleSheetPool();
     288                 :            :     SfxStyleSheetBase*  pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ),
     289 [ +  - ][ +  - ]:        131 :                                                         SFX_STYLE_FAMILY_PAGE );
                 [ +  - ]
     290                 :            :     OSL_ENSURE(pStyleSheet,"No style sheet");
     291         [ -  + ]:        131 :     if (!pStyleSheet) return false;
     292                 :        131 :     const SfxItemSet* pParamSet = &pStyleSheet->GetItemSet();
     293                 :            : 
     294                 :        131 :     aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize();
     295                 :        131 :     aPageSize.Width()  = (long) (aPageSize.Width()  * HMM_PER_TWIPS );
     296                 :        131 :     aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS );
     297                 :        131 :     return true;
     298                 :            : }
     299                 :            : 
     300                 :         34 : void ScPreviewShell::UpdateNeededScrollBars( bool bFromZoom )
     301                 :            : {
     302                 :         34 :     Size aPageSize;
     303         [ +  - ]:         34 :     OutputDevice* pDevice = Application::GetDefaultDevice();
     304                 :            : 
     305         [ +  - ]:         34 :     long nBarW = GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetScrollBarSize();
     306                 :         34 :     long nBarH = nBarW;
     307                 :            : 
     308 [ +  - ][ +  - ]:         34 :     long aHeightOffSet = pDevice ? pDevice->PixelToLogic( Size( nBarW, nBarH ), pPreview->GetMapMode() ).Height() : 0;
                 [ +  - ]
           [ #  #  #  # ]
                 [ +  - ]
     309                 :         34 :     long aWidthOffSet = aHeightOffSet;
     310                 :            : 
     311                 :            : 
     312 [ +  - ][ +  - ]:         34 :     if (!GetPageSize( aPageSize ))
     313                 :         34 :         return;
     314                 :            : 
     315                 :            :     //  for centering, page size without the shadow is used
     316 [ +  - ][ +  - ]:         34 :     bool bVert = pVerScroll ? pVerScroll->IsVisible() : false;
                 [ +  + ]
     317 [ +  - ][ +  - ]:         34 :     bool bHori = pHorScroll ? pHorScroll->IsVisible() : false;
                 [ -  + ]
     318         [ +  - ]:         34 :     Size aWindowSize = pPreview->GetOutputSize();
     319         [ +  - ]:         34 :     Point aPos = pPreview->GetPosPixel();
     320                 :         34 :     Size aWindowPixelSize = pPreview->GetOutputSizePixel();
     321                 :            : 
     322                 :            :     // if we are called from Zoom then we need to compensate for whatever
     323                 :            :     // scrollbars were displayed before the zoom was called
     324         [ +  + ]:         34 :     if ( bFromZoom )
     325                 :            :     {
     326         [ +  + ]:         18 :         if ( bVert )
     327                 :            :         {
     328                 :          1 :             aWindowPixelSize.Width() += nBarH;
     329                 :          1 :             aWindowSize.Width() += aHeightOffSet;
     330                 :            :         }
     331         [ -  + ]:         18 :         if ( bHori )
     332                 :            :         {
     333                 :          0 :             aWindowPixelSize.Height() += nBarW;
     334                 :          0 :             aWindowSize.Height() += aWidthOffSet;
     335                 :            :         }
     336                 :            :     }
     337                 :            :     // recalculate any needed scrollbars
     338                 :         34 :     bHori = false;
     339                 :         34 :     bVert = false;
     340                 :            : 
     341                 :         34 :     long nMaxWidthPos = aPageSize.Width() - aWindowSize.Width();
     342         [ +  - ]:         34 :     if ( nMaxWidthPos<0 )
     343                 :         34 :         bHori = false;
     344                 :            :     else
     345                 :          0 :         bHori = true;
     346                 :            : 
     347                 :         34 :     long nMaxHeightPos = aPageSize.Height() - aWindowSize.Height();
     348                 :            : 
     349         [ +  + ]:         34 :     if ( nMaxHeightPos < 0 )
     350                 :         32 :         bVert = false;
     351                 :            :     else
     352                 :          2 :         bVert = true;
     353                 :            : 
     354                 :            :     // see if having a scroll bar requires the other
     355 [ +  + ][ -  + ]:         34 :     if ( bVert != bHori && ( bVert || bHori ) )
                 [ #  # ]
     356                 :            :     {
     357 [ +  - ][ -  + ]:          2 :         if ( bVert && ( (nMaxWidthPos + aWidthOffSet  ) > 0 ) )
     358                 :          0 :             bHori = true;
     359         [ +  - ]:          2 :         else if ( (nMaxHeightPos + aHeightOffSet ) > 0 )
     360                 :          2 :             bVert = true;
     361                 :            :     }
     362         [ +  - ]:         34 :     pHorScroll->Show( bHori );
     363         [ +  - ]:         34 :     pVerScroll->Show( bVert );
     364                 :            : 
     365                 :            :     // make room for needed scrollbars ( and reduce the size
     366                 :            :     // of the preview appropriately )
     367         [ -  + ]:         34 :     if ( bHori )
     368                 :          0 :         aWindowPixelSize.Height() -= nBarW;
     369         [ +  + ]:         34 :     if ( bVert )
     370                 :          2 :         aWindowPixelSize.Width() -= nBarH;
     371                 :            : 
     372         [ +  - ]:         34 :     pPreview->SetSizePixel( aWindowPixelSize );
     373                 :         34 :     pHorScroll->SetPosSizePixel( Point( aPos.X(), aPos.Y() + aWindowPixelSize.Height() ),
     374         [ +  - ]:         68 :                                  Size( aWindowPixelSize.Width(), nBarH ) );
     375                 :         34 :     pVerScroll->SetPosSizePixel( Point( aPos.X() + aWindowPixelSize.Width(), aPos.Y() ),
     376         [ +  - ]:         68 :                                  Size( nBarW, aWindowPixelSize.Height() ) );
     377                 :         34 :     pCorner->SetPosSizePixel( Point( aPos.X() + aWindowPixelSize.Width(), aPos.Y() + aWindowPixelSize.Height() ),
     378         [ +  - ]:         68 :                               Size( nBarW, nBarH ) );
     379         [ +  - ]:         34 :     UpdateScrollBars();
     380                 :            : }
     381                 :            : 
     382                 :         97 : void ScPreviewShell::UpdateScrollBars()
     383                 :            : {
     384                 :         97 :     Size aPageSize;
     385 [ +  - ][ +  - ]:         97 :     if ( !GetPageSize( aPageSize ) )
     386                 :         97 :         return;
     387                 :            : 
     388                 :            :     //  for centering, page size without the shadow is used
     389                 :            : 
     390         [ +  - ]:         97 :     Size aWindowSize = pPreview->GetOutputSize();
     391                 :            : 
     392                 :         97 :     Point aOfs = pPreview->GetOffset();
     393                 :            : 
     394         [ +  - ]:         97 :     if( pHorScroll )
     395                 :            :     {
     396         [ +  - ]:         97 :         pHorScroll->SetRange( Range( 0, aPageSize.Width() ) );
     397                 :         97 :         pHorScroll->SetLineSize( aWindowSize.Width() / 16 );
     398                 :         97 :         pHorScroll->SetPageSize( aWindowSize.Width() );
     399         [ +  - ]:         97 :         pHorScroll->SetVisibleSize( aWindowSize.Width() );
     400                 :         97 :         long nMaxPos = aPageSize.Width() - aWindowSize.Width();
     401         [ +  - ]:         97 :         if ( nMaxPos<0 )
     402                 :            :         {
     403                 :            :             //  page smaller than window -> center (but put scrollbar to 0)
     404                 :         97 :             aOfs.X() = 0;
     405         [ +  - ]:         97 :             pPreview->SetXOffset( nMaxPos / 2 );
     406                 :            :         }
     407         [ #  # ]:          0 :         else if (aOfs.X() < 0)
     408                 :            :         {
     409                 :            :             //  page larger than window -> never use negative offset
     410                 :          0 :             aOfs.X() = 0;
     411         [ #  # ]:          0 :             pPreview->SetXOffset( 0 );
     412                 :            :         }
     413         [ #  # ]:          0 :         else if (aOfs.X() > nMaxPos)
     414                 :            :         {
     415                 :            :             //  limit offset to align with right edge of window
     416                 :          0 :             aOfs.X() = nMaxPos;
     417         [ #  # ]:          0 :             pPreview->SetXOffset(nMaxPos);
     418                 :            :         }
     419         [ +  - ]:         97 :         pHorScroll->SetThumbPos( aOfs.X() );
     420                 :            :     }
     421                 :            : 
     422         [ +  - ]:         97 :     if( pVerScroll )
     423                 :            :     {
     424                 :         97 :         long nPageNo     = pPreview->GetPageNo();
     425         [ +  - ]:         97 :         long nTotalPages = pPreview->GetTotalPages();
     426                 :            : 
     427                 :         97 :         nMaxVertPos = aPageSize.Height() - aWindowSize.Height();
     428                 :         97 :         pVerScroll->SetLineSize( aWindowSize.Height() / 16  );
     429                 :         97 :         pVerScroll->SetPageSize( aWindowSize.Height() );
     430         [ +  - ]:         97 :         pVerScroll->SetVisibleSize( aWindowSize.Height() );
     431         [ +  + ]:         97 :         if ( nMaxVertPos < 0 )
     432                 :            :         {
     433                 :            :             //  page smaller than window -> center (but put scrollbar to 0)
     434                 :         90 :             aOfs.Y() = 0;
     435         [ +  - ]:         90 :             pPreview->SetYOffset( nMaxVertPos / 2 );
     436         [ +  - ]:         90 :             pVerScroll->SetThumbPos( nPageNo * aWindowSize.Height() );
     437         [ +  - ]:         90 :             pVerScroll->SetRange( Range( 0, aWindowSize.Height() * nTotalPages ));
     438                 :            :         }
     439         [ +  + ]:          7 :         else if (aOfs.Y() < 0)
     440                 :            :         {
     441                 :            :             //  page larger than window -> never use negative offset
     442         [ +  - ]:          2 :             pVerScroll->SetRange( Range( 0, aPageSize.Height() ) );
     443                 :          2 :             aOfs.Y() = 0;
     444         [ +  - ]:          2 :             pPreview->SetYOffset( 0 );
     445         [ +  - ]:          2 :             pVerScroll->SetThumbPos( aOfs.Y() );
     446                 :            :         }
     447         [ -  + ]:          5 :         else if (aOfs.Y() > nMaxVertPos )
     448                 :            :         {
     449                 :            :             //  limit offset to align with window bottom
     450         [ #  # ]:          0 :             pVerScroll->SetRange( Range( 0, aPageSize.Height() ) );
     451                 :          0 :             aOfs.Y() = nMaxVertPos;
     452         [ #  # ]:          0 :             pPreview->SetYOffset( nMaxVertPos );
     453         [ #  # ]:         97 :             pVerScroll->SetThumbPos( aOfs.Y() );
     454                 :            :         }
     455                 :            :     }
     456                 :            : }
     457                 :            : 
     458                 :          0 : IMPL_LINK (ScPreviewShell,ScrollHandler, ScrollBar* ,pScroll )
     459                 :            : {
     460                 :          0 :     long nPos           = pScroll->GetThumbPos();
     461                 :          0 :     long nDelta         = pScroll->GetDelta();
     462                 :          0 :     long nMaxRange      = pScroll->GetRangeMax();
     463                 :          0 :     long nTotalPages    = pPreview->GetTotalPages();
     464                 :          0 :     long nPageNo        = 0;
     465                 :          0 :     long nPerPageLength = 0;
     466                 :          0 :     sal_Bool bIsDivide      = sal_True;
     467                 :            : 
     468         [ #  # ]:          0 :     if( nTotalPages )
     469                 :          0 :         nPerPageLength = nMaxRange / nTotalPages;
     470                 :            : 
     471         [ #  # ]:          0 :     if( nPerPageLength )
     472                 :            :     {
     473                 :          0 :         nPageNo = nPos / nPerPageLength;
     474         [ #  # ]:          0 :         if( nPos % nPerPageLength )
     475                 :            :         {
     476                 :          0 :             bIsDivide = false;
     477                 :          0 :             nPageNo ++;
     478                 :            :         }
     479                 :            :     }
     480                 :            : 
     481                 :          0 :     sal_Bool bHoriz = ( pScroll == pHorScroll );
     482                 :            : 
     483         [ #  # ]:          0 :     if( bHoriz )
     484                 :          0 :         pPreview->SetXOffset( nPos );
     485                 :            :     else
     486                 :            :     {
     487         [ #  # ]:          0 :         if( nMaxVertPos > 0 )
     488                 :          0 :             pPreview->SetYOffset( nPos );
     489                 :            :         else
     490                 :            :         {
     491 [ #  # ][ #  # ]:          0 :             Point  aMousePos = pScroll->OutputToNormalizedScreenPixel( pScroll->GetPointerPosPixel() );
     492 [ #  # ][ #  # ]:          0 :             Point  aPos      = pScroll->GetParent()->OutputToNormalizedScreenPixel( pScroll->GetPosPixel() );
                 [ #  # ]
     493         [ #  # ]:          0 :             String aHelpStr;
     494         [ #  # ]:          0 :             Rectangle aRect;
     495                 :            :             sal_uInt16   nAlign;
     496                 :            : 
     497         [ #  # ]:          0 :             if( nDelta < 0 )
     498                 :            :             {
     499 [ #  # ][ #  # ]:          0 :                 if ( nTotalPages && nPageNo > 0 && !bIsDivide )
                 [ #  # ]
     500         [ #  # ]:          0 :                     pPreview->SetPageNo( nPageNo-1 );
     501         [ #  # ]:          0 :                 if( bIsDivide )
     502         [ #  # ]:          0 :                     pPreview->SetPageNo( nPageNo );
     503                 :            : 
     504 [ #  # ][ #  # ]:          0 :                 aHelpStr = ScGlobal::GetRscString( STR_PAGE );
     505         [ #  # ]:          0 :                 aHelpStr += ' ';
     506 [ #  # ][ #  # ]:          0 :                 aHelpStr += String::CreateFromInt32( nPageNo );
                 [ #  # ]
     507                 :            : 
     508         [ #  # ]:          0 :                 aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
     509 [ #  # ][ #  # ]:          0 :                 aHelpStr += String::CreateFromInt32( nTotalPages );
                 [ #  # ]
     510                 :            :             }
     511         [ #  # ]:          0 :             else if( nDelta > 0 )
     512                 :            :             {
     513                 :          0 :                 sal_Bool bAllTested = pPreview->AllTested();
     514 [ #  # ][ #  # ]:          0 :                 if ( nTotalPages && ( nPageNo < nTotalPages || !bAllTested ) )
                 [ #  # ]
     515         [ #  # ]:          0 :                     pPreview->SetPageNo( nPageNo );
     516                 :            : 
     517 [ #  # ][ #  # ]:          0 :                 aHelpStr = ScGlobal::GetRscString( STR_PAGE );
     518         [ #  # ]:          0 :                 aHelpStr += ' ';
     519 [ #  # ][ #  # ]:          0 :                 aHelpStr += String::CreateFromInt32( nPageNo+1 );
                 [ #  # ]
     520                 :            : 
     521         [ #  # ]:          0 :                 aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
     522 [ #  # ][ #  # ]:          0 :                 aHelpStr += String::CreateFromInt32( nTotalPages );
                 [ #  # ]
     523                 :            :             }
     524                 :            : 
     525                 :          0 :             aRect.Left()    = aPos.X() - 8;
     526                 :          0 :             aRect.Top()     = aMousePos.Y();
     527                 :          0 :             aRect.Right()   = aRect.Left();
     528                 :          0 :             aRect.Top()     = aRect.Top();
     529                 :          0 :             nAlign          = QUICKHELP_BOTTOM|QUICKHELP_CENTER;
     530 [ #  # ][ #  # ]:          0 :             Help::ShowQuickHelp( pScroll->GetParent(), aRect, aHelpStr, nAlign );
                 [ #  # ]
     531                 :            :         }
     532                 :            :     }
     533                 :            : 
     534                 :          0 :     return 0;
     535                 :            : }
     536                 :            : 
     537                 :          0 : IMPL_LINK (ScPreviewShell, CloseHdl, SystemWindow*, EMPTYARG)
     538                 :            : {
     539                 :          0 :     ExitPreview();
     540                 :          0 :     return 0;
     541                 :            : }
     542                 :            : 
     543                 :          0 : sal_Bool ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt )
     544                 :            : {
     545                 :          0 :     sal_Bool bDone = false;
     546                 :          0 :     const CommandWheelData* pData = rCEvt.GetWheelData();
     547 [ #  # ][ #  # ]:          0 :     if ( pData && pData->GetMode() == COMMAND_WHEEL_ZOOM )
                 [ #  # ]
     548                 :            :     {
     549                 :          0 :         long nOld = pPreview->GetZoom();
     550                 :          0 :         long nNew = nOld;
     551         [ #  # ]:          0 :         if ( pData->GetDelta() < 0 )
     552                 :          0 :             nNew = Max( (long) MINZOOM, basegfx::zoomtools::zoomOut( nOld ));
     553                 :            :         else
     554                 :          0 :             nNew = Min( (long) MAXZOOM, basegfx::zoomtools::zoomIn( nOld ));
     555                 :            : 
     556         [ #  # ]:          0 :         if ( nNew != nOld )
     557                 :            :         {
     558                 :          0 :             eZoom = SVX_ZOOM_PERCENT;
     559                 :          0 :             pPreview->SetZoom( (sal_uInt16)nNew );
     560                 :            :         }
     561                 :            : 
     562                 :          0 :         bDone = sal_True;
     563                 :            :     }
     564                 :            :     else
     565                 :            :     {
     566                 :          0 :         bDone = pPreview->HandleScrollCommand( rCEvt, pHorScroll, pVerScroll );
     567                 :            :     }
     568                 :            : 
     569                 :          0 :     return bDone;
     570                 :            : }
     571                 :            : 
     572                 :         59 : SfxPrinter* ScPreviewShell::GetPrinter( sal_Bool bCreate )
     573                 :            : {
     574                 :         59 :     return pDocShell->GetPrinter(bCreate);
     575                 :            : }
     576                 :            : 
     577                 :          0 : sal_uInt16 ScPreviewShell::SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags, bool )
     578                 :            : {
     579                 :          0 :     return pDocShell->SetPrinter( pNewPrinter, nDiffFlags );
     580                 :            : }
     581                 :            : 
     582                 :          0 : SfxTabPage* ScPreviewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions )
     583                 :            : {
     584                 :          0 :     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     585                 :            :     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     586                 :          0 :     ::CreateTabPage ScTpPrintOptionsCreate =    pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
     587         [ #  # ]:          0 :     if ( ScTpPrintOptionsCreate )
     588                 :          0 :         return  (*ScTpPrintOptionsCreate)( pParent, rOptions);
     589                 :          0 :     return 0;
     590                 :            : }
     591                 :            : 
     592                 :         16 : void ScPreviewShell::Activate(sal_Bool bMDI)
     593                 :            : {
     594                 :         16 :     SfxViewShell::Activate(bMDI);
     595                 :            : 
     596                 :            :     //! Basic etc. -> auslagern in eigene Datei (s. tabvwsh4)
     597                 :            : 
     598         [ +  - ]:         16 :     if (bMDI)
     599                 :            :     {
     600                 :            :         // InputHdl ist jetzt meistens Null, keine Assertion mehr!
     601                 :         16 :         ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
     602         [ -  + ]:         16 :         if ( pInputHdl )
     603                 :          0 :             pInputHdl->NotifyChange( NULL );
     604                 :            :     }
     605                 :         16 : }
     606                 :            : 
     607                 :         16 : void ScPreviewShell::Deactivate(sal_Bool bMDI)
     608                 :            : {
     609                 :         16 :     SfxViewShell::Deactivate(bMDI);
     610                 :            : 
     611                 :            :     if (bMDI)
     612                 :            :     {
     613                 :            :     }
     614                 :         16 : }
     615                 :            : 
     616                 :            : //------------------------------------------------------------------------
     617                 :            : 
     618                 :          2 : void ScPreviewShell::Execute( SfxRequest& rReq )
     619                 :            : {
     620                 :          2 :     sal_uInt16 nSlot = rReq.GetSlot();
     621                 :          2 :     const SfxItemSet* pReqArgs = rReq.GetArgs();
     622                 :            : 
     623   [ -  -  -  -  :          2 :     switch ( nSlot )
          -  -  -  +  -  
          -  -  -  -  -  
                   -  - ]
     624                 :            :     {
     625                 :            :         case SID_FORMATPAGE:
     626                 :            :         case SID_STATUS_PAGESTYLE:
     627                 :            :         case SID_HFEDIT:
     628                 :          0 :             pDocShell->ExecutePageStyle( *this, rReq, pPreview->GetTab() );
     629                 :          0 :             break;
     630                 :            :         case SID_REPAINT:
     631                 :          0 :             pPreview->Invalidate();
     632                 :          0 :             rReq.Done();
     633                 :          0 :             break;
     634                 :            :         case SID_PREV_TABLE: // Accelerator
     635                 :            :         case SID_PREVIEW_PREVIOUS:
     636                 :            :             {
     637                 :          0 :                 long nPage = pPreview->GetPageNo();
     638                 :          0 :                 long nTotal = pPreview->GetTotalPages();
     639 [ #  # ][ #  # ]:          0 :                 if (nTotal && nPage > 0)
     640                 :          0 :                     pPreview->SetPageNo( nPage-1 );
     641                 :            :             }
     642                 :          0 :             break;
     643                 :            :         case SID_NEXT_TABLE: // Accelerator
     644                 :            :         case SID_PREVIEW_NEXT:
     645                 :            :             {
     646                 :          0 :                 sal_Bool bAllTested = pPreview->AllTested();
     647                 :          0 :                 long nPage = pPreview->GetPageNo();
     648                 :          0 :                 long nTotal = pPreview->GetTotalPages();
     649 [ #  # ][ #  # ]:          0 :                 if (nTotal && (nPage+1 < nTotal || !bAllTested))
                 [ #  # ]
     650                 :          0 :                     pPreview->SetPageNo( nPage+1 );
     651                 :            :             }
     652                 :          0 :             break;
     653                 :            :         case SID_CURSORTOPOFFILE: // Accelerator
     654                 :            :         case SID_PREVIEW_FIRST:
     655                 :            :             {
     656                 :          0 :                 long nPage = pPreview->GetPageNo();
     657                 :          0 :                 long nTotal = pPreview->GetTotalPages();
     658 [ #  # ][ #  # ]:          0 :                 if (nTotal && nPage != 0)
     659                 :          0 :                     pPreview->SetPageNo( 0 );
     660                 :            :             }
     661                 :          0 :             break;
     662                 :            :         case SID_CURSORENDOFFILE: // Accelerator
     663                 :            :         case SID_PREVIEW_LAST:
     664                 :            :             {
     665         [ #  # ]:          0 :                 if (!pPreview->AllTested())
     666                 :          0 :                     pPreview->CalcAll();
     667                 :            : 
     668                 :          0 :                 long nPage = pPreview->GetPageNo();
     669                 :          0 :                 long nTotal = pPreview->GetTotalPages();
     670 [ #  # ][ #  # ]:          0 :                 if (nTotal && nPage+1 != nTotal)
     671                 :          0 :                     pPreview->SetPageNo( nTotal-1 );
     672                 :            :             }
     673                 :          0 :             break;
     674                 :            :         case SID_ATTR_ZOOM:
     675                 :            :         case FID_SCALE:
     676                 :            :             {
     677                 :          0 :                 sal_uInt16      nZoom       = 100;
     678                 :          0 :                 sal_Bool        bCancel     = false;
     679                 :            : 
     680                 :          0 :                 eZoom = SVX_ZOOM_PERCENT;
     681                 :            : 
     682         [ #  # ]:          0 :                 if ( pReqArgs )
     683                 :            :                 {
     684                 :            : 
     685                 :            :                     const SvxZoomItem& rZoomItem = (const SvxZoomItem&)
     686                 :          0 :                                                    pReqArgs->Get(SID_ATTR_ZOOM);
     687                 :            : 
     688                 :          0 :                     eZoom = rZoomItem.GetType();
     689                 :          0 :                     nZoom = rZoomItem.GetValue();
     690                 :            :                 }
     691                 :            :                 else
     692                 :            :                 {
     693         [ #  # ]:          0 :                     SfxItemSet      aSet     ( GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
     694         [ #  # ]:          0 :                     SvxZoomItem     aZoomItem( SVX_ZOOM_PERCENT, pPreview->GetZoom(), SID_ATTR_ZOOM );
     695                 :            : 
     696         [ #  # ]:          0 :                     aSet.Put( aZoomItem );
     697         [ #  # ]:          0 :                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     698         [ #  # ]:          0 :                     if(pFact)
     699                 :            :                     {
     700         [ #  # ]:          0 :                         AbstractSvxZoomDialog* pDlg = pFact->CreateSvxZoomDialog(NULL, aSet);
     701                 :            :                         OSL_ENSURE(pDlg, "Dialogdiet fail!");
     702         [ #  # ]:          0 :                         pDlg->SetLimits( 20, 400 );
     703         [ #  # ]:          0 :                         pDlg->HideButton( ZOOMBTN_OPTIMAL );
     704         [ #  # ]:          0 :                         bCancel = ( RET_CANCEL == pDlg->Execute() );
     705                 :            : 
     706         [ #  # ]:          0 :                         if ( !bCancel )
     707                 :            :                         {
     708                 :            :                             const SvxZoomItem&  rZoomItem = (const SvxZoomItem&)
     709         [ #  # ]:          0 :                                                     pDlg->GetOutputItemSet()->
     710         [ #  # ]:          0 :                                                         Get( SID_ATTR_ZOOM );
     711                 :            : 
     712                 :          0 :                             eZoom = rZoomItem.GetType();
     713                 :          0 :                             nZoom = rZoomItem.GetValue();
     714                 :            :                         }
     715                 :            : 
     716 [ #  # ][ #  # ]:          0 :                         delete pDlg;
     717 [ #  # ][ #  # ]:          0 :                     }
     718                 :            :                 }
     719                 :            : 
     720         [ #  # ]:          0 :                 if ( !bCancel )
     721                 :            :                 {
     722      [ #  #  # ]:          0 :                     switch ( eZoom )
     723                 :            :                     {
     724                 :            :                         case SVX_ZOOM_OPTIMAL:
     725                 :            :                         case SVX_ZOOM_WHOLEPAGE:
     726                 :          0 :                             nZoom = pPreview->GetOptimalZoom(false);
     727                 :          0 :                             break;
     728                 :            :                         case SVX_ZOOM_PAGEWIDTH:
     729                 :          0 :                             nZoom = pPreview->GetOptimalZoom(sal_True);
     730                 :          0 :                             break;
     731                 :            :                         default:
     732                 :            :                         {
     733                 :            :                             // added to avoid warnings
     734                 :            :                         }
     735                 :            :                     }
     736                 :            : 
     737                 :          0 :                     pPreview->SetZoom( nZoom );
     738                 :          0 :                     rReq.Done();
     739                 :            :                 }
     740                 :            :             }
     741                 :          0 :             break;
     742                 :            :         case SID_PREVIEW_ZOOMIN:
     743                 :            :             {
     744                 :          2 :                 sal_uInt16 nNew = pPreview->GetZoom() + 20 ;
     745                 :          2 :                 nNew -= nNew % 20;
     746                 :          2 :                 pPreview->SetZoom( nNew );
     747                 :          2 :                 eZoom = SVX_ZOOM_PERCENT;
     748                 :          2 :                 rReq.Done();
     749                 :            :             }
     750                 :          2 :             break;
     751                 :            :         case SID_PREVIEW_ZOOMOUT:
     752                 :            :             {
     753                 :          0 :                 sal_uInt16 nNew = pPreview->GetZoom() - 1;
     754                 :          0 :                 nNew -= nNew % 20;
     755                 :          0 :                 pPreview->SetZoom( nNew );
     756                 :          0 :                 eZoom = SVX_ZOOM_PERCENT;
     757                 :          0 :                 rReq.Done();
     758                 :            :             }
     759                 :          0 :             break;
     760                 :            :         case SID_PREVIEW_MARGIN:
     761                 :            :             {
     762                 :          0 :                 sal_Bool bMargin = pPreview->GetPageMargins();
     763                 :          0 :                 pPreview->SetPageMargins( !bMargin );
     764                 :          0 :                 pPreview->Invalidate();
     765                 :          0 :                 rReq.Done();
     766                 :            :             }
     767                 :          0 :             break;
     768                 :            :         case SID_ATTR_ZOOMSLIDER:
     769                 :            :             {
     770                 :            :                 const SfxPoolItem* pItem;
     771                 :          0 :                 eZoom = SVX_ZOOM_PERCENT;
     772 [ #  # ][ #  # ]:          0 :                 if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_ZOOMSLIDER, sal_True, &pItem ) )
         [ #  # ][ #  # ]
     773                 :            :                 {
     774                 :          0 :                     const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem*)pItem)->GetValue();
     775         [ #  # ]:          0 :                     if( nCurrentZoom )
     776                 :            :                     {
     777         [ #  # ]:          0 :                         pPreview->SetZoom( nCurrentZoom );
     778         [ #  # ]:          0 :                         rReq.Done();
     779                 :            :                     }
     780                 :            :                 }
     781                 :            :             }
     782                 :          0 :             break;
     783                 :            :         case SID_PREVIEW_SCALINGFACTOR:
     784                 :            :             {
     785                 :            :                 const SfxPoolItem* pItem;
     786         [ #  # ]:          0 :                 SCTAB nTab                      = pPreview->GetTab();
     787 [ #  # ][ #  # ]:          0 :                 String aOldName                 = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() );
                 [ #  # ]
     788         [ #  # ]:          0 :                 ScStyleSheetPool* pStylePool    = pDocShell->GetDocument()->GetStyleSheetPool();
     789         [ #  # ]:          0 :                 SfxStyleSheetBase* pStyleSheet  = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
     790                 :            :                 OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
     791                 :            : 
     792 [ #  # ][ #  # ]:          0 :                 if ( pReqArgs && pStyleSheet && SFX_ITEM_SET == pReqArgs->GetItemState( SID_PREVIEW_SCALINGFACTOR, sal_True, &pItem ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     793                 :            :                 {
     794                 :          0 :                     const sal_uInt16 nCurrentZoom   = ((const SvxZoomSliderItem *)pItem)->GetValue();
     795         [ #  # ]:          0 :                     SfxItemSet& rSet            = pStyleSheet->GetItemSet();
     796 [ #  # ][ #  # ]:          0 :                     rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nCurrentZoom ) );
                 [ #  # ]
     797 [ #  # ][ #  # ]:          0 :                     ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab );
     798         [ #  # ]:          0 :                     aPrintFunc.UpdatePages();
     799 [ #  # ][ #  # ]:          0 :                     rReq.Done();
     800                 :            :                 }
     801 [ #  # ][ #  # ]:          0 :                 GetViewFrame()->GetBindings().Invalidate( nSlot );
     802                 :            :             }
     803                 :          0 :             break;
     804                 :            :         case SID_PRINTPREVIEW:
     805                 :            :         case SID_PREVIEW_CLOSE:
     806                 :            :             //  print preview is now always in the same frame as the tab view
     807                 :            :             //  -> always switch this frame back to normal view
     808                 :            :             //  (ScTabViewShell ctor reads stored view data)
     809                 :            : 
     810                 :          0 :             ExitPreview();
     811                 :          0 :             break;
     812                 :            :         case SID_CURSORPAGEUP:
     813                 :            :         case SID_CURSORPAGEDOWN:
     814                 :            :         case SID_CURSORHOME:
     815                 :            :         case SID_CURSOREND:
     816                 :            :         case SID_CURSORUP:
     817                 :            :         case SID_CURSORDOWN:
     818                 :            :         case SID_CURSORLEFT:
     819                 :            :         case SID_CURSORRIGHT:
     820                 :          0 :             DoScroll( nSlot );
     821                 :          0 :             break;
     822                 :            :         case SID_CANCEL:
     823         [ #  # ]:          0 :             if( ScViewUtil::IsFullScreen( *this ) )
     824                 :          0 :                 ScViewUtil::SetFullScreen( *this, false );
     825                 :          0 :             break;
     826                 :            : 
     827                 :            :         default:
     828                 :          0 :             break;
     829                 :            :     }
     830                 :          2 : }
     831                 :            : 
     832                 :        389 : void ScPreviewShell::GetState( SfxItemSet& rSet )
     833                 :            : {
     834                 :        389 :     pPreview->SetInGetState(sal_True);
     835                 :            : 
     836         [ +  - ]:        389 :     SCTAB nTab      = pPreview->GetTab();
     837                 :        389 :     long nPage      = pPreview->GetPageNo();
     838         [ +  - ]:        389 :     long nTotal     = pPreview->GetTotalPages();
     839                 :        389 :     sal_uInt16 nZoom    = pPreview->GetZoom();
     840                 :        389 :     sal_Bool bAllTested = pPreview->AllTested();
     841                 :            : 
     842         [ +  - ]:        389 :     SfxWhichIter aIter(rSet);
     843         [ +  - ]:        389 :     sal_uInt16 nWhich = aIter.FirstWhich();
     844         [ +  + ]:       1089 :     while ( nWhich )
     845                 :            :     {
     846   [ +  +  +  +  :        700 :         switch (nWhich)
          +  +  +  +  +  
             +  +  +  + ]
     847                 :            :         {
     848                 :            :             case SID_STATUS_PAGESTYLE:
     849                 :            :             case SID_HFEDIT:
     850         [ +  - ]:         62 :                 pDocShell->GetStatePageStyle( *this, rSet, nTab );
     851                 :         62 :                 break;
     852                 :            :             case SID_UNDO:
     853                 :            :             case SID_REDO:
     854                 :            :             case SID_REPEAT:
     855                 :            :             case SID_SAVEDOC:
     856                 :            :             case SID_SAVEASDOC:
     857                 :            :             case SID_MAIL_SENDDOC:
     858                 :            :             case SID_VIEW_DATA_SOURCE_BROWSER:
     859                 :            :             case SID_QUITAPP:
     860         [ +  - ]:        162 :                 rSet.DisableItem(nWhich);
     861                 :        162 :                 break;
     862                 :            :             case SID_PREVIEW_PREVIOUS:
     863                 :            :             case SID_PREVIEW_FIRST:
     864 [ +  - ][ +  - ]:         70 :                 if (!nTotal || nPage==0)
     865         [ +  - ]:         70 :                     rSet.DisableItem(nWhich);
     866                 :         70 :                 break;
     867                 :            :             case SID_PREVIEW_NEXT:
     868                 :            :             case SID_PREVIEW_LAST:
     869         [ +  - ]:         70 :                 if (bAllTested)
     870 [ +  - ][ +  - ]:         70 :                     if (!nTotal || nPage==nTotal-1)
     871         [ +  - ]:         70 :                         rSet.DisableItem(nWhich);
     872                 :         70 :                 break;
     873                 :            :             case SID_PREVIEW_ZOOMIN:
     874         [ -  + ]:         37 :                 if (nZoom >= 400)
     875         [ #  # ]:          0 :                     rSet.DisableItem(nWhich);
     876                 :         37 :                 break;
     877                 :            :             case SID_PREVIEW_ZOOMOUT:
     878         [ -  + ]:         35 :                 if (nZoom <= 20)
     879         [ #  # ]:          0 :                     rSet.DisableItem(nWhich);
     880                 :         35 :                 break;
     881                 :            :             case SID_ATTR_ZOOM:
     882                 :            :                 {
     883         [ +  - ]:         51 :                     SvxZoomItem aZoom( eZoom, nZoom, nWhich );
     884                 :         51 :                     aZoom.SetValueSet( SVX_ZOOM_ENABLE_ALL & ~SVX_ZOOM_ENABLE_OPTIMAL );
     885 [ +  - ][ +  - ]:         51 :                     rSet.Put( aZoom );
     886                 :            :                 }
     887                 :         51 :                 break;
     888                 :            :             case SID_ATTR_ZOOMSLIDER:
     889                 :            :                 {
     890         [ +  - ]:         35 :                     SvxZoomSliderItem aZoomSliderItem( nZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
     891         [ +  - ]:         35 :                     aZoomSliderItem.AddSnappingPoint( 100 );
     892 [ +  - ][ +  - ]:         35 :                     rSet.Put( aZoomSliderItem );
     893                 :            :                 }
     894                 :         35 :                 break;
     895                 :            :             case SID_PREVIEW_SCALINGFACTOR:
     896                 :            :                 {
     897 [ +  - ][ -  + ]:         35 :                     if( pDocShell->IsReadOnly() )
     898         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     899                 :            :                     else
     900                 :            :                     {
     901 [ +  - ][ +  - ]:         35 :                         String aOldName                 = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() );
                 [ +  - ]
     902         [ +  - ]:         35 :                         ScStyleSheetPool* pStylePool    = pDocShell->GetDocument()->GetStyleSheetPool();
     903         [ +  - ]:         35 :                         SfxStyleSheetBase* pStyleSheet  = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
     904                 :            :                         OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
     905                 :            : 
     906         [ +  - ]:         35 :                         if ( pStyleSheet )
     907                 :            :                         {
     908         [ +  - ]:         35 :                             SfxItemSet& rStyleSet   = pStyleSheet->GetItemSet();
     909         [ +  - ]:         35 :                             sal_uInt16 nCurrentZoom     = ((const SfxUInt16Item&)rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
     910         [ +  - ]:         35 :                             if( nCurrentZoom )
     911                 :            :                             {
     912         [ +  - ]:         35 :                                 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM_SLIDER, MAXZOOM_SLIDER, SID_PREVIEW_SCALINGFACTOR );
     913         [ +  - ]:         35 :                                 aZoomSliderItem.AddSnappingPoint( 100 );
     914 [ +  - ][ +  - ]:         35 :                                 rSet.Put( aZoomSliderItem );
     915                 :            :                             }
     916                 :            :                             else
     917         [ #  # ]:          0 :                                 rSet.DisableItem( nWhich );
     918         [ +  - ]:         35 :                         }
     919                 :            :                     }
     920                 :            :                 }
     921                 :         35 :                 break;
     922                 :            :             case SID_STATUS_DOCPOS:
     923 [ +  - ][ +  - ]:         35 :                 rSet.Put( SfxStringItem( nWhich, pPreview->GetPosString() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     924                 :         35 :                 break;
     925                 :            :             case SID_PRINTPREVIEW:
     926 [ +  - ][ +  - ]:         27 :                 rSet.Put( SfxBoolItem( nWhich, sal_True ) );
                 [ +  - ]
     927                 :         27 :                 break;
     928                 :            :             case SID_FORMATPAGE:
     929                 :            :             case SID_PREVIEW_MARGIN:
     930 [ +  - ][ -  + ]:         54 :                 if( pDocShell->IsReadOnly() )
     931         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     932                 :         54 :                 break;
     933                 :            :         }
     934                 :            : 
     935         [ +  - ]:        700 :         nWhich = aIter.NextWhich();
     936                 :            :     }
     937                 :            : 
     938         [ +  - ]:        389 :     pPreview->SetInGetState(false);
     939                 :        389 : }
     940                 :            : 
     941                 :         18 : void ScPreviewShell::FillFieldData( ScHeaderFieldData& rData )
     942                 :            : {
     943                 :         18 :     ScDocument* pDoc = pDocShell->GetDocument();
     944         [ +  - ]:         18 :     SCTAB nTab = pPreview->GetTab();
     945                 :         18 :     rtl::OUString aTmp;
     946         [ +  - ]:         18 :     pDoc->GetName(nTab, aTmp);
     947         [ +  - ]:         18 :     rData.aTabName = aTmp;
     948                 :            : 
     949 [ +  - ][ +  - ]:         18 :     if( pDocShell->getDocProperties()->getTitle().getLength() != 0 )
         [ +  - ][ -  + ]
     950 [ #  # ][ #  # ]:          0 :         rData.aTitle = pDocShell->getDocProperties()->getTitle();
         [ #  # ][ #  # ]
     951                 :            :     else
     952 [ +  - ][ +  - ]:         18 :         rData.aTitle = pDocShell->GetTitle();
                 [ +  - ]
     953                 :            : 
     954         [ +  - ]:         18 :     const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
     955 [ +  - ][ +  - ]:         18 :     rData.aLongDocName  = rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
     956         [ -  + ]:         18 :     if ( rData.aLongDocName.Len() )
     957 [ #  # ][ #  # ]:          0 :         rData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
     958                 :            :     else
     959 [ +  - ][ +  - ]:         18 :         rData.aShortDocName = rData.aLongDocName = rData.aTitle;
     960                 :         18 :     rData.nPageNo       = pPreview->GetPageNo() + 1;
     961                 :            : 
     962                 :         18 :     sal_Bool bAllTested = pPreview->AllTested();
     963         [ +  - ]:         18 :     if (bAllTested)
     964         [ +  - ]:         18 :         rData.nTotalPages = pPreview->GetTotalPages();
     965                 :            :     else
     966                 :         18 :         rData.nTotalPages = 99;
     967                 :            : 
     968                 :            :     //  eNumType kennt der Dialog selber
     969                 :         18 : }
     970                 :            : 
     971                 :          0 : void ScPreviewShell::WriteUserData(String& rData, sal_Bool /* bBrowse */)
     972                 :            : {
     973                 :            :     //  nZoom
     974                 :            :     //  nPageNo
     975                 :            : 
     976         [ #  # ]:          0 :     rData =  String::CreateFromInt32(pPreview->GetZoom());
     977                 :          0 :     rData += (sal_Unicode) SC_USERDATA_SEP;
     978         [ #  # ]:          0 :     rData += String::CreateFromInt32(pPreview->GetPageNo());
     979                 :          0 : }
     980                 :            : 
     981                 :          0 : void ScPreviewShell::ReadUserData(const String& rData, sal_Bool /* bBrowse */)
     982                 :            : {
     983         [ #  # ]:          0 :     xub_StrLen nCount = comphelper::string::getTokenCount(rData, ';');
     984         [ #  # ]:          0 :     if (nCount)
     985                 :            :     {
     986                 :          0 :         xub_StrLen nIndex = 0;
     987 [ #  # ][ #  # ]:          0 :         pPreview->SetZoom((sal_uInt16)rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32());
         [ #  # ][ #  # ]
     988 [ #  # ][ #  # ]:          0 :         pPreview->SetPageNo(rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32());
         [ #  # ][ #  # ]
     989                 :          0 :         eZoom = SVX_ZOOM_PERCENT;
     990                 :            :     }
     991                 :          0 : }
     992                 :            : 
     993                 :          0 : void ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue >& rSeq, sal_Bool /* bBrowse */)
     994                 :            : {
     995                 :          0 :     rSeq.realloc(3);
     996                 :          0 :     beans::PropertyValue* pSeq = rSeq.getArray();
     997         [ #  # ]:          0 :     if(pSeq)
     998                 :            :     {
     999         [ #  # ]:          0 :         sal_uInt16 nViewID(GetViewFrame()->GetCurViewId());
    1000                 :          0 :         pSeq[0].Name = rtl::OUString(SC_VIEWID);
    1001         [ #  # ]:          0 :         rtl::OUStringBuffer sBuffer(rtl::OUString(SC_VIEW));
    1002                 :            :         ::sax::Converter::convertNumber(sBuffer,
    1003         [ #  # ]:          0 :                 static_cast<sal_Int32>(nViewID));
    1004 [ #  # ][ #  # ]:          0 :         pSeq[0].Value <<= sBuffer.makeStringAndClear();
    1005                 :          0 :         pSeq[1].Name = rtl::OUString(SC_ZOOMVALUE);
    1006         [ #  # ]:          0 :         pSeq[1].Value <<= sal_Int32 (pPreview->GetZoom());
    1007                 :          0 :         pSeq[2].Name = rtl::OUString("PageNumber");
    1008         [ #  # ]:          0 :         pSeq[2].Value <<= pPreview->GetPageNo();
    1009                 :            :     }
    1010                 :          0 : }
    1011                 :            : 
    1012                 :         16 : void ScPreviewShell::ReadUserDataSequence(const uno::Sequence < beans::PropertyValue >& rSeq, sal_Bool /* bBrowse */)
    1013                 :            : {
    1014                 :         16 :     sal_Int32 nCount(rSeq.getLength());
    1015         [ +  - ]:         16 :     if (nCount)
    1016                 :            :     {
    1017                 :         16 :         const beans::PropertyValue* pSeq = rSeq.getConstArray();
    1018         [ +  - ]:         16 :         if(pSeq)
    1019                 :            :         {
    1020         [ +  + ]:        384 :             for(sal_Int32 i = 0; i < nCount; i++, pSeq++)
    1021                 :            :             {
    1022                 :        368 :                 rtl::OUString sName(pSeq->Name);
    1023         [ +  + ]:        368 :                 if(sName.compareToAscii(SC_ZOOMVALUE) == 0)
    1024                 :            :                 {
    1025                 :         16 :                     sal_Int32 nTemp = 0;
    1026         [ +  - ]:         16 :                     if (pSeq->Value >>= nTemp)
    1027         [ +  - ]:         16 :                         pPreview->SetZoom(sal_uInt16(nTemp));
    1028                 :            :                 }
    1029         [ -  + ]:        352 :                 else if (sName.compareToAscii("PageNumber") == 0)
    1030                 :            :                 {
    1031                 :          0 :                     sal_Int32 nTemp = 0;
    1032         [ #  # ]:          0 :                     if (pSeq->Value >>= nTemp)
    1033         [ #  # ]:          0 :                         pPreview->SetPageNo(nTemp);
    1034                 :            :                 }
    1035                 :        368 :             }
    1036                 :            :         }
    1037                 :            :     }
    1038                 :         16 : }
    1039                 :            : 
    1040                 :          0 : void ScPreviewShell::DoScroll( sal_uInt16 nMode )
    1041                 :            : {
    1042                 :          0 :     Point   aCurPos, aPrevPos;
    1043                 :            : 
    1044                 :          0 :     long nHRange    = pHorScroll->GetRange().Max();
    1045                 :          0 :     long nHLine     = pHorScroll->GetLineSize();
    1046                 :          0 :     long nHPage     = pHorScroll->GetPageSize();
    1047                 :          0 :     long nVRange    = pVerScroll->GetRange().Max();
    1048                 :          0 :     long nVLine     = pVerScroll->GetLineSize();
    1049                 :          0 :     long nVPage     = pVerScroll->GetPageSize();
    1050                 :            : 
    1051                 :          0 :     aCurPos.X() = pHorScroll->GetThumbPos();
    1052                 :          0 :     aCurPos.Y() = pVerScroll->GetThumbPos();
    1053                 :          0 :     aPrevPos = aCurPos;
    1054                 :            : 
    1055                 :          0 :     long nThumbPos  = pVerScroll->GetThumbPos();
    1056                 :          0 :     long nRangeMax  = pVerScroll->GetRangeMax();
    1057                 :            : 
    1058   [ #  #  #  #  :          0 :     switch( nMode )
             #  #  #  #  
                      # ]
    1059                 :            :     {
    1060                 :            :         case SID_CURSORUP:
    1061         [ #  # ]:          0 :             if( nMaxVertPos<0 )
    1062                 :            :             {
    1063                 :          0 :                 long nPage = pPreview->GetPageNo();
    1064                 :            : 
    1065         [ #  # ]:          0 :                 if( nPage>0 )
    1066                 :            :                 {
    1067                 :          0 :                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
    1068         [ #  # ]:          0 :                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
    1069 [ #  # ][ #  # ]:          0 :                     Execute( aSfxRequest );
    1070                 :            :                 }
    1071                 :            :             }
    1072                 :            :             else
    1073                 :          0 :                 aCurPos.Y() -= nVLine;
    1074                 :          0 :             break;
    1075                 :            :         case SID_CURSORDOWN:
    1076         [ #  # ]:          0 :             if( nMaxVertPos<0 )
    1077                 :            :             {
    1078                 :          0 :                 long nPage = pPreview->GetPageNo();
    1079         [ #  # ]:          0 :                 long nTotal = pPreview->GetTotalPages();
    1080                 :            : 
    1081                 :            :                 // before testing for last page, make sure all page counts are calculated
    1082 [ #  # ][ #  # ]:          0 :                 if ( nPage+1 == nTotal && !pPreview->AllTested() )
                 [ #  # ]
    1083                 :            :                 {
    1084         [ #  # ]:          0 :                     pPreview->CalcAll();
    1085         [ #  # ]:          0 :                     nTotal = pPreview->GetTotalPages();
    1086                 :            :                 }
    1087                 :            : 
    1088         [ #  # ]:          0 :                 if( nPage<nTotal-1 )
    1089                 :            :                 {
    1090                 :          0 :                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
    1091         [ #  # ]:          0 :                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
    1092 [ #  # ][ #  # ]:          0 :                     Execute( aSfxRequest );
    1093                 :            :                 }
    1094                 :            :             }
    1095                 :            :             else
    1096                 :          0 :                 aCurPos.Y() += nVLine;
    1097                 :          0 :             break;
    1098                 :            :         case SID_CURSORLEFT:
    1099                 :          0 :             aCurPos.X() -= nHLine;
    1100                 :          0 :             break;
    1101                 :            :         case SID_CURSORRIGHT:
    1102                 :          0 :             aCurPos.X() += nHLine;
    1103                 :          0 :             break;
    1104                 :            :         case SID_CURSORPAGEUP:
    1105 [ #  # ][ #  # ]:          0 :             if( nThumbPos==0 || nMaxVertPos<0 )
    1106                 :            :             {
    1107                 :          0 :                 long nPage = pPreview->GetPageNo();
    1108                 :            : 
    1109         [ #  # ]:          0 :                 if( nPage>0 )
    1110                 :            :                 {
    1111                 :          0 :                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
    1112         [ #  # ]:          0 :                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
    1113         [ #  # ]:          0 :                     Execute( aSfxRequest );
    1114         [ #  # ]:          0 :                     aCurPos.Y() = nVRange;
    1115                 :          0 :                 }
    1116                 :            :             }
    1117                 :            :             else
    1118                 :          0 :                 aCurPos.Y() -= nVPage;
    1119                 :          0 :             break;
    1120                 :            :         case SID_CURSORPAGEDOWN:
    1121 [ #  # ][ #  # ]:          0 :             if( (abs(nVPage+nThumbPos-nRangeMax)<10) || nMaxVertPos<0 )
                 [ #  # ]
    1122                 :            :             {
    1123                 :          0 :                 long nPage = pPreview->GetPageNo();
    1124         [ #  # ]:          0 :                 long nTotal = pPreview->GetTotalPages();
    1125                 :            : 
    1126                 :            :                 // before testing for last page, make sure all page counts are calculated
    1127 [ #  # ][ #  # ]:          0 :                 if ( nPage+1 == nTotal && !pPreview->AllTested() )
                 [ #  # ]
    1128                 :            :                 {
    1129         [ #  # ]:          0 :                     pPreview->CalcAll();
    1130         [ #  # ]:          0 :                     nTotal = pPreview->GetTotalPages();
    1131                 :            :                 }
    1132         [ #  # ]:          0 :                 if( nPage<nTotal-1 )
    1133                 :            :                 {
    1134                 :          0 :                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
    1135         [ #  # ]:          0 :                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
    1136         [ #  # ]:          0 :                     Execute( aSfxRequest );
    1137         [ #  # ]:          0 :                     aCurPos.Y() = 0;
    1138                 :          0 :                 }
    1139                 :            :             }
    1140                 :            :             else
    1141                 :          0 :                 aCurPos.Y() += nVPage;
    1142                 :          0 :             break;
    1143                 :            :         case SID_CURSORHOME:
    1144         [ #  # ]:          0 :             if( nMaxVertPos<0 )
    1145                 :            :             {
    1146                 :          0 :                 long nPage  = pPreview->GetPageNo();
    1147         [ #  # ]:          0 :                 long nTotal = pPreview->GetTotalPages();
    1148 [ #  # ][ #  # ]:          0 :                 if( nTotal && nPage != 0 )
    1149                 :            :                 {
    1150                 :          0 :                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
    1151         [ #  # ]:          0 :                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_FIRST );
    1152 [ #  # ][ #  # ]:          0 :                     Execute( aSfxRequest );
    1153                 :            :                 }
    1154                 :            :             }
    1155                 :            :             else
    1156                 :            :             {
    1157                 :          0 :                 aCurPos.Y() = 0;
    1158                 :          0 :                 aCurPos.X() = 0;
    1159                 :            :             }
    1160                 :          0 :             break;
    1161                 :            :         case SID_CURSOREND:
    1162         [ #  # ]:          0 :             if( nMaxVertPos<0 )
    1163                 :            :             {
    1164         [ #  # ]:          0 :                 if( !pPreview->AllTested() )
    1165         [ #  # ]:          0 :                     pPreview->CalcAll();
    1166                 :          0 :                 long nPage  = pPreview->GetPageNo();
    1167         [ #  # ]:          0 :                 long nTotal = pPreview->GetTotalPages();
    1168 [ #  # ][ #  # ]:          0 :                 if( nTotal && nPage+1 != nTotal )
    1169                 :            :                 {
    1170                 :          0 :                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
    1171         [ #  # ]:          0 :                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_LAST );
    1172 [ #  # ][ #  # ]:          0 :                     Execute( aSfxRequest );
    1173                 :            :                 }
    1174                 :            :             }
    1175                 :            :             else
    1176                 :            :             {
    1177                 :          0 :                 aCurPos.Y() = nVRange;
    1178                 :          0 :                 aCurPos.X() = nHRange;
    1179                 :            :             }
    1180                 :          0 :             break;
    1181                 :            :     }
    1182                 :            : 
    1183                 :            :         // nHRange-nHPage kann negativ sein, deshalb Abfrage auf < 0 hinterher
    1184                 :            : 
    1185         [ #  # ]:          0 :     if( aCurPos.Y() > (nVRange-nVPage) )
    1186                 :          0 :         aCurPos.Y() = (nVRange-nVPage);
    1187         [ #  # ]:          0 :     if( aCurPos.Y() < 0 )
    1188                 :          0 :         aCurPos.Y() = 0;
    1189         [ #  # ]:          0 :     if( aCurPos.X() > (nHRange-nHPage) )
    1190                 :          0 :         aCurPos.X() = (nHRange-nHPage);
    1191         [ #  # ]:          0 :     if( aCurPos.X() < 0 )
    1192                 :          0 :         aCurPos.X() = 0;
    1193                 :            : 
    1194         [ #  # ]:          0 :     if( nMaxVertPos>=0 )
    1195                 :            :     {
    1196         [ #  # ]:          0 :         if( aCurPos.Y() != aPrevPos.Y() )
    1197                 :            :         {
    1198         [ #  # ]:          0 :             pVerScroll->SetThumbPos( aCurPos.Y() );
    1199         [ #  # ]:          0 :             pPreview->SetYOffset( aCurPos.Y() );
    1200                 :            :         }
    1201                 :            :     }
    1202                 :            : 
    1203         [ #  # ]:          0 :     if( aCurPos.X() != aPrevPos.X() )
    1204                 :            :     {
    1205         [ #  # ]:          0 :         pHorScroll->SetThumbPos( aCurPos.X() );
    1206         [ #  # ]:          0 :         pPreview->SetXOffset( aCurPos.X() );
    1207                 :            :     }
    1208                 :            : 
    1209                 :          0 : }
    1210                 :            : 
    1211                 :          0 : void ScPreviewShell::ExitPreview()
    1212                 :            : {
    1213                 :          0 :     GetViewFrame()->GetDispatcher()->Execute(SID_VIEWSHELL0, SFX_CALLMODE_ASYNCHRON);
    1214                 :          0 : }
    1215                 :            : 
    1216                 :        127 : void ScPreviewShell::AddAccessibilityObject( SfxListener& rObject )
    1217                 :            : {
    1218         [ +  + ]:        127 :     if (!pAccessibilityBroadcaster)
    1219         [ +  - ]:         16 :         pAccessibilityBroadcaster = new SfxBroadcaster;
    1220                 :            : 
    1221                 :        127 :     rObject.StartListening( *pAccessibilityBroadcaster );
    1222                 :        127 : }
    1223                 :            : 
    1224                 :        127 : void ScPreviewShell::RemoveAccessibilityObject( SfxListener& rObject )
    1225                 :            : {
    1226         [ +  - ]:        127 :     if (pAccessibilityBroadcaster)
    1227                 :        127 :         rObject.EndListening( *pAccessibilityBroadcaster );
    1228                 :            :     else
    1229                 :            :     {
    1230                 :            :         OSL_FAIL("kein Accessibility-Broadcaster?");
    1231                 :            :     }
    1232                 :        127 : }
    1233                 :            : 
    1234                 :         58 : void ScPreviewShell::BroadcastAccessibility( const SfxHint &rHint )
    1235                 :            : {
    1236         [ +  - ]:         58 :     if (pAccessibilityBroadcaster)
    1237                 :         58 :         pAccessibilityBroadcaster->Broadcast( rHint );
    1238                 :         58 : }
    1239                 :            : 
    1240                 :        119 : sal_Bool ScPreviewShell::HasAccessibilityObjects()
    1241                 :            : {
    1242 [ +  + ][ +  - ]:        119 :     return pAccessibilityBroadcaster && pAccessibilityBroadcaster->HasListeners();
    1243                 :            : }
    1244                 :            : 
    1245                 :       2360 : const ScPreviewLocationData& ScPreviewShell::GetLocationData()
    1246                 :            : {
    1247                 :       2360 :     return pPreview->GetLocationData();
    1248                 :            : }
    1249                 :            : 
    1250                 :        368 : ScDocument* ScPreviewShell::GetDocument()
    1251                 :            : {
    1252                 :        368 :     return pDocShell->GetDocument();
    1253                 :            : }
    1254                 :            : 
    1255                 :            : 
    1256                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10