-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdocument.hpp
More file actions
525 lines (440 loc) · 15.7 KB
/
Copy pathdocument.hpp
File metadata and controls
525 lines (440 loc) · 15.7 KB
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
#pragma once
#include <memory>
#include <optional>
namespace odr {
class File;
enum class FileType;
enum class DocumentType;
enum class ElementType;
class DocumentPath;
enum class ValueType;
enum class AnchorType;
struct PageLayout;
struct TableDimensions;
struct TablePosition;
struct TableStyle;
struct TableColumnStyle;
struct TableRowStyle;
struct TableCellStyle;
struct TextStyle;
struct ParagraphStyle;
struct GraphicStyle;
} // namespace odr
namespace odr::internal {
class Path;
} // namespace odr::internal
namespace odr::internal::abstract {
class ReadableFilesystem;
}
namespace odr::internal::abstract {
class ElementAdapter;
class TextRootAdapter;
class SlideAdapter;
class PageAdapter;
class SheetAdapter;
class SheetColumnAdapter;
class SheetRowAdapter;
class SheetCellAdapter;
class MasterPageAdapter;
class LineBreakAdapter;
class ParagraphAdapter;
class SpanAdapter;
class TextAdapter;
class LinkAdapter;
class BookmarkAdapter;
class ListItemAdapter;
class TableAdapter;
class TableColumnAdapter;
class TableRowAdapter;
class TableCellAdapter;
class FrameAdapter;
class RectAdapter;
class LineAdapter;
class CircleAdapter;
class CustomShapeAdapter;
class ImageAdapter;
class Document {
public:
virtual ~Document() = default;
/// \return `true` if the document is editable in any way.
[[nodiscard]] virtual bool is_editable() const noexcept = 0;
/// \param encrypted to ask for encrypted saves.
/// \return `true` if the document is is_savable.
[[nodiscard]] virtual bool is_savable(bool encrypted) const noexcept = 0;
/// \param path the destination path.
virtual void save(const Path &path) const = 0;
/// \param path the destination path.
/// \param password the encryption password.
virtual void save(const Path &path, const char *password) const = 0;
/// \return the type of the document.
[[nodiscard]] virtual FileType file_type() const noexcept = 0;
/// \return the type of the document.
[[nodiscard]] virtual DocumentType document_type() const noexcept = 0;
/// \return the underlying filesystem of the document.
[[nodiscard]] virtual std::shared_ptr<ReadableFilesystem>
as_filesystem() const noexcept = 0;
/// \return cursor to the root element of the document.
[[nodiscard]] virtual ElementIdentifier root_element() const = 0;
/// \return the element adapter for this document.
[[nodiscard]] virtual const ElementAdapter *element_adapter() const = 0;
};
class ElementAdapter {
public:
virtual ~ElementAdapter() = default;
[[nodiscard]] virtual ElementType
element_type(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
element_parent(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
element_first_child(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
element_last_child(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
element_previous_sibling(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
element_next_sibling(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual bool
element_is_unique(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual bool
element_is_self_locatable(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual bool
element_is_editable(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual DocumentPath
element_document_path(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
element_navigate_path(ElementIdentifier element_id,
const DocumentPath &path) const = 0;
[[nodiscard]] virtual const TextRootAdapter *
text_root_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const SlideAdapter *
slide_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const PageAdapter *
page_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const SheetAdapter *
sheet_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const SheetCellAdapter *sheet_cell_adapter(
[[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const MasterPageAdapter *master_page_adapter(
[[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const LineBreakAdapter *line_break_adapter(
[[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const ParagraphAdapter *
paragraph_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const SpanAdapter *
span_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const TextAdapter *
text_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const LinkAdapter *
link_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const BookmarkAdapter *
bookmark_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const ListItemAdapter *
list_item_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const TableAdapter *
table_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const TableColumnAdapter *table_column_adapter(
[[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const TableRowAdapter *
table_row_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const TableCellAdapter *table_cell_adapter(
[[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const FrameAdapter *
frame_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const RectAdapter *
rect_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const LineAdapter *
line_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const CircleAdapter *
circle_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const CustomShapeAdapter *custom_shape_adapter(
[[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
[[nodiscard]] virtual const ImageAdapter *
image_adapter([[maybe_unused]] const ElementIdentifier element_id) const {
return nullptr;
}
};
class TextRootAdapter {
public:
virtual ~TextRootAdapter() = default;
[[nodiscard]] virtual PageLayout
text_root_page_layout(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
text_root_first_master_page(ElementIdentifier element_id) const = 0;
};
class SlideAdapter {
public:
virtual ~SlideAdapter() = default;
[[nodiscard]] virtual PageLayout
slide_page_layout(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
slide_master_page(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
slide_name(ElementIdentifier element_id) const = 0;
};
class PageAdapter {
public:
virtual ~PageAdapter() = default;
[[nodiscard]] virtual PageLayout
page_layout(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
page_master_page(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
page_name(ElementIdentifier element_id) const = 0;
};
class SheetAdapter {
public:
virtual ~SheetAdapter() = default;
[[nodiscard]] virtual std::string
sheet_name(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableDimensions
sheet_dimensions(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableDimensions
sheet_content(ElementIdentifier element_id,
std::optional<TableDimensions> range) const = 0;
[[nodiscard]] virtual ElementIdentifier
sheet_cell(ElementIdentifier element_id, std::uint32_t column,
std::uint32_t row) const = 0;
[[nodiscard]] virtual ElementIdentifier
sheet_first_shape(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableStyle
sheet_style(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableColumnStyle
sheet_column_style(ElementIdentifier element_id,
std::uint32_t column) const = 0;
[[nodiscard]] virtual TableRowStyle
sheet_row_style(ElementIdentifier element_id, std::uint32_t row) const = 0;
[[nodiscard]] virtual TableCellStyle
sheet_cell_style(ElementIdentifier element_id, std::uint32_t column,
std::uint32_t row) const = 0;
};
class SheetCellAdapter {
public:
virtual ~SheetCellAdapter() = default;
[[nodiscard]] virtual TablePosition
sheet_cell_position(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual bool
sheet_cell_is_covered(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableDimensions
sheet_cell_span(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ValueType
sheet_cell_value_type(ElementIdentifier element_id) const = 0;
};
class MasterPageAdapter {
public:
virtual ~MasterPageAdapter() = default;
[[nodiscard]] virtual PageLayout
master_page_page_layout(ElementIdentifier element_id) const = 0;
};
class LineBreakAdapter {
public:
virtual ~LineBreakAdapter() = default;
[[nodiscard]] virtual TextStyle
line_break_style(ElementIdentifier element_id) const = 0;
};
class ParagraphAdapter {
public:
virtual ~ParagraphAdapter() = default;
[[nodiscard]] virtual ParagraphStyle
paragraph_style(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TextStyle
paragraph_text_style(ElementIdentifier element_id) const = 0;
};
class SpanAdapter {
public:
virtual ~SpanAdapter() = default;
[[nodiscard]] virtual TextStyle
span_style(ElementIdentifier element_id) const = 0;
};
class TextAdapter {
public:
virtual ~TextAdapter() = default;
[[nodiscard]] virtual std::string
text_content(ElementIdentifier element_id) const = 0;
virtual void text_set_content(ElementIdentifier element_id,
const std::string &text) const = 0;
[[nodiscard]] virtual TextStyle
text_style(ElementIdentifier element_id) const = 0;
};
class LinkAdapter {
public:
virtual ~LinkAdapter() = default;
[[nodiscard]] virtual std::string
link_href(ElementIdentifier element_id) const = 0;
};
class BookmarkAdapter {
public:
virtual ~BookmarkAdapter() = default;
[[nodiscard]] virtual std::string
bookmark_name(ElementIdentifier element_id) const = 0;
};
class ListItemAdapter {
public:
virtual ~ListItemAdapter() = default;
[[nodiscard]] virtual TextStyle
list_item_style(ElementIdentifier element_id) const = 0;
};
class TableAdapter {
public:
virtual ~TableAdapter() = default;
[[nodiscard]] virtual TableDimensions
table_dimensions(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
table_first_column(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ElementIdentifier
table_first_row(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableStyle
table_style(ElementIdentifier element_id) const = 0;
};
class TableColumnAdapter {
public:
virtual ~TableColumnAdapter() = default;
[[nodiscard]] virtual TableColumnStyle
table_column_style(ElementIdentifier element_id) const = 0;
};
class TableRowAdapter {
public:
virtual ~TableRowAdapter() = default;
[[nodiscard]] virtual TableRowStyle
table_row_style(ElementIdentifier element_id) const = 0;
};
class TableCellAdapter {
public:
virtual ~TableCellAdapter() = default;
[[nodiscard]] virtual bool
table_cell_is_covered(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableDimensions
table_cell_span(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual ValueType
table_cell_value_type(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual TableCellStyle
table_cell_style(ElementIdentifier element_id) const = 0;
};
class FrameAdapter {
public:
virtual ~FrameAdapter() = default;
[[nodiscard]] virtual AnchorType
frame_anchor_type(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::optional<std::string>
frame_x(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::optional<std::string>
frame_y(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::optional<std::string>
frame_width(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::optional<std::string>
frame_height(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::optional<std::string>
frame_z_index(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual GraphicStyle
frame_style(ElementIdentifier element_id) const = 0;
};
class RectAdapter {
public:
virtual ~RectAdapter() = default;
[[nodiscard]] virtual std::string
rect_x(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
rect_y(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
rect_width(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
rect_height(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual GraphicStyle
rect_style(ElementIdentifier element_id) const = 0;
};
class LineAdapter {
public:
virtual ~LineAdapter() = default;
[[nodiscard]] virtual std::string
line_x1(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
line_y1(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
line_x2(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
line_y2(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual GraphicStyle
line_style(ElementIdentifier element_id) const = 0;
};
class CircleAdapter {
public:
virtual ~CircleAdapter() = default;
[[nodiscard]] virtual std::string
circle_x(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
circle_y(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
circle_width(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
circle_height(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual GraphicStyle
circle_style(ElementIdentifier element_id) const = 0;
};
class CustomShapeAdapter {
public:
virtual ~CustomShapeAdapter() = default;
[[nodiscard]] virtual std::optional<std::string>
custom_shape_x(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::optional<std::string>
custom_shape_y(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
custom_shape_width(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
custom_shape_height(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual GraphicStyle
custom_shape_style(ElementIdentifier element_id) const = 0;
};
class ImageAdapter {
public:
virtual ~ImageAdapter() = default;
[[nodiscard]] virtual bool
image_is_internal(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::optional<odr::File>
image_file(ElementIdentifier element_id) const = 0;
[[nodiscard]] virtual std::string
image_href(ElementIdentifier element_id) const = 0;
};
} // namespace odr::internal::abstract