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/xenumerationaccess.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/sheet/spreadsheetviewsettings.hxx>
15 #include <test/sheet/xactivationbroadcaster.hxx>
16 #include <test/sheet/xcellrangereferrer.hxx>
17 #include <test/sheet/xspreadsheetview.hxx>
18 #include <test/sheet/xviewfreezable.hxx>
19 #include <test/sheet/xviewsplitable.hxx>
21 #include <com/sun/star/container/XIndexAccess.hpp>
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/lang/XComponent.hpp>
24 #include <com/sun/star/sheet/XSpreadsheet.hpp>
25 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
26 #include <com/sun/star/sheet/XViewPane.hpp>
27 #include <com/sun/star/uno/XInterface.hpp>
29 #include <com/sun/star/uno/Reference.hxx>
31 #include <cppu/unotype.hxx>
34 using namespace css::uno
;
38 class ScTabViewObj
: public CalcUnoApiTest
,
39 public apitest::SpreadsheetViewSettings
,
40 public apitest::XActivationBroadcaster
,
41 public apitest::XCellRangeReferrer
,
42 public apitest::XElementAccess
,
43 public apitest::XEnumerationAccess
,
44 public apitest::XIndexAccess
,
45 public apitest::XSpreadsheetView
,
46 public apitest::XViewFreezable
,
47 public apitest::XViewSplitable
52 virtual uno::Reference
<uno::XInterface
> init() override
;
53 virtual uno::Reference
<uno::XInterface
> getXSpreadsheet(const sal_Int16 nNumber
= 0) override
;
55 virtual void setUp() override
;
56 virtual void tearDown() override
;
58 CPPUNIT_TEST_SUITE(ScTabViewObj
);
60 // SpreadsheetViewSettings
61 CPPUNIT_TEST(testSpreadsheetViewSettingsProperties
);
63 // XActivationBroadcaster
64 CPPUNIT_TEST(testAddRemoveActivationEventListener
);
67 //Disabled till it's clear why it fails on some machines.
68 //CPPUNIT_TEST(testGetReferredCells);
71 CPPUNIT_TEST(testGetElementType
);
72 CPPUNIT_TEST(testHasElements
);
75 CPPUNIT_TEST(testCreateEnumeration
);
78 CPPUNIT_TEST(testGetByIndex
);
79 CPPUNIT_TEST(testGetCount
);
82 CPPUNIT_TEST(testGetSetActiveSheet
);
85 CPPUNIT_TEST(testFreeze
);
88 CPPUNIT_TEST(testSplit
);
90 CPPUNIT_TEST_SUITE_END();
93 uno::Reference
<lang::XComponent
> mxComponent
;
96 ScTabViewObj::ScTabViewObj()
97 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
98 , XElementAccess(cppu::UnoType
<sheet::XViewPane
>::get())
103 uno::Reference
<uno::XInterface
> ScTabViewObj::init()
105 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
106 uno::Reference
<frame::XModel
> xModel(xDoc
, uno::UNO_QUERY_THROW
);
108 setCellRange(table::CellRangeAddress(0, 0, 0, 6, 23));
110 return xModel
->getCurrentController();
113 uno::Reference
<uno::XInterface
> ScTabViewObj::getXSpreadsheet(const sal_Int16 nNumber
)
115 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
117 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), UNO_SET_THROW
);
118 xSheets
->insertNewByName("Sheet2", 2);
119 uno::Reference
<container::XIndexAccess
> xIndex(xDoc
->getSheets(), UNO_QUERY_THROW
);
120 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(nNumber
), UNO_QUERY_THROW
);
125 void ScTabViewObj::setUp()
127 CalcUnoApiTest::setUp();
128 mxComponent
= loadFromDesktop("private:factory/scalc");
131 void ScTabViewObj::tearDown()
133 closeDocument(mxComponent
);
134 CalcUnoApiTest::tearDown();
137 CPPUNIT_TEST_SUITE_REGISTRATION(ScTabViewObj
);
139 } // namespace sc_apitest
141 CPPUNIT_PLUGIN_IMPLEMENT();
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */