oox/source/drawingml/shape.cxx | 19 ++++++++++------- sd/qa/unit/data/pptx/tdf165321.pptx |binary sd/qa/unit/data/xml/n593612_0.xml | 4 +-- sd/qa/unit/import-tests2.cxx | 39 ++++++++++++++++++++++++++++-------- 4 files changed, 44 insertions(+), 18 deletions(-)
New commits: commit 620b89adea77519fd5d057cac7e1acf8a6fb2544 Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Thu Mar 6 13:29:07 2025 +0100 Commit: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> CommitDate: Fri Mar 7 17:41:26 2025 +0100 tdf#165321 - sd ooxml import fix missing shapes or shapes with near zero height Use the calculated shapes size (before we calculate the shape size with NbcAdjustTextFrameWidthAndHeight if the autoTextGrowHeight is true) instead of the shape size directly from the xml, which need to be transformed in some cases. Regression from commit: ebf13e890766f4cadbba81444784cfe3c8e1bbc3 (tdf#156857: sd ooxml import: fix shape size if spAutofit is set) Change-Id: Icddaf22d10a89b172a3f1ca3e55150162e51a877 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182581 Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Tested-by: Jenkins Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 71f402572e2f..571d38b5b2b8 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1235,6 +1235,7 @@ Reference< XShape > const & Shape::createAndInsert( } } HomogenMatrix3 aMatrix; + tools::Rectangle aOrigSize; if ( aServiceName == "com.sun.star.drawing.ConnectorShape" ) { ::basegfx::B2DPolygon aPoly; @@ -2002,6 +2003,10 @@ Reference< XShape > const & Shape::createAndInsert( if (mbWps && aServiceName == "com.sun.star.drawing.LineShape" && !pParentGroupShape) mxShape->setPosition(maPosition); + SdrObject* pShape = SdrObject::getSdrObjectFromXShape(mxShape); + if (pShape) + aOrigSize = pShape->GetLogicRect(); + if (bIsConnectorShape) { msConnectorName = mpCustomShapePropertiesPtr->getShapePresetTypeName(); @@ -2299,16 +2304,14 @@ Reference< XShape > const & Shape::createAndInsert( } SdrObject* pShape = SdrObject::getSdrObjectFromXShape(mxShape); - if (pShape && bAutoHeight && bIsCustomShape) + if (pShape && bAutoHeight) { - tools::Rectangle aOrigSize(aShapeRectHmm.X, aShapeRectHmm.Y, - aShapeRectHmm.X + aShapeRectHmm.Width, aShapeRectHmm.Y + aShapeRectHmm.Height); - tools::Rectangle aAdaptSize = pShape->GetLogicRect(); - // a little tolerance same as in \svx\source\svdraw\svdoashp.cxx:AdjustTextFrameWidthAndHeight - if (std::abs(aOrigSize.GetHeight() - aAdaptSize.GetHeight()) > 1) + tools::Rectangle aAutoSize = pShape->GetLogicRect(); + // little tolerance same as in \svx\source\svdraw\svdoashp.cxx:AdjustTextFrameWidthAndHeight + if (!aOrigSize.IsEmpty() && (std::abs(aOrigSize.GetHeight() - aAutoSize.GetHeight()) > 1 || + std::abs(aOrigSize.GetWidth() - aAutoSize.GetWidth()) > 1)) { - aAdaptSize.setHeight(aOrigSize.GetHeight()); - pShape->NbcSetLogicRect(aAdaptSize, false); + pShape->NbcSetLogicRect(aOrigSize, false); } } } diff --git a/sd/qa/unit/data/pptx/tdf165321.pptx b/sd/qa/unit/data/pptx/tdf165321.pptx new file mode 100644 index 000000000000..86736d94b563 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf165321.pptx differ diff --git a/sd/qa/unit/data/xml/n593612_0.xml b/sd/qa/unit/data/xml/n593612_0.xml index f278976b7d2a..4c99db725cab 100644 --- a/sd/qa/unit/data/xml/n593612_0.xml +++ b/sd/qa/unit/data/xml/n593612_0.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <XShapes> - <XShape positionX="11429" positionY="1324" sizeX="2259" sizeY="15971" type="com.sun.star.drawing.CustomShape" name="Rectangle 52" text=" " fontHeight="24.000000" fontColor="ffffffff" textAutoGrowHeight="true" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="CENTER" textVerticalAdjust="TOP" textLeftDistance="254" textRightDistance="254" textUpperDistance="127" textLowerDistance="127" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="0" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="SOLID" fillColor="3c8c93" fillTransparence="0" fillTran sparenceGradientName=""> + <XShape positionX="11429" positionY="1324" sizeX="2259" sizeY="15969" type="com.sun.star.drawing.CustomShape" name="Rectangle 52" text=" " fontHeight="24.000000" fontColor="ffffffff" textAutoGrowHeight="true" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="CENTER" textVerticalAdjust="TOP" textLeftDistance="254" textRightDistance="254" textUpperDistance="127" textLowerDistance="127" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="0" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="SOLID" fillColor="3c8c93" fillTransparence="0" fillTran sparenceGradientName=""> <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="000000" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> <FillGradient style="LINEAR" startColor="3465a4" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/> @@ -10,7 +10,7 @@ <LineEnd/> <Transformation> <Line1 column1="2260.000000" column2="0.000000" column3="11429.000000"/> - <Line2 column1="0.000000" column2="15972.000000" column3="1324.000000"/> + <Line2 column1="0.000000" column2="15970.000000" column3="1324.000000"/> <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/> </Transformation> <CustomShapeGeometry> diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index f6c30881cadc..b197ee530350 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -111,18 +111,41 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf160490) sal_Int32 nHeight1 = xShape1->getSize().Height; // Without the fix in place, this test would have failed with - // Expected: placeholder height: 3728 + // Expected: placeholder height: 3726 // Actual : placeholder height: 3476 - CPPUNIT_ASSERT_EQUAL(sal_Int32(3728), nHeight1); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3726), nHeight1); uno::Reference<drawing::XShape> xShape2(getShapeFromPage(0, 1), uno::UNO_QUERY); CPPUNIT_ASSERT(xShape2.is()); sal_Int32 nHeight2 = xShape2->getSize().Height; // Without the fix in place, this test would have failed with - // Expected: placeholder height: 3367 + // Expected: placeholder height: 3365 // Actual : placeholder height: 3116 - CPPUNIT_ASSERT_EQUAL(sal_Int32(3367), nHeight2); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3365), nHeight2); +} + +CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf165321) +{ + createSdImpressDoc("pptx/tdf165321.pptx"); + + uno::Reference<container::XIndexAccess> xGroupShape(getShapeFromPage(0, 0), + uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xShape.is()); + // Without the fix in place, this test would have failed with + // Expected: shape height: 3597 + // Actual : shape height: 3 + CPPUNIT_ASSERT_EQUAL(sal_Int32(3597), xShape->getSize().Height); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6592), xShape->getSize().Width); + + xShape.set(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xShape.is()); + // Without the fix in place, this test would have failed with + // Expected: shape height: 3597 + // Actual : shape height: 3 + CPPUNIT_ASSERT_EQUAL(sal_Int32(3597), xShape->getSize().Height); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6402), xShape->getSize().Width); } CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf157285) @@ -134,18 +157,18 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf157285) sal_Int32 nHeight1 = xShape1->getSize().Height; // Without the fix in place, this test would have failed with - // Expected: placeholder height: 2565 + // Expected: placeholder height: 2795 // Actual : placeholder height: 3435 - CPPUNIT_ASSERT_EQUAL(sal_Int32(2565), nHeight1); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2795), nHeight1); uno::Reference<drawing::XShape> xShape2(getShapeFromPage(1, 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xShape2.is()); sal_Int32 nHeight2 = xShape2->getSize().Height; // Without the fix in place, this test would have failed with - // Expected: placeholder height: 1180 + // Expected: placeholder height: 1271 // Actual : placeholder height: 11303 - CPPUNIT_ASSERT_EQUAL(sal_Int32(1180), nHeight2); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1271), nHeight2); } CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf152186)