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

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 15 10:12:19 UTC 2020


 cui/source/tabpages/swpossizetabpage.cxx                      |    4 -
 oox/source/vml/vmlshape.cxx                                   |    8 +-
 sw/qa/core/objectpositioning/data/vml-vertical-alignment.docx |binary
 sw/qa/core/objectpositioning/objectpositioning.cxx            |   40 ++++++++++
 4 files changed, 48 insertions(+), 4 deletions(-)

New commits:
commit cf0c04d5fc85acbe6cbeb090de6a739a0d5a8d30
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Thu Sep 10 14:13:37 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Tue Sep 15 12:11:39 2020 +0200

    tdf#103611 sw: fix vertical alignment to page bottom margin
    
    Allow to align objects to page bottom margin vertically in
    Position and Size settings. Fix also DOCX import of VML shapes.
    
    Co-authored-by: Attila Szűcs (NISZ)
    
    Change-Id: I78db2553ee9d963b18a2d580b1cbb76c1917ac0b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102379
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx
index e78826bc5105..803b56081007 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -308,7 +308,7 @@ static FrmMap aHCharHtmlAbsMap[] =
 // #i18732# - allow vertical alignment at page areas
 // #i22341# - handle <LB::RelChar> on its own
 constexpr auto VERT_CHAR_REL = LB::VertFrame|LB::VertPrintArea|
-                                      LB::RelPageFrame|LB::RelPagePrintArea;
+                                      LB::RelPageFrame|LB::RelPagePrintArea|LB::RelPagePrintAreaBottom;
 
 static FrmMap aVCharMap[] =
 {
@@ -323,7 +323,7 @@ static FrmMap aVCharMap[] =
     {SvxSwFramePosString::BOTTOM,        SvxSwFramePosString::BOTTOM,         VertOrientation::BOTTOM,        VERT_CHAR_REL|LB::RelChar},
     {SvxSwFramePosString::BELOW,         SvxSwFramePosString::BELOW,          VertOrientation::CHAR_BOTTOM,   LB::RelChar},
     {SvxSwFramePosString::CENTER_VERT,   SvxSwFramePosString::CENTER_VERT,    VertOrientation::CENTER,        VERT_CHAR_REL|LB::RelChar},
-    {SvxSwFramePosString::FROMTOP,       SvxSwFramePosString::FROMTOP,        VertOrientation::NONE,          VERT_CHAR_REL|LB::RelPagePrintAreaBottom},
+    {SvxSwFramePosString::FROMTOP,       SvxSwFramePosString::FROMTOP,        VertOrientation::NONE,          VERT_CHAR_REL},
     {SvxSwFramePosString::FROMBOTTOM,    SvxSwFramePosString::FROMBOTTOM,     VertOrientation::NONE,          LB::RelChar|LB::VertLine},
     {SvxSwFramePosString::TOP,           SvxSwFramePosString::TOP,            VertOrientation::LINE_TOP,      LB::VertLine},
     {SvxSwFramePosString::BOTTOM,        SvxSwFramePosString::BOTTOM,         VertOrientation::LINE_BOTTOM,   LB::VertLine},
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 905548bafb9e..eb0f886c32b6 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -608,6 +608,10 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rType
         {
             rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_PRINT_AREA);
         }
+        else if (rTypeModel.maPositionVerticalRelative == "bottom-margin-area")
+        {
+            rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_PRINT_AREA_BOTTOM);
+        }
         else
         {
             rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::FRAME);
@@ -663,9 +667,9 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rType
     else if ( rTypeModel.maPositionVertical == "bottom" )
         rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::BOTTOM));
     else if ( rTypeModel.maPositionVertical == "inside" )
-        rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::LINE_TOP));
+        rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::TOP));
     else if ( rTypeModel.maPositionVertical == "outside" )
-        rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::LINE_BOTTOM));
+        rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::BOTTOM));
 
     lcl_setSurround( rPropSet, rTypeModel, rGraphicHelper );
 }
diff --git a/sw/qa/core/objectpositioning/data/vml-vertical-alignment.docx b/sw/qa/core/objectpositioning/data/vml-vertical-alignment.docx
new file mode 100644
index 000000000000..36ed5fdfb063
Binary files /dev/null and b/sw/qa/core/objectpositioning/data/vml-vertical-alignment.docx differ
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx
index b6d06022fd7c..13a936500329 100644
--- a/sw/qa/core/objectpositioning/objectpositioning.cxx
+++ b/sw/qa/core/objectpositioning/objectpositioning.cxx
@@ -231,6 +231,46 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testInsideOutsideVertAlignBott
     // 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_TEST_FIXTURE(SwCoreObjectpositioningTest, testVMLVertAlignBottomMargin)
+{
+    // Load a document, with five shapes.
+    // The shapes align the top,center,bottom,outside and inside of page print area bottom.
+    // The height of page print area bottom is 4320 ~ 7.62cm.
+    // The size of shapes are 442 ~ 0.78cm
+    load(DATA_DIRECTORY, "vml-vertical-alignment.docx");
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    sal_Int32 nBodyBottom = getXPath(pXmlDoc, "//body/infos/bounds", "bottom").toInt32(); //11803
+    sal_Int32 nPageBottom = getXPath(pXmlDoc, "//page/infos/bounds", "bottom").toInt32(); //16123
+
+    sal_Int32 nFirstVMLShapeInside
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[1]/bounds", "top").toInt32(); //11802
+    sal_Int32 nSecondVMLShapeBottom
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[2]/bounds", "bottom").toInt32(); //16124
+    sal_Int32 nThirdVMLShapeCenterBottom
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[3]/bounds", "bottom").toInt32(); //14185
+    sal_Int32 nThirdVMLShapeCenterTop
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[3]/bounds", "top").toInt32(); //13741
+    sal_Int32 nFourthVMLShapeTop
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[4]/bounds", "top").toInt32(); //11802
+    sal_Int32 nFifthVMLShapeOutside
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject[5]/bounds", "bottom").toInt32(); //16124
+
+    // Verify that the distance between the bottom of body and top of first VMLshape is around 0cm. (align=inside)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nBodyBottom - nFirstVMLShapeInside);
+    // Verify that the distance between the bottom of page and bottom of second VMLshape is around 0cm. (align=bottom)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nSecondVMLShapeBottom - nPageBottom);
+    // Verify that the distance between the bottom of page and bottom of third VMLshape is around 3.4cm and
+    // verify that the distance between the bottom of body and top of third shape is around 3.4cm.(align=center)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1938), nPageBottom - nThirdVMLShapeCenterBottom);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1938), nThirdVMLShapeCenterTop - nBodyBottom);
+    // Verify that the distance between the bottom of body and top of fourth VMLshape is around 0cm. (align=top)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nBodyBottom - nFourthVMLShapeTop);
+    // Verify that the distance between the bottom of page and bottom of fifth shape is around 0cm. (align=outside)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nFifthVMLShapeOutside - nPageBottom);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list