From 30104ff4c76b7f31450f525b4a6d7ebad9823aad Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 7 Jun 2016 14:03:44 +0300 Subject: Add a pause() method to XToolkitExperimental Pauses the main thread of LibreOffice for the requested amount of time. Change-Id: I5978a3a9b9561623c698526d8c29695d71df3d03 --- toolkit/source/awt/vclxtoolkit.cxx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'toolkit') diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 2dfa25cf13cb..7916de775756 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -143,6 +143,32 @@ extern "C" typedef vcl::Window* (SAL_CALL *FN_SvtCreateWindow)( vcl::Window* pParent, WinBits nWinBits ); +class Pause : public Idle +{ +public: + Pause(sal_Int32 nPauseMilliseconds) : + Idle("pause"), + m_nPauseMilliseconds(nPauseMilliseconds) + { + SetPriority(SchedulerPriority::HIGHEST); + Start(); + } + + virtual ~Pause() + { + } + + virtual void Invoke() override + { + SolarMutexGuard aSolarGuard; + osl::Thread::wait(std::chrono::milliseconds(m_nPauseMilliseconds)); + Stop(); + delete this; + } + + sal_Int32 m_nPauseMilliseconds; +}; + class VCLXToolkitMutexHelper { protected: @@ -205,6 +231,9 @@ public: virtual void SAL_CALL setDeterministicScheduling(sal_Bool bDeterministicMode) throw (css::uno::RuntimeException, std::exception) override; + virtual void SAL_CALL pause(sal_Int32 nMilliseconds) + throw (css::uno::RuntimeException, std::exception) override; + // css::awt::XToolkit css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) throw(css::uno::RuntimeException, std::exception) override; css::awt::Rectangle SAL_CALL getWorkArea( ) throw(css::uno::RuntimeException, std::exception) override; @@ -1942,6 +1971,12 @@ void SAL_CALL VCLXToolkit::setDeterministicScheduling(sal_Bool bDeterministicMod Scheduler::SetDeterministicMode(bDeterministicMode); } +void SAL_CALL VCLXToolkit::pause(sal_Int32 nMilliseconds) + throw (css::uno::RuntimeException, std::exception) +{ + new Pause(nMilliseconds); +} + // css:awt:XToolkitRobot void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent ) -- cgit