diff options
-rw-r--r-- | sw/inc/ndtxt.hxx | 36 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/layact.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/txtfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 149 | ||||
-rw-r--r-- | sw/source/core/unocore/unoflatpara.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 2 |
8 files changed, 78 insertions, 136 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 2a1f9f878cfa..a37661e18547 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -63,7 +63,6 @@ class SwInterHyphInfo; class SwWrongList; class SwGrammarMarkUp; struct SwDocStat; -struct SwParaIdleData_Impl; enum class ExpandMode; enum class SwFieldIds : sal_uInt16; class SwField; @@ -81,6 +80,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 @@ -105,7 +127,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. */ @@ -172,10 +194,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); @@ -186,16 +204,14 @@ class SW_DLLPUBLIC SwTextNode final void HandleNonLegacyHint(const SfxHint&); 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 62064507114b..dfd11369ade7 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1120,14 +1120,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 fc7f1c1f5314..75662f3374e0 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -2029,7 +2029,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 8c8fc987f57c..af3955a23e87 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1837,7 +1837,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 cab06e4959aa..7bf7f23761b9 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -201,7 +201,6 @@ SwTextNode *SwNodes::MakeTextNode( SwNode& rWhere, SwTextNode::SwTextNode( SwNode& rWhere, SwTextFormatColl *pTextColl, const SfxItemSet* pAutoAttr ) : SwContentNode( rWhere, SwNodeType::Text, pTextColl ), - m_pParaIdleData_Impl(nullptr), m_bContainsHiddenChars(false), m_bHiddenCharsHidePara(false), m_bRecalcHiddenCharFlags(false), @@ -213,7 +212,6 @@ SwTextNode::SwTextNode( SwNode& rWhere, SwTextFormatColl *pTextColl, const SfxIt { { sw::TextNodeNotificationSuppressor(*this); - InitSwParaStatistics( true ); if( pAutoAttr ) SetAttr( *pAutoAttr ); @@ -264,7 +262,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) @@ -483,7 +480,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, { pNode->SetWrong( GetWrong()->SplitList( nSplitPos ) ); } - SetWrongDirty(WrongState::TODO); + SetWrongDirty(sw::WrongState::TODO); if( GetGrammarCheck() ) { @@ -588,7 +585,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 ); @@ -1014,7 +1011,7 @@ SwContentNode *SwTextNode::JoinNext() if( pList ) { pList->JoinList( pTextNode->GetWrong(), nOldLen ); - SetWrongDirty(WrongState::TODO); + SetWrongDirty(sw::WrongState::TODO); } else { @@ -1022,7 +1019,7 @@ SwContentNode *SwTextNode::JoinNext() if( pList ) { pList->Move( 0, nOldLen ); - SetWrongDirty(WrongState::TODO); + SetWrongDirty(sw::WrongState::TODO); } } @@ -1126,7 +1123,7 @@ void SwTextNode::JoinPrev() if( pList ) { pList->JoinList( GetWrong(), Len() ); - SetWrongDirty(WrongState::TODO); + SetWrongDirty(sw::WrongState::TODO); ClearWrong(); } else @@ -1135,7 +1132,7 @@ void SwTextNode::JoinPrev() if( pList ) { pList->Move( 0, nLen ); - SetWrongDirty(WrongState::TODO); + SetWrongDirty(sw::WrongState::TODO); } } @@ -1814,7 +1811,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 131869909782..d16a17eddc28 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -99,33 +99,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); @@ -1410,14 +1383,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 ); @@ -2069,13 +2042,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; } @@ -2170,13 +2141,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 @@ -2188,72 +2156,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 @@ -2266,24 +2212,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 @@ -2293,72 +2237,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 a417e4384182..553deb7560be 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 f4c7c659bd04..0bc921fa8f00 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -2592,7 +2592,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 ) |