LibreOffice Module test (master) 1
helper/shape.cxx
Go to the documentation of this file.
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.
4 *
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 */
9
10#include <test/helper/shape.hxx>
11#include <sal/types.h>
12
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>
17
18#include <com/sun/star/uno/Reference.hxx>
19
20using namespace css;
21
23{
24uno::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)
28{
29 return createShape(r_xComponent, u"Ellipse", nX, nY, nWidth, nHeight);
30}
31
32uno::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)
36{
37 return createShape(r_xComponent, u"Line", nX, nY, nWidth, nHeight);
38}
39
40uno::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)
44{
45 return createShape(r_xComponent, u"Rectangle", nX, nY, nWidth, nHeight);
46}
47
48uno::Reference<drawing::XShape> OOO_DLLPUBLIC_TEST
49createShape(const uno::Reference<lang::XComponent>& r_xComponent, std::u16string_view r_aKind,
50 const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nWidth, const sal_Int32 nHeight)
51{
52 uno::Reference<lang::XMultiServiceFactory> xMSF(r_xComponent, uno::UNO_QUERY_THROW);
53 uno::Reference<drawing::XShape> xShape(
54 xMSF->createInstance(OUString::Concat("com.sun.star.drawing.") + r_aKind + "Shape"),
55 uno::UNO_QUERY_THROW);
56
57 try
58 {
59 xShape->setPosition(awt::Point(nX, nY));
60 xShape->setSize(awt::Size(nWidth, nHeight));
61 }
62 catch (const beans::PropertyVetoException&)
63 {
64 }
65
66 return xShape;
67}
68
69} // namespace apitest::helper::shape
70
71/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
float u
uno::Reference< drawing::XShape > OOO_DLLPUBLIC_TEST createLine(const uno::Reference< lang::XComponent > &r_xComponent, const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nWidth, const sal_Int32 nHeight)
uno::Reference< drawing::XShape > OOO_DLLPUBLIC_TEST createShape(const uno::Reference< lang::XComponent > &r_xComponent, std::u16string_view r_aKind, const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nWidth, const sal_Int32 nHeight)
uno::Reference< drawing::XShape > OOO_DLLPUBLIC_TEST createEllipse(const uno::Reference< lang::XComponent > &r_xComponent, const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nWidth, const sal_Int32 nHeight)
uno::Reference< drawing::XShape > OOO_DLLPUBLIC_TEST createRectangle(const uno::Reference< lang::XComponent > &r_xComponent, const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nWidth, const sal_Int32 nHeight)
#define OOO_DLLPUBLIC_TEST
Definition: testdllapi.hxx:28