summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-07-27 13:59:01 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-07-28 12:15:39 +0200
commit28927faf2c90e19b2a1b0b220712f088923f34c2 (patch)
tree3f4acf6cb13c0d4c2571c4e14714eb589a464f8b /sw/qa/extras
parent6e856335678034e40d3cade38ef4d856948b46a0 (diff)
sw: add new TextParagraph property to XTextRange
A text range represents a selection or cursor position, so similar to sections or tables, it makes sense to expose the containing paragraph as well. This new property does exactly that. Reviewed-on: https://gerrit.libreoffice.org/40483 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit 7ed402ba648dd0f3de3b0dadebc13403b2c0a620) Conflicts: sw/qa/extras/uiwriter/uiwriter.cxx Change-Id: If92a3b5e61f13c7c14ca52bc8593a2b286a596cc
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/uiwriter/data/paragraph-of-text-range.odtbin0 -> 8878 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx23
2 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/paragraph-of-text-range.odt b/sw/qa/extras/uiwriter/data/paragraph-of-text-range.odt
new file mode 100644
index 000000000000..52cdb0be1ff2
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/paragraph-of-text-range.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index bbd16708152c..36c1a5a10199 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -201,6 +201,7 @@ public:
void testTdf84695NormalChar();
void testTdf78727();
void testTdf104814();
+ void testParagraphOfTextRange();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -304,6 +305,7 @@ public:
CPPUNIT_TEST(testTdf84695NormalChar);
CPPUNIT_TEST(testTdf78727);
CPPUNIT_TEST(testTdf104814);
+ CPPUNIT_TEST(testParagraphOfTextRange);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3730,6 +3732,27 @@ void SwUiWriterTest::testTdf104814()
pEditShell->AcceptRedline(0);
}
+void SwUiWriterTest::testParagraphOfTextRange()
+{
+ SwDoc* pDoc = createDoc("paragraph-of-text-range.odt");
+
+ // Enter the table.
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Down(/*bSelect=*/false);
+ CPPUNIT_ASSERT(pWrtShell->IsCursorInTable());
+ // Enter the section.
+ pWrtShell->Down(/*bSelect=*/false);
+ CPPUNIT_ASSERT(pWrtShell->IsDirectlyInSection());
+
+ // Assert that we get the right paragraph object.
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursorSupplier> xController(xModel->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xViewCursor(xController->getViewCursor(), uno::UNO_QUERY);
+ // This failed as there were no TextParagraph property.
+ auto xParagraph = getProperty< uno::Reference<text::XTextRange> >(xViewCursor->getStart(), "TextParagraph");
+ CPPUNIT_ASSERT_EQUAL(OUString("In section"), xParagraph->getString());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();