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/unoapi_test.hxx>
11 #include <test/lang/xserviceinfo.hxx>
12 #include <test/sheet/xcellrangereferrer.hxx>
13 #include <test/sheet/xviewpane.hxx>
14 #include <test/view/xcontrolaccess.hxx>
15 #include <test/view/xformlayeraccess.hxx>
16 #include <test/helper/form.hxx>
18 #include <com/sun/star/container/XIndexAccess.hpp>
19 #include <com/sun/star/container/XNameContainer.hpp>
20 #include <com/sun/star/drawing/XDrawPage.hpp>
21 #include <com/sun/star/drawing/XDrawPages.hpp>
22 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
23 #include <com/sun/star/form/XForm.hpp>
24 #include <com/sun/star/form/XFormsSupplier.hpp>
25 #include <com/sun/star/frame/XController.hpp>
26 #include <com/sun/star/frame/XModel.hpp>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
29 #include <com/sun/star/sheet/XViewPane.hpp>
30 #include <com/sun/star/uno/XInterface.hpp>
32 #include <com/sun/star/uno/Reference.hxx>
38 class ScViewPaneObj
: public UnoApiTest
,
39 public apitest::XCellRangeReferrer
,
40 public apitest::XControlAccess
,
41 public apitest::XFormLayerAccess
,
42 public apitest::XServiceInfo
,
43 public apitest::XViewPane
48 virtual uno::Reference
<uno::XInterface
> init() override
;
49 virtual uno::Reference
<uno::XInterface
> getXComponent() override
;
50 virtual void setUp() override
;
52 CPPUNIT_TEST_SUITE(ScViewPaneObj
);
55 CPPUNIT_TEST(testGetReferredCells
);
58 CPPUNIT_TEST(testGetControl
);
61 CPPUNIT_TEST(testGetFormController
);
62 CPPUNIT_TEST(testIsFormDesignMode
);
63 CPPUNIT_TEST(testSetFormDesignMode
);
66 CPPUNIT_TEST(testGetImplementationName
);
67 CPPUNIT_TEST(testGetSupportedServiceNames
);
68 CPPUNIT_TEST(testSupportsService
);
71 CPPUNIT_TEST(testFirstVisibleColumn
);
72 CPPUNIT_TEST(testFirstVisibleRow
);
73 CPPUNIT_TEST(testVisibleRange
);
75 CPPUNIT_TEST_SUITE_END();
78 ScViewPaneObj::ScViewPaneObj()
79 : UnoApiTest("/sc/qa/extras/testdocuments")
80 , XServiceInfo("ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane")
84 uno::Reference
<uno::XInterface
> ScViewPaneObj::getXComponent() { return mxComponent
; }
86 uno::Reference
<uno::XInterface
> ScViewPaneObj::init()
88 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
90 uno::Reference
<frame::XModel
> xModel(xDoc
, uno::UNO_QUERY_THROW
);
91 uno::Reference
<frame::XController
> xController(xModel
->getCurrentController(),
93 uno::Reference
<container::XIndexAccess
> xIA(xController
, uno::UNO_QUERY_THROW
);
94 uno::Reference
<sheet::XViewPane
> xViewPane(xIA
->getByIndex(0), uno::UNO_QUERY_THROW
);
96 uno::Reference
<drawing::XDrawPagesSupplier
> xDPS(xDoc
, uno::UNO_QUERY_THROW
);
97 uno::Reference
<drawing::XDrawPages
> xDP(xDPS
->getDrawPages(), uno::UNO_SET_THROW
);
98 xDP
->insertNewByIndex(1);
99 xDP
->insertNewByIndex(2);
101 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDP
->getByIndex(0), uno::UNO_QUERY_THROW
);
103 apitest::helper::form::createCommandButton(mxComponent
, 15000, 10000, 3000, 4500));
105 uno::Reference
<form::XFormsSupplier
> xFS(xDrawPage
, uno::UNO_QUERY_THROW
);
106 uno::Reference
<container::XNameContainer
> xNC(xFS
->getForms(), uno::UNO_SET_THROW
);
109 uno::Reference
<form::XForm
> xForm(xNC
->getByName("Form"), uno::UNO_QUERY_THROW
);
111 // XCellRangeReferrer
112 setCellRange(xViewPane
->getVisibleRange());
117 void ScViewPaneObj::setUp()
120 // create a calc document
121 mxComponent
= loadFromDesktop("private:factory/scalc");
124 CPPUNIT_TEST_SUITE_REGISTRATION(ScViewPaneObj
);
126 } // namespace sc_apitest
128 CPPUNIT_PLUGIN_IMPLEMENT();
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */