LCOV - code coverage report
Current view: top level - sw/source/uibase/inc - pview.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 24 8.3 %
Date: 2014-11-03 Functions: 2 20 10.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_PVIEW_HXX
      20             : #define INCLUDED_SW_SOURCE_UIBASE_INC_PVIEW_HXX
      21             : 
      22             : #include <tools/link.hxx>
      23             : #include <vcl/window.hxx>
      24             : #include <sfx2/viewfrm.hxx>
      25             : #include <sfx2/viewfac.hxx>
      26             : #include <sfx2/viewsh.hxx>
      27             : #include <sfx2/zoomitem.hxx>
      28             : #include "swdllapi.h"
      29             : #include "shellid.hxx"
      30             : 
      31             : class SwViewOption;
      32             : class SwDocShell;
      33             : class SwScrollbar;
      34             : class SwViewShell;
      35             : class SwPagePreview;
      36             : class ImageButton;
      37             : class Button;
      38             : class SwRect;
      39             : class DataChangedEvent;
      40             : class CommandEvent;
      41             : class SvtAccessibilityOptions;
      42             : class SwPagePreviewLayout;
      43             : 
      44             : // Delete member <mnVirtPage> and its accessor
      45             : class SwPagePreviewWin : public vcl::Window
      46             : {
      47             :     SwViewShell*          mpViewShell;
      48             :     sal_uInt16              mnSttPage;
      49             :     sal_uInt8                mnRow, mnCol;
      50             :     Size                maPxWinSize;
      51             :     Fraction            maScale;
      52             :     SwPagePreview&      mrView;
      53             :     bool                mbCalcScaleForPreviewLayout;
      54             :     Rectangle           maPaintedPreviewDocRect;
      55             :     SwPagePreviewLayout* mpPgPreviewLayout;
      56             : 
      57             :     void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
      58             : 
      59             :     using Window::Scroll;
      60             : 
      61             : public:
      62             :     SwPagePreviewWin( vcl::Window* pParent, SwPagePreview& rView );
      63             :     virtual ~SwPagePreviewWin();
      64             : 
      65             :     // calls SwViewShell::Paint
      66             :     virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
      67             :     virtual void KeyInput( const KeyEvent & ) SAL_OVERRIDE;
      68             :     virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
      69             :     virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
      70             :     virtual void DataChanged( const DataChangedEvent& ) SAL_OVERRIDE;
      71             : 
      72             :     void SetViewShell( SwViewShell* pShell );
      73             : 
      74           0 :     SwViewShell* GetViewShell() const { return mpViewShell; }
      75             : 
      76           0 :     sal_uInt8    GetRow() const      { return mnRow; }
      77             :     void    SetRow( sal_uInt8 n )    { if( n ) mnRow = n; }
      78             : 
      79           0 :     sal_uInt8    GetCol() const      { return mnCol; }
      80             :     void    SetCol( sal_uInt8 n )    { if( n ) mnCol = n; }
      81             : 
      82           0 :     sal_uInt16  GetSttPage() const      { return mnSttPage; }
      83           0 :     void    SetSttPage( sal_uInt16 n )  { mnSttPage = n; }
      84             : 
      85             :     /** get selected page number of document preview
      86             : 
      87             :         @return selected page number
      88             :     */
      89             :     sal_uInt16 SelectedPage() const;
      90             : 
      91             :     /** set selected page number in document preview
      92             : 
      93             :         @param _nSelectedPageNum
      94             :         input parameter - physical page number of page that will be the selected one.
      95             :     */
      96             :     void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
      97             : 
      98             :     // If we only have one column we do not have a oth page
      99           0 :     sal_uInt16  GetDefSttPage() const   { return 1 == mnCol ? 1 : 0; }
     100             : 
     101             :     void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
     102             : 
     103             :     const Size& GetWinSize() const  { return maPxWinSize; }
     104             :     void SetWinSize( const Size& rNewSize );
     105             : 
     106             :     // Add <MV_SELPAGE>, <MV_SCROLL>
     107             :     enum MoveMode{ MV_CALC, MV_PAGE_UP, MV_PAGE_DOWN, MV_DOC_STT, MV_DOC_END,
     108             :                    MV_SELPAGE, MV_SCROLL, MV_NEWWINSIZE };
     109             :     int MovePage( int eMoveMode );
     110             : 
     111             :     // Create the status bar's string
     112             :     OUString GetStatusStr( sal_uInt16 nPageCount ) const;
     113             : 
     114             :     void RepaintCoreRect( const SwRect& rRect );
     115             : 
     116             :     /** Method to adjust preview to a new zoom factor
     117             :         paint of preview is prepared for a new zoom factor
     118             :         Zoom type has also been considered.
     119             :         Thus, add new parameter <_eZoomType>
     120             :     */
     121             :     void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
     122             :                                  const SvxZoomType _eZoomType );
     123             : 
     124           0 :     const Rectangle& GetPaintedPreviewDocRect() const
     125             :     {
     126           0 :         return maPaintedPreviewDocRect;
     127             :     }
     128             : 
     129             :     void Scroll(long nXMove, long nYMove, sal_uInt16 nFlags = 0) SAL_OVERRIDE;
     130             : 
     131             :     /** Method to enable/disable book preview
     132             :         @param _bBookPreview
     133             :         input parameter - boolean indicating, if book preview mode has to
     134             :         switch on <sal_True> or of <sal_False>
     135             : 
     136             :         @return boolean indicating, if book preview mode has changed.
     137             :     */
     138             :     bool SetBookPreviewMode( const bool _bBookPreview );
     139             : 
     140             :     virtual ::com::sun::star::uno::Reference<
     141             :         ::com::sun::star::accessibility::XAccessible>
     142             :                     CreateAccessible() SAL_OVERRIDE;
     143             :     virtual void SwitchView();
     144             : };
     145             : 
     146             : /**
     147             :  * View of a document
     148             :  */
     149             : class SW_DLLPUBLIC SwPagePreview: public SfxViewShell
     150             : {
     151             :     // ViewWindow and handle to core
     152             :     // current dispatcher shell
     153             :     SwPagePreviewWin*        pViewWin;
     154             :     //viewdata of the previous SwView and the new crsrposition
     155             :     OUString                sSwViewData;
     156             :     //and the new cursor position if the user double click in the PagePreview
     157             :     OUString                sNewCrsrPos;
     158             :     // to support keyboard the number of the page to go to can be set too
     159             :     sal_uInt16                  nNewPage;
     160             :     // visible range
     161             :     OUString                sPageStr;
     162             :     Size                    aDocSz;
     163             :     Rectangle               aVisArea;
     164             : 
     165             :     // MDI control elements
     166             :     SwScrollbar             *pHScrollbar;
     167             :     SwScrollbar             *pVScrollbar;
     168             :     bool                    mbHScrollbarEnabled;
     169             :     bool                    mbVScrollbarEnabled;
     170             :     ImageButton             *pPageUpBtn,
     171             :                             *pPageDownBtn;
     172             :     // dummy window for filling the lower right edge when both scrollbars are active
     173             :     ::vcl::Window           *pScrollFill;
     174             : 
     175             :     sal_uInt16              mnPageCount;
     176             :     bool                    bNormalPrint;
     177             : 
     178             :     // New members to reset design mode at draw view for form shell on switching
     179             :     // back from writer page preview to normal view.
     180             :     bool                mbResetFormDesignMode:1;
     181             :     bool                mbFormDesignModeToReset:1;
     182             : 
     183             :     SAL_DLLPRIVATE void            Init(const SwViewOption* = 0);
     184             :     SAL_DLLPRIVATE Point           AlignToPixel(const Point& rPt) const;
     185             : 
     186             :     SAL_DLLPRIVATE int             _CreateScrollbar( bool bHori );
     187             :     SAL_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * );
     188             :     SAL_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * );
     189             :     SAL_DLLPRIVATE DECL_LINK( BtnPage, Button * );
     190             :     SAL_DLLPRIVATE bool            ChgPage( int eMvMode, bool bUpdateScrollbar = true );
     191             : 
     192             :     SAL_DLLPRIVATE virtual SfxPrinter*     GetPrinter( bool bCreate = false ) SAL_OVERRIDE;
     193             :     SAL_DLLPRIVATE virtual sal_uInt16      SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ) SAL_OVERRIDE;
     194             :     SAL_DLLPRIVATE virtual bool            HasPrintOptionsPage() const SAL_OVERRIDE;
     195             :     SAL_DLLPRIVATE virtual SfxTabPage*     CreatePrintOptionsPage( vcl::Window *pParent,
     196             :                                                 const SfxItemSet &rOptions ) SAL_OVERRIDE;
     197             : 
     198             :     SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, bool bInner );
     199             : 
     200             :     /** Helper method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
     201             : 
     202             :         @param _bPgUp
     203             :         input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
     204             :         has to be executed.
     205             : 
     206             :         @param _pReq
     207             :         optional input parameter - pointer to the <SfxRequest> instance, if existing.
     208             :     */
     209             :     SAL_DLLPRIVATE void _ExecPgUpAndPgDown( const bool  _bPgUp,
     210             :                              SfxRequest* _pReq = 0 );
     211             : 
     212             : protected:
     213             :     virtual void    InnerResizePixel( const Point &rOfs, const Size &rSize ) SAL_OVERRIDE;
     214             :     virtual void    OuterResizePixel( const Point &rOfs, const Size &rSize ) SAL_OVERRIDE;
     215             : 
     216             :     void         SetZoom(SvxZoomType eSet, sal_uInt16 nFactor);
     217             : 
     218             : public:
     219         270 :     SFX_DECL_VIEWFACTORY(SwPagePreview);
     220          90 :     SFX_DECL_INTERFACE(SW_PAGEPREVIEW)
     221             :     TYPEINFO_OVERRIDE();
     222             : 
     223             : private:
     224             :     /// SfxInterface initializer.
     225             :     static void InitInterface_Impl();
     226             : 
     227             : public:
     228             :     inline vcl::Window&          GetFrameWindow() const { return GetViewFrame()->GetWindow(); }
     229           0 :     inline SwViewShell*     GetViewShell() const { return pViewWin->GetViewShell(); }
     230             :     inline const Rectangle& GetVisArea() const { return aVisArea; }
     231             :     inline void             GrabFocusViewWin() { pViewWin->GrabFocus(); }
     232           0 :     inline void             RepaintCoreRect( const SwRect& rRect )
     233           0 :                                 { pViewWin->RepaintCoreRect( rRect ); }
     234             : 
     235             :     void            DocSzChgd(const Size& rNewSize);
     236             :     const Size&     GetDocSz() const { return aDocSz; }
     237             : 
     238             :     virtual void    SetVisArea( const Rectangle&, bool bUpdateScrollbar = true);
     239             : 
     240             :     inline void     AdjustEditWin();
     241             : 
     242             :     void            ScrollViewSzChg();
     243             :     void            ScrollDocSzChg();
     244             :     void            ShowHScrollbar(bool bShow);
     245             :     void            ShowVScrollbar(bool bShow);
     246             :     void            EnableHScrollbar(bool bEnable);
     247             :     void            EnableVScrollbar(bool bEnable);
     248             : 
     249           0 :     sal_uInt16      GetPageCount() const        { return mnPageCount; }
     250           0 :     sal_uInt16      GetSelectedPage() const {return pViewWin->SelectedPage();}
     251             : 
     252             :     bool            HandleWheelCommands( const CommandEvent& );
     253             : 
     254           0 :     OUString        GetPrevSwViewData() const       { return sSwViewData; }
     255           0 :     void            SetNewCrsrPos( const OUString& rStr ) { sNewCrsrPos = rStr; }
     256           0 :     const OUString& GetNewCrsrPos() const           { return sNewCrsrPos; }
     257             : 
     258           0 :     sal_uInt16          GetNewPage() const {return nNewPage;}
     259           0 :     void            SetNewPage(sal_uInt16 nSet)  {nNewPage = nSet;}
     260             : 
     261             :     // Handler
     262             :     void            Execute(SfxRequest&);
     263             :     void            GetState(SfxItemSet&);
     264             :     void            StateUndo(SfxItemSet&);
     265             : 
     266             :     SwDocShell*     GetDocShell();
     267             : 
     268             :     // apply Accessiblity options
     269             :     void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
     270             : 
     271             :     // Inline method to request values of new members
     272             :     // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
     273           0 :     inline bool ResetFormDesignMode() const
     274             :     {
     275           0 :         return mbResetFormDesignMode;
     276             :     }
     277             : 
     278           0 :     inline bool FormDesignModeToReset() const
     279             :     {
     280           0 :         return mbFormDesignModeToReset;
     281             :     }
     282             : 
     283             :     /** Adjust position of vertical scrollbar
     284             : 
     285             :         Currently used, if the complete preview layout rows fit into to the given
     286             :         window, if a new page is selected and this page is visible.
     287             : 
     288             :         @param _nNewThumbPos
     289             :         input parameter - new position, which will be assigned to the vertical
     290             :         scrollbar.
     291             :     */
     292             :     void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
     293             : 
     294             :     SwPagePreview( SfxViewFrame* pFrame, SfxViewShell* );
     295             :     virtual ~SwPagePreview();
     296             : };
     297             : 
     298             : inline void SwPagePreview::AdjustEditWin()
     299             : {
     300             :     OuterResizePixel( Point(), GetFrameWindow().GetOutputSizePixel() );
     301             : }
     302             : 
     303             : #endif
     304             : 
     305             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10