desktop/inc/lib/init.hxx | 1 + desktop/source/lib/init.cxx | 6 ++++++ include/editeng/outliner.hxx | 1 + include/sfx2/lokcallback.hxx | 3 +++ include/sfx2/viewsh.hxx | 5 +++-- include/test/lokcallback.hxx | 1 + sfx2/source/view/viewsh.cxx | 10 ++++++++++ sw/source/core/view/viewimp.cxx | 5 ++++- test/source/lokcallback.cxx | 6 ++++++ 9 files changed, 35 insertions(+), 3 deletions(-)
New commits: commit 2cc955f9109c0fc8443c9f93c1bf6bd317043cb5 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue Jun 28 09:42:17 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Aug 31 08:36:19 2022 +0200 lok: make sure flushPendingLOKInvalidateTiles() is called SwViewShellImp::AddPendingLOKInvalidation() collects invalidations, but this was relying on something eventually calling flushPendingLOKInvalidateTiles(), which wasn't guaranteed. If e.g. a spellchecker caused an invalidation from in idle callback and nothing else changed, then the LOK callback handling code didn't know there was something pending. So add an explicit call to ensure to notify about these pending invalidations. Change-Id: I0a9cb0d5aba2fdbbac126cd8a4a3412bef1cab25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136531 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> (cherry picked from commit 32cbd1c57dbaf7cff2325c126b3adfcf2150bc23) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136532 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index baa1b682de07..7346e51ff159 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -119,6 +119,7 @@ namespace desktop { virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) override; virtual void libreOfficeKitViewUpdatedCallback(int nType) override; virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) override; + virtual void libreOfficeKitViewAddPendingInvalidateTiles() override; virtual void dumpState(rtl::OStringBuffer &rState) override; private: diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d1b1931fc69e..bf37ae65c9d0 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1490,6 +1490,12 @@ void CallbackFlushHandler::dumpState(rtl::OStringBuffer &rState) } } +void CallbackFlushHandler::libreOfficeKitViewAddPendingInvalidateTiles() +{ + // Invoke() will call flushPendingLOKInvalidateTiles(), so just make sure the timer is active. + startTimer(); +} + void CallbackFlushHandler::queue(const int type, const char* data) { CallbackData callbackData(data); diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 87fabb4ee45e..c8890a89a72f 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -373,6 +373,7 @@ public: virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const = 0; virtual void libreOfficeKitViewUpdatedCallback(int nType) const = 0; virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const = 0; + virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0; virtual ViewShellId GetViewShellId() const = 0; virtual ViewShellDocId GetDocId() const = 0; /// Wrapper around SfxLokHelper::notifyOtherViews(). diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx index 95572aba1104..1b90e6c938c5 100644 --- a/include/sfx2/lokcallback.hxx +++ b/include/sfx2/lokcallback.hxx @@ -52,6 +52,9 @@ public: virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) = 0; + // There are pending invalidate tiles calls that need to be processed. + // A call to SfxViewShell::flushPendingLOKInvalidateTiles() should be scheduled. + virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0; virtual void dumpState(rtl::OStringBuffer& rState) = 0; }; diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index e2ef0475dbc6..9f085fca62e3 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -346,10 +346,11 @@ public: virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const override; virtual void libreOfficeKitViewCallbackWithViewId(int nType, const char* pPayload, int nViewId) const override; virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const override; - // Performs any pending calls to libreOfficeKitViewInvalidateTilesCallback() as necessary. - virtual void flushPendingLOKInvalidateTiles(); virtual void libreOfficeKitViewUpdatedCallback(int nType) const override; virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const override; + // Performs any pending calls to libreOfficeKitViewInvalidateTilesCallback() as necessary. + virtual void flushPendingLOKInvalidateTiles(); + virtual void libreOfficeKitViewAddPendingInvalidateTiles() override; // Returns current payload for nType, after libreOfficeKitViewUpdatedCallback() or // libreOfficeKitViewUpdatedCallbackPerViewId() were called. If no payload should // be generated, the ignore flag should be set. diff --git a/include/test/lokcallback.hxx b/include/test/lokcallback.hxx index e18724279040..75a8977938bc 100644 --- a/include/test/lokcallback.hxx +++ b/include/test/lokcallback.hxx @@ -39,6 +39,7 @@ public: virtual void libreOfficeKitViewUpdatedCallback(int nType) override; virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) override; + virtual void libreOfficeKitViewAddPendingInvalidateTiles() override; virtual void dumpState(rtl::OStringBuffer&) override{}; virtual void Invoke() override; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 2098e05a283f..0e9279dedeb3 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1546,6 +1546,16 @@ void SfxViewShell::libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nVi << lokCallbackTypeToString(nType)); } +void SfxViewShell::libreOfficeKitViewAddPendingInvalidateTiles() +{ + if (pImpl->m_pLibreOfficeKitViewCallback) + pImpl->m_pLibreOfficeKitViewCallback->libreOfficeKitViewAddPendingInvalidateTiles(); + else + SAL_INFO( + "sfx.view", + "SfxViewShell::libreOfficeKitViewAddPendingInvalidateTiles no callback set!"); +} + void SfxViewShell::afterCallbackRegistered() { } diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index f08c3305e5d6..cb3773383b95 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -36,6 +36,7 @@ #include <IDocumentDrawModelAccess.hxx> #include <drawdoc.hxx> #include <prevwpage.hxx> +#include <sfx2/viewsh.hxx> void SwViewShellImp::Init( const SwViewOption *pNewOpt ) { @@ -161,8 +162,10 @@ bool SwViewShellImp::AddPaintRect( const SwRect &rRect ) void SwViewShellImp::AddPendingLOKInvalidation( const SwRect& rRect ) { - // These are often repeated, so check first for duplicates. std::vector<SwRect>& l = m_pendingLOKInvalidations; + if(l.empty()) // Announce that these invalidations will need flushing. + m_pShell->GetSfxViewShell()->libreOfficeKitViewAddPendingInvalidateTiles(); + // These are often repeated, so check first for duplicates. if( std::find( l.begin(), l.end(), rRect ) == l.end()) l.push_back( rRect ); } diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx index c938e1e699a8..d7500cb74443 100644 --- a/test/source/lokcallback.cxx +++ b/test/source/lokcallback.cxx @@ -106,6 +106,12 @@ void TestLokCallbackWrapper::libreOfficeKitViewUpdatedCallbackPerViewId(int nTyp startTimer(); } +void TestLokCallbackWrapper::libreOfficeKitViewAddPendingInvalidateTiles() +{ + // Invoke() will call flushPendingLOKInvalidateTiles(). + startTimer(); +} + void TestLokCallbackWrapper::discardUpdatedTypes(int nType, int nViewId) { // If a callback is called directly with an event, drop the updated flag for it, since