summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-09-13 15:55:34 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-09-13 20:49:46 +0200
commit8e6df40db6e52b4ea657e5d81a32a7fdb006b00a (patch)
tree475764cf07012ec0800f9a96420113c39fb64506 /oox
parent66517fda4c40d0c20b52a3110ee169353ff8c227 (diff)
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/+/139867 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/shapes.cxx27
-rw-r--r--oox/source/export/vmlexport.cxx15
2 files changed, 27 insertions, 15 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 90e4ad86926f..74dadd5da473 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 fa21068cf4b6..5d6f244bb42f 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1151,12 +1151,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)