[Libreoffice-commits] core.git: vcl/inc vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 27 20:04:24 UTC 2020


 vcl/inc/salgdi.hxx              |    4 +++-
 vcl/source/gdi/salgdilayout.cxx |   28 ++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 5 deletions(-)

New commits:
commit 0c5f58114cea0fbb7c638726b1ce6bc214fea504
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Nov 27 11:47:35 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Nov 27 21:03:47 2020 +0100

    with RTL UI the LTR scrollbar in 'gen' calc is rendered incorrectly
    
    this is noticable since...
    
    commit 4deadc3c78949c18bb886eb1f66caa8f3cd7a2df
    Date:   Fri Sep 25 13:30:11 2020 +0200
    
        disentangle AA and B2D use in VCL drawing
    
    but is probably a problem since around...
    
    commit b5f081e1ac14f60497f62a27be86b07b0baa42f7
    Date:   Thu Aug 30 23:41:36 2018 +0200
    
        Support RTL layout in VCL using Matrices
    
    Change-Id: I6bcad30982ee1eaee96bc6721d73e1e545f0d86a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106761
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 9fa687123bfa..6ed360105d24 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -596,7 +596,9 @@ private:
 
     // for buffering the Mirror-Matrix, see ::getMirror
     basegfx::B2DHomMatrix       m_aLastMirror;
-    tools::Long                        m_aLastMirrorW;
+    tools::Long                 m_aLastMirrorW;
+    tools::Long                 m_nLastMirrorDeviceLTRButBiDiRtlTranslate;
+    bool                        m_bLastMirrorDeviceLTRButBiDiRtlSet;
 
 protected:
     /// flags which hold the SetAntialiasing() value from OutputDevice
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 89089d9755a2..5638cb9bb856 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -58,6 +58,8 @@ SalGraphics::SalGraphics()
 :   m_nLayout( SalLayoutFlags::NONE ),
     m_aLastMirror(),
     m_aLastMirrorW(0),
+    m_nLastMirrorDeviceLTRButBiDiRtlTranslate(0),
+    m_bLastMirrorDeviceLTRButBiDiRtlSet(false),
     m_bAntiAlias(false)
 {
     // read global RTL settings
@@ -316,14 +318,33 @@ const basegfx::B2DHomMatrix& SalGraphics::getMirror( const OutputDevice* i_pOutD
     const tools::Long w = GetDeviceWidth(i_pOutDev);
     SAL_WARN_IF( !w, "vcl", "missing graphics width" );
 
-    if(w != m_aLastMirrorW)
+    const bool bMirrorDeviceLTRButBiDiRtlSet = i_pOutDev && !i_pOutDev->IsRTLEnabled();
+    tools::Long nMirrorDeviceLTRButBiDiRtlTranslate(0);
+    if (bMirrorDeviceLTRButBiDiRtlSet)
+        nMirrorDeviceLTRButBiDiRtlTranslate = w - i_pOutDev->GetOutputWidthPixel() - (2 * i_pOutDev->GetOutOffXPixel());
+
+    // if the device width, or mirror state of the device changed, then m_aLastMirror is invalid
+    bool bLastMirrorValid = w == m_aLastMirrorW && bMirrorDeviceLTRButBiDiRtlSet == m_bLastMirrorDeviceLTRButBiDiRtlSet;
+    if (bLastMirrorValid && bMirrorDeviceLTRButBiDiRtlSet)
+    {
+        // if the device is in in the unusual mode of a LTR device, but layout flags of SalLayoutFlags::BiDiRtl are
+        // in use, then the m_aLastMirror is invalid if the distance it should translate has changed
+        bLastMirrorValid = nMirrorDeviceLTRButBiDiRtlTranslate == m_nLastMirrorDeviceLTRButBiDiRtlTranslate;
+    }
+
+    if (!bLastMirrorValid)
     {
         const_cast<SalGraphics*>(this)->m_aLastMirrorW = w;
+        const_cast<SalGraphics*>(this)->m_bLastMirrorDeviceLTRButBiDiRtlSet = bMirrorDeviceLTRButBiDiRtlSet;
+        const_cast<SalGraphics*>(this)->m_nLastMirrorDeviceLTRButBiDiRtlTranslate = nMirrorDeviceLTRButBiDiRtlTranslate;
 
         if(w)
         {
-            if(nullptr != i_pOutDev && !i_pOutDev->IsRTLEnabled())
+            if (bMirrorDeviceLTRButBiDiRtlSet)
             {
+                /* This path gets exercised in calc's RTL UI (e.g. SAL_RTL_ENABLED=1)
+                   with its LTR horizontal scrollbar */
+
                 // Original code was (removed here already pOutDevRef->i_pOutDev):
                 //      // mirror this window back
                 //      double devX = w-i_pOutDev->GetOutputWidthPixel()-i_pOutDev->GetOutOffXPixel();   // re-mirrored mnOutOffX
@@ -332,8 +353,7 @@ const basegfx::B2DHomMatrix& SalGraphics::getMirror( const OutputDevice* i_pOutD
                 // that this works as before, but I have reduced this (by re-placing and re-formatting) to
                 // a simple translation:
                 const_cast<SalGraphics*>(this)->m_aLastMirror = basegfx::utils::createTranslateB2DHomMatrix(
-                    w - i_pOutDev->GetOutputWidthPixel() - (2 * i_pOutDev->GetOutOffXPixel()),
-                    0.0);
+                    nMirrorDeviceLTRButBiDiRtlTranslate, 0.0);
             }
             else
             {


More information about the Libreoffice-commits mailing list