From c9e5640c8fcad7beb42a66f9bee0252eee9fe323 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Thu, 18 Mar 2021 00:48:49 +0100 Subject: 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 --- oox/source/drawingml/shape.cxx | 9 +------ sw/qa/extras/ooxmlimport/data/tdf118693.docx | Bin 0 -> 26072 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 ++------- sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 37 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 sw/qa/extras/ooxmlimport/data/tdf118693.docx diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 469dc7c30c17..45a7a7e64307 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -852,7 +852,6 @@ Reference< XShape > const & Shape::createAndInsert( uno::Sequence< awt::Point > aPointSequence( nNumPoints ); awt::Point* pPoints = aPointSequence.getArray(); uno::Reference 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 ) ); @@ -860,13 +859,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(convertMm100ToTwip(aPoint.getX())), static_cast(convertMm100ToTwip(aPoint.getY()))); - else - pPoints[i] = awt::Point(static_cast(aPoint.getX()), static_cast(aPoint.getY())); + pPoints[i] = awt::Point(static_cast(aPoint.getX()), static_cast(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 16351d9fcb35..8163c0c10377 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1346,16 +1346,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(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(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 474cfbe2b13d..fcfaccafb774 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -196,6 +196,43 @@ DECLARE_OOXMLIMPORT_TEST(testTdf120547, "tdf120547.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(8073), aSizeShape3.Height); } +DECLARE_OOXMLIMPORT_TEST(testTdf118693, "tdf118693.docx") +{ + uno::Reference xGroupShape = getShape(1); + uno::Reference xGroup(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast(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 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 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 -- cgit v1.2.3