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

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 4 07:14:09 UTC 2020


 sw/qa/core/objectpositioning/data/inside-outside-vert-align.docx |binary
 sw/qa/core/objectpositioning/objectpositioning.cxx               |   20 ++++++++++
 writerfilter/source/dmapper/GraphicHelpers.cxx                   |    8 ++--
 3 files changed, 24 insertions(+), 4 deletions(-)

New commits:
commit d362c0625fa92e0f4d4472f197bd1d68fba522f1
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Wed Sep 2 15:59:23 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Sep 4 09:13:28 2020 +0200

    tdf#136354 DOCX import: fix vertical mirrored alignment on bottom margin
    
    The relative mirrored vertical alignment (INSIDE and OUTSIDE) of
    bottom page margin wasn't handled.
    
    Note: this fix doesn't check mirroring (if it's possible to mirror
    vertically either, for example, by mixing portrait and landscape
    mode in a document), only support INSIDE as OUTSIDE as alternative
    names of TOP and BOTTOM in case of alignment to bottom margins.
    
    Follow-up of commit d54264e34c1ccc0eaf4178ab165a843028500223
    (tdf#133071 DOCX import: fix vertical alignment to bottom page margin)
    
    Co-authored-by: Attila Szűcs (NISZ)
    
    Change-Id: I6d844f57505bcda1faa7dd6112d1cda666c3ac07
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101934
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/core/objectpositioning/data/inside-outside-vert-align.docx b/sw/qa/core/objectpositioning/data/inside-outside-vert-align.docx
new file mode 100644
index 000000000000..15d2dca0775e
Binary files /dev/null and b/sw/qa/core/objectpositioning/data/inside-outside-vert-align.docx differ
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx
index 21151f3b92de..b6d06022fd7c 100644
--- a/sw/qa/core/objectpositioning/objectpositioning.cxx
+++ b/sw/qa/core/objectpositioning/objectpositioning.cxx
@@ -211,6 +211,26 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testVertAlignBottomMarginWithF
     // Verify that the distance between the bottom of body and top of third shape is around 0cm. (align=top)
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), nThirdShapeTop - nBodyBottom);
 }
+
+CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testInsideOutsideVertAlignBottomMargin)
+{
+    // Load a document, with two shapes.
+    // The shapes align the outside and inside of page print area bottom.
+    load(DATA_DIRECTORY, "inside-outside-vert-align.docx");
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    sal_Int32 nBodyBottom = getXPath(pXmlDoc, "//body/infos/bounds", "bottom").toInt32(); //15704
+    sal_Int32 nPageBottom = getXPath(pXmlDoc, "//page/infos/bounds", "bottom").toInt32(); //17121
+    sal_Int32 nFirstShapeOutside
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[1]/bounds", "bottom").toInt32(); //17098
+    sal_Int32 nSecondShapeInside
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[2]/bounds", "top").toInt32(); //15694
+
+    // Verify that the distance between the bottom of page and bottom of first shape is around 0cm. (align=outside)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(23), nPageBottom - nFirstShapeOutside);
+    // Verify that the distance between the bottom of body and top of second shape is around 0cm. (align=inside)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10), nBodyBottom - nSecondShapeInside);
+}
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index a2275d95be4a..7051f3c45b47 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -176,10 +176,10 @@ void PositionHandler::lcl_sprm(Sprm& rSprm)
                 m_nOrient = text::VertOrientation::BOTTOM;
             else if (rAlign == "center")
                 m_nOrient = text::VertOrientation::CENTER;
-            else if (rAlign == "inside")
-                m_nOrient = text::VertOrientation::NONE;
-            else if (rAlign == "outside")
-                m_nOrient = text::VertOrientation::NONE;
+            else if (rAlign == "inside" && m_nRelation == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
+                m_nOrient = text::VertOrientation::TOP;
+            else if (rAlign == "outside" && m_nRelation == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
+                m_nOrient = text::VertOrientation::BOTTOM;
             rAlign.clear();
             break;
         }


More information about the Libreoffice-commits mailing list