use insert function instead of for loop
[LibreOffice.git] / sw / qa / api / SwXChapterNumbering.cxx
blobf2ba5d0fd09c4e988a4389008352e77a360f37d5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <test/unoapi_test.hxx>
11 #include <test/beans/xpropertyset.hxx>
12 #include <test/container/xindexaccess.hxx>
13 #include <test/container/xelementaccess.hxx>
14 #include <test/text/numberingrules.hxx>
16 #include <com/sun/star/frame/Desktop.hpp>
18 #include <com/sun/star/text/XTextDocument.hpp>
19 #include <com/sun/star/container/XIndexAccess.hpp>
20 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
22 using namespace css;
23 using namespace css::uno;
25 namespace
27 /**
28 * Initial tests for SwXChapterNumbering.
30 class SwXChapterNumbering final : public UnoApiTest,
31 public apitest::XPropertySet,
32 public apitest::XElementAccess,
33 public apitest::XIndexAccess,
34 public apitest::NumberingRules
36 public:
37 SwXChapterNumbering()
38 : UnoApiTest(u""_ustr)
39 , XElementAccess(cppu::UnoType<Sequence<beans::PropertyValue>>::get())
40 , XIndexAccess(10)
44 Reference<XInterface> init() override
46 loadFromURL(u"private:factory/swriter"_ustr);
47 Reference<text::XTextDocument> xTextDocument(mxComponent, UNO_QUERY_THROW);
49 Reference<text::XChapterNumberingSupplier> xCNSupplier(xTextDocument, UNO_QUERY_THROW);
50 Reference<container::XIndexAccess> xCNRules(xCNSupplier->getChapterNumberingRules(),
51 UNO_QUERY_THROW);
53 try
55 Reference<container::XIndexReplace> xIndexReplace(xCNRules->getByIndex(1),
56 UNO_QUERY_THROW);
58 catch (Exception&)
61 return Reference<XInterface>(xCNRules, UNO_QUERY_THROW);
64 CPPUNIT_TEST_SUITE(SwXChapterNumbering);
65 CPPUNIT_TEST(testGetCount);
66 CPPUNIT_TEST(testGetByIndex);
67 CPPUNIT_TEST(testGetElementType);
68 CPPUNIT_TEST(testHasElements);
69 CPPUNIT_TEST(testGetPropertySetInfo);
70 CPPUNIT_TEST(testSetPropertyValue);
71 CPPUNIT_TEST(testGetPropertyValue);
72 CPPUNIT_TEST(testPropertyChangeListener);
73 CPPUNIT_TEST(testVetoableChangeListener);
74 CPPUNIT_TEST(testNumberingRulesProperties);
75 CPPUNIT_TEST_SUITE_END();
78 CPPUNIT_TEST_SUITE_REGISTRATION(SwXChapterNumbering);
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */