Update git submodules
[LibreOffice.git] / sc / qa / extras / sctablecolumnobj.cxx
blobc68f3fa6fd6e7ff40ec96a72d5400b8e834dbb26
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/unoapi_test.hxx>
11 #include <test/beans/xpropertyset.hxx>
12 #include <test/container/xnamed.hxx>
13 #include <test/lang/xserviceinfo.hxx>
14 #include <test/table/tablecolumn.hxx>
15 #include <test/table/xcellrange.hxx>
17 #include <com/sun/star/container/XIndexAccess.hpp>
18 #include <com/sun/star/sheet/XSpreadsheet.hpp>
19 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
20 #include <com/sun/star/sheet/XSpreadsheets.hpp>
21 #include <com/sun/star/table/XColumnRowRange.hpp>
22 #include <com/sun/star/table/XTableColumns.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Reference.hxx>
27 using namespace css;
29 namespace sc_apitest
31 class ScTableColumnObj : public UnoApiTest,
32 public apitest::TableColumn,
33 public apitest::XCellRange,
34 public apitest::XNamed,
35 public apitest::XPropertySet,
36 public apitest::XServiceInfo
38 public:
39 ScTableColumnObj();
41 virtual uno::Reference<uno::XInterface> init() override;
42 virtual void setUp() override;
44 CPPUNIT_TEST_SUITE(ScTableColumnObj);
46 // TableColumn
47 CPPUNIT_TEST(testTableColumnProperties);
49 // XCellRange
50 CPPUNIT_TEST(testGetCellByPosition);
51 CPPUNIT_TEST(testGetCellRangeByName);
52 CPPUNIT_TEST(testGetCellRangeByPosition);
54 // XNamed
55 CPPUNIT_TEST(testGetName);
56 // because TableColumnNames are fixed, test for an exception
57 CPPUNIT_TEST(testSetNameThrowsException);
59 // XPropertySet
60 CPPUNIT_TEST(testGetPropertySetInfo);
61 CPPUNIT_TEST(testGetPropertyValue);
62 CPPUNIT_TEST(testSetPropertyValue);
63 CPPUNIT_TEST(testPropertyChangeListener);
64 CPPUNIT_TEST(testVetoableChangeListener);
66 // XServiceInfo
67 CPPUNIT_TEST(testGetImplementationName);
68 CPPUNIT_TEST(testGetSupportedServiceNames);
69 CPPUNIT_TEST(testSupportsService);
71 CPPUNIT_TEST_SUITE_END();
74 ScTableColumnObj::ScTableColumnObj()
75 : UnoApiTest(u"/sc/qa/extras/testdocuments"_ustr)
76 , XCellRange(u"K1:K1"_ustr)
77 , XNamed(u"K"_ustr)
78 , XPropertySet({
79 u"BottomBorder"_ustr,
80 u"BottomBorder2"_ustr,
81 u"BottomBorderComplexColor"_ustr,
82 u"CellProtection"_ustr,
83 u"CharLocale"_ustr,
84 u"CharLocaleAsian"_ustr,
85 u"CharLocaleComplex"_ustr,
86 u"CharPosture"_ustr,
87 u"CharPostureAsian"_ustr,
88 u"CharPostureComplex"_ustr,
89 u"ConditionalFormat"_ustr,
90 u"ConditionalFormatLocal"_ustr,
91 u"ConditionalFormatXML"_ustr,
92 u"DiagonalBLTR"_ustr,
93 u"DiagonalBLTR2"_ustr,
94 u"DiagonalTLBR"_ustr,
95 u"DiagonalTLBR2"_ustr,
96 u"HoriJustify"_ustr,
97 u"LeftBorder"_ustr,
98 u"LeftBorder2"_ustr,
99 u"LeftBorderComplexColor"_ustr,
100 u"NumberingRules"_ustr,
101 u"Orientation"_ustr,
102 u"RightBorder"_ustr,
103 u"RightBorder2"_ustr,
104 u"RightBorderComplexColor"_ustr,
105 u"ShadowFormat"_ustr,
106 u"TableBorder"_ustr,
107 u"TableBorder2"_ustr,
108 u"TopBorder"_ustr,
109 u"TopBorder2"_ustr,
110 u"TopBorderComplexColor"_ustr,
111 u"UserDefinedAttributes"_ustr,
112 u"Validation"_ustr,
113 u"ValidationLocal"_ustr,
114 u"ValidationXML"_ustr,
115 u"WritingMode"_ustr,
117 , XServiceInfo(u"ScTableColumnObj"_ustr, u"com.sun.star.table.TableColumn"_ustr)
121 uno::Reference<uno::XInterface> ScTableColumnObj::init()
123 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
124 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_SET_THROW);
125 uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
127 uno::Reference<sheet::XSpreadsheet> xSheet0(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
128 setSpreadsheet(xSheet0);
129 uno::Reference<table::XColumnRowRange> xCRR(xSheet0, uno::UNO_QUERY_THROW);
130 uno::Reference<table::XTableColumns> xTC(xCRR->getColumns(), uno::UNO_SET_THROW);
132 uno::Reference<container::XIndexAccess> xIA_TC(xTC, uno::UNO_QUERY_THROW);
133 uno::Reference<uno::XInterface> xReturn(xIA_TC->getByIndex(10), uno::UNO_QUERY_THROW);
134 return xReturn;
137 void ScTableColumnObj::setUp()
139 UnoApiTest::setUp();
140 // create calc document
141 loadFromURL(u"private:factory/scalc"_ustr);
144 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableColumnObj);
146 } // namespace sc_apitest
148 CPPUNIT_PLUGIN_IMPLEMENT();
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */