editeng/source/editeng/impedit.hxx  |    2 +
 editeng/source/editeng/impedit2.cxx |    3 +-
 editeng/source/editeng/impedit3.cxx |   36 +++++++++++++++++++-------------
 editeng/source/items/svxfont.cxx    |   40 +++++++++++++++++++++++++++---------
 include/editeng/svxfont.hxx         |    7 ++++--
 include/vcl/glyphitemcache.hxx      |   23 +++++++++++++++++---
 sc/source/ui/view/output2.cxx       |    2 -
 vcl/source/gdi/impglyphitem.cxx     |   30 +++++++++++++++++++--------
 8 files changed, 103 insertions(+), 40 deletions(-)

New commits:
commit 673a210b73716cf9ceb7b104b38e39987d0515af
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Mar 15 14:07:01 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Mar 15 19:42:45 2022 +0100

    use SalLayoutGlyphsCache in EditEngine/SvxFont (tdf#94677)
    
    Change-Id: I4c7c94c10b9184ad1d3348e7b364748b4e7c34de
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131611
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index eb8176561cb1..36480f26bc1c 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -36,6 +36,7 @@
 #include <vcl/idle.hxx>
 #include <vcl/commandevent.hxx>
 #include <vcl/ptrstyle.hxx>
+#include <vcl/glyphitemcache.hxx>
 
 #include <vcl/dndhelp.hxx>
 #include <svl/ondemand.hxx>
@@ -607,6 +608,7 @@ private:
 
     bool            mbNbspRunNext;  // can't be a bitfield as it is passed as 
bool&
 
+    SalLayoutGlyphsCache mGlyphsCache;
 
     // Methods...
 
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 36747c1c8666..402d606d8b57 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3438,7 +3438,8 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* 
pPortion, EditLine* pLine,
                     SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
                     aTmpFont.SetPhysFont(*GetRefDevice());
                     ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
-                    nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), 
pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen() ).Width();
+                    nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(),
+                        pPortion->GetNode()->GetString(), nPos, 
rTextPortion.GetLen(), nullptr, &mGlyphsCache ).Width();
                 }
             }
             break;
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 4bff8d26c94d..4f341fd65959 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -996,7 +996,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
 
                         // Height needed...
                         SeekCursor( pNode, nTmpPos+1, aTmpFont );
-                        pPortion->GetSize().setHeight( 
aTmpFont.QuickGetTextSize( GetRefDevice(), OUString(), 0, 0 ).Height() );
+                        pPortion->GetSize().setHeight(
+                            aTmpFont.QuickGetTextSize( GetRefDevice(), 
OUString(), 0, 0, nullptr, &mGlyphsCache ).Height() );
 
                         DBG_ASSERT( pPortion->GetSize().Width() >= 0, "Tab 
incorrectly calculated!" );
 
@@ -1041,7 +1042,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                         OUString aFieldValue = static_cast<const 
EditCharAttribField*>(pNextFeature)->GetFieldValue();
                         // get size, but also DXArray to allow length 
information in line breaking below
                         std::vector<sal_Int32> aTmpDXArray;
-                        pPortion->GetSize() = 
aTmpFont.QuickGetTextSize(GetRefDevice(), aFieldValue, 0, 
aFieldValue.getLength(), &aTmpDXArray);
+                        pPortion->GetSize() = 
aTmpFont.QuickGetTextSize(GetRefDevice(),
+                            aFieldValue, 0, aFieldValue.getLength(), 
&aTmpDXArray, &mGlyphsCache);
 
                         // So no scrolling for oversized fields
                         if ( pPortion->GetSize().Width() > nXWidth )
@@ -1146,7 +1148,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 if (bContinueLastPortion)
                 {
                      Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
-                            rParaPortion.GetNode()->GetString(), nTmpPos, 
nPortionLen, &aBuf ));
+                            rParaPortion.GetNode()->GetString(), nTmpPos, 
nPortionLen, &aBuf, &mGlyphsCache ));
                      pPortion->GetSize().AdjustWidth(aSize.Width() );
                      if (pPortion->GetSize().Height() < aSize.Height())
                          pPortion->GetSize().setHeight( aSize.Height() );
@@ -1154,7 +1156,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 else
                 {
                     pPortion->GetSize() = aTmpFont.QuickGetTextSize( 
GetRefDevice(),
-                            rParaPortion.GetNode()->GetString(), nTmpPos, 
nPortionLen, &aBuf );
+                            rParaPortion.GetNode()->GetString(), nTmpPos, 
nPortionLen, &aBuf, &mGlyphsCache );
                 }
 
                 // #i9050# Do Kerning also behind portions...
