LibreOffice Module sw (master) 1
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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 .
18 */
19#pragma once
21#include "itrpaint.hxx"
23class SwFlyCntPortion;
24class SwDropPortion;
25class SwFormatDrop;
26class SwTextAttr;
27class SwNumberPortion;
29class SwExpandPortion;
30class SwMultiPortion;
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)
48 SwLinePortion *NewPortion(SwTextFormatInfo &rInf, ::std::optional<TextFrameIndex>);
51 SwTabPortion *NewTabPortion( SwTextFormatInfo &rInf, bool bAuto ) const;
57 const SwTextAttr *pHt ) const;
64 SwTextAttr *pHt ) const;
69 // The center piece of formatting
70 void BuildPortions( SwTextFormatInfo &rInf );
83 void CalcFlyWidth( SwTextFormatInfo &rInf );
85 // Is overloaded by SwTextFormatter because of UpdatePos
86 void CalcAdjustLine( SwLineLayout *pCurr );
88 // considers line spacing attributes
89 void CalcRealHeight( bool bNewLine = false );
91 // Transfers the data to rInf
92 void FeedInf( SwTextFormatInfo &rInf ) const;
94 // Treats underflow situations
97 // Calculates the ascent and the height from the fontmetric
98 void CalcAscent( SwTextFormatInfo &rInf, SwLinePortion *pPor );
100 // determines, if an optimized repaint rectangle is allowed
101 bool AllowRepaintOpt() const;
103 // Is called by FormatLine
104 void FormatReset( SwTextFormatInfo &rInf );
113 void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx,
114 bool bAlways = false ) const;
120 void AlignFlyInCntBase( tools::Long nBaseLine ) const;
129 bool ChkFlyUnderflow( SwTextFormatInfo &rInf ) const;
131 // Insert portion
132 void InsertPortion( SwTextFormatInfo &rInf, SwLinePortion *pPor );
134 // Guess height for the DropPortion
135 void GuessDropHeight( const sal_uInt16 nLines );
138 // Calculate the height for the DropPortion
139 void CalcDropHeight( const sal_uInt16 nLines );
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;
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 );
149 // Amongst others for DropCaps
150 bool CalcOnceMore();
153 SwTextFormatter(SwTextFrame *pTextFrame, SwTextFormatInfo *pTextFormatInf)
154 : SwTextPainter(pTextFrame->GetTextNodeFirst())
155 , m_bUnclipped(false)
156 {
157 CtorInitTextFormatter( pTextFrame, pTextFormatInf );
158 }
159 virtual ~SwTextFormatter() override;
163 void RecalcRealHeight();
165 // We format a line for interactive hyphenation
168 // A special method for QuoVadis texts:
169 // nErgo is the page number of the ErgoSum Footnote
170 // At 0 it's still unclear
173 // The emergency break: Cancel formatting, discard line
174 bool IsStop() const { return GetInfo().IsStop(); }
176 // The counterpart: Continue formatting at all costs
177 bool IsNewLine() const { return GetInfo().IsNewLine(); }
179 // FormatQuick(); Refresh formatting information
180 bool IsQuick() const { return GetInfo().IsQuick(); }
182 // Create a SwLineLayout if needed, which avoids Footnote/Fly to oscillate
183 void MakeDummyLine();
185 // SwTextIter functionality
186 void Insert( SwLineLayout *pLine );
188 // The remaining height to the page border
189 sal_uInt16 GetFrameRstHeight() const;
191 // How wide would you be without any bounds (Flys etc.)?
196 const SwFormatDrop *GetDropFormat() const { return m_pDropFormat; }
197 void ClearDropFormat() { m_pDropFormat = nullptr; }
199 SwMultiPortion *GetMulti() const { return m_pMulti; }
201 bool IsOnceMore() const { return m_bOnceMore; }
202 void SetOnceMore( bool bNew ) { m_bOnceMore = bNew; }
204 bool HasTruncLines() const { return m_bTruncLines; }
205 void SetTruncLines( bool bNew ) { m_bTruncLines = bNew; }
207 bool IsUnclipped() const { return m_bUnclipped; }
208 void SetUnclipped( bool bNew ) { m_bUnclipped = bNew; }
210 bool IsFlyInCntBase() const { return m_bFlyInContentBase; }
211 void SetFlyInCntBase( bool bNew = true ) { m_bFlyInContentBase = bNew; }
214 { return static_cast<SwTextFormatInfo&>(SwTextIter::GetInfo()); }
216 { return static_cast<const SwTextFormatInfo&>(SwTextIter::GetInfo()); }
219 const sal_uInt8 &CntEndHyph() const { return m_nContentEndHyph; }
220 const sal_uInt8 &CntMidHyph() const { return m_nContentMidHyph; }
229 static void MergeCharacterBorder( SwDropPortion const & rPortion );
240 void MergeCharacterBorder( SwLinePortion& rPortion, SwLinePortion const *pPrev, SwTextFormatInfo& rInf );
242 bool ClearIfIsFirstOfBorderMerge(SwLinePortion const *pPortion);
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:72
a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index
Definition: txtfrm.hxx:61
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:592
bool IsNewLine() const
Definition: inftxt.hxx:583
bool IsStop() const
Definition: inftxt.hxx:579
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:316
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:2351
TextFrameIndex m_nRightScanIdx
Definition: itrform2.hxx:40
bool CalcOnceMore()
Definition: itrform2.cxx:2302
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:1316
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:2672
void CalcUnclipped(SwTwips &rTop, SwTwips &rBottom)
Definition: itrform2.cxx:2403
void FormatReset(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:2289
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:484
SwTwips CalcFitToContent_()
Definition: itrform2.cxx:2340
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:93
SwLinePortion * NewPortion(SwTextFormatInfo &rInf, ::std::optional< TextFrameIndex >)
Definition: itrform2.cxx:1567
void AlignFlyInCntBase(tools::Long nBaseLine) const
Set all anchored as character objects to the passed BaseLine (in Y direction).
Definition: itrform2.cxx:2537
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:2584
bool IsNewLine() const
Definition: itrform2.hxx:177
void CalcAscent(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:811
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:796
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1878
SwMultiPortion * m_pMulti
Definition: itrform2.hxx:36
SwNumberPortion * NewNumberPortion(SwTextFormatInfo &rInf) const
Definition: txtfld.cxx:584
SwLinePortion * WhichFirstPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1390
void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx, bool bAlways=false) const
The position of the portions changes with the adjustment.
Definition: itrform2.cxx:2415
SwLinePortion * NewExtraPortion(SwTextFormatInfo &rInf)
Definition: txtfld.cxx:355
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:3025
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:2109
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:2925
void FeedInf(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:2265
SwTextPortion * WhichTextPor(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:1152
SwLinePortion * m_pFirstOfBorderMerge
Definition: itrform2.hxx:46
void RecalcRealHeight()
Definition: itrform2.cxx:2101
SwLinePortion * Underflow(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:168
void InsertPortion(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:313
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:2315
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:168
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