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/container/xindexaccess.hxx>
14 #include <com/sun/star/frame/Desktop.hpp>
16 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
18 #include <com/sun/star/text/XFootnote.hpp>
19 #include <com/sun/star/text/XFootnotesSupplier.hpp>
20 #include <com/sun/star/text/XTextDocument.hpp>
21 #include <com/sun/star/text/XText.hpp>
23 #include <comphelper/processfactory.hxx>
26 using namespace css::uno
;
31 * Initial tests for SwXFootnotes.
33 class SwXFootnotes final
: public UnoApiTest
,
34 public apitest::XElementAccess
,
35 public apitest::XIndexAccess
39 : UnoApiTest(u
""_ustr
)
40 , XElementAccess(cppu::UnoType
<text::XFootnote
>::get())
45 Reference
<XInterface
> init() override
47 loadFromURL(u
"private:factory/swriter"_ustr
);
48 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
49 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
51 Reference
<text::XFootnote
> xFootnote(
52 xMSF
->createInstance(u
"com.sun.star.text.Footnote"_ustr
), UNO_QUERY_THROW
);
54 Reference
<text::XText
> xText
= xTextDocument
->getText();
55 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
57 xText
->insertTextContent(xCursor
, xFootnote
, false);
59 Reference
<text::XFootnotesSupplier
> xSupplier(xTextDocument
, UNO_QUERY_THROW
);
61 return Reference
<XInterface
>(xSupplier
->getFootnotes(), UNO_QUERY_THROW
);
64 CPPUNIT_TEST_SUITE(SwXFootnotes
);
65 CPPUNIT_TEST(testGetElementType
);
66 CPPUNIT_TEST(testHasElements
);
67 CPPUNIT_TEST(testGetCount
);
68 CPPUNIT_TEST(testGetByIndex
);
69 CPPUNIT_TEST_SUITE_END();
72 CPPUNIT_TEST_SUITE_REGISTRATION(SwXFootnotes
);
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */