[Libreoffice-commits] core.git: offapi/com toolkit/source

Tor Lillqvist tml at collabora.com
Fri Jun 10 14:44:08 UTC 2016


 offapi/com/sun/star/awt/XToolkitExperimental.idl |    5 ++-
 toolkit/source/awt/vclxtoolkit.cxx               |   35 +++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 30104ff4c76b7f31450f525b4a6d7ebad9823aad
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Jun 7 14:03:44 2016 +0300

    Add a pause() method to XToolkitExperimental
    
    Pauses the main thread of LibreOffice for the requested amount of
    time.
    
    Change-Id: I5978a3a9b9561623c698526d8c29695d71df3d03

diff --git a/offapi/com/sun/star/awt/XToolkitExperimental.idl b/offapi/com/sun/star/awt/XToolkitExperimental.idl
index 89828b2..5764ef5 100644
--- a/offapi/com/sun/star/awt/XToolkitExperimental.idl
+++ b/offapi/com/sun/star/awt/XToolkitExperimental.idl
@@ -23,7 +23,6 @@ interface XToolkitExperimental : XToolkit2
      */
     void processEventsToIdle();
 
-
     /** Get the number of OpenGL buffer swaps.
      */
     hyper getOpenGLBufferSwapCounter();
@@ -31,6 +30,10 @@ interface XToolkitExperimental : XToolkit2
     /** Turn on or off deterministic scheduling (off is the default).
      */
     void setDeterministicScheduling([in] boolean bDeterministicMode);
+
+    /** Pause the main thread of LibreOffice for the requested amount of time.
+     */
+    void pause([in] long nMilliseconds);
 };
 
 }; }; }; };
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 2dfa25c..7916de7 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 )


More information about the Libreoffice-commits mailing list