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_UI_INC_PVIEW_HXX
20 : #define INCLUDED_SW_SOURCE_UI_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 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( 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 : Window *pScrollFill;
174 :
175 : sal_uInt16 mnPageCount;
176 : sal_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 : sal_Bool mbResetFormDesignMode:1;
181 : sal_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( sal_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, int bUpdateScrollbar = sal_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( Window *pParent,
196 : const SfxItemSet &rOptions ) SAL_OVERRIDE;
197 :
198 : SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_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 0 : SFX_DECL_VIEWFACTORY(SwPagePreview);
220 0 : SFX_DECL_INTERFACE(SW_PAGEPREVIEW)
221 : TYPEINFO_OVERRIDE();
222 :
223 : inline Window* GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); }
224 0 : inline SwViewShell* GetViewShell() const { return pViewWin->GetViewShell(); }
225 : inline const Rectangle& GetVisArea() const { return aVisArea; }
226 : inline void GrabFocusViewWin() { pViewWin->GrabFocus(); }
227 0 : inline void RepaintCoreRect( const SwRect& rRect )
228 0 : { pViewWin->RepaintCoreRect( rRect ); }
229 :
230 : void DocSzChgd(const Size& rNewSize);
231 : const Size& GetDocSz() const { return aDocSz; }
232 :
233 : virtual void SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True);
234 :
235 : inline void AdjustEditWin();
236 :
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);
243 :
244 0 : sal_uInt16 GetPageCount() const { return mnPageCount; }
245 0 : sal_uInt16 GetSelectedPage() const {return pViewWin->SelectedPage();}
246 :
247 : sal_Bool HandleWheelCommands( const CommandEvent& );
248 :
249 0 : OUString GetPrevSwViewData() const { return sSwViewData; }
250 0 : void SetNewCrsrPos( const OUString& rStr ) { sNewCrsrPos = rStr; }
251 0 : const OUString& GetNewCrsrPos() const { return sNewCrsrPos; }
252 :
253 0 : sal_uInt16 GetNewPage() const {return nNewPage;}
254 0 : void SetNewPage(sal_uInt16 nSet) {nNewPage = nSet;}
255 :
256 : // Handler
257 : void Execute(SfxRequest&);
258 : void GetState(SfxItemSet&);
259 : void StateUndo(SfxItemSet&);
260 :
261 : SwDocShell* GetDocShell();
262 :
263 : // apply Accessiblity options
264 : void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
265 :
266 : // Inline method to request values of new members
267 : // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
268 0 : inline sal_Bool ResetFormDesignMode() const
269 : {
270 0 : return mbResetFormDesignMode;
271 : }
272 :
273 0 : inline sal_Bool FormDesignModeToReset() const
274 : {
275 0 : return mbFormDesignModeToReset;
276 : }
277 :
278 : /** Adjust position of vertical scrollbar
279 :
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.
282 :
283 : @param _nNewThumbPos
284 : input parameter - new position, which will be assigned to the vertical
285 : scrollbar.
286 : */
287 : void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
288 :
289 : SwPagePreview( SfxViewFrame* pFrame, SfxViewShell* );
290 : virtual ~SwPagePreview();
291 : };
292 :
293 : // ----------------- inline methods ----------------------
294 : inline void SwPagePreview::AdjustEditWin()
295 : {
296 : OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() );
297 : }
298 :
299 : #endif
300 :
301 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|