nss: upgrade to release 3.73
[LibreOffice.git] / test / source / helper / shape.cxx
blob4fafcc0c7e48ae4c63588469f81da8af0d60b97b
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/helper/shape.hxx>
11 #include <sal/types.h>
13 #include <com/sun/star/drawing/XShape.hpp>
14 #include <com/sun/star/lang/XComponent.hpp>
15 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
16 #include <com/sun/star/beans/PropertyVetoException.hpp>
18 #include <com/sun/star/uno/Reference.hxx>
20 using namespace css;
22 namespace apitest::helper::shape
24 uno::Reference<drawing::XShape>
25 OOO_DLLPUBLIC_TEST createEllipse(const uno::Reference<lang::XComponent>& r_xComponent,
26 const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nWidth,
27 const sal_Int32 nHeight)
29 return createShape(r_xComponent, "Ellipse", nX, nY, nWidth, nHeight);
32 uno::Reference<drawing::XShape>
33 OOO_DLLPUBLIC_TEST createLine(const uno::Reference<lang::XComponent>& r_xComponent,
34 const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nWidth,
35 const sal_Int32 nHeight)
37 return createShape(r_xComponent, "Line", nX, nY, nWidth, nHeight);
40 uno::Reference<drawing::XShape>
41 OOO_DLLPUBLIC_TEST createRectangle(const uno::Reference<lang::XComponent>& r_xComponent,
42 const sal_Int32 nX, const sal_Int32 nY,
43 const sal_Int32 nWidth, const sal_Int32 nHeight)
45 return createShape(r_xComponent, "Rectangle", nX, nY, nWidth, nHeight);
48 uno::Reference<drawing::XShape>
49 OOO_DLLPUBLIC_TEST createShape(const uno::Reference<lang::XComponent>& r_xComponent,
50 const OUString& r_aKind, const sal_Int32 nX, const sal_Int32 nY,
51 const sal_Int32 nWidth, const sal_Int32 nHeight)
53 uno::Reference<lang::XMultiServiceFactory> xMSF(r_xComponent, uno::UNO_QUERY_THROW);
54 uno::Reference<drawing::XShape> xShape(
55 xMSF->createInstance("com.sun.star.drawing." + r_aKind + "Shape"), uno::UNO_QUERY_THROW);
57 try
59 xShape->setPosition(awt::Point(nX, nY));
60 xShape->setSize(awt::Size(nWidth, nHeight));
62 catch (const beans::PropertyVetoException&)
66 return xShape;
69 } // namespace apitest::helper::shape
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */