sw/source/filter/ww8/docxattributeoutput.cxx | 19 +++++++++++++++++-- sw/source/filter/ww8/docxattributeoutput.hxx | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-)
New commits: commit ada2d449175afd9a6aa1db9281739e5ad6ac6fef Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Apr 13 08:34:33 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Apr 13 09:54:04 2022 +0200 sw content controls, DOCX export: handle SDT end at para end Once the DOCX import maps Run SDTs to SwContentControl, make -C sw -sr CppunitTest_sw_ooxmlexport17 CPPUNIT_TEST_NAME=testTdf148361 starts to fail without this fix. Previously we only tested SwContentControl end in the middle of a paragraph. Fix the paragraph end case similar to how hyperlinks are handled to be consistent. Change-Id: I0633ca8d7d909a2cb3c70e7edce3a85df5fac3f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132944 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 847888dfba75..bf120d3e47a9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -367,7 +367,10 @@ void DocxAttributeOutput::StartContentControl(const SwFormatContentControl& rFor m_pContentControl = rFormatContentControl.GetContentControl(); } -void DocxAttributeOutput::EndContentControl() { ++m_nCloseContentControl; } +void DocxAttributeOutput::EndContentControl() +{ + ++m_nCloseContentControlInThisRun; +} static void checkAndWriteFloatingTables(DocxAttributeOutput& rDocxAttributeOutput) { @@ -1628,8 +1631,9 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool / m_bEndCharSdt = false; } - for (; m_nCloseContentControl > 0; --m_nCloseContentControl) + for (; m_nCloseContentControlInPreviousRun > 0; --m_nCloseContentControlInPreviousRun) { + // Not the last run of this paragraph. m_pSerializer->endElementNS(XML_w, XML_sdtContent); m_pSerializer->endElementNS(XML_w, XML_sdt); } @@ -1854,6 +1858,13 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool / m_pRedlineData = nullptr; } + for (; m_nCloseContentControlInThisRun > 0; --m_nCloseContentControlInThisRun) + { + // Last run of this paragraph. + m_pSerializer->endElementNS(XML_w, XML_sdtContent); + m_pSerializer->endElementNS(XML_w, XML_sdt); + } + if ( m_closeHyperlinkInThisRun ) { if ( m_startedHyperlink ) @@ -3259,6 +3270,10 @@ void DocxAttributeOutput::RunText( const OUString& rText, rtl_TextEncoding /*eCh { m_closeHyperlinkInPreviousRun = true; } + if (m_nCloseContentControlInThisRun > 0) + { + ++m_nCloseContentControlInPreviousRun; + } m_bRunTextIsOn = true; // one text can be split into more <w:t>blah</w:t>'s by line breaks etc. const sal_Unicode *pBegin = rText.getStr(); diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 4b4be1ca6160..00549f5d8beb 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -911,7 +911,8 @@ private: o3tl::sorted_vector<const SwFrameFormat*> m_aFloatingTablesOfParagraph; sal_Int32 m_nTextFrameLevel; - sal_Int32 m_nCloseContentControl = 0; + sal_Int32 m_nCloseContentControlInThisRun = 0; + sal_Int32 m_nCloseContentControlInPreviousRun = 0; // close of hyperlink needed bool m_closeHyperlinkInThisRun;