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#pragma once
20
21#include "itrpaint.hxx"
22
23class SwFlyCntPortion;
24class SwDropPortion;
25class SwFormatDrop;
26class SwTextAttr;
27class SwNumberPortion;
29class SwExpandPortion;
30class SwMultiPortion;
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
48 SwLinePortion *NewPortion(SwTextFormatInfo &rInf, ::std::optional<TextFrameIndex>);
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
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( tools::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
137public:
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
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
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()); }
216 { return static_cast<const SwTextFormatInfo&>(SwTextIter::GetInfo()); }
217
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 bool ClearIfIsFirstOfBorderMerge(SwLinePortion const *pPortion);
243};
244
245/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Text portion for the Format -> Paragraph -> Drop Caps functionality.
Definition: pordrop.hxx:65
Used in footnotes if they break across pages, follow starts with this portion.
Definition: porftn.hxx:94
This portion represents an as-character anchored fly (shape, frame, etc.)
Definition: porfly.hxx:45
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps.
Definition: paratr.hxx:63
a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index
Definition: txtfrm.hxx:58
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:79
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
bool IsQuick() const
Definition: inftxt.hxx:590
bool IsNewLine() const
Definition: inftxt.hxx:581
bool IsStop() const
Definition: inftxt.hxx:577
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:321
bool IsFlyInCntBase() const
Definition: itrform2.hxx:210
void SetUnclipped(bool bNew)
Definition: itrform2.hxx:208
std::unique_ptr< sw::MergedAttrIterByEnd > m_pByEndIter
Definition: itrform2.hxx:45
bool IsOnceMore() const
Definition: itrform2.hxx:201
sal_uInt8 & CntMidHyph()
Definition: itrform2.hxx:222
bool m_bTruncLines
Definition: itrform2.hxx:43
sal_uInt16 GetFrameRstHeight() const
Definition: itrform2.cxx:141
bool AllowRepaintOpt() const
Definition: itrform2.cxx:2313
TextFrameIndex m_nRightScanIdx
Definition: itrform2.hxx:40
bool CalcOnceMore()
Definition: itrform2.cxx:2264
SwExpandPortion * NewFieldPortion(SwTextFormatInfo &rInf, const SwTextAttr *pHt) const
Definition: txtfld.cxx:76
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:546
SwTextPortion * NewTextPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1296
sal_uInt8 m_nContentEndHyph
Definition: itrform2.hxx:37
const sal_uInt8 & CntMidHyph() const
Definition: itrform2.hxx:220
bool ClearIfIsFirstOfBorderMerge(SwLinePortion const *pPortion)
Definition: itrform2.cxx:158
void InitCntHyph()
Definition: itrform2.hxx:218
SwErgoSumPortion * NewErgoSumPortion(SwTextFormatInfo const &rInf) const
Definition: txtftn.cxx:1044
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
Definition: txthyph.cxx:126
bool HasTruncLines() const
Definition: itrform2.hxx:204
SwMultiPortion * GetMulti() const
Definition: itrform2.hxx:199
SwTextFormatter(SwTextFrame *pTextFrame, SwTextFormatInfo *pTextFormatInf)
Definition: itrform2.hxx:153
void SetFlyInCntBase(bool bNew=true)
Definition: itrform2.hxx:211
bool m_bFlyInContentBase
Definition: itrform2.hxx:42
SwTabPortion * NewTabPortion(SwTextFormatInfo &rInf, bool bAuto) const
Definition: txttab.cxx:70
sal_uInt8 & CntEndHyph()
Definition: itrform2.hxx:221
const sal_uInt8 & CntEndHyph() const
Definition: itrform2.hxx:219
void SetOnceMore(bool bNew)
Definition: itrform2.hxx:202
void MakeDummyLine()
This function creates a Line that reaches to the other Page Margin.
Definition: txtftn.cxx:1276
void SetTruncLines(bool bNew)
Definition: itrform2.hxx:205
void CalcFlyWidth(SwTextFormatInfo &rInf)
Calculation of the emulated right side.
Definition: itrform2.cxx:2634
void CalcUnclipped(SwTwips &rTop, SwTwips &rBottom)
Definition: itrform2.cxx:2365
void FormatReset(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:2251
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:484
SwTwips CalcFitToContent_()
Definition: itrform2.cxx:2302
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:93
SwLinePortion * NewPortion(SwTextFormatInfo &rInf, ::std::optional< TextFrameIndex >)
Definition: itrform2.cxx:1547
void AlignFlyInCntBase(tools::Long nBaseLine) const
Set all anchored as character objects to the passed BaseLine (in Y direction).
Definition: itrform2.cxx:2499
SwDropPortion * NewDropPortion(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:561
bool IsStop() const
Definition: itrform2.hxx:174
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:2546
bool IsNewLine() const
Definition: itrform2.hxx:177
void CalcAscent(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:800
const SwFormatDrop * GetDropFormat() const
Definition: itrform2.hxx:196
TextFrameIndex FormatQuoVadis(TextFrameIndex nStart)
Definition: txtftn.cxx:1072
SwLinePortion * MakeRestPortion(const SwLineLayout *pLine, TextFrameIndex nPos)
Definition: pormulti.cxx:2397
void BuildPortions(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:377
void CalcAdjustLine(SwLineLayout *pCurr)
Definition: itrform2.cxx:785
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1858
SwMultiPortion * m_pMulti
Definition: itrform2.hxx:36
SwNumberPortion * NewNumberPortion(SwTextFormatInfo &rInf) const
Definition: txtfld.cxx:620
SwLinePortion * WhichFirstPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1370
void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx, bool bAlways=false) const
The position of the portions changes with the adjustment.
Definition: itrform2.cxx:2377
SwLinePortion * NewExtraPortion(SwTextFormatInfo &rInf)
Definition: txtfld.cxx:360
bool BuildMultiPortion(SwTextFormatInfo &rInf, SwMultiPortion &rMulti)
Definition: pormulti.cxx:1907
const SwTextFormatInfo & GetInfo() const
Definition: itrform2.hxx:215
TextFrameIndex m_nLeftScanIdx
Definition: itrform2.hxx:39
bool IsUnclipped() const
Definition: itrform2.hxx:207
static void MergeCharacterBorder(SwDropPortion const &rPortion)
Merge border of the drop portion with modifying the font of the portions' part.
Definition: itrform2.cxx:2963
void ClearDropFormat()
Definition: itrform2.hxx:197
SwFootnotePortion * NewFootnotePortion(SwTextFormatInfo &rInf, SwTextAttr *pHt)
The portion for the Footnote Reference in the Text.
Definition: txtftn.cxx:793
SwNumberPortion * NewFootnoteNumPortion(SwTextFormatInfo const &rInf) const
The portion for the Footnote Numbering in the Footnote Area.
Definition: txtftn.cxx:933
void CalcRealHeight(bool bNewLine=false)
Definition: itrform2.cxx:2071
bool IsQuick() const
Definition: itrform2.hxx:180
const SwFormatDrop * m_pDropFormat
Definition: itrform2.hxx:35
SwFlyCntPortion * NewFlyCntPortion(SwTextFormatInfo &rInf, SwTextAttr *pHt) const
Sets a new portion for an object anchored as character.
Definition: itrform2.cxx:2863
void FeedInf(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:2227
SwTextPortion * WhichTextPor(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:1132
SwLinePortion * m_pFirstOfBorderMerge
Definition: itrform2.hxx:46
void RecalcRealHeight()
Definition: itrform2.cxx:2063
SwLinePortion * Underflow(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:168
void InsertPortion(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:313
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:2277
SwTextFormatInfo & GetInfo()
Definition: itrform2.hxx:213
virtual ~SwTextFormatter() override
Definition: itrform2.cxx:118
void Insert(SwLineLayout *pLine)
Definition: itrform2.cxx:129
sal_uInt8 m_nContentMidHyph
Definition: itrform2.hxx:38
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
SwTextInfo & GetInfo()
Definition: itrtxt.hxx:96
void CntHyphens(sal_uInt8 &nEndCnt, sal_uInt8 &nMidCnt) const
Definition: itrtxt.cxx:422
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
long Long
tools::Long SwTwips
Definition: swtypes.hxx:51
unsigned char sal_uInt8