LibreOffice Module sw (master)  1
pview.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_PVIEW_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_PVIEW_HXX
21 
22 #include <tools/link.hxx>
23 #include <tools/fract.hxx>
24 #include <vcl/window.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <sfx2/viewfac.hxx>
27 #include <sfx2/viewsh.hxx>
28 #include <sfx2/zoomitem.hxx>
29 #include <swdllapi.h>
30 #include <shellid.hxx>
31 
32 class SwViewOption;
33 class SwDocShell;
34 class SwScrollbar;
35 class SwViewShell;
36 class SwPagePreview;
37 class ImageButton;
38 class Button;
39 class SwRect;
40 class DataChangedEvent;
41 class CommandEvent;
44 
45 // Delete member <mnVirtPage> and its accessor
46 class SAL_DLLPUBLIC_RTTI SwPagePreviewWin : public vcl::Window
47 {
49  sal_uInt16 mnSttPage;
58 
59  void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
60 
61  using Window::Scroll;
62 
63 public:
64  SwPagePreviewWin( vcl::Window* pParent, SwPagePreview& rView );
65  virtual ~SwPagePreviewWin() override;
66 
67  // calls SwViewShell::Paint
68  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
69  virtual void KeyInput( const KeyEvent & ) override;
70  virtual void Command( const CommandEvent& rCEvt ) override;
71  virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
72  virtual void DataChanged( const DataChangedEvent& ) override;
73 
74  void SetViewShell( SwViewShell* pShell );
75 
77  {
78  return mpViewShell;
79  }
80 
81  sal_uInt8 GetRow() const
82  {
83  return mnRow;
84  }
85 
86  sal_uInt8 GetCol() const
87  {
88  return mnCol;
89  }
90 
91  sal_uInt16 GetSttPage() const
92  {
93  return mnSttPage;
94  }
95 
96  void SetSttPage(sal_uInt16 n)
97  {
98  mnSttPage = n;
99  }
100 
105  sal_uInt16 SelectedPage() const;
106 
112  void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
113 
114  // If we only have one column we do not have a oth page
115  sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; }
116 
117  void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
118 
119  void SetWinSize( const Size& rNewSize );
120 
121  // 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, MV_SPECIFIC_PAGE };
124  bool MovePage( int eMoveMode );
125 
126  // Create the status bar's string
127  OUString GetStatusStr( sal_uInt16 nPageCount ) const;
128 
129  void RepaintCoreRect( const SwRect& rRect );
130 
136  void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
137  const SvxZoomType _eZoomType );
138 
140  {
141  return maPaintedPreviewDocRect;
142  }
143 
144  void Scroll(long nXMove, long nYMove, ScrollFlags nFlags = ScrollFlags::NONE) override;
145 
153  bool SetBookPreviewMode( const bool _bBookPreview );
154 
155  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
156 };
157 
162 {
163  // ViewWindow and handle to core
164  // current dispatcher shell
166  //viewdata of the previous SwView and the new cursor position
167  OUString m_sSwViewData;
168  //and the new cursor position if the user double click in the PagePreview
170  // to support keyboard the number of the page to go to can be set too
171  sal_uInt16 m_nNewPage;
172  // visible range
173  OUString const m_sPageStr;
176 
177  // MDI control elements
180  bool mbHScrollbarEnabled : 1;
181  bool mbVScrollbarEnabled : 1;
182  // dummy window for filling the lower right edge when both scrollbars are active
184 
185  sal_uInt16 mnPageCount;
187 
188  // New members to reset design mode at draw view for form shell on switching
189  // back from writer page preview to normal view.
190  bool mbResetFormDesignMode:1;
191  bool mbFormDesignModeToReset:1;
192 
193  SAL_DLLPRIVATE void Init();
194  SAL_DLLPRIVATE Point AlignToPixel(const Point& rPt) const;
195 
196  SAL_DLLPRIVATE void CreateScrollbar( bool bHori);
197  DECL_DLLPRIVATE_LINK(ScrollHdl, ScrollBar*, void);
198  DECL_DLLPRIVATE_LINK(EndScrollHdl, ScrollBar*, void);
199  SAL_DLLPRIVATE bool ChgPage( int eMvMode, bool bUpdateScrollbar = true );
200 
201  SAL_DLLPRIVATE virtual SfxPrinter* GetPrinter( bool bCreate = false ) override;
202  SAL_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ) override;
203  SAL_DLLPRIVATE virtual bool HasPrintOptionsPage() const override;
204  SAL_DLLPRIVATE virtual VclPtr<SfxTabPage> CreatePrintOptionsPage(TabPageParent pParent, const SfxItemSet &rOptions) override;
205 
206  SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill );
207 
217  SAL_DLLPRIVATE void ExecPgUpAndPgDown( const bool _bPgUp,
218  SfxRequest* _pReq );
219 
220 protected:
221  virtual void InnerResizePixel( const Point &rOfs, const Size &rSize, bool inplaceEditModeChange ) override;
222  virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ) override;
223 
224  void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor);
225 
226 public:
229 
230 private:
232  static void InitInterface_Impl();
233 
234 public:
235  SwViewShell* GetViewShell() const
236  { return m_pViewWin->GetViewShell(); }
237  void RepaintCoreRect( const SwRect& rRect )
238  { m_pViewWin->RepaintCoreRect( rRect ); }
239 
240  void DocSzChgd(const Size& rNewSize);
241 
242  void SetVisArea( const tools::Rectangle& );
243 
244  void ScrollViewSzChg();
245  void ScrollDocSzChg();
246  void ShowHScrollbar(bool bShow);
247  void ShowVScrollbar(bool bShow);
248  void EnableHScrollbar(bool bEnable);
249  void EnableVScrollbar(bool bEnable);
250 
251  sal_uInt16 GetPageCount() const { return mnPageCount; }
252  sal_uInt16 GetSelectedPage() const {return m_pViewWin->SelectedPage();}
253 
254  bool HandleWheelCommands( const CommandEvent& );
255 
256  const OUString& GetPrevSwViewData() const { return m_sSwViewData; }
257  void SetNewCursorPos( const OUString& rStr ) { m_sNewCursorPosition = rStr; }
258  const OUString& GetNewCursorPos() const { return m_sNewCursorPosition; }
259 
260  sal_uInt16 GetNewPage() const {return m_nNewPage;}
261 
262  // Handler
263  void Execute(SfxRequest&);
264  void GetState(SfxItemSet&);
265  static void StateUndo(SfxItemSet&);
266 
267  SwDocShell* GetDocShell();
268 
269  // apply Accessiblity options
270  void ApplyAccessiblityOptions(SvtAccessibilityOptions const & rAccessibilityOptions);
271 
272  // Inline method to request values of new members
273  // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
274  bool ResetFormDesignMode() const
275  {
276  return mbResetFormDesignMode;
277  }
278 
280  {
281  return mbFormDesignModeToReset;
282  }
283 
293  void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos );
294 
296  virtual ~SwPagePreview() override;
297 };
298 
299 
300 #endif
301 
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetNewCursorPos(const OUString &rStr)
Definition: pview.hxx:257
bool m_bNormalPrint
Definition: pview.hxx:186
bool ResetFormDesignMode() const
Definition: pview.hxx:274
void Init()
OUString const m_sPageStr
Definition: pview.hxx:173
virtual void MouseButtonDown(const MouseEvent &rMEvt)
VclPtr< SwPagePreviewWin > m_pViewWin
Definition: pview.hxx:165
OUString m_sSwViewData
Definition: pview.hxx:167
View of a document.
Definition: pview.hxx:161
const tools::Rectangle & GetPaintedPreviewDocRect() const
Definition: pview.hxx:139
Fraction maScale
Definition: pview.hxx:53
SwPagePreview & mrView
Definition: pview.hxx:54
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange)
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
#define SW_PAGEPREVIEW
Definition: shellid.hxx:39
bool mbCalcScaleForPreviewLayout
Definition: pview.hxx:55
virtual VclPtr< SfxTabPage > CreatePrintOptionsPage(TabPageParent pParent, const SfxItemSet &rOptions)
virtual bool HasPrintOptionsPage() const
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
ScrollFlags
virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL)
SfxPrinterChangeFlags
sal_uInt16 m_nNewPage
Definition: pview.hxx:171
sal_uInt16 mnSttPage
Definition: pview.hxx:49
sal_uInt8 GetCol() const
Definition: pview.hxx:86
Size maPxWinSize
Definition: pview.hxx:52
tools::Rectangle m_aVisArea
Definition: pview.hxx:175
OUString m_sNewCursorPosition
Definition: pview.hxx:169
void RepaintCoreRect(const SwRect &rRect)
Definition: pview.hxx:237
const OUString & GetPrevSwViewData() const
Definition: pview.hxx:256
#define SFX_DECL_VIEWFACTORY(Class)
void RepaintCoreRect(const SwRect &rRect)
Definition: pview.cxx:1714
sal_uInt16 SelectedPage() const
get selected page number of document preview
Definition: pview.cxx:538
page preview functionality in the writer
VclPtr< vcl::Window > m_pScrollFill
Definition: pview.hxx:183
VclPtr< SwScrollbar > m_pHScrollbar
Definition: pview.hxx:178
const OUString & GetNewCursorPos() const
Definition: pview.hxx:258
void SetSttPage(sal_uInt16 n)
Definition: pview.hxx:96
sal_uInt16 GetPageCount() const
Definition: pview.hxx:251
sal_uInt8 mnCol
Definition: pview.hxx:51
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize)
bool FormDesignModeToReset() const
Definition: pview.hxx:279
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
sal_uInt8 GetRow() const
Definition: pview.hxx:81
SwViewShell * mpViewShell
Definition: pview.hxx:48
SwPagePreviewLayout * mpPgPreviewLayout
Definition: pview.hxx:57
virtual void KeyInput(const KeyEvent &rKEvt)
virtual void Scroll(long nHorzScroll, long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
sal_uInt8 mnRow
Definition: pview.hxx:50
Size m_aDocSize
Definition: pview.hxx:174
unsigned char sal_uInt8
sal_uInt16 GetSelectedPage() const
Definition: pview.hxx:252
sal_uInt16 GetNewPage() const
Definition: pview.hxx:260
sal_uInt16 GetDefSttPage() const
Definition: pview.hxx:115
sal_uInt16 mnPageCount
Definition: pview.hxx:185
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
virtual SfxPrinter * GetPrinter(bool bCreate=false)
SvxZoomType
virtual void Command(const CommandEvent &rCEvt)
sal_uInt16 GetSttPage() const
Definition: pview.hxx:91
tools::Rectangle maPaintedPreviewDocRect
Definition: pview.hxx:56
SwViewShell * GetViewShell() const
Definition: pview.hxx:76
virtual void DataChanged(const DataChangedEvent &rDCEvt)
VclPtr< SwScrollbar > m_pVScrollbar
Definition: pview.hxx:179
#define SFX_DECL_INTERFACE(nId)