@@ -1222,7 +1224,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                     if ( nDecPos != -1 )
                     {
                         nW -= 
rParaPortion.GetTextPortions()[nTmpPortion].GetSize().Width();
-                        nW += aTmpFont.QuickGetTextSize( GetRefDevice(), 
rParaPortion.GetNode()->GetString(), nTmpPos, nDecPos ).Width();
+                        nW += aTmpFont.QuickGetTextSize( GetRefDevice(), 
rParaPortion.GetNode()->GetString(),
+                                nTmpPos, nDecPos, nullptr, &mGlyphsCache 
).Width();
                         aCurrentTab.bValid = false;
                     }
                 }
@@ -2367,7 +2370,8 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* 
pPortion, sal_Int32 nPos
             aTmpFont.SetPhysFont(*GetRefDevice());
             GetRefDevice()->Push( vcl::PushFlags::TEXTLANGUAGE );
             ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
-            Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), 
pPortion->GetNode()->GetString(), nTxtPortionStart, pTextPortion->GetLen() );
+            Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), 
pPortion->GetNode()->GetString(),
+                nTxtPortionStart, pTextPortion->GetLen(), nullptr, 
&mGlyphsCache );
             GetRefDevice()->Pop();
             pTextPortion->GetExtraInfos()->nOrgWidth = aSz.Width();
         }
@@ -3296,7 +3300,8 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
 
                                             if ( 0x200B == cChar || 0x2060 == 
cChar )
                                             {
-                                                tools::Long nHalfBlankWidth = 
aTmpFont.QuickGetTextSize( &rOutDev, " ", 0, 1 ).Width() / 2;
+                                                tools::Long nHalfBlankWidth = 
aTmpFont.QuickGetTextSize( &rOutDev,
+                                                    " ", 0, 1, nullptr, 
&mGlyphsCache ).Width() / 2;
 
                                                 const tools::Long nAdvanceX = 
( nTmpIdx == nTmpEnd ?
                                                                          
rTextPortion.GetSize().Width() :
@@ -3332,13 +3337,14 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
                                                     aTmpFont.SetPropr( 25 );
                                                     
aTmpFont.SetPhysFont(rOutDev);
 
-                                                    const Size aSlashSize = 
aTmpFont.QuickGetTextSize( &rOutDev, aSlash, 0, 1 );
+                                                    const Size aSlashSize = 
aTmpFont.QuickGetTextSize( &rOutDev,
+                                                        aSlash, 0, 1, nullptr, 
&mGlyphsCache );
                                                     Point aSlashPos( aTmpPos );
                                                     const tools::Long nAddX = 
nHalfBlankWidth - aSlashSize.Width() / 2;
                                                     
setXDirectionAwareFrom(aSlashPos, aTopLeftRectPos);
                                                     
adjustXDirectionAware(aSlashPos, nAddX);
 
-                                                    aTmpFont.QuickDrawText( 
&rOutDev, aSlashPos, aSlash, 0, 1 );
+                                                    aTmpFont.QuickDrawText( 
&rOutDev, aSlashPos, aSlash, 0, 1, {}, &mGlyphsCache );
 
                                                     aTmpFont.SetEscapement( 
nOldEscapement );
                                                     aTmpFont.SetPropr( 
nOldPropr );
@@ -3399,7 +3405,8 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
                                     }
 
                                     aTmpFont.SetPhysFont(*GetRefDevice());
-                                    aTmpFont.QuickGetTextSize( GetRefDevice(), 
aText, nTextStart, nTextLen, &aTmpDXArray );
+                                    aTmpFont.QuickGetTextSize( GetRefDevice(), 
aText, nTextStart, nTextLen,
+                                        &aTmpDXArray, &mGlyphsCache );
                                     pDXArray = aTmpDXArray;
 
                                     // add a meta file comment if we record to 
a metafile
@@ -3425,7 +3432,8 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
 
                                     // crash when accessing 0 pointer in 
pDXArray
                                     aTmpFont.SetPhysFont(*GetRefDevice());
-                                    aTmpFont.QuickGetTextSize( GetRefDevice(), 
aText, 0, aText.getLength(), &aTmpDXArray );
+                                    aTmpFont.QuickGetTextSize( GetRefDevice(), 
aText, 0, aText.getLength(),
+                                        &aTmpDXArray, &mGlyphsCache );
                                     pDXArray = aTmpDXArray;
                                 }
 
@@ -3626,7 +3634,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
                                             --nTextLen;
 
                                         // output directly
