oox/source/drawingml/shape.cxx | 11 +++++++++++ sd/qa/unit/data/pptx/tdf157285.pptx |binary sd/qa/unit/data/xml/n819614_0.xml | 2 +- sd/qa/unit/import-tests2.cxx | 23 +++++++++++++++++++++++ sd/source/ui/unoidl/unopage.cxx | 5 +++++ 5 files changed, 40 insertions(+), 1 deletion(-)
New commits: commit 40d3d510fca99b555381deb74b9915c91c924de5 Author: Tibor Nagy <tibor.nagy.ext...@allotropia.de> AuthorDate: Fri Mar 29 15:19:10 2024 +0100 Commit: Nagy Tibor <tibor.nagy.ext...@allotropia.de> CommitDate: Fri Mar 29 23:38:18 2024 +0100 tdf#157285 PPTX import: fix placeholder height The "TextAutoGrowHeight" property doesn't shrink the shape automatically when its content is smaller than the current size. Change-Id: Ia7f94d7452d1a1c3f004aebd73b6ed5cbfd9b43b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165551 Tested-by: Jenkins Reviewed-by: Nagy Tibor <tibor.nagy.ext...@allotropia.de> diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index bd81fa9b42bf..23be28b546b6 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1251,6 +1251,17 @@ Reference< XShape > const & Shape::createAndInsert( { xSet->setPropertyValue("Decorative", Any(m_isDecorative)); } + + // set the placeholder height to "0" if it has the 'TextAutoGrowHeight' property + // the placeholder height is set later to the correct size. + bool bAutoGrowHeight = false; + xSet->getPropertyValue("TextAutoGrowHeight") >>= bAutoGrowHeight; + if (bAutoGrowHeight && mxShape->getShapeType().startsWith("com.sun.star.presentation.")) + { + awt::Size aSize(mxShape->getSize().Width, 0); + mxShape->setSize(aSize); + } + if (aServiceName != "com.sun.star.text.TextFrame") rxShapes->add( mxShape ); diff --git a/sd/qa/unit/data/pptx/tdf157285.pptx b/sd/qa/unit/data/pptx/tdf157285.pptx new file mode 100644 index 000000000000..7fa9ec88f1b0 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf157285.pptx differ diff --git a/sd/qa/unit/data/xml/n819614_0.xml b/sd/qa/unit/data/xml/n819614_0.xml index c889b00c343a..0fa127c07d9b 100644 --- a/sd/qa/unit/data/xml/n819614_0.xml +++ b/sd/qa/unit/data/xml/n819614_0.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <XShapes> - <XShape positionX="1270" positionY="763" sizeX="21166" sizeY="1564" type="com.sun.star.presentation.TitleTextShape" name="Title 1" text="Test" fontHeight="44.000000" fontColor="000000" textAutoGrowHeight="false" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="AUTOFIT" textHorizontalAdjust="BLOCK" textVerticalAdjust="CENTER" textLeftDistance="254" textRightDistance="254" textUpperDistance="127" textLowerDistance="127" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="3181" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="729fcf" fillTransparence="0" fillTransparenceGradientName=""> + <XShape positionX="1270" positionY="763" sizeX="21166" sizeY="1564" type="com.sun.star.presentation.TitleTextShape" name="Title 1" text="Test" fontHeight="44.000000" fontColor="000000" textAutoGrowHeight="false" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="AUTOFIT" textHorizontalAdjust="BLOCK" textVerticalAdjust="CENTER" textLeftDistance="254" textRightDistance="254" textUpperDistance="127" textLowerDistance="127" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="1" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="729fcf" fillTransparence="0" fillTransparenceGradientName=""> <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="000000" 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"/> diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index bf3cfee14dad..9ade40ad1917 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -74,6 +74,29 @@ protected: bool checkPattern(int nShapeNumber, std::vector<sal_uInt8>& rExpected); }; +CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf157285) +{ + createSdImpressDoc("pptx/tdf157285.pptx"); + + uno::Reference<drawing::XShape> xShape1(getShapeFromPage(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShape1.is()); + sal_Int32 nHeight1 = xShape1->getSize().Height; + + // Without the fix in place, this test would have failed with + // Expected: placeholder height: 2541 + // Actual : placeholder height: 3435 + CPPUNIT_ASSERT_EQUAL(sal_Int32(2541), 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: 1169 + // Actual : placeholder height: 11303 + CPPUNIT_ASSERT_EQUAL(sal_Int32(1169), nHeight2); +} + CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf152186) { createSdImpressDoc("pptx/tdf152186.pptx"); diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 1462e08e369e..569116c96b61 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -486,6 +486,11 @@ rtl::Reference<SdrObject> SdGenericDrawPage::CreateSdrObject_( const Reference< ::tools::Rectangle aRect( eObjKind == PresObjKind::Title ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect() ); + // OOXML placeholder with auto grow height + // do not set the height here yet + if (xShape->getSize().Height == 0) + aRect.setHeight(0); + const awt::Point aPos( aRect.Left(), aRect.Top() ); xShape->setPosition( aPos );