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/beans/xpropertyset.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/text/numberingrules.hxx>
16 #include <com/sun/star/frame/Desktop.hpp>
18 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
20 #include <com/sun/star/text/XTextDocument.hpp>
21 #include <com/sun/star/text/XText.hpp>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/container/XIndexAccess.hpp>
24 #include <com/sun/star/container/XNameAccess.hpp>
25 #include <com/sun/star/container/XNameContainer.hpp>
26 #include <com/sun/star/text/ControlCharacter.hpp>
27 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
31 using namespace css::uno
;
36 * Initial tests for SwXNumberingRules.
38 class SwXNumberingRules final
: public UnoApiTest
,
39 public apitest::XElementAccess
,
40 public apitest::XIndexAccess
,
41 public apitest::XPropertySet
,
42 public apitest::NumberingRules
46 : UnoApiTest(u
""_ustr
)
47 , XElementAccess(cppu::UnoType
<Sequence
<beans::PropertyValue
>>::get())
52 Reference
<XInterface
> init() override
54 loadFromURL(u
"private:factory/swriter"_ustr
);
55 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
57 Reference
<container::XIndexAccess
> xIndexAccess
;
58 Reference
<container::XIndexAccess
> xNumRules
;
60 Reference
<text::XText
> xText
= xTextDocument
->getText();
61 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
65 xText
->insertString(xCursor
, u
"The quick brown fox jumps over the lazy dog"_ustr
,
67 xText
->insertControlCharacter(xCursor
, text::ControlCharacter::PARAGRAPH_BREAK
, false);
69 catch (lang::IllegalArgumentException
&)
73 Reference
<style::XStyleFamiliesSupplier
> xStyleFam(xTextDocument
, UNO_QUERY_THROW
);
77 Reference
<container::XNameAccess
> xStyleFamNames
= xStyleFam
->getStyleFamilies();
78 Reference
<container::XNameContainer
> xNumStyles(
79 xStyleFamNames
->getByName(u
"NumberingStyles"_ustr
), UNO_QUERY_THROW
);
80 xIndexAccess
= Reference
<container::XIndexAccess
>(xNumStyles
, UNO_QUERY_THROW
);
82 catch (lang::WrappedTargetException
&)
85 catch (container::NoSuchElementException
&)
88 catch (lang::IllegalArgumentException
&)
94 Reference
<beans::XPropertySet
> xPropSet(xIndexAccess
->getByIndex(0), UNO_QUERY_THROW
);
95 xNumRules
= Reference
<container::XIndexAccess
>(
96 xPropSet
->getPropertyValue(u
"NumberingRules"_ustr
), UNO_QUERY_THROW
);
98 catch (lang::WrappedTargetException
&)
101 catch (lang::IndexOutOfBoundsException
&)
104 catch (beans::UnknownPropertyException
&)
107 catch (lang::IllegalArgumentException
&)
111 return Reference
<XInterface
>(xNumRules
, UNO_QUERY_THROW
);
114 CPPUNIT_TEST_SUITE(SwXNumberingRules
);
115 CPPUNIT_TEST(testGetElementType
);
116 CPPUNIT_TEST(testHasElements
);
117 CPPUNIT_TEST(testGetCount
);
118 CPPUNIT_TEST(testGetByIndex
);
119 CPPUNIT_TEST(testGetPropertySetInfo
);
120 CPPUNIT_TEST(testSetPropertyValue
);
121 CPPUNIT_TEST(testGetPropertyValue
);
122 CPPUNIT_TEST(testPropertyChangeListener
);
123 CPPUNIT_TEST(testVetoableChangeListener
);
124 CPPUNIT_TEST(testNumberingRulesProperties
);
125 CPPUNIT_TEST_SUITE_END();
128 CPPUNIT_TEST_SUITE_REGISTRATION(SwXNumberingRules
);
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */