From c7f3ac890526306804ec2bdf1256ba15a4247f13 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 17 Jan 2020 14:32:49 +0100 Subject: Clean up duplicated command dispatch test functionality Used in both Writer and Calc at 5 different places, so host it in unotest/. Change-Id: I013e6df471deb8693cf4ae62f0958b12e16fda7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86972 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- unotest/source/cpp/macros_test.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'unotest') diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx index 758dcc707347..5b5804c309ab 100644 --- a/unotest/source/cpp/macros_test.cxx +++ b/unotest/source/cpp/macros_test.cxx @@ -13,11 +13,14 @@ #include #include +#include +#include #include #include #include #include +#include using namespace css; @@ -59,6 +62,22 @@ uno::Reference MacrosTest::loadFromDesktop(const OUString return xComponent; } +void MacrosTest::dispatchCommand(const uno::Reference& xComponent, + const OUString& rCommand, + const uno::Sequence& rPropertyValues) +{ + uno::Reference xController + = uno::Reference(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); + CPPUNIT_ASSERT(xController.is()); + uno::Reference xFrame(xController->getFrame(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFrame.is()); + + uno::Reference xContext = ::comphelper::getProcessComponentContext(); + uno::Reference xDispatchHelper(frame::DispatchHelper::create(xContext)); + CPPUNIT_ASSERT(xDispatchHelper.is()); + + xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit