Filter out more unwanted command URIs
[LibreOffice.git] / test / source / helper / form.cxx
blob7238ecda9f88b4f705490074359800e434f4b0d1
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/form.hxx>
11 #include <sal/types.h>
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>
20 #include <com/sun/star/uno/Any.hxx>
21 #include <com/sun/star/uno/Reference.hxx>
23 using namespace css;
25 namespace apitest::helper::form
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)
32 return createControlShape(r_xComponent, u"CommandButton", nX, nY, nHeight, nWidth);
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)
39 uno::Reference<lang::XMultiServiceFactory> xMSF(r_xComponent, uno::UNO_QUERY_THROW);
41 uno::Reference<drawing::XControlShape> xControlShape(
42 xMSF->createInstance(u"com.sun.star.drawing.ControlShape"_ustr), uno::UNO_QUERY_THROW);
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 u"DefaultControl"_ustr, uno::Any(OUString::Concat("com.sun.star.form.control.") + r_aKind));
50 uno::Reference<awt::XControlModel> xControlModel(aComponent, uno::UNO_QUERY_THROW);
52 xControlShape->setSize(awt::Size(nHeight, nWidth));
53 xControlShape->setPosition(awt::Point(nX, nY));
55 xControlShape->setControl(xControlModel);
57 return xControlShape;
60 } // namespace apitest::helper::form
62 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */