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/calc_unoapi_test.hxx>
11 #include <test/container/xelementaccess.hxx>
12 #include <test/container/xindexaccess.hxx>
13 #include <test/container/xnameaccess.hxx>
14 #include <test/lang/xserviceinfo.hxx>
15 #include <test/style/xstyleloader.hxx>
17 #include <com/sun/star/container/XNameAccess.hpp>
18 #include <com/sun/star/container/XNameContainer.hpp>
19 #include <com/sun/star/lang/XComponent.hpp>
20 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
21 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
22 #include <com/sun/star/uno/XInterface.hpp>
24 #include <com/sun/star/uno/Reference.hxx>
26 #include <cppu/unotype.hxx>
29 using namespace css::uno
;
33 class ScStyleFamiliesObj
: public CalcUnoApiTest
,
34 public apitest::XElementAccess
,
35 public apitest::XIndexAccess
,
36 public apitest::XNameAccess
,
37 public apitest::XServiceInfo
,
38 public apitest::XStyleLoader
43 virtual uno::Reference
<uno::XInterface
> init() override
;
44 virtual uno::Reference
<sheet::XSpreadsheetDocument
> getTargetDoc() override
;
45 virtual uno::Reference
<lang::XComponent
> getSourceComponent() override
;
46 virtual OUString
getTestURL() override
;
48 virtual void setUp() override
;
49 virtual void tearDown() override
;
51 CPPUNIT_TEST_SUITE(ScStyleFamiliesObj
);
54 CPPUNIT_TEST(testGetElementType
);
55 CPPUNIT_TEST(testHasElements
);
58 CPPUNIT_TEST(testGetByIndex
);
59 CPPUNIT_TEST(testGetCount
);
62 CPPUNIT_TEST(testGetByName
);
63 CPPUNIT_TEST(testGetElementNames
);
64 CPPUNIT_TEST(testHasByName
);
67 CPPUNIT_TEST(testGetImplementationName
);
68 CPPUNIT_TEST(testGetSupportedServiceNames
);
69 CPPUNIT_TEST(testSupportsService
);
72 CPPUNIT_TEST(testLoadStylesFromDocument
);
73 CPPUNIT_TEST(testLoadStylesFromStream
);
74 CPPUNIT_TEST(testLoadStylesFromURL
);
76 CPPUNIT_TEST_SUITE_END();
79 uno::Reference
<lang::XComponent
> m_xComponent
;
80 uno::Reference
<lang::XComponent
> m_xSrcComponent
;
83 ScStyleFamiliesObj::ScStyleFamiliesObj()
84 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
85 , XElementAccess(cppu::UnoType
<container::XNameContainer
>::get())
87 , XNameAccess("CellStyles")
88 , XServiceInfo("ScStyleFamiliesObj", "com.sun.star.style.StyleFamilies")
92 uno::Reference
<uno::XInterface
> ScStyleFamiliesObj::init()
94 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(m_xComponent
, uno::UNO_QUERY_THROW
);
95 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
97 uno::Reference
<style::XStyleFamiliesSupplier
> xSFS(xDoc
, uno::UNO_QUERY_THROW
);
98 uno::Reference
<container::XNameAccess
> xNA(xSFS
->getStyleFamilies(), uno::UNO_SET_THROW
);
103 uno::Reference
<sheet::XSpreadsheetDocument
> ScStyleFamiliesObj::getTargetDoc()
105 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(m_xComponent
, uno::UNO_QUERY_THROW
);
106 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
111 uno::Reference
<lang::XComponent
> ScStyleFamiliesObj::getSourceComponent()
113 return m_xSrcComponent
;
116 OUString
ScStyleFamiliesObj::getTestURL()
119 createFileURL("ScStyleFamiliesObj.ods", aFileURL
);
123 void ScStyleFamiliesObj::setUp()
125 CalcUnoApiTest::setUp();
126 // create a calc document
127 m_xComponent
= loadFromDesktop("private:factory/scalc");
128 CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent
.is());
130 m_xSrcComponent
= loadFromDesktop(getTestURL());
131 CPPUNIT_ASSERT_MESSAGE("no src component", m_xSrcComponent
.is());
134 void ScStyleFamiliesObj::tearDown()
136 closeDocument(m_xComponent
);
137 closeDocument(m_xSrcComponent
);
138 CalcUnoApiTest::tearDown();
141 CPPUNIT_TEST_SUITE_REGISTRATION(ScStyleFamiliesObj
);
143 } // namespace sc_apitest
145 CPPUNIT_PLUGIN_IMPLEMENT();
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */