CairoSDPR: Simplify EditEngine text decomposition
The EditEngine decomposes it's content mainly to Prmitives (there is still a direct paint mode used in rare remaining cases which we not yet got rid of). For TABs the special case for 'extended' TABs (see format/paragraph/Tabs, FillCharacter) was handed through all layers using method DrawingTab, put into a DrawPortionInfo and held at the text primitive (TextSimplePortionPrimitive2D). While for direct paint the expansion was already done in ImpEditEngine::Paint anyways (and always painted, independent from bStripOnly what was unneccessary and I corrected that, too) it had to be done for text paint in VclProcessor2D for each repaint. This is not needed, so now the extended text created in EditEngine decompose gets used. This makes a lot of stuff simpler, including EditEngine/Outliner and some involved classes. If it somehow should show that it might be necessary to do that for each paint it should be done in the obvious way then - using an own primitive that creates the expansin in the decomposition (and buffers it). Change-Id: Ieb02219142af8f6bee01dcd658e08b185a4212cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171380 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
This commit is contained in:
committed by
Armin Le Grand
parent
4726058aa5
commit
af014d1b5d
@@ -338,7 +338,17 @@ namespace drawinglayer::primitive2d
|
||||
bool bEmphasisMarkBelow,
|
||||
TextRelief eTextRelief,
|
||||
bool bShadow)
|
||||
: TextSimplePortionPrimitive2D(rNewTransform, rText, nTextPosition, nTextLength, std::move(rDXArray), std::move(rKashidaArray), rFontAttribute, rLocale, rFontColor, false, 0, rFillColor),
|
||||
: TextSimplePortionPrimitive2D(
|
||||
rNewTransform,
|
||||
rText,
|
||||
nTextPosition,
|
||||
nTextLength,
|
||||
std::move(rDXArray),
|
||||
std::move(rKashidaArray),
|
||||
rFontAttribute,
|
||||
rLocale,
|
||||
rFontColor,
|
||||
rFillColor),
|
||||
maOverlineColor(rOverlineColor),
|
||||
maTextlineColor(rTextlineColor),
|
||||
meFontOverline(eFontOverline),
|
||||
|
||||
@@ -203,8 +203,7 @@ TextSimplePortionPrimitive2D::TextSimplePortionPrimitive2D(
|
||||
basegfx::B2DHomMatrix rNewTransform, OUString rText, sal_Int32 nTextPosition,
|
||||
sal_Int32 nTextLength, std::vector<double>&& rDXArray, std::vector<sal_Bool>&& rKashidaArray,
|
||||
attribute::FontAttribute aFontAttribute, css::lang::Locale aLocale,
|
||||
const basegfx::BColor& rFontColor, bool bFilled, tools::Long nWidthToFill,
|
||||
const Color& rTextFillColor)
|
||||
const basegfx::BColor& rFontColor, const Color& rTextFillColor)
|
||||
: maTextTransform(std::move(rNewTransform))
|
||||
, maText(std::move(rText))
|
||||
, mnTextPosition(nTextPosition)
|
||||
@@ -214,8 +213,6 @@ TextSimplePortionPrimitive2D::TextSimplePortionPrimitive2D(
|
||||
, maFontAttribute(std::move(aFontAttribute))
|
||||
, maLocale(std::move(aLocale))
|
||||
, maFontColor(rFontColor)
|
||||
, mbFilled(bFilled)
|
||||
, mnWidthToFill(nWidthToFill)
|
||||
, maTextFillColor(rTextFillColor)
|
||||
{
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
@@ -245,8 +242,7 @@ bool TextSimplePortionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive)
|
||||
&& getKashidaArray() == rCompare.getKashidaArray()
|
||||
&& getFontAttribute() == rCompare.getFontAttribute()
|
||||
&& LocalesAreEqual(getLocale(), rCompare.getLocale())
|
||||
&& getFontColor() == rCompare.getFontColor() && mbFilled == rCompare.mbFilled
|
||||
&& mnWidthToFill == rCompare.mnWidthToFill
|
||||
&& getFontColor() == rCompare.getFontColor()
|
||||
&& maTextFillColor == rCompare.maTextFillColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -336,37 +336,6 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
|
||||
mpOutputDevice->SetLayoutMode(nLTRLayoutMode);
|
||||
}
|
||||
|
||||
OUString aText(rTextCandidate.getText());
|
||||
sal_Int32 nPos = rTextCandidate.getTextPosition();
|
||||
sal_Int32 nLen = rTextCandidate.getTextLength();
|
||||
|
||||
// this contraption is used in editeng, with format paragraph used to
|
||||
// set a tab with a tab-fill character
|
||||
if (rTextCandidate.isFilled())
|
||||
{
|
||||
tools::Long nWidthToFill = rTextCandidate.getWidthToFill();
|
||||
|
||||
tools::Long nWidth = basegfx::fround<tools::Long>(
|
||||
mpOutputDevice->GetTextArray(rTextCandidate.getText(), &aDXArray, 0, 1).nWidth);
|
||||
sal_Int32 nChars = 2;
|
||||
if (nWidth)
|
||||
nChars = nWidthToFill / nWidth;
|
||||
|
||||
OUStringBuffer aFilled(nChars);
|
||||
comphelper::string::padToLength(aFilled, nChars, aText[0]);
|
||||
aText = aFilled.makeStringAndClear();
|
||||
nPos = 0;
|
||||
nLen = nChars;
|
||||
|
||||
if (!aDXArray.empty())
|
||||
{
|
||||
sal_Int32 nDX = aDXArray[0];
|
||||
aDXArray.resize(nLen);
|
||||
for (sal_Int32 i = 1; i < nLen; ++i)
|
||||
aDXArray.set(i, aDXArray[i - 1] + nDX);
|
||||
}
|
||||
}
|
||||
|
||||
Point aStartPoint;
|
||||
bool bChangeMapMode(false);
|
||||
if (!bScaleFont)
|
||||
@@ -468,14 +437,18 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
|
||||
if (!aDXArray.empty())
|
||||
{
|
||||
const SalLayoutGlyphs* pGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(
|
||||
mpOutputDevice, aText, nPos, nLen);
|
||||
mpOutputDevice->DrawTextArray(aStartPoint, aText, aDXArray,
|
||||
rTextCandidate.getKashidaArray(), nPos, nLen,
|
||||
SalLayoutFlags::NONE, pGlyphs);
|
||||
mpOutputDevice, rTextCandidate.getText(), rTextCandidate.getTextPosition(),
|
||||
rTextCandidate.getTextLength());
|
||||
mpOutputDevice->DrawTextArray(
|
||||
aStartPoint, rTextCandidate.getText(), aDXArray,
|
||||
rTextCandidate.getKashidaArray(), rTextCandidate.getTextPosition(),
|
||||
rTextCandidate.getTextLength(), SalLayoutFlags::NONE, pGlyphs);
|
||||
}
|
||||
else
|
||||
{
|
||||
mpOutputDevice->DrawText(aStartPoint, aText, nPos, nLen);
|
||||
mpOutputDevice->DrawText(aStartPoint, rTextCandidate.getText(),
|
||||
rTextCandidate.getTextPosition(),
|
||||
rTextCandidate.getTextLength());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,14 +57,6 @@ public:
|
||||
const Color& rOverlineColor,
|
||||
const Color& rTextLineColor) override;
|
||||
|
||||
virtual void DrawingTab(
|
||||
const Point& rStartPos, tools::Long nWidth, const OUString& rChar,
|
||||
const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
|
||||
bool bEndOfLine,
|
||||
bool bEndOfParagraph,
|
||||
const Color& rOverlineColor,
|
||||
const Color& rTextLineColor) override;
|
||||
|
||||
virtual void StyleSheetChanged( SfxStyleSheet* pStyle ) override;
|
||||
virtual void ParaAttribsChanged( sal_Int32 nPara ) override;
|
||||
virtual bool SpellNextDocument() override;
|
||||
|
||||
@@ -1590,14 +1590,6 @@ void EditEngine::DrawingText( const Point&, const OUString&, sal_Int32, sal_Int3
|
||||
{
|
||||
}
|
||||
|
||||
void EditEngine::DrawingTab( const Point& /*rStartPos*/, tools::Long /*nWidth*/,
|
||||
const OUString& /*rChar*/, const SvxFont& /*rFont*/,
|
||||
sal_Int32 /*nPara*/, sal_uInt8 /*nRightToLeft*/, bool /*bEndOfLine*/,
|
||||
bool /*bEndOfParagraph*/, const Color& /*rOverlineColor*/,
|
||||
const Color& /*rTextLineColor*/)
|
||||
{
|
||||
}
|
||||
|
||||
void EditEngine::PaintingFirstLine(sal_Int32, const Point&, const Point&, Degree10, OutputDevice&)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4182,6 +4182,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
{
|
||||
if ( rTextPortion.GetExtraValue() && ( rTextPortion.GetExtraValue() != ' ' ) )
|
||||
{
|
||||
// calculate expanded text
|
||||
SeekCursor(rParaPortion.GetNode(), nIndex+1, aTmpFont, &rOutDev);
|
||||
aTmpFont.SetTransparent( false );
|
||||
aTmpFont.SetEscapement( 0 );
|
||||
@@ -4196,11 +4197,10 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
else if ( nChars == 2 )
|
||||
nChars = 3; // looks better
|
||||
|
||||
// create expanded text
|
||||
OUStringBuffer aBuf(nChars);
|
||||
comphelper::string::padToLength(aBuf, nChars, rTextPortion.GetExtraValue());
|
||||
OUString aText(aBuf.makeStringAndClear());
|
||||
aTmpFont.QuickDrawText( &rOutDev, aTmpPos, aText, 0, aText.getLength(), {} );
|
||||
rOutDev.DrawStretchText( aTmpPos, rTextPortion.GetSize().Width(), aText );
|
||||
|
||||
if ( bStripOnly )
|
||||
{
|
||||
@@ -4212,12 +4212,21 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
const Color aTextLineColor(rOutDev.GetTextLineColor());
|
||||
|
||||
// StripPortions() data callback
|
||||
GetEditEnginePtr()->DrawingTab( aTmpPos,
|
||||
rTextPortion.GetSize().Width(),
|
||||
OUString(rTextPortion.GetExtraValue()),
|
||||
aTmpFont, nParaPortion, rTextPortion.GetRightToLeftLevel(),
|
||||
GetEditEnginePtr()->DrawingText(
|
||||
aTmpPos, aText, 0, aText.getLength(), {}, {},
|
||||
aTmpFont, nParaPortion, 0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
bEndOfLine, bEndOfParagraph,
|
||||
aOverlineColor, aTextLineColor);
|
||||
nullptr,
|
||||
aOverlineColor,
|
||||
aTextLineColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// direct paint needed
|
||||
aTmpFont.QuickDrawText( &rOutDev, aTmpPos, aText, 0, aText.getLength(), {} );
|
||||
rOutDev.DrawStretchText( aTmpPos, rTextPortion.GetSize().Width(), aText );
|
||||
}
|
||||
}
|
||||
else if ( bStripOnly )
|
||||
|
||||
@@ -165,15 +165,6 @@ void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText
|
||||
pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, false/*bEndOfBullet*/, pLocale, rOverlineColor, rTextLineColor);
|
||||
}
|
||||
|
||||
void OutlinerEditEng::DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUString& rChar,
|
||||
const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
|
||||
bool bEndOfLine, bool bEndOfParagraph,
|
||||
const Color& rOverlineColor, const Color& rTextLineColor)
|
||||
{
|
||||
pOwner->DrawingTab(rStartPos, nWidth, rChar, rFont, nPara, nRightToLeft,
|
||||
bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
|
||||
}
|
||||
|
||||
OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor, std::optional<FontLineStyle>& rpFldLineStyle )
|
||||
{
|
||||
return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor, rpFldLineStyle );
|
||||
|
||||
@@ -1659,20 +1659,8 @@ void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_I
|
||||
if(aDrawPortionHdl.IsSet())
|
||||
{
|
||||
DrawPortionInfo aInfo( rStartPos, rText, nTextStart, nTextLen, rFont, nPara, pDXArray, pKashidaArray, pWrongSpellVector,
|
||||
pFieldData, pLocale, rOverlineColor, rTextLineColor, nRightToLeft, false, 0, bEndOfLine, bEndOfParagraph, bEndOfBullet);
|
||||
|
||||
aDrawPortionHdl.Call( &aInfo );
|
||||
}
|
||||
}
|
||||
|
||||
void Outliner::DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUString& rChar, const SvxFont& rFont,
|
||||
sal_Int32 nPara, sal_uInt8 nRightToLeft, bool bEndOfLine, bool bEndOfParagraph,
|
||||
const Color& rOverlineColor, const Color& rTextLineColor)
|
||||
{
|
||||
if(aDrawPortionHdl.IsSet())
|
||||
{
|
||||
DrawPortionInfo aInfo( rStartPos, rChar, 0, rChar.getLength(), rFont, nPara, {}, {}, nullptr,
|
||||
nullptr, nullptr, rOverlineColor, rTextLineColor, nRightToLeft, true, nWidth, bEndOfLine, bEndOfParagraph, false);
|
||||
pFieldData, pLocale, rOverlineColor, rTextLineColor, nRightToLeft,
|
||||
bEndOfLine, bEndOfParagraph, bEndOfBullet);
|
||||
|
||||
aDrawPortionHdl.Call( &aInfo );
|
||||
}
|
||||
|
||||
@@ -122,12 +122,6 @@ private:
|
||||
/// font color
|
||||
basegfx::BColor maFontColor;
|
||||
|
||||
// Whether to fill a given width with the text
|
||||
bool mbFilled;
|
||||
|
||||
// the width to fill
|
||||
tools::Long mnWidthToFill;
|
||||
|
||||
/// The fill color of the text
|
||||
Color maTextFillColor;
|
||||
|
||||
@@ -146,8 +140,7 @@ public:
|
||||
std::vector<double>&& rDXArray,
|
||||
std::vector<sal_Bool>&& rKashidaArray,
|
||||
attribute::FontAttribute aFontAttribute, css::lang::Locale aLocale,
|
||||
const basegfx::BColor& rFontColor, bool bFilled = false,
|
||||
tools::Long nWidthToFill = 0,
|
||||
const basegfx::BColor& rFontColor,
|
||||
const Color& rTextFillColor = COL_TRANSPARENT);
|
||||
|
||||
/** get text outlines as polygons and their according ObjectTransformation. Handles all
|
||||
@@ -167,8 +160,6 @@ public:
|
||||
const css::lang::Locale& getLocale() const { return maLocale; }
|
||||
const basegfx::BColor& getFontColor() const { return maFontColor; }
|
||||
const Color& getTextFillColor() const { return maTextFillColor; }
|
||||
bool isFilled() const { return mbFilled; }
|
||||
tools::Long getWidthToFill() const { return mnWidthToFill; }
|
||||
|
||||
/// compare operator
|
||||
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
|
||||
|
||||
@@ -510,12 +510,6 @@ public:
|
||||
const Color& rOverlineColor,
|
||||
const Color& rTextLineColor);
|
||||
|
||||
virtual void DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUString& rChar,
|
||||
const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
|
||||
bool bEndOfLine,
|
||||
bool bEndOfParagraph,
|
||||
const Color& rOverlineColor,
|
||||
const Color& rTextLineColor);
|
||||
virtual OUString GetUndoComment( sal_uInt16 nUndoId ) const;
|
||||
virtual bool SpellNextDocument();
|
||||
/** @return true, when click was consumed. false otherwise. */
|
||||
|
||||
@@ -418,9 +418,6 @@ public:
|
||||
|
||||
sal_uInt8 mnBiDiLevel;
|
||||
|
||||
bool mbFilled;
|
||||
tools::Long mnWidthToFill;
|
||||
|
||||
bool mbEndOfLine : 1;
|
||||
bool mbEndOfParagraph : 1;
|
||||
bool mbEndOfBullet : 1;
|
||||
@@ -442,8 +439,6 @@ public:
|
||||
const Color& rOverlineColor,
|
||||
const Color& rTextLineColor,
|
||||
sal_uInt8 nBiDiLevel,
|
||||
bool bFilled,
|
||||
tools::Long nWidthToFill,
|
||||
bool bEndOfLine,
|
||||
bool bEndOfParagraph,
|
||||
bool bEndOfBullet)
|
||||
@@ -461,8 +456,6 @@ public:
|
||||
maOverlineColor(rOverlineColor),
|
||||
maTextLineColor(rTextLineColor),
|
||||
mnBiDiLevel(nBiDiLevel),
|
||||
mbFilled( bFilled ),
|
||||
mnWidthToFill( nWidthToFill ),
|
||||
mbEndOfLine(bEndOfLine),
|
||||
mbEndOfParagraph(bEndOfParagraph),
|
||||
mbEndOfBullet(bEndOfBullet)
|
||||
@@ -844,13 +837,6 @@ public:
|
||||
const Color& rOverlineColor,
|
||||
const Color& rTextLineColor);
|
||||
|
||||
SAL_DLLPRIVATE void DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUString& rChar,
|
||||
const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
|
||||
bool bEndOfLine,
|
||||
bool bEndOfParagraph,
|
||||
const Color& rOverlineColor,
|
||||
const Color& rTextLineColor);
|
||||
|
||||
Size CalcTextSize();
|
||||
|
||||
void SetStyleSheetPool( SfxStyleSheetPool* pSPool );
|
||||
|
||||
@@ -211,7 +211,8 @@ namespace
|
||||
nullptr, /* no spelling in subportion, handled outside */
|
||||
nullptr, /* no field in subportion, handled outside */
|
||||
m_rInfo.mpLocale, m_rInfo.maOverlineColor, m_rInfo.maTextLineColor,
|
||||
m_rInfo.mnBiDiLevel, false, 0, false, false, false);
|
||||
m_rInfo.mnBiDiLevel,
|
||||
false, false, false);
|
||||
|
||||
m_rHandler.impCreateTextPortionPrimitive(aInfo);
|
||||
|
||||
@@ -590,8 +591,6 @@ namespace
|
||||
rFontAttribute,
|
||||
rInfo.mpLocale ? *rInfo.mpLocale : css::lang::Locale(),
|
||||
aBFontColor,
|
||||
rInfo.mbFilled,
|
||||
rInfo.mnWidthToFill,
|
||||
aTextFillColor);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user