sw/inc/ndtxt.hxx                       |   36 +++++--
 sw/source/core/doc/doc.cxx             |    4 
 sw/source/core/inc/layact.hxx          |    8 +
 sw/source/core/layout/layact.cxx       |   26 +++--
 sw/source/core/text/txtfrm.cxx         |    2 
 sw/source/core/txtnode/ndtxt.cxx       |   17 +--
 sw/source/core/txtnode/txtedt.cxx      |  149 ++++++++-------------------------
 sw/source/core/unocore/unoflatpara.cxx |    2 
 sw/source/core/unocore/unoobj.cxx      |    2 
 9 files changed, 98 insertions(+), 148 deletions(-)

New commits:
commit 1ca337267e4f0aa3b513461a42626ac619171833
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Sep 24 22:35:19 2022 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Dec 6 08:43:47 2022 +0000

    sw: refactor SwParaIdleData - rename, lifecycle, move to header
    
    This renames SwParaIdleData to sw::ParagraphIdleData, moves it to
    the header file and changes from a raw pointer initialized at the
    SwTextNode construction and deleted at SwTextNode destruction to
    a pure member variable (which has the same lifecycle). A it is not
    a pointer anymore, there is no need to check if it is nullptr or
    not, which simplifies the code.
    
    Change-Id: I74413eef2cfd3666cf75177a6ea080219eee0ac0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140681
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit e051b3a6d59ed925e1cddfa72696c9a740830808)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143654
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 9e83ded061f6..21735f35e03a 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -59,7 +59,6 @@ class SwInterHyphInfo;
 class SwWrongList;
 class SwGrammarMarkUp;
 struct SwDocStat;
-struct SwParaIdleData_Impl;
 enum class ExpandMode;
 enum class SwFieldIds : sal_uInt16;
 class SwField;
@@ -75,6 +74,29 @@ namespace com::sun::star {
 
 typedef o3tl::sorted_vector< sal_Int32 > SwSoftPageBreakList;
 
+namespace sw
+{
+
+enum class WrongState { TODO, PENDING, DONE };
+
+struct ParagraphIdleData
+{
+    std::unique_ptr<SwWrongList> pWrong;                // for spell checking
+    std::unique_ptr<SwGrammarMarkUp> pGrammarCheck;     // for grammar 
checking /  proof reading
+    std::unique_ptr<SwWrongList> pSmartTags;
+    sal_uLong nNumberOfWords  = 0;
+    sal_uLong nNumberOfAsianWords  = 0;
+    sal_uLong nNumberOfChars  = 0;
+    sal_uLong nNumberOfCharsExcludingSpaces = 0;
+    bool bWordCountDirty = true;
+    WrongState eWrongDirty = WrongState::TODO; ///< online spell checking 
needed/done?
+    bool bGrammarCheckDirty = true;
+    bool bSmartTagDirty = true;
+    bool bAutoComplDirty = true;               ///< auto complete list dirty
+};
+
+} // end namespace sw
+
 /// SwTextNode is a paragraph in the document model.
 class SW_DLLPUBLIC SwTextNode final
     : public SwContentNode
@@ -97,7 +119,7 @@ class SW_DLLPUBLIC SwTextNode final
 
     OUString m_Text;
 
-    SwParaIdleData_Impl* m_pParaIdleData_Impl;
+    mutable sw::ParagraphIdleData m_aParagraphIdleData;
 
     /** Some of the chars this para are hidden. Paragraph has to be reformatted
        on changing the view to print preview. */
@@ -164,10 +186,6 @@ class SW_DLLPUBLIC SwTextNode final
             LanguageType nLang, sal_uInt16 nLangWhichId,
             const vcl::Font *pFont,  sal_uInt16 nFontWhichId );
 
-    /// Start: Data collected during idle time
-
-    SAL_DLLPRIVATE void InitSwParaStatistics( bool bNew );
-
     inline void TryDeleteSwpHints();
 
     SAL_DLLPRIVATE void impl_FormatToTextAttr(const SfxItemSet& i_rAttrSet);
@@ -177,16 +195,14 @@ class SW_DLLPUBLIC SwTextNode final
     void DelFrames_TextNodePart();
 
 public:
-    enum class WrongState { TODO, PENDING, DONE };
-
     bool IsWordCountDirty() const;
-    WrongState GetWrongDirty() const;
+    sw::WrongState GetWrongDirty() const;
     bool IsWrongDirty() const;
     bool IsGrammarCheckDirty() const;
     bool IsSmartTagDirty() const;
     bool IsAutoCompleteWordDirty() const;
     void SetWordCountDirty( bool bNew ) const;
-    void SetWrongDirty(WrongState eNew) const;
+    void SetWrongDirty(sw::WrongState eNew) const;
     void SetGrammarCheckDirty( bool bNew ) const;
     void SetSmartTagDirty( bool bNew ) const;
     void SetAutoCompleteWordDirty( bool bNew ) const;
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 5abb1d9d92c9..571a9bb75c4c 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1124,14 +1124,14 @@ static bool lcl_SpellAndGrammarAgain( SwNode* pNd, 
void* pArgs )
         {
             if( pTextNode->GetWrong() &&
                 pTextNode->GetWrong()->InvalidateWrong() )
-                pTextNode->SetWrongDirty(SwTextNode::WrongState::TODO);
+                pTextNode->SetWrongDirty(sw::WrongState::TODO);
             if( pTextNode->GetGrammarCheck() &&
                 pTextNode->GetGrammarCheck()->InvalidateWrong() )
                 pTextNode->SetGrammarCheckDirty( true );
         }
         else
         {
-            pTextNode->SetWrongDirty(SwTextNode::WrongState::TODO);
+            pTextNode->SetWrongDirty(sw::WrongState::TODO);
             if( pTextNode->GetWrong() )
                 pTextNode->GetWrong()->SetInvalid( 0, COMPLETE_STRING );
             pTextNode->SetGrammarCheckDirty( true );
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 5caf4451ce7b..81c3a588c363 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -2028,7 +2028,7 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, 
IdleJobType eJob )
             {
                 SwRect aRepaint( 
const_cast<SwTextFrame*>(pTextFrame)->AutoSpell_(*pTextNode, nPos) );
                 // PENDING should stop idle spell checking
-                m_bPageValid = m_bPageValid && (SwTextNode::WrongState::TODO 
!= pTextNode->GetWrongDirty());
+                m_bPageValid = m_bPageValid && (sw::WrongState::TODO != 
pTextNode->GetWrongDirty());
                 if ( aRepaint.HasArea() )
                     m_pImp->GetShell()->InvalidateWindows( aRepaint );
                 if (Application::AnyInput(VCL_INPUT_ANY & 
VclInputFlags(~VclInputFlags::TIMER)))
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index fb177841728d..4c163bc8a0df 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1838,7 +1838,7 @@ static void lcl_SetWrong( SwTextFrame& rFrame, SwTextNode 
const& rNode,
             pTextNode->SetSmartTags( std::make_unique<SwWrongList>( 
WRONGLIST_SMARTTAG ) );
             pTextNode->GetSmartTags()->SetInvalid( nPos, nEnd );
         }
-        pTextNode->SetWrongDirty(SwTextNode::WrongState::TODO);
+        pTextNode->SetWrongDirty(sw::WrongState::TODO);
         pTextNode->SetGrammarCheckDirty( true );
         pTextNode->SetWordCountDirty( true );
         pTextNode->SetAutoCompleteWordDirty( true );
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 74ae4c2cb0c3..8eeb9b6cdf59 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -187,7 +187,6 @@ SwTextNode *SwNodes::MakeTextNode( const SwNodeIndex & 
rWhere,
 
 SwTextNode::SwTextNode( const SwNodeIndex &rWhere, SwTextFormatColl 
*pTextColl, const SfxItemSet* pAutoAttr )
 :   SwContentNode( rWhere, SwNodeType::Text, pTextColl ),
-    m_pParaIdleData_Impl(nullptr),
     m_bContainsHiddenChars(false),
     m_bHiddenCharsHidePara(false),
     m_bRecalcHiddenCharFlags(false),
@@ -197,7 +196,6 @@ SwTextNode::SwTextNode( const SwNodeIndex &rWhere, 
SwTextFormatColl *pTextColl,
     mbInSetOrResetAttr( false ),
     m_bInUndo(false)
 {
-    InitSwParaStatistics( true );
 
     if( pAutoAttr )
         SetAttr( *pAutoAttr );
@@ -249,7 +247,6 @@ SwTextNode::~SwTextNode()
 
     RemoveFromList();
 
-    InitSwParaStatistics( false );
     DelFrames(nullptr); // must be called here while it's still a SwTextNode
     DelFrames_TextNodePart();
 #if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
@@ -468,7 +465,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & 
rPos,
         {
             pNode->SetWrong( GetWrong()->SplitList( nSplitPos ) );
         }
-        SetWrongDirty(WrongState::TODO);
+        SetWrongDirty(sw::WrongState::TODO);
 
         if( GetGrammarCheck() )
         {
@@ -573,7 +570,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & 
rPos,
     else
     {
         std::unique_ptr<SwWrongList> pList = ReleaseWrong();
-        SetWrongDirty(WrongState::TODO);
+        SetWrongDirty(sw::WrongState::TODO);
 
         std::unique_ptr<SwGrammarMarkUp> pList3 = ReleaseGrammarCheck();
         SetGrammarCheckDirty( true );
@@ -999,7 +996,7 @@ SwContentNode *SwTextNode::JoinNext()
         if( pList )
         {
             pList->JoinList( pTextNode->GetWrong(), nOldLen );
-            SetWrongDirty(WrongState::TODO);
+            SetWrongDirty(sw::WrongState::TODO);
         }
         else
         {
@@ -1007,7 +1004,7 @@ SwContentNode *SwTextNode::JoinNext()
             if( pList )
             {
                 pList->Move( 0, nOldLen );
-                SetWrongDirty(WrongState::TODO);
+                SetWrongDirty(sw::WrongState::TODO);
             }
         }
 
@@ -1111,7 +1108,7 @@ void SwTextNode::JoinPrev()
         if( pList )
         {
             pList->JoinList( GetWrong(), Len() );
-            SetWrongDirty(WrongState::TODO);
+            SetWrongDirty(sw::WrongState::TODO);
             ClearWrong();
         }
         else
@@ -1120,7 +1117,7 @@ void SwTextNode::JoinPrev()
             if( pList )
             {
                 pList->Move( 0, nLen );
-                SetWrongDirty(WrongState::TODO);
+                SetWrongDirty(sw::WrongState::TODO);
             }
         }
 
@@ -1775,7 +1772,7 @@ const SwTextInputField* 
SwTextNode::GetOverlappingInputField( const SwTextAttr&
 void SwTextNode::DelFrames_TextNodePart()
 {
     SetWrong( nullptr );
-    SetWrongDirty(WrongState::TODO);
+    SetWrongDirty(sw::WrongState::TODO);
 
     SetGrammarCheck( nullptr );
     SetGrammarCheckDirty( true );
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index 74ae7cf1d3c2..59626eaf6d90 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -97,33 +97,6 @@ namespace
     }
 }
 
-struct SwParaIdleData_Impl
-{
-    std::unique_ptr<SwWrongList> pWrong;                // for spell checking
-    std::unique_ptr<SwGrammarMarkUp> pGrammarCheck;     // for grammar 
checking /  proof reading
-    std::unique_ptr<SwWrongList> pSmartTags;
-    sal_uLong nNumberOfWords;
-    sal_uLong nNumberOfAsianWords;
-    sal_uLong nNumberOfChars;
-    sal_uLong nNumberOfCharsExcludingSpaces;
-    bool bWordCountDirty;
-    SwTextNode::WrongState eWrongDirty; ///< online spell checking needed/done?
-    bool bGrammarCheckDirty;
-    bool bSmartTagDirty;
-    bool bAutoComplDirty;               ///< auto complete list dirty
-
-    SwParaIdleData_Impl() :
-        nNumberOfWords      ( 0 ),
-        nNumberOfAsianWords ( 0 ),
-        nNumberOfChars      ( 0 ),
-        nNumberOfCharsExcludingSpaces ( 0 ),
-        bWordCountDirty     ( true ),
-        eWrongDirty         ( SwTextNode::WrongState::TODO ),
-        bGrammarCheckDirty  ( true ),
-        bSmartTagDirty      ( true ),
-        bAutoComplDirty     ( true ) {};
-};
-
 static bool lcl_HasComments(const SwTextNode& rNode)
 {
     sal_Int32 nPosition = rNode.GetText().indexOf(CH_TXTATR_INWORD);
@@ -1409,14 +1382,14 @@ SwRect SwTextFrame::AutoSpell_(SwTextNode & rNode, 
sal_Int32 nActPos)
         pNode->SetWrongDirty(
             (COMPLETE_STRING != pNode->GetWrong()->GetBeginInv())
                 ? (bPending
-                    ? SwTextNode::WrongState::PENDING
-                    : SwTextNode::WrongState::TODO)
-                : SwTextNode::WrongState::DONE);
+                    ? sw::WrongState::PENDING
+                    : sw::WrongState::TODO)
+                : sw::WrongState::DONE);
         if( !pNode->GetWrong()->Count() && ! pNode->IsWrongDirty() )
             pNode->ClearWrong();
     }
     else
-        pNode->SetWrongDirty(SwTextNode::WrongState::DONE);
+        pNode->SetWrongDirty(sw::WrongState::DONE);
 
     if( bAddAutoCmpl )
         pNode->SetAutoCompleteWordDirty( false );
@@ -2047,13 +2020,11 @@ bool SwTextNode::CountWords( SwDocStat& rStat,
     if ( bCountAll && !IsWordCountDirty() )
     {
         // accumulate into DocStat record to return the values
-        if (m_pParaIdleData_Impl)
-        {
-            rStat.nWord += m_pParaIdleData_Impl->nNumberOfWords;
-            rStat.nAsianWord += m_pParaIdleData_Impl->nNumberOfAsianWords;
-            rStat.nChar += m_pParaIdleData_Impl->nNumberOfChars;
-            rStat.nCharExcludingSpaces += 
m_pParaIdleData_Impl->nNumberOfCharsExcludingSpaces;
-        }
+
+        rStat.nWord += m_aParagraphIdleData.nNumberOfWords;
+        rStat.nAsianWord += m_aParagraphIdleData.nNumberOfAsianWords;
+        rStat.nChar += m_aParagraphIdleData.nNumberOfChars;
+        rStat.nCharExcludingSpaces += 
m_aParagraphIdleData.nNumberOfCharsExcludingSpaces;
         return false;
     }
 
@@ -2148,13 +2119,10 @@ bool SwTextNode::CountWords( SwDocStat& rStat,
     // If counting the whole para then update cached values and mark clean
     if ( bCountAll )
     {
-        if ( m_pParaIdleData_Impl )
-        {
-            m_pParaIdleData_Impl->nNumberOfWords = nTmpWords;
-            m_pParaIdleData_Impl->nNumberOfAsianWords = nTmpAsianWords;
-            m_pParaIdleData_Impl->nNumberOfChars = nTmpChars;
-            m_pParaIdleData_Impl->nNumberOfCharsExcludingSpaces = 
nTmpCharsExcludingSpaces;
-        }
+        m_aParagraphIdleData.nNumberOfWords = nTmpWords;
+        m_aParagraphIdleData.nNumberOfAsianWords = nTmpAsianWords;
+        m_aParagraphIdleData.nNumberOfChars = nTmpChars;
+        m_aParagraphIdleData.nNumberOfCharsExcludingSpaces = 
nTmpCharsExcludingSpaces;
         SetWordCountDirty( false );
     }
     // accumulate into DocStat record to return the values
@@ -2166,72 +2134,50 @@ bool SwTextNode::CountWords( SwDocStat& rStat,
     return true;
 }
 
-// Paragraph statistics start -->
-
-void SwTextNode::InitSwParaStatistics( bool bNew )
-{
-    if ( bNew )
-    {
-        m_pParaIdleData_Impl = new SwParaIdleData_Impl;
-    }
-    else if ( m_pParaIdleData_Impl )
-    {
-        m_pParaIdleData_Impl->pWrong.reset();
-        m_pParaIdleData_Impl->pGrammarCheck.reset();
-        m_pParaIdleData_Impl->pSmartTags.reset();
-        delete m_pParaIdleData_Impl;
-        m_pParaIdleData_Impl = nullptr;
-    }
-}
-
 void SwTextNode::SetWrong( std::unique_ptr<SwWrongList> pNew )
 {
-    if ( m_pParaIdleData_Impl )
-        m_pParaIdleData_Impl->pWrong = std::move(pNew);
+    m_aParagraphIdleData.pWrong = std::move(pNew);
 }
 
 void SwTextNode::ClearWrong()
 {
-    if ( m_pParaIdleData_Impl )
-        m_pParaIdleData_Impl->pWrong.reset();
+    m_aParagraphIdleData.pWrong.reset();
 }
 
 std::unique_ptr<SwWrongList> SwTextNode::ReleaseWrong()
 {
-    return m_pParaIdleData_Impl ? std::move(m_pParaIdleData_Impl->pWrong) : 
nullptr;
+    return std::move(m_aParagraphIdleData.pWrong);
 }
 
 SwWrongList* SwTextNode::GetWrong()
 {
-    return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pWrong.get() : nullptr;
+    return m_aParagraphIdleData.pWrong.get();
 }
 
 // #i71360#
 const SwWrongList* SwTextNode::GetWrong() const
 {
-    return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pWrong.get() : nullptr;
+    return m_aParagraphIdleData.pWrong.get();
 }
 
 void SwTextNode::SetGrammarCheck( std::unique_ptr<SwGrammarMarkUp> pNew )
 {
-    if ( m_pParaIdleData_Impl )
-        m_pParaIdleData_Impl->pGrammarCheck = std::move(pNew);
+    m_aParagraphIdleData.pGrammarCheck = std::move(pNew);
 }
 
 void SwTextNode::ClearGrammarCheck()
 {
-    if ( m_pParaIdleData_Impl )
-        m_pParaIdleData_Impl->pGrammarCheck.reset();
+    m_aParagraphIdleData.pGrammarCheck.reset();
 }
 
 std::unique_ptr<SwGrammarMarkUp> SwTextNode::ReleaseGrammarCheck()
 {
-    return m_pParaIdleData_Impl ? 
std::move(m_pParaIdleData_Impl->pGrammarCheck) : nullptr;
+    return std::move(m_aParagraphIdleData.pGrammarCheck);
 }
 
 SwGrammarMarkUp* SwTextNode::GetGrammarCheck()
 {
-    return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pGrammarCheck.get() : 
nullptr;
+    return m_aParagraphIdleData.pGrammarCheck.get();
 }
 
 SwWrongList const* SwTextNode::GetGrammarCheck() const
@@ -2244,24 +2190,22 @@ void SwTextNode::SetSmartTags( 
std::unique_ptr<SwWrongList> pNew )
     OSL_ENSURE( !pNew || SwSmartTagMgr::Get().IsSmartTagsEnabled(),
             "Weird - we have a smart tag list without any recognizers?" );
 
-    if ( m_pParaIdleData_Impl )
-        m_pParaIdleData_Impl->pSmartTags = std::move(pNew);
+    m_aParagraphIdleData.pSmartTags = std::move(pNew);
 }
 
 void SwTextNode::ClearSmartTags()
 {
-    if ( m_pParaIdleData_Impl )
-        m_pParaIdleData_Impl->pSmartTags.reset();
+    m_aParagraphIdleData.pSmartTags.reset();
 }
 
 std::unique_ptr<SwWrongList> SwTextNode::ReleaseSmartTags()
 {
-    return m_pParaIdleData_Impl ? std::move(m_pParaIdleData_Impl->pSmartTags) 
: nullptr;
+    return std::move(m_aParagraphIdleData.pSmartTags);
 }
 
 SwWrongList* SwTextNode::GetSmartTags()
 {
-    return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pSmartTags.get() : 
nullptr;
+    return m_aParagraphIdleData.pSmartTags.get();
 }
 
 SwWrongList const* SwTextNode::GetSmartTags() const
@@ -2271,72 +2215,57 @@ SwWrongList const* SwTextNode::GetSmartTags() const
 
 void SwTextNode::SetWordCountDirty( bool bNew ) const
 {
-    if ( m_pParaIdleData_Impl )
-    {
-        m_pParaIdleData_Impl->bWordCountDirty = bNew;
-    }
+    m_aParagraphIdleData.bWordCountDirty = bNew;
 }
 
 bool SwTextNode::IsWordCountDirty() const
 {
-    return m_pParaIdleData_Impl && m_pParaIdleData_Impl->bWordCountDirty;
+    return m_aParagraphIdleData.bWordCountDirty;
 }
 
-void SwTextNode::SetWrongDirty(WrongState eNew) const
+void SwTextNode::SetWrongDirty(sw::WrongState eNew) const
 {
-    if ( m_pParaIdleData_Impl )
-    {
-        m_pParaIdleData_Impl->eWrongDirty = eNew;
-    }
+    m_aParagraphIdleData.eWrongDirty = eNew;
 }
 
-auto SwTextNode::GetWrongDirty() const -> WrongState
+sw::WrongState SwTextNode::GetWrongDirty() const
 {
-    return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->eWrongDirty : 
WrongState::DONE;
+    return m_aParagraphIdleData.eWrongDirty;
 }
 
 bool SwTextNode::IsWrongDirty() const
 {
-    return m_pParaIdleData_Impl && m_pParaIdleData_Impl->eWrongDirty != 
WrongState::DONE;
+    return m_aParagraphIdleData.eWrongDirty != sw::WrongState::DONE;
 }
 
 void SwTextNode::SetGrammarCheckDirty( bool bNew ) const
 {
-    if ( m_pParaIdleData_Impl )
-    {
-        m_pParaIdleData_Impl->bGrammarCheckDirty = bNew;
-    }
+    m_aParagraphIdleData.bGrammarCheckDirty = bNew;
 }
 
 bool SwTextNode::IsGrammarCheckDirty() const
 {
-    return m_pParaIdleData_Impl && m_pParaIdleData_Impl->bGrammarCheckDirty;
+    return m_aParagraphIdleData.bGrammarCheckDirty;
 }
 
 void SwTextNode::SetSmartTagDirty( bool bNew ) const
 {
-    if ( m_pParaIdleData_Impl )
-    {
-        m_pParaIdleData_Impl->bSmartTagDirty = bNew;
-    }
+    m_aParagraphIdleData.bSmartTagDirty = bNew;
 }
 
 bool SwTextNode::IsSmartTagDirty() const
 {
-    return m_pParaIdleData_Impl && m_pParaIdleData_Impl->bSmartTagDirty;
+    return m_aParagraphIdleData.bSmartTagDirty;
 }
 
 void SwTextNode::SetAutoCompleteWordDirty( bool bNew ) const
 {
-    if ( m_pParaIdleData_Impl )
-    {
-        m_pParaIdleData_Impl->bAutoComplDirty = bNew;
-    }
+    m_aParagraphIdleData.bAutoComplDirty = bNew;
 }
 
 bool SwTextNode::IsAutoCompleteWordDirty() const
 {
-    return m_pParaIdleData_Impl && m_pParaIdleData_Impl->bAutoComplDirty;
+    return m_aParagraphIdleData.bAutoComplDirty;
 }
 
 // <-- Paragraph statistics end
diff --git a/sw/source/core/unocore/unoflatpara.cxx 
b/sw/source/core/unocore/unoflatpara.cxx
index a04004124dd1..20b642bd23a2 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -182,7 +182,7 @@ void SAL_CALL SwXFlatParagraph::setChecked( ::sal_Int32 
nType, sal_Bool bVal )
     if ( text::TextMarkupType::SPELLCHECK == nType )
     {
         GetTextNode()->SetWrongDirty(
-            bVal ? SwTextNode::WrongState::DONE : 
SwTextNode::WrongState::TODO);
+            bVal ? sw::WrongState::DONE : sw::WrongState::TODO);
     }
     else if ( text::TextMarkupType::SMARTTAG == nType )
         GetTextNode()->SetSmartTagDirty( !bVal );
diff --git a/sw/source/core/unocore/unoobj.cxx 
b/sw/source/core/unocore/unoobj.cxx
index 33dfba9e8358..2a29eb452cb8 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -2606,7 +2606,7 @@ void SAL_CALL 
SwXTextCursor::invalidateMarkings(::sal_Int32 nType)
 
     if ( text::TextMarkupType::SPELLCHECK == nType )
     {
-        txtNode->SetWrongDirty(SwTextNode::WrongState::TODO);
+        txtNode->SetWrongDirty(sw::WrongState::TODO);
         txtNode->ClearWrong();
     }
     else if( text::TextMarkupType::PROOFREADING == nType )
commit b7566d1b5b06c196b09eff1f588d25279d057431
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Sep 22 15:46:58 2022 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Dec 6 08:43:37 2022 +0000

    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>
    (cherry picked from commit 822e5aba1b40c69591b5fa6cf94819011adc8455)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143653
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx
index 66aeb75112ed..d32951964dd4 100644
--- a/sw/source/core/inc/layact.hxx
+++ b/sw/source/core/inc/layact.hxx
@@ -193,6 +193,12 @@ enum class IdleJobType
     SMART_TAGS
 };
 
+enum class IdleJobArea
+{
+    ALL,
+    VISIBLE
+};
+
 class SwLayIdle
 {
     SwRootFrame *m_pRoot;
@@ -207,7 +213,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 88ec6c171476..5caf4451ce7b 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -2130,7 +2130,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.
@@ -2141,7 +2141,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());
@@ -2207,9 +2207,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;
 }
@@ -2256,9 +2258,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
@@ -2370,10 +2372,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