[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - oox/qa oox/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 18 14:32:44 UTC 2020


 oox/qa/unit/data/shape-non-autosize-with-text.docx |binary
 oox/qa/unit/vml.cxx                                |   18 ++++++++++++++++++
 oox/source/vml/vmlshape.cxx                        |    6 +++---
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 29ccc5f041562305c559d0e84ed90af9ccf302f7
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 16 21:18:25 2020 +0100
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Wed Mar 18 15:32:20 2020 +0100

    tdf#131118 VML import: fix size of non-autosize shapes containing text
    
    Regression from commit b92293b3943423324064a8513c2e114d18817179
    (tdf#103983 VML import: handle <v:textbox
    style="mso-fit-shape-to-text:t">, 2020-01-20), the problem was that in
    case we disable autosize too late, then the size will be already set
    during adding text to the shape.
    
    Do it before adding text, this way adding text won't change the shape
    size, so it'll be correct at the end of the import.
    
    (cherry picked from commit 4ee7ee1c4a515479bc174543af4dbc400035c0ba)
    
    Change-Id: I9410fc695c3edfa5089d845864bf237e71c533c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90602
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/oox/qa/unit/data/shape-non-autosize-with-text.docx b/oox/qa/unit/data/shape-non-autosize-with-text.docx
new file mode 100644
index 000000000000..b9ae501f4b93
Binary files /dev/null and b/oox/qa/unit/data/shape-non-autosize-with-text.docx differ
diff --git a/oox/qa/unit/vml.cxx b/oox/qa/unit/vml.cxx
index 01539abdfbda..b83334eeadc6 100644
--- a/oox/qa/unit/vml.cxx
+++ b/oox/qa/unit/vml.cxx
@@ -103,6 +103,24 @@ CPPUNIT_TEST_FIXTURE(OoxVmlTest, testSpt202ShapeType)
     CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.TextShape"), xShape->getShapeType());
 }
 
+CPPUNIT_TEST_FIXTURE(OoxVmlTest, testShapeNonAutosizeWithText)
+{
+    // Load a document which has a group shape, containing a single child.
+    // 17.78 cm is the full group shape width, 19431/64008 is the child shape's relative width inside
+    // that, so 5.3975 cm should be the shape width.
+    load("shape-non-autosize-with-text.docx");
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+                                                 uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xGroup(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Actual  : 1115
+    // - Expected: 5398
+    // because the width was determined using its text size, not using the explicit size.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5398), xShape->getSize().Width);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 82cacfdcaf68..45409c3f23a3 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -784,6 +784,9 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
             eTextVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM;
         PropertySet(xShape).setAnyProperty(PROP_TextVerticalAdjust, makeAny(eTextVerticalAdjust));
 
+        PropertySet(xShape).setAnyProperty(PROP_TextAutoGrowHeight,
+                                           makeAny(maTypeModel.mbAutoHeight));
+
         if (getTextBox())
         {
             getTextBox()->convert(xShape);
@@ -797,9 +800,6 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
                 xShape->setSize(aSize);
             }
         }
-
-        PropertySet(xShape).setAnyProperty(PROP_TextAutoGrowHeight,
-                                           makeAny(maTypeModel.mbAutoHeight));
     }
 
     // Import Legacy Fragments (if any)


More information about the Libreoffice-commits mailing list