-                                        aTmpFont.QuickDrawText( &rOutDev, 
aRealOutPos, aText, nTextStart, nTextLen, pDXArray );
+                                        aTmpFont.QuickDrawText( &rOutDev, 
aRealOutPos, aText, nTextStart, nTextLen, pDXArray, &mGlyphsCache );
 
                                         if ( bDrawFrame )
                                         {
@@ -3717,7 +3725,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
                                     aTmpFont.SetEscapement( 0 );
                                     aTmpFont.SetPhysFont(rOutDev);
                                     tools::Long nCharWidth = 
aTmpFont.QuickGetTextSize( &rOutDev,
-                                        
OUString(rTextPortion.GetExtraValue()), 0, 1 ).Width();
+                                        
OUString(rTextPortion.GetExtraValue()), 0, 1, {}, &mGlyphsCache ).Width();
                                     sal_Int32 nChars = 2;
                                     if( nCharWidth )
                                         nChars = 
rTextPortion.GetSize().Width() / nCharWidth;
@@ -3729,7 +3737,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
                                     OUStringBuffer aBuf(nChars);
                                     comphelper::string::padToLength(aBuf, 
nChars, rTextPortion.GetExtraValue());
                                     OUString aText(aBuf.makeStringAndClear());
-                                    aTmpFont.QuickDrawText( &rOutDev, aTmpPos, 
aText, 0, aText.getLength() );
+                                    aTmpFont.QuickDrawText( &rOutDev, aTmpPos, 
aText, 0, aText.getLength(), {}, &mGlyphsCache );
                                     rOutDev.DrawStretchText( aTmpPos, 
rTextPortion.GetSize().Width(), aText );
 
                                     if ( bStripOnly )
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index d4370e9b00de..7c73d0c9d628 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <editeng/svxfont.hxx>
+
+#include <vcl/glyphitemcache.hxx>
 #include <vcl/metric.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/print.hxx>
@@ -25,7 +28,6 @@
 #include <tools/poly.hxx>
 #include <unotools/charclass.hxx>
 #include <com/sun/star/i18n/KCharacterType.hpp>
-#include <editeng/svxfont.hxx>
 #include <editeng/escapementitem.hxx>
 #include <sal/log.hxx>
 
@@ -451,20 +453,28 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut )
     return aTxtSize;
 }
 
+static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& 
rStr, std::vector<sal_Int32>* pDXAry,
+                                 sal_Int32 nIndex, sal_Int32 nLen, 
SalLayoutGlyphsCache* cache )
+{
+    const SalLayoutGlyphs* layoutGlyphs = cache ? cache->GetLayoutGlyphs(pOut, 
rStr, nIndex, nLen) : nullptr;
+    return pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, nullptr, 
layoutGlyphs);
+}
+
 Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
-                         const sal_Int32 nIdx, const sal_Int32 nLen, 
std::vector<sal_Int32>* pDXArray ) const
+                         const sal_Int32 nIdx, const sal_Int32 nLen, 
std::vector<sal_Int32>* pDXArray,
+                         SalLayoutGlyphsCache* cache ) const
 {
     if ( !IsCaseMap() && !IsKern() )
-        return Size( pOut->GetTextArray( rTxt, pDXArray, nIdx, nLen ),
+        return Size( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen, cache ),
                      pOut->GetTextHeight() );
 
     Size aTxtSize;
     aTxtSize.setHeight( pOut->GetTextHeight() );
     if ( !IsCaseMap() )
-        aTxtSize.setWidth( pOut->GetTextArray( rTxt, pDXArray, nIdx, nLen ) );
+        aTxtSize.setWidth( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen, 
cache ) );
     else
