1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_PVIEW_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_PVIEW_HXX
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>
30 #include <shellid.hxx>
40 class DataChangedEvent
;
42 class SvtAccessibilityOptions
;
43 class SwPagePreviewLayout
;
45 /// Provides the VCL widget that is used for the main area of the File -> Print Preview window.
46 class SAL_DLLPUBLIC_RTTI SwPagePreviewWin final
: public vcl::Window
48 SwViewShell
* mpViewShell
;
54 SwPagePreview
& mrView
;
55 bool mbCalcScaleForPreviewLayout
;
56 tools::Rectangle maPaintedPreviewDocRect
;
57 SwPagePreviewLayout
* mpPgPreviewLayout
;
59 void SetPagePreview( sal_Int16 nRow
, sal_Int16 nCol
);
64 SwPagePreviewWin( vcl::Window
* pParent
, SwPagePreview
& rView
);
65 virtual ~SwPagePreviewWin() override
;
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
;
74 void SetViewShell( SwViewShell
* pShell
);
76 SwViewShell
* GetViewShell() const
81 sal_Int16
GetRow() const
86 sal_Int16
GetCol() const
91 sal_uInt16
GetSttPage() const
96 void SetSttPage(sal_uInt16 n
)
101 /** get selected page number of document preview
103 @return selected page number
105 sal_uInt16
SelectedPage() const;
107 /** set selected page number in document preview
109 @param _nSelectedPageNum
110 input parameter - physical page number of page that will be the selected one.
112 void SetSelectedPage( sal_uInt16 _nSelectedPageNum
);
114 // If we only have one column we do not have a oth page
115 sal_uInt16
GetDefSttPage() const { return 1 == mnCol
? 1 : 0; }
117 void CalcWish( sal_Int16 nNewRow
, sal_Int16 nNewCol
);
119 void SetWinSize( const Size
& rNewSize
);
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
);
126 // Create the status bar's string
127 OUString
GetStatusStr( sal_uInt16 nPageCount
) const;
129 void RepaintCoreRect( const SwRect
& rRect
);
131 /** Method to adjust preview to a new zoom factor
132 paint of preview is prepared for a new zoom factor
133 Zoom type has also been considered.
134 Thus, add new parameter <_eZoomType>
136 void AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor
,
137 const SvxZoomType _eZoomType
);
139 const tools::Rectangle
& GetPaintedPreviewDocRect() const
141 return maPaintedPreviewDocRect
;
144 void Scroll(tools::Long nXMove
, tools::Long nYMove
, ScrollFlags nFlags
= ScrollFlags::NONE
) override
;
146 /** Method to enable/disable book preview
148 input parameter - boolean indicating, if book preview mode has to
149 switch on <true> or of <false>
151 @return boolean indicating, if book preview mode has changed.
153 bool SetBookPreviewMode( const bool _bBookPreview
);
155 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
161 class SW_DLLPUBLIC SwPagePreview final
: public SfxViewShell
163 // ViewWindow and handle to core
164 // current dispatcher shell
165 VclPtr
<SwPagePreviewWin
> m_pViewWin
;
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
169 OUString m_sNewCursorPosition
;
170 // to support keyboard the number of the page to go to can be set too
171 sal_uInt16 m_nNewPage
;
175 tools::Rectangle m_aVisArea
;
177 // MDI control elements
178 VclPtr
<SwScrollbar
> m_pHScrollbar
;
179 VclPtr
<SwScrollbar
> m_pVScrollbar
;
180 bool mbHScrollbarEnabled
: 1;
181 bool mbVScrollbarEnabled
: 1;
183 sal_uInt16 mnPageCount
;
186 // New members to reset design mode at draw view for form shell on switching
187 // back from writer page preview to normal view.
188 bool mbResetFormDesignMode
:1;
189 bool mbFormDesignModeToReset
:1;
191 SAL_DLLPRIVATE
void Init();
192 SAL_DLLPRIVATE Point
AlignToPixel(const Point
& rPt
) const;
194 SAL_DLLPRIVATE
void CreateScrollbar( bool bHori
);
195 DECL_DLLPRIVATE_LINK(HoriScrollHdl
, weld::Scrollbar
&, void);
196 DECL_DLLPRIVATE_LINK(VertScrollHdl
, weld::Scrollbar
&, void);
197 SAL_DLLPRIVATE
void ScrollHdl(weld::Scrollbar
&, bool bHorizontal
);
198 SAL_DLLPRIVATE
void EndScrollHdl(weld::Scrollbar
&, bool bHorizontal
);
199 SAL_DLLPRIVATE
bool ChgPage( int eMvMode
, bool bUpdateScrollbar
= true );
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 std::unique_ptr
<SfxTabPage
> CreatePrintOptionsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rOptions
) override
;
206 SAL_DLLPRIVATE
void CalcAndSetBorderPixel( SvBorder
&rToFill
);
208 /** Helper method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN
211 input parameter - boolean that indicates, if FN_PAGE_UP or FN_PAGE_DOWN
215 optional input parameter - pointer to the <SfxRequest> instance, if existing.
217 SAL_DLLPRIVATE
void ExecPgUpAndPgDown( const bool _bPgUp
,
220 virtual void InnerResizePixel( const Point
&rOfs
, const Size
&rSize
, bool inplaceEditModeChange
) override
;
221 virtual void OuterResizePixel( const Point
&rOfs
, const Size
&rSize
) override
;
223 void Activate(bool bMDI
) override
;
225 void SetZoom(SvxZoomType eSet
, sal_uInt16 nFactor
);
228 SFX_DECL_VIEWFACTORY(SwPagePreview
);
229 SFX_DECL_INTERFACE(SW_PAGEPREVIEW
)
232 /// SfxInterface initializer.
233 static void InitInterface_Impl();
236 SwViewShell
* GetViewShell() const
237 { return m_pViewWin
->GetViewShell(); }
238 void RepaintCoreRect( const SwRect
& rRect
)
239 { m_pViewWin
->RepaintCoreRect( rRect
); }
241 void DocSzChgd(const Size
& rNewSize
);
243 void SetVisArea( const tools::Rectangle
& );
245 void ScrollViewSzChg();
246 void ScrollDocSzChg();
247 void ShowHScrollbar(bool bShow
);
248 void ShowVScrollbar(bool bShow
);
249 void EnableHScrollbar(bool bEnable
);
250 void EnableVScrollbar(bool bEnable
);
252 sal_uInt16
GetPageCount() const { return mnPageCount
; }
253 sal_uInt16
GetSelectedPage() const {return m_pViewWin
->SelectedPage();}
255 bool HandleWheelCommands( const CommandEvent
& );
257 const OUString
& GetPrevSwViewData() const { return m_sSwViewData
; }
258 void SetNewCursorPos( const OUString
& rStr
) { m_sNewCursorPosition
= rStr
; }
259 const OUString
& GetNewCursorPos() const { return m_sNewCursorPosition
; }
261 sal_uInt16
GetNewPage() const {return m_nNewPage
;}
264 void Execute(SfxRequest
&);
265 void GetState(SfxItemSet
&);
266 static void StateUndo(SfxItemSet
&);
268 SwDocShell
* GetDocShell();
270 // apply Accessibility options
271 void ApplyAccessibilityOptions();
273 // Inline method to request values of new members
274 // <mbResetFormDesignMode> and <mbFormDesignModeToReset>
275 bool ResetFormDesignMode() const
277 return mbResetFormDesignMode
;
280 bool FormDesignModeToReset() const
282 return mbFormDesignModeToReset
;
285 /** Adjust position of vertical scrollbar
287 Currently used, if the complete preview layout rows fit into to the given
288 window, if a new page is selected and this page is visible.
291 input parameter - new position, which will be assigned to the vertical
294 void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos
);
296 SwPagePreview(SfxViewFrame
& rFrame
, SfxViewShell
*);
297 virtual ~SwPagePreview() override
;
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */