LCOV - code coverage report
Current view: top level - sw/source/core/uibase/uiview - pview.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 911 0.0 %
Date: 2014-04-14 Functions: 0 77 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/objface.hxx>
      21             : #include <vcl/timer.hxx>
      22             : #include <vcl/field.hxx>
      23             : #include <vcl/fixed.hxx>
      24             : #include <vcl/help.hxx>
      25             : #include <vcl/cmdevt.hxx>
      26             : #include <vcl/button.hxx>
      27             : #include <vcl/settings.hxx>
      28             : 
      29             : #include <svl/whiter.hxx>
      30             : #include <svl/stritem.hxx>
      31             : #include <svl/eitem.hxx>
      32             : #include <sfx2/printer.hxx>
      33             : #include <sfx2/progress.hxx>
      34             : #include <sfx2/app.hxx>
      35             : #include <sfx2/bindings.hxx>
      36             : #include <sfx2/request.hxx>
      37             : #include <sfx2/dispatch.hxx>
      38             : #include <vcl/msgbox.hxx>
      39             : #include <svx/stddlg.hxx>
      40             : #include <editeng/paperinf.hxx>
      41             : #include <svl/srchitem.hxx>
      42             : #include <svx/svdview.hxx>
      43             : #include <svx/dlgutil.hxx>
      44             : #include <svx/zoomslideritem.hxx>
      45             : #include <svx/svxids.hrc>
      46             : 
      47             : #include <swwait.hxx>
      48             : #include <globdoc.hxx>
      49             : #include <wdocsh.hxx>
      50             : #include <pvprtdat.hxx>
      51             : #include <swmodule.hxx>
      52             : #include <modcfg.hxx>
      53             : #include <wrtsh.hxx>
      54             : #include <docsh.hxx>
      55             : #include <viewopt.hxx>
      56             : #include <doc.hxx>
      57             : #include <pview.hxx>
      58             : #include <view.hxx>
      59             : #include <textsh.hxx>
      60             : #include <scroll.hxx>
      61             : #include <prtopt.hxx>
      62             : #include <docstat.hxx>
      63             : #include <usrpref.hxx>
      64             : #include <viewfunc.hxx>
      65             : 
      66             : #include <helpid.h>
      67             : #include <cmdid.h>
      68             : #include <globals.hrc>
      69             : #include <popup.hrc>
      70             : #include <view.hrc>
      71             : 
      72             : #define SwPagePreview
      73             : #include <sfx2/msg.hxx>
      74             : #include <swslots.hxx>
      75             : #include <pagepreviewlayout.hxx>
      76             : 
      77             : #include <svx/svxdlg.hxx>
      78             : #include <svx/dialogs.hrc>
      79             : #include <osl/mutex.hxx>
      80             : 
      81             : #include <boost/scoped_ptr.hpp>
      82             : 
      83             : using namespace ::com::sun::star;
      84           0 : SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreview, "PrintPreview")
      85             : {
      86           0 :     SFX_VIEW_REGISTRATION(SwDocShell);
      87           0 :     SFX_VIEW_REGISTRATION(SwWebDocShell);
      88           0 :     SFX_VIEW_REGISTRATION(SwGlobalDocShell);
      89           0 : }
      90             : 
      91           0 : SFX_IMPL_INTERFACE(SwPagePreview, SfxViewShell, SW_RES(RID_PVIEW_TOOLBOX))
      92             : {
      93           0 :     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_PPREVIEW_POPUPMENU));
      94           0 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|
      95             :                                 SFX_VISIBILITY_CLIENT|SFX_VISIBILITY_FULLSCREEN|
      96             :                                 SFX_VISIBILITY_READONLYDOC,
      97           0 :                                 SW_RES(RID_PVIEW_TOOLBOX));
      98           0 : }
      99             : 
     100           0 : TYPEINIT1(SwPagePreview,SfxViewShell)
     101             : 
     102             : #define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT|SFX_VIEW_HAS_PRINTOPTIONS )
     103             : 
     104             : #define MIN_PREVIEW_ZOOM 25
     105             : #define MAX_PREVIEW_ZOOM 600
     106             : 
     107           0 : static sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, sal_Bool bZoomIn)
     108             : {
     109             :     static const sal_uInt16 aZoomArr[] =
     110             :     {
     111             :         25, 50, 75, 100, 150, 200, 400, 600
     112             :     };
     113           0 :     const sal_uInt16 nZoomArrSize = sizeof(aZoomArr)/sizeof(sal_uInt16);
     114           0 :     if(bZoomIn)
     115           0 :         for(int i = nZoomArrSize - 1; i >= 0; --i)
     116             :         {
     117           0 :             if(nCurrentZoom > aZoomArr[i] || !i)
     118           0 :                 return aZoomArr[i];
     119             :         }
     120             :     else
     121           0 :         for(int i = 0; i < nZoomArrSize; ++i)
     122             :         {
     123           0 :             if(nCurrentZoom < aZoomArr[i])
     124           0 :                 return aZoomArr[i];
     125             :         }
     126           0 :     return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM;
     127             : };
     128             : 
     129           0 : static void lcl_InvalidateZoomSlots(SfxBindings& rBindings)
     130             : {
     131             :     static sal_uInt16 const aInval[] =
     132             :     {
     133             :         SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, FN_PREVIEW_ZOOM, FN_STAT_ZOOM,
     134             :         0
     135             :     };
     136           0 :     rBindings.Invalidate( aInval );
     137           0 : }
     138             : 
     139             : // At first the zoom dialog
     140           0 : class SwPreviewZoomDlg : public SvxStandardDialog
     141             : {
     142             :     NumericField* m_pRowEdit;
     143             :     NumericField* m_pColEdit;
     144             : 
     145             :     virtual void  Apply() SAL_OVERRIDE;
     146             : 
     147             : public:
     148             :     SwPreviewZoomDlg( SwPagePreviewWin& rParent );
     149             : };
     150             : 
     151           0 : SwPreviewZoomDlg::SwPreviewZoomDlg( SwPagePreviewWin& rParent )
     152           0 :     : SvxStandardDialog(&rParent, "PreviewZoomDialog", "modules/swriter/ui/previewzoomdialog.ui")
     153             : {
     154           0 :     get(m_pRowEdit, "rows");
     155           0 :     get(m_pColEdit, "cols");
     156             : 
     157           0 :     m_pRowEdit->SetValue( rParent.GetRow() );
     158           0 :     m_pColEdit->SetValue( rParent.GetCol() );
     159           0 : }
     160             : 
     161           0 : void  SwPreviewZoomDlg::Apply()
     162             : {
     163           0 :     ((SwPagePreviewWin*)GetParent())->CalcWish(
     164           0 :                 sal_uInt8(m_pRowEdit->GetValue()),
     165           0 :                 sal_uInt8(m_pColEdit->GetValue()) );
     166           0 : }
     167             : 
     168             : // all for SwPagePreviewWin
     169           0 : SwPagePreviewWin::SwPagePreviewWin( Window *pParent, SwPagePreview& rPView )
     170             :     : Window(pParent, WinBits(WB_CLIPCHILDREN))
     171             :     , mpViewShell(0)
     172             :     , mrView(rPView)
     173             :     , mbCalcScaleForPreviewLayout(true)
     174             :     , maPaintedPreviewDocRect(Rectangle(0,0,0,0))
     175           0 :     , mpPgPreviewLayout(NULL)
     176             : {
     177           0 :     SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW );
     178           0 :     SetHelpId(HID_PAGEPREVIEW);
     179           0 :     SetFillColor( GetBackground().GetColor() );
     180           0 :     SetLineColor( GetBackground().GetColor());
     181           0 :     SetMapMode( MapMode(MAP_TWIP) );
     182             : 
     183           0 :     const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(sal_False);
     184           0 :     mnRow = pUsrPref->GetPagePrevRow();     // 1 row
     185           0 :     mnCol = pUsrPref->GetPagePrevCol();     // 1 column
     186           0 :     mnSttPage = USHRT_MAX;
     187           0 : }
     188             : 
     189           0 : SwPagePreviewWin::~SwPagePreviewWin()
     190             : {
     191           0 : }
     192             : 
     193           0 : void  SwPagePreviewWin::Paint( const Rectangle& rRect )
     194             : {
     195           0 :     if( !mpViewShell || !mpViewShell->GetLayout() )
     196           0 :         return;
     197             : 
     198           0 :     if( USHRT_MAX == mnSttPage )        // was never calculated ? (Init-Phase!)
     199             :     {
     200             :         // This is the size to which I always relate.
     201           0 :         if( !maPxWinSize.Height() || !maPxWinSize.Width() )
     202           0 :             maPxWinSize = GetOutputSizePixel();
     203             : 
     204           0 :         Rectangle aRect( LogicToPixel( rRect ));
     205             :         mpPgPreviewLayout->Prepare( 1, Point(0,0), maPxWinSize,
     206           0 :                                   mnSttPage, maPaintedPreviewDocRect );
     207           0 :         SetSelectedPage( 1 );
     208           0 :         mpPgPreviewLayout->Paint( PixelToLogic( aRect ) );
     209           0 :         SetPagePreview(mnRow, mnCol);
     210             :     }
     211             :     else
     212             :     {
     213           0 :         MapMode aMM( GetMapMode() );
     214           0 :         aMM.SetScaleX( maScale );
     215           0 :         aMM.SetScaleY( maScale );
     216           0 :         SetMapMode( aMM );
     217           0 :         mpPgPreviewLayout->Paint( rRect );
     218             :     }
     219             : }
     220             : 
     221           0 : void SwPagePreviewWin::CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol )
     222             : {
     223           0 :     if( !mpViewShell || !mpViewShell->GetLayout() )
     224           0 :         return;
     225             : 
     226           0 :     sal_uInt16 nOldCol = mnCol;
     227           0 :     mnRow = nNewRow;
     228           0 :     mnCol = nNewCol;
     229           0 :     sal_uInt16 nPages = mnRow * mnCol,
     230           0 :            nLastSttPg = mrView.GetPageCount()+1 > nPages
     231           0 :                             ? mrView.GetPageCount()+1 - nPages : 0;
     232           0 :     if( mnSttPage > nLastSttPg )
     233           0 :         mnSttPage = nLastSttPg;
     234             : 
     235           0 :     mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize, true );
     236             :     mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
     237           0 :                               mnSttPage, maPaintedPreviewDocRect );
     238           0 :     SetSelectedPage( mnSttPage );
     239           0 :     SetPagePreview(mnRow, mnCol);
     240           0 :     maScale = GetMapMode().GetScaleX();
     241             : 
     242             :     // If changes have taken place at the columns, the special case "single column"
     243             :     // must be considered and corrected if necessary.
     244           0 :     if( (1 == nOldCol) != (1 == mnCol) )
     245           0 :         mrView.ScrollDocSzChg();
     246             : 
     247             :     // Order must be maintained!
     248             :     // additional invalidate page status.
     249             :     static sal_uInt16 aInval[] =
     250             :     {
     251             :         SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN,
     252             :         FN_PREVIEW_ZOOM,
     253             :         FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
     254             :         FN_STAT_PAGE, FN_STAT_ZOOM,
     255             :         FN_SHOW_TWO_PAGES, FN_SHOW_MULTIPLE_PAGES,
     256             :         0
     257             :     };
     258           0 :     SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
     259           0 :     rBindings.Invalidate( aInval );
     260           0 :     rBindings.Update( FN_SHOW_TWO_PAGES );
     261           0 :     rBindings.Update( FN_SHOW_MULTIPLE_PAGES );
     262             :     // adjust scrollbars
     263           0 :     mrView.ScrollViewSzChg();
     264             : }
     265             : 
     266             : // mnSttPage is Absolute
     267           0 : int SwPagePreviewWin::MovePage( int eMoveMode )
     268             : {
     269             :     // number of pages up
     270           0 :     sal_uInt16 nPages = mnRow * mnCol;
     271           0 :     sal_uInt16 nNewSttPage = mnSttPage;
     272           0 :     sal_uInt16 nPageCount = mrView.GetPageCount();
     273           0 :     sal_uInt16 nDefSttPg = GetDefSttPage();
     274           0 :     bool bPaintPageAtFirstCol = true;
     275             : 
     276           0 :     switch( eMoveMode )
     277             :     {
     278             :     case MV_PAGE_UP:
     279             :     {
     280           0 :         const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
     281           0 :         const sal_uInt16 nNewAbsSttPage = nRelSttPage - nPages > 0 ?
     282           0 :                                           mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage - nPages ) :
     283           0 :                                           nDefSttPg;
     284           0 :         nNewSttPage = nNewAbsSttPage;
     285             : 
     286           0 :         const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
     287           0 :         const sal_uInt16 nNewRelSelPage = nRelSelPage - nPages > 0 ?
     288             :                                           nRelSelPage - nPages :
     289           0 :                                           1;
     290           0 :         SetSelectedPage( mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nNewRelSelPage ) );
     291             : 
     292           0 :         break;
     293             :     }
     294             :     case MV_PAGE_DOWN:
     295             :     {
     296           0 :         const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
     297           0 :         const sal_uInt16 nNewAbsSttPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage + nPages );
     298           0 :         nNewSttPage = nNewAbsSttPage < nPageCount ? nNewAbsSttPage : nPageCount;
     299             : 
     300           0 :         const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
     301           0 :         const sal_uInt16 nNewAbsSelPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSelPage + nPages );
     302           0 :         SetSelectedPage( nNewAbsSelPage < nPageCount ? nNewAbsSelPage : nPageCount );
     303             : 
     304           0 :         break;
     305             :     }
     306             :     case MV_DOC_STT:
     307           0 :         nNewSttPage = nDefSttPg;
     308           0 :         SetSelectedPage( mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nNewSttPage ? nNewSttPage : 1 ) );
     309           0 :         break;
     310             :     case MV_DOC_END:
     311             :         // correct calculation of new start page.
     312           0 :         nNewSttPage = nPageCount;
     313           0 :         SetSelectedPage( nPageCount );
     314           0 :         break;
     315             :     case MV_SELPAGE:
     316             :         // <nNewSttPage> and <SelectedPage()> are already set.
     317             :         // not start at first column, only if the
     318             :         // complete preview layout columns doesn't fit into window.
     319           0 :         if ( !mpPgPreviewLayout->DoesPreviewLayoutColsFitIntoWindow() )
     320           0 :             bPaintPageAtFirstCol = false;
     321           0 :         break;
     322             :     case MV_SCROLL:
     323             :         // check, if paint page at first column
     324             :         // has to be avoided
     325           0 :         if ( !mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() ||
     326           0 :              !mpPgPreviewLayout->DoesPreviewLayoutColsFitIntoWindow() )
     327           0 :             bPaintPageAtFirstCol = false;
     328           0 :         break;
     329             :     case MV_NEWWINSIZE:
     330             :         // nothing special to do.
     331           0 :         break;
     332             :     case MV_CALC:
     333             :         // re-init page preview layout.
     334           0 :         mpPgPreviewLayout->ReInit();
     335             : 
     336             :         // correct calculation of new start page.
     337           0 :         if( nNewSttPage > nPageCount )
     338           0 :             nNewSttPage = nPageCount;
     339             : 
     340             :         // correct selected page number
     341           0 :         if( SelectedPage() > nPageCount )
     342           0 :             SetSelectedPage( nNewSttPage ? nNewSttPage : 1 );
     343             :     }
     344             : 
     345             :     mpPgPreviewLayout->Prepare( nNewSttPage, Point(0,0), maPxWinSize,
     346             :                               nNewSttPage,
     347           0 :                               maPaintedPreviewDocRect, bPaintPageAtFirstCol );
     348           0 :     if( nNewSttPage == mnSttPage &&
     349             :         eMoveMode != MV_SELPAGE )
     350           0 :         return sal_False;
     351             : 
     352           0 :     SetPagePreview(mnRow, mnCol);
     353           0 :     mnSttPage = nNewSttPage;
     354             : 
     355             :     // additional invalidate page status.
     356             :     static sal_uInt16 aInval[] =
     357             :     {
     358             :         FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
     359             :         FN_STAT_PAGE, 0
     360             :     };
     361             : 
     362           0 :     SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
     363           0 :     rBindings.Invalidate( aInval );
     364             : 
     365           0 :     return sal_True;
     366             : }
     367             : 
     368           0 : void SwPagePreviewWin::SetWinSize( const Size& rNewSize )
     369             : {
     370             :     // We always want the size as pixel units.
     371           0 :     maPxWinSize = LogicToPixel( rNewSize );
     372             : 
     373           0 :     if( USHRT_MAX == mnSttPage )
     374             :     {
     375           0 :         mnSttPage = GetDefSttPage();
     376           0 :         SetSelectedPage( GetDefSttPage() );
     377             :     }
     378             : 
     379           0 :     if ( mbCalcScaleForPreviewLayout )
     380             :     {
     381           0 :         mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize, true );
     382           0 :         maScale = GetMapMode().GetScaleX();
     383             :     }
     384             :     mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
     385           0 :                               mnSttPage, maPaintedPreviewDocRect );
     386           0 :     if ( mbCalcScaleForPreviewLayout )
     387             :     {
     388           0 :         SetSelectedPage( mnSttPage );
     389           0 :         mbCalcScaleForPreviewLayout = false;
     390             :     }
     391           0 :     SetPagePreview(mnRow, mnCol);
     392           0 :     maScale = GetMapMode().GetScaleX();
     393           0 : }
     394             : 
     395           0 : OUString SwPagePreviewWin::GetStatusStr( sal_uInt16 nPageCnt ) const
     396             : {
     397             :     // show physical and virtual page number of
     398             :     // selected page, if it's visible.
     399             :     sal_uInt16 nPageNum;
     400           0 :     if ( mpPgPreviewLayout->IsPageVisible( mpPgPreviewLayout->SelectedPage() ) )
     401             :     {
     402           0 :         nPageNum = mpPgPreviewLayout->SelectedPage();
     403             :     }
     404             :     else
     405             :     {
     406           0 :         nPageNum = mnSttPage > 1 ? mnSttPage : 1;
     407             :     }
     408           0 :     OUStringBuffer aStatusStr;
     409           0 :     sal_uInt16 nVirtPageNum = mpPgPreviewLayout->GetVirtPageNumByPageNum( nPageNum );
     410           0 :     if( nVirtPageNum && nVirtPageNum != nPageNum )
     411             :     {
     412           0 :         aStatusStr.append( OUString::number(nVirtPageNum) + " " );
     413             :     }
     414           0 :     aStatusStr.append( OUString::number(nPageNum) + " / " + OUString::number(nPageCnt) );
     415           0 :     return aStatusStr.makeStringAndClear();
     416             : }
     417             : 
     418           0 : void  SwPagePreviewWin::KeyInput( const KeyEvent &rKEvt )
     419             : {
     420           0 :     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
     421           0 :     sal_uInt16 nKey = rKeyCode.GetCode();
     422           0 :     bool bHandled = false;
     423           0 :     if(!rKeyCode.GetModifier())
     424             :     {
     425           0 :         sal_uInt16 nSlot = 0;
     426           0 :         switch(nKey)
     427             :         {
     428           0 :             case KEY_ADD : nSlot = SID_ZOOM_OUT;         break;
     429           0 :             case KEY_ESCAPE: nSlot = FN_CLOSE_PAGEPREVIEW; break;
     430           0 :             case KEY_SUBTRACT : nSlot = SID_ZOOM_IN;    break;
     431             :         }
     432           0 :         if(nSlot)
     433             :         {
     434           0 :             bHandled = true;
     435             :             mrView.GetViewFrame()->GetDispatcher()->Execute(
     436           0 :                                 nSlot, SFX_CALLMODE_ASYNCHRON );
     437             :         }
     438             :     }
     439           0 :     if( !bHandled && !mrView.KeyInput( rKEvt ) )
     440           0 :         Window::KeyInput( rKEvt );
     441           0 : }
     442             : 
     443           0 : void SwPagePreviewWin::Command( const CommandEvent& rCEvt )
     444             : {
     445           0 :     bool bCallBase = true;
     446           0 :     switch( rCEvt.GetCommand() )
     447             :     {
     448             :         case COMMAND_CONTEXTMENU:
     449           0 :             mrView.GetViewFrame()->GetDispatcher()->ExecutePopup();
     450           0 :             bCallBase = false;
     451           0 :         break;
     452             : 
     453             :         case COMMAND_WHEEL:
     454             :         case COMMAND_STARTAUTOSCROLL:
     455             :         case COMMAND_AUTOSCROLL:
     456             :         {
     457           0 :             const CommandWheelData* pData = rCEvt.GetWheelData();
     458           0 :             if( pData )
     459             :             {
     460             :                 const CommandWheelData aDataNew(pData->GetDelta(),pData->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL,
     461           0 :                     pData->GetMode(),pData->GetModifier(),pData->IsHorz(), pData->IsDeltaPixel());
     462           0 :                 const CommandEvent aEvent( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),rCEvt.IsMouseEvent(),&aDataNew);
     463           0 :                     bCallBase = !mrView.HandleWheelCommands( aEvent );
     464             :             }
     465             :             else
     466           0 :                 bCallBase = !mrView.HandleWheelCommands( rCEvt );
     467             :        }
     468           0 :        break;
     469             :        default:
     470             :            ;
     471             :     }
     472             : 
     473           0 :     if( bCallBase )
     474           0 :         Window::Command( rCEvt );
     475           0 : }
     476             : 
     477           0 : void SwPagePreviewWin::MouseButtonDown( const MouseEvent& rMEvt )
     478             : {
     479             :     // consider single-click to set selected page
     480           0 :     if( MOUSE_LEFT == ( rMEvt.GetModifier() + rMEvt.GetButtons() ) )
     481             :     {
     482           0 :         Point aPreviewPos( PixelToLogic( rMEvt.GetPosPixel() ) );
     483           0 :         Point aDocPos;
     484             :         bool bPosInEmptyPage;
     485             :         sal_uInt16 nNewSelectedPage;
     486             :         bool bIsDocPos =
     487             :             mpPgPreviewLayout->IsPreviewPosInDocPreviewPage( aPreviewPos,
     488           0 :                                     aDocPos, bPosInEmptyPage, nNewSelectedPage );
     489           0 :         if ( bIsDocPos && rMEvt.GetClicks() == 2 )
     490             :         {
     491             :             // close page preview, set new cursor position and switch to
     492             :             // normal view.
     493           0 :             OUString sNewCrsrPos = OUString::number( aDocPos.X() ) + ";" +
     494           0 :                                    OUString::number( aDocPos.Y() ) + ";";
     495           0 :             mrView.SetNewCrsrPos( sNewCrsrPos );
     496             : 
     497           0 :             SfxViewFrame *pTmpFrm = mrView.GetViewFrame();
     498           0 :             pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
     499           0 :                                                     SFX_CALLMODE_ASYNCHRON );
     500             :         }
     501           0 :         else if ( bIsDocPos || bPosInEmptyPage )
     502             :         {
     503             :             // show clicked page as the selected one
     504           0 :             mpPgPreviewLayout->MarkNewSelectedPage( nNewSelectedPage );
     505           0 :             GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
     506             :             // adjust position at vertical scrollbar.
     507           0 :             if ( mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() )
     508             :             {
     509           0 :                 mrView.SetVScrollbarThumbPos( nNewSelectedPage );
     510             :             }
     511             :             // invalidate page status.
     512             :             static sal_uInt16 aInval[] =
     513             :             {
     514             :                 FN_STAT_PAGE, 0
     515             :             };
     516           0 :             SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
     517           0 :             rBindings.Invalidate( aInval );
     518             :         }
     519             :     }
     520           0 : }
     521             : 
     522             : // Set user prefs or view options
     523             : 
     524           0 : void SwPagePreviewWin::SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol )
     525             : {
     526           0 :     SwMasterUsrPref *pOpt = (SwMasterUsrPref *)SW_MOD()->GetUsrPref(sal_False);
     527             : 
     528           0 :     if (nRow != pOpt->GetPagePrevRow() || nCol != pOpt->GetPagePrevCol())
     529             :     {
     530           0 :         pOpt->SetPagePrevRow( nRow );
     531           0 :         pOpt->SetPagePrevCol( nCol );
     532           0 :         pOpt->SetModified();
     533             : 
     534             :         // Update scrollbar!
     535           0 :         mrView.ScrollViewSzChg();
     536             :     }
     537           0 : }
     538             : 
     539             : /** get selected page in document preview
     540             : 
     541             :     @author OD
     542             : */
     543           0 : sal_uInt16 SwPagePreviewWin::SelectedPage() const
     544             : {
     545           0 :     return mpPgPreviewLayout->SelectedPage();
     546             : }
     547             : 
     548             : /** set selected page number in document preview
     549             : 
     550             :     @author OD
     551             : */
     552           0 : void SwPagePreviewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum )
     553             : {
     554           0 :     mpPgPreviewLayout->SetSelectedPage( _nSelectedPageNum );
     555           0 : }
     556             : 
     557             : /** method to enable/disable book preview
     558             : 
     559             :     @author OD
     560             : */
     561           0 : bool SwPagePreviewWin::SetBookPreviewMode( const bool _bBookPreview )
     562             : {
     563             :     return mpPgPreviewLayout->SetBookPreviewMode( _bBookPreview,
     564             :                                                 mnSttPage,
     565           0 :                                                 maPaintedPreviewDocRect );
     566             : }
     567             : 
     568           0 : void SwPagePreviewWin::DataChanged( const DataChangedEvent& rDCEvt )
     569             : {
     570           0 :     Window::DataChanged( rDCEvt );
     571             : 
     572           0 :     switch( rDCEvt.GetType() )
     573             :     {
     574             :     case DATACHANGED_SETTINGS:
     575             :         // Rearrange the scrollbars or trigger resize, because the
     576             :         // size of the scrollbars may have be changed. Also the
     577             :         // size of the scrollbars has to be retrieved from the settings
     578             :         // out of the resize handler.
     579           0 :         if( rDCEvt.GetFlags() & SETTINGS_STYLE )
     580           0 :             mrView.InvalidateBorder();              // Scrollbar widths
     581             :         // zoom has to be disabled if Accessibility support is switched on
     582           0 :         lcl_InvalidateZoomSlots(mrView.GetViewFrame()->GetBindings());
     583           0 :         break;
     584             : 
     585             :     case DATACHANGED_PRINTER:
     586             :     case DATACHANGED_DISPLAY:
     587             :     case DATACHANGED_FONTS:
     588             :     case DATACHANGED_FONTSUBSTITUTION:
     589           0 :         mrView.GetDocShell()->UpdateFontList(); // Font change
     590           0 :         if ( mpViewShell->GetWin() )
     591           0 :             mpViewShell->GetWin()->Invalidate();
     592           0 :         break;
     593             :     }
     594           0 : }
     595             : 
     596             : /** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN
     597             : 
     598             :     @author OD
     599             : */
     600           0 : void SwPagePreview::_ExecPgUpAndPgDown( const bool  _bPgUp,
     601             :                                         SfxRequest* _pReq )
     602             : {
     603           0 :     SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
     604             :     // check, if top/bottom of preview is *not* already visible.
     605           0 :     if( pPagePreviewLay->GetWinPagesScrollAmount( _bPgUp ? -1 : 1 ) != 0 )
     606             :     {
     607           0 :         if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() &&
     608           0 :              pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
     609             :         {
     610             :             const int eMvMode = _bPgUp ?
     611             :                                 SwPagePreviewWin::MV_PAGE_UP :
     612           0 :                                 SwPagePreviewWin::MV_PAGE_DOWN;
     613           0 :             if ( ChgPage( eMvMode, sal_True ) )
     614           0 :                 pViewWin->Invalidate();
     615             :         }
     616             :         else
     617             :         {
     618             :             SwTwips nScrollAmount;
     619           0 :             sal_uInt16 nNewSelectedPageNum = 0;
     620           0 :             const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
     621           0 :             if( _bPgUp )
     622             :             {
     623           0 :                 if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
     624             :                 {
     625           0 :                     nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( -1 );
     626           0 :                     if ( (pViewWin->SelectedPage() - nVisPages) > 0 )
     627           0 :                         nNewSelectedPageNum = pViewWin->SelectedPage() - nVisPages;
     628             :                     else
     629           0 :                         nNewSelectedPageNum = 1;
     630             :                 }
     631             :                 else
     632           0 :                     nScrollAmount = - std::min( pViewWin->GetOutputSize().Height(),
     633           0 :                                            pViewWin->GetPaintedPreviewDocRect().Top() );
     634             :             }
     635             :             else
     636             :             {
     637           0 :                 if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
     638             :                 {
     639           0 :                     nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( 1 );
     640           0 :                     if ( (pViewWin->SelectedPage() + nVisPages) <= mnPageCount )
     641           0 :                         nNewSelectedPageNum = pViewWin->SelectedPage() + nVisPages;
     642             :                     else
     643           0 :                         nNewSelectedPageNum = mnPageCount;
     644             :                 }
     645             :                 else
     646           0 :                     nScrollAmount = std::min( pViewWin->GetOutputSize().Height(),
     647           0 :                                          ( pPagePreviewLay->GetPreviewDocSize().Height() -
     648           0 :                                            pViewWin->GetPaintedPreviewDocRect().Bottom() ) );
     649             :             }
     650           0 :             pViewWin->Scroll( 0, nScrollAmount );
     651           0 :             if ( nNewSelectedPageNum != 0 )
     652             :             {
     653           0 :                 pViewWin->SetSelectedPage( nNewSelectedPageNum );
     654             :             }
     655           0 :             ScrollViewSzChg();
     656             :             // additional invalidate page status.
     657             :             static sal_uInt16 aInval[] =
     658             :             {
     659             :                 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
     660             :                 FN_STAT_PAGE, 0
     661             :             };
     662           0 :             SfxBindings& rBindings = GetViewFrame()->GetBindings();
     663           0 :             rBindings.Invalidate( aInval );
     664           0 :             pViewWin->Invalidate();
     665             :         }
     666             :     }
     667             : 
     668           0 :     if ( _pReq )
     669           0 :         _pReq->Done();
     670           0 : }
     671             : 
     672             : // Then all for the SwPagePreview
     673           0 : void  SwPagePreview::Execute( SfxRequest &rReq )
     674             : {
     675             :     int eMvMode;
     676           0 :     sal_uInt8 nRow = 1;
     677           0 :     bool bRetVal = false;
     678           0 :     bool bRefresh = true;
     679             : 
     680           0 :     switch(rReq.GetSlot())
     681             :     {
     682             :         case FN_REFRESH_VIEW:
     683             :         case FN_STAT_PAGE:
     684             :         case FN_STAT_ZOOM:
     685           0 :             break;
     686             : 
     687             :         case FN_SHOW_MULTIPLE_PAGES:
     688             :         {
     689           0 :             const SfxItemSet *pArgs = rReq.GetArgs();
     690           0 :             if( pArgs && pArgs->Count() >= 2 )
     691             :             {
     692             :                 sal_uInt8 nCols = (sal_uInt8)((SfxUInt16Item &)pArgs->Get(
     693           0 :                                         SID_ATTR_TABLE_COLUMN)).GetValue();
     694             :                 sal_uInt8 nRows = (sal_uInt8)((SfxUInt16Item &)pArgs->Get(
     695           0 :                                         SID_ATTR_TABLE_ROW)).GetValue();
     696           0 :                 pViewWin->CalcWish( nRows, nCols );
     697             : 
     698             :             }
     699             :             else
     700           0 :                 SwPreviewZoomDlg( *pViewWin ).Execute();
     701             : 
     702             :         }
     703           0 :         break;
     704             :         case FN_SHOW_BOOKVIEW:
     705             :         {
     706           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
     707             :             const SfxPoolItem* pItem;
     708           0 :             bool bBookPreview = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
     709           0 :             if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_SHOW_BOOKVIEW, false, &pItem ) )
     710             :             {
     711           0 :                 bBookPreview = static_cast< const SfxBoolItem* >( pItem )->GetValue();
     712           0 :                 ( ( SwViewOption* ) GetViewShell()->GetViewOptions() )->SetPagePrevBookview( bBookPreview );
     713             :                     // cast is not gentleman like, but it's common use in writer and in this case
     714             :             }
     715           0 :             if ( pViewWin->SetBookPreviewMode( bBookPreview ) )
     716             :             {
     717             :                 // book preview mode changed. Thus, adjust scrollbars and
     718             :                 // invalidate corresponding states.
     719           0 :                 ScrollViewSzChg();
     720             :                 static sal_uInt16 aInval[] =
     721             :                 {
     722             :                     FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
     723             :                     FN_STAT_PAGE, FN_SHOW_BOOKVIEW, 0
     724             :                 };
     725           0 :                 SfxBindings& rBindings = GetViewFrame()->GetBindings();
     726           0 :                 rBindings.Invalidate( aInval );
     727           0 :                 pViewWin->Invalidate();
     728             :             }
     729             : 
     730             :         }
     731           0 :         break;
     732             :         case FN_SHOW_TWO_PAGES:
     733           0 :             pViewWin->CalcWish( nRow, 2 );
     734           0 :             break;
     735             : 
     736             :         case FN_PREVIEW_ZOOM:
     737             :         case SID_ATTR_ZOOM:
     738             :         {
     739           0 :             const SfxItemSet *pArgs = rReq.GetArgs();
     740             :             const SfxPoolItem* pItem;
     741           0 :             boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
     742           0 :             if(!pArgs)
     743             :             {
     744           0 :                 SfxItemSet aCoreSet(GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM);
     745           0 :                 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
     746             :                 SvxZoomItem aZoom( (SvxZoomType)pVOpt->GetZoomType(),
     747           0 :                                             pVOpt->GetZoom() );
     748             :                 aZoom.SetValueSet(
     749             :                         SVX_ZOOM_ENABLE_50|
     750             :                         SVX_ZOOM_ENABLE_75|
     751             :                         SVX_ZOOM_ENABLE_100|
     752             :                         SVX_ZOOM_ENABLE_150|
     753             :                         SVX_ZOOM_ENABLE_200|
     754           0 :                         SVX_ZOOM_ENABLE_WHOLEPAGE);
     755           0 :                 aCoreSet.Put( aZoom );
     756             : 
     757           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     758           0 :                 if(pFact)
     759             :                 {
     760           0 :                     pDlg.reset(pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet));
     761             :                     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     762             :                 }
     763             : 
     764           0 :                 pDlg->SetLimits( MINZOOM, MAXZOOM );
     765             : 
     766           0 :                 if( pDlg->Execute() != RET_CANCEL )
     767           0 :                     pArgs = pDlg->GetOutputItemSet();
     768             :             }
     769           0 :             if( pArgs )
     770             :             {
     771           0 :                 enum SvxZoomType eType = SVX_ZOOM_PERCENT;
     772           0 :                 sal_uInt16 nZoomFactor = USHRT_MAX;
     773           0 :                 if(SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOM, true, &pItem))
     774             :                 {
     775           0 :                     eType = ((const SvxZoomItem *)pItem)->GetType();
     776           0 :                     nZoomFactor = ((const SvxZoomItem *)pItem)->GetValue();
     777             :                 }
     778           0 :                 else if(SFX_ITEM_SET == pArgs->GetItemState(FN_PREVIEW_ZOOM, true, &pItem))
     779           0 :                     nZoomFactor = ((const SfxUInt16Item *)pItem)->GetValue();
     780           0 :                 if(USHRT_MAX != nZoomFactor)
     781           0 :                     SetZoom(eType, nZoomFactor);
     782           0 :             }
     783             :         }
     784           0 :         break;
     785             :         case SID_ATTR_ZOOMSLIDER :
     786             :         {
     787           0 :             const SfxItemSet *pArgs = rReq.GetArgs();
     788             :             const SfxPoolItem* pItem;
     789             : 
     790           0 :             if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ) )
     791             :             {
     792           0 :                 const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
     793           0 :                 SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
     794             :             }
     795             :         }
     796           0 :         break;
     797             :         case SID_ZOOM_IN:
     798             :         case SID_ZOOM_OUT:
     799             :         {
     800           0 :             enum SvxZoomType eType = SVX_ZOOM_PERCENT;
     801           0 :             const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
     802             :             SetZoom(eType,
     803           0 :                     lcl_GetNextZoomStep(pVOpt->GetZoom(), SID_ZOOM_IN == rReq.GetSlot()));
     804             :         }
     805           0 :         break;
     806             :         case FN_CHAR_LEFT:
     807             :         case FN_CHAR_RIGHT:
     808             :         case FN_LINE_UP:
     809             :         case FN_LINE_DOWN:
     810             :         {
     811           0 :             SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
     812             :             sal_uInt16 nNewSelectedPage;
     813             :             sal_uInt16 nNewStartPage;
     814           0 :             Point aNewStartPos;
     815           0 :             sal_Int16 nHoriMove = 0;
     816           0 :             sal_Int16 nVertMove = 0;
     817           0 :             switch(rReq.GetSlot())
     818             :             {
     819           0 :                 case FN_CHAR_LEFT:  nHoriMove = -1; break;
     820           0 :                 case FN_CHAR_RIGHT: nHoriMove = 1;  break;
     821           0 :                 case FN_LINE_UP:    nVertMove = -1; break;
     822           0 :                 case FN_LINE_DOWN:  nVertMove = 1;  break;
     823             :             }
     824             :             pPagePreviewLay->CalcStartValuesForSelectedPageMove( nHoriMove, nVertMove,
     825           0 :                                 nNewSelectedPage, nNewStartPage, aNewStartPos );
     826           0 :             if ( pViewWin->SelectedPage() != nNewSelectedPage )
     827             :             {
     828           0 :                 if ( pPagePreviewLay->IsPageVisible( nNewSelectedPage ) )
     829             :                 {
     830           0 :                     pPagePreviewLay->MarkNewSelectedPage( nNewSelectedPage );
     831             :                     // adjust position at vertical scrollbar.
     832           0 :                     SetVScrollbarThumbPos( nNewSelectedPage );
     833           0 :                     bRefresh = false;
     834             :                 }
     835             :                 else
     836             :                 {
     837           0 :                     pViewWin->SetSelectedPage( nNewSelectedPage );
     838           0 :                     pViewWin->SetSttPage( nNewStartPage );
     839           0 :                     bRefresh = ChgPage( SwPagePreviewWin::MV_SELPAGE, sal_True );
     840             :                 }
     841           0 :                 GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
     842             :                 // invalidate page status.
     843             :                 static sal_uInt16 aInval[] =
     844             :                 {
     845             :                     FN_STAT_PAGE, 0
     846             :                 };
     847           0 :                 SfxBindings& rBindings = GetViewFrame()->GetBindings();
     848           0 :                 rBindings.Invalidate( aInval );
     849           0 :                 rReq.Done();
     850             :             }
     851             :             else
     852             :             {
     853           0 :                 bRefresh = false;
     854             :             }
     855           0 :             break;
     856             :         }
     857             :         case FN_PAGEUP:
     858             :         case FN_PAGEDOWN:
     859             :         {
     860           0 :             _ExecPgUpAndPgDown( rReq.GetSlot() == FN_PAGEUP, &rReq );
     861           0 :             break;
     862             :         }
     863             :         case FN_START_OF_LINE:
     864             :         case FN_START_OF_DOCUMENT:
     865           0 :             pViewWin->SetSelectedPage( 1 );
     866           0 :             eMvMode = SwPagePreviewWin::MV_DOC_STT; bRetVal = true; goto MOVEPAGE;
     867             :         case FN_END_OF_LINE:
     868             :         case FN_END_OF_DOCUMENT:
     869           0 :             pViewWin->SetSelectedPage( mnPageCount );
     870           0 :             eMvMode = SwPagePreviewWin::MV_DOC_END; bRetVal = true; goto MOVEPAGE;
     871             : MOVEPAGE:
     872             :             {
     873           0 :                 bool nRet = ChgPage( eMvMode, sal_True );
     874             :                 // return value fuer Basic
     875           0 :                 if(bRetVal)
     876           0 :                     rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !nRet));
     877             : 
     878           0 :                 bRefresh = nRet;
     879           0 :                 rReq.Done();
     880             :             }
     881           0 :             break;
     882             : 
     883             :         case FN_PRINT_PAGEPREVIEW:
     884             :         {
     885           0 :             const SwPagePreviewPrtData* pPPVPD = pViewWin->GetViewShell()->GetDoc()->GetPreviewPrtData();
     886             :             // The thing with the orientation
     887           0 :             if(pPPVPD)
     888             :             {
     889           0 :                 SfxPrinter* pPrinter = GetPrinter( true );
     890           0 :                 if((pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE)
     891           0 :                         != pPPVPD->GetLandscape())
     892           0 :                     pPrinter->SetOrientation(pPPVPD->GetLandscape() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
     893             :             }
     894           0 :             ::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False );
     895           0 :             bNormalPrint = sal_False;
     896           0 :             sal_uInt16 nPrtSlot = SID_PRINTDOC;
     897           0 :             rReq.SetSlot( nPrtSlot );
     898           0 :             SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
     899           0 :             rReq.SetSlot( FN_PRINT_PAGEPREVIEW );
     900           0 :             return;
     901             :         }
     902             :         case SID_PRINTDOCDIRECT:
     903             :         case SID_PRINTDOC:
     904           0 :             ::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False );
     905           0 :             bNormalPrint = sal_True;
     906           0 :             SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
     907           0 :             return;
     908             :         case FN_CLOSE_PAGEPREVIEW:
     909             :         case SID_PRINTPREVIEW:
     910             :             //  print preview is now always in the same frame as the tab view
     911             :             //  -> always switch this frame back to normal view
     912             :             //  (ScTabViewShell ctor reads stored view data)
     913           0 :             GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, 0, 0, SFX_CALLMODE_ASYNCHRON );
     914           0 :             break;
     915             :         case FN_INSERT_BREAK:
     916             :         {
     917           0 :             sal_uInt16 nSelPage = pViewWin->SelectedPage();
     918             :             //if a dummy page is selected (e.g. a non-existing right/left page)
     919             :             //the direct neighbor is used
     920           0 :             if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage ))
     921           0 :                 nSelPage +=2;
     922           0 :             SetNewPage( nSelPage );
     923           0 :             SfxViewFrame *pTmpFrm = GetViewFrame();
     924           0 :             pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
     925           0 :                                                     SFX_CALLMODE_ASYNCHRON );
     926             :         }
     927           0 :         break;
     928             :         default:
     929             :             OSL_ENSURE(!this, "wrong dispatcher");
     930           0 :             return;
     931             :     }
     932             : 
     933           0 :     if( bRefresh )
     934           0 :         pViewWin->Invalidate();
     935             : }
     936             : 
     937           0 : void  SwPagePreview::GetState( SfxItemSet& rSet )
     938             : {
     939           0 :     SfxWhichIter aIter(rSet);
     940           0 :     sal_uInt8 nRow = 1;
     941           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     942             :     OSL_ENSURE(nWhich, "empty set");
     943           0 :     SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
     944             : 
     945           0 :     while(nWhich)
     946             :     {
     947           0 :         switch(nWhich)
     948             :         {
     949             :         case SID_BROWSER_MODE:
     950             :         case FN_PRINT_LAYOUT:
     951           0 :             rSet.DisableItem(nWhich);
     952           0 :             break;
     953             :         case FN_START_OF_DOCUMENT:
     954             :         {
     955           0 :             if ( pPagePreviewLay->IsPageVisible( 1 ) )
     956           0 :                 rSet.DisableItem(nWhich);
     957           0 :             break;
     958             :         }
     959             :         case FN_END_OF_DOCUMENT:
     960             :         {
     961           0 :             if ( pPagePreviewLay->IsPageVisible( mnPageCount ) )
     962           0 :                 rSet.DisableItem(nWhich);
     963           0 :             break;
     964             :         }
     965             :         case FN_PAGEUP:
     966             :         {
     967           0 :             if( pPagePreviewLay->GetWinPagesScrollAmount( -1 ) == 0 )
     968           0 :                 rSet.DisableItem(nWhich);
     969           0 :             break;
     970             :         }
     971             :         case FN_PAGEDOWN:
     972             :         {
     973           0 :             if( pPagePreviewLay->GetWinPagesScrollAmount( 1 ) == 0 )
     974           0 :                 rSet.DisableItem(nWhich);
     975           0 :             break;
     976             :         }
     977             : 
     978             :         case FN_STAT_PAGE:
     979             :             {
     980           0 :                 OUString aStr = sPageStr + pViewWin->GetStatusStr( mnPageCount );
     981           0 :                 rSet.Put( SfxStringItem( nWhich, aStr) );
     982             :             }
     983           0 :             break;
     984             : 
     985             :         case SID_ATTR_ZOOM:
     986             :         case FN_STAT_ZOOM:
     987             :             {
     988           0 :                     const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
     989             :                     SvxZoomItem aZoom((SvxZoomType)pVOpt->GetZoomType(),
     990           0 :                                         pVOpt->GetZoom());
     991             :                     aZoom.SetValueSet(
     992             :                             SVX_ZOOM_ENABLE_50|
     993             :                             SVX_ZOOM_ENABLE_75|
     994             :                             SVX_ZOOM_ENABLE_100|
     995             :                             SVX_ZOOM_ENABLE_150|
     996           0 :                             SVX_ZOOM_ENABLE_200);
     997           0 :                     rSet.Put( aZoom );
     998             :             }
     999           0 :         break;
    1000             :         case SID_ATTR_ZOOMSLIDER :
    1001             :             {
    1002           0 :                     const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
    1003           0 :                     const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
    1004           0 :                     SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
    1005           0 :                     aZoomSliderItem.AddSnappingPoint( 100 );
    1006           0 :                     rSet.Put( aZoomSliderItem );
    1007             :             }
    1008           0 :         break;
    1009             :         case FN_PREVIEW_ZOOM:
    1010             :         {
    1011           0 :                 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
    1012           0 :                 rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom()));
    1013             :         }
    1014           0 :         break;
    1015             :         case SID_ZOOM_IN:
    1016             :         case SID_ZOOM_OUT:
    1017             :         {
    1018           0 :             const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
    1019           0 :             if((SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM)||
    1020           0 :               (SID_ZOOM_IN == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM))
    1021             :             {
    1022           0 :                 rSet.DisableItem(nWhich);
    1023             :             }
    1024             :         }
    1025           0 :         break;
    1026             :         case FN_SHOW_MULTIPLE_PAGES:
    1027             :         // should never be disabled
    1028           0 :         break;
    1029             :         case FN_SHOW_BOOKVIEW:
    1030             :         {
    1031           0 :             sal_Bool b = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
    1032           0 :             rSet.Put(SfxBoolItem(nWhich, b));
    1033             :         }
    1034           0 :         break;
    1035             : 
    1036             :         case FN_SHOW_TWO_PAGES:
    1037           0 :             if( 2 == pViewWin->GetCol() && nRow == pViewWin->GetRow() )
    1038           0 :                 rSet.DisableItem( nWhich );
    1039           0 :             break;
    1040             : 
    1041             :         case FN_PRINT_PAGEPREVIEW:
    1042             :             // has the same status like the normal printing
    1043             :             {
    1044             :                 const SfxPoolItem* pItem;
    1045           0 :                 SfxItemSet aSet( *rSet.GetPool(), SID_PRINTDOC, SID_PRINTDOC );
    1046           0 :                 GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet );
    1047           0 :                 if( SFX_ITEM_DISABLED == aSet.GetItemState( SID_PRINTDOC,
    1048           0 :                         false, &pItem ))
    1049           0 :                     rSet.DisableItem( nWhich );
    1050           0 :                 else if( SFX_ITEM_SET == aSet.GetItemState( SID_PRINTDOC,
    1051           0 :                         false, &pItem ))
    1052             :                 {
    1053           0 :                     ((SfxPoolItem*)pItem)->SetWhich( FN_PRINT_PAGEPREVIEW );
    1054           0 :                     rSet.Put( *pItem );
    1055           0 :                 }
    1056             :             }
    1057           0 :             break;
    1058             : 
    1059             :         case SID_PRINTPREVIEW:
    1060           0 :             rSet.Put( SfxBoolItem( nWhich, true ) );
    1061           0 :             break;
    1062             : 
    1063             :         case SID_PRINTDOC:
    1064             :         case SID_PRINTDOCDIRECT:
    1065           0 :             GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
    1066           0 :             break;
    1067             :         }
    1068           0 :         nWhich = aIter.NextWhich();
    1069           0 :     }
    1070           0 : }
    1071             : 
    1072           0 : void  SwPagePreview::StateUndo(SfxItemSet& rSet)
    1073             : {
    1074           0 :     SfxWhichIter aIter(rSet);
    1075           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1076             : 
    1077           0 :     while (nWhich)
    1078             :     {
    1079           0 :         rSet.DisableItem(nWhich);
    1080           0 :         nWhich = aIter.NextWhich();
    1081           0 :     }
    1082           0 : }
    1083             : 
    1084           0 : void SwPagePreview::Init(const SwViewOption * pPrefs)
    1085             : {
    1086           0 :     if ( GetViewShell()->HasDrawView() )
    1087           0 :         GetViewShell()->GetDrawView()->SetAnimationEnabled( false );
    1088             : 
    1089           0 :     bNormalPrint = sal_True;
    1090             : 
    1091             :     // Check and process the DocSize. The shell could not be found via
    1092             :     // the handler, because the shell is unknown to the SFX management
    1093             :     // within the CTOR phase.
    1094             : 
    1095           0 :     if( !pPrefs )
    1096           0 :         pPrefs = SW_MOD()->GetUsrPref(sal_False);
    1097             : 
    1098           0 :     mbHScrollbarEnabled = pPrefs->IsViewHScrollBar();
    1099           0 :     mbVScrollbarEnabled = pPrefs->IsViewVScrollBar();
    1100             : 
    1101             :     // Update the fields
    1102             :     // ATTENTION: Do cast the EditShell up, to use the SS.
    1103             :     //            At the methodes the current shell will be queried!
    1104           0 :     SwEditShell* pESh = (SwEditShell*)GetViewShell();
    1105           0 :     sal_Bool bIsModified = pESh->IsModified();
    1106             : 
    1107           0 :     SwViewOption aOpt( *pPrefs );
    1108           0 :     aOpt.SetPagePreview(sal_True);
    1109           0 :     aOpt.SetTab( sal_False );
    1110           0 :     aOpt.SetBlank( sal_False );
    1111           0 :     aOpt.SetHardBlank( sal_False );
    1112           0 :     aOpt.SetParagraph( sal_False );
    1113           0 :     aOpt.SetLineBreak( sal_False );
    1114           0 :     aOpt.SetPageBreak( sal_False );
    1115           0 :     aOpt.SetColumnBreak( sal_False );
    1116           0 :     aOpt.SetSoftHyph( sal_False );
    1117           0 :     aOpt.SetFldName( sal_False );
    1118           0 :     aOpt.SetPostIts( sal_False );
    1119           0 :     aOpt.SetShowHiddenChar( sal_False );
    1120           0 :     aOpt.SetShowHiddenField( sal_False );
    1121           0 :     aOpt.SetShowHiddenPara( sal_False );
    1122           0 :     aOpt.SetViewHRuler( sal_False );
    1123           0 :     aOpt.SetViewVRuler( sal_False );
    1124           0 :     aOpt.SetGraphic( sal_True );
    1125           0 :     aOpt.SetTable( sal_True );
    1126           0 :     aOpt.SetSnap( sal_False );
    1127           0 :     aOpt.SetGridVisible( sal_False );
    1128             : 
    1129           0 :     GetViewShell()->ApplyViewOptions( aOpt );
    1130           0 :     GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
    1131             : 
    1132             :     // adjust view shell option to the same as for print
    1133           0 :     SwPrintData const aPrintOptions = *SW_MOD()->GetPrtOptions(false);
    1134           0 :     GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions );
    1135             : 
    1136           0 :     GetViewShell()->CalcLayout();
    1137           0 :     DocSzChgd( GetViewShell()->GetDocSize() );
    1138             : 
    1139           0 :     if( !bIsModified )
    1140           0 :         pESh->ResetModified();
    1141           0 : }
    1142             : 
    1143           0 : SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh):
    1144             :     SfxViewShell( pViewFrame, SWVIEWFLAGS ),
    1145           0 :     pViewWin( new SwPagePreviewWin(&(GetViewFrame())->GetWindow(), *this ) ),
    1146             :     nNewPage(USHRT_MAX),
    1147             :     sPageStr(SW_RES(STR_PAGE)),
    1148             :     pHScrollbar(0),
    1149             :     pVScrollbar(0),
    1150             :     pScrollFill(new ScrollBarBox( &pViewFrame->GetWindow(),
    1151           0 :         pViewFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
    1152             :     mnPageCount( 0 ),
    1153             :     mbResetFormDesignMode( false ),
    1154           0 :     mbFormDesignModeToReset( false )
    1155             : {
    1156           0 :     SetName(OUString("PageView" ));
    1157           0 :     SetWindow( pViewWin );
    1158           0 :     SetHelpId(SW_PAGEPREVIEW);
    1159           0 :     _CreateScrollbar( sal_True );
    1160           0 :     _CreateScrollbar( sal_False );
    1161             : 
    1162           0 :     SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
    1163           0 :     if ( !pOldSh )
    1164             :     {
    1165             :         // Exists already a view on the document?
    1166           0 :         SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell );
    1167           0 :         if ( pF == pViewFrame )
    1168           0 :             pF = SfxViewFrame::GetNext( *pF, pObjShell );
    1169           0 :         if ( pF )
    1170           0 :             pOldSh = pF->GetViewShell();
    1171             :     }
    1172             : 
    1173             :     SwViewShell *pVS, *pNew;
    1174             : 
    1175           0 :     if( pOldSh && pOldSh->IsA( TYPE( SwPagePreview ) ) )
    1176           0 :         pVS = ((SwPagePreview*)pOldSh)->GetViewShell();
    1177             :     else
    1178             :     {
    1179           0 :         if( pOldSh && pOldSh->IsA( TYPE( SwView ) ) )
    1180             :         {
    1181           0 :             pVS = ((SwView*)pOldSh)->GetWrtShellPtr();
    1182             :             // save the current ViewData of the previous SwView
    1183           0 :             pOldSh->WriteUserData( sSwViewData, false );
    1184             :         }
    1185             :         else
    1186           0 :             pVS = GetDocShell()->GetWrtShell();
    1187           0 :         if( pVS )
    1188             :         {
    1189             :             // Set the current page as the first.
    1190             :             sal_uInt16 nPhysPg, nVirtPg;
    1191           0 :             ((SwCrsrShell*)pVS)->GetPageNum( nPhysPg, nVirtPg, sal_True, sal_False );
    1192           0 :             if( 1 != pViewWin->GetCol() && 1 == nPhysPg )
    1193           0 :                 --nPhysPg;
    1194           0 :             pViewWin->SetSttPage( nPhysPg );
    1195             :         }
    1196             :     }
    1197             : 
    1198             :     // for form shell remember design mode of draw view
    1199             :     // of previous view shell
    1200           0 :     if ( pVS && pVS->HasDrawView() )
    1201             :     {
    1202           0 :         mbResetFormDesignMode = true;
    1203           0 :         mbFormDesignModeToReset = pVS->GetDrawView()->IsDesignMode();
    1204             :     }
    1205             : 
    1206           0 :     if( pVS )
    1207           0 :         pNew = new SwViewShell( *pVS, pViewWin, 0, VSHELLFLAG_ISPREVIEW );
    1208             :     else
    1209             :         pNew = new SwViewShell(
    1210           0 :                 *((SwDocShell*)pViewFrame->GetObjectShell())->GetDoc(),
    1211           0 :                 pViewWin, 0, 0, VSHELLFLAG_ISPREVIEW );
    1212             : 
    1213           0 :     pViewWin->SetViewShell( pNew );
    1214           0 :     pNew->SetSfxViewShell( this );
    1215           0 :     Init();
    1216           0 : }
    1217             : 
    1218           0 : SwPagePreview::~SwPagePreview()
    1219             : {
    1220           0 :     SetWindow( 0 );
    1221           0 :     SwViewShell* pVShell =  pViewWin->GetViewShell();
    1222           0 :     pVShell->SetWin(0);
    1223           0 :     delete pVShell;
    1224           0 :     delete pViewWin;
    1225             : 
    1226           0 :     delete pScrollFill;
    1227           0 :     delete pHScrollbar;
    1228           0 :     delete pVScrollbar;
    1229           0 : }
    1230             : 
    1231           0 : SwDocShell* SwPagePreview::GetDocShell()
    1232             : {
    1233           0 :     return PTR_CAST(SwDocShell, GetViewFrame()->GetObjectShell());
    1234             : }
    1235             : 
    1236           0 : int SwPagePreview::_CreateScrollbar( sal_Bool bHori )
    1237             : {
    1238           0 :     Window *pMDI = &GetViewFrame()->GetWindow();
    1239           0 :     SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar;
    1240             : 
    1241             :     OSL_ENSURE( !*ppScrollbar, "check beforehand!" );
    1242             : 
    1243           0 :     *ppScrollbar = new SwScrollbar( pMDI, bHori );
    1244             : 
    1245           0 :     ScrollDocSzChg();
    1246           0 :     (*ppScrollbar)->EnableDrag( true );
    1247           0 :     (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwPagePreview, EndScrollHdl ));
    1248             : 
    1249           0 :     (*ppScrollbar)->SetScrollHdl( LINK( this, SwPagePreview, ScrollHdl ));
    1250             : 
    1251           0 :     InvalidateBorder();
    1252           0 :     (*ppScrollbar)->ExtendedShow();
    1253           0 :     return 1;
    1254             : }
    1255             : 
    1256           0 : bool SwPagePreview::ChgPage( int eMvMode, int bUpdateScrollbar )
    1257             : {
    1258           0 :     Rectangle aPixVisArea( pViewWin->LogicToPixel( aVisArea ) );
    1259           0 :     bool bChg = pViewWin->MovePage( eMvMode ) ||
    1260           0 :                eMvMode == SwPagePreviewWin::MV_CALC ||
    1261           0 :                eMvMode == SwPagePreviewWin::MV_NEWWINSIZE;
    1262           0 :     aVisArea = pViewWin->PixelToLogic( aPixVisArea );
    1263             : 
    1264           0 :     if( bChg )
    1265             :     {
    1266             :         // Update statusbar
    1267           0 :         OUString aStr = sPageStr + pViewWin->GetStatusStr( mnPageCount );
    1268           0 :         SfxBindings& rBindings = GetViewFrame()->GetBindings();
    1269             : 
    1270           0 :         if( bUpdateScrollbar )
    1271             :         {
    1272           0 :             ScrollViewSzChg();
    1273             : 
    1274             :             static sal_uInt16 aInval[] =
    1275             :             {
    1276             :                 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT,
    1277             :                 FN_PAGEUP, FN_PAGEDOWN, 0
    1278             :             };
    1279           0 :             rBindings.Invalidate( aInval );
    1280             :         }
    1281           0 :         rBindings.SetState( SfxStringItem( FN_STAT_PAGE, aStr ) );
    1282             :     }
    1283           0 :     return bChg;
    1284             : }
    1285             : 
    1286             : // From here, everything was taken from the SwView.
    1287           0 : void SwPagePreview::CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool /*bInner*/ )
    1288             : {
    1289           0 :     const StyleSettings &rSet = pViewWin->GetSettings().GetStyleSettings();
    1290           0 :     const long nTmp = rSet.GetScrollBarSize();
    1291           0 :     if ( pVScrollbar->IsVisible( true ) )
    1292           0 :         rToFill.Right()  = nTmp;
    1293           0 :     if ( pHScrollbar->IsVisible( true ) )
    1294           0 :         rToFill.Bottom() = nTmp;
    1295           0 :     SetBorderPixel( rToFill );
    1296           0 : }
    1297             : 
    1298           0 : void  SwPagePreview::InnerResizePixel( const Point &rOfst, const Size &rSize )
    1299             : {
    1300           0 :     SvBorder aBorder;
    1301           0 :     CalcAndSetBorderPixel( aBorder, sal_True );
    1302           0 :     Rectangle aRect( rOfst, rSize );
    1303           0 :     aRect += aBorder;
    1304             :     ViewResizePixel( *pViewWin, aRect.TopLeft(), aRect.GetSize(),
    1305           0 :                     pViewWin->GetOutputSizePixel(),
    1306           0 :                     *pVScrollbar, *pHScrollbar, *pScrollFill );
    1307             : 
    1308             :     // Never set EditWin !
    1309             :     // Never set VisArea !
    1310           0 : }
    1311             : 
    1312           0 : void SwPagePreview::OuterResizePixel( const Point &rOfst, const Size &rSize )
    1313             : {
    1314           0 :     SvBorder aBorder;
    1315           0 :     CalcAndSetBorderPixel( aBorder, sal_False );
    1316             : 
    1317             :     // Never set EditWin !
    1318             : 
    1319           0 :     Size aTmpSize( pViewWin->GetOutputSizePixel() );
    1320           0 :     Point aBottomRight( pViewWin->PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) );
    1321           0 :     SetVisArea( Rectangle( Point(), aBottomRight ) );
    1322             : 
    1323             :     // Call of the DocSzChgd-Methode of the scrollbars is necessary,
    1324             :     // because from the maximum scoll range half the height of the
    1325             :     // VisArea is always deducted.
    1326           0 :     if ( pVScrollbar && aTmpSize.Width() > 0 && aTmpSize.Height() > 0 )
    1327             :     {
    1328           0 :         ScrollDocSzChg();
    1329             :     }
    1330             : 
    1331           0 :     SvBorder aBorderNew;
    1332           0 :     CalcAndSetBorderPixel( aBorderNew, sal_False );
    1333           0 :     ViewResizePixel( *pViewWin, rOfst, rSize, pViewWin->GetOutputSizePixel(),
    1334           0 :                     *pVScrollbar, *pHScrollbar, *pScrollFill );
    1335           0 : }
    1336             : 
    1337           0 : void SwPagePreview::SetVisArea( const Rectangle &rRect, sal_Bool bUpdateScrollbar )
    1338             : {
    1339           0 :     const Point aTopLeft(AlignToPixel(rRect.TopLeft()));
    1340           0 :     const Point aBottomRight(AlignToPixel(rRect.BottomRight()));
    1341           0 :     Rectangle aLR(aTopLeft,aBottomRight);
    1342             : 
    1343           0 :     if(aLR == aVisArea)
    1344           0 :         return;
    1345             :         // No negative position, no negative size
    1346             : 
    1347           0 :     if(aLR.Top() < 0)
    1348             :     {
    1349           0 :         aLR.Bottom() += std::abs(aLR.Top());
    1350           0 :         aLR.Top() = 0;
    1351             :     }
    1352             : 
    1353           0 :     if(aLR.Left() < 0)
    1354             :     {
    1355           0 :         aLR.Right() += std::abs(aLR.Left());
    1356           0 :         aLR.Left() = 0;
    1357             :     }
    1358           0 :     if(aLR.Right() < 0) aLR.Right() = 0;
    1359           0 :     if(aLR.Bottom() < 0) aLR.Bottom() = 0;
    1360           0 :     if(aLR == aVisArea ||
    1361             :         // Ignore empty rectangle
    1362           0 :         ( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) )
    1363           0 :         return;
    1364             : 
    1365           0 :     if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() )
    1366           0 :         return;
    1367             : 
    1368             :     // Before the data can be changed call an update if necessary.
    1369             :     // Thereby ensured, that adjacent paints are correctly converted into
    1370             :     // document coordinates.
    1371             :     // As a precaution, we do this only when at the shell runs an action,
    1372             :     // because then we do not really paint but the rectangles are just
    1373             :     // bookmarked (in document coordinates).
    1374           0 :     if( GetViewShell()->ActionPend() )
    1375           0 :         pViewWin->Update();
    1376             : 
    1377             :     // Set at View-Win the current size
    1378           0 :     aVisArea = aLR;
    1379           0 :     pViewWin->SetWinSize( aLR.GetSize() );
    1380           0 :     ChgPage( SwPagePreviewWin::MV_NEWWINSIZE, bUpdateScrollbar );
    1381             : 
    1382           0 :     pViewWin->Invalidate();
    1383             : }
    1384             : 
    1385           0 : IMPL_LINK( SwPagePreview, ScrollHdl, SwScrollbar *, pScrollbar )
    1386             : {
    1387           0 :     if(!GetViewShell())
    1388           0 :         return 0;
    1389           0 :     if( !pScrollbar->IsHoriScroll() &&
    1390           0 :         pScrollbar->GetType() == SCROLL_DRAG &&
    1391           0 :         Help::IsQuickHelpEnabled() &&
    1392           0 :         GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
    1393             :     {
    1394             :         // Scroll how many pages??
    1395           0 :         OUString sStateStr(sPageStr);
    1396           0 :         sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos();
    1397           0 :         if( 1 == pViewWin->GetCol() || !nThmbPos )
    1398           0 :             ++nThmbPos;
    1399           0 :         sStateStr += OUString::number( nThmbPos );
    1400             :         Point aPos = pScrollbar->GetParent()->OutputToScreenPixel(
    1401           0 :                                         pScrollbar->GetPosPixel());
    1402           0 :         aPos.Y() = pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y();
    1403           0 :         Rectangle aRect;
    1404           0 :         aRect.Left()    = aPos.X() -8;
    1405           0 :         aRect.Right()   = aRect.Left();
    1406           0 :         aRect.Top()     = aPos.Y();
    1407           0 :         aRect.Bottom()  = aRect.Top();
    1408             : 
    1409             :         Help::ShowQuickHelp(pScrollbar, aRect, sStateStr,
    1410           0 :                 QUICKHELP_RIGHT|QUICKHELP_VCENTER);
    1411             : 
    1412             :     }
    1413             :     else
    1414           0 :         EndScrollHdl( pScrollbar );
    1415           0 :     return 0;
    1416             : }
    1417             : 
    1418           0 : IMPL_LINK( SwPagePreview, EndScrollHdl, SwScrollbar *, pScrollbar )
    1419             : {
    1420           0 :     if(!GetViewShell())
    1421           0 :         return 0;
    1422             : 
    1423             :     // boolean to avoid unnecessary invalidation of the window.
    1424           0 :     bool bInvalidateWin = true;
    1425             : 
    1426           0 :     if( !pScrollbar->IsHoriScroll() )       // scroll vertically
    1427             :     {
    1428           0 :         if ( Help::IsQuickHelpEnabled() )
    1429           0 :             Help::ShowQuickHelp(pScrollbar, Rectangle(), OUString(), 0);
    1430           0 :         if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
    1431             :         {
    1432             :             // Scroll how many pages ??
    1433           0 :             sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos();
    1434             :             // adjust to new preview functionality
    1435           0 :             if( nThmbPos != pViewWin->SelectedPage() )
    1436             :             {
    1437             :                 // consider case that page <nThmbPos>
    1438             :                 // is already visible
    1439           0 :                 SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
    1440           0 :                 if ( pPagePreviewLay->IsPageVisible( nThmbPos ) )
    1441             :                 {
    1442           0 :                     pPagePreviewLay->MarkNewSelectedPage( nThmbPos );
    1443             :                     // invalidation of window is unnecessary
    1444           0 :                     bInvalidateWin = false;
    1445             :                 }
    1446             :                 else
    1447             :                 {
    1448             :                     // consider whether layout columns
    1449             :                     // fit or not.
    1450           0 :                     if ( !pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
    1451             :                     {
    1452           0 :                         pViewWin->SetSttPage( nThmbPos );
    1453           0 :                         pViewWin->SetSelectedPage( nThmbPos );
    1454           0 :                         ChgPage( SwPagePreviewWin::MV_SCROLL, sal_False );
    1455             :                         // update scrollbars
    1456           0 :                         ScrollViewSzChg();
    1457             :                     }
    1458             :                     else
    1459             :                     {
    1460             :                         // correct scroll amount
    1461           0 :                         const sal_Int16 nPageDiff = nThmbPos - pViewWin->SelectedPage();
    1462           0 :                         const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
    1463           0 :                         sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages;
    1464           0 :                         if ( nPageDiff % nVisPages )
    1465             :                         {
    1466             :                             // decrease/increase number of preview pages to scroll
    1467           0 :                             nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll;
    1468             :                         }
    1469           0 :                         pViewWin->SetSelectedPage( nThmbPos );
    1470           0 :                         pViewWin->Scroll( 0, pPagePreviewLay->GetWinPagesScrollAmount( nWinPagesToScroll ) );
    1471             :                     }
    1472             :                 }
    1473             :                 // update accessibility
    1474           0 :                 GetViewShell()->ShowPreviewSelection( nThmbPos );
    1475             :             }
    1476             :             else
    1477             :             {
    1478             :                 // invalidation of window is unnecessary
    1479           0 :                 bInvalidateWin = false;
    1480             :             }
    1481             :         }
    1482             :         else
    1483             :         {
    1484           0 :             long nThmbPos = pScrollbar->GetThumbPos();
    1485           0 :             pViewWin->Scroll(0, nThmbPos - pViewWin->GetPaintedPreviewDocRect().Top());
    1486             :         }
    1487             :     }
    1488             :     else
    1489             :     {
    1490           0 :         long nThmbPos = pScrollbar->GetThumbPos();
    1491           0 :         pViewWin->Scroll(nThmbPos - pViewWin->GetPaintedPreviewDocRect().Left(), 0);
    1492             :     }
    1493             :     // additional invalidate page status.
    1494             :     static sal_uInt16 aInval[] =
    1495             :     {
    1496             :         FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
    1497             :         FN_STAT_PAGE, 0
    1498             :     };
    1499           0 :     SfxBindings& rBindings = GetViewFrame()->GetBindings();
    1500           0 :     rBindings.Invalidate( aInval );
    1501             :     // control invalidation of window
    1502           0 :     if ( bInvalidateWin )
    1503             :     {
    1504           0 :         pViewWin->Invalidate();
    1505             :     }
    1506           0 :     return 0;
    1507             : }
    1508             : 
    1509           0 : Point SwPagePreview::AlignToPixel(const Point &rPt) const
    1510             : {
    1511           0 :     return pViewWin->PixelToLogic( pViewWin->LogicToPixel( rPt ) );
    1512             : }
    1513             : 
    1514           0 : void SwPagePreview::DocSzChgd( const Size &rSz )
    1515             : {
    1516           0 :     if( aDocSz == rSz )
    1517           0 :         return;
    1518             : 
    1519           0 :     aDocSz = rSz;
    1520             : 
    1521             :     // #i96726#
    1522             :     // Due to the multiple page layout it is needed to trigger recalculation
    1523             :     // of the page preview layout, even if the count of pages is not changing.
    1524           0 :     mnPageCount = GetViewShell()->GetNumPages();
    1525             : 
    1526           0 :     if( aVisArea.GetWidth() )
    1527             :     {
    1528           0 :         ChgPage( SwPagePreviewWin::MV_CALC, sal_True );
    1529           0 :         ScrollDocSzChg();
    1530             : 
    1531           0 :         pViewWin->Invalidate();
    1532             :     }
    1533             : }
    1534             : 
    1535           0 : void SwPagePreview::ScrollViewSzChg()
    1536             : {
    1537           0 :     if(!GetViewShell())
    1538           0 :         return ;
    1539             : 
    1540           0 :     bool bShowVScrollbar = false, bShowHScrollbar = false;
    1541             : 
    1542           0 :     if(pVScrollbar)
    1543             :     {
    1544           0 :         if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
    1545             :         {
    1546             :             //vertical scrolling by row
    1547             :             // adjust to new preview functionality
    1548           0 :             sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
    1549             : 
    1550           0 :             pVScrollbar->SetVisibleSize( nVisPages );
    1551             :             // set selected page as scroll bar position,
    1552             :             // if it is visible.
    1553           0 :             SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
    1554           0 :             if ( pPagePreviewLay->IsPageVisible( pViewWin->SelectedPage() ) )
    1555             :             {
    1556           0 :                 pVScrollbar->SetThumbPos( pViewWin->SelectedPage() );
    1557             :             }
    1558             :             else
    1559             :             {
    1560           0 :                 pVScrollbar->SetThumbPos( pViewWin->GetSttPage() );
    1561             :             }
    1562           0 :             pVScrollbar->SetLineSize( pViewWin->GetCol() );
    1563           0 :             pVScrollbar->SetPageSize( nVisPages );
    1564             :             // calculate and set scrollbar range
    1565           0 :             Range aScrollbarRange( 1, mnPageCount );
    1566             :             // increase range by one, because left-top-corner is left blank.
    1567           0 :             ++aScrollbarRange.Max();
    1568             :             // increase range in order to access all pages
    1569           0 :             aScrollbarRange.Max() += ( nVisPages - 1 );
    1570           0 :             pVScrollbar->SetRange( aScrollbarRange );
    1571             : 
    1572           0 :             bShowVScrollbar = nVisPages < mnPageCount;
    1573             :         }
    1574             :         else //vertical scrolling by pixel
    1575             :         {
    1576           0 :             const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect();
    1577             :             const Size& rPreviewSize =
    1578           0 :                     GetViewShell()->PagePreviewLayout()->GetPreviewDocSize();
    1579           0 :             pVScrollbar->SetRangeMax(rPreviewSize.Height()) ;
    1580           0 :             long nVisHeight = rDocRect.GetHeight();
    1581           0 :             pVScrollbar->SetVisibleSize( nVisHeight );
    1582           0 :             pVScrollbar->SetThumbPos( rDocRect.Top() );
    1583           0 :             pVScrollbar->SetLineSize( nVisHeight / 10 );
    1584           0 :             pVScrollbar->SetPageSize( nVisHeight / 2 );
    1585             : 
    1586           0 :             bShowVScrollbar = true;
    1587             :         }
    1588             : 
    1589           0 :         if (!mbVScrollbarEnabled)
    1590           0 :             bShowVScrollbar = false;
    1591             : 
    1592           0 :         ShowVScrollbar(bShowVScrollbar);
    1593             :     }
    1594           0 :     if(pHScrollbar)
    1595             :     {
    1596           0 :         const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect();
    1597             :         const Size& rPreviewSize =
    1598           0 :                 GetViewShell()->PagePreviewLayout()->GetPreviewDocSize();
    1599           0 :         long nVisWidth = 0;
    1600           0 :         long nThumb   = 0;
    1601           0 :         Range aRange(0,0);
    1602             : 
    1603           0 :         if(rDocRect.GetWidth() < rPreviewSize.Width())
    1604             :         {
    1605           0 :             bShowHScrollbar = true;
    1606             : 
    1607           0 :             nVisWidth = rDocRect.GetWidth();
    1608           0 :             nThumb = rDocRect.Left();
    1609           0 :             aRange = Range(0, rPreviewSize.Width());
    1610             : 
    1611           0 :             pHScrollbar->SetRange( aRange );
    1612           0 :             pHScrollbar->SetVisibleSize( nVisWidth );
    1613           0 :             pHScrollbar->SetThumbPos( nThumb );
    1614           0 :             pHScrollbar->SetLineSize( nVisWidth / 10 );
    1615           0 :             pHScrollbar->SetPageSize( nVisWidth / 2 );
    1616             :         }
    1617             : 
    1618           0 :         if (!mbHScrollbarEnabled)
    1619           0 :             bShowHScrollbar = false;
    1620             : 
    1621           0 :         ShowHScrollbar(bShowHScrollbar);
    1622             :     }
    1623           0 :     pScrollFill->Show(bShowVScrollbar && bShowHScrollbar);
    1624             : }
    1625             : 
    1626           0 : void SwPagePreview::ScrollDocSzChg()
    1627             : {
    1628           0 :     ScrollViewSzChg();
    1629           0 : }
    1630             : 
    1631             : // All about printing
    1632           0 : SfxPrinter*  SwPagePreview::GetPrinter( bool bCreate )
    1633             : {
    1634           0 :     return pViewWin->GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate );
    1635             : }
    1636             : 
    1637           0 : sal_uInt16  SwPagePreview::SetPrinter( SfxPrinter *pNew, sal_uInt16 nDiffFlags, bool )
    1638             : {
    1639           0 :     SwViewShell &rSh = *GetViewShell();
    1640           0 :     SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false );
    1641           0 :     if ( pOld && pOld->IsPrinting() )
    1642           0 :         return SFX_PRINTERROR_BUSY;
    1643             : 
    1644           0 :     SwEditShell &rESh = (SwEditShell&)rSh;  //Buh...
    1645           0 :     if( ( SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ) & nDiffFlags )
    1646             :     {
    1647           0 :         rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true );
    1648           0 :         if( nDiffFlags & SFX_PRINTER_PRINTER )
    1649           0 :             rESh.SetModified();
    1650             :     }
    1651           0 :     if ( ( nDiffFlags & SFX_PRINTER_OPTIONS ) == SFX_PRINTER_OPTIONS )
    1652           0 :         ::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, sal_False );
    1653             : 
    1654           0 :     const bool bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION;
    1655           0 :     const bool bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE;
    1656           0 :     if ( bChgOri || bChgSize )
    1657             :     {
    1658           0 :         rESh.StartAllAction();
    1659           0 :         if ( bChgOri )
    1660           0 :             rSh.ChgAllPageOrientation( sal_uInt16(pNew->GetOrientation()) );
    1661           0 :         if ( bChgSize )
    1662             :         {
    1663           0 :             Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
    1664           0 :             rSh.ChgAllPageSize( aSz );
    1665             :         }
    1666           0 :         if( !bNormalPrint )
    1667           0 :             pViewWin->CalcWish( pViewWin->GetRow(), pViewWin->GetCol() );
    1668           0 :         rESh.SetModified();
    1669           0 :         rESh.EndAllAction();
    1670             : 
    1671             :         static sal_uInt16 aInval[] =
    1672             :         {
    1673             :             SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
    1674             :             SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0
    1675             :         };
    1676             : #if OSL_DEBUG_LEVEL > 0
    1677             :     {
    1678             :         const sal_uInt16* pPtr = aInval + 1;
    1679             :         do {
    1680             :             OSL_ENSURE( *(pPtr - 1) < *pPtr, "wrong sorting!" );
    1681             :         } while( *++pPtr );
    1682             :     }
    1683             : #endif
    1684             : 
    1685           0 :         GetViewFrame()->GetBindings().Invalidate(aInval);
    1686             :     }
    1687             : 
    1688           0 :     return 0;
    1689             : }
    1690             : 
    1691           0 : bool SwPagePreview::HasPrintOptionsPage() const
    1692             : {
    1693           0 :     return true;
    1694             : }
    1695             : 
    1696           0 : SfxTabPage*  SwPagePreview::CreatePrintOptionsPage( Window *pParent,
    1697             :                                                 const SfxItemSet &rOptions )
    1698             : {
    1699           0 :     return ::CreatePrintOptionsPage( pParent, rOptions, !bNormalPrint );
    1700             : }
    1701             : 
    1702           0 : void SwPagePreviewWin::SetViewShell( SwViewShell* pShell )
    1703             : {
    1704           0 :     mpViewShell = pShell;
    1705           0 :     if ( mpViewShell && mpViewShell->IsPreview() )
    1706             :     {
    1707           0 :         mpPgPreviewLayout = mpViewShell->PagePreviewLayout();
    1708             :     }
    1709           0 : }
    1710             : 
    1711           0 : void SwPagePreviewWin::RepaintCoreRect( const SwRect& rRect )
    1712             : {
    1713             :     // #i24183#
    1714           0 :     if ( mpPgPreviewLayout->PreviewLayoutValid() )
    1715             :     {
    1716           0 :         mpPgPreviewLayout->Repaint( Rectangle( rRect.Pos(), rRect.SSize() ) );
    1717             :     }
    1718           0 : }
    1719             : 
    1720             : /** method to adjust preview to a new zoom factor
    1721             : 
    1722             :     #i19975# also consider zoom type - adding parameter <_eZoomType>
    1723             : */
    1724           0 : void SwPagePreviewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
    1725             :                                                const SvxZoomType _eZoomType )
    1726             : {
    1727             :     // #i19975# consider zoom type
    1728           0 :     if ( _eZoomType == SVX_ZOOM_WHOLEPAGE )
    1729             :     {
    1730           0 :         mnRow = 1;
    1731           0 :         mnCol = 1;
    1732           0 :         mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize, true );
    1733             :         mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
    1734           0 :                                   mnSttPage, maPaintedPreviewDocRect );
    1735           0 :         SetSelectedPage( mnSttPage );
    1736           0 :         SetPagePreview(mnRow, mnCol);
    1737           0 :         maScale = GetMapMode().GetScaleX();
    1738             :     }
    1739           0 :     else if ( _nZoomFactor != 0 )
    1740             :     {
    1741             :         // calculate new scaling and set mapping mode appropriately.
    1742           0 :         Fraction aNewScale( _nZoomFactor, 100 );
    1743           0 :         MapMode aNewMapMode = GetMapMode();
    1744           0 :         aNewMapMode.SetScaleX( aNewScale );
    1745           0 :         aNewMapMode.SetScaleY( aNewScale );
    1746           0 :         SetMapMode( aNewMapMode );
    1747             : 
    1748             :         // calculate new start position for preview paint
    1749           0 :         Size aNewWinSize = PixelToLogic( maPxWinSize );
    1750             :         Point aNewPaintStartPos =
    1751           0 :                 mpPgPreviewLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize );
    1752             : 
    1753             :         // remember new scaling and prepare preview paint
    1754             :         // Note: paint of preview will be performed by a corresponding invalidate
    1755             :         //          due to property changes.
    1756           0 :         maScale = aNewScale;
    1757             :         mpPgPreviewLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize,
    1758           0 :                                   mnSttPage, maPaintedPreviewDocRect );
    1759             :     }
    1760             : 
    1761           0 : }
    1762             : 
    1763             : /**
    1764             :  * pixel scrolling - horizontally always or vertically
    1765             :  * when less than the desired number of rows fits into
    1766             :  * the view
    1767             :  */
    1768           0 : void SwPagePreviewWin::Scroll(long nXMove, long nYMove, sal_uInt16 /*nFlags*/)
    1769             : {
    1770           0 :     maPaintedPreviewDocRect.Move(nXMove, nYMove);
    1771             :     mpPgPreviewLayout->Prepare( 0, maPaintedPreviewDocRect.TopLeft(),
    1772             :                               maPxWinSize, mnSttPage,
    1773           0 :                               maPaintedPreviewDocRect );
    1774             : 
    1775           0 : }
    1776             : 
    1777           0 : sal_Bool SwPagePreview::HandleWheelCommands( const CommandEvent& rCEvt )
    1778             : {
    1779           0 :     sal_Bool bOk = sal_False;
    1780           0 :     const CommandWheelData* pWData = rCEvt.GetWheelData();
    1781           0 :     if( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() )
    1782             :     {
    1783             :         //only the Preference shouldn't control the Zoom, it is better to detect AT tools running. So the bridge can be used here
    1784           0 :         if (!Application::GetSettings().GetMiscSettings().GetEnableATToolSupport())
    1785             :         {
    1786           0 :             sal_uInt16 nFactor = GetViewShell()->GetViewOptions()->GetZoom();
    1787           0 :             const sal_uInt16 nOffset = 10;
    1788           0 :             if( 0L > pWData->GetDelta() )
    1789             :             {
    1790           0 :                 nFactor -= nOffset;
    1791           0 :                 if(nFactor < MIN_PREVIEW_ZOOM)
    1792           0 :                     nFactor = MIN_PREVIEW_ZOOM;
    1793             :             }
    1794             :             else
    1795             :             {
    1796           0 :                 nFactor += nOffset;
    1797           0 :                 if(nFactor > MAX_PREVIEW_ZOOM)
    1798           0 :                     nFactor = MAX_PREVIEW_ZOOM;
    1799             :             }
    1800           0 :             SetZoom(SVX_ZOOM_PERCENT, nFactor);
    1801             :         }
    1802           0 :         bOk = sal_True;
    1803             :     }
    1804             :     else
    1805           0 :         bOk = pViewWin->HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
    1806           0 :     return bOk;
    1807             : }
    1808             : 
    1809             : uno::Reference< ::com::sun::star::accessibility::XAccessible >
    1810           0 :     SwPagePreviewWin::CreateAccessible()
    1811             : {
    1812           0 :     SolarMutexGuard aGuard; // this should have happened already!!!
    1813             : 
    1814             :     OSL_ENSURE( GetViewShell() != NULL, "We need a view shell" );
    1815           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc = GetAccessible( false );
    1816           0 :     if (xAcc.is())
    1817             :     {
    1818           0 :         return xAcc;
    1819             :     }
    1820           0 :     if (mpViewShell)
    1821             :     {
    1822           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccPreview = mpViewShell->CreateAccessiblePreview();
    1823           0 :         SetAccessible(xAccPreview);
    1824             :     }
    1825           0 :     return GetAccessible( false );
    1826             : }
    1827             : 
    1828             : // MT: Removed Windows::SwitchView() introduced with IA2 CWS.
    1829             : // There are other notifications for this when the active view has chnaged, so please update the code to use that event mechanism
    1830           0 : void SwPagePreviewWin::SwitchView()
    1831             : {
    1832             : #ifdef ACCESSIBLE_LAYOUT
    1833             :     if (!Application::IsAccessibilityEnabled())
    1834             :     {
    1835             :         return ;
    1836             :     }
    1837             :     if (mpViewShell)
    1838             :     {
    1839             :         mpViewShell->InvalidateAccessibleFocus();
    1840             :     }
    1841             : #endif
    1842           0 : }
    1843             : 
    1844           0 : void SwPagePreview::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
    1845             : {
    1846           0 :     GetViewShell()->ApplyAccessiblityOptions(rAccessibilityOptions);
    1847           0 : }
    1848             : 
    1849           0 : void SwPagePreview::ShowHScrollbar(sal_Bool bShow)
    1850             : {
    1851           0 :     pHScrollbar->Show(bShow);
    1852           0 :     InvalidateBorder();
    1853           0 : }
    1854             : 
    1855           0 : void SwPagePreview::ShowVScrollbar(sal_Bool bShow)
    1856             : {
    1857           0 :     pVScrollbar->Show(bShow);
    1858           0 :     InvalidateBorder();
    1859           0 : }
    1860             : 
    1861           0 : void SwPagePreview::EnableHScrollbar(bool bEnable)
    1862             : {
    1863           0 :     if (mbHScrollbarEnabled != bEnable)
    1864             :     {
    1865           0 :         mbHScrollbarEnabled = bEnable;
    1866           0 :         ScrollViewSzChg();
    1867             :     }
    1868           0 : }
    1869             : 
    1870           0 : void SwPagePreview::EnableVScrollbar(bool bEnable)
    1871             : {
    1872           0 :     if (mbVScrollbarEnabled != bEnable)
    1873             :     {
    1874           0 :         mbVScrollbarEnabled = bEnable;
    1875           0 :         ScrollViewSzChg();
    1876             :     }
    1877           0 : }
    1878             : 
    1879           0 : void SwPagePreview::SetZoom(SvxZoomType eType, sal_uInt16 nFactor)
    1880             : {
    1881           0 :     SwViewShell& rSh = *GetViewShell();
    1882           0 :     SwViewOption aOpt(*rSh.GetViewOptions());
    1883             :     // perform action only on changes of zoom or zoom type.
    1884           0 :     if ( aOpt.GetZoom() != nFactor ||
    1885           0 :          aOpt.GetZoomType() != eType )
    1886             :     {
    1887           0 :         aOpt.SetZoom(nFactor);
    1888           0 :         aOpt.SetZoomType(eType);
    1889           0 :         rSh.ApplyViewOptions( aOpt );
    1890           0 :         lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
    1891             :         // #i19975# also consider zoom type
    1892           0 :         pViewWin->AdjustPreviewToNewZoom( nFactor, eType );
    1893           0 :         ScrollViewSzChg();
    1894           0 :     }
    1895           0 : }
    1896             : 
    1897             : /** adjust position of vertical scrollbar
    1898             : 
    1899             :     @author OD
    1900             : */
    1901           0 : void SwPagePreview::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos )
    1902             : {
    1903           0 :     if ( pVScrollbar )
    1904             :     {
    1905           0 :         pVScrollbar->SetThumbPos( _nNewThumbPos );
    1906             :     }
    1907           0 : }
    1908             : 
    1909             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10