Version 24.8.3.2, tag libreoffice-24.8.3.2
[LibreOffice.git] / include / test / lokcallback.hxx
blob7edf74311fcf44040f3825ca77558856e7decd8c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include <sal/config.h>
13 #include <test/testdllapi.hxx>
14 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
15 #include <sfx2/lokcallback.hxx>
16 #include <vcl/idle.hxx>
18 #include <vector>
20 class SfxChildWindow;
22 /**
23 A helper to convert SfxLokCallbackInterface to a LIbreOfficeKitCallback for tests.
25 It reimplements the specialized callbacks and converts them to the generic type/payload
26 callback.
28 class OOO_DLLPUBLIC_TEST TestLokCallbackWrapper final : public SfxLokCallbackInterface, public Idle
30 public:
31 TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data);
32 /// Discard all possibly still held events.
33 void clear();
34 /// Set the view id of the associated SfxViewShell.
35 void setLOKViewId(int viewId) { m_viewId = viewId; }
36 virtual void libreOfficeKitViewCallback(int nType, const rtl::OString& pPayload) override;
37 virtual void libreOfficeKitViewCallbackWithViewId(int nType, const rtl::OString& pPayload,
38 int nViewId) override;
39 virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart,
40 int nMode) override;
41 virtual void libreOfficeKitViewUpdatedCallback(int nType) override;
42 virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId,
43 int nSourceViewId) override;
44 virtual void libreOfficeKitViewAddPendingInvalidateTiles() override;
45 virtual void dumpState(rtl::OStringBuffer&) override{};
47 virtual void Invoke() override;
49 static SfxChildWindow* InitializeSidebar();
51 private:
52 void callCallback(int nType, const char* pPayload, int nViewId);
53 void startTimer();
54 void flushLOKData();
55 void discardUpdatedTypes(int nType, int nViewId);
56 LibreOfficeKitCallback m_callback;
57 void* m_data;
58 int m_viewId = -1; // the associated SfxViewShell
59 std::vector<int> m_updatedTypes; // value is type
60 struct PerViewIdData
62 int type;
63 int viewId;
64 int sourceViewId;
66 std::vector<PerViewIdData> m_updatedTypesPerViewId;
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */