oox/source/shape/WpsContext.cxx |   49 +++++++++++++++++++++++++++++++---------
 1 file changed, 39 insertions(+), 10 deletions(-)

New commits:
commit ad89b67276f62fa19d33f59e8008a53161e35f54
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Dec 2 11:00:59 2024 +0000
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Dec 2 16:21:00 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/+/177677
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index fae704856371..df318cedb291 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -674,6 +674,8 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
                     xPropertySet->setPropertyValue("InteropGrabBag", 
uno::Any(aGrabBag));
                 }
 
+                auto xPropertySetInfo = xPropertySet->getPropertySetInfo();
+
                 if (xServiceInfo.is())
                 {
                     // Handle inset attributes for Writer textframes.
@@ -693,16 +695,29 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
                         = { OUString("TextLeftDistance"), 
OUString("TextUpperDistance"),
                             OUString("TextRightDistance"), 
OUString("TextLowerDistance") };
                     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("TextVerticalAdjust", 
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.
@@ -763,9 +778,14 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
                     }
                 }
 
-                auto nWrappingType = rAttribs.getToken(XML_wrap, XML_square);
-                xPropertySet->setPropertyValue("TextWordWrap",
-                                               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;
             }
@@ -819,9 +839,18 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
                         "FrameIsAutomaticHeight",
                         uno::Any(getBaseToken(nElementToken) == 
XML_spAutoFit));
                 else
-                    xPropertySet->setPropertyValue(
-                        "TextAutoGrowHeight",
-                        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;

Reply via email to