sw/source/core/inc/layact.hxx | 1 sw/source/core/layout/layact.cxx | 71 +++++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 29 deletions(-)
New commits: commit 01396925b76011ffccb6eea40956a22d58de6f17 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Thu Sep 22 14:50:39 2022 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Sun Oct 16 21:25:26 2022 +0200 sw: move the check to determine if job is enabled to own method Change-Id: Idf681b59f127a6aa1c6496ad7db39f3dd367b99c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140678 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx index 6e8a109fbded..10720173ed7b 100644 --- a/sw/source/core/inc/layact.hxx +++ b/sw/source/core/inc/layact.hxx @@ -205,6 +205,7 @@ class SwLayIdle bool DoIdleJob_( const SwContentFrame*, IdleJobType ); bool DoIdleJob( IdleJobType, bool bVisAreaOnly ); + static bool isJobEnabled(IdleJobType eJob, const SwViewShell* pViewShell); public: SwLayIdle( SwRootFrame *pRt, SwViewShellImp *pImp ); ~SwLayIdle(); diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 54793d2f4bb9..ab1a8964de2f 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -2097,37 +2097,50 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob ) return false; } +bool SwLayIdle::isJobEnabled(IdleJobType eJob, const SwViewShell* pViewShell) +{ + switch (eJob) + { + case ONLINE_SPELLING: + { + const SwViewOption* pViewOptions = pViewShell->GetViewOptions(); + return pViewOptions->IsOnlineSpell(); + } + + case AUTOCOMPLETE_WORDS: + { + if (!SwViewOption::IsAutoCompleteWords() || SwDoc::GetAutoCompleteWords().IsLockWordLstLocked()) + return false; + return true; + } + + case WORD_COUNT: + { + return pViewShell->getIDocumentStatistics().GetDocStat().bModified; + } + + case SMART_TAGS: + { + const SwDoc* pDoc = pViewShell->GetDoc(); + if (!pDoc->GetDocShell()->IsHelpDocument() || pDoc->isXForms() || !SwSmartTagMgr::Get().IsSmartTagsEnabled()) + return false; + return true; + } + default: OSL_FAIL("Unknown idle job type"); + } + + return false; +} + bool SwLayIdle::DoIdleJob( IdleJobType eJob, bool bVisAreaOnly ) { // Spellcheck all contents of the pages. Either only the // visible ones or all of them. const SwViewShell* pViewShell = m_pImp->GetShell(); - const SwViewOption* pViewOptions = pViewShell->GetViewOptions(); - const SwDoc* pDoc = pViewShell->GetDoc(); - switch ( eJob ) - { - case ONLINE_SPELLING : - if( !pViewOptions->IsOnlineSpell() ) - return false; - break; - case AUTOCOMPLETE_WORDS : - if( !SwViewOption::IsAutoCompleteWords() || - SwDoc::GetAutoCompleteWords().IsLockWordLstLocked()) - return false; - break; - case WORD_COUNT : - if ( !pViewShell->getIDocumentStatistics().GetDocStat().bModified ) - return false; - break; - case SMART_TAGS : - if ( pDoc->GetDocShell()->IsHelpDocument() || - pDoc->isXForms() || - !SwSmartTagMgr::Get().IsSmartTagsEnabled() ) - return false; - break; - default: OSL_FAIL( "Unknown idle job type" ); - } + // Check if job ius enabled and can run + if (!isJobEnabled(eJob, pViewShell)) + return false; SwPageFrame *pPage; if ( bVisAreaOnly ) @@ -2141,15 +2154,15 @@ bool SwLayIdle::DoIdleJob( IdleJobType eJob, bool bVisAreaOnly ) while ( pPage ) { m_bPageValid = true; - const SwContentFrame *pCnt = pPage->ContainsContent(); - while( pCnt && pPage->IsAnLower( pCnt ) ) + const SwContentFrame* pContentFrame = pPage->ContainsContent(); + while (pContentFrame && pPage->IsAnLower(pContentFrame)) { - if ( DoIdleJob_( pCnt, eJob ) ) + if (DoIdleJob_(pContentFrame, eJob)) { SAL_INFO("sw.idle", "DoIdleJob " << eJob << " interrupted on page " << pPage->GetPhyPageNum()); return true; } - pCnt = pCnt->GetNextContentFrame(); + pContentFrame = pContentFrame->GetNextContentFrame(); } if ( pPage->GetSortedObjs() ) {
