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/beans/XPropertySet.hpp>
25 #include <com/sun/star/container/XNameAccess.hpp>
26 #include <com/sun/star/style/XStyle.hpp>
27 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
29 #include <comphelper/processfactory.hxx>
32 using namespace css::uno
;
37 * Initial tests for SwXHeadFootText.
39 class SwXHeadFootText final
: public UnoApiTest
,
40 public apitest::XElementAccess
,
41 public apitest::XSimpleText
,
42 public apitest::XTextRange
,
43 public apitest::XText
,
44 public apitest::XEnumerationAccess
,
45 public apitest::XTextRangeCompare
50 Reference
<XInterface
> init() override
;
51 Reference
<text::XTextContent
> getTextContent() override
{ return mxTextContent
; };
53 CPPUNIT_TEST_SUITE(SwXHeadFootText
);
54 CPPUNIT_TEST(testGetElementType
);
55 CPPUNIT_TEST(testHasElements
);
56 CPPUNIT_TEST(testCreateTextCursor
);
57 CPPUNIT_TEST(testCreateTextCursorByRange
);
58 CPPUNIT_TEST(testInsertString
);
59 CPPUNIT_TEST(testInsertControlCharacter
);
60 CPPUNIT_TEST(testGetEnd
);
61 CPPUNIT_TEST(testGetSetString
);
62 CPPUNIT_TEST(testGetStart
);
63 CPPUNIT_TEST(testGetText
);
64 // CPPUNIT_TEST(testInsertRemoveTextContent);
65 CPPUNIT_TEST(testCreateEnumeration
);
66 CPPUNIT_TEST(testCompareRegionStarts
);
67 CPPUNIT_TEST(testCompareRegionEnds
);
68 CPPUNIT_TEST_SUITE_END();
71 Reference
<text::XTextContent
> mxTextContent
;
74 SwXHeadFootText::SwXHeadFootText()
75 : UnoApiTest(u
""_ustr
)
76 , XElementAccess(cppu::UnoType
<text::XTextRange
>::get())
80 Reference
<XInterface
> SwXHeadFootText::init()
82 loadFromURL(u
"private:factory/swriter"_ustr
);
83 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
84 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
86 Reference
<style::XStyleFamiliesSupplier
> xStyleFam(xTextDocument
, UNO_QUERY_THROW
);
87 Reference
<container::XNameAccess
> xStyleFamNames
= xStyleFam
->getStyleFamilies();
89 Reference
<container::XNameAccess
> xPageStyles(xStyleFamNames
->getByName(u
"PageStyles"_ustr
),
91 Reference
<style::XStyle
> xStyle(xPageStyles
->getByName(u
"Standard"_ustr
), UNO_QUERY_THROW
);
93 Reference
<beans::XPropertySet
> xPropSet(xStyle
, UNO_QUERY_THROW
);
95 xPropSet
->setPropertyValue(u
"HeaderIsOn"_ustr
, uno::Any(true));
96 xPropSet
->setPropertyValue(u
"FooterIsOn"_ustr
, uno::Any(true));
97 Reference
<text::XText
> xText(xPropSet
->getPropertyValue(u
"HeaderText"_ustr
), UNO_QUERY_THROW
);
99 return Reference
<XInterface
>(xText
, UNO_QUERY_THROW
);
102 CPPUNIT_TEST_SUITE_REGISTRATION(SwXHeadFootText
);
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */