From 97ac77f067910fa5e8206d75160fa63546a9358d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 07:03:24 +0200 Subject: Merging upstream version 4:24.2.3. Signed-off-by: Daniel Baumann --- .../accessibilitycheck/AccessibilityCheckTest.cxx | 11 ++++ sw/qa/core/accessibilitycheck/data/Tabs-in-TOC.odt | Bin 0 -> 15284 bytes sw/qa/core/layout/data/floattable-header.docx | Bin 0 -> 31604 bytes sw/qa/core/layout/data/floattable-in-section.docx | Bin 14024 -> 16073 bytes sw/qa/core/layout/layact.cxx | 22 ++++++++ sw/qa/core/layout/tabfrm.cxx | 21 ++++++++ sw/qa/extras/htmlexport/data/tdf160390.fodt | 17 ++++++ sw/qa/extras/htmlexport/htmlexport.cxx | 7 +++ sw/qa/extras/layout/data/tdf160526.fodt | 47 ++++++++++++++++ sw/qa/extras/layout/data/tdf160549.fodt | 60 +++++++++++++++++++++ sw/qa/extras/layout/layout3.cxx | 21 ++++++++ sw/qa/extras/odfexport/data/tdf160700.odt | Bin 0 -> 10398 bytes sw/qa/extras/odfexport/odfexport2.cxx | 30 +++++++++++ sw/qa/extras/uiwriter/uiwriter5.cxx | 2 - sw/qa/extras/unowriter/unowriter.cxx | 21 ++++++++ sw/qa/uitest/writer_tests2/formatParagraph.py | 2 +- 16 files changed, 258 insertions(+), 3 deletions(-) create mode 100644 sw/qa/core/accessibilitycheck/data/Tabs-in-TOC.odt create mode 100644 sw/qa/core/layout/data/floattable-header.docx create mode 100644 sw/qa/extras/htmlexport/data/tdf160390.fodt create mode 100644 sw/qa/extras/layout/data/tdf160526.fodt create mode 100644 sw/qa/extras/layout/data/tdf160549.fodt create mode 100644 sw/qa/extras/odfexport/data/tdf160700.odt (limited to 'sw/qa') diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 117b48d016..bfe2e08d85 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -251,6 +251,17 @@ scanAccessibilityIssuesOnNodes(SwDoc* pDocument) return aIssues; } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTabsinTOC) +{ + createSwDoc("Tabs-in-TOC.odt"); + SwDoc* pDoc = getSwDoc(); + CPPUNIT_ASSERT(pDoc); + sw::AccessibilityCheck aCheck(pDoc); + aCheck.check(); + auto& aIssues = aCheck.getIssueCollection().getIssues(); + CPPUNIT_ASSERT_EQUAL(size_t(0), aIssues.size()); +} + void checkIssuePosition(std::shared_ptr const& pIssue, int nLine, sal_Int32 nStart, sal_Int32 nEnd, SwNodeOffset nIndex) { diff --git a/sw/qa/core/accessibilitycheck/data/Tabs-in-TOC.odt b/sw/qa/core/accessibilitycheck/data/Tabs-in-TOC.odt new file mode 100644 index 0000000000..2b3ce54cc5 Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/Tabs-in-TOC.odt differ diff --git a/sw/qa/core/layout/data/floattable-header.docx b/sw/qa/core/layout/data/floattable-header.docx new file mode 100644 index 0000000000..baddd365ce Binary files /dev/null and b/sw/qa/core/layout/data/floattable-header.docx differ diff --git a/sw/qa/core/layout/data/floattable-in-section.docx b/sw/qa/core/layout/data/floattable-in-section.docx index a0e9090bcc..9aab264867 100644 Binary files a/sw/qa/core/layout/data/floattable-in-section.docx and b/sw/qa/core/layout/data/floattable-in-section.docx differ diff --git a/sw/qa/core/layout/layact.cxx b/sw/qa/core/layout/layact.cxx index d432ae52b7..8923d6b0e8 100644 --- a/sw/qa/core/layout/layact.cxx +++ b/sw/qa/core/layout/layact.cxx @@ -86,6 +86,28 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf157096) CPPUNIT_ASSERT_EQUAL(1, getPages()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInSection) +{ + // Given a document with multiple sections, the 2nd section on page 1 has a one-page floating + // table: + createSwDoc("floattable-in-section.docx"); + + // When laying out that document: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + + // Then make sure the table is on page 1, not on page 2: + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + // Without the fix in place, it would have failed, the table was on page 2, not on page 1. + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(!pPage2->GetSortedObjs()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx index e0d099c771..9bfbd1b82e 100644 --- a/sw/qa/core/layout/tabfrm.cxx +++ b/sw/qa/core/layout/tabfrm.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include namespace { @@ -235,6 +237,25 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWrappedByTableNested) CPPUNIT_ASSERT_EQUAL(static_cast(3), pDoc->GetTableFrameFormats()->GetFormatCount()); CPPUNIT_ASSERT_EQUAL(static_cast(1), pDoc->GetSpzFrameFormats()->GetFormatCount()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyHeader) +{ + // Given a document with 8 pages: a first page ending in a manual page break, then a multi-page + // floating table on pages 2..8: + createSwDoc("floattable-header.docx"); + CPPUNIT_ASSERT_EQUAL(8, getPages()); + + // When creating a new paragraph at doc start: + SwDocShell* pDocShell = getSwDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->SplitNode(); + // Without the accompanying fix in place, this test would have crashed here. + pWrtShell->CalcLayout(); + + // Then make sure we get one more page, since the first page is now 2 pages: + CPPUNIT_ASSERT_EQUAL(9, getPages()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/htmlexport/data/tdf160390.fodt b/sw/qa/extras/htmlexport/data/tdf160390.fodt new file mode 100644 index 0000000000..53d6144ff1 --- /dev/null +++ b/sw/qa/extras/htmlexport/data/tdf160390.fodt @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + foo + + + \ No newline at end of file diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index de2e9da4c6..42099f3bc4 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -3053,6 +3053,13 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_Tdf160017_spanClosingOrder) CPPUNIT_ASSERT(parseXml(maTempFile)); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_Tdf160390) +{ + // This document must not hang infinitely on HTML export + createSwDoc("tdf160390.fodt"); + ExportToHTML(); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/layout/data/tdf160526.fodt b/sw/qa/extras/layout/data/tdf160526.fodt new file mode 100644 index 0000000000..37cf73fb8e --- /dev/null +++ b/sw/qa/extras/layout/data/tdf160526.fodt @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Foo + + + + + + \ No newline at end of file diff --git a/sw/qa/extras/layout/data/tdf160549.fodt b/sw/qa/extras/layout/data/tdf160549.fodt new file mode 100644 index 0000000000..fd8425eedd --- /dev/null +++ b/sw/qa/extras/layout/data/tdf160549.fodt @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + foobar + + + + + + + + + + + + + \ No newline at end of file diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index a074a35dc6..98c77b18ec 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -2353,6 +2353,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testPageBreakInHiddenSection) assertXPath(pXmlDoc, "//page[4]/body/section/infos/bounds"_ostr, "height"_ostr, u"0"_ustr); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf160549) +{ + // Given a document with a large as-char object, alone in its paragraph, shifted down by a + // header object: it must not hang in a layout loop on import (similar to i84870, but not + // fixed by its fix) + createSwDoc("tdf160549.fodt"); + // The object is the first in the document; it must not move to the next page + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf160526) +{ + // Given a document with a large as-char object, alone in its paragraph, shifted down by + // another body object + createSwDoc("tdf160526.fodt"); + // It must move to the next page + CPPUNIT_ASSERT_EQUAL(2, getPages()); + auto pExportDump = parseLayoutDump(); + assertXPath(pExportDump, "//page[2]/body/txt/anchored/SwAnchoredDrawObject"_ostr); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/odfexport/data/tdf160700.odt b/sw/qa/extras/odfexport/data/tdf160700.odt new file mode 100644 index 0000000000..bc1515da3f Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf160700.odt differ diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index 4983608290..f654821acf 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1343,6 +1344,35 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf159438) u"bookmark3"_ustr); } +CPPUNIT_TEST_FIXTURE(Test, testTdf160700) +{ + // Given a document with an empty numbered paragraph, and a cross-reference to it + loadAndReload("tdf160700.odt"); + + // Refresh fields and ensure cross-reference to numbered para is okay + auto xTextFieldsSupplier(mxComponent.queryThrow()); + auto xFieldsAccess(xTextFieldsSupplier->getTextFields()); + + xFieldsAccess.queryThrow()->refresh(); + + auto xFields(xFieldsAccess->createEnumeration()); + CPPUNIT_ASSERT(xFields->hasMoreElements()); + auto xTextField(xFields->nextElement().queryThrow()); + // Save must not create markup with text:bookmark-end element before text:bookmark-start + // Withoud the fix, this would fail with + // - Expected: 1 + // - Actual : Error: Reference source not found + // i.e., the bookmark wasn't imported, and the field had no proper source + CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xTextField->getPresentation(false)); + + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + // Check that we export the bookmark in the empty paragraph as a single text:bookmark + // element. Another walid markup is text:bookmark-start followed by text:bookmark-end + // (in that order). The problem was, that text:bookmark-end was before text:bookmark-start. + assertXPathChildren(pXmlDoc, "//office:text/text:list/text:list-item/text:p"_ostr, 1); + assertXPath(pXmlDoc, "//office:text/text:list/text:list-item/text:p/text:bookmark"_ostr); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index c6353f980d..702f6d7dd3 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -3007,7 +3007,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156487) assertXPath(pXmlDoc, "/metafile/push/push/push/textarray/text"_ostr, 1); } -#ifndef DBG_UTIL CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) { // load a table, and delete the first column with enabled change tracking: @@ -3023,7 +3022,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) // this would crash due to bookmark over cell boundary dispatchCommand(mxComponent, ".uno:Undo", {}); } -#endif CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150673_RedlineTableColumnDeletionWithExport) { diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx index 8bcadbaf42..80b9e556f7 100644 --- a/sw/qa/extras/unowriter/unowriter.cxx +++ b/sw/qa/extras/unowriter/unowriter.cxx @@ -1201,6 +1201,27 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTdf129841) CPPUNIT_ASSERT_EQUAL(aRefColor, aColor); } +CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTdf160278) +{ + createSwDoc(); + auto xTextDocument(mxComponent.queryThrow()); + auto xText(xTextDocument->getText()); + xText->setString(u"123"_ustr); + CPPUNIT_ASSERT_EQUAL(u"123"_ustr, xText->getString()); + auto xCursor = xText->createTextCursorByRange(xText->getEnd()); + xCursor->goLeft(1, true); + CPPUNIT_ASSERT_EQUAL(u"3"_ustr, xCursor->getString()); + // Insert an SMP character U+1f702 (so it's two UTF-16 code units, 0xd83d 0xdf02): + xCursor->setString(u"🜂"_ustr); + // Without the fix, the replacement would expand the cursor one too many characters to the left, + // and the cursor text would become "2🜂", failing the next test: + CPPUNIT_ASSERT_EQUAL(u"🜂"_ustr, xCursor->getString()); + xCursor->setString(u"test"_ustr); + CPPUNIT_ASSERT_EQUAL(u"test"_ustr, xCursor->getString()); + // This test would fail, too; the text would be "1test": + CPPUNIT_ASSERT_EQUAL(u"12test"_ustr, xText->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/uitest/writer_tests2/formatParagraph.py b/sw/qa/uitest/writer_tests2/formatParagraph.py index e90d0fd7f9..bfa6eff48d 100644 --- a/sw/qa/uitest/writer_tests2/formatParagraph.py +++ b/sw/qa/uitest/writer_tests2/formatParagraph.py @@ -177,7 +177,7 @@ class formatParagraph(UITestCase): self.assertEqual(get_state_as_dict(xspinWidow)["Text"], "2") self.assertEqual(get_state_as_dict(xcheckWidow)["Selected"], "false") self.assertEqual(get_state_as_dict(xcheckOrphan)["Selected"], "false") - self.assertEqual(get_state_as_dict(xcheckSplitPara)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckSplitPara)["Selected"], "false") self.assertEqual(get_state_as_dict(xcheckKeepPara)["Selected"], "true") -- cgit v1.2.3