From 027632ec97ad556606997254244c76c7474d9122 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Thu, 29 Feb 2024 08:42:07 -0500 Subject: [PATCH] NFC prepwork for tdf#159158: flatten writerfilter applyZOrder limit code shuffle in the fix itself Change-Id: Ic506ac700403fa434dd6410e9ea566c6d0e19676 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164154 Tested-by: Jenkins Reviewed-by: Justin Luth --- writerfilter/source/dmapper/DomainMapper.cxx | 4 +-- writerfilter/source/dmapper/DomainMapper.hxx | 2 +- .../source/dmapper/DomainMapper_Impl.cxx | 12 ++++----- writerfilter/source/dmapper/GraphicImport.cxx | 25 ++++++++++--------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 239ecde547d4..3548ece176ed 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -4908,11 +4908,11 @@ SettingsTablePtr const & DomainMapper::GetSettingsTable() return m_pImpl->GetSettingsTable(); } -GraphicZOrderHelper* DomainMapper::graphicZOrderHelper() +GraphicZOrderHelper& DomainMapper::graphicZOrderHelper() { if (m_zOrderHelper == nullptr) m_zOrderHelper.reset( new GraphicZOrderHelper ); - return m_zOrderHelper.get(); + return *m_zOrderHelper; } uno::Reference DomainMapper::PopPendingShape() diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx index db29f10d45eb..9d9771e640f5 100644 --- a/writerfilter/source/dmapper/DomainMapper.hxx +++ b/writerfilter/source/dmapper/DomainMapper.hxx @@ -107,7 +107,7 @@ public: OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties, bool bAlwaysCreate ); StyleSheetTablePtr const & GetStyleSheetTable( ); SettingsTablePtr const & GetSettingsTable(); - GraphicZOrderHelper* graphicZOrderHelper(); + GraphicZOrderHelper& graphicZOrderHelper(); /// Return the first from the pending (not inserted to the document) shapes, if there are any. css::uno::Reference PopPendingShape(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 0b1ff5e0e6e3..45ff00958083 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -4762,12 +4762,12 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape { if (rProp.Name == "VML-Z-ORDER") { - GraphicZOrderHelper* pZOrderHelper = m_rDMapper.graphicZOrderHelper(); + GraphicZOrderHelper& rZOrderHelper = m_rDMapper.graphicZOrderHelper(); sal_Int32 zOrder(0); rProp.Value >>= zOrder; xShapePropertySet->setPropertyValue("ZOrder", - uno::Any(pZOrderHelper->findZOrder(zOrder, /*LastDuplicateWins*/true))); - pZOrderHelper->addItem(xShapePropertySet, zOrder); + uno::Any(rZOrderHelper.findZOrder(zOrder, /*LastDuplicateWins*/true))); + rZOrderHelper.addItem(xShapePropertySet, zOrder); xShapePropertySet->setPropertyValue(getPropertyName( PROP_OPAQUE ), uno::Any( zOrder >= 0 ) ); checkZOrderStatus = true; } @@ -4807,12 +4807,12 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape { if (rProp.Name == "VML-Z-ORDER") { - GraphicZOrderHelper* pZOrderHelper = m_rDMapper.graphicZOrderHelper(); + GraphicZOrderHelper& rZOrderHelper = m_rDMapper.graphicZOrderHelper(); sal_Int32 zOrder(0); rProp.Value >>= zOrder; xShapePropertySet->setPropertyValue("ZOrder", - uno::Any(pZOrderHelper->findZOrder(zOrder, /*LastDuplicateWins*/true))); - pZOrderHelper->addItem(xShapePropertySet, zOrder); + uno::Any(rZOrderHelper.findZOrder(zOrder, /*LastDuplicateWins*/true))); + rZOrderHelper.addItem(xShapePropertySet, zOrder); xShapePropertySet->setPropertyValue(getPropertyName( PROP_OPAQUE ), uno::Any( zOrder >= 0 ) ); checkZOrderStatus = true; } diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index c11717b4048a..bee20740278f 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -391,14 +391,14 @@ public: void applyZOrder(uno::Reference const & xGraphicObjectProperties) const { std::optional oZOrder = m_oZOrder; - bool bBehindText = m_bBehindDoc && !m_bOpaque; if (m_rGraphicImportType == GraphicImportType::IMPORT_AS_DETECTED_INLINE && !m_rDomainMapper.IsInShape()) { oZOrder = SAL_MIN_INT32; - bBehindText = false; } - if (oZOrder) + else if (!oZOrder) + return; + else { // tdf#120760 Send objects with behinddoc=true to the back. @@ -417,18 +417,19 @@ public: // (especially needed for IsInHeaderFooter, as EVERYTHING is forced to the background). // // relativeHeight already removed 0x1E00 0000, so can subtract another 0x6200 0000 + const bool bBehindText = m_bBehindDoc && !m_bOpaque; if (bBehindText) oZOrder = *oZOrder - 0x62000000; - - // TODO: it is possible that RTF has been wrong all along as well. Always true here? - const bool bLastDuplicateWins(!m_rDomainMapper.IsRTFImport() - || m_rGraphicImportType == GraphicImportType::IMPORT_AS_DETECTED_INLINE); - - GraphicZOrderHelper* pZOrderHelper = m_rDomainMapper.graphicZOrderHelper(); - xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_Z_ORDER), - uno::Any(pZOrderHelper->findZOrder(*oZOrder, bLastDuplicateWins))); - pZOrderHelper->addItem(xGraphicObjectProperties, *oZOrder); } + + // TODO: it is possible that RTF has been wrong all along as well. Always true here? + const bool bLastDuplicateWins(!m_rDomainMapper.IsRTFImport() + || m_rGraphicImportType == GraphicImportType::IMPORT_AS_DETECTED_INLINE); + + GraphicZOrderHelper& rZOrderHelper = m_rDomainMapper.graphicZOrderHelper(); + xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_Z_ORDER), + uno::Any(rZOrderHelper.findZOrder(*oZOrder, bLastDuplicateWins))); + rZOrderHelper.addItem(xGraphicObjectProperties, *oZOrder); } void applyName(uno::Reference const & xGraphicObjectProperties) const