[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 16 12:05:12 UTC 2019


 sw/qa/extras/layout/layout.cxx |   31 +++++++++++++++++++++++++++++++
 sw/source/core/text/txtfrm.cxx |   13 ++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)

New commits:
commit 8072a926da2a02dfaf3fa848a2976634641a594f
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Apr 15 21:01:11 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Apr 16 14:04:33 2019 +0200

    tdf#124521 sw btlr writing mode render: fix paint rectangle on scroll
    
    By implementing btlr support in
    SwTextFrame::SwitchVerticalToHorizontal(SwRect), so not only
    invalidation but paint rectangle is also correct, which means actual
    text painting happens.
    
    Change-Id: I4215799ff63c93b300e4e8f97c6824f75d7c5401
    Reviewed-on: https://gerrit.libreoffice.org/70797
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index ff06af442bff..e44acc8ba1c0 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -22,6 +22,7 @@
 #include <wrtsh.hxx>
 #include <edtwin.hxx>
 #include <view.hxx>
+#include <txtfrm.hxx>
 
 static char const DATA_DIRECTORY[] = "/sw/qa/extras/layout/data/";
 
@@ -2839,6 +2840,36 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrCell)
         ss << "selection rectangle " << rRect << " is not inside cell rectangle " << aCellRect;
         CPPUNIT_ASSERT_MESSAGE(ss.str(), aCellRect.IsInside(rRect));
     }
+
+    // Make sure that the correct rectangle gets repainted on scroll.
+    SwFrame* pPageFrame = pLayout->GetLower();
+    CPPUNIT_ASSERT(pPageFrame->IsPageFrame());
+
+    SwFrame* pBodyFrame = pPageFrame->GetLower();
+    CPPUNIT_ASSERT(pBodyFrame->IsBodyFrame());
+
+    SwFrame* pTabFrame = pBodyFrame->GetLower();
+    CPPUNIT_ASSERT(pTabFrame->IsTabFrame());
+
+    SwFrame* pRowFrame = pTabFrame->GetLower();
+    CPPUNIT_ASSERT(pRowFrame->IsRowFrame());
+
+    SwFrame* pCellFrame = pRowFrame->GetLower();
+    CPPUNIT_ASSERT(pCellFrame->IsCellFrame());
+
+    SwFrame* pFrame = pCellFrame->GetLower();
+    CPPUNIT_ASSERT(pFrame->IsTextFrame());
+
+    SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pFrame);
+    pTextFrame->SwapWidthAndHeight();
+    // Mimic what normally SwTextFrame::PaintSwFrame() does:
+    SwRect aRect(4207, 2273, 269, 572);
+    pTextFrame->SwitchVerticalToHorizontal(aRect);
+    // Without the accompanying fix in place, this test would have failed with:
+    // Expected: 572x269@(1691,4217)
+    // Actual  : 572x269@(2263,4217)
+    // i.e. the paint rectangle position was incorrect, text was not painted on scrolling up.
+    CPPUNIT_ASSERT_EQUAL(SwRect(1691, 4217, 572, 269), aRect);
 #endif
 }
 
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index f71fee6ec9d5..66beb06d3928 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -595,7 +595,18 @@ void SwTextFrame::SwitchVerticalToHorizontal( SwRect& rRect ) const
             nOfstX = getFrameArea().Left() + getFrameArea().Width() - ( rRect.Left() + rRect.Width() );
     }
 
-    const long nOfstY = rRect.Top() - getFrameArea().Top();
+    long nOfstY;
+    if (IsVertLRBT())
+    {
+        // Note that mbIsSwapped only affects the frame area, not rRect, so rRect.Height() is used
+        // here unconditionally.
+        if (mbIsSwapped)
+            nOfstY = getFrameArea().Top() + getFrameArea().Width() - (rRect.Top() + rRect.Height());
+        else
+            nOfstY = getFrameArea().Top() + getFrameArea().Height() - (rRect.Top() + rRect.Height());
+    }
+    else
+        nOfstY = rRect.Top() - getFrameArea().Top();
     const long nWidth = rRect.Height();
     const long nHeight = rRect.Width();
 


More information about the Libreoffice-commits mailing list