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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 15 20:24:24 UTC 2019


 sw/qa/extras/layout/layout.cxx |   20 ++++++++++++++++++++
 sw/source/core/text/txtfrm.cxx |   30 ++++++++++++++++++++++++++----
 2 files changed, 46 insertions(+), 4 deletions(-)

New commits:
commit 61bb90aac5038b5ff051668f7ae86eb61658e4f3
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Feb 15 16:52:20 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Feb 15 21:23:57 2019 +0100

    sw btlr writing mode shell: fix cursor position
    
    By implementing the SwRect variant of
    SwTextFrame::SwitchHorizontalToVertical() for the IsVertLRBT() == true
    case.
    
    The blinking cursor position after doc load is now correct.
    
    Change-Id: I4862a6de286d3c0a34235fa0be8be2746b1a4151
    Reviewed-on: https://gerrit.libreoffice.org/67880
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index d29cc476f9cc..cb94560ab03a 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2816,6 +2816,26 @@ void SwLayoutWriter::testBtlrCell()
     // Actual  : 0', i.e. the AAA2 frame was not visible due to 0 width.
     pXmlDoc = parseLayoutDump();
     assertXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[2]/infos/bounds", "width", "269");
+
+    // Test the position of the cursor after doc load.
+    // We expect that it's inside the first text frame in the first cell.
+    // More precisely, this is a bottom to top vertical frame, so we expect it's at the start, which
+    // means it's at the lower half of the text frame rectangle (vertically).
+    SwWrtShell* pWrtShell = pShell->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    const SwRect& rCharRect = pWrtShell->GetCharRect();
+    SwTwips nFirstParaTop
+        = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[1]/infos/bounds", "top").toInt32();
+    SwTwips nFirstParaHeight
+        = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[1]/infos/bounds", "height")
+              .toInt32();
+    SwTwips nFirstParaMiddle = nFirstParaTop + nFirstParaHeight / 2;
+    SwTwips nFirstParaBottom = nFirstParaTop + nFirstParaHeight;
+    // Without the accompanying fix in place, this test would have failed: the lower half (vertical)
+    // range was 2273 -> 2835, the good vertical position is 2730, the bad one was 1830.
+    CPPUNIT_ASSERT_GREATER(nFirstParaMiddle, rCharRect.Top());
+    CPPUNIT_ASSERT_LESS(nFirstParaBottom, rCharRect.Top());
 #endif
 }
 
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 17d1d6f321fc..8902ca0483ca 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -478,8 +478,18 @@ void SwTextFrame::SwitchHorizontalToVertical( SwRect& rRect ) const
     long nOfstX, nOfstY;
     if ( IsVertLR() )
     {
-        nOfstX = rRect.Left() - getFrameArea().Left();
-        nOfstY = rRect.Top() - getFrameArea().Top();
+        if (IsVertLRBT())
+        {
+            // X and Y offsets here mean the position of the point that will be the top left corner
+            // after the switch.
+            nOfstX = rRect.Left() + rRect.Width() - getFrameArea().Left();
+            nOfstY = rRect.Top() - getFrameArea().Top();
+        }
+        else
+        {
+            nOfstX = rRect.Left() - getFrameArea().Left();
+            nOfstY = rRect.Top() - getFrameArea().Top();
+        }
     }
     else
     {
@@ -491,7 +501,12 @@ void SwTextFrame::SwitchHorizontalToVertical( SwRect& rRect ) const
     const long nHeight = rRect.Height();
 
     if ( IsVertLR() )
-        rRect.Left(getFrameArea().Left() + nOfstY);
+    {
+        if (IsVertLRBT())
+            rRect.Left(getFrameArea().Left() + nOfstY);
+        else
+            rRect.Left(getFrameArea().Left() + nOfstY);
+    }
     else
     {
         if ( mbIsSwapped )
@@ -501,7 +516,14 @@ void SwTextFrame::SwitchHorizontalToVertical( SwRect& rRect ) const
             rRect.Left( getFrameArea().Left() + getFrameArea().Width() - nOfstY );
     }
 
-    rRect.Top( getFrameArea().Top() + nOfstX );
+    if (IsVertLRBT())
+    {
+        SAL_WARN_IF(!mbIsSwapped, "sw.core",
+                    "SwTextFrame::SwitchHorizontalToVertical, IsVertLRBT, not swapped");
+        rRect.Top(getFrameArea().Top() + getFrameArea().Width() - nOfstX);
+    }
+    else
+        rRect.Top(getFrameArea().Top() + nOfstX);
     rRect.Width( nHeight );
     rRect.Height( nWidth );
 }


More information about the Libreoffice-commits mailing list