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