Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / qa / extras / scviewpaneobj.cxx
blob5f2da19260b90f537793338cc3b66c43396b0c37
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/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>
34 using namespace css;
36 namespace sc_apitest
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
45 public:
46 ScViewPaneObj();
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);
54 // XCellRangeReferrer
55 CPPUNIT_TEST(testGetReferredCells);
57 // XControlAccess
58 CPPUNIT_TEST(testGetControl);
60 // XFormLayerAccess
61 CPPUNIT_TEST(testGetFormController);
62 CPPUNIT_TEST(testIsFormDesignMode);
63 CPPUNIT_TEST(testSetFormDesignMode);
65 // XServiceInfo
66 CPPUNIT_TEST(testGetImplementationName);
67 CPPUNIT_TEST(testGetSupportedServiceNames);
68 CPPUNIT_TEST(testSupportsService);
70 // XViewPane
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(),
92 uno::UNO_SET_THROW);
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);
102 xDrawPage->add(
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);
108 // XFormLayerAccess
109 uno::Reference<form::XForm> xForm(xNC->getByName("Form"), uno::UNO_QUERY_THROW);
110 setForm(xForm);
111 // XCellRangeReferrer
112 setCellRange(xViewPane->getVisibleRange());
114 return xViewPane;
117 void ScViewPaneObj::setUp()
119 UnoApiTest::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: */