Kaydet (Commit) f66b76a4 authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#105688: findZOrder: catch exceptions from getPropertyValue

For some reason, sometimes items in GraphicZOrderHelper don't
have ZOrder property value, and so throw in getPropertyValue.
E.g., SwXFrame::getPropertyValue throws uno::RuntimeException
when its GetFrameFormat() returns nullptr.

The patch catches these to allow to proceed with fallback z-order.

Change-Id: I96140195f45364bccee7c5547d373158e2b49154
Reviewed-on: https://gerrit.libreoffice.org/37392Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 719a2adf
...@@ -273,20 +273,23 @@ sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight, bool bOldSt ...@@ -273,20 +273,23 @@ sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight, bool bOldSt
else else
++it; ++it;
} }
sal_Int32 itemZOrderOffset(0); // before the item
if( it == items.end()) // we're topmost if( it == items.end()) // we're topmost
{ {
if( items.empty()) if( items.empty())
return 0; return 0;
sal_Int32 itemZOrder(0);
--it; --it;
if( it->second->getPropertyValue(getPropertyName( PROP_Z_ORDER )) >>= itemZOrder ) itemZOrderOffset = 1; // after the topmost
return itemZOrder + 1; // after the topmost
} }
else // SwXFrame::getPropertyValue throws uno::RuntimeException
{ // when its GetFrameFormat() returns nullptr
try {
sal_Int32 itemZOrder(0); sal_Int32 itemZOrder(0);
if( it->second->getPropertyValue(getPropertyName( PROP_Z_ORDER )) >>= itemZOrder ) if( it->second->getPropertyValue(getPropertyName( PROP_Z_ORDER )) >>= itemZOrder )
return itemZOrder; // before the item return itemZOrder + itemZOrderOffset;
}
catch (const uno::RuntimeException&) {
SAL_WARN("writerfilter", "Exception when getting item z-order");
} }
SAL_WARN( "writerfilter", "findZOrder() didn't find item z-order" ); SAL_WARN( "writerfilter", "findZOrder() didn't find item z-order" );
return 0; // this should not(?) happen return 0; // this should not(?) happen
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment