diff options
-rw-r--r-- | sw/source/core/doc/DocumentTimerManager.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/inc/DocumentTimerManager.hxx | 7 |
2 files changed, 35 insertions, 6 deletions
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx index 44984c86e583..e80c74c695eb 100644 --- a/sw/source/core/doc/DocumentTimerManager.cxx +++ b/sw/source/core/doc/DocumentTimerManager.cxx @@ -34,22 +34,38 @@ #include <docfld.hxx> #include <fldbas.hxx> #include <vcl/scheduler.hxx> +#include <comphelper/lok.hxx> namespace sw { - -DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ), - m_nIdleBlockCount( 0 ), - m_bStartOnUnblock( false ), - m_aDocIdle( i_rSwdoc ) +DocumentTimerManager::DocumentTimerManager(SwDoc& i_rSwdoc) + : m_rDoc(i_rSwdoc) + , m_nIdleBlockCount(0) + , m_bStartOnUnblock(false) + , m_aDocIdle(i_rSwdoc) + , m_aFireIdleJobsTimer("sw::DocumentTimerManager m_aFireIdleJobsTimer") + , m_bWaitForLokInit(true) { m_aDocIdle.SetPriority(TaskPriority::LOWEST); - m_aDocIdle.SetInvokeHandler(LINK( this, DocumentTimerManager, DoIdleJobs)); + m_aDocIdle.SetInvokeHandler(LINK(this, DocumentTimerManager, DoIdleJobs)); m_aDocIdle.SetDebugName("sw::DocumentTimerManager m_aDocIdle"); + + m_aFireIdleJobsTimer.SetInvokeHandler(LINK(this, DocumentTimerManager, FireIdleJobsTimeout)); + m_aFireIdleJobsTimer.SetTimeout(1000); // Enough time for LOK to render the first tiles. } void DocumentTimerManager::StartIdling() { + if (m_bWaitForLokInit && comphelper::LibreOfficeKit::isActive()) + { + // Start the idle jobs only after a certain delay. + m_bWaitForLokInit = false; + StopIdling(); + m_aFireIdleJobsTimer.Start(); + return; + } + + m_bWaitForLokInit = false; m_bStartOnUnblock = true; if (0 == m_nIdleBlockCount) { @@ -86,6 +102,12 @@ void DocumentTimerManager::UnblockIdling() } } +IMPL_LINK(DocumentTimerManager, FireIdleJobsTimeout, Timer*, , void) +{ + // Now we can run the idle jobs, assuming we finished LOK initialization. + StartIdling(); +} + DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const { SwRootFrame* pTmpRoot = m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout(); diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx index 2caaf608c40d..df0a5d2b1ce6 100644 --- a/sw/source/core/inc/DocumentTimerManager.hxx +++ b/sw/source/core/inc/DocumentTimerManager.hxx @@ -23,6 +23,7 @@ #include <IDocumentTimerAccess.hxx> #include <SwDocIdle.hxx> +#include <vcl/idle.hxx> #include <sal/types.h> #include <tools/link.hxx> @@ -60,6 +61,10 @@ private: DocumentTimerManager(DocumentTimerManager const&) = delete; DocumentTimerManager& operator=(DocumentTimerManager const&) = delete; + /// Delay starting idle jobs to allow for post-load activity. + /// Used by LOK only. + DECL_LINK( FireIdleJobsTimeout, Timer *, void ); + DECL_LINK( DoIdleJobs, Timer *, void ); IdleJob GetNextIdleJob() const; @@ -69,6 +74,8 @@ private: sal_uInt32 m_nIdleBlockCount; ///< Don't run the Idle, if > 0 bool m_bStartOnUnblock; ///< true, if the last unblock should start the timer SwDocIdle m_aDocIdle; + Timer m_aFireIdleJobsTimer; + bool m_bWaitForLokInit; ///< true if we waited for LOK to initialize already. }; inline bool DocumentTimerManager::IsDocIdle() const |