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