1 | /* |
---|---|
2 | * Copyright 2018 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SkPDFTag_DEFINED |
9 | #define SkPDFTag_DEFINED |
10 | |
11 | #include "include/docs/SkPDFDocument.h" |
12 | #include "include/private/SkTArray.h" |
13 | #include "include/private/SkTHash.h" |
14 | #include "src/core/SkArenaAlloc.h" |
15 | |
16 | class SkPDFDocument; |
17 | struct SkPDFIndirectReference; |
18 | struct SkPDFTagNode; |
19 | |
20 | class SkPDFTagTree { |
21 | public: |
22 | SkPDFTagTree(); |
23 | ~SkPDFTagTree(); |
24 | void init(SkPDF::StructureElementNode*); |
25 | void reset(); |
26 | int getMarkIdForNodeId(int nodeId, unsigned pageIndex); |
27 | void addNodeAnnotation(int nodeId, SkPDFIndirectReference annotationRef); |
28 | SkPDFIndirectReference makeStructTreeRoot(SkPDFDocument* doc); |
29 | |
30 | private: |
31 | static void Copy(SkPDF::StructureElementNode& node, |
32 | SkPDFTagNode* dst, |
33 | SkArenaAlloc* arena, |
34 | SkTHashMap<int, SkPDFTagNode*>* nodeMap); |
35 | |
36 | SkArenaAlloc fArena; |
37 | SkTHashMap<int, SkPDFTagNode*> fNodeMap; |
38 | SkPDFTagNode* fRoot = nullptr; |
39 | SkTArray<SkTArray<SkPDFTagNode*>> fMarksPerPage; |
40 | |
41 | SkPDFTagTree(const SkPDFTagTree&) = delete; |
42 | SkPDFTagTree& operator=(const SkPDFTagTree&) = delete; |
43 | }; |
44 | |
45 | #endif |
46 |