xref: /aoo4110/main/sw/source/ui/inc/pview.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SWPVIEW_HXX
24 #define _SWPVIEW_HXX
25 
26 #include <tools/link.hxx>
27 #include <vcl/window.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <sfx2/viewfac.hxx>
30 #include <sfx2/viewsh.hxx>
31 #include <svx/zoomitem.hxx>
32 #include "swdllapi.h"
33 #include "shellid.hxx"
34 
35 class SwViewOption;
36 class SwDocShell;
37 class SwScrollbar;
38 class ViewShell;
39 class SwPagePreView;
40 class ImageButton;
41 class Button;
42 class SwRect;
43 class DataChangedEvent;
44 class CommandEvent;
45 class SvtAccessibilityOptions;
46 // OD 12.12.2002 #103492#
47 class SwPagePreviewLayout;
48 
49 // OD 24.03.2003 #108282# - delete member <mnVirtPage> and its accessor.
50 class SwPagePreViewWin : public Window
51 {
52     ViewShell*          mpViewShell;
53     sal_uInt16              mnSttPage;
54     sal_uInt8                mnRow, mnCol;
55     Size                maPxWinSize;
56     Fraction            maScale;
57     SwPagePreView&      mrView;
58     // OD 02.12.2002 #103492#
59     bool                mbCalcScaleForPreviewLayout;
60     Rectangle           maPaintedPreviewDocRect;
61     // OD 12.12.2002 #103492#
62     SwPagePreviewLayout* mpPgPrevwLayout;
63 
64 	void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
65 
66     using Window::Scroll;
67 
68 public:
69 	SwPagePreViewWin( Window* pParent, SwPagePreView& rView );
70 	~SwPagePreViewWin();
71 
72 	//Ruft ViewShell::Paint
73 	virtual void Paint( const Rectangle& rRect );
74 	virtual void KeyInput( const KeyEvent & );
75 	virtual void Command( const CommandEvent& rCEvt );
76 	virtual void MouseButtonDown(const MouseEvent& rMEvt);
77 	virtual void DataChanged( const DataChangedEvent& );
78 
79     void SetViewShell( ViewShell* pShell );
80 
GetViewShell() const81     ViewShell* GetViewShell() const { return mpViewShell; }
82 
GetRow() const83     sal_uInt8    GetRow() const      { return mnRow; }
SetRow(sal_uInt8 n)84     void    SetRow( sal_uInt8 n )    { if( n ) mnRow = n; }
85 
GetCol() const86     sal_uInt8    GetCol() const      { return mnCol; }
SetCol(sal_uInt8 n)87     void    SetCol( sal_uInt8 n )    { if( n ) mnCol = n; }
88 
GetSttPage() const89     sal_uInt16  GetSttPage() const      { return mnSttPage; }
SetSttPage(sal_uInt16 n)90     void    SetSttPage( sal_uInt16 n )  { mnSttPage = n; }
91 
92     /** get selected page number of document preview
93 
94         OD 13.12.2002 #103492#
95 
96         @author OD
97 
98         @return selected page number
99     */
100     sal_uInt16 SelectedPage() const;
101 
102     /** set selected page number in document preview
103 
104         OD 13.12.2002 #103492#
105 
106         @author OD
107 
108         @param _nSelectedPageNum
109         input parameter - physical page number of page that will be the selected one.
110     */
111     void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
112 
113     //JP 19.08.98: bei Einspaltigkeit gibt es keine 0. Seite!
GetDefSttPage() const114     sal_uInt16  GetDefSttPage() const   { return 1 == mnCol ? 1 : 0; }
115 
116 	void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
117 
GetWinSize() const118     const Size& GetWinSize() const  { return maPxWinSize; }
119 	void SetWinSize( const Size& rNewSize );
120 
121     // OD 18.12.2002 #103492# - add <MV_SELPAGE>, <MV_SCROLL>
122     enum MoveMode{ MV_CALC, MV_PAGE_UP, MV_PAGE_DOWN, MV_DOC_STT, MV_DOC_END,
123                    MV_SELPAGE, MV_SCROLL, MV_NEWWINSIZE };
124 	int MovePage( int eMoveMode );
125 
126 	// erzeuge den String fuer die StatusLeiste
127 	void GetStatusStr( String& rStr, sal_uInt16 nPageCount ) const;
128 
129 	void RepaintCoreRect( const SwRect& rRect );
130 
131     /** method to adjust preview to a new zoom factor
132 
133         OD 02.12.2002 #103492#
134         paint of preview is prepared for a new zoom factor
135         OD 24.09.2003 #i19975# - zoom type has also been considered.
136         Thus, add new parameter <_eZoomType>
137 
138         @author OD
139     */
140     void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
141                                  const SvxZoomType _eZoomType );
142 
GetPaintedPreviewDocRect() const143     const Rectangle& GetPaintedPreviewDocRect() const
144     {
145         return maPaintedPreviewDocRect;
146     }
147 
148     void Scroll(long nXMove, long nYMove, sal_uInt16 nFlags = 0);
149 
150     /** method to enable/disable book preview
151 
152         OD 2004-03-05 #i18143#
153 
154         @author OD
155 
156         @param _bBookPreview
157         input parameter - boolean indicating, if book preview mode has to
158         switch on <sal_True> or of <sal_False>
159 
160         @return boolean indicating, if book preview mode has changed.
161     */
162     bool SetBookPreviewMode( const bool _bBookPreview );
163 
164     virtual ::com::sun::star::uno::Reference<
165         ::com::sun::star::accessibility::XAccessible>
166                     CreateAccessible();
167 	virtual void SwitchView();
168 };
169 
170 
171 /*--------------------------------------------------------------------
172 	Beschreibung:   Sicht auf ein Dokument
173  --------------------------------------------------------------------*/
174 
175 class SW_DLLPUBLIC SwPagePreView: public SfxViewShell
176 {
177 	// ViewWindow und Henkel zur Core
178 	// aktuelle Dispatcher-Shell
179 	SwPagePreViewWin*        pViewWin;	//viewdata of the previous SwView and the new crsrposition
180 	String 					sSwViewData,
181 	//and the new cursor position if the user double click in the PagePreView
182 							sNewCrsrPos;
183     // to support keyboard the number of the page to go to can be set too
184     sal_uInt16                  nNewPage;
185     // Sichtbarer Bereich
186 	String                  sPageStr;
187 	Size                    aDocSz;
188 	Rectangle               aVisArea;
189 
190 	// MDI Bedienelemente
191 	SwScrollbar             *pHScrollbar;
192 	SwScrollbar             *pVScrollbar;
193 	ImageButton             *pPageUpBtn,
194 							*pPageDownBtn;
195 	// Dummy-Window zum F�llen der rechten unteren Ecke, wenn beide Scrollbars
196 	// aktiv sind
197 	Window					*pScrollFill;
198 
199     sal_uInt16                  mnPageCount;
200 	sal_Bool                    bNormalPrint;
201 
202     // OD 09.01.2003 #106334#
203     // new members to reset design mode at draw view for form shell on switching
204     // back from writer page preview to normal view.
205     sal_Bool                mbResetFormDesignMode:1;
206     sal_Bool                mbFormDesignModeToReset:1;
207 
208 	SW_DLLPRIVATE void            Init(const SwViewOption* = 0);
209 	SW_DLLPRIVATE Point           AlignToPixel(const Point& rPt) const;
210 
211     SW_DLLPRIVATE int             _CreateScrollbar( sal_Bool bHori );
212 	SW_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * );
213 	SW_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * );
214 	SW_DLLPRIVATE DECL_LINK( BtnPage, Button * );
215 	SW_DLLPRIVATE int             ChgPage( int eMvMode, int bUpdateScrollbar = sal_True );
216 
217 
218 	SW_DLLPRIVATE virtual SfxPrinter*     GetPrinter( sal_Bool bCreate = sal_False );
219     SW_DLLPRIVATE virtual sal_uInt16          SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
220 	SW_DLLPRIVATE virtual SfxTabPage*     CreatePrintOptionsPage( Window *pParent,
221 												const SfxItemSet &rOptions );
222 
223 	SW_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool bInner );
224 
225     /** help method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
226 
227         OD 04.03.2003 #107369#
228 
229         @param _bPgUp
230         input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
231         has to be executed.
232 
233         @param _pReq
234         optional input parameter - pointer to the <SfxRequest> instance, if existing.
235 
236         @author OD
237     */
238     SW_DLLPRIVATE void _ExecPgUpAndPgDown( const bool  _bPgUp,
239                              SfxRequest* _pReq = 0 );
240 
241 protected:
242 	virtual void    InnerResizePixel( const Point &rOfs, const Size &rSize );
243 	virtual void    OuterResizePixel( const Point &rOfs, const Size &rSize );
244 	virtual Size	GetOptimalSizePixel() const;
245 
246     void         SetZoom(SvxZoomType eSet, sal_uInt16 nFactor);
247 
248 public:
249 	SFX_DECL_VIEWFACTORY(SwPagePreView);
250 	SFX_DECL_INTERFACE(SW_PAGEPREVIEW)
251 	TYPEINFO();
252 
GetFrameWindow() const253 	inline Window*          GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); }
GetViewShell() const254     inline ViewShell*       GetViewShell() const { return pViewWin->GetViewShell(); }
GetVisArea() const255 	inline const Rectangle& GetVisArea() const { return aVisArea; }
GrabFocusViewWin()256 	inline void             GrabFocusViewWin() { pViewWin->GrabFocus(); }
RepaintCoreRect(const SwRect & rRect)257 	inline void             RepaintCoreRect( const SwRect& rRect )
258 								{ pViewWin->RepaintCoreRect( rRect ); }
259 
260 	void            DocSzChgd(const Size& rNewSize);
GetDocSz() const261 	const Size&     GetDocSz() const { return aDocSz; }
262 
263 	virtual void    SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True);
264 
265 	inline void     AdjustEditWin();
266 
267     void            ScrollViewSzChg();
268     void            ScrollDocSzChg();
269     void            ShowHScrollbar(sal_Bool bShow);
270 
271     void            ShowVScrollbar(sal_Bool bShow);
272 
GetPageCount() const273     sal_uInt16          GetPageCount() const        { return mnPageCount; }
274 
275 	sal_Bool 			HandleWheelCommands( const CommandEvent& );
276 
GetPrevSwViewData() const277 	const String&	GetPrevSwViewData() const		{ return sSwViewData; }
SetNewCrsrPos(const String & rStr)278 	void 			SetNewCrsrPos( const String& rStr ) { sNewCrsrPos = rStr; }
GetNewCrsrPos() const279 	const String&	GetNewCrsrPos() const			{ return sNewCrsrPos; }
280 
GetNewPage() const281     sal_uInt16          GetNewPage() const {return nNewPage;}
SetNewPage(sal_uInt16 nSet)282     void            SetNewPage(sal_uInt16 nSet)  {nNewPage = nSet;}
283 
284         // Handler
285 	void            Execute(SfxRequest&);
286 	void            GetState(SfxItemSet&);
287 	void            StateUndo(SfxItemSet&);
288 
289 	SwDocShell*     GetDocShell();
290 
291     //apply Accessiblity options
292     void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
293 
294     // OD 09.01.2003 #106334# - inline method to request values of new members
295     // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
ResetFormDesignMode() const296     inline sal_Bool ResetFormDesignMode() const
297     {
298         return mbResetFormDesignMode;
299     }
300 
FormDesignModeToReset() const301     inline sal_Bool FormDesignModeToReset() const
302     {
303         return mbFormDesignModeToReset;
304     }
305 
306     /** adjust position of vertical scrollbar
307 
308         OD 19.02.2003 #107369
309         Currently used, if the complete preview layout rows fit into to the given
310         window, if a new page is selected and this page is visible.
311 
312         @author OD
313 
314         @param _nNewThumbPos
315         input parameter - new position, which will be assigned to the vertical
316         scrollbar.
317     */
318     void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
319 
320     SwPagePreView( SfxViewFrame* pFrame, SfxViewShell* );
321 	~SwPagePreView();
322 };
323 
324 // ----------------- inline Methoden ----------------------
325 
326 
AdjustEditWin()327 inline void SwPagePreView::AdjustEditWin()
328 {
329 	OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() );
330 }
331 
332 #endif
333