summaryrefslogtreecommitdiff
path: root/include/sfx2
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-24 11:25:27 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-10-15 13:39:43 +0200
commit3b729db05553c1a6d461fb41c89a05702f407448 (patch)
tree42a0195fe2dd40a97126b5e0fd4c4d55b737ed10 /include/sfx2
parentaf908d9f18fbb83a5c393f856026cebefd821f18 (diff)
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 <michael.meeks@collabora.com>
Diffstat (limited to 'include/sfx2')
-rw-r--r--include/sfx2/lokcallback.hxx41
-rw-r--r--include/sfx2/viewsh.hxx10
2 files changed, 48 insertions, 3 deletions
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 <sal/types.h>
+
+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().