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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Feb 14 17:16:39 UTC 2019


 sw/qa/extras/layout/layout.cxx |    8 ++++++++
 sw/source/core/text/itrtxt.cxx |    8 +++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit a0bb480364c80192111ecab3501d63584e651ea3
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Feb 14 15:35:12 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Feb 14 18:16:10 2019 +0100

    sw btlr writing mode layout: fix baseline offset
    
    The problem was that the x position of the btlr text had a 159 twips
    difference (it was too close to the cell border), since the text portion
    height -> baseline offset calculation worked with the descent, not with
    the ascent.
    
    The position of the text now matches exactly what Word does.
    
    As a side-effect this means that multiple portions in a line and also
    multiple lines in a text frame now work correctly.
    
    Change-Id: Ic139db328e2a913e5cae4026886c3410cdab357d
    Reviewed-on: https://gerrit.libreoffice.org/67823
    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 77c826dba30d..1c8ca7aa6385 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2804,6 +2804,14 @@ void SwLayoutWriter::testBtlrCell()
     // the orientation was 0 (layout did not take btlr direction request from
     // doc model).
     assertXPath(pXmlDoc, "//font[1]", "orientation", "900");
+
+#ifndef MACOSX // macOS fails with actual == 2662 for some reason.
+    // Without the accompanying fix in place, this test would have failed with 'Expected: 1915;
+    // Actual  : 1756', i.e. the AAA text was too close to the left cell border due to an ascent vs
+    // descent mismatch when calculating the baseline offset of the text portion.
+    assertXPath(pXmlDoc, "//textarray[1]", "x", "1915");
+    assertXPath(pXmlDoc, "//textarray[1]", "y", "2707");
+#endif
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index dd5d7efe39e9..c975a6863263 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -274,7 +274,13 @@ sal_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
             case SvxParaVertAlignItem::Align::Automatic :
                 if ( bAutoToCentered || GetInfo().GetTextFrame()->IsVertical() )
                 {
-                    if( GetInfo().GetTextFrame()->IsVertLR() )
+                    // Vertical text has these cases to calculate the baseline:
+                    // - Implicitly TB and RL: the origo is the top right corner, offset is the
+                    //   ascent.
+                    // - (Implicitly TB and) LR: the origo is the top left corner, offset is the
+                    //   descent.
+                    // - BT and LR: the origo is the bottom left corner, offset is the ascent.
+                    if (GetInfo().GetTextFrame()->IsVertLR() && !GetInfo().GetTextFrame()->IsVertLRBT())
                             nOfst += rLine.Height() - ( rLine.Height() - nPorHeight ) / 2 - nPorAscent;
                     else
                             nOfst += ( rLine.Height() - nPorHeight ) / 2 + nPorAscent;


More information about the Libreoffice-commits mailing list