bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / inc / pview.hxx
blobfbb8a725395f5e9f1d3f73ddfb3ffe33b55b3e65
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SWPVIEW_HXX
20 #define _SWPVIEW_HXX
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"
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 class SwPagePreviewLayout;
44 // Delete member <mnVirtPage> and its accessor
45 class SwPagePreViewWin : public Window
47 ViewShell* 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* mpPgPrevwLayout;
57 void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
59 using Window::Scroll;
61 public:
62 SwPagePreViewWin( Window* pParent, SwPagePreView& rView );
63 ~SwPagePreViewWin();
65 // calls ViewShell::Paint
66 virtual void Paint( const Rectangle& rRect );
67 virtual void KeyInput( const KeyEvent & );
68 virtual void Command( const CommandEvent& rCEvt );
69 virtual void MouseButtonDown(const MouseEvent& rMEvt);
70 virtual void DataChanged( const DataChangedEvent& );
72 void SetViewShell( ViewShell* pShell );
74 ViewShell* GetViewShell() const { return mpViewShell; }
76 sal_uInt8 GetRow() const { return mnRow; }
77 void SetRow( sal_uInt8 n ) { if( n ) mnRow = n; }
79 sal_uInt8 GetCol() const { return mnCol; }
80 void SetCol( sal_uInt8 n ) { if( n ) mnCol = n; }
82 sal_uInt16 GetSttPage() const { return mnSttPage; }
83 void SetSttPage( sal_uInt16 n ) { mnSttPage = n; }
85 /** get selected page number of document preview
87 @return selected page number
89 sal_uInt16 SelectedPage() const;
91 /** set selected page number in document preview
93 @param _nSelectedPageNum
94 input parameter - physical page number of page that will be the selected one.
96 void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
98 // If we only have one column we do not have a oth page
99 sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; }
101 void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
103 const Size& GetWinSize() const { return maPxWinSize; }
104 void SetWinSize( const Size& rNewSize );
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 );
111 // Create the status bar's string
112 OUString GetStatusStr( sal_uInt16 nPageCount ) const;
114 void RepaintCoreRect( const SwRect& rRect );
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>
121 void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
122 const SvxZoomType _eZoomType );
124 const Rectangle& GetPaintedPreviewDocRect() const
126 return maPaintedPreviewDocRect;
129 void Scroll(long nXMove, long nYMove, sal_uInt16 nFlags = 0);
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>
136 @return boolean indicating, if book preview mode has changed.
138 bool SetBookPreviewMode( const bool _bBookPreview );
140 virtual ::com::sun::star::uno::Reference<
141 ::com::sun::star::accessibility::XAccessible>
142 CreateAccessible();
146 * View of a document
148 class SW_DLLPUBLIC SwPagePreView: public SfxViewShell
150 // ViewWindow and handle to core
151 // current dispatcher shell
152 SwPagePreViewWin aViewWin;
153 //viewdata of the previous SwView and the new crsrposition
154 String sSwViewData,
155 //and the new cursor position if the user double click in the PagePreView
156 sNewCrsrPos;
157 // to support keyboard the number of the page to go to can be set too
158 sal_uInt16 nNewPage;
159 // visible range
160 OUString sPageStr;
161 Size aDocSz;
162 Rectangle aVisArea;
164 // MDI control elements
165 SwScrollbar *pHScrollbar;
166 SwScrollbar *pVScrollbar;
167 bool mbHScrollbarEnabled;
168 bool mbVScrollbarEnabled;
169 ImageButton *pPageUpBtn,
170 *pPageDownBtn;
171 // dummy window for filling the lower right edge when both scrollbars are active
172 Window *pScrollFill;
174 sal_uInt16 mnPageCount;
175 sal_Bool bNormalPrint;
177 // New members to reset design mode at draw view for form shell on switching
178 // back from writer page preview to normal view.
179 sal_Bool mbResetFormDesignMode:1;
180 sal_Bool mbFormDesignModeToReset:1;
182 SW_DLLPRIVATE void Init(const SwViewOption* = 0);
183 SW_DLLPRIVATE Point AlignToPixel(const Point& rPt) const;
185 SW_DLLPRIVATE int _CreateScrollbar( sal_Bool bHori );
186 SW_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * );
187 SW_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * );
188 SW_DLLPRIVATE DECL_LINK( BtnPage, Button * );
189 SW_DLLPRIVATE int ChgPage( int eMvMode, int bUpdateScrollbar = sal_True );
192 SW_DLLPRIVATE virtual SfxPrinter* GetPrinter( sal_Bool bCreate = sal_False );
193 SW_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
194 SW_DLLPRIVATE virtual bool HasPrintOptionsPage() const;
195 SW_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent,
196 const SfxItemSet &rOptions );
198 SW_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool bInner );
200 /** Helper method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
202 @param _bPgUp
203 input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
204 has to be executed.
206 @param _pReq
207 optional input parameter - pointer to the <SfxRequest> instance, if existing.
209 SW_DLLPRIVATE void _ExecPgUpAndPgDown( const bool _bPgUp,
210 SfxRequest* _pReq = 0 );
212 protected:
213 virtual void InnerResizePixel( const Point &rOfs, const Size &rSize );
214 virtual void OuterResizePixel( const Point &rOfs, const Size &rSize );
216 void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor);
218 public:
219 SFX_DECL_VIEWFACTORY(SwPagePreView);
220 SFX_DECL_INTERFACE(SW_PAGEPREVIEW)
221 TYPEINFO();
223 inline Window* GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); }
224 inline ViewShell* GetViewShell() const { return aViewWin.GetViewShell(); }
225 inline const Rectangle& GetVisArea() const { return aVisArea; }
226 inline void GrabFocusViewWin() { aViewWin.GrabFocus(); }
227 inline void RepaintCoreRect( const SwRect& rRect )
228 { aViewWin.RepaintCoreRect( rRect ); }
230 void DocSzChgd(const Size& rNewSize);
231 const Size& GetDocSz() const { return aDocSz; }
233 virtual void SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True);
235 inline void AdjustEditWin();
237 void ScrollViewSzChg();
238 void ScrollDocSzChg();
239 void ShowHScrollbar(sal_Bool bShow);
240 void ShowVScrollbar(sal_Bool bShow);
241 void EnableHScrollbar(bool bEnable);
242 void EnableVScrollbar(bool bEnable);
244 sal_uInt16 GetPageCount() const { return mnPageCount; }
245 sal_uInt16 GetSelectedPage() const {return aViewWin.SelectedPage();}
247 sal_Bool HandleWheelCommands( const CommandEvent& );
249 const String& GetPrevSwViewData() const { return sSwViewData; }
250 void SetNewCrsrPos( const String& rStr ) { sNewCrsrPos = rStr; }
251 const String& GetNewCrsrPos() const { return sNewCrsrPos; }
253 sal_uInt16 GetNewPage() const {return nNewPage;}
254 void SetNewPage(sal_uInt16 nSet) {nNewPage = nSet;}
256 // Handler
257 void Execute(SfxRequest&);
258 void GetState(SfxItemSet&);
259 void StateUndo(SfxItemSet&);
261 SwDocShell* GetDocShell();
263 // apply Accessiblity options
264 void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
266 // Inline method to request values of new members
267 // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
268 inline sal_Bool ResetFormDesignMode() const
270 return mbResetFormDesignMode;
273 inline sal_Bool FormDesignModeToReset() const
275 return mbFormDesignModeToReset;
278 /** Adjust position of vertical scrollbar
280 Currently used, if the complete preview layout rows fit into to the given
281 window, if a new page is selected and this page is visible.
283 @param _nNewThumbPos
284 input parameter - new position, which will be assigned to the vertical
285 scrollbar.
287 void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
289 SwPagePreView( SfxViewFrame* pFrame, SfxViewShell* );
290 ~SwPagePreView();
293 // ----------------- inline methods ----------------------
294 inline void SwPagePreView::AdjustEditWin()
296 OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() );
299 #endif
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */