drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx |   12 ++
 drawinglayer/source/primitive2d/textprimitive2d.cxx          |    8 -
 drawinglayer/source/processor2d/vclprocessor2d.cxx           |   45 ++---------
 editeng/inc/outleeng.hxx                                     |    8 -
 editeng/source/editeng/editeng.cxx                           |    8 -
 editeng/source/editeng/impedit3.cxx                          |   23 +++--
 editeng/source/outliner/outleeng.cxx                         |    9 --
 editeng/source/outliner/outliner.cxx                         |   16 ---
 include/drawinglayer/primitive2d/textprimitive2d.hxx         |   11 --
 include/editeng/editeng.hxx                                  |    6 -
 include/editeng/outliner.hxx                                 |   14 ---
 svx/source/svdraw/svdotextdecomposition.cxx                  |    5 -
 12 files changed, 43 insertions(+), 122 deletions(-)

New commits:
commit af014d1b5dea3419560b1df7933e3ac61db2c76b
Author:     Armin Le Grand (Collabora) <[email protected]>
AuthorDate: Thu Aug 1 17:05:25 2024 +0200
Commit:     Armin Le Grand <[email protected]>
CommitDate: Thu Aug 1 20:28:36 2024 +0200

    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 <[email protected]>

diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx 
b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx
index 07181bbf2a17..125b1e735cc8 100644
--- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx
@@ -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),
diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx 
b/drawinglayer/source/primitive2d/textprimitive2d.cxx
index 2d91785c5287..820b3d39f804 100644
--- a/drawinglayer/source/primitive2d/textprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx
@@ -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);
     }
 
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index a99032e7683e..3da588b1a096 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -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());
                 }
             }
 
diff --git a/editeng/inc/outleeng.hxx b/editeng/inc/outleeng.hxx
index 36194c3d0f6f..c40837dc5f8f 100644
--- a/editeng/inc/outleeng.hxx
+++ b/editeng/inc/outleeng.hxx
@@ -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;
diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 172f6ad2c108..7feff6e8e6e0 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -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&)
 {
 }
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 944f3a1c14a9..b627c2447e81 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -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 )
diff --git a/editeng/source/outliner/outleeng.cxx 
b/editeng/source/outliner/outleeng.cxx
index 1136ef37b9e2..6ad8d267ed19 100644
--- a/editeng/source/outliner/outleeng.cxx
+++ b/editeng/source/outliner/outleeng.cxx
@@ -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 );
diff --git a/editeng/source/outliner/outliner.cxx 
b/editeng/source/outliner/outliner.cxx
index 2eb127a7f430..e367bb5cb263 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -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 );
     }
diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx 
b/include/drawinglayer/primitive2d/textprimitive2d.hxx
index 17b38f1414ec..b5cff99f4047 100644
--- a/include/drawinglayer/primitive2d/textprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx
@@ -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;
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index af62e525e98a..c981c332a855 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -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. */
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 4b28af42ab00..8c217b22247b 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -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 );
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx 
b/svx/source/svdraw/svdotextdecomposition.cxx
index e3643498835d..76e27768224c 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -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);
         }
 

Reply via email to