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/drawing/xgluepointssupplier.hxx>
12 #include <test/drawing/xshape.hxx>
13 #include <test/drawing/xshapedescriptor.hxx>
14 #include <test/lang/xcomponent.hxx>
15 #include <test/sheet/shape.hxx>
17 #include <com/sun/star/awt/Point.hpp>
18 #include <com/sun/star/awt/Size.hpp>
19 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
20 #include <com/sun/star/drawing/XDrawPage.hpp>
21 #include <com/sun/star/drawing/XDrawPages.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/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
27 #include <com/sun/star/uno/XInterface.hpp>
29 #include <com/sun/star/uno/Reference.hxx>
35 class ScShapeObj
: public CalcUnoApiTest
,
36 public apitest::Shape
,
37 public apitest::XComponent
,
38 public apitest::XGluePointsSupplier
,
39 public apitest::XShape
,
40 public apitest::XShapeDescriptor
45 virtual uno::Reference
<uno::XInterface
> init() override
;
46 virtual uno::Reference
<uno::XInterface
> getXSheetDocument() override
;
47 virtual void triggerDesktopTerminate() override
{};
48 virtual void setUp() override
;
49 virtual void tearDown() override
;
51 CPPUNIT_TEST_SUITE(ScShapeObj
);
54 CPPUNIT_TEST(testShapePropertiesAnchor
);
55 CPPUNIT_TEST(testShapePropertiesPosition
);
58 CPPUNIT_TEST(testAddEventListener
);
59 CPPUNIT_TEST(testDispose
);
60 CPPUNIT_TEST(testRemoveEventListener
);
62 // XGluePointsSupplier
63 CPPUNIT_TEST(testGetGluePoints
);
66 CPPUNIT_TEST(testGetSetPosition
);
67 CPPUNIT_TEST(testGetSetSize
);
70 CPPUNIT_TEST(testGetShapeType
);
72 CPPUNIT_TEST_SUITE_END();
75 uno::Reference
<lang::XComponent
> mxComponent
;
78 ScShapeObj::ScShapeObj()
79 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
80 , XShapeDescriptor("com.sun.star.drawing.RectangleShape")
84 uno::Reference
<uno::XInterface
> ScShapeObj::init()
86 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
88 uno::Reference
<lang::XMultiServiceFactory
> xMSF(xDoc
, uno::UNO_QUERY_THROW
);
89 uno::Reference
<drawing::XShape
> xShape(
90 xMSF
->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY_THROW
);
91 xShape
->setPosition(awt::Point(5000, 3500));
92 xShape
->setSize(awt::Size(7500, 5000));
94 uno::Reference
<drawing::XDrawPagesSupplier
> xDPS(xDoc
, uno::UNO_QUERY_THROW
);
95 uno::Reference
<drawing::XDrawPages
> xDrawPages
= xDPS
->getDrawPages();
96 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
97 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
, uno::UNO_QUERY_THROW
);
100 for (auto i
= 0; i
< 10; i
++)
102 xShape
->setPosition(awt::Point(5000, 3500));
103 xShape
->setSize(awt::Size(7510 + 10 * i
, 5010 + 10 * i
));
104 xShapes
->add(xShape
);
110 uno::Reference
<uno::XInterface
> ScShapeObj::getXSheetDocument()
112 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
116 void ScShapeObj::setUp()
118 CalcUnoApiTest::setUp();
119 // create a calc document
120 mxComponent
= loadFromDesktop("private:factory/scalc");
123 void ScShapeObj::tearDown()
125 closeDocument(mxComponent
);
126 CalcUnoApiTest::tearDown();
129 CPPUNIT_TEST_SUITE_REGISTRATION(ScShapeObj
);
131 } // namespace sc_apitest
133 CPPUNIT_PLUGIN_IMPLEMENT();
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */