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/xnameaccess.hxx>
12 #include <test/container/xindexaccess.hxx>
13 #include <test/container/xelementaccess.hxx>
15 #include <com/sun/star/frame/Desktop.hpp>
17 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
19 #include <com/sun/star/container/XNameAccess.hpp>
20 #include <com/sun/star/text/XText.hpp>
21 #include <com/sun/star/text/XTextContent.hpp>
22 #include <com/sun/star/text/XTextCursor.hpp>
23 #include <com/sun/star/text/XTextDocument.hpp>
24 #include <com/sun/star/text/XTextSection.hpp>
25 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
28 using namespace css::uno
;
33 * Initial tests for SwXTextSections.
35 class SwXTextSections final
: public UnoApiTest
,
36 public apitest::XElementAccess
,
37 public apitest::XIndexAccess
,
38 public apitest::XNameAccess
42 : UnoApiTest(u
""_ustr
)
43 , XElementAccess(cppu::UnoType
<text::XTextSection
>::get())
45 , XNameAccess(u
"TextSection"_ustr
)
49 Reference
<XInterface
> init() override
51 loadFromURL(u
"private:factory/swriter"_ustr
);
52 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
53 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
55 Reference
<text::XText
> xText
= xTextDocument
->getText();
56 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
58 Reference
<text::XTextContent
> xContent(
59 xMSF
->createInstance(u
"com.sun.star.text.TextSection"_ustr
), UNO_QUERY_THROW
);
60 xText
->insertTextContent(xCursor
, xContent
, false);
62 Reference
<text::XTextContent
> xContent2(
63 xMSF
->createInstance(u
"com.sun.star.text.TextSection"_ustr
), UNO_QUERY_THROW
);
64 xText
->insertTextContent(xCursor
, xContent2
, false);
66 Reference
<container::XNameAccess
> xNameAccess
;
69 Reference
<text::XTextSectionsSupplier
> xSupplier(xTextDocument
, UNO_QUERY_THROW
);
70 xNameAccess
= xSupplier
->getTextSections();
76 return Reference
<XInterface
>(xNameAccess
, UNO_QUERY_THROW
);
79 CPPUNIT_TEST_SUITE(SwXTextSections
);
80 CPPUNIT_TEST(testGetByName
);
81 CPPUNIT_TEST(testGetElementNames
);
82 CPPUNIT_TEST(testHasByName
);
83 CPPUNIT_TEST(testGetCount
);
84 CPPUNIT_TEST(testGetByIndex
);
85 CPPUNIT_TEST(testGetElementType
);
86 CPPUNIT_TEST(testHasElements
);
87 CPPUNIT_TEST_SUITE_END();
90 CPPUNIT_TEST_SUITE_REGISTRATION(SwXTextSections
);
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */