diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-04-13 08:34:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-04-13 09:54:04 +0200 |
commit | ada2d449175afd9a6aa1db9281739e5ad6ac6fef (patch) | |
tree | bcb00d4b5cd58d0ca1d50356dbf06789919a98e0 /sw | |
parent | 634990f32c354dd7690b6ae44b19a94c9f19ffc4 (diff) |
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 <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 3 |
2 files changed, 19 insertions, 3 deletions
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; |