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.extern@allotropia.de>
This commit is contained in:
Balazs Varga
2024-12-04 14:09:25 +01:00
parent 9b4cbd876b
commit 293d03e680
3 changed files with 30 additions and 2 deletions

View File

@@ -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));
}

Binary file not shown.

View File

@@ -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: */