LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/uiview - pview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 921 1.3 %
Date: 2013-07-09 Functions: 8 78 10.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10