From 8d4427d14148181c6125b49f7a23d33e91189160 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 5 Jun 2024 00:41:03 +0500 Subject: tdf#136294: trigger pending spellcheck in SwCursorShell::UpdateCursor This allows to drop the partial fix created for tdf#124603 (except for unit test). The problem solved in commit 4c91e94e892943ef5e031d65f6f42864233cb4cd (tdf#92036: sw: fix idle spelling loop, 2015-09-09) is kept solved; when a word is marked pending, this is signalled to the viewshell. SwCursorShell stores that as a flag, which will then start an idle on cursor update, and finally call SwViewShell::LayoutIdle, which does the spell checking. If the cursor is still in the word that is pending the check, the cycle will repeat, trying spell checks only at cursor update, not as a busy loop. Change-Id: I5dc77baabffa723e261d553e40d40e5ace4266bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168413 Tested-by: Jenkins Reviewed-by: Mike Kaganski Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168430 Reviewed-by: Michael Stahl --- sw/inc/crsrsh.hxx | 12 ++++++++++++ sw/inc/viewsh.hxx | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'sw/inc') diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 03afe5006ad6..97248572c762 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -243,8 +244,14 @@ private: bool m_bMacroExecAllowed : 1; + // SwViewShell::LayoutIdle needs to be called on cursor update to repeat a spell check, + // because previous attempt marked a word as pending, because the word had cursor + bool m_bNeedLayoutOnCursorUpdate : 1 = false; + SwFrame* m_oldColFrame; + Idle m_aLayoutIdle; // An idle to schedule another SwViewShell::LayoutIdle call + SAL_DLLPRIVATE void MoveCursorToNum(); SAL_DLLPRIVATE void ParkPams( SwPaM* pDelRg, SwShellCursor** ppDelRing ); @@ -285,6 +292,9 @@ private: SAL_DLLPRIVATE const SwRangeRedline* GotoRedline_( SwRedlineTable::size_type nArrPos, bool bSelect ); SAL_DLLPRIVATE void sendLOKCursorUpdates(); + + DECL_LINK(DoLayoutIdle, Timer*, void); // calls SwViewShell::LayoutIdle + protected: inline SwMoveFnCollection const & MakeFindRange( SwDocPositions, SwDocPositions, SwPaM* ) const; @@ -308,6 +318,8 @@ protected: protected: virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + virtual void OnSpellWrongStatePending() override { m_bNeedLayoutOnCursorUpdate = true; } + public: SwCursorShell( SwDoc& rDoc, vcl::Window *pWin, const SwViewOption *pOpt ); // disguised copy constructor diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 66eec0f5060e..ea5ed065dafa 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -598,6 +598,13 @@ public: void GetFirstLastVisPageNumbers(SwVisiblePageNumbers& rVisiblePageNumbers); virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; + + // SwTextFrame::AutoSpell_ calls this, to notify the shell, that a word has a spelling error, + // but that couldn't be drawn, because the cursor was in that word (so that the user is not + // annoyed while typing). The shell's task is to re-run the spell check (i.e., call LayoutIdle, + // which internally does the spell check), when the cursor leaves that word (implemented in + // SwCursorShell). + virtual void OnSpellWrongStatePending() {} }; // manages global ShellPointer -- cgit