sw/source/core/inc/fntcache.hxx     |    7 -------
 sw/source/core/txtnode/fntcache.cxx |   14 +++++++-------
 vcl/source/gdi/impglyphitem.cxx     |    7 ++++++-
 3 files changed, 13 insertions(+), 15 deletions(-)

New commits:
commit 7cc4b06fc44c06866cdabb4a8856c7cee3fcfe2d
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Apr 8 14:35:34 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Sat Apr 9 00:37:21 2022 +0200

    use helper GetTextArray() in all places
    
    Change-Id: Icec4326cf614574d7dabe6752f985b3ac4462fb9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132744
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx
index 3b8934013059..4f58be568951 100644
--- a/sw/source/core/inc/fntcache.hxx
+++ b/sw/source/core/inc/fntcache.hxx
@@ -78,13 +78,6 @@ class SwFntObj final : public SwCacheObj
     bool m_bSymbol : 1;
     bool m_bPaintBlank : 1;
 
-    static void GetTextArray(const OutputDevice& rOutputDevice, const 
OUString& rStr,
-                             std::vector<sal_Int32>& rDXAry, sal_Int32 nIndex, 
sal_Int32 nLen,
-                             const vcl::text::TextLayoutCache* layoutCache = 
nullptr);
-    static void GetTextArray(const OutputDevice& rOutputDevice, const 
SwDrawTextInfo& rInf, std::vector<sal_Int32>& rDXAry,
-                             sal_Int32 nLen);
-    static void GetTextArray(const OutputDevice& rOutputDevice, const 
SwDrawTextInfo& rInf, std::vector<sal_Int32>& rDXAry);
-
     static tools::Long s_nPixWidth;
     static MapMode *s_pPixMap;
 
diff --git a/sw/source/core/txtnode/fntcache.cxx 
b/sw/source/core/txtnode/fntcache.cxx
index 39e23613e669..65a4332b462d 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -756,20 +756,20 @@ static void lcl_DrawLineForWrongListData(
         rInf.GetOut().Pop();
 }
 
-void SwFntObj::GetTextArray(const OutputDevice& rDevice, const OUString& rStr, 
std::vector<sal_Int32>& rDXAry,
-                            sal_Int32 nIndex, sal_Int32 nLen, const 
vcl::text::TextLayoutCache* layoutCache)
+static void GetTextArray(const OutputDevice& rDevice, const OUString& rStr, 
std::vector<sal_Int32>& rDXAry,
+                         sal_Int32 nIndex, sal_Int32 nLen, const 
vcl::text::TextLayoutCache* layoutCache = nullptr)
 {
     const SalLayoutGlyphs* pLayoutCache = 
SalLayoutGlyphsCache::self()->GetLayoutGlyphs(&rDevice, rStr, nIndex, nLen,
         0, layoutCache);
     rDevice.GetTextArray(rStr, &rDXAry, nIndex, nLen, layoutCache, 
pLayoutCache);
 }
 
-void SwFntObj::GetTextArray(const OutputDevice& rOutputDevice, const 
SwDrawTextInfo& rInf, std::vector<sal_Int32>& rDXAry)
+static void GetTextArray(const OutputDevice& rOutputDevice, const 
SwDrawTextInfo& rInf, std::vector<sal_Int32>& rDXAry)
 {
     return GetTextArray(rOutputDevice, rInf.GetText(), rDXAry, 
rInf.GetIdx().get(), rInf.GetLen().get(), rInf.GetVclCache());
 }
 
-void SwFntObj::GetTextArray(const OutputDevice& rOutputDevice, const 
SwDrawTextInfo& rInf, std::vector<sal_Int32>& rDXAry, sal_Int32 nLen)
+static void GetTextArray(const OutputDevice& rOutputDevice, const 
SwDrawTextInfo& rInf, std::vector<sal_Int32>& rDXAry, sal_Int32 nLen)
 {
     // Substring is fine.
     assert( nLen <= rInf.GetLen().get());
@@ -2246,7 +2246,7 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const 
& rInf, tools::Long nTe
             const sal_uInt16 nGridWidth = GetGridWidth(*pGrid, *pDoc);
 
             std::vector<sal_Int32> aKernArray;
-            rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
+            GetTextArray( rInf.GetOut(), rInf.GetText(), aKernArray,
                     sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
 
             tools::Long nAvgWidthPerChar = aKernArray[sal_Int32(rInf.GetLen()) 
- 1] / sal_Int32(rInf.GetLen());
@@ -2277,7 +2277,7 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const 
& rInf, tools::Long nTe
             const tools::Long nGridWidthAdd = EvalGridWidthAdd( pGrid, rInf );
 
             std::vector<sal_Int32> aKernArray;
-            rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
+            GetTextArray( rInf.GetOut(), rInf.GetText(), aKernArray,
                         sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
             tools::Long nCurrPos = aKernArray[sal_Int32(nTextBreak)] + 
nGridWidthAdd;
             while (++nTextBreak < rInf.GetLen() && nTextWidth >= nCurrPos)
@@ -2394,7 +2394,7 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const 
& rInf, tools::Long nTe
         else if (nLn > nTextBreak2 + nTextBreak2)
             nLn = nTextBreak2 + nTextBreak2;
         std::vector<sal_Int32> aKernArray;
-        rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
+        GetTextArray( rInf.GetOut(), rInf.GetText(), aKernArray,
                                     sal_Int32(rInf.GetIdx()), sal_Int32(nLn));
         if( rInf.GetScriptInfo()->Compress( aKernArray.data(), rInf.GetIdx(), 
nLn,
                             rInf.GetKanaComp(), 
o3tl::narrowing<sal_uInt16>(GetHeight( m_nActual )),
commit bc0acc7bd02057f3c04af39530ee0fe235353576
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Apr 8 12:35:45 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Sat Apr 9 00:37:09 2022 +0200

    cache failures in SalLayoutGlyphsCache too
    
    Change-Id: I0ddbb8ac94705d7a1a843fe39d0821644dfb5084
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132743
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 86284c256e64..e78d23b68676 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -142,7 +142,12 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<const 
OutputDevice> outputDevice, c
         assert(mCachedGlyphs.find(key) == mCachedGlyphs.begin()); // newly 
inserted item is first
         return &mCachedGlyphs.begin()->second;
     }
-    return nullptr;
+    else
+    {
+        // Failure, cache it too as invalid glyphs.
+        mCachedGlyphs.insert(std::make_pair(key, SalLayoutGlyphs()));
+        return nullptr;
+    }
 }
 
 SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey(const VclPtr<const 
OutputDevice>& d,

Reply via email to