1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <test/unoapi_test.hxx>
11 #include <test/container/xelementaccess.hxx>
12 #include <test/text/xsimpletext.hxx>
13 #include <test/text/xtextrange.hxx>
14 #include <test/text/xtext.hxx>
15 #include <test/container/xenumerationaccess.hxx>
16 #include <test/text/xtextrangecompare.hxx>
18 #include <com/sun/star/frame/Desktop.hpp>
20 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 #include <com/sun/star/text/XTextDocument.hpp>
23 #include <com/sun/star/text/XText.hpp>
24 #include <com/sun/star/text/XFootnote.hpp>
25 #include <com/sun/star/text/XSimpleText.hpp>
27 #include <comphelper/processfactory.hxx>
30 using namespace css::uno
;
35 * Initial tests for SwXFootnoteText.
37 class SwXFootnoteText final
: public UnoApiTest
,
38 public apitest::XElementAccess
,
39 public apitest::XSimpleText
,
40 public apitest::XTextRange
,
41 public apitest::XText
,
42 public apitest::XEnumerationAccess
,
43 public apitest::XTextRangeCompare
48 Reference
<XInterface
> init() override
;
49 Reference
<text::XTextContent
> getTextContent() override
{ return mxTextContent
; };
51 CPPUNIT_TEST_SUITE(SwXFootnoteText
);
52 CPPUNIT_TEST(testGetElementType
);
53 CPPUNIT_TEST(testHasElements
);
54 CPPUNIT_TEST(testCreateTextCursor
);
55 CPPUNIT_TEST(testCreateTextCursorByRange
);
56 CPPUNIT_TEST(testInsertString
);
57 CPPUNIT_TEST(testInsertControlCharacter
);
58 CPPUNIT_TEST(testGetEnd
);
59 CPPUNIT_TEST(testGetSetString
);
60 CPPUNIT_TEST(testGetStart
);
61 CPPUNIT_TEST(testGetText
);
62 // CPPUNIT_TEST(testInsertRemoveTextContent);
63 CPPUNIT_TEST(testCreateEnumeration
);
64 CPPUNIT_TEST(testCompareRegionStarts
);
65 CPPUNIT_TEST(testCompareRegionEnds
);
66 CPPUNIT_TEST_SUITE_END();
69 Reference
<text::XTextContent
> mxTextContent
;
72 SwXFootnoteText::SwXFootnoteText()
73 : UnoApiTest(u
""_ustr
)
74 , XElementAccess(cppu::UnoType
<text::XTextRange
>::get())
78 Reference
<XInterface
> SwXFootnoteText::init()
80 loadFromURL(u
"private:factory/swriter"_ustr
);
81 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
82 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
84 Reference
<text::XFootnote
> xFootnote(xMSF
->createInstance(u
"com.sun.star.text.Footnote"_ustr
),
87 Reference
<text::XText
> xText
= xTextDocument
->getText();
88 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
90 xText
->insertTextContent(xCursor
, xFootnote
, false);
92 Reference
<text::XSimpleText
> xFootText(xFootnote
, UNO_QUERY_THROW
);
93 xFootText
->setString(u
"SwXFootnoteText"_ustr
);
94 mxTextContent
= Reference
<text::XTextContent
>(
95 xMSF
->createInstance(u
"com.sun.star.text.Footnote"_ustr
), UNO_QUERY_THROW
);
97 return Reference
<XInterface
>(xFootText
->getText(), UNO_QUERY_THROW
);
100 CPPUNIT_TEST_SUITE_REGISTRATION(SwXFootnoteText
);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */