sw/source/filter/ww8/docxattributeoutput.cxx | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-)
New commits: commit 435b193806e004701705b8989296e8b972bbae5f Author: Justin Luth <[email protected]> AuthorDate: Sat Feb 14 20:40:53 2026 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Feb 20 09:33:47 2026 +0100 NFC docx export: move useful code snippet into lcl_hasParaSdtEndBefore Change-Id: I59d04beb9a2445da1bc76663f5fe0590348f3e7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199643 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Justin Luth <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 142b14965000..08b5ff354110 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -437,6 +437,21 @@ bool lclHasSolidFillTransformations(const model::ComplexColor& aComplexColor) return idx != transformations.end(); } +// Does this paragraph indicate that a grabbagged 'SdtPr' (in a previous paragraph) should end here? +bool lcl_hasParaSdtEndBefore(const SwNode& rNode) +{ + const SwTextNode* pTextNode = rNode.GetTextNode(); + if (!pTextNode || !pTextNode->GetpSwAttrSet()) + return false; + + const SfxGrabBagItem* pParaGrabBag = pTextNode->GetpSwAttrSet()->GetItem(RES_PARATR_GRABBAG); + if (!pParaGrabBag) + return false; + + const std::map<OUString, css::uno::Any>& rMap = pParaGrabBag->GetGrabBag(); + return rMap.contains(u"ParaSdtEndBefore"_ustr); +} + } // end anonymous namespace void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ ) @@ -593,21 +608,10 @@ sal_Int32 DocxAttributeOutput::StartParagraph(const ww8::WW8TableNodeInfo::Point // Look up the "sdt end before this paragraph" property early, when it // would normally arrive, it would be too late (would be after the // paragraph start has been written). - bool bEndParaSdt = false; - if (m_aParagraphSdt.m_bStartedSdt) - { - SwTextNode* pTextNode = m_rExport.m_pCurPam->GetPointNode().GetTextNode(); - if (pTextNode && pTextNode->GetpSwAttrSet()) - { - const SfxItemSet* pSet = pTextNode->GetpSwAttrSet(); - if (const SfxPoolItem* pItem = pSet->GetItem(RES_PARATR_GRABBAG)) - { - const SfxGrabBagItem& rParaGrabBag = static_cast<const SfxGrabBagItem&>(*pItem); - const std::map<OUString, css::uno::Any>& rMap = rParaGrabBag.GetGrabBag(); - bEndParaSdt = m_aParagraphSdt.m_bStartedSdt && rMap.contains(u"ParaSdtEndBefore"_ustr); - } - } - } + const bool bEndParaSdt + = m_aParagraphSdt.m_bStartedSdt + && lcl_hasParaSdtEndBefore(m_rExport.m_pCurPam->GetPointNode()); + // TODO also avoid multiline paragraphs in those SDT types for shape text if (bEndParaSdt || (m_aParagraphSdt.m_bStartedSdt && m_bHadSectPr)) {
