From 3b729db05553c1a6d461fb41c89a05702f407448 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 24 Sep 2021 11:25:27 +0200 Subject: do not use text-based LOK callback internally CallbackFlushHandler post-processes LOK messages, but for things like dropping useless invalidations it needs to know the rectangle or the view id, and since the only data it gets are string messages, it needs to convert those back to binary form. Which is slow with large numbers of messages. Add internal LOK callback variant that allows also passing specific data in the original binary form. And then use directly the binary data in CallbackFlushHandler. Change-Id: I8dd30d2ff9c09feadebc31a44d8e6a8ccc306504 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123589 Tested-by: Jenkins Reviewed-by: Michael Meeks --- include/sfx2/lokcallback.hxx | 41 +++++++++++++++++++++++++++++++++++++++++ include/sfx2/viewsh.hxx | 10 +++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 include/sfx2/lokcallback.hxx (limited to 'include/sfx2') diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx new file mode 100644 index 000000000000..4c40c5452c15 --- /dev/null +++ b/include/sfx2/lokcallback.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include + +namespace tools +{ +class Rectangle; +} + +// An extended callback type that allows passing in also some binary data, +// so that post-processing the messages does not require conversions +// from and to strings. + +// TODO: It might possibly make sense to drop the generic type/payload function +// and have only a dedicated function for each message type? + +class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SfxLokCallbackInterface +{ +public: + virtual ~SfxLokCallbackInterface() {} + // LibreOfficeKitCallback equivalent. + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) = 0; + // Callback that explicitly provides view id (which is also included in the payload). + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) = 0; + // LOK_CALLBACK_INVALIDATE_TILES + // nPart is either part, -1 for all-parts, or INT_MIN if + // comphelper::LibreOfficeKit::isPartInInvalidation() is not set + virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) + = 0; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 64b56e1c1293..44201db40e41 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -55,6 +55,7 @@ class SfxPrinter; class Menu; class NotifyEvent; class SfxInPlaceClient; +class SfxLokCallbackInterface; namespace vcl { class PrinterController; } namespace com::sun::star::beans { struct PropertyValue; } @@ -333,10 +334,13 @@ public: SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( false ); } SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey); - /// The actual per-view implementation of lok::Document::registerCallback(). - void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData); + /// Set up a more efficient internal callback instead of LibreOfficeKitCallback. + void setLibreOfficeKitViewCallback(SfxLokCallbackInterface* pCallback); /// Invokes the registered callback, if there are any. - void libreOfficeKitViewCallback(int nType, const char* pPayload) const override; + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const override; + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) const override; + virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const override; + /// Set if we are doing tiled searching. void setTiledSearching(bool bTiledSearching); /// See lok::Document::getPart(). -- cgit