oox/source/drawingml/shape.cxx | 9 ------ sw/qa/extras/ooxmlimport/data/tdf118693.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 +------- sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 37 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 18 deletions(-)
New commits: commit ddf13fc815903238c90aa963af7e0ea96fe7280d Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Mar 18 00:48:49 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Mar 18 15:20:10 2021 +0100 tdf#118693: no need to use convertMm100ToTwip() for line shapes anymore It was introduced in 11129d89b152db54c86bb2bda58c24b8abb6c5a8 < tdf#85232 WPG import: fix handling of line shapes > and later in 36bade04d3780bc54c51b46bb0b63e69789658a5 < tdf106792 Get rid of SvxShapePolyPolygonBezier > ForceMetricToItemPoolMetric was added to SvxShapePolyPolygon::setPropertyValueImpl to convert from 100thmm to twips as can be read in the comment in testTdf85232 With this change, xShape->getPosition().X in testTdf85232 is 2267, which was already in twips Change-Id: I30b757885327a477213f96f8f84541971f435164 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112663 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit c9e5640c8fcad7beb42a66f9bee0252eee9fe323) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112619 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112671 diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 567564479846..5aeab36ba880 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -846,7 +846,6 @@ Reference< XShape > const & Shape::createAndInsert( uno::Sequence< awt::Point > aPointSequence( nNumPoints ); awt::Point* pPoints = aPointSequence.getArray(); uno::Reference<lang::XServiceInfo> xModelInfo(rFilterBase.getModel(), uno::UNO_QUERY); - bool bIsWriter = xModelInfo->supportsService("com.sun.star.text.TextDocument"); for( i = 0; i < nNumPoints; ++i ) { const basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) ); @@ -854,13 +853,7 @@ Reference< XShape > const & Shape::createAndInsert( // tdf#106792 Not needed anymore due to the change in SdrPathObj::NbcResize: // tdf#96674: Guard against zero width or height. - if (bIsWriter && bNoTranslation) - // Writer's draw page is in twips, and these points get passed - // to core without any unit conversion when Writer - // postprocesses only the group shape itself. - pPoints[i] = awt::Point(static_cast<sal_Int32>(convertMm100ToTwip(aPoint.getX())), static_cast<sal_Int32>(convertMm100ToTwip(aPoint.getY()))); - else - pPoints[i] = awt::Point(static_cast<sal_Int32>(aPoint.getX()), static_cast<sal_Int32>(aPoint.getY())); + pPoints[i] = awt::Point(static_cast<sal_Int32>(aPoint.getX()), static_cast<sal_Int32>(aPoint.getY())); } uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 ); aPolyPolySequence.getArray()[ 0 ] = aPointSequence; diff --git a/sw/qa/extras/ooxmlimport/data/tdf118693.docx b/sw/qa/extras/ooxmlimport/data/tdf118693.docx new file mode 100644 index 000000000000..4e832398bcd5 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf118693.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index f932e9739800..fe1b4ed5028d 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1315,16 +1315,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf85232, "tdf85232.docx") // Make sure we're not testing the ellipse child. CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.LineShape"), xShapeDescriptor->getShapeType()); - // tdf#106792 checked that during load of tdf85232.docx the method - // SvxShapePolyPolygon::setPropertyValueImpl is used three times. In - // that method, a call to ForceMetricToItemPoolMetric was missing so - // that the import did not convert the input values from 100thmm - // to twips what is needed due to the object residing in Writer. The - // UNO API by definition is in 100thmm. Result is that in SwXShape::getPosition - // the offset (aOffset) now is (0, 0) instead of an existing offset in - // the load of the document before (what is plausible for a GroupObject). - // Thus, I will adapt the result value here to the now (hopefully) correct one. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1630), xShape->getPosition().X); // was: 2267 + // This was 2900: horizontal position of the line was incorrect, the 3 children were not connected visually. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2267), xShape->getPosition().X); } DECLARE_OOXMLIMPORT_TEST(testTdf95755, "tdf95755.docx") diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 1c3b36535c6e..19b47af46929 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -135,6 +135,43 @@ DECLARE_OOXMLIMPORT_TEST(testTdf109524, "tdf109524.docx") getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth")); } +DECLARE_OOXMLIMPORT_TEST(testTdf118693, "tdf118693.docx") +{ + uno::Reference<drawing::XShape> xGroupShape = getShape(1); + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xGroup->getCount()); + + awt::Point aPosGroup = xGroupShape->getPosition(); + awt::Size aSizeGroup = xGroupShape->getSize(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(10162), aPosGroup.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(118), aPosGroup.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6369), aSizeGroup.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4983), aSizeGroup.Height); + + // Without the fix in place, this test would have failed at many places + // as the first shape in the group would have had an incorrect position, + // an incorrect width or an incorrect height. + + uno::Reference<drawing::XShape> xShape1(xGroup->getByIndex(0), uno::UNO_QUERY_THROW); + awt::Point aPosShape1 = xShape1->getPosition(); + awt::Size aSizeShape1 = xShape1->getSize(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(12863), aPosShape1.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(146), aPosShape1.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3669), aSizeShape1.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4914), aSizeShape1.Height); + + uno::Reference<drawing::XShape> xShape2(xGroup->getByIndex(1), uno::UNO_QUERY_THROW); + awt::Point aPosShape2 = xShape2->getPosition(); + awt::Size aSizeShape2 = xShape2->getSize(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(10162), aPosShape2.X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(118), aPosShape2.Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4595), aSizeShape2.Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4983), aSizeShape2.Height); +} + DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx") { // Font names inside a group shape were not imported _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits