1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/sheet/xheaderfootercontent.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/container/XNameAccess.hpp>
15 #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
16 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
17 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
18 #include <com/sun/star/text/XText.hpp>
19 #include <com/sun/star/uno/Any.hxx>
20 #include <com/sun/star/uno/Reference.hxx>
21 #include <com/sun/star/uno/XInterface.hpp>
24 using namespace css::uno
;
25 using namespace com::sun::star
;
29 class ScHeaderFooterContentObj
: public UnoApiTest
, public apitest::XHeaderFooterContent
32 ScHeaderFooterContentObj();
34 virtual uno::Reference
<uno::XInterface
> init() override
;
35 virtual void setUp() override
;
37 CPPUNIT_TEST_SUITE(ScHeaderFooterContentObj
);
39 // XHeaderFooterContent
40 CPPUNIT_TEST(testGetCenterText
);
41 CPPUNIT_TEST(testGetLeftText
);
42 CPPUNIT_TEST(testGetRightText
);
44 CPPUNIT_TEST_SUITE_END();
47 ScHeaderFooterContentObj::ScHeaderFooterContentObj()
48 : UnoApiTest(u
"/sc/qa/extras/testdocuments"_ustr
)
52 uno::Reference
<uno::XInterface
> ScHeaderFooterContentObj::init()
54 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
56 uno::Reference
<style::XStyleFamiliesSupplier
> xStyleFamSupp(xDoc
, UNO_QUERY_THROW
);
57 uno::Reference
<container::XNameAccess
> xStyleFamiliesNames(xStyleFamSupp
->getStyleFamilies(),
59 uno::Reference
<container::XNameAccess
> xPageStyles(
60 xStyleFamiliesNames
->getByName(u
"PageStyles"_ustr
), UNO_QUERY_THROW
);
61 uno::Any aDefaultStyle
= xPageStyles
->getByName(u
"Default"_ustr
);
62 uno::Reference
<beans::XPropertySet
> xProp(aDefaultStyle
, UNO_QUERY_THROW
);
64 uno::Any aHFC
= xProp
->getPropertyValue(u
"RightPageHeaderContent"_ustr
);
65 uno::Reference
<sheet::XHeaderFooterContent
> xHFC(aHFC
, UNO_QUERY_THROW
);
67 uno::Reference
<text::XText
> xTxtCenter
= xHFC
->getCenterText();
68 uno::Reference
<text::XText
> xTxtLeft
= xHFC
->getLeftText();
69 uno::Reference
<text::XText
> xTxtRight
= xHFC
->getRightText();
71 xTxtCenter
->setString(u
"CENTER"_ustr
);
72 xTxtLeft
->setString(u
"LEFT"_ustr
);
73 xTxtRight
->setString(u
"RIGHT"_ustr
);
75 xProp
->setPropertyValue(u
"RightPageHeaderContent"_ustr
, aHFC
);
80 void ScHeaderFooterContentObj::setUp()
83 // create a calc document
84 loadFromURL(u
"private:factory/scalc"_ustr
);
87 CPPUNIT_TEST_SUITE_REGISTRATION(ScHeaderFooterContentObj
);
91 CPPUNIT_PLUGIN_IMPLEMENT();
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */