oox/source/export/drawingml.cxx | 22 ++++++++++++++++++++-- sd/qa/unit/data/pptx/tdf160487.pptx |binary sd/qa/unit/export-tests-ooxml4.cxx | 10 ++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-)
New commits: commit 293d03e6803be57af7a3948e358e7ed9f8545c13 Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Wed Dec 4 14:09:25 2024 +0100 Commit: Balazs Varga <balazs.varga.ext...@allotropia.de> CommitDate: Thu Dec 5 09:05:46 2024 +0100 tdf#160487 - PPTX export: fix "Fit height to text" attribute of drawing objects (placeholders) Export spAutoFit attribute correctly to ooxml. Change-Id: I57e5b21bd6c407bdb5d1b36b3c3674249fbd2f59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177798 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 18334ad0516a..d3bc81b08b26 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -4305,9 +4305,27 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo } else { - // tdf#127030: Only custom shapes obey the TextAutoGrowHeight option. + bool bAutoGrowHeightEnabled = false; + const SdrObject* pObj = xShape.is() ? SdrObject::getSdrObjectFromXShape(xShape) : nullptr; + if (pObj) + { + switch (pObj->GetObjIdentifier()) + { + case SdrObjKind::NONE: + case SdrObjKind::Text: + case SdrObjKind::TitleText: + case SdrObjKind::OutlineText: + case SdrObjKind::Caption: + case SdrObjKind::CustomShape: + bAutoGrowHeightEnabled = true; + break; + default: + bAutoGrowHeightEnabled = false; + } + } + bool bTextAutoGrowHeight = false; - if (dynamic_cast<SvxCustomShape*>(rXIface.get()) && GetProperty(rXPropSet, u"TextAutoGrowHeight"_ustr)) + if (bAutoGrowHeightEnabled && GetProperty(rXPropSet, u"TextAutoGrowHeight"_ustr)) mAny >>= bTextAutoGrowHeight; mpFS->singleElementNS(XML_a, (bTextAutoGrowHeight ? XML_spAutoFit : XML_noAutofit)); } diff --git a/sd/qa/unit/data/pptx/tdf160487.pptx b/sd/qa/unit/data/pptx/tdf160487.pptx new file mode 100644 index 000000000000..ac0f3fb553d1 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf160487.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml4.cxx b/sd/qa/unit/export-tests-ooxml4.cxx index 9513b3ae5e61..55f1b5d5de2d 100644 --- a/sd/qa/unit/export-tests-ooxml4.cxx +++ b/sd/qa/unit/export-tests-ooxml4.cxx @@ -1263,6 +1263,16 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf163483_export_math_fallback) "id", cNvPr_id); } +CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testPlaceHolderFitHeightToText) +{ + createSdImpressDoc("pptx/tdf160487.pptx"); + saveAndReload(u"Impress Office Open XML"_ustr); + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(1, 0)); + bool bTextAutoGrowHeight = false; + xShape->getPropertyValue(u"TextAutoGrowHeight"_ustr) >>= bTextAutoGrowHeight; + CPPUNIT_ASSERT_MESSAGE("PlaceHolder Fit height to text should be true.", bTextAutoGrowHeight); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */