[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/inc vcl/source

Khaled Hosny khaledhosny at eglug.org
Wed Sep 14 06:28:16 UTC 2016


 vcl/inc/CommonSalLayout.hxx        |    3 ++
 vcl/inc/sallayout.hxx              |    4 +-
 vcl/source/gdi/CommonSalLayout.cxx |   50 +++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 2 deletions(-)

New commits:
commit 380a5d8ebe08d4431214e84b0f1b8d43f4730fd0
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sun Sep 11 10:25:46 2016 +0200

    Override GetCharWidths and ApplyDXArray in CSL
    
    A much simpler and saner implementation. This also unbreaks Awami
    Nastaliq.
    
    Break kashida justification, will need to rewrite that one as well.
    
    Change-Id: I843679e937f2881e77df61f5cbd9516b6df1b3b6

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 34cca79..f9ba70c 100755
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -65,4 +65,7 @@ public:
     virtual bool            LayoutText(ImplLayoutArgs&) override;
     virtual void            DrawText( SalGraphics& ) const override;
     std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const override;
+
+    virtual bool            GetCharWidths(DeviceCoordinate* pCharWidths) const;
+    virtual void            ApplyDXArray(ImplLayoutArgs&);
 };
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 7b044fb..8f0ad9b 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -326,7 +326,7 @@ public:
     void            AppendGlyph( const GlyphItem& );
     void            Reserve(int size) { m_GlyphItems.reserve(size + 1); }
     virtual void    AdjustLayout( ImplLayoutArgs& ) override;
-    void    ApplyDXArray( ImplLayoutArgs& );
+    virtual void    ApplyDXArray( ImplLayoutArgs& );
     void    Justify( DeviceCoordinate nNewWidth );
     void            KashidaJustify( long nIndex, int nWidth );
     void            ApplyAsianKerning(const OUString& rStr);
@@ -352,7 +352,7 @@ protected:
     virtual void    DropGlyph( int nStart ) override;
     virtual void    Simplify( bool bIsBase ) override;
 
-    bool            GetCharWidths( DeviceCoordinate* pCharWidths ) const;
+    virtual bool    GetCharWidths( DeviceCoordinate* pCharWidths ) const;
 
     std::vector<GlyphItem>     m_GlyphItems;
 
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 71fc186..8d4bfbe 100755
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -483,3 +483,53 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 
     return true;
 }
+
+bool CommonSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const
+{
+    int nCharCount = mnEndCharPos - mnMinCharPos;
+
+    for (int i = 0; i < nCharCount; ++i)
+        pCharWidths[i] = 0;
+
+    for (auto const& aGlyphItem : m_GlyphItems)
+        pCharWidths[aGlyphItem.mnCharPos - mnMinCharPos] += aGlyphItem.mnNewWidth;
+
+    return true;
+}
+
+void CommonSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
+{
+    int nCharCount = mnEndCharPos - mnMinCharPos;
+    long pOldCharWidths[nCharCount];
+    long pNewCharWidths[nCharCount];
+
+    GetCharWidths(pOldCharWidths);
+
+    for (int i = 0; i < nCharCount; ++i)
+    {
+        if (i == 0)
+          pNewCharWidths[i] = rArgs.mpDXArray[i];
+        else
+          pNewCharWidths[i] = rArgs.mpDXArray[i] - rArgs.mpDXArray[i - 1];
+    }
+
+    long nDelta = 0;
+    size_t i = 0;
+    while (i < m_GlyphItems.size())
+    {
+        int nCharPos = m_GlyphItems[i].mnCharPos - mnMinCharPos;
+        long nDiff = pNewCharWidths[nCharPos] - pOldCharWidths[nCharPos];
+
+        m_GlyphItems[i].maLinearPos.X() += nDelta;
+        size_t j = i;
+        while (++j < m_GlyphItems.size())
+        {
+            if (m_GlyphItems[j].mnCharPos != m_GlyphItems[i].mnCharPos)
+              break;
+            m_GlyphItems[j].maLinearPos.X() += nDelta;
+        }
+
+        nDelta += nDiff;
+        i = j;
+    }
+}


More information about the Libreoffice-commits mailing list