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