diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-01-17 14:32:49 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-01-17 16:09:49 +0100 |
commit | c7f3ac890526306804ec2bdf1256ba15a4247f13 (patch) | |
tree | 44b5563a31d1147c425ebdccf72e4be83a08b595 /unotest/source | |
parent | bee9f15317d8a9ac909f54791e86f29fdf6a679d (diff) |
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 <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'unotest/source')
-rw-r--r-- | unotest/source/cpp/macros_test.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
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 <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/document/MacroExecMode.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <basic/basrdll.hxx> #include <cppunit/TestAssert.h> #include <rtl/ustrbuf.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/processfactory.hxx> using namespace css; @@ -59,6 +62,22 @@ uno::Reference<css::lang::XComponent> MacrosTest::loadFromDesktop(const OUString return xComponent; } +void MacrosTest::dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, + const OUString& rCommand, + const uno::Sequence<beans::PropertyValue>& rPropertyValues) +{ + uno::Reference<frame::XController> xController + = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); + CPPUNIT_ASSERT(xController.is()); + uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFrame.is()); + + uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); + uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); + CPPUNIT_ASSERT(xDispatchHelper.is()); + + xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |