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 
34 class SwViewShell;
35 class SwRootFrame;
36 class SwPageFrame;
37 class Fraction;
38 struct PreviewPage;
39 
42 {
43 private:
44  friend class SwViewShell;
45 
47  static constexpr SwTwips gnXFree = 4 * 142;
48  static constexpr SwTwips gnYFree = 4 * 142;
49 
54 
67 
69  sal_uInt16 mnCols;
70  sal_uInt16 mnRows;
71  sal_uInt16 mnPages;
72  // #i18143# - the book preview is controlled by this flag
75 
84 
86  sal_uInt16 mnPaintStartCol;
87  sal_uInt16 mnPaintStartRow;
93  sal_uInt16 mnSelectedPageNum;
94 
95  std::vector<std::unique_ptr<PreviewPage>> maPreviewPages;
96 
99  mutable bool mbInPaint;
101 
103 
105  void Clear_();
106 
109 
111  void ClearPreviewPageData();
112 
114  void CalcPreviewLayoutSizes();
115 
121  void ApplyNewZoomAtViewShell( sal_uInt8 _aNewZoom );
122 
136 
148 
163  void CalcPreviewDataForPage( const SwPageFrame& _rPage,
164  const Point& _rPreviewOffset,
165  PreviewPage* _opPreviewPage );
166 
174  void CalcPreviewPages();
175 
185  const PreviewPage* GetPreviewPageByPageNum( const sal_uInt16 _nPageNum ) const;
186 
188  void PaintSelectMarkAtPage(vcl::RenderContext& rRenderContext, const PreviewPage* _aSelectedPreviewPage) const;
189 
190 public:
206  SwPagePreviewLayout( SwViewShell& _rParentViewShell,
207  const SwRootFrame& _rLayoutRootFrame );
208 
211  {
213  }
214 
233  void Init( const sal_uInt16 _nCols,
234  const sal_uInt16 _nRows,
235  const Size& _rPxWinSize
236  );
237 
239  void ReInit();
240 
278  bool Prepare( const sal_uInt16 _nProposedStartPageNum,
279  const Point& rProposedStartPos,
280  const Size& _rPxWinSize,
281  sal_uInt16& _onStartPageNum,
282  tools::Rectangle& _orDocPreviewPaintRect,
283  const bool _bStartWithPageAtFirstCol = true
284  );
285 
287  sal_uInt16 SelectedPage()
288  {
289  return mnSelectedPageNum;
290  }
291 
293  void SetSelectedPage( sal_uInt16 _nSelectedPageNum )
294  {
295  mnSelectedPageNum = _nSelectedPageNum;
296  }
297 
305  bool Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rOutRect) const;
306 
312  void Repaint(const tools::Rectangle& rInvalidCoreRect) const;
313 
322  void MarkNewSelectedPage( const sal_uInt16 _nSelectedPage );
323 
333  Point GetPreviewStartPosForNewScale( const Fraction& _aNewScale,
334  const Fraction& _aOldScale,
335  const Size& _aNewWinSize ) const;
336 
346  bool IsPageVisible( const sal_uInt16 _nPageNum ) const;
347 
367  void CalcStartValuesForSelectedPageMove( const sal_Int16 _nHoriMove,
368  const sal_Int16 _nVertMove,
369  sal_uInt16& _orNewSelectedPage,
370  sal_uInt16& _orNewStartPage,
371  Point& _orNewStartPos ) const;
372 
395  bool IsPreviewPosInDocPreviewPage( const Point& rPreviewPos,
396  Point& _orDocPos,
397  bool& _obPosInEmptyPage,
398  sal_uInt16& _onPageNum ) const;
399 
401  {
403  }
404 
406  {
408  }
409 
410  bool PreviewLayoutValid() const
411  {
412  return mbLayoutInfoValid && mbLayoutSizesValid && mbPaintInfoValid;
413  }
414 
424  SwTwips GetWinPagesScrollAmount( const sal_Int16 _nWinPagesToScroll ) const;
425 
434  sal_uInt16 GetRowOfPage( sal_uInt16 _nPageNum ) const;
435 
444  sal_uInt16 GetColOfPage( sal_uInt16 _nPageNum ) const;
445 
446  Size GetPreviewDocSize() const;
447 
456  Size GetPreviewPageSizeByPageNum( sal_uInt16 _nPageNum ) const;
457 
467  sal_uInt16 GetVirtPageNumByPageNum( sal_uInt16 _nPageNum ) const;
468 
470  bool SetBookPreviewMode( const bool _bEnableBookPreview,
471  sal_uInt16& _onStartPageNum,
472  tools::Rectangle& _orDocPreviewPaintRect );
473 
475  sal_uInt16 ConvertRelativeToAbsolutePageNum( sal_uInt16 _nRelPageNum ) const;
476 
478  sal_uInt16 ConvertAbsoluteToRelativePageNum( sal_uInt16 _nAbsPageNum ) const;
479 
481  {
482  return mrParentViewShell;
483  }
484 };
485 
486 #endif // INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX
487 
488 /* 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