This repository was archived by the owner on Feb 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsoffice.d.ts
339 lines (296 loc) · 9.09 KB
/
soffice.d.ts
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/// <reference types="emscripten" />
export type SetClipbaordItem = {
mimeType: string;
buffer: string | ArrayBuffer;
};
export type GetClipbaordItem =
| {
mimeType: 'text/plain' | 'text/html';
text: string;
}
| {
mimeType: string;
data: Uint8Array;
};
export type DocumentRef = number & {};
export type TileRenderData = {
readonly viewId: number;
readonly tileSize: number;
/** `_Atomic int32_t` */
state: Int32Array;
/** `uint8_t[MAX_PAINTED_TILES_PER_ITER * TILE_DIM_SIZE]` */
paintedTiles: Uint8Array;
/** `_Atomic uint32_t` */
tileStartIndex: Uint32Array;
/** `_Atomic uint32_t` */
tileEndIndex: Uint32Array;
/** `_Atomic int32_t` */
pendingFullPaint: Int32Array;
/** `_Atomic int32_t` */
isVisibleAreaPainted: Int32Array;
/** `_Atomic int32_t` */
hasInvalidations: Int32Array;
/** `_Atomic uint32_t[MAX_INVALIDATION_STACK][4]` */
invalidationStack: Uint32Array;
/** `_Atomic int32_t` */
invalidationStackHead: Int32Array;
/** `_Atomic uint32_t` */
scrollHeightTwips: Uint32Array;
/** `_Atomic uint32_t` */
widthTileStride: Uint32Array;
/** `_Atomic uint32_t` */
docWidthTwips: Uint32Array;
/** `_Atomic uint32_t` */
docHeightTwips: Uint32Array;
/** `_Atomic uint32_t` */
tileDimTwips: Uint32Array;
};
export type RectArray = [x: number, y: number, width: number, height: number];
export type OutlineItem = {
id: number;
parent: number;
text: string;
};
export declare const enum LayoutStatus {
INVISIBLE,
VISIBLE,
INSERTED,
DELETED,
NONE,
HIDDEN,
}
export type Comment = {
id: number;
parentId: number;
author: string;
text: string;
resolved: boolean;
dateTime: string;
};
export type RootComment = Comment & {
parentId: 0;
anchorPos: RectArray;
textRange: RectArray[];
bottomTwips: number;
layoutStatus: LayoutStatus;
};
export type SanitizeOptions = Partial<{
documentMetadata: boolean;
trackChangesAccept: boolean;
trackChangesReject: boolean;
comments: boolean;
}>;
export type HeaderFooterRect = {
type: 'header' | 'footer';
rect: RectArray;
};
export type ParagraphStyle<T extends readonly string[], K = T[number]> = {
name: string;
} & {
[PK in K]: any;
};
export type ParagraphStyleList<T extends readonly string[]> = {
userDefined: ParagraphStyle<T>[];
used: ParagraphStyle<T>[];
other: ParagraphStyle<T>[];
};
export type FindAllOptions = Partial<{
/** the case of letters is important for the match */
caseSensitive: boolean;
/** only complete words are matched */
wholeWords: boolean;
/** the mode used to make matches.
*
* undefined: a normal text search.
* wildcard: `*` for any sequence of characters (including empty), `?` for exactly one character. `\` escapes these characters.
* regex: a regular expression-based search.
* similar: an approximate match/fuzzy search.
**/
mode: 'wildcard' | 'regex' | 'similar';
}>;
export type TextRangeDescription = [
before: string,
term: string,
after: string,
];
export type ITextRanges = {
length(): number;
rect(index: number): RectArray[];
rects(
startYPosTwips: number,
endYPosTwips: number
): Array<{
i: number;
rect: RectArray[];
}>;
isCursorAt(index: number): boolean;
indexAtCursor(): number;
moveCursorTo(index: number, end: boolean, select: boolean): void;
description(index: number): TextRangeDescription | undefined;
descriptions(
startIndex: number,
endIndex: number
): Array<{
i: number;
desc: TextRangeDescription;
}>;
replace(index: number, text: string): void;
replaceAll(text: string): void;
};
export declare class ExpandedDocPart {
constructor(path: string, content: string): void;
}
export declare class ExpandedDocument {
constructor(): void;
addPart(path: string, name: ArrayBuffer): void;
delete(): void;
}
export type ExpandedPart = { path: string; content: ArrayBuffer };
/** Embind document class, see main_wasm.cxx */
export declare class Document {
constructor(path: string): void;
constructor(expanded: ExpandedDocument, name: string, readOnly: boolean): void;
delete(): void;
valid(): boolean;
saveAs(path: string, format?: string, filterOptions?: string): boolean;
save(): Array<{ path: string; sha: string }>;
getParts(): number;
pageRects(): RectArray[];
paintTile(
tileWidthPx: number,
tileHeightPx: number,
xTwips: number,
yTwips: number
): Uint8Array;
getDocumentSize(): [widthTwips: number, heightTwips: number];
initializeForRendering(args: string): void;
getViewId(): number;
newView(): number;
ref(): DocumentRef;
postKeyEvent(
viewId: number,
type: number,
charCode: number,
keyCode: number
): void;
postTextInputEvent(viewId: number, windowId: number, text: string): void;
postMouseEvent(
viewId: number,
type: number,
x: number,
y: number,
count: number,
buttons: number,
modifiers: number
): void;
setTextSelection(viewId: number, type: number, x: number, y: Number): void;
setClipboard(viewId: number, items: SetClipbaordItem[]): boolean;
getClipboard(viewId: number, mimeTypes: string[]): GetClipbaordItem[];
paste(viewId: number, mimeType: string, data: string | ArrayBuffer): void;
setGraphicSelection(viewId: number, type: number, x: number, y: number): void;
resetSelection(viewId: number): void;
getCommandValues(viewId: number, command: string): string;
subscribe(viewId: number, type: number): void;
unsubscribe(viewId: number, type: number): void;
startTileRenderer(viewId: number, tileSize: number): TileRenderData;
paintTiles(viewId: number, startIndex: number, endIndex: number);
stopTileRenderer(viewId: number): void;
setClientVisibleArea(
viewId: number,
x: number,
y: number,
width: number,
heght: number
): void;
setCurrentView(viewId: number): void;
dispatchCommand(
viewId: number,
command: string,
args?: string,
notifyWhenFinished?: boolean
): void;
removeText(
viewId: number,
windowId: number,
charsBefore: number,
charsAfter: number
): void;
// NOTE: Disabled until unoembind startup cost is under 1s
// getXComponent(viewId: number): any;
comments(ids: number[]): Comment[];
addComment(text: string): void;
replyComment(parentId: number, text: string): void;
updateComment(id: number, text: string): void;
deleteCommentThreads(parentIds: number[]): void;
deleteComment(commentId: number): void;
resolveCommentThread(parentId: number): void;
resolveComment(commentId: number): void;
sanitize(options: SanitizeOptions): void;
headerFooterRect(): HeaderFooterRect | undefined;
getPropertyValue(property: string): any;
setPropertyValue(property: string, value: any): void;
saveCurrentSelection(): void;
restoreCurrentSelection(): void;
getSelectionText(): string | undefined;
getParagraphStyle(
name: string,
properties: string[]
): undefined | Record<string, any>;
paragraphStyles<T extends readonly string[]>(
properties: T
): ParagraphStyleList<T>;
findAll(text: string, options: FindAllOptions | undefined): ITextRanges;
getOutline(): OutlineItem[];
gotoOutline(index: number): RectArray;
setAuthor(author: string): void;
getExpandedPart(path: string): ExpandedPart | null;
listExpandedParts(): Array<ExpandedPart>;
addExternalUndo(): number;
getNextUndoId(): number;
getNextRedoId(): number;
getUndoCount(): number;
getRedoCount(): number;
undo(count: number): void;
redo(count: number): void;
getRedlineTextRange(id: number): RectArray[] | undefined;
getCursor(viewId: number): string | undefined;
getCustomStringProperty(property: string): string | any;
setCustomStringProperty(property: string, value: any): void;
}
// NOTE: Disabled until unoembind startup cost is under 1s
// declare global {
// interface WorkerGlobalScope {
// /** registers new methods for Document */
// registerExtension(handlers: {
// [name: string]: (doc: Document, viewId: number, ...args: any[]) => Promise<any>;
// }): void;
// }
// }
export interface Module extends EmscriptenModule {
/** indicate whether to load fccache with the module */
withFcCache?: boolean;
/** mounts the blob at a file path with `name` and returns the file path */
mountBlob(name: string, blob: Blob): string;
/** unmounts the current blob */
unmountBlob(): void;
/** reads and unlinks a temporary file at path */
readUnlink(path: string): Uint8Array;
Document: typeof Document;
ExpandedPart: typeof ExpandedPart;
ExpandedDocument: typeof ExpandedDocument;
/** preloads LOK */
preload(): void;
/** makes it so that all accelerator configuration files are handled as if they are on macOS */
setIsMacOSForConfig(): void;
/** creates the font config cache so that it can be exported to optimize load times */
createFontConfigCache(): void;
getDirectoryFiles(dir: string): Array<{ name: string; buffer: ArrayBuffer }>;
/** handlers for subscribed document events */
callbackHandlers: {
callback(ref: DocumentRef, type: number, payload: string): void;
};
yield(): void;
loopPoll(timeoutUs): void;
}
declare const LOK: EmscriptenModuleFactory<Module>;
export default LOK;