oox/source/shape/WpsContext.cxx | 49 +++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-)
New commits: commit 5deb0ca100bf2bf962ea77c77b561186c3952b01 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Dec 2 11:00:59 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Dec 10 20:37:37 2024 +0100 crashtesting: failure to reload conversion of forum-de3-6592.odt to docx Change-Id: Ic2781bbd25e794992a181b2f4807fc0ca08ef33b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177675 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins (cherry picked from commit 9efc47ac6fb7c6b82ac35f114898e4e8e510c5f4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177689 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index 83934745d946..56abef55fcc1 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -682,6 +682,8 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken xPropertySet->setPropertyValue(u"InteropGrabBag"_ustr, uno::Any(aGrabBag)); } + auto xPropertySetInfo = xPropertySet->getPropertySetInfo(); + if (xServiceInfo.is()) { // Handle inset attributes for Writer textframes. @@ -701,16 +703,29 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken = { u"TextLeftDistance"_ustr, u"TextUpperDistance"_ustr, u"TextRightDistance"_ustr, u"TextLowerDistance"_ustr }; for (std::size_t i = 0; i < SAL_N_ELEMENTS(aShapeProps); ++i) - if (oInsets[i]) + { + if (!oInsets[i]) + continue; + if (xPropertySetInfo && xPropertySetInfo->hasPropertyByName(aShapeProps[i])) xPropertySet->setPropertyValue(aShapeProps[i], uno::Any(*oInsets[i])); + else + SAL_WARN("oox", "Property: " << aShapeProps[i] << " not supported"); + } } // Handle text vertical adjustment inside a text frame if (rAttribs.hasAttribute(XML_anchor)) { - drawing::TextVerticalAdjust eAdjust - = drawingml::GetTextVerticalAdjust(rAttribs.getToken(XML_anchor, XML_t)); - xPropertySet->setPropertyValue(u"TextVerticalAdjust"_ustr, uno::Any(eAdjust)); + if (xPropertySetInfo + && xPropertySetInfo->hasPropertyByName(u"TextVerticalAdjust"_ustr)) + { + drawing::TextVerticalAdjust eAdjust = drawingml::GetTextVerticalAdjust( + rAttribs.getToken(XML_anchor, XML_t)); + xPropertySet->setPropertyValue(u"TextVerticalAdjust"_ustr, + uno::Any(eAdjust)); + } + else + SAL_WARN("oox", "Property: TextVerticalAdjust not supported"); } // Apply character color of the shape to the shape's textbox. @@ -778,9 +793,14 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken } } - auto nWrappingType = rAttribs.getToken(XML_wrap, XML_square); - xPropertySet->setPropertyValue(u"TextWordWrap"_ustr, - uno::Any(nWrappingType == XML_square)); + if (xPropertySetInfo && xPropertySetInfo->hasPropertyByName(u"TextWordWrap"_ustr)) + { + auto nWrappingType = rAttribs.getToken(XML_wrap, XML_square); + xPropertySet->setPropertyValue(u"TextWordWrap"_ustr, + uno::Any(nWrappingType == XML_square)); + } + else + SAL_WARN("oox", "Property: TextWordWrap not supported"); return this; } @@ -834,9 +854,18 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken u"FrameIsAutomaticHeight"_ustr, uno::Any(getBaseToken(nElementToken) == XML_spAutoFit)); else - xPropertySet->setPropertyValue( - u"TextAutoGrowHeight"_ustr, - uno::Any(getBaseToken(nElementToken) == XML_spAutoFit)); + { + auto xPropertySetInfo = xPropertySet->getPropertySetInfo(); + if (xPropertySetInfo + && xPropertySetInfo->hasPropertyByName(u"TextAutoGrowHeight"_ustr)) + { + xPropertySet->setPropertyValue( + u"TextAutoGrowHeight"_ustr, + uno::Any(getBaseToken(nElementToken) == XML_spAutoFit)); + } + else + SAL_WARN("oox", "Property: TextAutoGrowHeight not supported"); + } } } break;