From 04ca6792748eb410e997e8c6a5d4a18c9e9c531a Mon Sep 17 00:00:00 2001 From: Jens Carl Date: Wed, 5 Dec 2018 04:56:57 +0000 Subject: Make helper to create XControlShape. Change-Id: I74dc16cde0acdbc995a8808b8e8005c66c300823 Reviewed-on: https://gerrit.libreoffice.org/64584 Tested-by: Jenkins Reviewed-by: Jens Carl --- test/Library_test.mk | 2 ++ test/inc/helper/form.hxx | 42 ++++++++++++++++++++++++++++++++++ test/source/helper/form.cxx | 55 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 test/inc/helper/form.hxx create mode 100644 test/source/helper/form.cxx diff --git a/test/Library_test.mk b/test/Library_test.mk index 92097613eb4d..1e4a013e1e4b 100644 --- a/test/Library_test.mk +++ b/test/Library_test.mk @@ -10,6 +10,7 @@ $(eval $(call gb_Library_Library,test)) $(eval $(call gb_Library_set_include,test,\ + -I$(SRCDIR)/test/inc \ $$(INCLUDE) \ )) @@ -52,6 +53,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\ test/source/primitive2dxmldump \ test/source/screenshot_test \ test/source/unoapi_property_testers \ + test/source/helper/form \ )) # vim: set noet sw=4 ts=4: diff --git a/test/inc/helper/form.hxx b/test/inc/helper/form.hxx new file mode 100644 index 000000000000..173306b118c8 --- /dev/null +++ b/test/inc/helper/form.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_TEST_INC_HELPER_FORM_HXX +#define INCLUDED_TEST_INC_HELPER_FORM_HXX + +#include +#include + +#include + +#include +#include +#include +#include + +namespace apitest +{ +/** @brief Create a XControlShape + * + * @param r_xComponent The document. + * @param nHeight The height of the shape. + * @param nWidth The width of the shape. + * @param nX The x-position of the shape. + * @param nY The y-position of the shape. + * @param r_aKind The kind of the shape. + */ +css::uno::Reference OOO_DLLPUBLIC_TEST createControlShape( + const css::uno::Reference& r_xComponent, const sal_Int32 nHeight, + const sal_Int32 nWidth, const sal_Int32 nX, const sal_Int32 nY, const OUString& r_aKind); + +} // namespace apitest + +#endif // INCLUDED_TEST_INC_HELPER_FORM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/helper/form.cxx b/test/source/helper/form.cxx new file mode 100644 index 000000000000..47da3565f79d --- /dev/null +++ b/test/source/helper/form.cxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +using namespace css; + +namespace apitest +{ +uno::Reference +createControlShape(const uno::Reference& r_xComponent, const sal_Int32 nHeight, + const sal_Int32 nWidth, const sal_Int32 nX, const sal_Int32 nY, + const OUString& r_aKind) +{ + uno::Reference xMSF(r_xComponent, uno::UNO_QUERY_THROW); + + uno::Reference xControlShape( + xMSF->createInstance("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY_THROW); + + uno::Reference aComponent( + xMSF->createInstance("com.sun.star.form.component." + r_aKind), uno::UNO_QUERY_THROW); + uno::Reference xPropertySet(aComponent, uno::UNO_QUERY_THROW); + uno::Any aValue; + aValue <<= "com.sun.star.form.control." + r_aKind; + xPropertySet->setPropertyValue("DefaultControl", aValue); + uno::Reference xControlModel(aComponent, uno::UNO_QUERY_THROW); + + xControlShape->setSize(awt::Size(nHeight, nWidth)); + xControlShape->setPosition(awt::Point(nX, nY)); + + xControlShape->setControl(xControlModel); + + return xControlShape; +} +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit