summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test/text/xtextrangecompare.hxx37
-rw-r--r--qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXBodyText.csv2
-rw-r--r--qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXFootnoteText.csv2
-rw-r--r--qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXHeadFootText.csv2
-rw-r--r--sw/qa/api/SwXBodyText.cxx6
-rw-r--r--sw/qa/api/SwXFootnoteText.cxx6
-rw-r--r--sw/qa/api/SwXHeadFootText.cxx34
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/text/xtextrangecompare.cxx76
9 files changed, 143 insertions, 23 deletions
diff --git a/include/test/text/xtextrangecompare.hxx b/include/test/text/xtextrangecompare.hxx
new file mode 100644
index 000000000000..b7e36a5cc445
--- /dev/null
+++ b/include/test/text/xtextrangecompare.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <rtl/ustring.hxx>
+#include <test/testdllapi.hxx>
+
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <utility>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST XTextRangeCompare
+{
+public:
+ virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+ void testCompareRegionStarts();
+ void testCompareRegionEnds();
+
+protected:
+ ~XTextRangeCompare() {}
+};
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXBodyText.csv b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXBodyText.csv
index 45ebfd332ec9..44603eda85f2 100644
--- a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXBodyText.csv
+++ b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXBodyText.csv
@@ -1,6 +1,4 @@
"SwXBodyText";"com::sun::star::text::XTextRangeMover#optional";"moveTextRange()"
-"SwXBodyText";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionStarts()"
-"SwXBodyText";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionEnds()"
"SwXBodyText";"com::sun::star::text::XSimpleText";"createTextCursor()"
"SwXBodyText";"com::sun::star::text::XSimpleText";"createTextCursorByRange()"
"SwXBodyText";"com::sun::star::text::XSimpleText";"insertString()"
diff --git a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXFootnoteText.csv b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXFootnoteText.csv
index 3f3663b8c2dd..6bba3d3cf263 100644
--- a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXFootnoteText.csv
+++ b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXFootnoteText.csv
@@ -1,6 +1,4 @@
"SwXFootnoteText";"com::sun::star::text::XTextRangeMover#optional";"moveTextRange()"
-"SwXFootnoteText";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionStarts()"
-"SwXFootnoteText";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionEnds()"
"SwXFootnoteText";"com::sun::star::text::XSimpleText";"createTextCursor()"
"SwXFootnoteText";"com::sun::star::text::XSimpleText";"createTextCursorByRange()"
"SwXFootnoteText";"com::sun::star::text::XSimpleText";"insertString()"
diff --git a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXHeadFootText.csv b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXHeadFootText.csv
index 0602fbf2e584..7e780f968a58 100644
--- a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXHeadFootText.csv
+++ b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXHeadFootText.csv
@@ -1,6 +1,4 @@
"SwXHeadFootText";"com::sun::star::text::XTextRangeMover#optional";"moveTextRange()"
-"SwXHeadFootText";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionStarts()"
-"SwXHeadFootText";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionEnds()"
"SwXHeadFootText";"com::sun::star::text::XSimpleText";"createTextCursor()"
"SwXHeadFootText";"com::sun::star::text::XSimpleText";"createTextCursorByRange()"
"SwXHeadFootText";"com::sun::star::text::XSimpleText";"insertString()"
diff --git a/sw/qa/api/SwXBodyText.cxx b/sw/qa/api/SwXBodyText.cxx
index d364ba3a8aa0..69fb22a959b2 100644
--- a/sw/qa/api/SwXBodyText.cxx
+++ b/sw/qa/api/SwXBodyText.cxx
@@ -12,6 +12,7 @@
#include <test/container/xelementaccess.hxx>
#include <test/text/xtextrange.hxx>
#include <test/container/xenumerationaccess.hxx>
+#include <test/text/xtextrangecompare.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -36,7 +37,8 @@ class SwXBodyText final : public test::BootstrapFixture,
public apitest::XElementAccess,
public apitest::XTextRange,
public apitest::XSimpleText,
- public apitest::XEnumerationAccess
+ public apitest::XEnumerationAccess,
+ public apitest::XTextRangeCompare
{
public:
SwXBodyText();
@@ -57,6 +59,8 @@ public:
CPPUNIT_TEST(testGetEnd);
CPPUNIT_TEST(testGetSetString);
CPPUNIT_TEST(testCreateEnumeration);
+ CPPUNIT_TEST(testCompareRegionStarts);
+ CPPUNIT_TEST(testCompareRegionEnds);
CPPUNIT_TEST_SUITE_END();
private:
diff --git a/sw/qa/api/SwXFootnoteText.cxx b/sw/qa/api/SwXFootnoteText.cxx
index 9e8bab00c544..23697293352a 100644
--- a/sw/qa/api/SwXFootnoteText.cxx
+++ b/sw/qa/api/SwXFootnoteText.cxx
@@ -13,6 +13,7 @@
#include <test/text/xtextrange.hxx>
#include <test/text/xtext.hxx>
#include <test/container/xenumerationaccess.hxx>
+#include <test/text/xtextrangecompare.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -40,7 +41,8 @@ class SwXFootnoteText final : public test::BootstrapFixture,
public apitest::XSimpleText,
public apitest::XTextRange,
public apitest::XText,
- public apitest::XEnumerationAccess
+ public apitest::XEnumerationAccess,
+ public apitest::XTextRangeCompare
{
public:
SwXFootnoteText();
@@ -63,6 +65,8 @@ public:
CPPUNIT_TEST(testGetText);
// CPPUNIT_TEST(testInsertRemoveTextContent);
CPPUNIT_TEST(testCreateEnumeration);
+ CPPUNIT_TEST(testCompareRegionStarts);
+ CPPUNIT_TEST(testCompareRegionEnds);
CPPUNIT_TEST_SUITE_END();
private:
diff --git a/sw/qa/api/SwXHeadFootText.cxx b/sw/qa/api/SwXHeadFootText.cxx
index ca51ba8c0069..b3769ccc58a1 100644
--- a/sw/qa/api/SwXHeadFootText.cxx
+++ b/sw/qa/api/SwXHeadFootText.cxx
@@ -13,6 +13,7 @@
#include <test/text/xtextrange.hxx>
#include <test/text/xtext.hxx>
#include <test/container/xenumerationaccess.hxx>
+#include <test/text/xtextrangecompare.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -34,25 +35,26 @@ using namespace css::uno;
namespace
{
/**
- * Initial tests for SwXHeadFootTextText.
+ * Initial tests for SwXHeadFootText.
*/
-class SwXHeadFootTextText final : public test::BootstrapFixture,
- public unotest::MacrosTest,
- public apitest::XElementAccess,
- public apitest::XSimpleText,
- public apitest::XTextRange,
- public apitest::XText,
- public apitest::XEnumerationAccess
+class SwXHeadFootText final : public test::BootstrapFixture,
+ public unotest::MacrosTest,
+ public apitest::XElementAccess,
+ public apitest::XSimpleText,
+ public apitest::XTextRange,
+ public apitest::XText,
+ public apitest::XEnumerationAccess,
+ public apitest::XTextRangeCompare
{
public:
- SwXHeadFootTextText();
+ SwXHeadFootText();
virtual void setUp() override;
void tearDown() override;
Reference<XInterface> init() override;
Reference<text::XTextContent> getTextContent() override { return mxTextContent; };
- CPPUNIT_TEST_SUITE(SwXHeadFootTextText);
+ CPPUNIT_TEST_SUITE(SwXHeadFootText);
CPPUNIT_TEST(testGetElementType);
CPPUNIT_TEST(testHasElements);
CPPUNIT_TEST(testCreateTextCursor);
@@ -65,6 +67,8 @@ public:
CPPUNIT_TEST(testGetText);
// CPPUNIT_TEST(testInsertRemoveTextContent);
CPPUNIT_TEST(testCreateEnumeration);
+ CPPUNIT_TEST(testCompareRegionStarts);
+ CPPUNIT_TEST(testCompareRegionEnds);
CPPUNIT_TEST_SUITE_END();
private:
@@ -72,19 +76,19 @@ private:
Reference<text::XTextContent> mxTextContent;
};
-SwXHeadFootTextText::SwXHeadFootTextText()
+SwXHeadFootText::SwXHeadFootText()
: XElementAccess(cppu::UnoType<text::XTextRange>::get())
{
}
-void SwXHeadFootTextText::setUp()
+void SwXHeadFootText::setUp()
{
test::BootstrapFixture::setUp();
mxDesktop.set(
frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
}
-void SwXHeadFootTextText::tearDown()
+void SwXHeadFootText::tearDown()
{
if (component_.is())
component_->dispose();
@@ -92,7 +96,7 @@ void SwXHeadFootTextText::tearDown()
test::BootstrapFixture::tearDown();
}
-Reference<XInterface> SwXHeadFootTextText::init()
+Reference<XInterface> SwXHeadFootText::init()
{
component_ = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
Reference<text::XTextDocument> xTextDocument(component_, UNO_QUERY_THROW);
@@ -114,7 +118,7 @@ Reference<XInterface> SwXHeadFootTextText::init()
return Reference<XInterface>(xText, UNO_QUERY_THROW);
}
-CPPUNIT_TEST_SUITE_REGISTRATION(SwXHeadFootTextText);
+CPPUNIT_TEST_SUITE_REGISTRATION(SwXHeadFootText);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index de084b1ab9e0..a8f4258df040 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -197,6 +197,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/text/xtextcontent \
test/source/text/xtextfield \
test/source/text/xtextrange \
+ test/source/text/xtextrangecompare \
test/source/text/xdocumentindex \
test/source/text/textdocumentsettings \
test/source/text/textprintersettings \
diff --git a/test/source/text/xtextrangecompare.cxx b/test/source/text/xtextrangecompare.cxx
new file mode 100644
index 000000000000..b31d6b864332
--- /dev/null
+++ b/test/source/text/xtextrangecompare.cxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/text/xtextrangecompare.hxx>
+
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextRangeCompare.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XTextRangeCompare::testCompareRegionStarts()
+{
+ Reference<text::XTextRangeCompare> xCompare(init(), UNO_QUERY_THROW);
+ Reference<text::XText> xText(xCompare, UNO_QUERY_THROW);
+
+ try
+ {
+ Reference<text::XTextCursor> xCursor1 = xText->createTextCursor();
+ xText->insertString(xCursor1, "XTextRangeCompare", false);
+
+ xCursor1->gotoStart(false);
+ xCursor1->goRight(5, true);
+ Reference<text::XTextCursor> xCursor2 = xText->createTextCursor();
+ xCursor2->gotoEnd(false);
+ xCursor2->goLeft(7, true);
+
+ CPPUNIT_ASSERT(xCompare->compareRegionStarts(xCursor1, xCursor2));
+ }
+ catch (lang::IllegalArgumentException&)
+ {
+ }
+}
+
+void XTextRangeCompare::testCompareRegionEnds()
+{
+ Reference<text::XTextRangeCompare> xCompare(init(), UNO_QUERY_THROW);
+ Reference<text::XText> xText(xCompare, UNO_QUERY_THROW);
+
+ try
+ {
+ Reference<text::XTextCursor> xCursor1 = xText->createTextCursor();
+ xText->insertString(xCursor1, "XTextRangeCompare", false);
+
+ xCursor1->gotoStart(false);
+ xCursor1->goRight(5, true);
+ Reference<text::XTextCursor> xCursor2 = xText->createTextCursor();
+ xCursor2->gotoEnd(false);
+ xCursor2->goLeft(7, true);
+
+ CPPUNIT_ASSERT(xCompare->compareRegionEnds(xCursor1, xCursor2));
+ }
+ catch (lang::IllegalArgumentException&)
+ {
+ }
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */