Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SWPVIEW_HXX
29 : : #define _SWPVIEW_HXX
30 : :
31 : : #include <tools/link.hxx>
32 : : #include <vcl/window.hxx>
33 : : #include <sfx2/viewfrm.hxx>
34 : : #include <sfx2/viewfac.hxx>
35 : : #include <sfx2/viewsh.hxx>
36 : : #include <sfx2/zoomitem.hxx>
37 : : #include "swdllapi.h"
38 : : #include "shellid.hxx"
39 : :
40 : : class SwViewOption;
41 : : class SwDocShell;
42 : : class SwScrollbar;
43 : : class ViewShell;
44 : : class SwPagePreView;
45 : : class ImageButton;
46 : : class Button;
47 : : class SwRect;
48 : : class DataChangedEvent;
49 : : class CommandEvent;
50 : : class SvtAccessibilityOptions;
51 : : // OD 12.12.2002 #103492#
52 : : class SwPagePreviewLayout;
53 : :
54 : : // OD 24.03.2003 #108282# - delete member <mnVirtPage> and its accessor.
55 : : class SwPagePreViewWin : public Window
56 : : {
57 : : ViewShell* mpViewShell;
58 : : sal_uInt16 mnSttPage;
59 : : sal_uInt8 mnRow, mnCol;
60 : : Size maPxWinSize;
61 : : Fraction maScale;
62 : : SwPagePreView& mrView;
63 : : // OD 02.12.2002 #103492#
64 : : bool mbCalcScaleForPreviewLayout;
65 : : Rectangle maPaintedPreviewDocRect;
66 : : // OD 12.12.2002 #103492#
67 : : SwPagePreviewLayout* mpPgPrevwLayout;
68 : :
69 : : void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
70 : :
71 : : using Window::Scroll;
72 : :
73 : : public:
74 : : SwPagePreViewWin( Window* pParent, SwPagePreView& rView );
75 : : ~SwPagePreViewWin();
76 : :
77 : : // calls ViewShell::Paint
78 : : virtual void Paint( const Rectangle& rRect );
79 : : virtual void KeyInput( const KeyEvent & );
80 : : virtual void Command( const CommandEvent& rCEvt );
81 : : virtual void MouseButtonDown(const MouseEvent& rMEvt);
82 : : virtual void DataChanged( const DataChangedEvent& );
83 : :
84 : : void SetViewShell( ViewShell* pShell );
85 : :
86 : 0 : ViewShell* GetViewShell() const { return mpViewShell; }
87 : :
88 : 0 : sal_uInt8 GetRow() const { return mnRow; }
89 : : void SetRow( sal_uInt8 n ) { if( n ) mnRow = n; }
90 : :
91 : 0 : sal_uInt8 GetCol() const { return mnCol; }
92 : : void SetCol( sal_uInt8 n ) { if( n ) mnCol = n; }
93 : :
94 : 0 : sal_uInt16 GetSttPage() const { return mnSttPage; }
95 : 0 : void SetSttPage( sal_uInt16 n ) { mnSttPage = n; }
96 : :
97 : : /** get selected page number of document preview
98 : :
99 : : OD 13.12.2002 #103492#
100 : :
101 : : @author OD
102 : :
103 : : @return selected page number
104 : : */
105 : : sal_uInt16 SelectedPage() const;
106 : :
107 : : /** set selected page number in document preview
108 : :
109 : : OD 13.12.2002 #103492#
110 : :
111 : : @author OD
112 : :
113 : : @param _nSelectedPageNum
114 : : input parameter - physical page number of page that will be the selected one.
115 : : */
116 : : void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
117 : :
118 : : //JP 19.08.98: bei Einspaltigkeit gibt es keine 0. Seite!
119 [ # # ]: 0 : sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; }
120 : :
121 : : void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
122 : :
123 : : const Size& GetWinSize() const { return maPxWinSize; }
124 : : void SetWinSize( const Size& rNewSize );
125 : :
126 : : // OD 18.12.2002 #103492# - add <MV_SELPAGE>, <MV_SCROLL>
127 : : enum MoveMode{ MV_CALC, MV_PAGE_UP, MV_PAGE_DOWN, MV_DOC_STT, MV_DOC_END,
128 : : MV_SELPAGE, MV_SCROLL, MV_NEWWINSIZE };
129 : : int MovePage( int eMoveMode );
130 : :
131 : : // erzeuge den String fuer die StatusLeiste
132 : : void GetStatusStr( String& rStr, sal_uInt16 nPageCount ) const;
133 : :
134 : : void RepaintCoreRect( const SwRect& rRect );
135 : :
136 : : /** method to adjust preview to a new zoom factor
137 : :
138 : : OD 02.12.2002 #103492#
139 : : paint of preview is prepared for a new zoom factor
140 : : OD 24.09.2003 #i19975# - zoom type has also been considered.
141 : : Thus, add new parameter <_eZoomType>
142 : :
143 : : @author OD
144 : : */
145 : : void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
146 : : const SvxZoomType _eZoomType );
147 : :
148 : 0 : const Rectangle& GetPaintedPreviewDocRect() const
149 : : {
150 : 0 : return maPaintedPreviewDocRect;
151 : : }
152 : :
153 : : void Scroll(long nXMove, long nYMove, sal_uInt16 nFlags = 0);
154 : :
155 : : /** method to enable/disable book preview
156 : :
157 : : OD 2004-03-05 #i18143#
158 : :
159 : : @author OD
160 : :
161 : : @param _bBookPreview
162 : : input parameter - boolean indicating, if book preview mode has to
163 : : switch on <sal_True> or of <sal_False>
164 : :
165 : : @return boolean indicating, if book preview mode has changed.
166 : : */
167 : : bool SetBookPreviewMode( const bool _bBookPreview );
168 : :
169 : : virtual ::com::sun::star::uno::Reference<
170 : : ::com::sun::star::accessibility::XAccessible>
171 : : CreateAccessible();
172 : : };
173 : :
174 : : /*--------------------------------------------------------------------
175 : : Description: view of a document
176 : : --------------------------------------------------------------------*/
177 : : class SW_DLLPUBLIC SwPagePreView: public SfxViewShell
178 : : {
179 : : // ViewWindow and handle to core
180 : : // current dispatcher shell
181 : : SwPagePreViewWin aViewWin;
182 : : //viewdata of the previous SwView and the new crsrposition
183 : : String sSwViewData,
184 : : //and the new cursor position if the user double click in the PagePreView
185 : : sNewCrsrPos;
186 : : // to support keyboard the number of the page to go to can be set too
187 : : sal_uInt16 nNewPage;
188 : : // visible range
189 : : String sPageStr;
190 : : Size aDocSz;
191 : : Rectangle aVisArea;
192 : :
193 : : // MDI control elements
194 : : SwScrollbar *pHScrollbar;
195 : : SwScrollbar *pVScrollbar;
196 : : ImageButton *pPageUpBtn,
197 : : *pPageDownBtn;
198 : : // dummy window for filling the lower right edge when both scrollbars are active
199 : : Window *pScrollFill;
200 : :
201 : : sal_uInt16 mnPageCount;
202 : : sal_Bool bNormalPrint;
203 : :
204 : : // OD 09.01.2003 #106334#
205 : : // new members to reset design mode at draw view for form shell on switching
206 : : // back from writer page preview to normal view.
207 : : sal_Bool mbResetFormDesignMode:1;
208 : : sal_Bool mbFormDesignModeToReset:1;
209 : :
210 : : SW_DLLPRIVATE void Init(const SwViewOption* = 0);
211 : : SW_DLLPRIVATE Point AlignToPixel(const Point& rPt) const;
212 : :
213 : : SW_DLLPRIVATE int _CreateScrollbar( sal_Bool bHori );
214 : : SW_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * );
215 : : SW_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * );
216 : : SW_DLLPRIVATE DECL_LINK( BtnPage, Button * );
217 : : SW_DLLPRIVATE int ChgPage( int eMvMode, int bUpdateScrollbar = sal_True );
218 : :
219 : :
220 : : SW_DLLPRIVATE virtual SfxPrinter* GetPrinter( sal_Bool bCreate = sal_False );
221 : : SW_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
222 : : SW_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent,
223 : : const SfxItemSet &rOptions );
224 : :
225 : : SW_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool bInner );
226 : :
227 : : /** help method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
228 : :
229 : : OD 04.03.2003 #107369#
230 : :
231 : : @param _bPgUp
232 : : input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
233 : : has to be executed.
234 : :
235 : : @param _pReq
236 : : optional input parameter - pointer to the <SfxRequest> instance, if existing.
237 : :
238 : : @author OD
239 : : */
240 : : SW_DLLPRIVATE void _ExecPgUpAndPgDown( const bool _bPgUp,
241 : : SfxRequest* _pReq = 0 );
242 : :
243 : : protected:
244 : : virtual void InnerResizePixel( const Point &rOfs, const Size &rSize );
245 : : virtual void OuterResizePixel( const Point &rOfs, const Size &rSize );
246 : : virtual Size GetOptimalSizePixel() const;
247 : :
248 : : void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor);
249 : :
250 : : public:
251 : 201 : SFX_DECL_VIEWFACTORY(SwPagePreView);
252 : 73 : SFX_DECL_INTERFACE(SW_PAGEPREVIEW)
253 : : TYPEINFO();
254 : :
255 : : inline Window* GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); }
256 : 0 : inline ViewShell* GetViewShell() const { return aViewWin.GetViewShell(); }
257 : : inline const Rectangle& GetVisArea() const { return aVisArea; }
258 : : inline void GrabFocusViewWin() { aViewWin.GrabFocus(); }
259 : 0 : inline void RepaintCoreRect( const SwRect& rRect )
260 : 0 : { aViewWin.RepaintCoreRect( rRect ); }
261 : :
262 : : void DocSzChgd(const Size& rNewSize);
263 : : const Size& GetDocSz() const { return aDocSz; }
264 : :
265 : : virtual void SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True);
266 : :
267 : : inline void AdjustEditWin();
268 : :
269 : : void ScrollViewSzChg();
270 : : void ScrollDocSzChg();
271 : : void ShowHScrollbar(sal_Bool bShow);
272 : :
273 : : void ShowVScrollbar(sal_Bool bShow);
274 : :
275 : 0 : sal_uInt16 GetPageCount() const { return mnPageCount; }
276 : 0 : sal_uInt16 GetSelectedPage() const {return aViewWin.SelectedPage();}
277 : :
278 : : sal_Bool HandleWheelCommands( const CommandEvent& );
279 : :
280 : 0 : const String& GetPrevSwViewData() const { return sSwViewData; }
281 : 0 : void SetNewCrsrPos( const String& rStr ) { sNewCrsrPos = rStr; }
282 : 0 : const String& GetNewCrsrPos() const { return sNewCrsrPos; }
283 : :
284 : 0 : sal_uInt16 GetNewPage() const {return nNewPage;}
285 : 0 : void SetNewPage(sal_uInt16 nSet) {nNewPage = nSet;}
286 : :
287 : : // handler
288 : : void Execute(SfxRequest&);
289 : : void GetState(SfxItemSet&);
290 : : void StateUndo(SfxItemSet&);
291 : :
292 : : SwDocShell* GetDocShell();
293 : :
294 : : //apply Accessiblity options
295 : : void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
296 : :
297 : : // OD 09.01.2003 #106334# - inline method to request values of new members
298 : : // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
299 : 0 : inline sal_Bool ResetFormDesignMode() const
300 : : {
301 : 0 : return mbResetFormDesignMode;
302 : : }
303 : :
304 : 0 : inline sal_Bool FormDesignModeToReset() const
305 : : {
306 : 0 : return mbFormDesignModeToReset;
307 : : }
308 : :
309 : : /** adjust position of vertical scrollbar
310 : :
311 : : OD 19.02.2003 #107369
312 : : Currently used, if the complete preview layout rows fit into to the given
313 : : window, if a new page is selected and this page is visible.
314 : :
315 : : @author OD
316 : :
317 : : @param _nNewThumbPos
318 : : input parameter - new position, which will be assigned to the vertical
319 : : scrollbar.
320 : : */
321 : : void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
322 : :
323 : : SwPagePreView( SfxViewFrame* pFrame, SfxViewShell* );
324 : : ~SwPagePreView();
325 : : };
326 : :
327 : : // ----------------- inline methods ----------------------
328 : : inline void SwPagePreView::AdjustEditWin()
329 : : {
330 : : OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() );
331 : : }
332 : :
333 : : #endif
334 : :
335 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|