nss: upgrade to release 3.73
[LibreOffice.git] / test / source / helper / form.cxx
blob77e6b163524cb55a07c08fcf30fa2d449eef8b0f
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, "CommandButton", nX, nY, nHeight, nWidth);
35 uno::Reference<drawing::XControlShape> OOO_DLLPUBLIC_TEST createControlShape(
36 const uno::Reference<lang::XComponent>& r_xComponent, const OUString& 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("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY_THROW);
44 uno::Reference<uno::XInterface> aComponent(
45 xMSF->createInstance("com.sun.star.form.component." + r_aKind), uno::UNO_SET_THROW);
46 uno::Reference<beans::XPropertySet> xPropertySet(aComponent, uno::UNO_QUERY_THROW);
47 xPropertySet->setPropertyValue("DefaultControl",
48 uno::makeAny("com.sun.star.form.control." + r_aKind));
49 uno::Reference<awt::XControlModel> xControlModel(aComponent, uno::UNO_QUERY_THROW);
51 xControlShape->setSize(awt::Size(nHeight, nWidth));
52 xControlShape->setPosition(awt::Point(nX, nY));
54 xControlShape->setControl(xControlModel);
56 return xControlShape;
59 } // namespace apitest::helper::form
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */