summaryrefslogtreecommitdiff
path: root/sw/qa/extras/unowriter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2018-12-04 10:16:03 +0100
committerMiklos Vajna <vmiklos@collabora.com>2018-12-04 12:23:47 +0100
commita4b67dbccb4f376ac3a75f8f602ea84b8c4d00ea (patch)
tree560d882028832e9ebfdd1792781bf71aeb7a33bc /sw/qa/extras/unowriter
parent607b80ca3cddc239a35580470944a438ce144fc8 (diff)
sw: fix paragraph enumeration going past selection end
SwCursor::MovePara() may move the uno cursor past the end of the selection range, check for this explicitly. In practice this makes sure that in case a 1-paragraph cell text is selected, we never jump to the next cell for a selection created from the previous cell. Change-Id: Ibe2d00cfa75ed0c32b9c89d86cfae3b51d70ddc6 Reviewed-on: https://gerrit.libreoffice.org/64509 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/unowriter')
-rw-r--r--sw/qa/extras/unowriter/data/selection-in-table-enum.odtbin0 -> 8941 bytes
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx35
2 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/extras/unowriter/data/selection-in-table-enum.odt b/sw/qa/extras/unowriter/data/selection-in-table-enum.odt
new file mode 100644
index 000000000000..bef9b0ea71e9
--- /dev/null
+++ b/sw/qa/extras/unowriter/data/selection-in-table-enum.odt
Binary files differ
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index 96e29c303319..4bff617f62ef 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -14,6 +14,8 @@
#include <com/sun/star/text/XAutoTextGroup.hpp>
#include <com/sun/star/rdf/URI.hpp>
#include <com/sun/star/rdf/URIs.hpp>
+#include <wrtsh.hxx>
+#include <ndtxt.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -345,6 +347,39 @@ DECLARE_UNOAPI_TEST(testSetPagePrintSettings)
CPPUNIT_ASSERT_EQUAL(true, aMap.getValue("IsLandscape").get<bool>());
}
+DECLARE_UNOAPI_TEST_FILE(testSelectionInTableEnum, "selection-in-table-enum.odt")
+{
+ // Select the A1 cell's text.
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->EndPara(/*bSelect=*/true);
+ CPPUNIT_ASSERT_EQUAL(OUString("A1"),
+ pWrtShell->GetCursor()->GetNode().GetTextNode()->GetText());
+
+ // Access the selection.
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xModel.is());
+ uno::Reference<container::XIndexAccess> xSelections(xModel->getCurrentSelection(),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xSelections.is());
+ uno::Reference<text::XTextRange> xSelection(xSelections->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xSelection.is());
+
+ // Enumerate paragraphs in the selection.
+ uno::Reference<container::XEnumerationAccess> xCursor(
+ xSelection->getText()->createTextCursorByRange(xSelection), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xCursor.is());
+ uno::Reference<container::XEnumeration> xEnum = xCursor->createEnumeration();
+ xEnum->nextElement();
+ // Without the accompanying fix in place, this test would have failed: i.e.
+ // the enumeration contained a second paragraph, even if the cell has only
+ // one paragraph.
+ CPPUNIT_ASSERT(!xEnum->hasMoreElements());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */