xmloff: ODF export: avoid mysterious crash while sorting shapes
Apparently the draw page contains a null XShape. That sounds like a bug
but OTOH this sorting feature from commit
9bc6160e0acbc78be998129ea55ed7e4529959faa isn't that important so let's
sweep the problem under the rug.
0 swlo.dll sw::GetZOrderLayer::operator()(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const &) C:\cygwin64\home\buildslave\source\libo-core\sw\source\filter\xml\zorder.hxx:37
1 mergedlo.dll xmloff::FixZOrder(com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> const &,std::function<unsigned int > const &) C:\cygwin64\home\buildslave\source\libo-core\xmloff\source\draw\shapeexport.cxx:1003
2 swlo.dll SwXMLWriter::Write_(com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> const &,rtl::OUString const &) C:\cygwin64\home\buildslave\source\libo-core\sw\source\filter\xml\wrtxml.cxx:190
https://crashreport.libreoffice.org/stats/crash_details/045adea4-c577-4164-9e69-bde5f892bd17
Change-Id: I1e67dc1c354cb14717cf9667314d6752e1b4c295
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121860
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 455ca3b..8c7ba17 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -1024,6 +1024,11 @@ void FixZOrder(uno::Reference<drawing::XShapes> const& xShapes,
for (sal_Int32 i = 0; i < nCount; ++i)
{
uno::Reference<beans::XPropertySet> const xShape(xShapes->getByIndex(i), uno::UNO_QUERY);
if (!xShape.is())
{
SAL_WARN("xmloff", "FixZOrder: null shape, cannot sort");
return;
}
unsigned int const nLayer(rGetLayer(xShape));
if (layers.size() <= nLayer)
{