Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/comphelper/lok.hxx
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
#ifndef INCLUDED_COMPHELPER_LOK_HXX
11
#define INCLUDED_COMPHELPER_LOK_HXX
12
13
#include <functional>
14
15
#include <comphelper/comphelperdllapi.h>
16
#include <o3tl/strong_int.hxx>
17
#include <rtl/ustring.hxx>
18
19
typedef o3tl::strong_int<int, struct ViewShellDocIdTag> ViewShellDocId;
20
21
class LanguageTag;
22
namespace com::sun::star::awt
23
{
24
struct Rectangle;
25
}
26
27
// Interface between the LibreOfficeKit implementation called by LibreOfficeKit clients and other
28
// LibreOffice code.
29
30
namespace comphelper::LibreOfficeKit
31
{
32
/// interface for allowing threads to be transiently shutdown.
33
class COMPHELPER_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") ThreadJoinable
34
{
35
public:
36
    /// shutdown and join threads, @returns true on success
37
    virtual bool joinThreads() = 0;
38
    /// restart any required threads, usually are demand-restarted
39
0
    virtual void startThreads() {}
40
};
41
42
// Functions to be called only from the LibreOfficeKit implementation in desktop, not from other
43
// places in LibreOffice code.
44
45
COMPHELPER_DLLPUBLIC void setActive(bool bActive = true);
46
47
COMPHELPER_DLLPUBLIC void setForkedChild(bool bIsChild = true);
48
49
enum class statusIndicatorCallbackType
50
{
51
    Start,
52
    SetValue,
53
    Finish
54
};
55
56
COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(
57
    void (*callback)(void* data, statusIndicatorCallbackType type, int percent, const char* pText),
58
    void* data);
59
60
// Functions that can be called from arbitrary places in LibreOffice.
61
62
// Check whether the code is running as invoked through LibreOfficeKit.
63
COMPHELPER_DLLPUBLIC bool isActive();
64
65
/// Is this a transient forked child process, that shares many
66
/// eg. file-system resources with its parent process?
67
COMPHELPER_DLLPUBLIC bool isForkedChild();
68
69
/// Shift the coordinates before rendering each bitmap.
70
/// Used by Calc to render each tile separately.
71
/// This should be unnecessary (and removed) once Calc
72
/// moves to using 100MM Unit.
73
COMPHELPER_DLLPUBLIC void setLocalRendering(bool bLocalRendering = true);
74
COMPHELPER_DLLPUBLIC bool isLocalRendering();
75
76
/// Used by SlideshowLayerRenderer for signaling that a slide rendering is occurring.
77
COMPHELPER_DLLPUBLIC void setSlideshowRendering(bool bSlideshowRendering);
78
COMPHELPER_DLLPUBLIC bool isSlideshowRendering();
79
80
/// Check whether clients want a part number in an invalidation payload.
81
COMPHELPER_DLLPUBLIC bool isPartInInvalidation();
82
/// Set whether clients want a part number in an invalidation payload.
83
COMPHELPER_DLLPUBLIC void setPartInInvalidation(bool bPartInInvalidation);
84
85
/// Check if we are doing tiled painting.
86
COMPHELPER_DLLPUBLIC bool isTiledPainting();
87
/// Set if we are doing tiled painting.
88
COMPHELPER_DLLPUBLIC void setTiledPainting(bool bTiledPainting);
89
/// Set if we are doing idle layout.
90
COMPHELPER_DLLPUBLIC void setIdleLayouting(bool bIdleLayouting);
91
/// Check if we are painting the dialog.
92
COMPHELPER_DLLPUBLIC bool isDialogPainting();
93
/// Set if we are painting the dialog.
94
COMPHELPER_DLLPUBLIC void setDialogPainting(bool bDialogPainting);
95
/// Set the DPI scale for rendering for HiDPI displays.
96
COMPHELPER_DLLPUBLIC void setDPIScale(double fDPIScale);
97
/// Get the DPI scale for rendering for HiDPI displays.
98
COMPHELPER_DLLPUBLIC double getDPIScale();
99
/// Set if we want no annotations rendering
100
COMPHELPER_DLLPUBLIC void setTiledAnnotations(bool bTiledAnnotations);
101
/// Check if annotations rendering is turned off
102
COMPHELPER_DLLPUBLIC bool isTiledAnnotations();
103
/// Set if we want range based header data
104
COMPHELPER_DLLPUBLIC void setRangeHeaders(bool bTiledAnnotations);
105
/// Check if range based header data is enabled
106
COMPHELPER_DLLPUBLIC bool isRangeHeaders();
107
108
enum Compat : sal_uInt32
109
{
110
    none = 0,
111
    scNoGridBackground = 1,
112
    scPrintTwipsMsgs = 2,
113
};
114
/// Set compatibility flags
115
COMPHELPER_DLLPUBLIC void setCompatFlag(Compat flag);
116
/// Get compatibility flags
117
COMPHELPER_DLLPUBLIC bool isCompatFlagSet(Compat flag);
118
/// Reset compatibility flags
119
COMPHELPER_DLLPUBLIC void resetCompatFlag();
120
121
/// Check whether clients want viewId in visible cursor invalidation payload.
122
COMPHELPER_DLLPUBLIC bool isViewIdForVisCursorInvalidation();
123
/// Set whether clients want viewId in visible cursor invalidation payload.
124
COMPHELPER_DLLPUBLIC void setViewIdForVisCursorInvalidation(bool bViewIdForVisCursorInvalidation);
125
126
/// Update the current LOK's locale.
127
COMPHELPER_DLLPUBLIC void setLocale(const LanguageTag& languageTag);
128
/// Get the current LOK's locale.
129
COMPHELPER_DLLPUBLIC const LanguageTag& getLocale();
130
131
/// Update the current LOK's language.
132
COMPHELPER_DLLPUBLIC void setLanguageTag(const LanguageTag& languageTag);
133
/// Get the current LOK's language.
134
COMPHELPER_DLLPUBLIC const LanguageTag& getLanguageTag();
135
/// If the language name should be used for this LOK instance.
136
COMPHELPER_DLLPUBLIC bool isAllowlistedLanguage(const OUString& lang);
137
138
/// Update the current LOK's timezone.
139
COMPHELPER_DLLPUBLIC void setTimezone(bool isSet, const OUString& rTimezone);
140
141
// Status indicator handling. Even if in theory there could be several status indicators active at
142
// the same time, in practice there is only one at a time, so we don't handle any identification of
143
// status indicator in this API.
144
COMPHELPER_DLLPUBLIC void statusIndicatorStart(const OUString& sText);
145
COMPHELPER_DLLPUBLIC void statusIndicatorSetValue(int percent);
146
COMPHELPER_DLLPUBLIC void statusIndicatorFinish();
147
148
COMPHELPER_DLLPUBLIC void setBlockedCommandList(const char* blockedCommandList);
149
150
COMPHELPER_DLLPUBLIC void
151
setAnyInputCallback(const std::function<bool(void*, int)>& pAnyInputCallback, void* pData,
152
                    const std::function<int()>& pMostUrgentPriorityGetter);
153
COMPHELPER_DLLPUBLIC bool anyInput();
154
155
COMPHELPER_DLLPUBLIC void setFileSaveDialogCallback(
156
    const std::function<void(const char*, char*, size_t)>& pFileSaveDialogCallback);
157
COMPHELPER_DLLPUBLIC bool fileSaveDialog(const OUString& rSuggested, OUString& rResult);
158
159
// These allow setting callbacks, so that set/get of a LOK view is possible even in code that is
160
// below sfx2.
161
COMPHELPER_DLLPUBLIC void setViewSetter(const std::function<void(int)>& pViewSetter);
162
COMPHELPER_DLLPUBLIC void setView(int nView);
163
COMPHELPER_DLLPUBLIC void setViewGetter(const std::function<int()>& pViewGetter);
164
COMPHELPER_DLLPUBLIC int getView();
165
166
/// Set the current DocId, which is used by Mobile LOKit to
167
/// load multiple documents and yet identify the views of each.
168
/// There are events that are fired while creating a new view,
169
/// and if we don't have a DocId, we can't know which other views
170
/// within the same document (if any) should get those events.
171
/// By setting this static value, we are able to set the DocId
172
/// of each SfxViewShell at construction time.
173
COMPHELPER_DLLPUBLIC void setDocId(ViewShellDocId nDocId);
174
COMPHELPER_DLLPUBLIC ViewShellDocId getDocId();
175
176
COMPHELPER_DLLPUBLIC void
177
setInitialClientVisibleArea(const css::awt::Rectangle& rClientVisibleArea);
178
COMPHELPER_DLLPUBLIC const css::awt::Rectangle& getInitialClientVisibleArea();
179
}
180
181
#endif // INCLUDED_COMPHELPER_LOK_HXX
182
183
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */