/src/libreoffice/sw/source/uibase/inc/pview.hxx
Line | Count | Source |
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 | | #pragma once |
20 | | |
21 | | #include <tools/link.hxx> |
22 | | #include <tools/fract.hxx> |
23 | | #include <vcl/window.hxx> |
24 | | #include <sfx2/viewfrm.hxx> |
25 | | #include <sfx2/viewfac.hxx> |
26 | | #include <sfx2/viewsh.hxx> |
27 | | #include <sfx2/zoomitem.hxx> |
28 | | #include <swdllapi.h> |
29 | | #include <shellid.hxx> |
30 | | |
31 | | class SwDocShell; |
32 | | class SwScrollbar; |
33 | | class SwViewShell; |
34 | | class SwPagePreview; |
35 | | class SwRect; |
36 | | class CommandEvent; |
37 | | class SwPagePreviewLayout; |
38 | | |
39 | | /// Provides the VCL widget that is used for the main area of the File -> Print Preview window. |
40 | | class SAL_DLLPUBLIC_RTTI SwPagePreviewWin final : public vcl::Window |
41 | | { |
42 | | SwViewShell* mpViewShell; |
43 | | sal_uInt16 mnSttPage; |
44 | | sal_Int16 mnRow; |
45 | | sal_Int16 mnCol; |
46 | | Size maPxWinSize; |
47 | | Fraction maScale; |
48 | | SwPagePreview& mrView; |
49 | | bool mbCalcScaleForPreviewLayout; |
50 | | tools::Rectangle maPaintedPreviewDocRect; |
51 | | SwPagePreviewLayout* mpPgPreviewLayout; |
52 | | |
53 | | void SetPagePreview( sal_Int16 nRow, sal_Int16 nCol ); |
54 | | |
55 | | using Window::Scroll; |
56 | | |
57 | | public: |
58 | | SwPagePreviewWin( vcl::Window* pParent, SwPagePreview& rView ); |
59 | | virtual ~SwPagePreviewWin() override; |
60 | | |
61 | | // calls SwViewShell::Paint |
62 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; |
63 | | virtual void KeyInput( const KeyEvent & ) override; |
64 | | virtual void Command( const CommandEvent& rCEvt ) override; |
65 | | virtual void MouseButtonDown(const MouseEvent& rMEvt) override; |
66 | | virtual void DataChanged( const DataChangedEvent& ) override; |
67 | | |
68 | | void SetViewShell( SwViewShell* pShell ); |
69 | | |
70 | | SwViewShell* GetViewShell() const |
71 | 0 | { |
72 | 0 | return mpViewShell; |
73 | 0 | } |
74 | | |
75 | | sal_Int16 GetRow() const |
76 | 0 | { |
77 | 0 | return mnRow; |
78 | 0 | } |
79 | | |
80 | | sal_Int16 GetCol() const |
81 | 0 | { |
82 | 0 | return mnCol; |
83 | 0 | } |
84 | | |
85 | | sal_uInt16 GetSttPage() const |
86 | 0 | { |
87 | 0 | return mnSttPage; |
88 | 0 | } |
89 | | |
90 | | void SetSttPage(sal_uInt16 n) |
91 | 0 | { |
92 | 0 | mnSttPage = n; |
93 | 0 | } |
94 | | |
95 | | /** get selected page number of document preview |
96 | | |
97 | | @return selected page number |
98 | | */ |
99 | | sal_uInt16 SelectedPage() const; |
100 | | |
101 | | /** set selected page number in document preview |
102 | | |
103 | | @param _nSelectedPageNum |
104 | | input parameter - physical page number of page that will be the selected one. |
105 | | */ |
106 | | void SetSelectedPage( sal_uInt16 _nSelectedPageNum ); |
107 | | |
108 | | // If we only have one column we do not have a oth page |
109 | 0 | sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; } |
110 | | |
111 | | void CalcWish( sal_Int16 nNewRow, sal_Int16 nNewCol ); |
112 | | |
113 | | void SetWinSize( const Size& rNewSize ); |
114 | | |
115 | | // Add <MV_SELPAGE>, <MV_SCROLL> |
116 | | enum MoveMode{ MV_CALC, MV_PAGE_UP, MV_PAGE_DOWN, MV_DOC_STT, MV_DOC_END, |
117 | | MV_SELPAGE, MV_SCROLL, MV_NEWWINSIZE, MV_SPECIFIC_PAGE }; |
118 | | bool MovePage( int eMoveMode ); |
119 | | |
120 | | // Create the status bar's string |
121 | | OUString GetStatusStr( sal_uInt16 nPageCount ) const; |
122 | | |
123 | | void RepaintCoreRect( const SwRect& rRect ); |
124 | | |
125 | | /** Method to adjust preview to a new zoom factor |
126 | | paint of preview is prepared for a new zoom factor |
127 | | Zoom type has also been considered. |
128 | | Thus, add new parameter <_eZoomType> |
129 | | */ |
130 | | void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor, |
131 | | const SvxZoomType _eZoomType ); |
132 | | |
133 | | const tools::Rectangle& GetPaintedPreviewDocRect() const |
134 | 0 | { |
135 | 0 | return maPaintedPreviewDocRect; |
136 | 0 | } |
137 | | |
138 | | void Scroll(tools::Long nXMove, tools::Long nYMove, ScrollFlags nFlags = ScrollFlags::NONE) override; |
139 | | |
140 | | /** Method to enable/disable book preview |
141 | | @param _bBookPreview |
142 | | input parameter - boolean indicating, if book preview mode has to |
143 | | switch on <true> or of <false> |
144 | | |
145 | | @return boolean indicating, if book preview mode has changed. |
146 | | */ |
147 | | bool SetBookPreviewMode( const bool _bBookPreview ); |
148 | | |
149 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
150 | | |
151 | | void ReInit(); |
152 | | }; |
153 | | |
154 | | /** |
155 | | * View of a document |
156 | | */ |
157 | | class SW_DLLPUBLIC SwPagePreview final : public SfxViewShell |
158 | | { |
159 | | // ViewWindow and handle to core |
160 | | // current dispatcher shell |
161 | | VclPtr<SwPagePreviewWin> m_pViewWin; |
162 | | //viewdata of the previous SwView and the new cursor position |
163 | | OUString m_sSwViewData; |
164 | | //and the new cursor position if the user double click in the PagePreview |
165 | | OUString m_sNewCursorPosition; |
166 | | // to support keyboard the number of the page to go to can be set too |
167 | | sal_uInt16 m_nNewPage; |
168 | | // visible range |
169 | | OUString m_sPageStr; |
170 | | Size m_aDocSize; |
171 | | tools::Rectangle m_aVisArea; |
172 | | |
173 | | // MDI control elements |
174 | | VclPtr<SwScrollbar> m_pHScrollbar; |
175 | | VclPtr<SwScrollbar> m_pVScrollbar; |
176 | | bool mbHScrollbarEnabled : 1; |
177 | | bool mbVScrollbarEnabled : 1; |
178 | | |
179 | | sal_uInt16 mnPageCount; |
180 | | bool m_bNormalPrint; |
181 | | |
182 | | // New members to reset design mode at draw view for form shell on switching |
183 | | // back from writer page preview to normal view. |
184 | | bool mbResetFormDesignMode:1; |
185 | | bool mbFormDesignModeToReset:1; |
186 | | |
187 | | SAL_DLLPRIVATE void Init(); |
188 | | SAL_DLLPRIVATE Point AlignToPixel(const Point& rPt) const; |
189 | | |
190 | | SAL_DLLPRIVATE void CreateScrollbar( bool bHori); |
191 | | DECL_DLLPRIVATE_LINK(HoriScrollHdl, weld::Scrollbar&, void); |
192 | | DECL_DLLPRIVATE_LINK(VertScrollHdl, weld::Scrollbar&, void); |
193 | | SAL_DLLPRIVATE void ScrollHdl(const weld::Scrollbar&, bool bHorizontal); |
194 | | SAL_DLLPRIVATE void EndScrollHdl(const weld::Scrollbar&, bool bHorizontal); |
195 | | SAL_DLLPRIVATE bool ChgPage( int eMvMode, bool bUpdateScrollbar = true ); |
196 | | |
197 | | SAL_DLLPRIVATE virtual SfxPrinter* GetPrinter( bool bCreate = false ) override; |
198 | | SAL_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ) override; |
199 | | SAL_DLLPRIVATE virtual bool HasPrintOptionsPage() const override; |
200 | | SAL_DLLPRIVATE virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions) override; |
201 | | |
202 | | SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill ); |
203 | | |
204 | | /** Helper method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN |
205 | | |
206 | | @param _bPgUp |
207 | | input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN |
208 | | has to be executed. |
209 | | |
210 | | @param _pReq |
211 | | optional input parameter - pointer to the <SfxRequest> instance, if existing. |
212 | | */ |
213 | | SAL_DLLPRIVATE void ExecPgUpAndPgDown( const bool _bPgUp, |
214 | | SfxRequest* _pReq ); |
215 | | |
216 | | virtual void InnerResizePixel( const Point &rOfs, const Size &rSize, bool inplaceEditModeChange ) override; |
217 | | virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ) override; |
218 | | |
219 | | void Activate(bool bMDI) override; |
220 | | |
221 | | void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor); |
222 | | |
223 | | public: |
224 | | SFX_DECL_VIEWFACTORY(SwPagePreview); |
225 | | SFX_DECL_INTERFACE(SW_PAGEPREVIEW) |
226 | | |
227 | | private: |
228 | | /// SfxInterface initializer. |
229 | | static void InitInterface_Impl(); |
230 | | |
231 | | public: |
232 | | SwViewShell* GetViewShell() const |
233 | 0 | { return m_pViewWin->GetViewShell(); } |
234 | | void RepaintCoreRect( const SwRect& rRect ) |
235 | 0 | { m_pViewWin->RepaintCoreRect( rRect ); } |
236 | | |
237 | | void DocSzChgd(const Size& rNewSize); |
238 | | |
239 | | void SetVisArea( const tools::Rectangle& ); |
240 | | |
241 | | void ScrollViewSzChg(); |
242 | | void ScrollDocSzChg(); |
243 | | void ShowHScrollbar(bool bShow); |
244 | | void ShowVScrollbar(bool bShow); |
245 | | void EnableHScrollbar(bool bEnable); |
246 | | void EnableVScrollbar(bool bEnable); |
247 | | |
248 | 0 | sal_uInt16 GetPageCount() const { return mnPageCount; } |
249 | 0 | sal_uInt16 GetSelectedPage() const {return m_pViewWin->SelectedPage();} |
250 | | |
251 | | bool HandleWheelCommands( const CommandEvent& ); |
252 | | |
253 | 0 | const OUString& GetPrevSwViewData() const { return m_sSwViewData; } |
254 | 0 | void SetNewCursorPos( const OUString& rStr ) { m_sNewCursorPosition = rStr; } |
255 | 0 | const OUString& GetNewCursorPos() const { return m_sNewCursorPosition; } |
256 | | |
257 | 0 | sal_uInt16 GetNewPage() const {return m_nNewPage;} |
258 | | |
259 | | // Handler |
260 | | void Execute(SfxRequest&); |
261 | | void GetState(SfxItemSet&); |
262 | | static void StateUndo(SfxItemSet&); |
263 | | |
264 | | SwDocShell* GetDocShell(); |
265 | | |
266 | | // Inline method to request values of new members |
267 | | // <mbResetFormDesignMode> and <mbFormDesignModeToReset> |
268 | | bool ResetFormDesignMode() const |
269 | 0 | { |
270 | 0 | return mbResetFormDesignMode; |
271 | 0 | } |
272 | | |
273 | | bool FormDesignModeToReset() const |
274 | 0 | { |
275 | 0 | return mbFormDesignModeToReset; |
276 | 0 | } |
277 | | |
278 | | /** Adjust position of vertical scrollbar |
279 | | |
280 | | Currently used, if the complete preview layout rows fit into to the given |
281 | | window, if a new page is selected and this page is visible. |
282 | | |
283 | | @param _nNewThumbPos |
284 | | input parameter - new position, which will be assigned to the vertical |
285 | | scrollbar. |
286 | | */ |
287 | | void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos ); |
288 | | |
289 | | void PrintSettingsChanged(); |
290 | | |
291 | | SwPagePreview(SfxViewFrame& rFrame, SfxViewShell*); |
292 | | virtual ~SwPagePreview() override; |
293 | | }; |
294 | | |
295 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |