summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-01-17 14:32:49 +0100
committerPranam Lashkari <lpranam@collabora.com>2021-03-16 05:46:15 +0100
commit8ff147f200e6514bbc7e7d7b5ca91694b9234bfc (patch)
treebf19842568df4965ddf8aef4a88bc722d35255fa /unotest
parentd7dcecb76b15e1df9a1f3afaf56164a8bf597b71 (diff)
Clean up duplicated command dispatch test functionality
Used in both Writer and Calc at few 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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112395 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
Diffstat (limited to 'unotest')
-rw-r--r--unotest/source/cpp/macros_test.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx
index e25fc8fd2f67..0066160a985b 100644
--- a/unotest/source/cpp/macros_test.cxx
+++ b/unotest/source/cpp/macros_test.cxx
@@ -13,6 +13,8 @@
#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 <cppunit/TestAssert.h>
#include <rtl/ustrbuf.hxx>
@@ -21,6 +23,7 @@
#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/thread.h>
+#include <comphelper/processfactory.hxx>
using namespace css;
@@ -115,6 +118,23 @@ void MacrosTest::tearDownNssGpg()
(void)this;
#endif
}
+
+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: */