Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / comphelper / lok.hxx
blobf998c12dedc37c2c6c1b4c907530b9e9e76587c1
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 #ifndef INCLUDED_COMPHELPER_LOK_HXX
11 #define INCLUDED_COMPHELPER_LOK_HXX
13 #include <comphelper/comphelperdllapi.h>
14 #include <rtl/ustring.hxx>
16 class LanguageTag;
18 // Interface between the LibreOfficeKit implementation called by LibreOfficeKit clients and other
19 // LibreOffice code.
21 namespace comphelper::LibreOfficeKit
23 /// interface for allowing threads to be transiently shutdown.
24 class COMPHELPER_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") ThreadJoinable
26 public:
27 /// shutdown and join threads, @returns true on success
28 virtual bool joinThreads() = 0;
29 /// restart any required threads, usually are demand-restarted
30 virtual void startThreads() {}
33 // Functions to be called only from the LibreOfficeKit implementation in desktop, not from other
34 // places in LibreOffice code.
36 COMPHELPER_DLLPUBLIC void setActive(bool bActive = true);
38 COMPHELPER_DLLPUBLIC void setForkedChild(bool bIsChild = true);
40 enum class statusIndicatorCallbackType
42 Start,
43 SetValue,
44 Finish
47 COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(
48 void (*callback)(void* data, statusIndicatorCallbackType type, int percent, const char* pText),
49 void* data);
51 // Functions that can be called from arbitrary places in LibreOffice.
53 // Check whether the code is running as invoked through LibreOfficeKit.
54 COMPHELPER_DLLPUBLIC bool isActive();
56 /// Is this a transient forked child process, that shares many
57 /// eg. file-system resources with its parent process?
58 COMPHELPER_DLLPUBLIC bool isForkedChild();
60 /// Shift the coordinates before rendering each bitmap.
61 /// Used by Calc to render each tile separately.
62 /// This should be unnecessary (and removed) once Calc
63 /// moves to using 100MM Unit.
64 COMPHELPER_DLLPUBLIC void setLocalRendering(bool bLocalRendering = true);
65 COMPHELPER_DLLPUBLIC bool isLocalRendering();
67 /// Check whether clients want a part number in an invalidation payload.
68 COMPHELPER_DLLPUBLIC bool isPartInInvalidation();
69 /// Set whether clients want a part number in an invalidation payload.
70 COMPHELPER_DLLPUBLIC void setPartInInvalidation(bool bPartInInvalidation);
72 /// Check if we are doing tiled painting.
73 COMPHELPER_DLLPUBLIC bool isTiledPainting();
74 /// Set if we are doing tiled painting.
75 COMPHELPER_DLLPUBLIC void setTiledPainting(bool bTiledPainting);
76 /// Check if we are painting the dialog.
77 COMPHELPER_DLLPUBLIC bool isDialogPainting();
78 /// Set if we are painting the dialog.
79 COMPHELPER_DLLPUBLIC void setDialogPainting(bool bDialogPainting);
80 /// Set the DPI scale for rendering for HiDPI displays.
81 COMPHELPER_DLLPUBLIC void setDPIScale(double fDPIScale);
82 /// Get the DPI scale for rendering for HiDPI displays.
83 COMPHELPER_DLLPUBLIC double getDPIScale();
84 /// Set if we want no annotations rendering
85 COMPHELPER_DLLPUBLIC void setTiledAnnotations(bool bTiledAnnotations);
86 /// Check if annotations rendering is turned off
87 COMPHELPER_DLLPUBLIC bool isTiledAnnotations();
88 /// Set if we want range based header data
89 COMPHELPER_DLLPUBLIC void setRangeHeaders(bool bTiledAnnotations);
90 /// Check if range based header data is enabled
91 COMPHELPER_DLLPUBLIC bool isRangeHeaders();
93 enum Compat : sal_uInt32
95 none = 0,
96 scNoGridBackground = 1,
97 scPrintTwipsMsgs = 2,
99 /// Set compatibility flags
100 COMPHELPER_DLLPUBLIC void setCompatFlag(Compat flag);
101 /// Get compatibility flags
102 COMPHELPER_DLLPUBLIC bool isCompatFlagSet(Compat flag);
103 /// Reset compatibility flags
104 COMPHELPER_DLLPUBLIC void resetCompatFlag();
106 /// Check whether clients want viewId in visible cursor invalidation payload.
107 COMPHELPER_DLLPUBLIC bool isViewIdForVisCursorInvalidation();
108 /// Set whether clients want viewId in visible cursor invalidation payload.
109 COMPHELPER_DLLPUBLIC void setViewIdForVisCursorInvalidation(bool bViewIdForVisCursorInvalidation);
111 /// Update the current LOK's locale.
112 COMPHELPER_DLLPUBLIC void setLocale(const LanguageTag& languageTag);
113 /// Get the current LOK's locale.
114 COMPHELPER_DLLPUBLIC const LanguageTag& getLocale();
116 /// Update the current LOK's language.
117 COMPHELPER_DLLPUBLIC void setLanguageTag(const LanguageTag& languageTag);
118 /// Get the current LOK's language.
119 COMPHELPER_DLLPUBLIC const LanguageTag& getLanguageTag();
120 /// If the language name should be used for this LOK instance.
121 COMPHELPER_DLLPUBLIC bool isAllowlistedLanguage(const OUString& lang);
123 /// Update the current LOK's timezone.
124 COMPHELPER_DLLPUBLIC void setTimezone(bool isSet, const OUString& rTimezone);
126 // Status indicator handling. Even if in theory there could be several status indicators active at
127 // the same time, in practice there is only one at a time, so we don't handle any identification of
128 // status indicator in this API.
129 COMPHELPER_DLLPUBLIC void statusIndicatorStart(const OUString& sText);
130 COMPHELPER_DLLPUBLIC void statusIndicatorSetValue(int percent);
131 COMPHELPER_DLLPUBLIC void statusIndicatorFinish();
133 COMPHELPER_DLLPUBLIC void setBlockedCommandList(const char* blockedCommandList);
136 #endif // INCLUDED_COMPHELPER_LOK_HXX
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */