[Libreoffice-commits] core.git: test/inc test/Library_test.mk test/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 5 09:47:32 UTC 2018


 test/Library_test.mk        |    2 +
 test/inc/helper/form.hxx    |   42 +++++++++++++++++++++++++++++++++
 test/source/helper/form.cxx |   55 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+)

New commits:
commit 04ca6792748eb410e997e8c6a5d4a18c9e9c531a
Author:     Jens Carl <j.carl43 at gmx.de>
AuthorDate: Wed Dec 5 04:56:57 2018 +0000
Commit:     Jens Carl <j.carl43 at gmx.de>
CommitDate: Wed Dec 5 10:47:09 2018 +0100

    Make helper to create XControlShape.
    
    Change-Id: I74dc16cde0acdbc995a8808b8e8005c66c300823
    Reviewed-on: https://gerrit.libreoffice.org/64584
    Tested-by: Jenkins
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

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 <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <rtl/string.hxx>
+#include <sal/config.h>
+#include <sal/types.h>
+#include <test/testdllapi.hxx>
+
+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<css::drawing::XControlShape> OOO_DLLPUBLIC_TEST createControlShape(
+    const css::uno::Reference<css::lang::XComponent>& 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 <helper/form.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <rtl/string.hxx>
+#include <sal/types.h>
+
+using namespace css;
+
+namespace apitest
+{
+uno::Reference<drawing::XControlShape>
+createControlShape(const uno::Reference<lang::XComponent>& r_xComponent, const sal_Int32 nHeight,
+                   const sal_Int32 nWidth, const sal_Int32 nX, const sal_Int32 nY,
+                   const OUString& r_aKind)
+{
+    uno::Reference<lang::XMultiServiceFactory> xMSF(r_xComponent, uno::UNO_QUERY_THROW);
+
+    uno::Reference<drawing::XControlShape> xControlShape(
+        xMSF->createInstance("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY_THROW);
+
+    uno::Reference<uno::XInterface> aComponent(
+        xMSF->createInstance("com.sun.star.form.component." + r_aKind), uno::UNO_QUERY_THROW);
+    uno::Reference<beans::XPropertySet> xPropertySet(aComponent, uno::UNO_QUERY_THROW);
+    uno::Any aValue;
+    aValue <<= "com.sun.star.form.control." + r_aKind;
+    xPropertySet->setPropertyValue("DefaultControl", aValue);
+    uno::Reference<awt::XControlModel> 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: */


More information about the Libreoffice-commits mailing list