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/helper/form.hxx>
11 #include <rtl/string.hxx>
12 #include <sal/types.h>
14 #include <com/sun/star/awt/Point.hpp>
15 #include <com/sun/star/awt/Size.hpp>
16 #include <com/sun/star/beans/XPropertySet.hpp>
17 #include <com/sun/star/drawing/XControlShape.hpp>
18 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
19 #include <com/sun/star/uno/XInterface.hpp>
21 #include <com/sun/star/uno/Any.hxx>
22 #include <com/sun/star/uno/Reference.hxx>
32 uno::Reference
<drawing::XControlShape
>
33 OOO_DLLPUBLIC_TEST
createCommandButton(const uno::Reference
<lang::XComponent
>& r_xComponent
,
34 const sal_Int32 nX
, const sal_Int32 nY
,
35 const sal_Int32 nHeight
, const sal_Int32 nWidth
)
37 return createControlShape(r_xComponent
, "CommandButton", nX
, nY
, nHeight
, nWidth
);
40 uno::Reference
<drawing::XControlShape
> OOO_DLLPUBLIC_TEST
createControlShape(
41 const uno::Reference
<lang::XComponent
>& r_xComponent
, const OUString
& r_aKind
,
42 const sal_Int32 nX
, const sal_Int32 nY
, const sal_Int32 nHeight
, const sal_Int32 nWidth
)
44 uno::Reference
<lang::XMultiServiceFactory
> xMSF(r_xComponent
, uno::UNO_QUERY_THROW
);
46 uno::Reference
<drawing::XControlShape
> xControlShape(
47 xMSF
->createInstance("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY_THROW
);
49 uno::Reference
<uno::XInterface
> aComponent(
50 xMSF
->createInstance("com.sun.star.form.component." + r_aKind
), uno::UNO_SET_THROW
);
51 uno::Reference
<beans::XPropertySet
> xPropertySet(aComponent
, uno::UNO_QUERY_THROW
);
52 xPropertySet
->setPropertyValue("DefaultControl",
53 uno::makeAny("com.sun.star.form.control." + r_aKind
));
54 uno::Reference
<awt::XControlModel
> xControlModel(aComponent
, uno::UNO_QUERY_THROW
);
56 xControlShape
->setSize(awt::Size(nHeight
, nWidth
));
57 xControlShape
->setPosition(awt::Point(nX
, nY
));
59 xControlShape
->setControl(xControlModel
);
66 } // namespace apitest
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */