22 #include <com/sun/star/i18n/ScriptType.hpp>
23 #include <com/sun/star/i18n/XBreakIterator.hpp>
42 #include <accessibilityoptions.hxx>
44 #include <unicode/ubidi.h>
45 #include <bookmark.hxx>
54 std::unique_ptr<SwFont> pNewFnt;
69 OSL_ENSURE( pField,
"TakeNextOffset: Missing Source" );
76 : m_aExpand(rExpand), m_pFont(
std::move(pFont)), m_nNextOffset(0)
77 , m_nNextScriptChg(
COMPLETE_STRING), m_nFieldLen(nFieldLen), m_nViewWidth(0)
81 , m_bReplace(
false), m_bPlaceHolder( bPlaceHold )
82 , m_bNoLength(
false )
90 , m_aExpand( rField.
GetExp() )
91 , m_nNextOffset( rField.GetNextOffset() )
92 , m_nNextScriptChg( rField.m_nNextScriptChg )
93 , m_nFieldLen(rField.m_nFieldLen)
94 , m_nViewWidth( rField.m_nViewWidth )
95 , m_bFollow( rField.IsFollow() )
96 , m_bLeft( rField.IsLeft() )
97 , m_bHide( rField.IsHide() )
98 , m_bCenter( rField.IsCenter() )
99 , m_bHasFollow( rField.HasFollow() )
100 , m_bAnimated ( rField.m_bAnimated )
101 , m_bNoPaint( rField.m_bNoPaint)
102 , m_bReplace( rField.m_bReplace )
103 , m_bPlaceHolder( rField.m_bPlaceHolder )
104 , m_bNoLength( rField.m_bNoLength )
105 , m_nAttrFieldType( rField.m_nAttrFieldType)
140 std::shared_ptr<const vcl::text::TextLayoutCache> m_pOldCachedVclData;
141 const OUString *pOldText;
168 nLen = pInf->GetLen();
169 pOldText = &(pInf->GetText());
170 m_pOldCachedVclData = pInf->GetCachedVclData();
172 pInf->SetCachedVclData(
nullptr);
175 pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() );
184 aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText);
186 else if (nIdx == nEnd)
187 aText = *pOldText + aText;
189 SAL_WARN(
"sw.core",
"SwFieldSlot bad SwFieldPortion index.");
191 pInf->SetText( aText );
194 SwFieldSlot::~SwFieldSlot()
198 pInf->SetCachedVclData(m_pOldCachedVclData);
199 pInf->SetText( *pOldText );
200 pInf->SetIdx( nIdx );
201 pInf->SetLen( nLen );
202 pInf->SetFakeLineStart(
false );
209 if (!
GetExpText(rInf, aText) || aText.isEmpty())
215 if( i18n::ScriptType::WEAK == nScript )
218 if (nChg < aText.getLength() && nChg >= 0)
224 if (nChg < aText.getLength() && nChg >= 0)
235 default: nTmp = nActual;
246 UErrorCode nError = U_ZERO_ERROR;
247 UBiDi* pBidi = ubidi_openSized( aText.getLength(), 0, &nError );
248 ubidi_setPara( pBidi, reinterpret_cast<const UChar *>(aText.getStr()), aText.getLength(), nFieldDir,
nullptr, &nError );
251 ubidi_getLogicalRun( pBidi, 0, &nEnd, &nCurrDir );
252 ubidi_close( pBidi );
258 if (nCurrDir != UBIDI_RTL &&
259 (UBIDI_LTR != nFieldDir || i18n::ScriptType::COMPLEX == nScript))
261 nCurrDir = UBIDI_RTL;
262 for( sal_Int32 nCharIdx = 0; nCharIdx < nEnd; ++nCharIdx )
264 UCharDirection nCharDir = u_charDirection ( aText[ nCharIdx ]);
265 if ( nCharDir == U_LEFT_TO_RIGHT ||
266 nCharDir == U_LEFT_TO_RIGHT_EMBEDDING ||
267 nCharDir == U_LEFT_TO_RIGHT_OVERRIDE )
269 nCurrDir = UBIDI_LTR;
275 if (nCurrDir == UBIDI_RTL)
281 if (nScript == i18n::ScriptType::COMPLEX)
294 else if ( nTmp != nActual )
311 SwFieldSlot aDiffText( &rInf,
this );
356 rInf.
SetNotEOL( nFullLen == nOldFullLen && nTextRest > nFollow );
370 bEOL = !nTmpLen && nFollow && bFull;
371 nRest = nOldFullLen - nTmpLen;
384 nNextOfst = nNextOfst +
TextFrameIndex(static_cast<SwQuoVadisPortion*>(
this)->GetContText().getLength());
386 OUString aNew(
m_aExpand.copy(sal_Int32(nNextOfst)) );
387 m_aExpand = m_aExpand.copy(0, sal_Int32(nNextOfst));
391 const sal_Unicode nNew = !aNew.isEmpty() ? aNew[0] : 0;
406 aNew = aNew.copy( 1 );
417 if( !aNew.isEmpty() && !pField->
GetFont() )
455 if( rText.isEmpty() && rInf.
OnWin() &&
478 (
void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFieldPortion"));
482 (
void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"expand"), BAD_CAST(
m_aExpand.toUtf8().getStr()));
484 (
void)xmlTextWriterEndElement(pWriter);
496 std::unique_ptr<SwFont> pNewFnt;
519 std::unique_ptr<SwFont> pFont,
522 const sal_uInt16 nMinDst,
523 const bool bLabelAlignmentPosAndSpaceModeActive )
526 m_nMinDist( nMinDst ),
527 mbLabelAlignmentPosAndSpaceModeActive( bLabelAlignmentPosAndSpaceModeActive )
542 std::unique_ptr<SwFont> pNewFnt;
567 OSL_ENSURE(
Height() &&
mnAscent,
"NumberPortions without Height | Ascent" );
579 GetSwAttrSet().GetLRSpace().GetTextFirstLineOffset()
592 else if ( nDiff > rInf.
X() )
604 const bool bFly = rInf.
GetFly() ||
606 if( nDiff > rInf.
Width() )
608 nDiff = rInf.
Width();
620 else if(
Width() < nDiff )
659 const sal_uInt16 nOldWidth =
Width();
660 sal_uInt16 nSumWidth = 0;
661 sal_uInt16 nOffset = 0;
666 nSumWidth = nSumWidth + pTmp->
Width();
667 if ( static_cast<const SwNumberPortion*>(pTmp)->
HasFollow() )
681 pThis->
Width( nSumWidth );
683 pThis->
Width( nOldWidth );
708 bPaintSpace = bPaintSpace &&
m_nFixWidth < nOldWidth;
725 sal_uInt16 nTmpOffset = nOffset;
733 aInf.
X( aInf.
X() + nOffset );
736 nSpaceOffs = nSpaceOffs + nOffset;
738 if( bPaintSpace && nOldWidth > nSpaceOffs )
741 aInf.
X( aInf.
X() + nSpaceOffs );
750 pThis->
Width( nOldWidth - nSpaceOffs + 12 );
752 SwTextSlot aDiffText( &aInf,
this,
true,
false,
" " );
756 pThis->
Width( nOldWidth );
761 std::u16string_view rBulletFollowedBy,
762 std::unique_ptr<SwFont> pFont,
765 const sal_uInt16 nMinDst,
766 const bool bLabelAlignmentPosAndSpaceModeActive )
768 std::move(pFont), bLft, bCntr, nMinDst,
769 bLabelAlignmentPosAndSpaceModeActive )
774 #define GRFNUM_SECURE 10
777 const OUString& rGraphicFollowedBy,
778 const SvxBrushItem* pGrfBrush, OUString
const & referer,
780 const bool bLft,
const bool bCntr,
const sal_uInt16 nMinDst,
781 const bool bLabelAlignmentPosAndSpaceModeActive ) :
783 bLabelAlignmentPosAndSpaceModeActive ),
840 sal_uInt16 nFollowedByWidth( 0 );
844 nFollowedByWidth =
Width();
848 const bool bFull = rInf.
Width() < rInf.
X() +
Width();
849 const bool bFly = rInf.
GetFly() ||
875 else if ( nDiff > rInf.
X() )
884 if( nDiff > rInf.
Width() )
886 nDiff = rInf.
Width();
891 if(
Width() < nDiff )
937 aPos.AdjustX(nOffset );
943 aSize =
Size( nTmpH, nTmpH );
944 aPos.setY( rInf.
Y() - nTmpH );
946 SwRect aTmp( aPos, aSize );
965 pViewShell && pViewShell->
GetWin() )
973 else if ( pViewShell &&
985 *const_cast<OutputDevice*>(pOut), aPos, aSize,
m_nId);
1004 if( rFrame.IsVertical() )
1007 rFrame.SwitchHorizontalToVertical( aRepaint );
1010 if( rFrame.IsRightToLeft() )
1012 rFrame.SwitchLTRtoRTL( aTmp );
1013 rFrame.SwitchLTRtoRTL( aRepaint );
1032 if (
GetOrient() == text::VertOrientation::CENTER )
1034 else if (
GetOrient() == text::VertOrientation::TOP )
1036 else if (
GetOrient() == text::VertOrientation::BOTTOM )
1038 else if (
GetOrient() == text::VertOrientation::CHAR_CENTER )
1040 else if (
GetOrient() == text::VertOrientation::CHAR_TOP )
1042 else if (
GetOrient() == text::VertOrientation::CHAR_BOTTOM )
1052 else if (
GetOrient() == text::VertOrientation::LINE_CENTER )
1054 else if (
GetOrient() == text::VertOrientation::LINE_TOP )
1056 else if (
GetOrient() == text::VertOrientation::LINE_BOTTOM )
1063 OSL_ENSURE(
HasAnimation(),
"SwTextFrame::StopAnimation: Which Animation?" );
1074 static_cast<SwGrfNumPortion*>(pPor)->StopAnimation( pOut );
1103 for( sal_Int32
i = 0;
i < rText.getLength(); ++
i )
1130 OSL_ENSURE( nCount < 7,
"Too much combined characters" );
1133 const sal_Int32 nTop = ( nCount + 1 ) / 2;
1141 for( sal_Int32
i = 0 ;
i < nCount; ++
i )
1144 aOutPos.setY( aOldPos.Y() +
m_nLowPos );
1145 aOutPos.setX( aOldPos.X() +
m_aPos[
i] );
1147 aTmpFont.SetActual( nAct );
1153 Size aTmpSz = aTmpFont.GetSize( nAct );
1157 aTmpFont.SetSize( aTmpSz, nAct );
1177 OSL_ENSURE( nCount < 7,
"Too much combined characters" );
1188 OSL_ENSURE(
m_aScrType[
i] < SW_SCRIPTS,
"Combined: Script fault" );
1198 const sal_Int32 nTop = ( nCount + 1 ) / 2;
1205 sal_uInt16 nMaxDescent, nMaxAscent, nMaxWidth;
1208 nMainDescent = nMainDescent - nMainAscent;
1226 for( sal_Int32
i = 0;
i < nCount; ++
i )
1229 aTmpFont.SetActual( nScrp );
1232 Size aFontSize( aTmpFont.GetSize( nScrp ) );
1234 aTmpFont.SetSize( aFontSize, nScrp );
1238 Size aSize = aTmpFont.GetTextSize_( aDrawInf );
1239 const sal_uInt16 nAsc = aTmpFont.GetAscent( pSh, *rInf.
GetOut() );
1240 m_aPos[ i ] = o3tl::narrowing<sal_uInt16>(aSize.Width());
1244 Height( nMaxDescent + nMaxAscent );
1251 nMaxWidth = nMaxWidth +
m_aPos[ i ];
1252 if( nAsc > nMaxAscent )
1254 if( aSize.Height() - nAsc > nMaxDescent )
1255 nMaxDescent = aSize.Height() - nAsc;
1264 Height( nMaxAscent + nMaxDescent );
1280 if(
Height() < nMainAscent + nMainDescent )
1281 Height( nMainAscent + nMainDescent );
1284 sal_uInt16 nTopDiff = 0;
1285 sal_uInt16 nBotDiff = 0;
1286 if( nMaxWidth >
Width() )
1288 nTopDiff = ( nMaxWidth -
Width() ) / 2;
1292 nBotDiff = (
Width() - nMaxWidth ) / 2;
1304 case 3:
m_aPos[nTop] = nBotDiff;
break;
1307 case 4:
m_aPos[nTop] = 0;
1313 const bool bFull = rInf.
Width() < rInf.
X() +
Width();
1351 rInf.
CalcRect( *
this, &aPaintArea );
1369 rInf.
CalcRect( *
this, &aPaintArea );
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Fieldmark representing a date form field.
OutDevType GetOutDevType() const
SwFieldPortion(const SwFieldPortion &rField)
const sal_Unicode CH_BREAK
SwNumberPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFnt, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
Represents the visualization of a paragraph.
void StartAnimation(OutputDevice &rOutDev, const Point &rDestPt, const Size &rDestSize, tools::Long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
void DrawBackBrush(const SwLinePortion &rPor) const
bool IsGrfNumPortion() const
bool IsPagePreview() const
bool IsStopAnimatedGraphics() const
void StopAnimation(const OutputDevice *pOut)
void setWidth(tools::Long nWidth)
const SwAccessibilityOptions * GetAccessibilityOptions() const
SwTwips GetRelPos() const
void SetCenter(bool bNew)
virtual void Paint(const SwTextPaintInfo &rInf) const override
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout...
void dumpAsXmlAttributes(xmlTextWriterPtr writer, std::u16string_view rText, TextFrameIndex nOffset) const
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
TextFrameIndex GetUnderScorePos() 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...
TextFrameIndex ScanPortionEnd(TextFrameIndex nStart, TextFrameIndex nEnd)
sal_uInt16 GetTextHeight() const
SwParaPortion * GetPara()
void SetLen(TextFrameIndex const nLen)
std::unique_ptr< SwFont > m_pFont
void DrawText(const OUString &rText, const SwLinePortion &rPor, TextFrameIndex nIdx=TextFrameIndex(0), TextFrameIndex nLen=TextFrameIndex(COMPLETE_STRING), const bool bKern=false) const
void SetAnimation() const
void NoteAnimation() const
FontStrikeout GetStrikeout() const
Of course Writer needs its own rectangles.
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
void SetPortionPaintAreaEnd(const SwRect &rPortionPaintArea)
SwPosSize GetTextSize(OutputDevice *pOut, const SwScriptInfo *pSI, const OUString &rText, TextFrameIndex nIdx, TextFrameIndex nLen) const
sal_uInt8 DirType(const TextFrameIndex nPos) const
sal_uInt16 ForcedLeftMargin() const
void SetHookChar(const sal_Unicode cNew)
virtual SwLinePortion * Compress()
virtual ~SwFieldPortion() override
constexpr tools::Long Width() const
#define CH_TXTATR_BREAKWORD
SwTwips GetGrfHeight() const
virtual ~SwGrfNumPortion() override
void SetFollow(bool bNew)
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
void SetHasFollow(bool bNew)
o3tl::enumarray< SwFontScript, sal_uInt16 > m_aWidth
void DrawViewOpt(const SwLinePortion &rPor, PortionType nWhich, const Color *pColor=nullptr) const
FontMetric GetFontMetric() const
const Graphic * GetGraphic(OUString const &referer=OUString()) const
virtual bool Format(SwTextFormatInfo &rInf) override
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
TextFrameIndex GetLineStart() const
SwFontScript m_aScrType[6]
sal_Int16 GetOrient() const
SwFontScript GetActual() 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...
void SetNumDone(const bool bNew)
virtual void Special(TextFrameIndex nLength, const OUString &rText, PortionType nType, sal_Int32 nHeight=0, sal_Int32 nWidth=0, const SwFont *pFont=nullptr)=0
special portion.
SwCombinedPortion(const OUString &rExpand)
Initializes the script array and clears the width array.
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 CheckScript(const SwTextSizeInfo &rInf)
const SwViewOption & GetOpt() const
SwTextNode const * GetTextNodeForParaProps() const
virtual void Paint(const SwTextPaintInfo &rInf) const override
void SetAnimated(bool bNew)
bool IsFootnoteNumPortion() const
void SetRelPos(SwTwips nNew)
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Collection of SwLinePortion instances, representing one line of text.
const Point & GetPos() const
void TakeNextOffset(const SwFieldPortion *pField)
vcl::RenderContext * GetOut()
TextFrameIndex m_nNextOffset
SwParaPortion * GetParaPortion()
void SetWhichPor(const PortionType nNew)
bool IsFlyPortion() const
FontLineStyle GetOverline() const
bool IsNumberPortion() const
TextFrameIndex GetFieldLen() const
sal_uInt16 GetTopBorderSpace() 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)
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
void CalcRect(const SwLinePortion &rPor, SwRect *pRect, SwRect *pIntersect=nullptr, const bool bInsideBox=false) const
Calculate the rectangular area where the portion takes place.
std::unique_ptr< SvxBrushItem > m_pBrush
const Size & GetFontSize() const
TextFrameIndex m_nNextScriptChg
void SetUnderScorePos(TextFrameIndex const nNew)
TextFrameIndex GetIdx() const
virtual SwLinePortion * Compress() override
virtual bool Format(SwTextFormatInfo &rInf) override
virtual void HandlePortion(SwPortionHandler &rPH) const override
void SetPortionPaintAreaStart(const SwRect &rPortionPaintArea)
void PrePaint(const SwTextPaintInfo &rInf, const SwLinePortion *pLast) const
bool mbLabelAlignmentPosAndSpaceModeActive
static bool IsFieldShadings()
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
TextFrameIndex GetLen() const
void SetPos(const Point &rPoint)
SwHiddenPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFntL=nullptr)
SwTextFrame * GetTextFrame()
void InvalidateWindows(const SwRect &rRect)
const OUString & GetText() const
TextFrameIndex m_nFieldLen
void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &nOffset) const override
const SwLinePortion * GetUnderflow() const
void SetId(tools::Long nNew) const
SwUnderlineFont * GetUnderFnt() const
SwLinePortion * mpNextPortion
const Point & GetPos() const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
FontLineStyle GetUnderline() const
Base class for anything that can be part of a line in the Writer layout.
virtual void FormatEOL(SwTextFormatInfo &rInf) override
A FormatEOL indicates that the subsequent text did not fit onto the line anymore. ...
virtual bool Format(SwTextFormatInfo &rInf) override
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
void SetLen(const TextFrameIndex nNew)
For the text replacement and restoration of SwTextSizeInfo.
constexpr tools::Long Height() const
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
PortionType GetWhichPor() const
bool IsFootnotePortion() const
vcl::Window * GetWin() const
void SetFont(const vcl::Font &rNewFont)
SwLinePortion * GetRest()
void StopAnimation(const OutputDevice *pOut)
Stops the animations within numberings.
IDocumentSettingAccess const & getIDocumentSettingAccess() const
bool IsRightToLeft() const
TextFrameIndex GetLen() const
sal_uInt16 GetBottomBorderSpace() const
const SwFont * GetFont() const
void SetFont(std::unique_ptr< SwFont > pNew)
void SetBase(tools::Long nLnAscent, tools::Long nLnDescent, tools::Long nFlyAscent, tools::Long nFlyDescent)
void SetLineStart(TextFrameIndex const nNew)
bool HasAnimation() const
void SetPortionPaintArea(const SwRect &rPortionPaintArea)
SwScriptInfo & GetScriptInfo()
SwLinePortion * GetLast()
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
virtual void Paint(const SwTextPaintInfo &rInf) const override
constexpr sal_Int32 COMPLETE_STRING
virtual void Paint(const SwTextPaintInfo &rInf) const override
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
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...
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
void StopAnimation(const OutputDevice *pOutputDevice, tools::Long nExtraData)
void SetNextOffset(TextFrameIndex nNew)
#define SAL_WARN(area, stream)
struct _xmlTextWriter * xmlTextWriterPtr
const SwRect & GetPaintRect() const
virtual SwFieldPortion * Clone(const OUString &rExpand) const
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
bool IsWordLineMode() const
sal_uInt8 GetDefaultDir() const
virtual void FormatEOL(SwTextFormatInfo &rInf)
bool IsQuoVadisPortion() const
void SetProportion(const sal_uInt8 nNewPropr)
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...
SwLinePortion * GetNextPortion() const
const bool m_bPlaceHolder
SwViewShell * GetCurrShell() const
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 SetRest(SwLinePortion *pNewRest)
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
TextFrameIndex GetNextOffset() const
bool Overlaps(const SwRect &rRect) const
Fieldmark representing a drop-down form field.
tools::Long GetHeight() const
SwRootFrame * getRootFrame()
const SvxFont & GetFnt(const SwFontScript nWhich) const
sal_uInt16 GetAscent() const
bool m_bDetectedRangeSegmentation false
bool IsShowPlaceHolderFields() const
void SetAscent(const SwTwips nNewAsc)
void SetNotEOL(const bool bNew)