LibreOffice Module sw (master)  1
pagepreviewlayout.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 
20 #ifndef INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX
21 #define INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX
22 
23 // template class <std::vector>
24 #include <vector>
25 // datatypes sal_xyz
26 #include <sal/types.h>
27 // classes <Point>, <Size> and <Rectangle>
28 #include <tools/gen.hxx>
29 // RenderContext type
30 #include <vcl/outdev.hxx>
31 // datatype <SwTwips>
32 #include "swtypes.hxx"
33 #include <prevwpage.hxx>
34 
35 class SwViewShell;
36 class SwRootFrame;
37 class SwPageFrame;
38 class Fraction;
39 struct PreviewPage;
40 
43 {
44 private:
45  friend class SwViewShell;
46 
48  static constexpr SwTwips gnXFree = 4 * 142;
49  static constexpr SwTwips gnYFree = 4 * 142;
50 
55 
68 
70  sal_uInt16 mnCols;
71  sal_uInt16 mnRows;
72  sal_uInt16 mnPages;
73  // #i18143# - the book preview is controlled by this flag
76 
85 
87  sal_uInt16 mnPaintStartCol;
88  sal_uInt16 mnPaintStartRow;
94  sal_uInt16 mnSelectedPageNum;
95 
96  std::vector<std::unique_ptr<PreviewPage>> maPreviewPages;
97 
100  mutable bool mbInPaint;
102 
104 
106  void Clear_();
107 
110 
112  void ClearPreviewPageData();
113 
115  void CalcPreviewLayoutSizes();
116 
122  void ApplyNewZoomAtViewShell( sal_uInt8 _aNewZoom );
123 
137 
149 
164  void CalcPreviewDataForPage( const SwPageFrame& _rPage,
165  const Point& _rPreviewOffset,
166  PreviewPage* _opPreviewPage );
167 
175  void CalcPreviewPages();
176 
186  const PreviewPage* GetPreviewPageByPageNum( const sal_uInt16 _nPageNum ) const;
187 
189  void PaintSelectMarkAtPage(vcl::RenderContext& rRenderContext, const PreviewPage* _aSelectedPreviewPage) const;
190 
191 public:
207  SwPagePreviewLayout( SwViewShell& _rParentViewShell,
208  const SwRootFrame& _rLayoutRootFrame );
209 
212  {
214  }
215 
234  void Init( const sal_uInt16 _nCols,
235  const sal_uInt16 _nRows,
236  const Size& _rPxWinSize
237  );
238 
240  void ReInit();
241 
279  bool Prepare( const sal_uInt16 _nProposedStartPageNum,
280  const Point& rProposedStartPos,
281  const Size& _rPxWinSize,
282  sal_uInt16& _onStartPageNum,
283  tools::Rectangle& _orDocPreviewPaintRect,
284  const bool _bStartWithPageAtFirstCol = true
285  );
286 
288  sal_uInt16 SelectedPage()
289  {
290  return mnSelectedPageNum;
291  }
292 
294  void SetSelectedPage( sal_uInt16 _nSelectedPageNum )
295  {
296  mnSelectedPageNum = _nSelectedPageNum;
297  }
298 
306  bool Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rOutRect) const;
307 
313  void Repaint(const tools::Rectangle& rInvalidCoreRect) const;
314 
323  void MarkNewSelectedPage( const sal_uInt16 _nSelectedPage );
324 
334  Point GetPreviewStartPosForNewScale( const Fraction& _aNewScale,
335  const Fraction& _aOldScale,
336  const Size& _aNewWinSize ) const;
337 
347  bool IsPageVisible( const sal_uInt16 _nPageNum ) const;
348 
368  void CalcStartValuesForSelectedPageMove( const sal_Int16 _nHoriMove,
369  const sal_Int16 _nVertMove,
370  sal_uInt16& _orNewSelectedPage,
371  sal_uInt16& _orNewStartPage,
372  Point& _orNewStartPos ) const;
373 
396  bool IsPreviewPosInDocPreviewPage( const Point& rPreviewPos,
397  Point& _orDocPos,
398  bool& _obPosInEmptyPage,
399  sal_uInt16& _onPageNum ) const;
400 
402  {
404  }
405 
407  {
409  }
410 
411  bool PreviewLayoutValid() const
412  {
413  return mbLayoutInfoValid && mbLayoutSizesValid && mbPaintInfoValid;
414  }
415 
425  SwTwips GetWinPagesScrollAmount( const sal_Int16 _nWinPagesToScroll ) const;
426 
435  sal_uInt16 GetRowOfPage( sal_uInt16 _nPageNum ) const;
436 
445  sal_uInt16 GetColOfPage( sal_uInt16 _nPageNum ) const;
446 
447  Size GetPreviewDocSize() const;
448 
457  Size GetPreviewPageSizeByPageNum( sal_uInt16 _nPageNum ) const;
458 
468  sal_uInt16 GetVirtPageNumByPageNum( sal_uInt16 _nPageNum ) const;
469 
471  bool SetBookPreviewMode( const bool _bEnableBookPreview,
472  sal_uInt16& _onStartPageNum,
473  tools::Rectangle& _orDocPreviewPaintRect );
474 
476  sal_uInt16 ConvertRelativeToAbsolutePageNum( sal_uInt16 _nRelPageNum ) const;
477 
479  sal_uInt16 ConvertAbsoluteToRelativePageNum( sal_uInt16 _nAbsPageNum ) const;
480 
482  {
483  return mrParentViewShell;
484  }
485 };
486 
487 #endif // INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX
488 
489 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
data structure for a preview page in the current preview layout
Definition: prevwpage.hxx:30
bool SetBookPreviewMode(const bool _bEnableBookPreview, sal_uInt16 &_onStartPageNum, tools::Rectangle &_orDocPreviewPaintRect)
enable/disable book preview
void CalcAdditionalPaintOffset()
calculate additional paint offset
const SwRootFrame & mrLayoutRootFrame
top layout frame of the layout for accessing the pages
bool mbLayoutSizesValid
boolean indicating, if the calculated print preview layout sizes ( windows size in twips...
void MarkNewSelectedPage(const sal_uInt16 _nSelectedPage)
paint to mark new selected page
tools::Rectangle maPaintedPreviewDocRect
Point GetPreviewStartPosForNewScale(const Fraction &_aNewScale, const Fraction &_aOldScale, const Size &_aNewWinSize) const
calculate start position for new scale
sal_uInt16 GetVirtPageNumByPageNum(sal_uInt16 _nPageNum) const
get virtual page number by its physical page number
void CalcPreviewDataForPage(const SwPageFrame &_rPage, const Point &_rPreviewOffset, PreviewPage *_opPreviewPage)
determines preview data for a given page and a given preview offset
bool mbLayoutInfoValid
boolean indicating, if the layout information (number of columns and rows) are valid.
bool Prepare(const sal_uInt16 _nProposedStartPageNum, const Point &rProposedStartPos, const Size &_rPxWinSize, sal_uInt16 &_onStartPageNum, tools::Rectangle &_orDocPreviewPaintRect, const bool _bStartWithPageAtFirstCol=true)
prepare paint of page preview
bool IsPreviewPosInDocPreviewPage(const Point &rPreviewPos, Point &_orDocPos, bool &_obPosInEmptyPage, sal_uInt16 &_onPageNum) const
checks, if given position is inside a shown document page
const PreviewPage * GetPreviewPageByPageNum(const sal_uInt16 _nPageNum) const
get preview page by physical page number
long SwTwips
Definition: swtypes.hxx:49
sal_uInt16 ConvertRelativeToAbsolutePageNum(sal_uInt16 _nRelPageNum) const
Convert relative to absolute page numbers (see PrintEmptyPages)
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
bool IsPageVisible(const sal_uInt16 _nPageNum) const
determines, if page with given page number is visible in preview
void ReInit()
method to adjust page preview layout to document changes
bool PreviewLayoutValid() const
bool mbInPaint
#i22014# - internal booleans to indicate, that a new print preview layout has been created during a p...
void SetSelectedPage(sal_uInt16 _nSelectedPageNum)
set selected page number
Size GetPreviewPageSizeByPageNum(sal_uInt16 _nPageNum) const
get size of a preview page by its physical page number
sal_uInt16 GetColOfPage(sal_uInt16 _nPageNum) const
determine column the page with the given number is in
bool mbPaintInfoValid
boolean indicating, if the paint information ( physical number of start page, start column and row...
bool DoesPreviewLayoutRowsFitIntoWindow() const
bool Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rOutRect) const
paint prepared preview
void CalcStartValuesForSelectedPageMove(const sal_Int16 _nHoriMove, const sal_Int16 _nVertMove, sal_uInt16 &_orNewSelectedPage, sal_uInt16 &_orNewStartPage, Point &_orNewStartPos) const
calculate data to bring new selected page into view.
page preview functionality in the writer
void ApplyNewZoomAtViewShell(sal_uInt8 _aNewZoom)
apply new zoom at given view shell
void Repaint(const tools::Rectangle &rInvalidCoreRect) const
repaint pages on page preview
void CalcPreviewLayoutSizes()
calculate page preview layout sizes
Size GetPreviewDocSize() const
std::vector< std::unique_ptr< PreviewPage > > maPreviewPages
sal_uInt16 mnPaintPhyStartPageNum
sal_uInt16 SelectedPage()
get selected page number
static constexpr SwTwips gnXFree
number of horizontal and vertical twips for spacing between the pages.
void ClearPreviewLayoutSizes()
helper method to clear preview page layout sizes
A page of the document layout.
Definition: pagefrm.hxx:40
SwViewShell & GetParentViewShell()
~SwPagePreviewLayout()
destructor of
void PaintSelectMarkAtPage(vcl::RenderContext &rRenderContext, const PreviewPage *_aSelectedPreviewPage) const
paint selection mark at page
void ClearPreviewPageData()
helper method to clear data in preview page vectors
unsigned char sal_uInt8
static constexpr SwTwips gnYFree
void CalcPreviewPages()
calculate preview pages
sal_uInt16 GetRowOfPage(sal_uInt16 _nPageNum) const
determine row the page with the given number is in
SwTwips GetWinPagesScrollAmount(const sal_Int16 _nWinPagesToScroll) const
determine preview window page scroll amount
SwViewShell & mrParentViewShell
view shell the print preview is generated for.
void CalcDocPreviewPaintRect()
calculate painted preview document rectangle
void Clear_()
clear internal data about current page preview
void Init(const sal_uInt16 _nCols, const sal_uInt16 _nRows, const Size &_rPxWinSize)
init page preview layout
bool DoesPreviewLayoutColsFitIntoWindow() const
SwPagePreviewLayout(SwViewShell &_rParentViewShell, const SwRootFrame &_rLayoutRootFrame)
constructor of
sal_uInt16 ConvertAbsoluteToRelativePageNum(sal_uInt16 _nAbsPageNum) const
Convert absolute to relative page numbers (see PrintEmptyPages)
tools::Rectangle maPreviewDocRect