nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scheaderfieldsobj.cxx
blob2265fb795d83b08a40171193b32a3c082efcc207
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/calc_unoapi_test.hxx>
11 #include <test/container/xenumerationaccess.hxx>
12 #include <test/util/xrefreshable.hxx>
14 #include <com/sun/star/beans/XPropertySet.hpp>
15 #include <com/sun/star/container/XNameAccess.hpp>
16 #include <com/sun/star/lang/XComponent.hpp>
17 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
18 #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
19 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
20 #include <com/sun/star/style/XStyle.hpp>
21 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
22 #include <com/sun/star/text/XText.hpp>
23 #include <com/sun/star/text/XTextContent.hpp>
24 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
25 #include <com/sun/star/uno/XInterface.hpp>
27 #include <com/sun/star/uno/Reference.hxx>
29 using namespace css;
31 namespace sc_apitest
33 class ScHeaderFieldsObj : public CalcUnoApiTest,
34 public apitest::XEnumerationAccess,
35 public apitest::XRefreshable
37 public:
38 ScHeaderFieldsObj();
40 virtual uno::Reference<uno::XInterface> init() override;
41 virtual void setUp() override;
42 virtual void tearDown() override;
44 CPPUNIT_TEST_SUITE(ScHeaderFieldsObj);
46 // XEnumerationAccess
47 CPPUNIT_TEST(testCreateEnumeration);
49 // XRefreshable
50 CPPUNIT_TEST(testRefreshListener);
52 CPPUNIT_TEST_SUITE_END();
54 private:
55 uno::Reference<lang::XComponent> m_xComponent;
58 ScHeaderFieldsObj::ScHeaderFieldsObj()
59 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
63 uno::Reference<uno::XInterface> ScHeaderFieldsObj::init()
65 uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
67 uno::Reference<style::XStyleFamiliesSupplier> xSFS(xDoc, uno::UNO_QUERY_THROW);
68 uno::Reference<container::XNameAccess> xNA(xSFS->getStyleFamilies(), uno::UNO_SET_THROW);
69 uno::Reference<container::XNameAccess> xNA1(xNA->getByName("PageStyles"), uno::UNO_QUERY_THROW);
70 uno::Reference<style::XStyle> xStyle(xNA1->getByName("Default"), uno::UNO_QUERY_THROW);
72 uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY_THROW);
73 uno::Reference<sheet::XHeaderFooterContent> xHFC(
74 xPropertySet->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
75 uno::Reference<text::XText> xText(xHFC->getLeftText(), uno::UNO_SET_THROW);
77 uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, uno::UNO_QUERY_THROW);
78 uno::Reference<text::XTextContent> xTC(xMSF->createInstance("com.sun.star.text.TextField.Time"),
79 uno::UNO_QUERY_THROW);
80 xText->insertTextContent(xText->createTextCursor(), xTC, false);
81 xPropertySet->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHFC));
83 uno::Reference<text::XTextFieldsSupplier> xTFS(xText, uno::UNO_QUERY_THROW);
84 return xTFS->getTextFields();
87 void ScHeaderFieldsObj::setUp()
89 CalcUnoApiTest::setUp();
90 // create calc document
91 m_xComponent = loadFromDesktop("private:factory/scalc");
94 void ScHeaderFieldsObj::tearDown()
96 closeDocument(m_xComponent);
97 CalcUnoApiTest::tearDown();
100 CPPUNIT_TEST_SUITE_REGISTRATION(ScHeaderFieldsObj);
102 } // namespace sc_apitest
104 CPPUNIT_PLUGIN_IMPLEMENT();
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */