[Libreoffice-commits] core.git: desktop/source include/vcl sw/source vcl/inc vcl/Library_vcl.mk vcl/qa vcl/source

Chris Sherlock (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 30 00:47:11 UTC 2021


 desktop/source/lib/init.cxx         |    2 +-
 include/vcl/outdev.hxx              |   19 +++++++++++--------
 include/vcl/window.hxx              |    2 +-
 sw/source/core/inc/drawfont.hxx     |   10 ++++++----
 sw/source/core/inc/fntcache.hxx     |    2 +-
 sw/source/core/text/inftxt.cxx      |    6 +++---
 sw/source/core/text/inftxt.hxx      |   14 +++++++-------
 sw/source/core/text/porfld.cxx      |    2 +-
 sw/source/core/text/pormulti.cxx    |    2 +-
 sw/source/core/txtnode/fntcache.cxx |    2 +-
 vcl/Library_vcl.mk                  |    1 +
 vcl/inc/TextLayoutCache.hxx         |   18 ++++--------------
 vcl/inc/sallayout.hxx               |    8 ++++----
 vcl/qa/cppunit/text.cxx             |    6 +++---
 vcl/source/gdi/CommonSalLayout.cxx  |   12 ++++++------
 vcl/source/gdi/sallayout.cxx        |    2 +-
 vcl/source/outdev/text.cxx          |   14 +++++++-------
 vcl/source/text/TextLayoutCache.cxx |   36 ++++++++++++++++++++++++++++++++++++
 vcl/source/window/window3.cxx       |    2 +-
 19 files changed, 96 insertions(+), 64 deletions(-)

New commits:
commit 229136b7c9363bc758c9e925ccfd0c9bb34ceaec
Author:     Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Sun Aug 29 00:59:08 2021 +1000
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Aug 30 02:46:33 2021 +0200

    vcl: move TextLayoutCache into vcl::text namespace
    
    Placed TextLayoutCache function into own source file and moved it into
    the new vcl::text namespace. With this patch we will have these vcl::*
    namespaces:
    
    namespace vcl::bitmap
    namespace vcl::CommandInfoProvider
    namespace vcl::detail
    namespace vcl::drawmode
    namespace vcl::fileregistration
    namespace vcl::filter
    namespace vcl::font
    namespace vcl::graphic
    namespace vcl::lok
    namespace vcl::pdf
    namespace vcl::table
    namespace vcl::test
      namespace vcl::text
    namespace vcl::unohelper
    namespace vcl::unotools
    
    Change-Id: Ia38c2d73715676a924cdbb0de6308a72a40ec3b3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121206
    Reviewed-by: Hossein <hossein at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index da8c0d5a1595..709b42038a0e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4543,7 +4543,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons
 
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
     {
-        {"AnchorType", uno::makeAny(static_cast<sal_uInt16>(text::TextContentAnchorType_AS_CHARACTER))},
+        {"AnchorType", uno::makeAny(static_cast<sal_uInt16>(css::text::TextContentAnchorType_AS_CHARACTER))},
         {"IgnoreComments", uno::makeAny(true)},
     }));
     if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues))
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 144a52308a3e..402b998bc1aa 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -101,12 +101,15 @@ namespace vcl
     class ExtOutDevData;
     class ITextLayout;
     struct FontCapabilities;
-    class TextLayoutCache;
     class Window;
     class WindowOutputDevice;
     namespace font {
         struct Feature;
     }
+
+    namespace text {
+        class TextLayoutCache;
+    }
 }
 
 namespace basegfx {
@@ -1027,7 +1030,7 @@ public:
         See also GetTextBoundRect() for more explanation + code examples.
     */
     tools::Long                        GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
-                                  vcl::TextLayoutCache const* = nullptr,
+                                  vcl::text::TextLayoutCache const* = nullptr,
                                   SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
 
     /** Height where any character of the current font fits; in logic coordinates.
@@ -1045,7 +1048,7 @@ public:
                                                const SalLayoutGlyphs* pLayoutCache = nullptr);
     tools::Long                        GetTextArray( const OUString& rStr, tools::Long* pDXAry,
                                               sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
-                                              vcl::TextLayoutCache const* = nullptr,
+                                              vcl::text::TextLayoutCache const* = nullptr,
                                               SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
 
     void                        GetCaretPositions( const OUString&, tools::Long* pCaretXArray,
@@ -1057,14 +1060,14 @@ public:
     sal_Int32                   GetTextBreak( const OUString& rStr, tools::Long nTextWidth,
                                               sal_Int32 nIndex, sal_Int32 nLen = -1,
                                               tools::Long nCharExtra = 0,
-                                              vcl::TextLayoutCache const* = nullptr,
+                                              vcl::text::TextLayoutCache const* = nullptr,
                                               const SalLayoutGlyphs* pGlyphs = nullptr) const;
     sal_Int32                   GetTextBreak( const OUString& rStr, tools::Long nTextWidth,
                                               sal_Unicode nExtraChar, sal_Int32& rExtraCharPos,
                                               sal_Int32 nIndex, sal_Int32 nLen,
                                               tools::Long nCharExtra,
-                                              vcl::TextLayoutCache const* = nullptr) const;
-    static std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&);
+                                              vcl::text::TextLayoutCache const* = nullptr) const;
+    static std::shared_ptr<vcl::text::TextLayoutCache> CreateTextLayoutCache(OUString const&);
 
 protected:
     SAL_DLLPRIVATE void         ImplInitTextLineSize();
@@ -1214,12 +1217,12 @@ public:
                                 ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
                                             const Point& rLogicPos = Point(0,0), tools::Long nLogicWidth=0,
                                             const tools::Long* pLogicDXArray=nullptr, SalLayoutFlags flags = SalLayoutFlags::NONE,
-                                            vcl::TextLayoutCache const* = nullptr,
+                                            vcl::text::TextLayoutCache const* = nullptr,
                                             const SalLayoutGlyphs* pGlyphs = nullptr) const;
     SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
                                                          DeviceCoordinate nPixelWidth, const DeviceCoordinate* pPixelDXArray,
                                                          SalLayoutFlags flags = SalLayoutFlags::NONE,
-                                                         vcl::TextLayoutCache const* = nullptr) const;
+                                                         vcl::text::TextLayoutCache const* = nullptr) const;
     SAL_DLLPRIVATE std::unique_ptr<SalLayout>
                                 ImplGlyphFallbackLayout( std::unique_ptr<SalLayout>,
                                                          ImplLayoutArgs&,
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 4fb9e4ab15e0..8d918161c2e0 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1536,7 +1536,7 @@ public:
         See also GetTextBoundRect() for more explanation + code examples.
     */
     tools::Long                 GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
-                                    vcl::TextLayoutCache const* = nullptr,
+                                    vcl::text::TextLayoutCache const* = nullptr,
                                     SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
 
     /** Height where any character of the current font fits; in logic coordinates.
diff --git a/sw/source/core/inc/drawfont.hxx b/sw/source/core/inc/drawfont.hxx
index 64739ef6d114..9f5a6e676291 100644
--- a/sw/source/core/inc/drawfont.hxx
+++ b/sw/source/core/inc/drawfont.hxx
@@ -33,7 +33,9 @@ namespace sw { class WrongListIterator; }
 class SwFont;
 namespace vcl {
     class Font;
-    class TextLayoutCache;
+    namespace text {
+        class TextLayoutCache;
+    }
     typedef OutputDevice RenderContext;
 }
 class SwUnderlineFont;
@@ -46,7 +48,7 @@ class SW_DLLPUBLIC SwDrawTextInfo
     SwViewShell const * m_pSh;
     const SwScriptInfo* m_pScriptInfo;
     Point m_aPos;
-    vcl::TextLayoutCache const* m_pCachedVclData;
+    vcl::text::TextLayoutCache const* m_pCachedVclData;
     OUString m_aText;
     sw::WrongListIterator* m_pWrong;
     sw::WrongListIterator* m_pGrammarCheck;
@@ -113,7 +115,7 @@ public:
     SwDrawTextInfo( SwViewShell const *pSh, OutputDevice &rOut, const SwScriptInfo* pSI,
                     const OUString &rText, TextFrameIndex const nIdx, TextFrameIndex const nLen,
                     sal_uInt16 nWidth = 0, bool bBullet = false,
-                    vcl::TextLayoutCache const*const pCachedVclData = nullptr)
+                    vcl::text::TextLayoutCache const*const pCachedVclData = nullptr)
         : m_pCachedVclData(pCachedVclData)
     {
         m_pFrame = nullptr;
@@ -208,7 +210,7 @@ public:
         return m_pHyphPos;
     }
 
-    vcl::TextLayoutCache const* GetVclCache() const
+    vcl::text::TextLayoutCache const* GetVclCache() const
     {
         return m_pCachedVclData;
     }
diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx
index 44a1483ed499..ab5c6a9e473b 100644
--- a/sw/source/core/inc/fntcache.hxx
+++ b/sw/source/core/inc/fntcache.hxx
@@ -116,7 +116,7 @@ public:
     sal_uInt16   GetPropWidth() const { return m_nPropWidth; }
     bool     IsSymbol() const { return m_bSymbol; }
 
-    tools::Long GetCachedTextWidth(const SwTextGlyphsKey& key, const vcl::TextLayoutCache* vclCache);
+    tools::Long GetCachedTextWidth(const SwTextGlyphsKey& key, const vcl::text::TextLayoutCache* vclCache);
     SalLayoutGlyphs* GetCachedSalLayoutGlyphs(const SwTextGlyphsKey& key);
     void ClearCachedTextGlyphs();
 
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index ddfc54bc6fc3..4f5df3eb8f17 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -417,7 +417,7 @@ SwPosSize SwTextSizeInfo::GetTextSize() const
 void SwTextSizeInfo::GetTextSize( const SwScriptInfo* pSI, const TextFrameIndex nIndex,
                                 const TextFrameIndex nLength, const sal_uInt16 nComp,
                                 sal_uInt16& nMinSize, sal_uInt16& nMaxSizeDiff,
-                                vcl::TextLayoutCache const*const pCache) const
+                                vcl::text::TextLayoutCache const*const pCache) const
 {
     SwDrawTextInfo aDrawInf( m_pVsh, *m_pOut, pSI, *m_pText, nIndex, nLength,
             0, false, pCache);
@@ -433,7 +433,7 @@ void SwTextSizeInfo::GetTextSize( const SwScriptInfo* pSI, const TextFrameIndex
 TextFrameIndex SwTextSizeInfo::GetTextBreak( const tools::Long nLineWidth,
                                        const TextFrameIndex nMaxLen,
                                        const sal_uInt16 nComp,
-                                       vcl::TextLayoutCache const*const pCache) const
+                                       vcl::text::TextLayoutCache const*const pCache) const
 {
     const SwScriptInfo& rScriptInfo =
                      const_cast<SwParaPortion*>(GetParaPortion())->GetScriptInfo();
@@ -454,7 +454,7 @@ TextFrameIndex SwTextSizeInfo::GetTextBreak( const tools::Long nLineWidth,
                                        const TextFrameIndex nMaxLen,
                                        const sal_uInt16 nComp,
                                        TextFrameIndex& rExtraCharPos,
-                                       vcl::TextLayoutCache const*const pCache) const
+                                       vcl::text::TextLayoutCache const*const pCache) const
 {
     const SwScriptInfo& rScriptInfo =
                      const_cast<SwParaPortion*>(GetParaPortion())->GetScriptInfo();
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index 4d5bb0651163..91fbf0c3aa7c 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -145,7 +145,7 @@ protected:
     // performance hack - this is only used by SwTextFormatInfo but
     // because it's not even possible to dynamic_cast these things
     // currently it has to be stored here
-    std::shared_ptr<vcl::TextLayoutCache> m_pCachedVclData;
+    std::shared_ptr<vcl::text::TextLayoutCache> m_pCachedVclData;
 
     SwFont *m_pFnt;
     SwUnderlineFont *m_pUnderFnt; // Font for underlining
@@ -251,7 +251,7 @@ public:
     void GetTextSize( const SwScriptInfo* pSI, TextFrameIndex nIdx,
                       TextFrameIndex nLen, const sal_uInt16 nComp,
                       sal_uInt16& nMinSize, sal_uInt16& nMaxSizeDiff,
-                      vcl::TextLayoutCache const* = nullptr) const;
+                      vcl::text::TextLayoutCache const* = nullptr) const;
     inline SwPosSize GetTextSize(const SwScriptInfo* pSI, TextFrameIndex nIdx,
                                  TextFrameIndex nLen) const;
     inline SwPosSize GetTextSize( const OUString &rText ) const;
@@ -259,12 +259,12 @@ public:
     TextFrameIndex GetTextBreak( const tools::Long nLineWidth,
                             const TextFrameIndex nMaxLen,
                             const sal_uInt16 nComp,
-                            vcl::TextLayoutCache const*) const;
+                            vcl::text::TextLayoutCache const*) const;
     TextFrameIndex GetTextBreak( const tools::Long nLineWidth,
                             const TextFrameIndex nMaxLen,
                             const sal_uInt16 nComp,
                             TextFrameIndex& rExtraCharPos,
-                            vcl::TextLayoutCache const*) const;
+                            vcl::text::TextLayoutCache const*) const;
 
     sal_uInt16 GetAscent() const;
 
@@ -325,11 +325,11 @@ public:
         { return ( m_pKanaComp && m_nKanaIdx < m_pKanaComp->size() )
                    ? (*m_pKanaComp)[m_nKanaIdx] : 0; }
 
-    const std::shared_ptr<vcl::TextLayoutCache>& GetCachedVclData() const
+    const std::shared_ptr<vcl::text::TextLayoutCache>& GetCachedVclData() const
     {
         return m_pCachedVclData;
     }
-    void SetCachedVclData(std::shared_ptr<vcl::TextLayoutCache> const& pCachedVclData)
+    void SetCachedVclData(std::shared_ptr<vcl::text::TextLayoutCache> const& pCachedVclData)
     {
         m_pCachedVclData = pCachedVclData;
     }
@@ -673,7 +673,7 @@ public:
 class SwTextSlot final
 {
     OUString aText;
-    std::shared_ptr<vcl::TextLayoutCache> m_pOldCachedVclData;
+    std::shared_ptr<vcl::text::TextLayoutCache> m_pOldCachedVclData;
     const OUString *pOldText;
     sw::WrongListIterator * m_pOldSmartTagList;
     sw::WrongListIterator * m_pOldGrammarCheckList;
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 4d589427850c..5a62aa07d290 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -137,7 +137,7 @@ namespace {
  */
 class SwFieldSlot
 {
-    std::shared_ptr<vcl::TextLayoutCache> m_pOldCachedVclData;
+    std::shared_ptr<vcl::text::TextLayoutCache> m_pOldCachedVclData;
     const OUString *pOldText;
     OUString aText;
     TextFrameIndex nIdx;
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index b94302bd8ed7..5a617a26f041 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -1996,7 +1996,7 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo &rInf,
     // save some values
     const OUString* pOldText = &(rInf.GetText());
     const SwTwips nOldPaintOfst = rInf.GetPaintOfst();
-    std::shared_ptr<vcl::TextLayoutCache> const pOldCachedVclData(rInf.GetCachedVclData());
+    std::shared_ptr<vcl::text::TextLayoutCache> const pOldCachedVclData(rInf.GetCachedVclData());
     rInf.SetCachedVclData(nullptr);
 
     OUString const aMultiStr( rInf.GetText().copy(0, sal_Int32(nMultiLen + rInf.GetIdx())) );
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index bf9bb3785678..9490fe51add0 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -257,7 +257,7 @@ SalLayoutGlyphs* SwFntObj::GetCachedSalLayoutGlyphs(const SwTextGlyphsKey& key)
     return lcl_CreateLayout(key, it);
 }
 
-tools::Long SwFntObj::GetCachedTextWidth(const SwTextGlyphsKey& key, const vcl::TextLayoutCache* vclCache)
+tools::Long SwFntObj::GetCachedTextWidth(const SwTextGlyphsKey& key, const vcl::text::TextLayoutCache* vclCache)
 {
     std::map<SwTextGlyphsKey, SwTextGlyphsData>::iterator it = m_aTextGlyphs.find(key);
     if(it != m_aTextGlyphs.end() && it->second.m_nTextWidth >= 0)
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index e7ed402ef0d8..91b2023d3554 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -235,6 +235,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/outdev/vclreferencebase \
     vcl/source/outdev/nativecontrols \
     vcl/source/outdev/map \
+    vcl/source/text/TextLayoutCache \
     vcl/source/treelist/headbar \
     vcl/source/treelist/iconview \
     vcl/source/treelist/iconviewimpl \
diff --git a/vcl/inc/TextLayoutCache.hxx b/vcl/inc/TextLayoutCache.hxx
index 0118ba32fed8..0ce0c19d8278 100644
--- a/vcl/inc/TextLayoutCache.hxx
+++ b/vcl/inc/TextLayoutCache.hxx
@@ -23,13 +23,11 @@
 
 #include <vcl/dllapi.h>
 
-#include "scrptrun.h"
-
 #include <hb-icu.h>
 
 #include <vector>
 
-namespace vcl
+namespace vcl::text
 {
 struct Run
 {
@@ -44,19 +42,11 @@ struct Run
     }
 };
 
-class TextLayoutCache
+class VCL_DLLPUBLIC TextLayoutCache
 {
 public:
-    std::vector<vcl::Run> runs;
-    TextLayoutCache(sal_Unicode const* pStr, sal_Int32 const nEnd)
-    {
-        vcl::ScriptRun aScriptRun(reinterpret_cast<const UChar*>(pStr), nEnd);
-        while (aScriptRun.next())
-        {
-            runs.emplace_back(aScriptRun.getScriptStart(), aScriptRun.getScriptEnd(),
-                              aScriptRun.getScriptCode());
-        }
-    }
+    std::vector<vcl::text::Run> runs;
+    TextLayoutCache(sal_Unicode const* pStr, sal_Int32 const nEnd);
 };
 }
 
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index f6783f3cc1ca..93d4b02d7dc8 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -46,7 +46,7 @@ class SalGraphics;
 class PhysicalFontFace;
 class GenericSalLayout;
 enum class SalLayoutFlags;
-namespace vcl {
+namespace vcl::text {
     class TextLayoutCache;
 }
 
@@ -84,7 +84,7 @@ public:
     int                 mnEndCharPos;
 
     // performance hack
-    vcl::TextLayoutCache const* m_pTextLayoutCache;
+    vcl::text::TextLayoutCache const* m_pTextLayoutCache;
 
     // positioning related inputs
     const DeviceCoordinate* mpDXArray;     // in pixel units
@@ -98,7 +98,7 @@ public:
                 ImplLayoutArgs( const OUString& rStr,
                                 int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags,
                                 const LanguageTag& rLanguageTag,
-                                vcl::TextLayoutCache const* pLayoutCache);
+                                vcl::text::TextLayoutCache const* pLayoutCache);
 
     void        SetLayoutWidth( DeviceCoordinate nWidth )       { mnLayoutWidth = nWidth; }
     void        SetDXArray( const DeviceCoordinate* pDXArray )  { mpDXArray = pDXArray; }
@@ -171,7 +171,7 @@ public:
     void            AdjustLayout(ImplLayoutArgs&) final override;
     bool            LayoutText(ImplLayoutArgs&, const SalLayoutGlyphsImpl*) final override;
     void            DrawText(SalGraphics&) const final override;
-    static std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&);
+    static std::shared_ptr<vcl::text::TextLayoutCache> CreateTextLayoutCache(OUString const&);
     SalLayoutGlyphs GetGlyphs() const final override;
 
     bool            IsKashidaPosValid(int nCharPos) const final override;
diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index 0db15435a675..548690674f47 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -382,10 +382,10 @@ void VclTextTest::testVerticalText()
 void VclTextTest::testTextLayoutCache()
 {
     OUString sTestString = u"The quick brown fox\n jumped over the lazy dogالعاشر";
-    vcl::TextLayoutCache cache(sTestString.getStr(), sTestString.getLength());
+    vcl::text::TextLayoutCache cache(sTestString.getStr(), sTestString.getLength());
 
-    vcl::Run run1 = cache.runs[0];
-    vcl::Run run2 = cache.runs[1];
+    vcl::text::Run run1 = cache.runs[0];
+    vcl::text::Run run2 = cache.runs[1];
 
     bool bCorrectRuns = (cache.runs.size() == 2);
     CPPUNIT_ASSERT_MESSAGE("Wrong number of runs", bCorrectRuns);
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 4adf864a933b..b2d332c82958 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -150,9 +150,9 @@ namespace {
 
 } // namespace
 
-std::shared_ptr<vcl::TextLayoutCache> GenericSalLayout::CreateTextLayoutCache(OUString const& rString)
+std::shared_ptr<vcl::text::TextLayoutCache> GenericSalLayout::CreateTextLayoutCache(OUString const& rString)
 {
-    return std::make_shared<vcl::TextLayoutCache>(rString.getStr(), rString.getLength());
+    return std::make_shared<vcl::text::TextLayoutCache>(rString.getStr(), rString.getLength());
 }
 
 SalLayoutGlyphs GenericSalLayout::GetGlyphs() const
@@ -278,15 +278,15 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm
     const int nLength = rArgs.mrStr.getLength();
     const sal_Unicode *pStr = rArgs.mrStr.getStr();
 
-    std::unique_ptr<vcl::TextLayoutCache> pNewScriptRun;
-    vcl::TextLayoutCache const* pTextLayout;
+    std::unique_ptr<vcl::text::TextLayoutCache> pNewScriptRun;
+    vcl::text::TextLayoutCache const* pTextLayout;
     if (rArgs.m_pTextLayoutCache)
     {
         pTextLayout = rArgs.m_pTextLayoutCache; // use cache!
     }
     else
     {
-        pNewScriptRun.reset(new vcl::TextLayoutCache(pStr, rArgs.mnEndCharPos));
+        pNewScriptRun.reset(new vcl::text::TextLayoutCache(pStr, rArgs.mnEndCharPos));
         pTextLayout = pNewScriptRun.get();
     }
 
@@ -342,7 +342,7 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm
         size_t k = 0;
         for (; k < pTextLayout->runs.size(); ++k)
         {
-            vcl::Run const& rRun(pTextLayout->runs[k]);
+            vcl::text::Run const& rRun(pTextLayout->runs[k]);
             if (rRun.nStart <= nCurrentPos && nCurrentPos < rRun.nEnd)
             {
                 break;
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 7b8f2c2a2a05..a993b8131ca4 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -387,7 +387,7 @@ bool ImplLayoutRuns::GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRightToLef
 
 ImplLayoutArgs::ImplLayoutArgs(const OUString& rStr,
     int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags, const LanguageTag& rLanguageTag,
-    vcl::TextLayoutCache const*const pLayoutCache)
+    vcl::text::TextLayoutCache const*const pLayoutCache)
 :
     maLanguageTag( rLanguageTag ),
     mnFlags( nFlags ),
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index d4d73d817654..b8cc324e14e9 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -836,7 +836,7 @@ void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr,
 }
 
 tools::Long OutputDevice::GetTextWidth( const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen,
-     vcl::TextLayoutCache const*const pLayoutCache,
+     vcl::text::TextLayoutCache const*const pLayoutCache,
      SalLayoutGlyphs const*const pSalLayoutCache) const
 {
 
@@ -908,7 +908,7 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr,
 
 tools::Long OutputDevice::GetTextArray( const OUString& rStr, tools::Long* pDXAry,
                                  sal_Int32 nIndex, sal_Int32 nLen,
-                                 vcl::TextLayoutCache const*const pLayoutCache,
+                                 vcl::text::TextLayoutCache const*const pLayoutCache,
                                  SalLayoutGlyphs const*const pSalLayoutCache) const
 {
     if( nIndex >= rStr.getLength() )
@@ -1101,7 +1101,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr,
                                                     const sal_Int32 nMinIndex, const sal_Int32 nLen,
                                                     DeviceCoordinate nPixelWidth, const DeviceCoordinate* pDXArray,
                                                     SalLayoutFlags nLayoutFlags,
-         vcl::TextLayoutCache const*const pLayoutCache) const
+         vcl::text::TextLayoutCache const*const pLayoutCache) const
 {
     assert(nMinIndex >= 0);
     assert(nLen >= 0);
@@ -1201,7 +1201,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
                                     sal_Int32 nMinIndex, sal_Int32 nLen,
                                     const Point& rLogicalPos, tools::Long nLogicalWidth,
                                     const tools::Long* pDXArray, SalLayoutFlags flags,
-         vcl::TextLayoutCache const* pLayoutCache,
+         vcl::text::TextLayoutCache const* pLayoutCache,
          const SalLayoutGlyphs* pGlyphs) const
 {
     if (pGlyphs && !pGlyphs->IsValid())
@@ -1313,7 +1313,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
     return pSalLayout;
 }
 
-std::shared_ptr<vcl::TextLayoutCache> OutputDevice::CreateTextLayoutCache(
+std::shared_ptr<vcl::text::TextLayoutCache> OutputDevice::CreateTextLayoutCache(
         OUString const& rString)
 {
     return GenericSalLayout::CreateTextLayoutCache(rString);
@@ -1333,7 +1333,7 @@ bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, sal_
 sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWidth,
                                        sal_Int32 nIndex, sal_Int32 nLen,
                                        tools::Long nCharExtra,
-         vcl::TextLayoutCache const*const pLayoutCache,
+         vcl::text::TextLayoutCache const*const pLayoutCache,
          const SalLayoutGlyphs* pGlyphs) const
 {
     std::unique_ptr<SalLayout> pSalLayout = ImplLayout( rStr, nIndex, nLen,
@@ -1365,7 +1365,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWid
                                        sal_Unicode nHyphenChar, sal_Int32& rHyphenPos,
                                        sal_Int32 nIndex, sal_Int32 nLen,
                                        tools::Long nCharExtra,
-         vcl::TextLayoutCache const*const pLayoutCache) const
+         vcl::text::TextLayoutCache const*const pLayoutCache) const
 {
     rHyphenPos = -1;
 
diff --git a/vcl/source/text/TextLayoutCache.cxx b/vcl/source/text/TextLayoutCache.cxx
new file mode 100644
index 000000000000..00e9f9405358
--- /dev/null
+++ b/vcl/source/text/TextLayoutCache.cxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <scrptrun.h>
+#include <TextLayoutCache.hxx>
+
+namespace vcl::text
+{
+TextLayoutCache::TextLayoutCache(sal_Unicode const* pStr, sal_Int32 const nEnd)
+{
+    vcl::ScriptRun aScriptRun(reinterpret_cast<const UChar*>(pStr), nEnd);
+    while (aScriptRun.next())
+    {
+        runs.emplace_back(aScriptRun.getScriptStart(), aScriptRun.getScriptEnd(),
+                          aScriptRun.getScriptCode());
+    }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/source/window/window3.cxx b/vcl/source/window/window3.cxx
index 371b4066ed19..5b8dd5cff4ec 100644
--- a/vcl/source/window/window3.cxx
+++ b/vcl/source/window/window3.cxx
@@ -64,7 +64,7 @@ const Wallpaper& Window::GetBackground() const { return GetOutDev()->GetBackgrou
 bool Window::IsBackground() const { return GetOutDev()->IsBackground(); }
 tools::Long Window::GetTextHeight() const { return GetOutDev()->GetTextHeight(); }
 tools::Long Window::GetTextWidth(const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen,
-                                 vcl::TextLayoutCache const* pCache,
+                                 vcl::text::TextLayoutCache const* pCache,
                                  SalLayoutGlyphs const* const pLayoutCache) const
 {
     return GetOutDev()->GetTextWidth(rStr, nIndex, nLen, pCache, pLayoutCache);


More information about the Libreoffice-commits mailing list