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 SwInterHyphInfo;
25 class SwDropPortion;
26 class SwFormatDrop;
27 class SwTextAttr;
28 class SwNumberPortion;
29 class SwErgoSumPortion;
30 class SwExpandPortion;
31 class SwMultiPortion;
32 class SwFootnotePortion;
33 
34 namespace sw { class MergedAttrIterByEnd; }
35 
37 {
39  SwMultiPortion* pMulti; // during formatting a multi-portion
40  sal_uInt8 nCntEndHyph; // Counts consecutive hyphens at the line end
41  sal_uInt8 nCntMidHyph; // Counts consecutive hyphens before flies
42  TextFrameIndex nLeftScanIdx; // for increasing performance during
43  TextFrameIndex nRightScanIdx; // scanning for portion ends
44  bool bOnceMore : 1; // Another round?
45  bool bFlyInCntBase : 1; // Base reference that sets a character-bound frame
46  bool bTruncLines : 1; // Flag for extending the repaint rect, if needed
47  bool bUnclipped : 1; // Flag whether repaint is larger than the fixed line height
48  std::unique_ptr<sw::MergedAttrIterByEnd> m_pByEndIter; // HACK for TryNewNoLengthPortion
49  SwLinePortion* m_pFirstOfBorderMerge; // The first text portion of a joined border (during portion building)
50 
54  SwTabPortion *NewTabPortion( SwTextFormatInfo &rInf, bool bAuto ) const;
60  const SwTextAttr *pHt ) const;
62 
67  SwTextAttr *pHt ) const;
71 
72  // The center piece of formatting
73  void BuildPortions( SwTextFormatInfo &rInf );
74 
75  bool BuildMultiPortion( SwTextFormatInfo &rInf, SwMultiPortion& rMulti );
76 
86  void CalcFlyWidth( SwTextFormatInfo &rInf );
87 
88  // Is overloaded by SwTextFormatter because of UpdatePos
89  void CalcAdjustLine( SwLineLayout *pCurr );
90 
91  // considers line spacing attributes
92  void CalcRealHeight( bool bNewLine = false );
93 
94  // Transfers the data to rInf
95  void FeedInf( SwTextFormatInfo &rInf ) const;
96 
97  // Treats underflow situations
99 
100  // Calculates the ascent and the height from the fontmetric
101  void CalcAscent( SwTextFormatInfo &rInf, SwLinePortion *pPor );
102 
103  // determines, if a optimized repaint rectangle is allowed
104  bool AllowRepaintOpt() const;
105 
106  // Is called by FormatLine
107  void FormatReset( SwTextFormatInfo &rInf );
108 
116  void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx,
117  bool bAlways = false ) const;
118 
123  void AlignFlyInCntBase( long nBaseLine ) const;
124 
132  bool ChkFlyUnderflow( SwTextFormatInfo &rInf ) const;
133 
134  // Insert portion
135  void InsertPortion( SwTextFormatInfo &rInf, SwLinePortion *pPor ) const;
136 
137  // Guess height for the DropPortion
138  void GuessDropHeight( const sal_uInt16 nLines );
139 
140 public:
141  // Calculate the height for the DropPortion
142  void CalcDropHeight( const sal_uInt16 nLines );
143 
144  // Calculates the paragraphs bottom, takes anchored objects within it into
145  // account which have a wrap setting of "wrap at 1st paragraph"
146  SwTwips CalcBottomLine() const;
147 
148  // Takes character-bound objects into account when calculating the
149  // repaint rect in lines with fixed line height
150  void CalcUnclipped( SwTwips& rTop, SwTwips& rBottom );
151 
152  // Amongst others for DropCaps
153  bool CalcOnceMore();
154 
155  void CtorInitTextFormatter( SwTextFrame *pFrame, SwTextFormatInfo *pInf );
156  SwTextFormatter(SwTextFrame *pTextFrame, SwTextFormatInfo *pTextFormatInf)
157  : SwTextPainter(pTextFrame->GetTextNodeFirst())
158  , bUnclipped(false)
159  {
160  CtorInitTextFormatter( pTextFrame, pTextFormatInf );
161  }
162  virtual ~SwTextFormatter() override;
163 
165 
166  void RecalcRealHeight();
167 
168  // We format a line for interactive hyphenation
169  bool Hyphenate(SwInterHyphInfoTextFrame & rInf);
170 
171  // A special method for QuoVadis texts:
172  // nErgo is the page number of the ErgoSum Footnote
173  // At 0 it's still unclear
175 
176  // The emergency break: Cancel formatting, discard line
177  bool IsStop() const { return GetInfo().IsStop(); }
178 
179  // The counterpart: Continue formatting at all costs
180  bool IsNewLine() const { return GetInfo().IsNewLine(); }
181 
182  // FormatQuick(); Refresh formatting information
183  bool IsQuick() const { return GetInfo().IsQuick(); }
184 
185  // Create a SwLineLayout if needed, which avoids Footnote/Fly to oscillate
186  void MakeDummyLine();
187 
188  // SwTextIter functionality
189  void Insert( SwLineLayout *pLine );
190 
191  // The remaining height to the page border
192  sal_uInt16 GetFrameRstHeight() const;
193 
194  // How wide would you be without any bounds (Flys etc.)?
196 
198 
199  const SwFormatDrop *GetDropFormat() const { return pDropFormat; }
200  void ClearDropFormat() { pDropFormat = nullptr; }
201 
202  SwMultiPortion *GetMulti() const { return pMulti; }
203 
204  bool IsOnceMore() const { return bOnceMore; }
205  void SetOnceMore( bool bNew ) { bOnceMore = bNew; }
206 
207  bool HasTruncLines() const { return bTruncLines; }
208  void SetTruncLines( bool bNew ) { bTruncLines = bNew; }
209 
210  bool IsUnclipped() const { return bUnclipped; }
211  void SetUnclipped( bool bNew ) { bUnclipped = bNew; }
212 
213  bool IsFlyInCntBase() const { return bFlyInCntBase; }
214  void SetFlyInCntBase( bool bNew = true ) { bFlyInCntBase = bNew; }
215 
217  { return static_cast<SwTextFormatInfo&>(SwTextIter::GetInfo()); }
218  const SwTextFormatInfo &GetInfo() const
219  { return static_cast<const SwTextFormatInfo&>(SwTextIter::GetInfo()); }
220 
221  void InitCntHyph() { CntHyphens( nCntEndHyph, nCntMidHyph ); }
222  const sal_uInt8 &CntEndHyph() const { return nCntEndHyph; }
223  const sal_uInt8 &CntMidHyph() const { return nCntMidHyph; }
226 
232  static void MergeCharacterBorder( SwDropPortion const & rPortion );
233 
243  void MergeCharacterBorder( SwLinePortion& rPortion, SwLinePortion const *pPrev, SwTextFormatInfo& rInf );
244 };
245 
246 #endif
247 
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
bool bFlyInCntBase
Definition: itrform2.hxx:45
TextFrameIndex FormatQuoVadis(TextFrameIndex nStart)
Definition: txtftn.cxx:993
TextFrameIndex nRightScanIdx
Definition: itrform2.hxx:43
void FormatReset(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1860
bool IsQuick() const
Definition: inftxt.hxx:599
SwFlyCntPortion * NewFlyCntPortion(SwTextFormatInfo &rInf, SwTextAttr *pHt) const
Sets a new portion for an object anchored as character.
Definition: itrform2.cxx:2464
SwExpandPortion * NewFieldPortion(SwTextFormatInfo &rInf, const SwTextAttr *pHt) const
Definition: txtfld.cxx:71
void MakeDummyLine()
This function creates a Line that reaches to the other Page Margin.
Definition: txtftn.cxx:1197
SwTextFormatter(SwTextFrame *pTextFrame, SwTextFormatInfo *pTextFormatInf)
Definition: itrform2.hxx:156
const SwFormatDrop * GetDropFormat() const
Definition: itrform2.hxx:199
bool IsNewLine() const
Definition: itrform2.hxx:180
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:2560
bool IsStop() const
Definition: itrform2.hxx:177
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
Definition: txthyph.cxx:127
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:214
Dialog to specify the properties of drop-down form field.
Definition: accframe.hxx:34
sal_uInt8 & CntEndHyph()
Definition: itrform2.hxx:224
void InitCntHyph()
Definition: itrform2.hxx:221
SwTextFormatInfo & GetInfo()
Definition: itrform2.hxx:216
void CalcUnclipped(SwTwips &rTop, SwTwips &rBottom)
Definition: itrform2.cxx:1975
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:315
bool BuildMultiPortion(SwTextFormatInfo &rInf, SwMultiPortion &rMulti)
Definition: pormulti.cxx:1882
virtual ~SwTextFormatter() override
Definition: itrform2.cxx:111
sal_uInt8 & CntMidHyph()
Definition: itrform2.hxx:225
bool IsNewLine() const
Definition: inftxt.hxx:590
void CalcRealHeight(bool bNewLine=false)
Definition: itrform2.cxx:1683
bool AllowRepaintOpt() const
Definition: itrform2.cxx:1923
void CalcFlyWidth(SwTextFormatInfo &rInf)
Calculation of the emulated right side.
Definition: itrform2.cxx:2244
This portion represents an as-character anchored fly (shape, frame, etc.)
Definition: porfly.hxx:45
void SetTruncLines(bool bNew)
Definition: itrform2.hxx:208
TextFrameIndex nLeftScanIdx
Definition: itrform2.hxx:42
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
const SwTextFormatInfo & GetInfo() const
Definition: itrform2.hxx:218
void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx, bool bAlways=false) const
The position of the portions changes with the adjustment.
Definition: itrform2.cxx:1987
SwTwips CalcFitToContent_()
Definition: itrform2.cxx:1912
SwFootnotePortion * NewFootnotePortion(SwTextFormatInfo &rInf, SwTextAttr *pHt)
The portion for the Footnote Reference in the Text.
Definition: txtftn.cxx:767
SwLinePortion * NewPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1172
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:80
void RecalcRealHeight()
Definition: itrform2.cxx:1675
SwNumberPortion * NewNumberPortion(SwTextFormatInfo &rInf) const
Definition: txtfld.cxx:472
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:86
SwLinePortion * NewExtraPortion(SwTextFormatInfo &rInf)
Definition: txtfld.cxx:354
std::unique_ptr< sw::MergedAttrIterByEnd > m_pByEndIter
Definition: itrform2.hxx:48
void BuildPortions(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:345
bool HasTruncLines() const
Definition: itrform2.hxx:207
void InsertPortion(SwTextFormatInfo &rInf, SwLinePortion *pPor) const
Definition: itrform2.cxx:299
bool IsQuick() const
Definition: itrform2.hxx:183
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:2156
const sal_uInt8 & CntMidHyph() const
Definition: itrform2.hxx:223
bool IsUnclipped() const
Definition: itrform2.hxx:210
SwMultiPortion * pMulti
Definition: itrform2.hxx:39
SwErgoSumPortion * NewErgoSumPortion(SwTextFormatInfo const &rInf) const
Definition: txtftn.cxx:965
bool IsStop() const
Definition: inftxt.hxx:586
void SetUnclipped(bool bNew)
Definition: itrform2.hxx:211
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
void ClearDropFormat()
Definition: itrform2.hxx:200
void CalcAscent(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:746
sal_uInt8 nCntMidHyph
Definition: itrform2.hxx:41
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1470
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:1887
SwTextPortion * WhichTextPor(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:868
SwMultiPortion * GetMulti() const
Definition: itrform2.hxx:202
Used in footnotes if they break across pages, follow starts with this portion.
Definition: porftn.hxx:90
void CalcAdjustLine(SwLineLayout *pCurr)
Definition: itrform2.cxx:731
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:483
unsigned char sal_uInt8
void SetOnceMore(bool bNew)
Definition: itrform2.hxx:205
const sal_uInt8 & CntEndHyph() const
Definition: itrform2.hxx:222
const SwFormatDrop * pDropFormat
Definition: itrform2.hxx:38
SwLinePortion * Underflow(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:151
SwNumberPortion * NewFootnoteNumPortion(SwTextFormatInfo const &rInf) const
The portion for the Footnote Numbering in the Footnote Area.
Definition: txtftn.cxx:906
a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index
Definition: txtfrm.hxx:55
SwTextPortion * NewTextPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:940
void CntHyphens(sal_uInt8 &nEndCnt, sal_uInt8 &nMidCnt) const
Definition: itrtxt.cxx:380
void FeedInf(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:1836
sal_uInt8 nCntEndHyph
Definition: itrform2.hxx:40
SwLinePortion * MakeRestPortion(const SwLineLayout *pLine, TextFrameIndex nPos)
Definition: pormulti.cxx:2352
SwTextInfo & GetInfo()
Definition: itrtxt.hxx:97
void Insert(SwLineLayout *pLine)
Definition: itrform2.cxx:122
bool IsFlyInCntBase() const
Definition: itrform2.hxx:213
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:49
bool IsOnceMore() const
Definition: itrform2.hxx:204
void AlignFlyInCntBase(long nBaseLine) const
Set all anchored as character objects to the passed BaseLine (in Y direction).
Definition: itrform2.cxx:2109
sal_uInt16 GetFrameRstHeight() const
Definition: itrform2.cxx:134
SwLinePortion * WhichFirstPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1009
SwDropPortion * NewDropPortion(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:560
bool CalcOnceMore()
Definition: itrform2.cxx:1874