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/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/XMultiServiceFactory.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 ScShapeObj
: public UnoApiTest
,
35 public apitest::Shape
,
36 public apitest::XComponent
,
37 public apitest::XGluePointsSupplier
,
38 public apitest::XShape
,
39 public apitest::XShapeDescriptor
44 virtual uno::Reference
<uno::XInterface
> init() override
;
45 virtual uno::Reference
<uno::XInterface
> getXSheetDocument() override
;
46 virtual void triggerDesktopTerminate() override
{};
47 virtual void setUp() override
;
49 CPPUNIT_TEST_SUITE(ScShapeObj
);
52 CPPUNIT_TEST(testShapePropertiesAnchor
);
53 CPPUNIT_TEST(testShapePropertiesPosition
);
56 CPPUNIT_TEST(testAddEventListener
);
57 CPPUNIT_TEST(testDispose
);
58 CPPUNIT_TEST(testRemoveEventListener
);
60 // XGluePointsSupplier
61 CPPUNIT_TEST(testGetGluePoints
);
64 CPPUNIT_TEST(testGetSetPosition
);
65 CPPUNIT_TEST(testGetSetSize
);
68 CPPUNIT_TEST(testGetShapeType
);
70 CPPUNIT_TEST_SUITE_END();
73 ScShapeObj::ScShapeObj()
74 : UnoApiTest(u
"/sc/qa/extras/testdocuments"_ustr
)
75 , XShapeDescriptor(u
"com.sun.star.drawing.RectangleShape"_ustr
)
79 uno::Reference
<uno::XInterface
> ScShapeObj::init()
81 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
83 uno::Reference
<lang::XMultiServiceFactory
> xMSF(xDoc
, uno::UNO_QUERY_THROW
);
84 uno::Reference
<drawing::XShape
> xShape(
85 xMSF
->createInstance(u
"com.sun.star.drawing.RectangleShape"_ustr
), uno::UNO_QUERY_THROW
);
86 xShape
->setPosition(awt::Point(5000, 3500));
87 xShape
->setSize(awt::Size(7500, 5000));
89 uno::Reference
<drawing::XDrawPagesSupplier
> xDPS(xDoc
, uno::UNO_QUERY_THROW
);
90 uno::Reference
<drawing::XDrawPages
> xDrawPages
= xDPS
->getDrawPages();
91 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
92 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
, uno::UNO_QUERY_THROW
);
95 for (auto i
= 0; i
< 10; i
++)
97 xShape
->setPosition(awt::Point(5000, 3500));
98 xShape
->setSize(awt::Size(7510 + 10 * i
, 5010 + 10 * i
));
105 uno::Reference
<uno::XInterface
> ScShapeObj::getXSheetDocument()
107 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
111 void ScShapeObj::setUp()
114 // create a calc document
115 loadFromURL(u
"private:factory/scalc"_ustr
);
118 CPPUNIT_TEST_SUITE_REGISTRATION(ScShapeObj
);
120 } // namespace sc_apitest
122 CPPUNIT_PLUGIN_IMPLEMENT();
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */