1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/document/xlinktargetsupplier.hxx>
12 #include <test/sheet/spreadsheetdocumentsettings.hxx>
13 #include <test/sheet/xcalculatable.hxx>
14 #include <test/sheet/xconsolidatable.hxx>
15 #include <test/sheet/xdocumentauditing.hxx>
16 #include <test/sheet/xgoalseek.hxx>
18 #include <com/sun/star/container/XIndexAccess.hpp>
19 #include <com/sun/star/frame/XModel.hpp>
20 #include <com/sun/star/lang/XComponent.hpp>
21 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
22 #include <com/sun/star/sheet/XSpreadsheet.hpp>
23 #include <com/sun/star/sheet/XSpreadsheets.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
29 using namespace css::uno
;
33 class ScModelObj
: public UnoApiTest
,
34 public apitest::SpreadsheetDocumentSettings
,
35 public apitest::XCalculatable
,
36 public apitest::XConsolidatable
,
37 public apitest::XDocumentAuditing
,
38 public apitest::XGoalSeek
,
39 public apitest::XLinkTargetSupplier
42 virtual void setUp() override
;
43 virtual void tearDown() override
;
45 virtual uno::Reference
<uno::XInterface
> init() override
;
46 virtual uno::Reference
<uno::XInterface
> getXMSF() override
;
47 virtual uno::Sequence
<uno::Reference
<table::XCell
>> getXCells() override
;
51 CPPUNIT_TEST_SUITE(ScModelObj
);
53 // SpreadsheetDocumentSettings
54 CPPUNIT_TEST(testSpreadsheetDocumentSettingsProperties
);
57 CPPUNIT_TEST(testCalculate
);
58 CPPUNIT_TEST(testCalculateAll
);
59 CPPUNIT_TEST(testEnableAutomaticCalculation
);
62 CPPUNIT_TEST(testCreateConsolidationDescriptor
);
63 CPPUNIT_TEST(testConsolidate
);
66 CPPUNIT_TEST(testRefreshArrows
);
69 CPPUNIT_TEST(testSeekGoal
);
71 // XLinkTargetSupplier
72 CPPUNIT_TEST(testGetLinks
);
74 CPPUNIT_TEST_SUITE_END();
77 uno::Reference
<lang::XComponent
> mxComponent
;
78 uno::Sequence
<uno::Reference
<table::XCell
>> m_xCells
;
81 ScModelObj::ScModelObj()
82 : UnoApiTest("/sc/qa/extras/testdocuments")
86 uno::Reference
<uno::XInterface
> ScModelObj::init()
88 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
90 uno::Reference
<frame::XModel
> xModel(xDoc
, UNO_QUERY_THROW
);
92 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), UNO_SET_THROW
);
93 uno::Reference
<container::XIndexAccess
> xIA(xSheets
, UNO_QUERY_THROW
);
94 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIA
->getByIndex(0), UNO_QUERY_THROW
);
97 m_xCells
[0] = xSheet
->getCellByPosition(4, 5);
98 m_xCells
[0]->setValue(15);
99 m_xCells
[1] = xSheet
->getCellByPosition(5, 5);
100 m_xCells
[1]->setValue(10);
101 m_xCells
[2] = xSheet
->getCellByPosition(6, 5);
102 m_xCells
[2]->setFormula("= E6 * F6");
107 uno::Reference
<uno::XInterface
> ScModelObj::getXMSF() { return getMultiServiceFactory(); }
109 uno::Sequence
<uno::Reference
<table::XCell
>> ScModelObj::getXCells() { return m_xCells
; }
111 void ScModelObj::setUp()
114 // create a calc document
116 createFileURL("ScModelObj.ods", aFileURL
);
117 mxComponent
= loadFromDesktop(aFileURL
, "com.sun.star.sheet.SpreadsheetDocument");
120 void ScModelObj::tearDown()
122 closeDocument(mxComponent
);
123 UnoApiTest::tearDown();
126 CPPUNIT_TEST_SUITE_REGISTRATION(ScModelObj
);
129 CPPUNIT_PLUGIN_IMPLEMENT();
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */