sw/qa/extras/ww8export/data/continuous-sections.doc |binary sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.doc |binary sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.doc |binary sw/qa/extras/ww8export/ww8export.cxx | 11 ++ sw/qa/extras/ww8export/ww8export4.cxx | 61 ++++++++++++ sw/source/filter/ww8/ww8par.cxx | 5 6 files changed, 76 insertions(+), 1 deletion(-)
New commits: commit 6819adb7a66a162f5be40990ea62689cd58f7c8b Author: Paris Oplopoios <[email protected]> AuthorDate: Tue Jul 18 17:23:12 2023 +0300 Commit: Paris Oplopoios <[email protected]> CommitDate: Wed Jul 19 14:19:37 2023 +0200 sw: Add test for continuous section breaks not adding page breaks Change-Id: I1dbaa0075ff33012c7cc94f1aa82dd992dd0e680 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154588 Tested-by: Jenkins Reviewed-by: Paris Oplopoios <[email protected]> diff --git a/sw/qa/extras/ww8export/data/continuous-sections.doc b/sw/qa/extras/ww8export/data/continuous-sections.doc new file mode 100644 index 000000000000..cf466c9e7286 Binary files /dev/null and b/sw/qa/extras/ww8export/data/continuous-sections.doc differ diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 616df9bb9189..f767d51bbe96 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -1571,6 +1571,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf99474) CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xStyle, "CharColor")); } +DECLARE_WW8EXPORT_TEST(testContinuousSectionsNoPageBreak, "continuous-sections.doc") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT(pDoc); + + // Continuous section breaks should not add new pages + CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetPageDescCnt()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit b33e485b1dc9aec04a8899671abf5397face30cd Author: Paris Oplopoios <[email protected]> AuthorDate: Wed Jul 12 16:56:25 2023 +0300 Commit: Paris Oplopoios <[email protected]> CommitDate: Wed Jul 19 14:19:28 2023 +0200 Fix inline page breaks not imported correctly from .doc files The way we handle page breaks is by creating new paragraphs. This visually looks fine until the imported file has stuff like first line indentation. Change-Id: I26d5bbc1ce8b0ff4492b099305f0ff22de41e4cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154358 Tested-by: Jenkins Reviewed-by: Paris Oplopoios <[email protected]> diff --git a/sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.doc b/sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.doc new file mode 100644 index 000000000000..4f339511d664 Binary files /dev/null and b/sw/qa/extras/ww8export/data/inlinePageBreakFirstLine.doc differ diff --git a/sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.doc b/sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.doc new file mode 100644 index 000000000000..5351a9edecc7 Binary files /dev/null and b/sw/qa/extras/ww8export/data/nonInlinePageBreakFirstLine.doc differ diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index 7e3042aefab2..459daa69ec81 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -25,6 +25,8 @@ #include <IDocumentMarkAccess.hxx> #include <IDocumentSettingAccess.hxx> #include <unotxdoc.hxx> +#include <ndtxt.hxx> +#include <editeng/lrspitem.hxx> class Test : public SwModelTestBase { @@ -142,6 +144,65 @@ CPPUNIT_TEST_FIXTURE(Test, testDontBreakWrappedTables) CPPUNIT_ASSERT(bDontBreakWrappedTables); } +static bool IsFirstLine(const SwTextNode* pTextNode) +{ + const SfxPoolItem* pItem = pTextNode->GetNoCondAttr(RES_MARGIN_FIRSTLINE, false); + return !!pItem; +} + +DECLARE_WW8EXPORT_TEST(testInlinePageBreakFirstLine, "inlinePageBreakFirstLine.doc") +{ + SwDoc* pDoc = getSwDoc(); + const SwNodes& rNodes = pDoc->GetNodes(); + + std::vector<SwTextNode*> aTextNodes; + + for (SwNodeOffset nNode(0); nNode < rNodes.Count(); ++nNode) + { + SwNode* pNode = pDoc->GetNodes()[nNode]; + SwTextNode* pTextNode = pNode->GetTextNode(); + if (!pTextNode) + continue; + aTextNodes.push_back(pTextNode); + } + + CPPUNIT_ASSERT_EQUAL(size_t(3), aTextNodes.size()); + CPPUNIT_ASSERT_EQUAL(OUString("First line"), aTextNodes[0]->GetText()); + CPPUNIT_ASSERT(IsFirstLine(aTextNodes[0])); + // Here exists an inline pagebreak (a pagebreak without a paragraph before it) + // This text node is not indented because it is not the first line of the paragraph + CPPUNIT_ASSERT_EQUAL(OUString("Should not be indented"), aTextNodes[1]->GetText()); + CPPUNIT_ASSERT(!IsFirstLine(aTextNodes[1])); + // Here is the actual second paragraph + CPPUNIT_ASSERT_EQUAL(OUString("Should be indented"), aTextNodes[2]->GetText()); + CPPUNIT_ASSERT(IsFirstLine(aTextNodes[2])); +} + +DECLARE_WW8EXPORT_TEST(testNonInlinePageBreakFirstLine, "nonInlinePageBreakFirstLine.doc") +{ + SwDoc* pDoc = getSwDoc(); + const SwNodes& rNodes = pDoc->GetNodes(); + + std::vector<SwTextNode*> aTextNodes; + + for (SwNodeOffset nNode(0); nNode < rNodes.Count(); ++nNode) + { + SwNode* pNode = pDoc->GetNodes()[nNode]; + SwTextNode* pTextNode = pNode->GetTextNode(); + if (!pTextNode) + continue; + aTextNodes.push_back(pTextNode); + } + + CPPUNIT_ASSERT_EQUAL(size_t(2), aTextNodes.size()); + CPPUNIT_ASSERT_EQUAL(OUString("First line"), aTextNodes[0]->GetText()); + CPPUNIT_ASSERT(IsFirstLine(aTextNodes[0])); + // Here exists a pagebreak after a paragraph + // This text node is indented because it is the first line of a paragraph + CPPUNIT_ASSERT_EQUAL(OUString("Should be indented"), aTextNodes[1]->GetText()); + CPPUNIT_ASSERT(IsFirstLine(aTextNodes[1])); +} + DECLARE_WW8EXPORT_TEST(testTdf104704_mangledFooter, "tdf104704_mangledFooter.odt") { CPPUNIT_ASSERT_EQUAL(2, getPages()); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 04c00b90b78e..e2d6b35e7345 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1418,7 +1418,10 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, if (firstLineNew != firstLineOld) { - pNd->SetAttr(firstLineNew); + if (nStart == aRegion.Start()->GetNodeIndex()) + { + pNd->SetAttr(firstLineNew); + } } if (leftMarginNew != leftMarginOld) {
