svx/source/unodraw/unoshape.cxx | 5 ++++- sw/source/core/unocore/unoframe.cxx | 2 +- xmloff/source/text/txtparae.cxx | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-)
New commits: commit 38955c300c692778efd1feee1e1a47922f119654 Author: Michael Stahl <[email protected]> AuthorDate: Fri Jan 16 19:20:05 2026 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Jan 20 12:29:20 2026 +0100 xmloff,svx,sw: ODF export: prevent spurious z-index="0" Currently any object anchored in a Writer header / footer which isn't actually used in the document isn't put on the SdrPage and thus doesn't have a ZOrder; this results in a spurious z-index="0" attribute, where 0 is a perfectly valid value that is typically already used by a visible shape and is thus duplicated, which is invalid. Fix SvxShape::getPropertyValueImpl() and SwXFrame::getPropertyValue() to check that it has a parent, and XMLTextParagraphExport::addTextFrameAttributes() to properly check that the property has a valid value. There is one possible use case for producing a z-index for something that isn't visible: when it's anchored in a delete tracked change, and we want to preserve the order relative to other shapes in the document. However, it turns out that in SdXMLShapeContext::AddShape() and XMLTextFrameContext_Impl::Create() the z-index of anything anchored in a delete redline is already explicitly ignored, so it's a non-issue. Change-Id: I37e461ebcd3e4546c60f421054ee39c053919267 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197474 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit 7ffd4f7a27b9b2bc55ac3ddb7333dbaf3d48109c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197623 diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 8299a96fb985..c06cf971c3b1 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -2592,7 +2592,10 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn case OWN_ATTR_ZORDER: { - rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetOrdNum()); + if (GetSdrObject()->getParentSdrObjListFromSdrObject()) + { + rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetOrdNum()); + } break; } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 4ea5dbcb08c6..99b05427ea9a 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2153,7 +2153,7 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) const SdrObject* pObj = pFormat->FindRealSdrObject(); if( pObj == nullptr ) pObj = pFormat->FindSdrObject(); - if( pObj ) + if (pObj && pObj->getParentSdrObjListFromSdrObject()) { aAny <<= static_cast<sal_Int32>(pObj->GetOrdNum()); } diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 60db48f76c59..65531cc07e0f 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3103,10 +3103,10 @@ XMLShapeExportFlags XMLTextParagraphExport::addTextFrameAttributes( OUString sZOrder( u"ZOrder"_ustr ); if( xPropSetInfo->hasPropertyByName( sZOrder ) ) { - sal_Int32 nZIndex = 0; - rPropSet->getPropertyValue( sZOrder ) >>= nZIndex; - if( -1 != nZIndex ) + sal_Int32 nZIndex{-1}; + if (rPropSet->getPropertyValue(sZOrder) >>= nZIndex) { + assert(0 <= nZIndex); GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_ZINDEX, OUString::number( nZIndex ) ); }
