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/helper/shape.hxx>
12 #include <test/container/xelementaccess.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/drawing/xshapegrouper.hxx>
15 #include <test/drawing/xshapes.hxx>
16 #include <test/lang/xserviceinfo.hxx>
17 #include <cppu/unotype.hxx>
19 #include <com/sun/star/drawing/XDrawPage.hpp>
20 #include <com/sun/star/drawing/XDrawPages.hpp>
21 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
22 #include <com/sun/star/drawing/XShape.hpp>
23 #include <com/sun/star/drawing/XShapes.hpp>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
26 #include <com/sun/star/uno/XInterface.hpp>
28 #include <com/sun/star/uno/Reference.hxx>
34 class ScDrawPageObj
: public UnoApiTest
,
35 public apitest::XElementAccess
,
36 public apitest::XIndexAccess
,
37 public apitest::XServiceInfo
,
38 public apitest::XShapeGrouper
,
39 public apitest::XShapes
44 virtual uno::Reference
<uno::XInterface
> init() override
;
45 virtual void setUp() override
;
47 CPPUNIT_TEST_SUITE(ScDrawPageObj
);
50 CPPUNIT_TEST(testGetElementType
);
51 CPPUNIT_TEST(testHasElements
);
54 CPPUNIT_TEST(testGetByIndex
);
55 CPPUNIT_TEST(testGetCount
);
58 CPPUNIT_TEST(testGetImplementationName
);
59 CPPUNIT_TEST(testGetSupportedServiceNames
);
60 CPPUNIT_TEST(testSupportsService
);
63 CPPUNIT_TEST(testGroup
);
64 CPPUNIT_TEST(testUngroup
);
67 CPPUNIT_TEST(testAddRemove
);
69 CPPUNIT_TEST_SUITE_END();
72 ScDrawPageObj::ScDrawPageObj()
73 : UnoApiTest("/sc/qa/extras/testdocuments")
74 , XElementAccess(cppu::UnoType
<drawing::XShape
>::get())
76 , XServiceInfo("ScPageObj", "com.sun.star.sheet.SpreadsheetDrawPage")
80 uno::Reference
<uno::XInterface
> ScDrawPageObj::init()
82 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
83 uno::Reference
<drawing::XDrawPagesSupplier
> xDPS(xDoc
, uno::UNO_QUERY_THROW
);
84 uno::Reference
<drawing::XDrawPages
> xDP(xDPS
->getDrawPages(), uno::UNO_SET_THROW
);
85 xDP
->insertNewByIndex(0);
86 xDP
->insertNewByIndex(1);
88 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDP
->getByIndex(0), uno::UNO_QUERY_THROW
);
89 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
, uno::UNO_QUERY_THROW
);
91 uno::Reference
<drawing::XShape
> xRectangle0(
92 apitest::helper::shape::createRectangle(mxComponent
, 7500, 5000, 5000, 3500),
94 xShapes
->add(xRectangle0
);
95 uno::Reference
<drawing::XShape
> xRectangle1(
96 apitest::helper::shape::createRectangle(mxComponent
, 5000, 5000, 5000, 5500),
98 xShapes
->add(xRectangle1
);
100 // needed for XShapeGrouper tests
101 setDrawPage(xDrawPage
);
102 // needed for XShapes tests
103 setShape(apitest::helper::shape::createLine(mxComponent
, 7500, 10000, 5000, 3500));
107 void ScDrawPageObj::setUp()
110 // create calc document
111 mxComponent
= loadFromDesktop("private:factory/scalc");
114 CPPUNIT_TEST_SUITE_REGISTRATION(ScDrawPageObj
);
116 } // namespace sc_apitest
118 CPPUNIT_PLUGIN_IMPLEMENT();
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */