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/xenumeration.hxx>
13 #include <com/sun/star/awt/Rectangle.hpp>
14 #include <com/sun/star/container/XEnumerationAccess.hpp>
15 #include <com/sun/star/container/XIndexAccess.hpp>
16 #include <com/sun/star/lang/XComponent.hpp>
17 #include <com/sun/star/sheet/XCellRangeAddressable.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/CellRangeAddress.hpp>
22 #include <com/sun/star/table/XCellRange.hpp>
23 #include <com/sun/star/table/XTableCharts.hpp>
24 #include <com/sun/star/table/XTableChartsSupplier.hpp>
25 #include <com/sun/star/uno/XInterface.hpp>
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <com/sun/star/uno/Reference.hxx>
31 using namespace css::uno
;
35 class ScIndexEnumeration_TableChartsEnumeration
: public CalcUnoApiTest
,
36 public apitest::XEnumeration
39 ScIndexEnumeration_TableChartsEnumeration();
41 virtual uno::Reference
<uno::XInterface
> init() override
;
42 virtual void setUp() override
;
43 virtual void tearDown() override
;
45 CPPUNIT_TEST_SUITE(ScIndexEnumeration_TableChartsEnumeration
);
48 CPPUNIT_TEST(testHasMoreElements
);
49 CPPUNIT_TEST(testNextElement
);
51 CPPUNIT_TEST_SUITE_END();
54 uno::Reference
<lang::XComponent
> m_xComponent
;
57 ScIndexEnumeration_TableChartsEnumeration::ScIndexEnumeration_TableChartsEnumeration()
58 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
62 uno::Reference
<uno::XInterface
> ScIndexEnumeration_TableChartsEnumeration::init()
64 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(m_xComponent
, uno::UNO_QUERY_THROW
);
65 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
67 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), uno::UNO_SET_THROW
);
68 uno::Reference
<container::XIndexAccess
> xIA(xSheets
, uno::UNO_QUERY_THROW
);
69 uno::Reference
<sheet::XSpreadsheet
> xSheet0(xIA
->getByIndex(0), uno::UNO_QUERY_THROW
);
71 xSheet0
->getCellByPosition(1, 0)->setFormula("JAN");
72 xSheet0
->getCellByPosition(2, 0)->setFormula("FEB");
73 xSheet0
->getCellByPosition(3, 0)->setFormula("MAR");
74 xSheet0
->getCellByPosition(4, 0)->setFormula("APR");
75 xSheet0
->getCellByPosition(5, 0)->setFormula("MAY");
76 xSheet0
->getCellByPosition(6, 0)->setFormula("JUN");
77 xSheet0
->getCellByPosition(7, 0)->setFormula("JUL");
78 xSheet0
->getCellByPosition(8, 0)->setFormula("AUG");
79 xSheet0
->getCellByPosition(9, 0)->setFormula("SEP");
80 xSheet0
->getCellByPosition(10, 0)->setFormula("OCT");
81 xSheet0
->getCellByPosition(11, 0)->setFormula("NOV");
82 xSheet0
->getCellByPosition(12, 0)->setFormula("DEC");
83 xSheet0
->getCellByPosition(13, 0)->setFormula("SUM");
85 xSheet0
->getCellByPosition(0, 1)->setFormula("Smith");
86 xSheet0
->getCellByPosition(1, 1)->setValue(42);
87 xSheet0
->getCellByPosition(2, 1)->setValue(58.9);
88 xSheet0
->getCellByPosition(3, 1)->setValue(-66.5);
89 xSheet0
->getCellByPosition(4, 1)->setValue(43.4);
90 xSheet0
->getCellByPosition(5, 1)->setValue(44.5);
91 xSheet0
->getCellByPosition(6, 1)->setValue(45.3);
92 xSheet0
->getCellByPosition(7, 1)->setValue(-67.3);
93 xSheet0
->getCellByPosition(8, 1)->setValue(30.5);
94 xSheet0
->getCellByPosition(9, 1)->setValue(23.2);
95 xSheet0
->getCellByPosition(10, 1)->setValue(-97.3);
96 xSheet0
->getCellByPosition(11, 1)->setValue(22.4);
97 xSheet0
->getCellByPosition(11, 1)->setValue(23.5);
98 xSheet0
->getCellByPosition(13, 1)->setFormula("SUM(B2:M2");
100 xSheet0
->getCellByPosition(0, 2)->setFormula("Jones");
101 xSheet0
->getCellByPosition(1, 2)->setValue(21);
102 xSheet0
->getCellByPosition(2, 2)->setValue(40.9);
103 xSheet0
->getCellByPosition(3, 2)->setValue(-57.5);
104 xSheet0
->getCellByPosition(4, 2)->setValue(-23.4);
105 xSheet0
->getCellByPosition(5, 2)->setValue(34.5);
106 xSheet0
->getCellByPosition(6, 2)->setValue(59.3);
107 xSheet0
->getCellByPosition(7, 2)->setValue(27.3);
108 xSheet0
->getCellByPosition(8, 2)->setValue(-38.5);
109 xSheet0
->getCellByPosition(9, 2)->setValue(43.2);
110 xSheet0
->getCellByPosition(10, 2)->setValue(57.3);
111 xSheet0
->getCellByPosition(11, 2)->setValue(25.4);
112 xSheet0
->getCellByPosition(11, 2)->setValue(28.5);
113 xSheet0
->getCellByPosition(13, 2)->setFormula("SUM(B3:M3");
115 xSheet0
->getCellByPosition(0, 3)->setFormula("Brown");
116 xSheet0
->getCellByPosition(1, 3)->setValue(31.45);
117 xSheet0
->getCellByPosition(2, 3)->setValue(-20.9);
118 xSheet0
->getCellByPosition(3, 3)->setValue(-117.5);
119 xSheet0
->getCellByPosition(4, 3)->setValue(23.4);
120 xSheet0
->getCellByPosition(5, 3)->setValue(-114.5);
121 xSheet0
->getCellByPosition(6, 3)->setValue(115.3);
122 xSheet0
->getCellByPosition(7, 3)->setValue(-171.3);
123 xSheet0
->getCellByPosition(8, 3)->setValue(89.5);
124 xSheet0
->getCellByPosition(9, 3)->setValue(41.2);
125 xSheet0
->getCellByPosition(10, 3)->setValue(71.3);
126 xSheet0
->getCellByPosition(11, 3)->setValue(25.4);
127 xSheet0
->getCellByPosition(11, 3)->setValue(38.5);
128 xSheet0
->getCellByPosition(13, 3)->setFormula("SUM(A4:L4");
130 uno::Reference
<table::XCellRange
> xCellRange0(xSheet0
, uno::UNO_QUERY_THROW
);
131 uno::Reference
<table::XCellRange
> xCellRange1(xCellRange0
->getCellRangeByName("A1:N4"),
133 uno::Reference
<sheet::XCellRangeAddressable
> xCRA(xCellRange1
, uno::UNO_QUERY_THROW
);
135 uno::Sequence
<table::CellRangeAddress
> aCRA(1);
136 aCRA
[0] = xCRA
->getRangeAddress();
138 uno::Reference
<table::XTableChartsSupplier
> xTCS(xSheet0
, uno::UNO_QUERY_THROW
);
139 uno::Reference
<table::XTableCharts
> xTC
= xTCS
->getCharts();
140 xTC
->addNewByName("ScChartObj", awt::Rectangle(500, 3000, 25000, 11000), aCRA
, true, false);
142 uno::Reference
<container::XEnumerationAccess
> xEA(xTC
, uno::UNO_QUERY_THROW
);
144 return xEA
->createEnumeration();
147 void ScIndexEnumeration_TableChartsEnumeration::setUp()
149 CalcUnoApiTest::setUp();
150 m_xComponent
= loadFromDesktop("private:factory/scalc");
151 CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent
.is());
154 void ScIndexEnumeration_TableChartsEnumeration::tearDown()
156 closeDocument(m_xComponent
);
157 CalcUnoApiTest::tearDown();
160 CPPUNIT_TEST_SUITE_REGISTRATION(ScIndexEnumeration_TableChartsEnumeration
);
162 } // namespace sc_apitest
164 CPPUNIT_PLUGIN_IMPLEMENT();
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */