1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* -*- 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/.
*/
#include <test/lokcallback.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <rtl/strbuf.hxx>
#include <tools/gen.hxx>
#include <comphelper/lok.hxx>
#include <sfx2/viewsh.hxx>
TestLokCallbackWrapper::TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data)
: Idle("TestLokCallbackWrapper flush timer")
, m_callback(callback)
, m_data(data)
{
// Flushing timer needs to run with the lowest priority, so that all pending tasks
// such as invalidations are processed before it.
SetPriority(TaskPriority::LOWEST);
}
inline void TestLokCallbackWrapper::callCallback(int nType, const char* pPayload)
{
m_callback(nType, pPayload, m_data);
if (!IsActive())
Start();
}
void TestLokCallbackWrapper::libreOfficeKitViewCallback(int nType, const char* pPayload)
{
callCallback(nType, pPayload);
}
void TestLokCallbackWrapper::libreOfficeKitViewCallbackWithViewId(int nType, const char* pPayload,
int /*nViewId*/)
{
callCallback(nType, pPayload); // the view id is also included in payload
}
void TestLokCallbackWrapper::libreOfficeKitViewInvalidateTilesCallback(
const tools::Rectangle* pRect, int nPart)
{
OStringBuffer buf(64);
if (pRect)
buf.append(pRect->toString());
else
buf.append("EMPTY");
if (comphelper::LibreOfficeKit::isPartInInvalidation())
{
buf.append(", ");
buf.append(static_cast<sal_Int32>(nPart));
}
callCallback(LOK_CALLBACK_INVALIDATE_TILES, buf.makeStringAndClear().getStr());
}
void TestLokCallbackWrapper::Invoke()
{
// Timer timeout, flush any possibly pending data.
for (SfxViewShell* viewShell = SfxViewShell::GetFirst(false); viewShell != nullptr;
viewShell = SfxViewShell::GetNext(*viewShell, false))
{
viewShell->flushPendingLOKInvalidateTiles();
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|