sw/qa/extras/ooxmlexport/data/tdf148057_columnBreak.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 8 +++++ sw/source/writerfilter/dmapper/DomainMapper.cxx | 23 ++++++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-)
New commits: commit bc511e9b7f33ff2b5e2b5e16debc550af73c3ada Author: Justin Luth <jl...@mail.com> AuthorDate: Tue Aug 19 15:50:44 2025 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Aug 20 02:45:29 2025 +0200 tdf#148057 writerfilter: overwrite BreakType::None Granted, this is an (extreme) edge case. Those few things that still pass through lcl_text instead of lcl_utext miss out on many things. In this case, a "character" column break was being cancelled by a paragraph NONE break (which was there to prevent a style's page break). Still missing is the ability to split the paragraph in half. I assume that a page break should never be masked by a column break, and not surprisingly no existing unit tests exhibit any of these oddities. make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf148057_columnBreak Change-Id: I4a5291946c8322ee0996e593f833515ee48f5a99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189937 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/tdf148057_columnBreak.docx b/sw/qa/extras/ooxmlexport/data/tdf148057_columnBreak.docx new file mode 100644 index 000000000000..367ae7c01ff4 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148057_columnBreak.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index b7681ff523d3..69d5db357d34 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -33,6 +33,14 @@ public: } }; +DECLARE_OOXMLEXPORT_TEST(testTdf148057_columnBreak, "tdf148057_columnBreak.docx") +{ + // given a document with a linefeed immediately following a column break (in non-column section) + + // don't lose the column break to the paragraph's no-inherited-page-break property. + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf166544_noTopMargin_fields, "tdf166544_noTopMargin_fields.docx") { // given a document with a hyperlink field containing a page break diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index 8af00b57e224..384e2e3852e8 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -4291,10 +4291,25 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len) if (!m_pImpl->GetFootnoteContext() && !m_pImpl->IsInShape() && !m_pImpl->IsInComments()) { - if (m_pImpl->isBreakDeferred(PAGE_BREAK)) - m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::Any(style::BreakType_PAGE_BEFORE)); - else if (m_pImpl->isBreakDeferred(COLUMN_BREAK)) - m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::Any(style::BreakType_COLUMN_BEFORE)); + const bool bIsPageBreak = m_pImpl->isBreakDeferred(PAGE_BREAK); + const bool bIsColumnBreak = m_pImpl->isBreakDeferred(COLUMN_BREAK); + if (bIsPageBreak || bIsColumnBreak) + { + PropertyMapPtr pParaContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH); + style::BreakType eBreakType = style::BreakType_NONE; + bool bOverwrite = bIsPageBreak; + if (!bOverwrite) + { + std::optional<PropertyMap::Property> oValue + = pParaContext->getProperty(PROP_BREAK_TYPE); + if (oValue.has_value()) + oValue->second >>= eBreakType; + bOverwrite = eBreakType == style::BreakType_NONE; + } + eBreakType + = bIsPageBreak ? style::BreakType_PAGE_BEFORE : style::BreakType_COLUMN_BEFORE; + pParaContext->Insert(PROP_BREAK_TYPE, uno::Any(eBreakType), bOverwrite); + } m_pImpl->clearDeferredBreaks(); }