Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/app/lok.cxx
Line
Count
Source
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.
4
 *
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
 */
9
10
#include <dbggui.hxx>
11
#include <salinst.hxx>
12
#include <svdata.hxx>
13
14
#include <LibreOfficeKit/LibreOfficeKit.hxx>
15
#include <tools/json_writer.hxx>
16
#include <vcl/lok.hxx>
17
18
namespace vcl::lok
19
{
20
void registerPollCallbacks(LibreOfficeKitPollCallback pPollCallback,
21
                           LibreOfficeKitWakeCallback pWakeCallback, void* pData)
22
0
{
23
0
    ImplSVData* pSVData = ImplGetSVData();
24
0
    if (pSVData)
25
0
    {
26
0
        pSVData->mpPollCallback = pPollCallback;
27
0
        pSVData->mpWakeCallback = pWakeCallback;
28
0
        pSVData->mpPollClosure = pData;
29
0
    }
30
0
}
31
32
void unregisterPollCallbacks()
33
0
{
34
0
    ImplSVData* pSVData = ImplGetSVData();
35
0
    if (!pSVData)
36
0
        return;
37
38
    // Not hyper-elegant - but in the case of Android & unipoll we need to detach
39
    // this thread from the JVM's clutches to avoid a crash closing document
40
0
    if (pSVData->mpPollClosure && pSVData->mpDefInst)
41
0
        pSVData->mpDefInst->releaseMainThread();
42
43
    // Just set mpPollClosure to null as that is what calling this means, that the callback data
44
    // points to an object that no longer exists. In particular, don't set
45
    // pSVData->mpPollCallback to nullptr as that is used to detect whether Unipoll is in use in
46
    // isUnipoll().
47
0
    pSVData->mpPollClosure = nullptr;
48
0
}
49
50
bool isUnipoll()
51
107k
{
52
107k
    ImplSVData* pSVData = ImplGetSVData();
53
107k
    return pSVData && pSVData->mpPollCallback != nullptr;
54
107k
}
55
56
void numberOfViewsChanged(int count)
57
0
{
58
0
    if (count == 0)
59
0
        return;
60
0
    ImplSVData* pSVData = ImplGetSVData();
61
0
    auto& rCache = pSVData->maGDIData.maScaleCache;
62
    // Normally the cache size is set to 10, scale according to the number of users.
63
0
    rCache.setMaxSize(count * 10);
64
0
}
65
66
void dumpState(rtl::OStringBuffer& rState)
67
0
{
68
0
    ImplSVData* pSVData = ImplGetSVData();
69
0
    if (!pSVData)
70
0
        return;
71
72
#ifndef NDEBUG
73
    // lo_dumpState deliberately doesn't take SolarMutexGuard
74
    // so disable these checks during dumpState
75
    DbgGUIDeInitSolarMutexCheck();
76
#endif
77
78
0
    rState.append("\nWindows:\t");
79
0
    rState.append(static_cast<sal_Int32>(Application::GetTopWindowCount()));
80
81
0
    vcl::Window* pWin = Application::GetFirstTopLevelWindow();
82
0
    while (pWin)
83
0
    {
84
0
        tools::JsonWriter aProps;
85
0
        pWin->DumpAsPropertyTree(aProps);
86
87
0
        rState.append("\n\tWindow: ");
88
89
0
        auto notifier = pWin->GetLOKNotifier();
90
0
        if (notifier)
91
0
        {
92
0
            rState.append(notifier->dumpNotifyState());
93
0
            rState.append(" ");
94
0
        }
95
0
        else
96
0
            rState.append("no notifier ");
97
98
0
        OString aPropStr = aProps.finishAndGetAsOString();
99
0
        if (aPropStr.getLength() > 256)
100
0
        {
101
0
            rState.append(aPropStr.subView(0, 256));
102
0
            rState.append("...");
103
0
        }
104
0
        else
105
0
            rState.append(aPropStr);
106
107
0
        pWin = Application::GetNextTopLevelWindow(pWin);
108
0
    }
109
110
0
    pSVData->dumpState(rState);
111
112
#ifndef NDEBUG
113
    DbgGUIInitSolarMutexCheck();
114
#endif
115
0
}
116
117
void trimMemory(int nTarget)
118
0
{
119
0
    if (nTarget >= 1000)
120
0
    {
121
0
        SolarMutexGuard aGuard;
122
0
        ImplSVData* pSVData = ImplGetSVData();
123
0
        if (!pSVData) // shutting down
124
0
            return;
125
0
        pSVData->dropCaches();
126
0
    }
127
    // else for now caches re-fill themselves as/when used.
128
0
}
129
130
} // namespace lok, namespace vcl
131
132
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */