LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/inc - pview.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 24 8.3 %
Date: 2012-12-27 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 _SWPVIEW_HXX
      20             : #define _SWPVIEW_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 ViewShell;
      35             : class SwPagePreView;
      36             : class ImageButton;
      37             : class Button;
      38             : class SwRect;
      39             : class DataChangedEvent;
      40             : class CommandEvent;
      41             : class SvtAccessibilityOptions;
      42             : // OD 12.12.2002 #103492#
      43             : class SwPagePreviewLayout;
      44             : 
      45             : // OD 24.03.2003 #108282# - delete member <mnVirtPage> and its accessor.
      46             : class SwPagePreViewWin : public Window
      47             : {
      48             :     ViewShell*          mpViewShell;
      49             :     sal_uInt16              mnSttPage;
      50             :     sal_uInt8                mnRow, mnCol;
      51             :     Size                maPxWinSize;
      52             :     Fraction            maScale;
      53             :     SwPagePreView&      mrView;
      54             :     // OD 02.12.2002 #103492#
      55             :     bool                mbCalcScaleForPreviewLayout;
      56             :     Rectangle           maPaintedPreviewDocRect;
      57             :     // OD 12.12.2002 #103492#
      58             :     SwPagePreviewLayout* mpPgPrevwLayout;
      59             : 
      60             :     void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
      61             : 
      62             :     using Window::Scroll;
      63             : 
      64             : public:
      65             :     SwPagePreViewWin( Window* pParent, SwPagePreView& rView );
      66             :     ~SwPagePreViewWin();
      67             : 
      68             :     // calls ViewShell::Paint
      69             :     virtual void Paint( const Rectangle& rRect );
      70             :     virtual void KeyInput( const KeyEvent & );
      71             :     virtual void Command( const CommandEvent& rCEvt );
      72             :     virtual void MouseButtonDown(const MouseEvent& rMEvt);
      73             :     virtual void DataChanged( const DataChangedEvent& );
      74             : 
      75             :     void SetViewShell( ViewShell* pShell );
      76             : 
      77           0 :     ViewShell* GetViewShell() const { return mpViewShell; }
      78             : 
      79           0 :     sal_uInt8    GetRow() const      { return mnRow; }
      80             :     void    SetRow( sal_uInt8 n )    { if( n ) mnRow = n; }
      81             : 
      82           0 :     sal_uInt8    GetCol() const      { return mnCol; }
      83             :     void    SetCol( sal_uInt8 n )    { if( n ) mnCol = n; }
      84             : 
      85           0 :     sal_uInt16  GetSttPage() const      { return mnSttPage; }
      86           0 :     void    SetSttPage( sal_uInt16 n )  { mnSttPage = n; }
      87             : 
      88             :     /** get selected page number of document preview
      89             : 
      90             :         OD 13.12.2002 #103492#
      91             : 
      92             :         @author OD
      93             : 
      94             :         @return selected page number
      95             :     */
      96             :     sal_uInt16 SelectedPage() const;
      97             : 
      98             :     /** set selected page number in document preview
      99             : 
     100             :         OD 13.12.2002 #103492#
     101             : 
     102             :         @author OD
     103             : 
     104             :         @param _nSelectedPageNum
     105             :         input parameter - physical page number of page that will be the selected one.
     106             :     */
     107             :     void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
     108             : 
     109             :     //JP 19.08.98: bei Einspaltigkeit gibt es keine 0. Seite!
     110           0 :     sal_uInt16  GetDefSttPage() const   { return 1 == mnCol ? 1 : 0; }
     111             : 
     112             :     void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
     113             : 
     114             :     const Size& GetWinSize() const  { return maPxWinSize; }
     115             :     void SetWinSize( const Size& rNewSize );
     116             : 
     117             :     // OD 18.12.2002 #103492# - add <MV_SELPAGE>, <MV_SCROLL>
     118             :     enum MoveMode{ MV_CALC, MV_PAGE_UP, MV_PAGE_DOWN, MV_DOC_STT, MV_DOC_END,
     119             :                    MV_SELPAGE, MV_SCROLL, MV_NEWWINSIZE };
     120             :     int MovePage( int eMoveMode );
     121             : 
     122             :     // erzeuge den String fuer die StatusLeiste
     123             :     OUString GetStatusStr( sal_uInt16 nPageCount ) const;
     124             : 
     125             :     void RepaintCoreRect( const SwRect& rRect );
     126             : 
     127             :     /** method to adjust preview to a new zoom factor
     128             : 
     129             :         OD 02.12.2002 #103492#
     130             :         paint of preview is prepared for a new zoom factor
     131             :         OD 24.09.2003 #i19975# - zoom type has also been considered.
     132             :         Thus, add new parameter <_eZoomType>
     133             : 
     134             :         @author OD
     135             :     */
     136             :     void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
     137             :                                  const SvxZoomType _eZoomType );
     138             : 
     139           0 :     const Rectangle& GetPaintedPreviewDocRect() const
     140             :     {
     141           0 :         return maPaintedPreviewDocRect;
     142             :     }
     143             : 
     144             :     void Scroll(long nXMove, long nYMove, sal_uInt16 nFlags = 0);
     145             : 
     146             :     /** method to enable/disable book preview
     147             : 
     148             :         OD 2004-03-05 #i18143#
     149             : 
     150             :         @author OD
     151             : 
     152             :         @param _bBookPreview
     153             :         input parameter - boolean indicating, if book preview mode has to
     154             :         switch on <sal_True> or of <sal_False>
     155             : 
     156             :         @return boolean indicating, if book preview mode has changed.
     157             :     */
     158             :     bool SetBookPreviewMode( const bool _bBookPreview );
     159             : 
     160             :     virtual ::com::sun::star::uno::Reference<
     161             :         ::com::sun::star::accessibility::XAccessible>
     162             :                     CreateAccessible();
     163             : };
     164             : 
     165             : /*--------------------------------------------------------------------
     166             :     Description:   view of a document
     167             :  --------------------------------------------------------------------*/
     168             : class SW_DLLPUBLIC SwPagePreView: public SfxViewShell
     169             : {
     170             :     // ViewWindow and handle to core
     171             :     // current dispatcher shell
     172             :     SwPagePreViewWin        aViewWin;
     173             :     //viewdata of the previous SwView and the new crsrposition
     174             :     String                  sSwViewData,
     175             :     //and the new cursor position if the user double click in the PagePreView
     176             :                             sNewCrsrPos;
     177             :     // to support keyboard the number of the page to go to can be set too
     178             :     sal_uInt16                  nNewPage;
     179             :     // visible range
     180             :     OUString                sPageStr;
     181             :     Size                    aDocSz;
     182             :     Rectangle               aVisArea;
     183             : 
     184             :     // MDI control elements
     185             :     SwScrollbar             *pHScrollbar;
     186             :     SwScrollbar             *pVScrollbar;
     187             :     bool                    mbHScrollbarEnabled;
     188             :     bool                    mbVScrollbarEnabled;
     189             :     ImageButton             *pPageUpBtn,
     190             :                             *pPageDownBtn;
     191             :     // dummy window for filling the lower right edge when both scrollbars are active
     192             :     Window                  *pScrollFill;
     193             : 
     194             :     sal_uInt16                  mnPageCount;
     195             :     sal_Bool                    bNormalPrint;
     196             : 
     197             :     // OD 09.01.2003 #106334#
     198             :     // new members to reset design mode at draw view for form shell on switching
     199             :     // back from writer page preview to normal view.
     200             :     sal_Bool                mbResetFormDesignMode:1;
     201             :     sal_Bool                mbFormDesignModeToReset:1;
     202             : 
     203             :     SW_DLLPRIVATE void            Init(const SwViewOption* = 0);
     204             :     SW_DLLPRIVATE Point           AlignToPixel(const Point& rPt) const;
     205             : 
     206             :     SW_DLLPRIVATE int             _CreateScrollbar( sal_Bool bHori );
     207             :     SW_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * );
     208             :     SW_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * );
     209             :     SW_DLLPRIVATE DECL_LINK( BtnPage, Button * );
     210             :     SW_DLLPRIVATE int             ChgPage( int eMvMode, int bUpdateScrollbar = sal_True );
     211             : 
     212             : 
     213             :     SW_DLLPRIVATE virtual SfxPrinter*     GetPrinter( sal_Bool bCreate = sal_False );
     214             :     SW_DLLPRIVATE virtual sal_uInt16      SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
     215             :     SW_DLLPRIVATE virtual bool            HasPrintOptionsPage() const;
     216             :     SW_DLLPRIVATE virtual SfxTabPage*     CreatePrintOptionsPage( Window *pParent,
     217             :                                                 const SfxItemSet &rOptions );
     218             : 
     219             :     SW_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool bInner );
     220             : 
     221             :     /** help method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
     222             : 
     223             :         OD 04.03.2003 #107369#
     224             : 
     225             :         @param _bPgUp
     226             :         input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
     227             :         has to be executed.
     228             : 
     229             :         @param _pReq
     230             :         optional input parameter - pointer to the <SfxRequest> instance, if existing.
     231             : 
     232             :         @author OD
     233             :     */
     234             :     SW_DLLPRIVATE void _ExecPgUpAndPgDown( const bool  _bPgUp,
     235             :                              SfxRequest* _pReq = 0 );
     236             : 
     237             : protected:
     238             :     virtual void    InnerResizePixel( const Point &rOfs, const Size &rSize );
     239             :     virtual void    OuterResizePixel( const Point &rOfs, const Size &rSize );
     240             :     virtual Size    GetOptimalSizePixel() const;
     241             : 
     242             :     void         SetZoom(SvxZoomType eSet, sal_uInt16 nFactor);
     243             : 
     244             : public:
     245          24 :     SFX_DECL_VIEWFACTORY(SwPagePreView);
     246          10 :     SFX_DECL_INTERFACE(SW_PAGEPREVIEW)
     247             :     TYPEINFO();
     248             : 
     249             :     inline Window*          GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); }
     250           0 :     inline ViewShell*       GetViewShell() const { return aViewWin.GetViewShell(); }
     251             :     inline const Rectangle& GetVisArea() const { return aVisArea; }
     252             :     inline void             GrabFocusViewWin() { aViewWin.GrabFocus(); }
     253           0 :     inline void             RepaintCoreRect( const SwRect& rRect )
     254           0 :                                 { aViewWin.RepaintCoreRect( rRect ); }
     255             : 
     256             :     void            DocSzChgd(const Size& rNewSize);
     257             :     const Size&     GetDocSz() const { return aDocSz; }
     258             : 
     259             :     virtual void    SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True);
     260             : 
     261             :     inline void     AdjustEditWin();
     262             : 
     263             :     void            ScrollViewSzChg();
     264             :     void            ScrollDocSzChg();
     265             :     void            ShowHScrollbar(sal_Bool bShow);
     266             :     void            ShowVScrollbar(sal_Bool bShow);
     267             :     void            EnableHScrollbar(bool bEnable);
     268             :     void            EnableVScrollbar(bool bEnable);
     269             : 
     270           0 :     sal_uInt16          GetPageCount() const        { return mnPageCount; }
     271           0 :     sal_uInt16      GetSelectedPage() const {return aViewWin.SelectedPage();}
     272             : 
     273             :     sal_Bool            HandleWheelCommands( const CommandEvent& );
     274             : 
     275           0 :     const String&   GetPrevSwViewData() const       { return sSwViewData; }
     276           0 :     void            SetNewCrsrPos( const String& rStr ) { sNewCrsrPos = rStr; }
     277           0 :     const String&   GetNewCrsrPos() const           { return sNewCrsrPos; }
     278             : 
     279           0 :     sal_uInt16          GetNewPage() const {return nNewPage;}
     280           0 :     void            SetNewPage(sal_uInt16 nSet)  {nNewPage = nSet;}
     281             : 
     282             :         // handler
     283             :     void            Execute(SfxRequest&);
     284             :     void            GetState(SfxItemSet&);
     285             :     void            StateUndo(SfxItemSet&);
     286             : 
     287             :     SwDocShell*     GetDocShell();
     288             : 
     289             :     //apply Accessiblity options
     290             :     void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
     291             : 
     292             :     // OD 09.01.2003 #106334# - inline method to request values of new members
     293             :     // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
     294           0 :     inline sal_Bool ResetFormDesignMode() const
     295             :     {
     296           0 :         return mbResetFormDesignMode;
     297             :     }
     298             : 
     299           0 :     inline sal_Bool FormDesignModeToReset() const
     300             :     {
     301           0 :         return mbFormDesignModeToReset;
     302             :     }
     303             : 
     304             :     /** adjust position of vertical scrollbar
     305             : 
     306             :         OD 19.02.2003 #107369
     307             :         Currently used, if the complete preview layout rows fit into to the given
     308             :         window, if a new page is selected and this page is visible.
     309             : 
     310             :         @author OD
     311             : 
     312             :         @param _nNewThumbPos
     313             :         input parameter - new position, which will be assigned to the vertical
     314             :         scrollbar.
     315             :     */
     316             :     void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
     317             : 
     318             :     SwPagePreView( SfxViewFrame* pFrame, SfxViewShell* );
     319             :     ~SwPagePreView();
     320             : };
     321             : 
     322             : // ----------------- inline methods ----------------------
     323             : inline void SwPagePreView::AdjustEditWin()
     324             : {
     325             :     OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() );
     326             : }
     327             : 
     328             : #endif
     329             : 
     330             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10