22#include <com/sun/star/i18n/ScriptType.hpp>
23#include <com/sun/star/i18n/XBreakIterator.hpp>
43#include <accessibilityoptions.hxx>
45#include <unicode/ubidi.h>
46#include <bookmark.hxx>
55 std::unique_ptr<SwFont> pNewFnt;
70 OSL_ENSURE( pField,
"TakeNextOffset: Missing Source" );
77 : m_aExpand(
std::move(aExpand)), m_pFont(
std::move(pFont)), m_nNextOffset(0)
78 , m_nNextScriptChg(
COMPLETE_STRING), m_nFieldLen(nFieldLen), m_nViewWidth(0)
79 , m_bFollow( false ), m_bLeft( false), m_bHide( false)
80 , m_bCenter (false), m_bHasFollow( false )
81 , m_bAnimated( false), m_bNoPaint( false)
82 , m_bReplace( false), m_bPlaceHolder( bPlaceHold )
83 , m_bNoLength( false )
91 , m_aExpand( rField.
GetExp() )
92 , m_nNextOffset( rField.GetNextOffset() )
93 , m_nNextScriptChg( rField.m_nNextScriptChg )
94 , m_nFieldLen(rField.m_nFieldLen)
95 , m_nViewWidth( rField.m_nViewWidth )
96 , m_bFollow( rField.IsFollow() )
97 , m_bLeft( rField.IsLeft() )
98 , m_bHide( rField.IsHide() )
99 , m_bCenter( rField.IsCenter() )
100 , m_bHasFollow( rField.HasFollow() )
101 , m_bAnimated ( rField.m_bAnimated )
102 , m_bNoPaint( rField.m_bNoPaint)
103 , m_bReplace( rField.m_bReplace )
104 , m_bPlaceHolder( rField.m_bPlaceHolder )
105 , m_bNoLength( rField.m_bNoLength )
106 , m_nAttrFieldType( rField.m_nAttrFieldType)
141 std::shared_ptr<const vcl::text::TextLayoutCache> m_pOldCachedVclData;
142 const OUString *pOldText;
169 nLen = pInf->GetLen();
170 pOldText = &(pInf->GetText());
171 m_pOldCachedVclData = pInf->GetCachedVclData();
173 pInf->SetCachedVclData(
nullptr);
176 pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() );
185 aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText);
187 else if (nIdx == nEnd)
188 aText = *pOldText + aText;
190 SAL_WARN(
"sw.core",
"SwFieldSlot bad SwFieldPortion index.");
192 pInf->SetText( aText );
195SwFieldSlot::~SwFieldSlot()
199 pInf->SetCachedVclData(m_pOldCachedVclData);
200 pInf->SetText( *pOldText );
201 pInf->SetIdx( nIdx );
202 pInf->SetLen( nLen );
203 pInf->SetFakeLineStart(
false );
210 if (!
GetExpText(rInf, aText) || aText.isEmpty())
216 if( i18n::ScriptType::WEAK == nScript )
219 if (nChg < aText.getLength() && nChg >= 0)
225 if (nChg < aText.getLength() && nChg >= 0)
236 default: nTmp = nActual;
247 UErrorCode nError = U_ZERO_ERROR;
248 UBiDi* pBidi = ubidi_openSized( aText.getLength(), 0, &nError );
249 ubidi_setPara( pBidi,
reinterpret_cast<const UChar *
>(aText.getStr()), aText.getLength(), nFieldDir,
nullptr, &nError );
252 ubidi_getLogicalRun( pBidi, 0, &nEnd, &nCurrDir );
253 ubidi_close( pBidi );
259 if (nCurrDir != UBIDI_RTL &&
260 (UBIDI_LTR != nFieldDir || i18n::ScriptType::COMPLEX == nScript))
262 nCurrDir = UBIDI_RTL;
263 for( sal_Int32 nCharIdx = 0; nCharIdx < nEnd; ++nCharIdx )
265 UCharDirection nCharDir = u_charDirection ( aText[ nCharIdx ]);
266 if ( nCharDir == U_LEFT_TO_RIGHT ||
267 nCharDir == U_LEFT_TO_RIGHT_EMBEDDING ||
268 nCharDir == U_LEFT_TO_RIGHT_OVERRIDE )
270 nCurrDir = UBIDI_LTR;
276 if (nCurrDir == UBIDI_RTL)
282 if (nScript == i18n::ScriptType::COMPLEX)
295 else if ( nTmp != nActual )
312 SwFieldSlot aDiffText( &rInf,
this );
357 rInf.
SetNotEOL( nFullLen == nOldFullLen && nTextRest > nFollow );
371 bEOL = !nTmpLen && nFollow && bFull;
372 nRest = nOldFullLen - nTmpLen;
387 OUString aNew(
m_aExpand.copy(sal_Int32(nNextOfst)) );
392 const sal_Unicode nNew = !aNew.isEmpty() ? aNew[0] : 0;
427 if( !aNew.isEmpty() && !pField->
GetFont() )
436 if (pField->
Compress() && !std::all_of(std::u16string_view(aNew).begin(),
437 std::u16string_view(aNew).end(), IsHook))
474 if( rText.isEmpty() && rInf.
OnWin() &&
490 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFieldPortion"));
494 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"expand"), BAD_CAST(
m_aExpand.toUtf8().getStr()));
501 (void)xmlTextWriterEndElement(pWriter);
513 std::unique_ptr<SwFont> pNewFnt;
536 std::unique_ptr<SwFont> pFont,
539 const sal_uInt16 nMinDst,
540 const bool bLabelAlignmentPosAndSpaceModeActive )
543 , m_nMinDist(nMinDst)
544 , mbLabelAlignmentPosAndSpaceModeActive(bLabelAlignmentPosAndSpaceModeActive)
559 std::unique_ptr<SwFont> pNewFnt;
584 OSL_ENSURE(
Height() &&
mnAscent,
"NumberPortions without Height | Ascent" );
596 GetSwAttrSet().GetFirstLineIndent().GetTextFirstLineOffset()
609 else if ( nDiff > rInf.
X() )
621 const bool bFly = rInf.
GetFly() ||
623 if( nDiff > rInf.
Width() )
625 nDiff = rInf.
Width();
637 else if(
Width() < nDiff )
676 const sal_uInt16 nOldWidth =
Width();
677 sal_uInt16 nSumWidth = 0;
678 sal_uInt16 nOffset = 0;
683 nSumWidth = nSumWidth + pTmp->
Width();
698 pThis->
Width( nSumWidth );
700 pThis->
Width( nOldWidth );
725 bPaintSpace = bPaintSpace &&
m_nFixWidth < nOldWidth;
742 sal_uInt16 nTmpOffset = nOffset;
750 aInf.
X( aInf.
X() + nOffset );
753 nSpaceOffs = nSpaceOffs + nOffset;
755 if( bPaintSpace && nOldWidth > nSpaceOffs )
758 aInf.
X( aInf.
X() + nSpaceOffs );
767 pThis->
Width( nOldWidth - nSpaceOffs + 12 );
769 SwTextSlot aDiffText( &aInf,
this,
true,
false,
" " );
773 pThis->
Width( nOldWidth );
778 std::u16string_view rBulletFollowedBy,
779 std::unique_ptr<SwFont> pFont,
782 const sal_uInt16 nMinDst,
783 const bool bLabelAlignmentPosAndSpaceModeActive )
785 std::move(pFont), bLft, bCntr, nMinDst,
786 bLabelAlignmentPosAndSpaceModeActive )
791#define GRFNUM_SECURE 10
794 const OUString& rGraphicFollowedBy,
795 const SvxBrushItem* pGrfBrush, OUString
const & referer,
797 const bool bLft,
const bool bCntr,
const sal_uInt16 nMinDst,
798 const bool bLabelAlignmentPosAndSpaceModeActive ) :
800 bLabelAlignmentPosAndSpaceModeActive ),
857 sal_uInt16 nFollowedByWidth( 0 );
861 nFollowedByWidth =
Width();
865 const bool bFull = rInf.
Width() < rInf.
X() +
Width();
866 const bool bFly = rInf.
GetFly() ||
892 else if ( nDiff > rInf.
X() )
901 if( nDiff > rInf.
Width() )
903 nDiff = rInf.
Width();
908 if(
Width() < nDiff )
960 aSize =
Size( nTmpH, nTmpH );
961 aPos.
setY( rInf.
Y() - nTmpH );
963 SwRect aTmp( aPos, aSize );
982 pViewShell && pViewShell->
GetWin() )
990 else if ( pViewShell &&
1049 if (
GetOrient() == text::VertOrientation::CENTER )
1051 else if (
GetOrient() == text::VertOrientation::TOP )
1053 else if (
GetOrient() == text::VertOrientation::BOTTOM )
1055 else if (
GetOrient() == text::VertOrientation::CHAR_CENTER )
1057 else if (
GetOrient() == text::VertOrientation::CHAR_TOP )
1059 else if (
GetOrient() == text::VertOrientation::CHAR_BOTTOM )
1069 else if (
GetOrient() == text::VertOrientation::LINE_CENTER )
1071 else if (
GetOrient() == text::VertOrientation::LINE_TOP )
1073 else if (
GetOrient() == text::VertOrientation::LINE_BOTTOM )
1080 OSL_ENSURE(
HasAnimation(),
"SwTextFrame::StopAnimation: Which Animation?" );
1106 , m_aWidth{ static_cast<sal_uInt16>(0),
1107 static_cast<sal_uInt16>(0),
1108 static_cast<sal_uInt16>(0) }
1123 for( sal_Int32
i = 0;
i < rText.getLength(); ++
i )
1150 OSL_ENSURE(
nCount < 7,
"Too much combined characters" );
1153 const sal_Int32 nTop = (
nCount + 1 ) / 2;
1161 for( sal_Int32
i = 0 ;
i <
nCount; ++
i )
1177 aTmpFont.
SetSize( aTmpSz, nAct );
1197 OSL_ENSURE(
nCount < 7,
"Too much combined characters" );
1218 const sal_Int32 nTop = (
nCount + 1 ) / 2;
1225 sal_uInt16 nMaxDescent, nMaxAscent, nMaxWidth;
1228 nMainDescent = nMainDescent - nMainAscent;
1254 aTmpFont.
SetSize( aFontSize, nScrp );
1260 m_aPos[
i ] = o3tl::narrowing<sal_uInt16>(aSize.
Width());
1264 Height( nMaxDescent + nMaxAscent );
1271 nMaxWidth = nMaxWidth +
m_aPos[
i ];
1272 if( nAsc > nMaxAscent )
1274 if( aSize.
Height() - nAsc > nMaxDescent )
1275 nMaxDescent = aSize.
Height() - nAsc;
1284 Height( nMaxAscent + nMaxDescent );
1300 if(
Height() < nMainAscent + nMainDescent )
1301 Height( nMainAscent + nMainDescent );
1304 sal_uInt16 nTopDiff = 0;
1305 sal_uInt16 nBotDiff = 0;
1306 if( nMaxWidth >
Width() )
1308 nTopDiff = ( nMaxWidth -
Width() ) / 2;
1312 nBotDiff = (
Width() - nMaxWidth ) / 2;
1324 case 3:
m_aPos[nTop] = nBotDiff;
break;
1327 case 4:
m_aPos[nTop] = 0;
1333 const bool bFull = rInf.
Width() < rInf.
X() +
Width();
1371 rInf.
CalcRect( *
this, &aPaintArea );
1389 rInf.
CalcRect( *
this, &aPaintArea );
@ IGNORE_FIRST_LINE_INDENT_IN_NUMBERING
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
void StopAnimation(const OutputDevice *pOutputDevice, tools::Long nExtraData)
void StartAnimation(OutputDevice &rOutDev, const Point &rDestPt, const Size &rDestSize, tools::Long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
void SetFont(const vcl::Font &rNewFont)
FontMetric GetFontMetric() const
OutDevType GetOutDevType() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
constexpr tools::Long Width() const
const Graphic * GetGraphic(OUString const &referer=OUString()) const
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
bool IsStopAnimatedGraphics() const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
SwBulletPortion(const sal_UCS4 cCh, std::u16string_view rBulletFollowedBy, std::unique_ptr< SwFont > pFnt, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
SwFontScript m_aScrType[6]
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
virtual bool Format(SwTextFormatInfo &rInf) override
SwCombinedPortion(const OUString &rExpand)
Initializes the script array and clears the width array.
o3tl::enumarray< SwFontScript, sal_uInt16 > m_aWidth
virtual void Paint(const SwTextPaintInfo &rInf) const override
IDocumentSettingAccess const & getIDocumentSettingAccess() const
virtual void Paint(const SwTextPaintInfo &rInf) const override
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
void SetCenter(bool bNew)
std::unique_ptr< SwFont > m_pFont
TextFrameIndex m_nNextOffset
void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &nOffset) const override
TextFrameIndex GetNextOffset() const
const bool m_bPlaceHolder
void SetNextOffset(TextFrameIndex nNew)
virtual SwFieldPortion * Clone(const OUString &rExpand) const
virtual void HandlePortion(SwPortionHandler &rPH) const override
const SwFont * GetFont() const
virtual SwLinePortion * Compress() override
TextFrameIndex GetFieldLen() const
virtual void Paint(const SwTextPaintInfo &rInf) const override
TextFrameIndex m_nFieldLen
virtual bool Format(SwTextFormatInfo &rInf) override
void SetFollow(bool bNew)
void CheckScript(const SwTextSizeInfo &rInf)
void SetFont(std::unique_ptr< SwFont > pNew)
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
TextFrameIndex m_nNextScriptChg
SwFieldPortion(const SwFieldPortion &rField)
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
void SetHasFollow(bool bNew)
virtual ~SwFieldPortion() override
void TakeNextOffset(const SwFieldPortion *pField)
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
sal_uInt16 GetBottomBorderSpace() const
sal_uInt16 GetTopBorderSpace() const
const Size & GetSize(SwFontScript nWhich) const
FontLineStyle GetUnderline() const
Size GetTextSize_(SwDrawTextInfo &rInf)
void SetProportion(const sal_uInt8 nNewPropr)
FontStrikeout GetStrikeout() const
void SetSize(const Size &rSize, const SwFontScript nWhich)
SwFontScript GetActual() const
FontLineStyle GetOverline() const
bool IsWordLineMode() const
const SvxFont & GetFnt(const SwFontScript nWhich) const
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
tools::Long GetHeight() const
void SetActual(SwFontScript nNew)
bool IsRightToLeft() const
SwRootFrame * getRootFrame()
SwTwips GetRelPos() const
void SetRelPos(SwTwips nNew)
void SetBase(tools::Long nLnAscent, tools::Long nLnDescent, tools::Long nFlyAscent, tools::Long nFlyDescent)
SwGrfNumPortion(const OUString &rGraphicFollowedBy, const SvxBrushItem *pGrfBrush, OUString const &referer, const SwFormatVertOrient *pGrfOrient, const Size &rGrfSize, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
void SetAnimated(bool bNew)
std::unique_ptr< SvxBrushItem > m_pBrush
virtual ~SwGrfNumPortion() override
SwTwips GetGrfHeight() const
virtual bool Format(SwTextFormatInfo &rInf) override
We can create multiple NumFields Tricky, if one enters enough previous-text in the dialog box to caus...
sal_Int16 GetOrient() const
void StopAnimation(const OutputDevice *pOut)
virtual void Paint(const SwTextPaintInfo &rInf) const override
A hidden NumberPortion is not displayed, unless there are TextPortions in this line or there's only o...
void SetId(tools::Long nNew) const
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
SwHiddenPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFntL=nullptr)
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
virtual void Paint(const SwTextPaintInfo &rInf) const override
Collection of SwLinePortion instances, representing one line of text.
Base class for anything that can be part of a line in the Writer layout.
void dumpAsXmlAttributes(xmlTextWriterPtr writer, std::u16string_view rText, TextFrameIndex nOffset) const
virtual void FormatEOL(SwTextFormatInfo &rInf)
SwLinePortion * mpNextPortion
SwLinePortion * GetNextPortion() const
void SetAscent(const SwTwips nNewAsc)
PortionType GetWhichPor() const
TextFrameIndex GetLen() const
bool IsFootnotePortion() const
virtual SwLinePortion * Compress()
bool IsQuoVadisPortion() const
void SetLen(TextFrameIndex const nLen)
bool IsGrfNumPortion() const
bool IsFlyPortion() const
bool IsFootnoteNumPortion() const
void SetWhichPor(const PortionType nNew)
bool IsNumberPortion() const
void PrePaint(const SwTextPaintInfo &rInf, const SwLinePortion *pLast) const
SwNumberPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFnt, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
bool mbLabelAlignmentPosAndSpaceModeActive
virtual void FormatEOL(SwTextFormatInfo &rInf) override
A FormatEOL indicates that the subsequent text did not fit onto the line anymore.
virtual void Paint(const SwTextPaintInfo &rInf) const override
A hidden NumberPortion is not displayed, unless there are TextPortions in this line or there's just o...
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
virtual bool Format(SwTextFormatInfo &rInf) override
We can create multiple NumFields Tricky, if one enters enough previous-text in the dialog box to caus...
SwScriptInfo & GetScriptInfo()
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
virtual void Special(TextFrameIndex nLength, const OUString &rText, PortionType nType)=0
special portion.
Used in footnotes if they break across pages, master has this portion at the end.
Of course Writer needs its own rectangles.
bool Overlaps(const SwRect &rRect) const
SwViewShell * GetCurrShell() const
sal_uInt8 GetDefaultDir() const
sal_uInt8 DirType(const TextFrameIndex nPos) const
SwLinePortion * GetLast()
void SetUnderScorePos(TextFrameIndex const nNew)
void SetRest(SwLinePortion *pNewRest)
sal_uInt16 ForcedLeftMargin() const
void SetLineStart(TextFrameIndex const nNew)
TextFrameIndex GetLineStart() const
const SwLinePortion * GetUnderflow() const
TextFrameIndex ScanPortionEnd(TextFrameIndex nStart, TextFrameIndex nEnd)
SwLinePortion * GetRest()
void SetNumDone(const bool bNew)
TextFrameIndex GetUnderScorePos() const
void SetHookChar(const sal_Unicode cNew)
Represents the visualization of a paragraph.
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
void SetAnimation() const
bool HasAnimation() const
void StopAnimation(const OutputDevice *pOut)
Stops the animations within numberings.
SwParaPortion * GetPara()
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout.
SwTextNode const * GetTextNodeForParaProps() const
SwParaPortion * GetParaPortion()
void DrawText(const OUString &rText, const SwLinePortion &rPor, TextFrameIndex nIdx=TextFrameIndex(0), TextFrameIndex nLen=TextFrameIndex(COMPLETE_STRING), const bool bKern=false) const
const SwRect & GetPaintRect() const
const Point & GetPos() const
void CalcRect(const SwLinePortion &rPor, SwRect *pRect, SwRect *pIntersect=nullptr, const bool bInsideBox=false) const
Calculate the rectangular area where the portion takes place.
void DrawBackBrush(const SwLinePortion &rPor) const
void DrawViewOpt(const SwLinePortion &rPor, PortionType nWhich, const Color *pColor=nullptr) const
virtual bool Format(SwTextFormatInfo &rInf) override
SwTextFrame * GetTextFrame()
vcl::RenderContext * GetOut()
const SwViewOption & GetOpt() const
void SetLen(const TextFrameIndex nNew)
sal_uInt16 GetTextHeight() const
void NoteAnimation() const
SwPosSize GetTextSize(OutputDevice *pOut, const SwScriptInfo *pSI, const OUString &rText, TextFrameIndex nIdx, TextFrameIndex nLen) const
SwUnderlineFont * GetUnderFnt() const
sal_uInt16 GetAscent() const
TextFrameIndex GetLen() const
void SetNotEOL(const bool bNew)
const OUString & GetText() const
TextFrameIndex GetIdx() const
For the text replacement and restoration of SwTextSizeInfo.
void SetPos(const Point &rPoint)
const Point & GetPos() const
bool IsPagePreview() const
bool IsShowPlaceHolderFields() const
bool IsFieldShadings() const
vcl::Window * GetWin() const
void InvalidateWindows(const SwRect &rRect)
const SwAccessibilityOptions * GetAccessibilityOptions() const
Fieldmark representing a date form field.
void SetPortionPaintAreaStart(const SwRect &rPortionPaintArea)
void SetPortionPaintAreaEnd(const SwRect &rPortionPaintArea)
Fieldmark representing a drop-down form field.
void SetPortionPaintArea(const SwRect &rPortionPaintArea)
const Size & GetFontSize() const
struct _xmlTextWriter * xmlTextWriterPtr
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
#define CH_TXTATR_BREAKWORD
#define SAL_WARN(area, stream)
double getLength(const B2DPolygon &rCandidate)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
const sal_Unicode CH_BREAK
constexpr sal_Int32 COMPLETE_STRING