1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pview.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <tools/link.hxx>
34 #include <vcl/window.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/viewfac.hxx>
37 #include <sfx2/viewsh.hxx>
38 #include <svx/zoomitem.hxx>
40 #include "shellid.hxx"
50 class DataChangedEvent
;
52 class SvtAccessibilityOptions
;
53 // OD 12.12.2002 #103492#
54 class SwPagePreviewLayout
;
56 // OD 24.03.2003 #108282# - delete member <mnVirtPage> and its accessor.
57 class SwPagePreViewWin
: public Window
59 ViewShell
* mpViewShell
;
64 SwPagePreView
& mrView
;
65 // OD 02.12.2002 #103492#
66 bool mbCalcScaleForPreviewLayout
;
67 Rectangle maPaintedPreviewDocRect
;
68 // OD 12.12.2002 #103492#
69 SwPagePreviewLayout
* mpPgPrevwLayout
;
71 void SetPagePreview( BYTE nRow
, BYTE nCol
);
76 SwPagePreViewWin( Window
* pParent
, SwPagePreView
& rView
);
79 //Ruft ViewShell::Paint
80 virtual void Paint( const Rectangle
& rRect
);
81 virtual void KeyInput( const KeyEvent
& );
82 virtual void Command( const CommandEvent
& rCEvt
);
83 virtual void MouseButtonDown(const MouseEvent
& rMEvt
);
84 virtual void DataChanged( const DataChangedEvent
& );
86 void SetViewShell( ViewShell
* pShell
);
88 ViewShell
* GetViewShell() const { return mpViewShell
; }
90 BYTE
GetRow() const { return mnRow
; }
91 void SetRow( BYTE n
) { if( n
) mnRow
= n
; }
93 BYTE
GetCol() const { return mnCol
; }
94 void SetCol( BYTE n
) { if( n
) mnCol
= n
; }
96 USHORT
GetSttPage() const { return mnSttPage
; }
97 void SetSttPage( USHORT n
) { mnSttPage
= n
; }
99 /** get selected page number of document preview
101 OD 13.12.2002 #103492#
105 @return selected page number
107 sal_uInt16
SelectedPage() const;
109 /** set selected page number in document preview
111 OD 13.12.2002 #103492#
115 @param _nSelectedPageNum
116 input parameter - physical page number of page that will be the selected one.
118 void SetSelectedPage( sal_uInt16 _nSelectedPageNum
);
120 //JP 19.08.98: bei Einspaltigkeit gibt es keine 0. Seite!
121 USHORT
GetDefSttPage() const { return 1 == mnCol
? 1 : 0; }
123 void CalcWish( BYTE nNewRow
, BYTE nNewCol
);
125 const Size
& GetWinSize() const { return maPxWinSize
; }
126 void SetWinSize( const Size
& rNewSize
);
128 // OD 18.12.2002 #103492# - add <MV_SELPAGE>, <MV_SCROLL>
129 enum MoveMode
{ MV_CALC
, MV_PAGE_UP
, MV_PAGE_DOWN
, MV_DOC_STT
, MV_DOC_END
,
130 MV_SELPAGE
, MV_SCROLL
, MV_NEWWINSIZE
};
131 int MovePage( int eMoveMode
);
133 // erzeuge den String fuer die StatusLeiste
134 void GetStatusStr( String
& rStr
, USHORT nPageCount
) const;
136 void RepaintCoreRect( const SwRect
& rRect
);
138 /** method to adjust preview to a new zoom factor
140 OD 02.12.2002 #103492#
141 paint of preview is prepared for a new zoom factor
142 OD 24.09.2003 #i19975# - zoom type has also been considered.
143 Thus, add new parameter <_eZoomType>
147 void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor
,
148 const SvxZoomType _eZoomType
);
150 const Rectangle
& GetPaintedPreviewDocRect() const
152 return maPaintedPreviewDocRect
;
155 void Scroll(long nXMove
, long nYMove
, USHORT nFlags
= 0);
157 /** method to enable/disable book preview
159 OD 2004-03-05 #i18143#
164 input parameter - boolean indicating, if book preview mode has to
165 switch on <TRUE> or of <FALSE>
167 @return boolean indicating, if book preview mode has changed.
169 bool SetBookPreviewMode( const bool _bBookPreview
);
171 virtual ::com::sun::star::uno::Reference
<
172 ::com::sun::star::accessibility::XAccessible
>
177 /*--------------------------------------------------------------------
178 Beschreibung: Sicht auf ein Dokument
179 --------------------------------------------------------------------*/
181 class SW_DLLPUBLIC SwPagePreView
: public SfxViewShell
183 // ViewWindow und Henkel zur Core
184 // aktuelle Dispatcher-Shell
185 SwPagePreViewWin aViewWin
;
186 //viewdata of the previous SwView and the new crsrposition
188 //and the new cursor position if the user double click in the PagePreView
190 // to support keyboard the number of the page to go to can be set too
192 // Sichtbarer Bereich
197 // MDI Bedienelemente
198 SwScrollbar
*pHScrollbar
;
199 SwScrollbar
*pVScrollbar
;
200 ImageButton
*pPageUpBtn
,
202 // Dummy-Window zum F�llen der rechten unteren Ecke, wenn beide Scrollbars
209 // OD 09.01.2003 #106334#
210 // new members to reset design mode at draw view for form shell on switching
211 // back from writer page preview to normal view.
212 sal_Bool mbResetFormDesignMode
:1;
213 sal_Bool mbFormDesignModeToReset
:1;
215 SW_DLLPRIVATE
void Init(const SwViewOption
* = 0);
216 SW_DLLPRIVATE Point
AlignToPixel(const Point
& rPt
) const;
218 SW_DLLPRIVATE
int _CreateScrollbar( BOOL bHori
);
219 SW_DLLPRIVATE
DECL_LINK( ScrollHdl
, SwScrollbar
* );
220 SW_DLLPRIVATE
DECL_LINK( EndScrollHdl
, SwScrollbar
* );
221 SW_DLLPRIVATE
DECL_LINK( BtnPage
, Button
* );
222 SW_DLLPRIVATE
int ChgPage( int eMvMode
, int bUpdateScrollbar
= TRUE
);
225 SW_DLLPRIVATE
virtual USHORT
Print( SfxProgress
&rProgress
, BOOL bIsAPI
,
226 PrintDialog
*pPrintDialog
= 0 );
227 SW_DLLPRIVATE
virtual SfxPrinter
* GetPrinter( BOOL bCreate
= FALSE
);
228 SW_DLLPRIVATE
virtual USHORT
SetPrinter( SfxPrinter
*pNewPrinter
, USHORT nDiffFlags
= SFX_PRINTER_ALL
, bool bIsAPI
=false );
229 SW_DLLPRIVATE
virtual SfxTabPage
* CreatePrintOptionsPage( Window
*pParent
,
230 const SfxItemSet
&rOptions
);
231 SW_DLLPRIVATE
virtual PrintDialog
* CreatePrintDialog( Window
*pParent
);
233 SW_DLLPRIVATE
void CalcAndSetBorderPixel( SvBorder
&rToFill
, BOOL bInner
);
235 /** help method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
237 OD 04.03.2003 #107369#
240 input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
244 optional input parameter - pointer to the <SfxRequest> instance, if existing.
248 SW_DLLPRIVATE
void _ExecPgUpAndPgDown( const bool _bPgUp
,
249 SfxRequest
* _pReq
= 0 );
252 virtual void InnerResizePixel( const Point
&rOfs
, const Size
&rSize
);
253 virtual void OuterResizePixel( const Point
&rOfs
, const Size
&rSize
);
254 virtual Size
GetOptimalSizePixel() const;
256 void SetZoom(SvxZoomType eSet
, USHORT nFactor
);
259 SFX_DECL_VIEWFACTORY(SwPagePreView
);
260 SFX_DECL_INTERFACE(SW_PAGEPREVIEW
)
263 inline Window
* GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); }
264 inline ViewShell
* GetViewShell() const { return aViewWin
.GetViewShell(); }
265 inline const Rectangle
& GetVisArea() const { return aVisArea
; }
266 inline void GrabFocusViewWin() { aViewWin
.GrabFocus(); }
267 inline void RepaintCoreRect( const SwRect
& rRect
)
268 { aViewWin
.RepaintCoreRect( rRect
); }
270 void DocSzChgd(const Size
& rNewSize
);
271 const Size
& GetDocSz() const { return aDocSz
; }
273 virtual void SetVisArea( const Rectangle
&, BOOL bUpdateScrollbar
= TRUE
);
275 inline void AdjustEditWin();
277 void ScrollViewSzChg();
278 void ScrollDocSzChg();
279 void ShowHScrollbar(sal_Bool bShow
);
281 void ShowVScrollbar(sal_Bool bShow
);
283 USHORT
GetPageCount() const { return mnPageCount
; }
285 BOOL
HandleWheelCommands( const CommandEvent
& );
287 const String
& GetPrevSwViewData() const { return sSwViewData
; }
288 void SetNewCrsrPos( const String
& rStr
) { sNewCrsrPos
= rStr
; }
289 const String
& GetNewCrsrPos() const { return sNewCrsrPos
; }
291 USHORT
GetNewPage() const {return nNewPage
;}
292 void SetNewPage(USHORT nSet
) {nNewPage
= nSet
;}
295 void Execute(SfxRequest
&);
296 void GetState(SfxItemSet
&);
297 void StateUndo(SfxItemSet
&);
299 SwDocShell
* GetDocShell();
301 //apply Accessiblity options
302 void ApplyAccessiblityOptions(SvtAccessibilityOptions
& rAccessibilityOptions
);
304 // OD 09.01.2003 #106334# - inline method to request values of new members
305 // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
306 inline sal_Bool
ResetFormDesignMode() const
308 return mbResetFormDesignMode
;
311 inline sal_Bool
FormDesignModeToReset() const
313 return mbFormDesignModeToReset
;
316 /** adjust position of vertical scrollbar
318 OD 19.02.2003 #107369
319 Currently used, if the complete preview layout rows fit into to the given
320 window, if a new page is selected and this page is visible.
325 input parameter - new position, which will be assigned to the vertical
328 void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos
);
330 SwPagePreView( SfxViewFrame
* pFrame
, SfxViewShell
* );
334 // ----------------- inline Methoden ----------------------
337 inline void SwPagePreView::AdjustEditWin()
339 OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() );