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>
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)
78 , m_bFollow( false ), m_bLeft( false), m_bHide( false)
79 , m_bCenter (false), m_bHasFollow( false )
80 , m_bAnimated( false), m_bNoPaint( false)
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<vcl::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() );
181 aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText);
183 pInf->SetText( aText );
186 SwFieldSlot::~SwFieldSlot()
190 pInf->SetCachedVclData(m_pOldCachedVclData);
191 pInf->SetText( *pOldText );
192 pInf->SetIdx( nIdx );
193 pInf->SetLen( nLen );
194 pInf->SetFakeLineStart(
false );
201 if (!
GetExpText(rInf, aText) || aText.isEmpty())
207 if( i18n::ScriptType::WEAK == nScript )
210 if (nChg < aText.getLength() && nChg >= 0)
216 if (nChg < aText.getLength() && nChg >= 0)
227 default: nTmp = nActual;
238 UErrorCode nError = U_ZERO_ERROR;
239 UBiDi* pBidi = ubidi_openSized( aText.getLength(), 0, &nError );
240 ubidi_setPara( pBidi, reinterpret_cast<const UChar *>(aText.getStr()), aText.getLength(), nFieldDir,
nullptr, &nError );
243 ubidi_getLogicalRun( pBidi, 0, &nEnd, &nCurrDir );
244 ubidi_close( pBidi );
250 if (nCurrDir != UBIDI_RTL &&
251 (UBIDI_LTR != nFieldDir || i18n::ScriptType::COMPLEX == nScript))
253 nCurrDir = UBIDI_RTL;
254 for( sal_Int32 nCharIdx = 0; nCharIdx < nEnd; ++nCharIdx )
256 UCharDirection nCharDir = u_charDirection ( aText[ nCharIdx ]);
257 if ( nCharDir == U_LEFT_TO_RIGHT ||
258 nCharDir == U_LEFT_TO_RIGHT_EMBEDDING ||
259 nCharDir == U_LEFT_TO_RIGHT_OVERRIDE )
261 nCurrDir = UBIDI_LTR;
267 if (nCurrDir == UBIDI_RTL)
273 if (nScript == i18n::ScriptType::COMPLEX)
286 else if ( nTmp != nActual )
303 SwFieldSlot aDiffText( &rInf,
this );
348 rInf.
SetNotEOL( nFullLen == nOldFullLen && nTextRest > nFollow );
362 bEOL = !nTmpLen && nFollow && bFull;
363 nRest = nOldFullLen - nTmpLen;
376 nNextOfst = nNextOfst +
TextFrameIndex(static_cast<SwQuoVadisPortion*>(
this)->GetContText().getLength());
378 OUString aNew(
m_aExpand.copy(sal_Int32(nNextOfst)) );
379 m_aExpand = m_aExpand.copy(0, sal_Int32(nNextOfst));
383 const sal_Unicode nNew = !aNew.isEmpty() ? aNew[0] : 0;
398 aNew = aNew.copy( 1 );
409 if( !aNew.isEmpty() && !pField->
GetFont() )
447 if( rText.isEmpty() && rInf.
OnWin() &&
476 std::unique_ptr<SwFont> pNewFnt;
499 std::unique_ptr<SwFont> pFont,
502 const sal_uInt16 nMinDst,
503 const bool bLabelAlignmentPosAndSpaceModeActive )
507 mbLabelAlignmentPosAndSpaceModeActive( bLabelAlignmentPosAndSpaceModeActive )
522 std::unique_ptr<SwFont> pNewFnt;
547 OSL_ENSURE(
Height() &&
mnAscent,
"NumberPortions without Height | Ascent" );
559 GetSwAttrSet().GetLRSpace().GetTextFirstLineOffset()
572 else if ( nDiff > rInf.
X() )
584 const bool bFly = rInf.
GetFly() ||
586 if( nDiff > rInf.
Width() )
588 nDiff = rInf.
Width();
598 Height( sal_uInt16( nDiff ) );
600 else if(
Width() < nDiff )
601 Width( sal_uInt16(nDiff) );
639 const sal_uInt16 nOldWidth =
Width();
640 sal_uInt16 nSumWidth = 0;
641 sal_uInt16 nOffset = 0;
646 nSumWidth = nSumWidth + pTmp->
Width();
647 if ( static_cast<const SwNumberPortion*>(pTmp)->
HasFollow() )
661 pThis->
Width( nSumWidth );
663 pThis->
Width( nOldWidth );
688 bPaintSpace = bPaintSpace &&
nFixWidth < nOldWidth;
705 sal_uInt16 nTmpOffset = nOffset;
713 aInf.
X( aInf.
X() + nOffset );
716 nSpaceOffs = nSpaceOffs + nOffset;
718 if( bPaintSpace && nOldWidth > nSpaceOffs )
721 aInf.
X( aInf.
X() + nSpaceOffs );
730 pThis->
Width( nOldWidth - nSpaceOffs + 12 );
732 SwTextSlot aDiffText( &aInf,
this,
true,
false,
" " );
736 pThis->
Width( nOldWidth );
741 std::u16string_view rBulletFollowedBy,
742 std::unique_ptr<SwFont> pFont,
745 const sal_uInt16 nMinDst,
746 const bool bLabelAlignmentPosAndSpaceModeActive )
748 std::move(pFont), bLft, bCntr, nMinDst,
749 bLabelAlignmentPosAndSpaceModeActive )
754 #define GRFNUM_SECURE 10
757 const OUString& rGraphicFollowedBy,
758 const SvxBrushItem* pGrfBrush, OUString
const & referer,
760 const bool bLft,
const bool bCntr,
const sal_uInt16 nMinDst,
761 const bool bLabelAlignmentPosAndSpaceModeActive ) :
763 bLabelAlignmentPosAndSpaceModeActive ),
786 eOrient = text::VertOrientation::TOP;
820 sal_uInt16 nFollowedByWidth( 0 );
824 nFollowedByWidth =
Width();
828 const bool bFull = rInf.
Width() < rInf.
X() +
Width();
829 const bool bFly = rInf.
GetFly() ||
837 Width( rInf.
Width() -
static_cast<sal_uInt16
>(rInf.
X()) );
855 else if ( nDiff > rInf.
X() )
864 if( nDiff > rInf.
Width() )
866 nDiff = rInf.
Width();
871 if(
Width() < nDiff )
872 Width( sal_uInt16(nDiff) );
917 aPos.AdjustX(nOffset );
923 aSize =
Size( nTmpH, nTmpH );
924 aPos.setY( rInf.
Y() - nTmpH );
926 SwRect aTmp( aPos, aSize );
945 pViewShell && pViewShell->
GetWin() )
953 else if ( pViewShell &&
963 const_cast<OutputDevice*>(rInf.
GetOut()), aPos, aSize,
nId );
982 if( rFrame.IsVertical() )
985 rFrame.SwitchHorizontalToVertical( aRepaint );
988 if( rFrame.IsRightToLeft() )
990 rFrame.SwitchLTRtoRTL( aTmp );
991 rFrame.SwitchLTRtoRTL( aRepaint );
1008 if (
GetOrient() == text::VertOrientation::CENTER )
1010 else if (
GetOrient() == text::VertOrientation::TOP )
1012 else if (
GetOrient() == text::VertOrientation::BOTTOM )
1014 else if (
GetOrient() == text::VertOrientation::CHAR_CENTER )
1016 else if (
GetOrient() == text::VertOrientation::CHAR_TOP )
1018 else if (
GetOrient() == text::VertOrientation::CHAR_BOTTOM )
1028 else if (
GetOrient() == text::VertOrientation::LINE_CENTER )
1030 else if (
GetOrient() == text::VertOrientation::LINE_TOP )
1032 else if (
GetOrient() == text::VertOrientation::LINE_BOTTOM )
1039 OSL_ENSURE(
HasAnimation(),
"SwTextFrame::StopAnimation: Which Animation?" );
1050 static_cast<SwGrfNumPortion*>(pPor)->StopAnimation( pOut );
1079 for( sal_Int32
i = 0;
i < rText.getLength(); ++
i )
1106 OSL_ENSURE( nCount < 7,
"Too much combined characters" );
1109 const sal_Int32 nTop = ( nCount + 1 ) / 2;
1116 Point aOutPos( aOldPos.X(), aOldPos.Y() -
nUpPos );
1117 for( sal_Int32
i = 0 ;
i < nCount; ++
i )
1120 aOutPos.setY( aOldPos.Y() +
nLowPos );
1121 aOutPos.setX( aOldPos.X() +
aPos[
i] );
1123 aTmpFont.SetActual( nAct );
1129 Size aTmpSz = aTmpFont.GetSize( nAct );
1133 aTmpFont.SetSize( aTmpSz, nAct );
1153 OSL_ENSURE( nCount < 7,
"Too much combined characters" );
1164 OSL_ENSURE(
aScrType[
i] < SW_SCRIPTS,
"Combined: Script fault" );
1174 const sal_Int32 nTop = ( nCount + 1 ) / 2;
1181 sal_uInt16 nMaxDescent, nMaxAscent, nMaxWidth;
1184 nMainDescent = nMainDescent - nMainAscent;
1202 for( sal_Int32
i = 0;
i < nCount; ++
i )
1205 aTmpFont.SetActual( nScrp );
1208 Size aFontSize( aTmpFont.GetSize( nScrp ) );
1210 aTmpFont.SetSize( aFontSize, nScrp );
1214 Size aSize = aTmpFont.GetTextSize_( aDrawInf );
1215 const sal_uInt16 nAsc = aTmpFont.GetAscent( pSh, *rInf.
GetOut() );
1216 aPos[ i ] =
static_cast<sal_uInt16
>(aSize.Width());
1220 Height( nMaxDescent + nMaxAscent );
1227 nMaxWidth = nMaxWidth +
aPos[ i ];
1228 if( nAsc > nMaxAscent )
1230 if( aSize.Height() - nAsc > nMaxDescent )
1231 nMaxDescent = static_cast<sal_uInt16>(aSize.Height() - nAsc);
1240 Height( nMaxAscent + nMaxDescent );
1256 if(
Height() < nMainAscent + nMainDescent )
1257 Height( nMainAscent + nMainDescent );
1260 sal_uInt16 nTopDiff = 0;
1261 sal_uInt16 nBotDiff = 0;
1262 if( nMaxWidth >
Width() )
1264 nTopDiff = ( nMaxWidth -
Width() ) / 2;
1268 nBotDiff = (
Width() - nMaxWidth ) / 2;
1271 case 3:
aPos[1] =
aPos[0] + nTopDiff;
1278 case 5:
aPos[4] =
aPos[3] + nBotDiff;
1280 case 3:
aPos[nTop] = nBotDiff;
break;
1281 case 6:
aPos[4] =
aPos[3] + nBotDiff;
1283 case 4:
aPos[nTop] = 0;
1289 const bool bFull = rInf.
Width() < rInf.
X() +
Width();
1294 Width( static_cast<sal_uInt16>( rInf.
Width() - rInf.
X() ) );
1327 rInf.
CalcRect( *
this, &aPaintArea );
1345 rInf.
CalcRect( *
this, &aPaintArea );
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 DrawBackBrush(const SwLinePortion &rPor) const
bool IsGrfNumPortion() const
bool IsPagePreview() const
bool IsStopAnimatedGraphics() const
void StopAnimation(const OutputDevice *pOut)
void setWidth(tools::Long nWidth)
sal_uInt16 Height() const
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...
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
std::unique_ptr< SvxBrushItem > pBrush
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
#define CH_TXTATR_BREAKWORD
SwTwips GetGrfHeight() const
virtual ~SwGrfNumPortion() override
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SetFollow(bool bNew)
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
void SetHasFollow(bool bNew)
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
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
tools::Long Width() 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.
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
const SwLinePortion * GetUnderflow() const
void SetId(tools::Long nNew) const
SwUnderlineFont * GetUnderFnt() const
SwLinePortion * mpNextPortion
void StartAnimation(OutputDevice *pOutDev, const Point &rDestPt, const Size &rDestSize, tools::Long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
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.
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
tools::Long Height() const
sal_uInt16 GetBottomBorderSpace() const
const SwFont * GetFont() const
o3tl::enumarray< SwFontScript, sal_uInt16 > aWidth
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
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 SetAscent(const sal_uInt16 nNewAsc)
void StopAnimation(const OutputDevice *pOutputDevice, tools::Long nExtraData)
void SetNextOffset(TextFrameIndex nNew)
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)
bool IsOver(const SwRect &rRect) const
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
Fieldmark representing a drop-down form field.
tools::Long GetHeight() const
const sal_Int32 COMPLETE_STRING
SwRootFrame * getRootFrame()
void DrawViewOpt(const SwLinePortion &rPor, PortionType nWhich) const
const SvxFont & GetFnt(const SwFontScript nWhich) const
sal_uInt16 GetAscent() const
bool IsShowPlaceHolderFields() const
void SetNotEOL(const bool bNew)