oox/source/export/shapes.cxx | 27 ++++++++++++++++++--------- oox/source/export/vmlexport.cxx | 15 +++++++++------ 2 files changed, 27 insertions(+), 15 deletions(-)
New commits: commit 3acd979a0ff308abe3d4ac62f7eb6bca4c59df4e Author: Caolán McNamara <[email protected]> AuthorDate: Tue Sep 13 15:55:34 2022 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Sep 16 08:18:20 2022 +0200 crashtesting: FastSaxSerializer::endDocument assert on export of ooo26868-1.doc to ooo26868-1.docx since: commit 17e27b4a19f22b912460f090b754d11f9a32fb7f Date: Tue Sep 6 14:28:22 2022 +0200 tdf#150756 - Assertion when opening report for editing but that commit looks blameless to me. Avoid the problem by checking for an empty Any for "TextBox" here as is common elsewhere Change-Id: I5f390952763044498d944a081703d0665cbb0444 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139839 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 7e3af9a04fea..4bb6520ec951 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -2010,21 +2010,30 @@ ShapeExport& ShapeExport::WriteShape( const Reference< XShape >& xShape ) return *this; } +static bool lcl_isTextBox(const Reference<XInterface>& xIface) +{ + uno::Reference<beans::XPropertySet> xPropertySet(xIface, uno::UNO_QUERY); + if (!xPropertySet.is()) + return false; + uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); + if (!xPropertySetInfo->hasPropertyByName("TextBox")) + return false; + css::uno::Any aTextBox(xPropertySet->getPropertyValue("TextBox")); + if (!aTextBox.hasValue()) + return false; + return aTextBox.get<bool>(); +} + ShapeExport& ShapeExport::WriteTextBox( const Reference< XInterface >& xIface, sal_Int32 nXmlNamespace, bool bWritePropertiesAsLstStyles ) { // In case this shape has an associated textbox, then export that, and we're done. if (GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes && GetTextExport()) { - uno::Reference<beans::XPropertySet> xPropertySet(xIface, uno::UNO_QUERY); - if (xPropertySet.is()) + if (lcl_isTextBox(xIface)) { - uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); - if (xPropertySetInfo->hasPropertyByName("TextBox") && xPropertySet->getPropertyValue("TextBox").get<bool>()) - { - GetTextExport()->WriteTextBox(uno::Reference<drawing::XShape>(xIface, uno::UNO_QUERY_THROW)); - WriteText( xIface, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace ); - return *this; - } + GetTextExport()->WriteTextBox(uno::Reference<drawing::XShape>(xIface, uno::UNO_QUERY_THROW)); + WriteText( xIface, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace ); + return *this; } } diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 8ee5c28ed67a..4f2654faee67 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1153,12 +1153,15 @@ static std::vector<OString> lcl_getShapeTypes() static bool lcl_isTextBox(const SdrObject* pSdrObject) { uno::Reference<beans::XPropertySet> xPropertySet(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), uno::UNO_QUERY); - if (xPropertySet.is()) - { - uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); - return xPropertySetInfo->hasPropertyByName("TextBox") && xPropertySet->getPropertyValue("TextBox").get<bool>(); - } - return false; + if (!xPropertySet.is()) + return false; + uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); + if (!xPropertySetInfo->hasPropertyByName("TextBox")) + return false; + css::uno::Any aTextBox(xPropertySet->getPropertyValue("TextBox")); + if (!aTextBox.hasValue()) + return false; + return aTextBox.get<bool>(); } static OUString lcl_getAnchorIdFromGrabBag(const SdrObject* pSdrObject)