-        aTxtSize.setWidth( pOut->GetTextArray( CalcCaseMap( rTxt ),
-                           pDXArray, nIdx, nLen ) );
+        aTxtSize.setWidth( GetTextArray( pOut, CalcCaseMap( rTxt ),
+                           pDXArray, nIdx, nLen, cache ) );
 
     if( IsKern() && ( nLen > 1 ) )
     {
@@ -498,15 +508,25 @@ Size SvxFont::GetTextSize(const OutputDevice& rOut, const 
OUString &rTxt,
     return aTxtSize;
 }
 
+static void DrawTextArray( OutputDevice* pOut, const Point& rStartPt, const 
OUString& rStr,
+                           o3tl::span<const sal_Int32> pDXAry,
+                           sal_Int32 nIndex, sal_Int32 nLen,
+                           SalLayoutGlyphsCache* cache )
+{
+    const SalLayoutGlyphs* layoutGlyphs = cache ? cache->GetLayoutGlyphs(pOut, 
rStr, nIndex, nLen) : nullptr;
+    pOut->DrawTextArray(rStartPt, rStr, pDXAry, nIndex, nLen, 
SalLayoutFlags::NONE, layoutGlyphs);
+}
+
 void SvxFont::QuickDrawText( OutputDevice *pOut,
     const Point &rPos, const OUString &rTxt,
-    const sal_Int32 nIdx, const sal_Int32 nLen, o3tl::span<const sal_Int32> 
pDXArray ) const
+    const sal_Int32 nIdx, const sal_Int32 nLen, o3tl::span<const sal_Int32> 
pDXArray,
+    SalLayoutGlyphsCache* cache ) const
 {
 
     // Font has to be selected in OutputDevice...
     if ( !IsCaseMap() && !IsCapital() && !IsKern() && !IsEsc() )
     {
-        pOut->DrawTextArray( rPos, rTxt, pDXArray, nIdx, nLen );
+        DrawTextArray( pOut, rPos, rTxt, pDXArray, nIdx, nLen, cache );
         return;
     }
 
@@ -543,9 +563,9 @@ void SvxFont::QuickDrawText( OutputDevice *pOut,
         else
         {
             if ( !IsCaseMap() )
-                pOut->DrawTextArray( aPos, rTxt, pDXArray, nIdx, nLen );
+                DrawTextArray( pOut, aPos, rTxt, pDXArray, nIdx, nLen, cache );
             else
-                pOut->DrawTextArray( aPos, CalcCaseMap( rTxt ), pDXArray, 
nIdx, nLen );
+                DrawTextArray( pOut, aPos, CalcCaseMap( rTxt ), pDXArray, 
nIdx, nLen, cache );
         }
     }
 }
diff --git a/include/editeng/svxfont.hxx b/include/editeng/svxfont.hxx
index dffc4101e009..a3db7b2a8936 100644
--- a/include/editeng/svxfont.hxx
+++ b/include/editeng/svxfont.hxx
@@ -36,6 +36,7 @@ class Printer;
 class Point;
 namespace tools { class Rectangle; }
 class Size;
+class SalLayoutGlyphsCache;
 
 class EDITENG_DLLPUBLIC SvxFont : public vcl::Font
 {
@@ -96,10 +97,12 @@ public:
                      const sal_Int32 nIdx = 0, const sal_Int32 nLen = 
SAL_MAX_INT32) const;
 
     void QuickDrawText( OutputDevice *pOut, const Point &rPos, const OUString 
&rTxt,
-                        const sal_Int32 nIdx = 0, const sal_Int32 nLen = 
SAL_MAX_INT32, o3tl::span<const sal_Int32> pDXArray = {} ) const;
+                        const sal_Int32 nIdx = 0, const sal_Int32 nLen = 
SAL_MAX_INT32, o3tl::span<const sal_Int32> pDXArray = {},
+                        SalLayoutGlyphsCache* cache = nullptr ) const;
 
     Size QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
