LibreOffice Module sw (master)  1
itrform2.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_CORE_TEXT_ITRFORM2_HXX
20 #define INCLUDED_SW_SOURCE_CORE_TEXT_ITRFORM2_HXX
21 #include "itrpaint.hxx"
22 
23 class SwFlyCntPortion;
24 class SwDropPortion;
25 class SwFormatDrop;
26 class SwTextAttr;
27 class SwNumberPortion;
28 class SwErgoSumPortion;
29 class SwExpandPortion;
30 class SwMultiPortion;
31 class SwFootnotePortion;
32 
34 {
36  SwMultiPortion* m_pMulti; // during formatting a multi-portion
37  sal_uInt8 m_nContentEndHyph; // Counts consecutive hyphens at the line end
38  sal_uInt8 m_nContentMidHyph; // Counts consecutive hyphens before flies
39  TextFrameIndex m_nLeftScanIdx; // for increasing performance during
40  TextFrameIndex m_nRightScanIdx; // scanning for portion ends
41  bool m_bOnceMore : 1; // Another round?
42  bool m_bFlyInContentBase : 1; // Base reference that sets a character-bound frame
43  bool m_bTruncLines : 1; // Flag for extending the repaint rect, if needed
44  bool m_bUnclipped : 1; // Flag whether repaint is larger than the fixed line height
45  std::unique_ptr<sw::MergedAttrIterByEnd> m_pByEndIter; // HACK for TryNewNoLengthPortion
46  SwLinePortion* m_pFirstOfBorderMerge; // The first text portion of a joined border (during portion building)
47 
51  SwTabPortion *NewTabPortion( SwTextFormatInfo &rInf, bool bAuto ) const;
57  const SwTextAttr *pHt ) const;
59 
64  SwTextAttr *pHt ) const;
68 
69  // The center piece of formatting
70  void BuildPortions( SwTextFormatInfo &rInf );
71 
72  bool BuildMultiPortion( SwTextFormatInfo &rInf, SwMultiPortion& rMulti );
73 
83  void CalcFlyWidth( SwTextFormatInfo &rInf );
84 
85  // Is overloaded by SwTextFormatter because of UpdatePos
86  void CalcAdjustLine( SwLineLayout *pCurr );
87 
88  // considers line spacing attributes
89  void CalcRealHeight( bool bNewLine = false );
90 
91  // Transfers the data to rInf
92  void FeedInf( SwTextFormatInfo &rInf ) const;
93 
94  // Treats underflow situations
96 
97  // Calculates the ascent and the height from the fontmetric
98  void CalcAscent( SwTextFormatInfo &rInf, SwLinePortion *pPor );
99 
100  // determines, if an optimized repaint rectangle is allowed
101  bool AllowRepaintOpt() const;
102 
103  // Is called by FormatLine
104  void FormatReset( SwTextFormatInfo &rInf );
105 
113  void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx,
114  bool bAlways = false ) const;
115 
120  void AlignFlyInCntBase( long nBaseLine ) const;
121 
129  bool ChkFlyUnderflow( SwTextFormatInfo &rInf ) const;
130 
131  // Insert portion
132  void InsertPortion( SwTextFormatInfo &rInf, SwLinePortion *pPor );
133 
134  // Guess height for the DropPortion
135  void GuessDropHeight( const sal_uInt16 nLines );
136 
137 public:
138  // Calculate the height for the DropPortion
139  void CalcDropHeight( const sal_uInt16 nLines );
140 
141  // Calculates the paragraphs bottom, takes anchored objects within it into
142  // account which have a wrap setting of "wrap at 1st paragraph"
143  SwTwips CalcBottomLine() const;
144 
145  // Takes character-bound objects into account when calculating the
146  // repaint rect in lines with fixed line height
147  void CalcUnclipped( SwTwips& rTop, SwTwips& rBottom );
148 
149  // Amongst others for DropCaps
150  bool CalcOnceMore();
151 
152  void CtorInitTextFormatter( SwTextFrame *pFrame, SwTextFormatInfo *pInf );
153  SwTextFormatter(SwTextFrame *pTextFrame, SwTextFormatInfo *pTextFormatInf)
154  : SwTextPainter(pTextFrame->GetTextNodeFirst())
155  , m_bUnclipped(false)
156  {
157  CtorInitTextFormatter( pTextFrame, pTextFormatInf );
158  }
159  virtual ~SwTextFormatter() override;
160 
162 
163  void RecalcRealHeight();
164 
165  // We format a line for interactive hyphenation
166  bool Hyphenate(SwInterHyphInfoTextFrame & rInf);
167 
168  // A special method for QuoVadis texts:
169  // nErgo is the page number of the ErgoSum Footnote
170  // At 0 it's still unclear
172 
173  // The emergency break: Cancel formatting, discard line
174  bool IsStop() const { return GetInfo().IsStop(); }
175 
176  // The counterpart: Continue formatting at all costs
177  bool IsNewLine() const { return GetInfo().IsNewLine(); }
178 
179  // FormatQuick(); Refresh formatting information
180  bool IsQuick() const { return GetInfo().IsQuick(); }
181 
182  // Create a SwLineLayout if needed, which avoids Footnote/Fly to oscillate
183  void MakeDummyLine();
184 
185  // SwTextIter functionality
186  void Insert( SwLineLayout *pLine );
187 
188  // The remaining height to the page border
189  sal_uInt16 GetFrameRstHeight() const;
190 
191  // How wide would you be without any bounds (Flys etc.)?
193 
195 
196  const SwFormatDrop *GetDropFormat() const { return m_pDropFormat; }
197  void ClearDropFormat() { m_pDropFormat = nullptr; }
198 
199  SwMultiPortion *GetMulti() const { return m_pMulti; }
200 
201  bool IsOnceMore() const { return m_bOnceMore; }
202  void SetOnceMore( bool bNew ) { m_bOnceMore = bNew; }
203 
204  bool HasTruncLines() const { return m_bTruncLines; }
205  void SetTruncLines( bool bNew ) { m_bTruncLines = bNew; }
206 
207  bool IsUnclipped() const { return m_bUnclipped; }
208  void SetUnclipped( bool bNew ) { m_bUnclipped = bNew; }
209 
210  bool IsFlyInCntBase() const { return m_bFlyInContentBase; }
211  void SetFlyInCntBase( bool bNew = true ) { m_bFlyInContentBase = bNew; }
212 
214  { return static_cast<SwTextFormatInfo&>(SwTextIter::GetInfo()); }
215  const SwTextFormatInfo &GetInfo() const
216  { return static_cast<const SwTextFormatInfo&>(SwTextIter::GetInfo()); }
217 
218  void InitCntHyph() { CntHyphens( m_nContentEndHyph, m_nContentMidHyph ); }
219  const sal_uInt8 &CntEndHyph() const { return m_nContentEndHyph; }
220  const sal_uInt8 &CntMidHyph() const { return m_nContentMidHyph; }
223 
229  static void MergeCharacterBorder( SwDropPortion const & rPortion );
230 
240  void MergeCharacterBorder( SwLinePortion& rPortion, SwLinePortion const *pPrev, SwTextFormatInfo& rInf );
241 };
242 
243 #endif
244 
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
TextFrameIndex FormatQuoVadis(TextFrameIndex nStart)
Definition: txtftn.cxx:1022
const SwFormatDrop * m_pDropFormat
Definition: itrform2.hxx:35
void FormatReset(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1863
bool IsQuick() const
Definition: inftxt.hxx:592
SwFlyCntPortion * NewFlyCntPortion(SwTextFormatInfo &rInf, SwTextAttr *pHt) const
Sets a new portion for an object anchored as character.
Definition: itrform2.cxx:2476
SwExpandPortion * NewFieldPortion(SwTextFormatInfo &rInf, const SwTextAttr *pHt) const
Definition: txtfld.cxx:78
void MakeDummyLine()
This function creates a Line that reaches to the other Page Margin.
Definition: txtftn.cxx:1226
SwTextFormatter(SwTextFrame *pTextFrame, SwTextFormatInfo *pTextFormatInf)
Definition: itrform2.hxx:153
const SwFormatDrop * GetDropFormat() const
Definition: itrform2.hxx:196
void InsertPortion(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:300
bool IsNewLine() const
Definition: itrform2.hxx:177
void GuessDropHeight(const sal_uInt16 nLines)
We assume that the font height doesn't change and that at first there are at least as many lines...
Definition: txtdrop.cxx:545
static void MergeCharacterBorder(SwDropPortion const &rPortion)
Merge border of the drop portion with modifying the font of the portions' part.
Definition: itrform2.cxx:2572
bool IsStop() const
Definition: itrform2.hxx:174
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
Definition: txthyph.cxx:128
SwTabPortion * NewTabPortion(SwTextFormatInfo &rInf, bool bAuto) const
Definition: txttab.cxx:65
long SwTwips
Definition: swtypes.hxx:49
void SetFlyInCntBase(bool bNew=true)
Definition: itrform2.hxx:211
sal_uInt8 & CntEndHyph()
Definition: itrform2.hxx:221
void InitCntHyph()
Definition: itrform2.hxx:218
SwTextFormatInfo & GetInfo()
Definition: itrform2.hxx:213
void CalcUnclipped(SwTwips &rTop, SwTwips &rBottom)
Definition: itrform2.cxx:1979
SwExpandPortion * TryNewNoLengthPortion(SwTextFormatInfo const &rInfo)
Try to create a new portion with zero length, for an end of a hint (where there is no CH_TXTATR)...
Definition: txtfld.cxx:322
bool BuildMultiPortion(SwTextFormatInfo &rInf, SwMultiPortion &rMulti)
Definition: pormulti.cxx:1882
virtual ~SwTextFormatter() override
Definition: itrform2.cxx:112
sal_uInt8 & CntMidHyph()
Definition: itrform2.hxx:222
bool IsNewLine() const
Definition: inftxt.hxx:583
void CalcRealHeight(bool bNewLine=false)
Definition: itrform2.cxx:1686
bool AllowRepaintOpt() const
Definition: itrform2.cxx:1927
sal_uInt8 m_nContentEndHyph
Definition: itrform2.hxx:37
void CalcFlyWidth(SwTextFormatInfo &rInf)
Calculation of the emulated right side.
Definition: itrform2.cxx:2248
This portion represents an as-character anchored fly (shape, frame, etc.)
Definition: porfly.hxx:44
void SetTruncLines(bool bNew)
Definition: itrform2.hxx:205
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
const SwTextFormatInfo & GetInfo() const
Definition: itrform2.hxx:215
void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx, bool bAlways=false) const
The position of the portions changes with the adjustment.
Definition: itrform2.cxx:1991
bool m_bFlyInContentBase
Definition: itrform2.hxx:42
TextFrameIndex m_nRightScanIdx
Definition: itrform2.hxx:40
SwTwips CalcFitToContent_()
Definition: itrform2.cxx:1916
SwFootnotePortion * NewFootnotePortion(SwTextFormatInfo &rInf, SwTextAttr *pHt)
The portion for the Footnote Reference in the Text.
Definition: txtftn.cxx:774
bool m_bTruncLines
Definition: itrform2.hxx:43
SwLinePortion * NewPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1175
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:78
SwMultiPortion * m_pMulti
Definition: itrform2.hxx:36
void RecalcRealHeight()
Definition: itrform2.cxx:1678
SwNumberPortion * NewNumberPortion(SwTextFormatInfo &rInf) const
Definition: txtfld.cxx:541
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:87
SwLinePortion * NewExtraPortion(SwTextFormatInfo &rInf)
Definition: txtfld.cxx:361
std::unique_ptr< sw::MergedAttrIterByEnd > m_pByEndIter
Definition: itrform2.hxx:45
void BuildPortions(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:352
bool HasTruncLines() const
Definition: itrform2.hxx:204
bool IsQuick() const
Definition: itrform2.hxx:180
bool ChkFlyUnderflow(SwTextFormatInfo &rInf) const
This is called after the real height of the line has been calculated Therefore it is possible...
Definition: itrform2.cxx:2160
const sal_uInt8 & CntMidHyph() const
Definition: itrform2.hxx:220
bool IsUnclipped() const
Definition: itrform2.hxx:207
SwErgoSumPortion * NewErgoSumPortion(SwTextFormatInfo const &rInf) const
Definition: txtftn.cxx:994
bool IsStop() const
Definition: inftxt.hxx:579
void SetUnclipped(bool bNew)
Definition: itrform2.hxx:208
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:50
void ClearDropFormat()
Definition: itrform2.hxx:197
void CalcAscent(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:737
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1473
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:1891
SwTextPortion * WhichTextPor(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:859
SwMultiPortion * GetMulti() const
Definition: itrform2.hxx:199
Used in footnotes if they break across pages, follow starts with this portion.
Definition: porftn.hxx:89
void CalcAdjustLine(SwLineLayout *pCurr)
Definition: itrform2.cxx:722
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:483
unsigned char sal_uInt8
void SetOnceMore(bool bNew)
Definition: itrform2.hxx:202
const sal_uInt8 & CntEndHyph() const
Definition: itrform2.hxx:219
SwLinePortion * Underflow(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:152
sal_uInt8 m_nContentMidHyph
Definition: itrform2.hxx:38
SwNumberPortion * NewFootnoteNumPortion(SwTextFormatInfo const &rInf) const
The portion for the Footnote Numbering in the Footnote Area.
Definition: txtftn.cxx:913
a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index
Definition: txtfrm.hxx:53
SwTextPortion * NewTextPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:943
void CntHyphens(sal_uInt8 &nEndCnt, sal_uInt8 &nMidCnt) const
Definition: itrtxt.cxx:381
void FeedInf(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:1839
SwLinePortion * MakeRestPortion(const SwLineLayout *pLine, TextFrameIndex nPos)
Definition: pormulti.cxx:2352
SwTextInfo & GetInfo()
Definition: itrtxt.hxx:96
void Insert(SwLineLayout *pLine)
Definition: itrform2.cxx:123
bool IsFlyInCntBase() const
Definition: itrform2.hxx:210
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:50
SwLinePortion * m_pFirstOfBorderMerge
Definition: itrform2.hxx:46
bool IsOnceMore() const
Definition: itrform2.hxx:201
TextFrameIndex m_nLeftScanIdx
Definition: itrform2.hxx:39
void AlignFlyInCntBase(long nBaseLine) const
Set all anchored as character objects to the passed BaseLine (in Y direction).
Definition: itrform2.cxx:2113
sal_uInt16 GetFrameRstHeight() const
Definition: itrform2.cxx:135
SwLinePortion * WhichFirstPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1012
SwDropPortion * NewDropPortion(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:560
bool CalcOnceMore()
Definition: itrform2.cxx:1878