summaryrefslogtreecommitdiffstats
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:47 +0000
commit91fe6b97952aa6f7cef58327fd085a17db38ad95 (patch)
tree7a4412295bfb80e15a4936fe67d4bd7b96458ce8 /sw/qa/extras/uiwriter
parentReleasing progress-linux version 4:24.2.1-4~progress7.99u1. (diff)
downloadlibreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.tar.xz
libreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.zip
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/data/FrameInHiddenSection.fodt20
-rw-r--r--sw/qa/extras/uiwriter/data/hiddenSectionsAroundPageBreak.fodt21
-rw-r--r--sw/qa/extras/uiwriter/uiwriter4.cxx15
-rw-r--r--sw/qa/extras/uiwriter/uiwriter9.cxx78
4 files changed, 124 insertions, 10 deletions
diff --git a/sw/qa/extras/uiwriter/data/FrameInHiddenSection.fodt b/sw/qa/extras/uiwriter/data/FrameInHiddenSection.fodt
new file mode 100644
index 0000000000..2095c71730
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/FrameInHiddenSection.fodt
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+ <office:text>
+ <text:section text:name="Section1">
+ <text:section text:name="Section2Hidden" text:display="none">
+ <text:p><draw:frame text:anchor-type="paragraph" svg:x="1cm" svg:y="1cm" svg:width="1cm">
+ <draw:text-box/>
+ </draw:frame>lorem</text:p>
+ </text:section>
+ <text:section text:name="Section3"/>
+ <text:section text:name="Section4"/>
+ <text:section text:name="Section5">
+ <text:p>ipsum</text:p>
+ </text:section>
+ </text:section>
+ </office:text>
+ </office:body>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/data/hiddenSectionsAroundPageBreak.fodt b/sw/qa/extras/uiwriter/data/hiddenSectionsAroundPageBreak.fodt
new file mode 100644
index 0000000000..12761847ed
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/hiddenSectionsAroundPageBreak.fodt
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:automatic-styles>
+ <style:style style:name="P1" style:family="paragraph" style:master-page-name="Landscape">
+ <style:paragraph-properties style:page-number="auto" fo:break-before="page"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:section text:name="Section 1" text:display="none"/>
+ <text:section text:name="Section 2">
+ <text:p text:style-name="P1">A paragraph with a page-break-before</text:p>
+ </text:section>
+ <text:section text:name="Section 3" text:display="none"/>
+ <text:section text:name="Section 4">
+ <text:p>Lorem</text:p>
+ </text:section>
+ </office:text>
+ </office:body>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx
index c1f0be1757..98fcbcae22 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -682,8 +682,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testBookmarkCollapsed)
// 6. Hit Del, thus deleting "abc" (The bookmark "test" is still there).
// 7. Save the document:
// <text:p text:style-name="Standard">
-// <text:bookmark-start text:name="test"/>
-// <text:bookmark-end text:name="test"/>
+// <text:bookmark text:name="test"/>
// def
// </text:p>
//
@@ -737,14 +736,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testRemoveBookmarkText)
// load only content.xml from the resaved document
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
- constexpr OString aPath("/office:document-content/office:body/office:text/text:p"_ostr);
-
- CPPUNIT_ASSERT_ASSERTION_FAIL(getXPathPosition(pXmlDoc, aPath, "bookmark")); // not found
- const int pos2 = getXPathPosition(pXmlDoc, aPath, "bookmark-start");
- const int pos3 = getXPathPosition(pXmlDoc, aPath, "bookmark-end");
-
- CPPUNIT_ASSERT_EQUAL(0, pos2); // found, and it is first
- CPPUNIT_ASSERT_EQUAL(1, pos3); // found, and it is second
+ // Bookmark without text becomes collapsed
+ assertXPath(pXmlDoc, "//office:body/office:text/text:p/text:bookmark"_ostr, 1);
+ assertXPath(pXmlDoc, "//office:body/office:text/text:p/text:bookmark-start"_ostr, 0);
+ assertXPath(pXmlDoc, "//office:body/office:text/text:p/text:bookmark-end"_ostr, 0);
}
// 1. Open a new writer document
diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx
index 1a3e49c257..3772955dd9 100644
--- a/sw/qa/extras/uiwriter/uiwriter9.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter9.cxx
@@ -16,6 +16,8 @@
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
#include <comphelper/propertysequence.hxx>
#include <swdtflvr.hxx>
#include <o3tl/string_view.hxx>
@@ -26,8 +28,10 @@
#include <ndtxt.hxx>
#include <toxmgr.hxx>
#include <IDocumentFieldsAccess.hxx>
+#include <IDocumentLayoutAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <fmtinfmt.hxx>
+#include <rootfrm.hxx>
namespace
{
@@ -122,6 +126,80 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf135083)
CPPUNIT_ASSERT(!getProperty<OUString>(xLastPara, u"ListId"_ustr).isEmpty());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testHiddenSectionsAroundPageBreak)
+{
+ createSwDoc("hiddenSectionsAroundPageBreak.fodt");
+
+ CPPUNIT_ASSERT_EQUAL(1, getPages());
+
+ auto xModel(mxComponent.queryThrow<frame::XModel>());
+ auto xTextViewCursorSupplier(
+ xModel->getCurrentController().queryThrow<text::XTextViewCursorSupplier>());
+ auto xCursor(xTextViewCursorSupplier->getViewCursor().queryThrow<text::XPageCursor>());
+
+ // Make sure that the page style is set correctly
+ xCursor->jumpToFirstPage();
+ CPPUNIT_ASSERT_EQUAL(u"Landscape"_ustr, getProperty<OUString>(xCursor, "PageStyleName"));
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf159565)
+{
+ // Given a document with a hidden section in the beginning, additionally containing a frame
+ createSwDoc("FrameInHiddenSection.fodt");
+
+ dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {});
+
+ // Check that the selection covers the whole visible text
+ auto xModel(mxComponent.queryThrow<css::frame::XModel>());
+ auto xSelSupplier(xModel->getCurrentController().queryThrow<css::view::XSelectionSupplier>());
+ auto xSelections(xSelSupplier->getSelection().queryThrow<css::container::XIndexAccess>());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSelections->getCount());
+ auto xSelection(xSelections->getByIndex(0).queryThrow<css::text::XTextRange>());
+
+ // Without the fix, this would fail - there was no selection
+ CPPUNIT_ASSERT_EQUAL(u"" SAL_NEWLINE_STRING SAL_NEWLINE_STRING "ipsum"_ustr,
+ xSelection->getString());
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf159816)
+{
+ createSwDoc();
+
+ SwDoc* pDoc = getSwDoc();
+ CPPUNIT_ASSERT(pDoc);
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ // Add 5 empty paragraphs
+ pWrtShell->SplitNode();
+ pWrtShell->SplitNode();
+ pWrtShell->SplitNode();
+ pWrtShell->SplitNode();
+ pWrtShell->SplitNode();
+
+ // Add a bookmark at the very end
+ IDocumentMarkAccess& rIDMA(*pDoc->getIDocumentMarkAccess());
+ rIDMA.makeMark(*pWrtShell->GetCursor(), "Mark", IDocumentMarkAccess::MarkType::BOOKMARK,
+ sw::mark::InsertMode::New);
+
+ // Get coordinates of the end point in the document
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ SwFrame* pPage = pLayout->Lower();
+ SwFrame* pBody = pPage->GetLower();
+ SwFrame* pLastPara = pBody->GetLower()->GetNext()->GetNext()->GetNext()->GetNext()->GetNext();
+ Point ptTo = pLastPara->getFrameArea().BottomRight();
+
+ pWrtShell->SelAll();
+
+ // Drag-n-drop to its own end
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ // Without the fix, this would crash: either in CopyFlyInFlyImpl (tdf#159813):
+ // Assertion failed: !pCopiedPaM || pCopiedPaM->End()->GetNode() == rRg.aEnd.GetNode()
+ // or in BigPtrArray::operator[] (tdf#159816):
+ // Assertion failed: idx < m_nSize
+ xTransfer->PrivateDrop(*pWrtShell, ptTo, /*bMove=*/true, /*bXSelection=*/true);
+}
+
} // end of anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();