diff options
author | Justin Luth <justin.luth@collabora.com> | 2023-03-02 19:32:27 -0500 |
---|---|---|
committer | Justin Luth <jluth@mail.com> | 2023-03-03 15:30:54 +0000 |
commit | 620d1dc63b652db97b05eb21685dad70e6b2ab0d (patch) | |
tree | 036fd324eadfc0ac6f793f80c910f77673f940ae | |
parent | f87ea14edfe3053e3091731deb90fc87c17ddad4 (diff) |
tdf#153613 writerfilter: handle defered break before SDT start
If there are deferred column or page breaks before an SDT,
then before starting the SDT we need to determine if the
existing run needs to split - same as everywhere else.
There was only one existing unit test that had any defered
page or column breaks, so only two example documents to work from.
That was tdf125778_lostPageBreakTOX.docx.
Change-Id: I02d71577af13399d8aaf3ba0ce40fc6bed5e6e3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148148
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx | bin | 0 -> 46930 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 31 |
3 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx b/sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx Binary files differnew file mode 100644 index 000000000000..fa62b475cfaa --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf153613_sdtAfterPgBreak.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index 2e71b5bcc7fe..67c15685d7a3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -197,6 +197,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak2, "tdf153613_textboxA assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no prior carriage return."); } +DECLARE_OOXMLEXPORT_TEST(testTdf153613_sdtAfterPgBreak, "tdf153613_sdtAfterPgBreak.docx") +{ + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert) { // Given a docx document with a shape with vert="mongolianVert". diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 573a1b41f4a5..d816aad4a9af 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1075,7 +1075,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) break; case NS_ooxml::LN_CT_SdtBlock_sdtContent: case NS_ooxml::LN_CT_SdtRun_sdtContent: + { m_pImpl->m_pSdtHelper->SetSdtType(nName); + if (m_pImpl->m_pSdtHelper->getControlType() == SdtControlType::unknown) { // Still not determined content type? and it is even not unsupported? Then it is plain text field @@ -1093,11 +1095,40 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) } } + PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH); + if (pContext && m_pImpl->isBreakDeferred(PAGE_BREAK)) + { + if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() + && !m_pImpl->IsInComments()) + { + if (m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun()) + { + m_pImpl->m_bIsSplitPara = true; + finishParagraph(); + lcl_startParagraphGroup(); + } + pContext->Insert(PROP_BREAK_TYPE, uno::Any(style::BreakType_PAGE_BEFORE)); + m_pImpl->clearDeferredBreaks(); + } + } + else if (pContext && m_pImpl->isBreakDeferred(COLUMN_BREAK)) + { + if (m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun()) + { + mbIsSplitPara = true; + finishParagraph(); + lcl_startParagraphGroup(); + } + pContext->Insert(PROP_BREAK_TYPE, uno::Any(style::BreakType_COLUMN_BEFORE)); + m_pImpl->clearDeferredBreaks(); + } + m_pImpl->m_pSdtHelper->setControlType(SdtControlType::richText); m_pImpl->PushSdt(); break; } m_pImpl->SetSdt(true); + } break; case NS_ooxml::LN_CT_SdtBlock_sdtEndContent: case NS_ooxml::LN_CT_SdtRun_sdtEndContent: |