LibreOffice Module test (master)  1
form.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/form.hxx>
11 #include <sal/types.h>
12 
13 #include <com/sun/star/awt/Point.hpp>
14 #include <com/sun/star/awt/Size.hpp>
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/drawing/XControlShape.hpp>
17 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
18 #include <com/sun/star/uno/XInterface.hpp>
19 
20 #include <com/sun/star/uno/Any.hxx>
21 #include <com/sun/star/uno/Reference.hxx>
22 
23 using namespace css;
24 
26 {
27 uno::Reference<drawing::XControlShape>
28  OOO_DLLPUBLIC_TEST createCommandButton(const uno::Reference<lang::XComponent>& r_xComponent,
29  const sal_Int32 nX, const sal_Int32 nY,
30  const sal_Int32 nHeight, const sal_Int32 nWidth)
31 {
32  return createControlShape(r_xComponent, u"CommandButton", nX, nY, nHeight, nWidth);
33 }
34 
35 uno::Reference<drawing::XControlShape> OOO_DLLPUBLIC_TEST createControlShape(
36  const uno::Reference<lang::XComponent>& r_xComponent, std::u16string_view r_aKind,
37  const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nHeight, const sal_Int32 nWidth)
38 {
39  uno::Reference<lang::XMultiServiceFactory> xMSF(r_xComponent, uno::UNO_QUERY_THROW);
40 
41  uno::Reference<drawing::XControlShape> xControlShape(
42  xMSF->createInstance("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY_THROW);
43 
44  uno::Reference<uno::XInterface> aComponent(
45  xMSF->createInstance(OUString::Concat("com.sun.star.form.component.") + r_aKind),
46  uno::UNO_SET_THROW);
47  uno::Reference<beans::XPropertySet> xPropertySet(aComponent, uno::UNO_QUERY_THROW);
48  xPropertySet->setPropertyValue(
49  "DefaultControl", uno::makeAny(OUString::Concat("com.sun.star.form.control.") + r_aKind));
50  uno::Reference<awt::XControlModel> xControlModel(aComponent, uno::UNO_QUERY_THROW);
51 
52  xControlShape->setSize(awt::Size(nHeight, nWidth));
53  xControlShape->setPosition(awt::Point(nX, nY));
54 
55  xControlShape->setControl(xControlModel);
56 
57  return xControlShape;
58 }
59 
60 } // namespace apitest::helper::form
61 
62 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
uno::Reference< drawing::XControlShape > OOO_DLLPUBLIC_TEST createCommandButton(const uno::Reference< lang::XComponent > &r_xComponent, const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nHeight, const sal_Int32 nWidth)
Definition: form.cxx:28
float u
uno::Reference< drawing::XControlShape > OOO_DLLPUBLIC_TEST createControlShape(const uno::Reference< lang::XComponent > &r_xComponent, std::u16string_view r_aKind, const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nHeight, const sal_Int32 nWidth)
Definition: form.cxx:35
#define OOO_DLLPUBLIC_TEST
Definition: testdllapi.hxx:28