From e051b3a6d59ed925e1cddfa72696c9a740830808 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 24 Sep 2022 22:35:19 +0200 Subject: sw: refactor SwParaIdleData - rename, lifecycle, move to header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- sw/inc/ndtxt.hxx | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'sw/inc') 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 pWrong; // for spell checking + std::unique_ptr pGrammarCheck; // for grammar checking / proof reading + std::unique_ptr 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; -- cgit