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 81 ViewShell* GetViewShell() const { return mpViewShell; } 82 83 sal_uInt8 GetRow() const { return mnRow; } 84 void SetRow( sal_uInt8 n ) { if( n ) mnRow = n; } 85 86 sal_uInt8 GetCol() const { return mnCol; } 87 void SetCol( sal_uInt8 n ) { if( n ) mnCol = n; } 88 89 sal_uInt16 GetSttPage() const { return mnSttPage; } 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! 114 sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; } 115 116 void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol ); 117 118 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 143 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 //IAccessibility2 Implementation 2009----- 168 virtual void SwitchView(); 169 //-----IAccessibility2 Implementation 2009 170 }; 171 172 173 /*-------------------------------------------------------------------- 174 Beschreibung: Sicht auf ein Dokument 175 --------------------------------------------------------------------*/ 176 177 class SW_DLLPUBLIC SwPagePreView: public SfxViewShell 178 { 179 // ViewWindow und Henkel zur Core 180 // aktuelle Dispatcher-Shell 181 SwPagePreViewWin* pViewWin;//IAccessibility2 Implementation 2009 182 //viewdata of the previous SwView and the new crsrposition 183 String sSwViewData, 184 //and the new cursor position if the user double click in the PagePreView 185 sNewCrsrPos; 186 // to support keyboard the number of the page to go to can be set too 187 sal_uInt16 nNewPage; 188 // Sichtbarer Bereich 189 String sPageStr; 190 Size aDocSz; 191 Rectangle aVisArea; 192 193 // MDI Bedienelemente 194 SwScrollbar *pHScrollbar; 195 SwScrollbar *pVScrollbar; 196 ImageButton *pPageUpBtn, 197 *pPageDownBtn; 198 // Dummy-Window zum F�llen der rechten unteren Ecke, wenn beide Scrollbars 199 // aktiv sind 200 Window *pScrollFill; 201 202 sal_uInt16 mnPageCount; 203 sal_Bool bNormalPrint; 204 205 // OD 09.01.2003 #106334# 206 // new members to reset design mode at draw view for form shell on switching 207 // back from writer page preview to normal view. 208 sal_Bool mbResetFormDesignMode:1; 209 sal_Bool mbFormDesignModeToReset:1; 210 211 SW_DLLPRIVATE void Init(const SwViewOption* = 0); 212 SW_DLLPRIVATE Point AlignToPixel(const Point& rPt) const; 213 214 SW_DLLPRIVATE int _CreateScrollbar( sal_Bool bHori ); 215 SW_DLLPRIVATE DECL_LINK( ScrollHdl, SwScrollbar * ); 216 SW_DLLPRIVATE DECL_LINK( EndScrollHdl, SwScrollbar * ); 217 SW_DLLPRIVATE DECL_LINK( BtnPage, Button * ); 218 SW_DLLPRIVATE int ChgPage( int eMvMode, int bUpdateScrollbar = sal_True ); 219 220 221 SW_DLLPRIVATE virtual SfxPrinter* GetPrinter( sal_Bool bCreate = sal_False ); 222 SW_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ); 223 SW_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, 224 const SfxItemSet &rOptions ); 225 226 SW_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool bInner ); 227 228 /** help method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN 229 230 OD 04.03.2003 #107369# 231 232 @param _bPgUp 233 input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN 234 has to be executed. 235 236 @param _pReq 237 optional input parameter - pointer to the <SfxRequest> instance, if existing. 238 239 @author OD 240 */ 241 SW_DLLPRIVATE void _ExecPgUpAndPgDown( const bool _bPgUp, 242 SfxRequest* _pReq = 0 ); 243 244 protected: 245 virtual void InnerResizePixel( const Point &rOfs, const Size &rSize ); 246 virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ); 247 virtual Size GetOptimalSizePixel() const; 248 249 void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor); 250 251 public: 252 SFX_DECL_VIEWFACTORY(SwPagePreView); 253 SFX_DECL_INTERFACE(SW_PAGEPREVIEW) 254 TYPEINFO(); 255 256 inline Window* GetFrameWindow() const { return &(GetViewFrame())->GetWindow(); } 257 inline ViewShell* GetViewShell() const { return pViewWin->GetViewShell(); } 258 inline const Rectangle& GetVisArea() const { return aVisArea; } 259 inline void GrabFocusViewWin() { pViewWin->GrabFocus(); } 260 inline void RepaintCoreRect( const SwRect& rRect ) 261 { pViewWin->RepaintCoreRect( rRect ); } 262 263 void DocSzChgd(const Size& rNewSize); 264 const Size& GetDocSz() const { return aDocSz; } 265 266 virtual void SetVisArea( const Rectangle&, sal_Bool bUpdateScrollbar = sal_True); 267 268 inline void AdjustEditWin(); 269 270 void ScrollViewSzChg(); 271 void ScrollDocSzChg(); 272 void ShowHScrollbar(sal_Bool bShow); 273 274 void ShowVScrollbar(sal_Bool bShow); 275 276 sal_uInt16 GetPageCount() const { return mnPageCount; } 277 278 sal_Bool HandleWheelCommands( const CommandEvent& ); 279 280 const String& GetPrevSwViewData() const { return sSwViewData; } 281 void SetNewCrsrPos( const String& rStr ) { sNewCrsrPos = rStr; } 282 const String& GetNewCrsrPos() const { return sNewCrsrPos; } 283 284 sal_uInt16 GetNewPage() const {return nNewPage;} 285 void SetNewPage(sal_uInt16 nSet) {nNewPage = nSet;} 286 287 // Handler 288 void Execute(SfxRequest&); 289 void GetState(SfxItemSet&); 290 void StateUndo(SfxItemSet&); 291 292 SwDocShell* GetDocShell(); 293 294 //apply Accessiblity options 295 void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions); 296 297 // OD 09.01.2003 #106334# - inline method to request values of new members 298 // <mbResetFormDesignMode> and <mbFormDesignModeToReset> 299 inline sal_Bool ResetFormDesignMode() const 300 { 301 return mbResetFormDesignMode; 302 } 303 304 inline sal_Bool FormDesignModeToReset() const 305 { 306 return mbFormDesignModeToReset; 307 } 308 309 /** adjust position of vertical scrollbar 310 311 OD 19.02.2003 #107369 312 Currently used, if the complete preview layout rows fit into to the given 313 window, if a new page is selected and this page is visible. 314 315 @author OD 316 317 @param _nNewThumbPos 318 input parameter - new position, which will be assigned to the vertical 319 scrollbar. 320 */ 321 void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos ); 322 323 SwPagePreView( SfxViewFrame* pFrame, SfxViewShell* ); 324 ~SwPagePreView(); 325 }; 326 327 // ----------------- inline Methoden ---------------------- 328 329 330 inline void SwPagePreView::AdjustEditWin() 331 { 332 OuterResizePixel( Point(), GetFrameWindow()->GetOutputSizePixel() ); 333 } 334 335 #endif 336