LCOV - code coverage report
Current view: top level - sw/source/uibase/uiview - pview.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 920 1.3 %
Date: 2015-06-13 12:38:46 Functions: 8 77 10.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11