-                         const sal_Int32 nIdx, const sal_Int32 nLen, 
std::vector<sal_Int32>* pDXArray = nullptr ) const;
+                         const sal_Int32 nIdx, const sal_Int32 nLen, 
std::vector<sal_Int32>* pDXArray = nullptr,
+                         SalLayoutGlyphsCache* cache = nullptr ) const;
 
     void DrawPrev( OutputDevice* pOut, Printer* pPrinter,
                    const Point &rPos, const OUString &rTxt,
diff --git a/include/vcl/glyphitemcache.hxx b/include/vcl/glyphitemcache.hxx
index 8afc8da0bae6..8c7cd01bbadc 100644
--- a/include/vcl/glyphitemcache.hxx
+++ b/include/vcl/glyphitemcache.hxx
@@ -26,6 +26,9 @@
 #include <o3tl/lru_map.hxx>
 #include <o3tl/hash_combine.hxx>
 #include <vcl/glyphitem.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/vclptr.hxx>
+#include <tools/gen.hxx>
 
 /**
 A cache for SalLayoutGlyphs objects.
@@ -41,17 +44,29 @@ public:
         : mCachedGlyphs(size)
     {
     }
-    const SalLayoutGlyphs* GetLayoutGlyphs(const OUString& text,
-                                           VclPtr<OutputDevice> outputDevice) 
const;
+    const SalLayoutGlyphs* GetLayoutGlyphs(VclPtr<const OutputDevice> 
outputDevice,
+                                           const OUString& text) const
+    {
+        return GetLayoutGlyphs(outputDevice, text, 0, text.getLength());
+    }
+    const SalLayoutGlyphs* GetLayoutGlyphs(VclPtr<const OutputDevice> 
outputDevice,
+                                           const OUString& text, sal_Int32 
nIndex, sal_Int32 nLen,
+                                           const Point& rLogicPos = Point(0, 
0),
+                                           tools::Long nLogicWidth = 0) const;
     void clear() { mCachedGlyphs.clear(); }
 
 private:
     struct CachedGlyphsKey
     {
+        VclPtr<const OutputDevice> outputDevice;
         OUString text;
-        VclPtr<OutputDevice> outputDevice;
+        sal_Int32 index;
+        sal_Int32 len;
+        Point logicPos;
+        tools::Long logicWidth;
         size_t hashValue;
-        CachedGlyphsKey(const OUString& t, const VclPtr<OutputDevice>& dev);
+        CachedGlyphsKey(const VclPtr<const OutputDevice>& dev, const OUString& 
t, sal_Int32 i,
+                        sal_Int32 l, const Point& p, tools::Long w);
         bool operator==(const CachedGlyphsKey& other) const;
     };
     struct CachedGlyphsHash
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 0c394b0f7945..90f6fdacf91e 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -189,7 +189,7 @@ public:
     // to lay out the text, which is relatively slow, so cache that operation.
     const SalLayoutGlyphs*  GetLayoutGlyphs(const OUString& rString) const
     {
-        return mCachedGlyphs.GetLayoutGlyphs(rString, pOutput->pFmtDevice);
+        return mCachedGlyphs.GetLayoutGlyphs(pOutput->pFmtDevice, rString);
     }
 
 private:
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 1fefe68994d2..37c535ab1e44 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -95,9 +95,11 @@ bool SalLayoutGlyphsImpl::IsValid() const
 }
 
 const SalLayoutGlyphs*
-SalLayoutGlyphsCache::GetLayoutGlyphs(const OUString& text, 
VclPtr<OutputDevice> outputDevice) const
+SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<const OutputDevice> outputDevice, 
const OUString& text,
+                                      sal_Int32 nIndex, sal_Int32 nLen, const 
Point& rLogicPos,
+                                      tools::Long nLogicWidth) const
 {
-    const CachedGlyphsKey key(text, outputDevice);
+    const CachedGlyphsKey key(outputDevice, text, nIndex, nLen, rLogicPos, 
nLogicWidth);
     auto it = mCachedGlyphs.find(key);
     if (it != mCachedGlyphs.end())
     {
@@ -109,7 +111,7 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(const OUString& text, 
VclPtr<OutputDevice>
         return nullptr;
     }
     std::unique_ptr<SalLayout> layout = outputDevice->ImplLayout(
-        text, 0, text.getLength(), Point(0, 0), 0, {}, 
SalLayoutFlags::GlyphItemsOnly);
+        text, nIndex, nLen, rLogicPos, nLogicWidth, {}, 
SalLayoutFlags::GlyphItemsOnly);
     if (layout)
     {
         mCachedGlyphs.insert(std::make_pair(key, layout->GetGlyphs()));
@@ -119,10 +121,15 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(const OUString& 
text, VclPtr<OutputDevice>
     return nullptr;
 }
 
-SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey(const OUString& t,
-                                                       const 
VclPtr<OutputDevice>& d)
-    : text(t)
-    , outputDevice(d)
+SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey(const VclPtr<const 
OutputDevice>& d,
+                                                       const OUString& t, 
sal_Int32 i, sal_Int32 l,
+                                                       const Point& p, 
tools::Long w)
+    : outputDevice(d)
+    , text(t)
+    , index(i)
+    , len(l)
+    , logicPos(p)
+    , logicWidth(w)
 {
     hashValue = 0;
     o3tl::hash_combine(hashValue, outputDevice.get());
@@ -130,11 +137,18 @@ 
SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey(const OUString& t,
     WriteFont(stream, outputDevice->GetFont());
     o3tl::hash_combine(hashValue, static_cast<const char*>(stream.GetData()), 
stream.GetSize());
     o3tl::hash_combine(hashValue, text);
+    o3tl::hash_combine(hashValue, index);
+    o3tl::hash_combine(hashValue, len);
+    o3tl::hash_combine(hashValue, logicPos.X());
+    o3tl::hash_combine(hashValue, logicPos.Y());
+    o3tl::hash_combine(hashValue, logicWidth);
 }
 
 inline bool SalLayoutGlyphsCache::CachedGlyphsKey::operator==(const 
CachedGlyphsKey& other) const
 {
-    return hashValue == other.hashValue && outputDevice == other.outputDevice 
&& text == other.text;
+    return hashValue == other.hashValue && outputDevice == other.outputDevice
+           && index == other.index && len == other.len && logicPos == 
other.logicPos
+           && logicWidth == other.logicWidth && text == other.text;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to