sw/source/core/doc/DocumentTimerManager.cxx | 34 +++++++++++++++++++++++----- sw/source/core/inc/DocumentTimerManager.hxx | 7 +++++ sw/source/core/txtnode/ndtxt.cxx | 9 ++++--- 3 files changed, 40 insertions(+), 10 deletions(-)
New commits: commit b402d0112a0bb53221b847fa372bfa3f6390a0e2 Author: Ashod Nakashian <[email protected]> AuthorDate: Fri Sep 28 06:27:09 2018 -0400 Commit: Ashod Nakashian <[email protected]> CommitDate: Mon Dec 3 08:10:45 2018 +0100 sw: paragraph-sign: erase metafields from copied text correctly This is relevant for paragraph signatures where the metadata is not yet copied and so we exclude it. The issue was that in some cases we didn't use the proper range of text and an assertion was triggered in debug builds. Otherwise there should be no change of behavior in release builds with this patch. Change-Id: I90bc2ca56d586b96d39f34c68de53d3dac6099d7 Reviewed-on: https://gerrit.libreoffice.org/63000 Tested-by: Jenkins Reviewed-by: Ashod Nakashian <[email protected]> diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index a979650504e1..ce948ec68c3c 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2018,7 +2018,7 @@ void SwTextNode::CopyText( SwTextNode *const pDest, { CHECK_SWPHINTS_IF_FRM(this); CHECK_SWPHINTS(pDest); - sal_Int32 nTextStartIdx = rStart.GetIndex(); + const sal_Int32 nTextStartIdx = rStart.GetIndex(); sal_Int32 nDestStart = rDestStart.GetIndex(); // remember old Pos if (pDest->GetDoc()->IsClipBoard() && GetNum()) @@ -2109,7 +2109,6 @@ void SwTextNode::CopyText( SwTextNode *const pDest, // Fetch end only now, because copying into self updates the start index // and all attributes - nTextStartIdx = rStart.GetIndex(); const sal_Int32 nEnd = nTextStartIdx + nLen; // 2. copy attributes @@ -2257,8 +2256,10 @@ void SwTextNode::CopyText( SwTextNode *const pDest, std::reverse(metaFieldRanges.begin(), metaFieldRanges.end()); for (const auto& pair : metaFieldRanges) { - const SwIndex aIdx(pDest, pair.first); - pDest->EraseText(aIdx, pair.second - pair.first); + const SwIndex aIdx(pDest, std::max<sal_Int32>(pair.first - nTextStartIdx, 0)); + const sal_Int32 nCount = pair.second - pair.first; + if (nCount > 0) + pDest->EraseText(aIdx, nCount); } } commit 349748e63c698076bb44f75da9eaa104489e959c Author: Ashod Nakashian <[email protected]> AuthorDate: Sat Oct 20 14:16:08 2018 -0400 Commit: Ashod Nakashian <[email protected]> CommitDate: Mon Dec 3 08:10:32 2018 +0100 sw lok: delay processing idle jobs to let LOK finish initialization When loading document, LOK needs to setup the client view, register callbacks, get document size and type, etc. All of these need to take SolarMutex, which is taken by the idle jobs immediately after loading, blocking LOK from finishing initialization and rendering the first tiles for the user. This gives the user the impression that the document is loading for far longer than it actually is, due to lack of interactivity (or indeed any activity on the screen besides the spinning wheel). By delaying the idle jobs, we allow time for LOK to finish initialization and render the first tiles before the idle jobs kick in and hog SolarMutex. Reviewed-on: https://gerrit.libreoffice.org/56572 Reviewed-by: Jan Holesovsky <[email protected]> Tested-by: Jan Holesovsky <[email protected]> (cherry picked from commit 1056640a6e1fd044cb61f5bf5ee85dfec3cbeb7c) Reviewed-on: https://gerrit.libreoffice.org/58157 Reviewed-by: Jan Holesovsky <[email protected]> Tested-by: Jan Holesovsky <[email protected]> (cherry picked from commit e5225f152c3128efa73cb602d7a524f2cb436189) Change-Id: Ic6f437bfd6f43dfed2aaa1a9d3510d43f5ec30ae Reviewed-on: https://gerrit.libreoffice.org/64013 Tested-by: Jenkins Reviewed-by: Ashod Nakashian <[email protected]> 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 _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
