sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx |binary sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 17 ++ sw/qa/extras/rtfexport/data/n818997B.rtf | 77 ++++++++++ sw/qa/extras/rtfexport/rtfexport5.cxx | 6 writerfilter/source/dmapper/DomainMapper.cxx | 16 +- 6 files changed, 108 insertions(+), 8 deletions(-)
New commits: commit 943a6a3b627d88a88bc2441d060c35987e3fc7c2 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Wed Feb 15 13:54:31 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Mar 8 22:39:16 2023 +0000 tdf#153613 writerfilter: don't always split para for shape w/ pagebreak The problem was that an extra paragraph was added, and the shape was anchored to the wrong page. There are lots of places that handle deferred breaks, and they typically do this only for FirstParagraph or non-first character properties run. This is needed here too. make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf153613_textboxAfterPgBreak make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf153613_textboxAfterPgBreak2 Of course, RTF is goofy, so handle that as an exception to just leave it alone as it has been. To solve it properly is likely very tricky - as are all things RTF, because we can't trust IsFirstRun in general and especially not for RTF. make CppunitTest_sw_rtfexport5 CPPUNIT_TEST_NAME=testN818997B Change-Id: Iad06f3ea9684a2860ae6ba724887bdf0b5850f94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147169 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147179 Tested-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx new file mode 100644 index 000000000000..4ad4dfba8110 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx new file mode 100644 index 000000000000..26006abd2fe3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153613_textboxAfterPgBreak2.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index f6d1d48094f0..3b26dded9fbc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -130,6 +130,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153613_inlineAfterPgBreak, "tdf153613_inlineAfte assertXPath(pLayout, "//page[2]//anchored", 1); } +DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak, "tdf153613_textboxAfterPgBreak.docx") +{ + CPPUNIT_ASSERT_EQUAL(3, getParagraphs()); + + const auto& pLayout = parseLayoutDump(); + assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no prior carriage return."); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf153613_textboxAfterPgBreak2, "tdf153613_textboxAfterPgBreak2.docx") +{ + // same as previous example, except that it is the first paragraph in the section. + CPPUNIT_ASSERT_EQUAL(2, getParagraphs()); + + const auto& pLayout = parseLayoutDump(); + assertXPathContent(pLayout, "//page[2]/body/txt", "There should be no prior carriage return."); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert) { // Given a docx document with a shape with vert="mongolianVert". diff --git a/sw/qa/extras/rtfexport/data/n818997B.rtf b/sw/qa/extras/rtfexport/data/n818997B.rtf new file mode 100644 index 000000000000..94c0324f42e8 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/n818997B.rtf @@ -0,0 +1,77 @@ +{\rtf +{\par\par\shp +{\*\shpinst\shpleft2310\shpright6060\shptop8685\shpbottom8985\shpbxpage +\shpbypage\shpwr3\shpz2 +{\sp +{\sn shapeType} +{\sv 202} +} +{\sp +{\sn dxTextLeft} +{\sv +0} +} +{\sp +{\sn dxTextRight} +{\sv 0} +} +{\sp +{\sn dyTextTop} +{\sv 0} +} +{\sp +{\sn +dyTextBottom} +{\sv 0} +} +{\sp +{\sn fLine} +{\sv 0} +} +{\shptxt\plain\pard\f29\fs24 +On first page.\par} +{\sp +{\sn fFilled} +{\sv 0} +} +} +} +\page +{\shp +{\*\shpinst\shpleft4800\shpright8025\shptop780\shpbottom1080\shpbxpage +\shpbypage\shpwr3\shpz2 +{\sp +{\sn shapeType} +{\sv 202} +} +{\sp +{\sn dxTextLeft} +{\sv +0} +} +{\sp +{\sn dxTextRight} +{\sv 0} +} +{\sp +{\sn dyTextTop} +{\sv 0} +} +{\sp +{\sn +dyTextBottom} +{\sv 0} +} +{\sp +{\sn fLine} +{\sv 0} +} +{\shptxt\plain\pard\f29\fs24\b +On second page.\par} +{\sp +{\sn fFilled} +{\sv 0} +} +} +} +} diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 751269daac03..8d122ec97b63 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -103,6 +103,12 @@ DECLARE_RTFEXPORT_TEST(testN818997, "n818997.rtf") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +DECLARE_RTFEXPORT_TEST(testN818997B, "n818997B.rtf") +{ + // \page was ignored between two \shp tokens - this time not IsFirstParagraphInSection. + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + DECLARE_RTFEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, "tdf153613_anchoredAfterPgBreak.rtf") { // An anchored TO character image (followed by nothing) anchors before the page break, no split. diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index a9e35622a966..8ca3d6c6c0ac 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3594,14 +3594,14 @@ void DomainMapper::lcl_startShape(uno::Reference<drawing::XShape> const& xShape) // started shape will be on the correct page. if (m_pImpl->isBreakDeferred(PAGE_BREAK)) { - m_pImpl->clearDeferredBreak(PAGE_BREAK); - lcl_startCharacterGroup(); - sal_uInt8 const sBreak[] = { 0xd }; - lcl_text(sBreak, 1); - lcl_endCharacterGroup(); - lcl_endParagraphGroup(); - lcl_startParagraphGroup(); - m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::Any(style::BreakType_PAGE_BEFORE)); + // RTF doesn't properly report IsFirstRun, so in order to prevent regressions + // always split the paragraph for RTF since that is the way it has been done lately. + if (!m_pImpl->IsFirstRun() || IsRTFImport()) + { + m_pImpl->m_bIsSplitPara = true; + finishParagraph(); + lcl_startParagraphGroup(); + } } m_pImpl->PushShapeContext( xShape ); lcl_startParagraphGroup();