sw/source/core/inc/layact.hxx    |    8 +++++++-
 sw/source/core/layout/layact.cxx |   24 +++++++++++++-----------
 2 files changed, 20 insertions(+), 12 deletions(-)

New commits:
commit 822e5aba1b40c69591b5fa6cf94819011adc8455
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Sep 22 15:46:58 2022 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sun Oct 16 21:26:33 2022 +0200

    sw: use enum class IdleJobArea instead of a bool (bVisAreaOnly)
    
    It's more clear what the parameter means - either ALL or only
    the VISIBLE area.
    
    Change-Id: Ib9769da55e29feecab3aad81363429b333fa9d7c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140680
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx
index bea708a4878a..417d75deebbf 100644
--- a/sw/source/core/inc/layact.hxx
+++ b/sw/source/core/inc/layact.hxx
@@ -196,6 +196,12 @@ enum class IdleJobType
     SMART_TAGS
 };
 
+enum class IdleJobArea
+{
+    ALL,
+    VISIBLE
+};
+
 class SwLayIdle
 {
     SwRootFrame *m_pRoot;
@@ -210,7 +216,7 @@ class SwLayIdle
 #endif
 
     bool DoIdleJob_( const SwContentFrame*, IdleJobType );
-    bool DoIdleJob( IdleJobType, bool bVisAreaOnly );
+    bool DoIdleJob(IdleJobType eJobType, IdleJobArea eJobArea);
 
     static bool isJobEnabled(IdleJobType eJob, const SwViewShell* pViewShell);
 public:
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 1d88d2f03cfb..fc7f1c1f5314 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -2131,7 +2131,7 @@ bool SwLayIdle::isJobEnabled(IdleJobType eJob, const 
SwViewShell* pViewShell)
     return false;
 }
 
-bool SwLayIdle::DoIdleJob( IdleJobType eJob, bool bVisAreaOnly )
+bool SwLayIdle::DoIdleJob(IdleJobType eJob, IdleJobArea eJobArea)
 {
     // Spellcheck all contents of the pages. Either only the
     // visible ones or all of them.
@@ -2142,7 +2142,7 @@ bool SwLayIdle::DoIdleJob( IdleJobType eJob, bool 
bVisAreaOnly )
         return false;
 
     SwPageFrame *pPage;
-    if ( bVisAreaOnly )
+    if (eJobArea == IdleJobArea::VISIBLE)
         pPage = m_pImp->GetFirstVisPage(pViewShell->GetOut());
     else
         pPage = static_cast<SwPageFrame*>(m_pRoot->Lower());
@@ -2208,9 +2208,11 @@ bool SwLayIdle::DoIdleJob( IdleJobType eJob, bool 
bVisAreaOnly )
         }
 
         pPage = static_cast<SwPageFrame*>(pPage->GetNext());
-        if ( pPage && bVisAreaOnly &&
-             !pPage->getFrameArea().Overlaps( m_pImp->GetShell()->VisArea()))
+        if (pPage && eJobArea == IdleJobArea::VISIBLE &&
+            !pPage->getFrameArea().Overlaps( m_pImp->GetShell()->VisArea()))
+        {
              break;
+        }
     }
     return false;
 }
@@ -2257,9 +2259,9 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
 
     // First, spellcheck the visible area. Only if there's nothing
     // to do there, we trigger the IdleFormat.
-    if ( !DoIdleJob( IdleJobType::SMART_TAGS, true ) &&
-         !DoIdleJob( IdleJobType::ONLINE_SPELLING, true ) &&
-         !DoIdleJob( IdleJobType::AUTOCOMPLETE_WORDS, true ) )
+    if ( !DoIdleJob(IdleJobType::SMART_TAGS, IdleJobArea::VISIBLE) &&
+         !DoIdleJob(IdleJobType::ONLINE_SPELLING, IdleJobArea::VISIBLE) &&
+         !DoIdleJob(IdleJobType::AUTOCOMPLETE_WORDS, IdleJobArea::VISIBLE) )
     {
         // Format, then register repaint rectangles with the SwViewShell if 
necessary.
         // This requires running artificial actions, so we don't get undesired
@@ -2371,10 +2373,10 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
 
         if (!bInterrupt)
         {
-            if ( !DoIdleJob( IdleJobType::WORD_COUNT, false ) )
-                if ( !DoIdleJob( IdleJobType::SMART_TAGS, false ) )
-                    if ( !DoIdleJob( IdleJobType::ONLINE_SPELLING, false ) )
-                        DoIdleJob( IdleJobType::AUTOCOMPLETE_WORDS, false );
+            if (!DoIdleJob(IdleJobType::WORD_COUNT, IdleJobArea::ALL))
+                if (!DoIdleJob(IdleJobType::SMART_TAGS, IdleJobArea::ALL))
+                    if (!DoIdleJob(IdleJobType::ONLINE_SPELLING, 
IdleJobArea::ALL))
+                        DoIdleJob(IdleJobType::AUTOCOMPLETE_WORDS, 
IdleJobArea::ALL);
         }
 
         bool bInValid = false;

Reply via email to