Flutter Engine
The Flutter Engine
SkPDFTag.h
Go to the documentation of this file.
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/core/SkSpan.h"
16#include "src/core/SkTHash.h"
17#include "src/pdf/SkPDFTypes.h"
18
19#include <cstddef>
20#include <vector>
21
22class SkPDFDocument;
23struct SkPDFTagNode;
24struct SkPoint;
25
27public:
31
32 class Mark {
33 SkPDFTagNode *const fNode;
34 size_t const fMarkIndex;
35 public:
36 Mark(SkPDFTagNode* node, size_t index) : fNode(node), fMarkIndex(index) {}
37 Mark() : Mark(nullptr, 0) {}
38 Mark(const Mark&) = delete;
39 Mark& operator=(const Mark&) = delete;
40 Mark(Mark&&) = default;
41 Mark& operator=(Mark&&) = delete;
42
43 explicit operator bool() const { return fNode; }
44 int id();
45 SkPoint& point();
46 };
47 // Used to allow marked content to refer to its corresponding structure
48 // tree node, via a page entry in the parent tree. Returns a false mark if
49 // nodeId is 0.
50 Mark createMarkIdForNodeId(int nodeId, unsigned pageIndex, SkPoint);
51 // Used to allow annotations to refer to their corresponding structure
52 // tree node, via the struct parent tree. Returns -1 if no struct parent
53 // key.
54 int createStructParentKeyForNodeId(int nodeId, unsigned pageIndex);
55
56 void addNodeAnnotation(int nodeId, SkPDFIndirectReference annotationRef, unsigned pageIndex);
57 void addNodeTitle(int nodeId, SkSpan<const char>);
61
62private:
63 // An entry in a map from a node ID to an indirect reference to its
64 // corresponding structure element node.
65 struct IDTreeEntry {
66 int nodeId;
68 };
69
70 void Copy(SkPDF::StructureElementNode& node,
72 SkArenaAlloc* arena,
74 bool wantTitle);
75 SkPDFIndirectReference PrepareTagTreeToEmit(SkPDFIndirectReference parent,
76 SkPDFTagNode* node,
77 SkPDFDocument* doc);
78
79 SkArenaAlloc fArena;
81 SkPDFTagNode* fRoot = nullptr;
84 std::vector<IDTreeEntry> fIdTreeEntries;
85 std::vector<int> fParentTreeAnnotationNodeIds;
86
87 SkPDFTagTree(const SkPDFTagTree&) = delete;
88 SkPDFTagTree& operator=(const SkPDFTagTree&) = delete;
89};
90
91#endif
Mark(const Mark &)=delete
Mark & operator=(const Mark &)=delete
Mark(SkPDFTagNode *node, size_t index)
Definition: SkPDFTag.h:36
SkPoint & point()
Definition: SkPDFTag.cpp:214
Mark & operator=(Mark &&)=delete
Mark(Mark &&)=default
SkPDFIndirectReference makeStructTreeRoot(SkPDFDocument *doc)
Definition: SkPDFTag.cpp:364
int createStructParentKeyForNodeId(int nodeId, unsigned pageIndex)
Definition: SkPDFTag.cpp:238
void init(SkPDF::StructureElementNode *, SkPDF::Metadata::Outline)
Definition: SkPDFTag.cpp:202
SkPDFIndirectReference makeOutline(SkPDFDocument *doc)
Definition: SkPDFTag.cpp:559
void addNodeAnnotation(int nodeId, SkPDFIndirectReference annotationRef, unsigned pageIndex)
Definition: SkPDFTag.cpp:329
SkString getRootLanguage()
Definition: SkPDFTag.cpp:583
Mark createMarkIdForNodeId(int nodeId, unsigned pageIndex, SkPoint)
Definition: SkPDFTag.cpp:218
void addNodeTitle(int nodeId, SkSpan< const char >)
Definition: SkPDFTag.cpp:344
dst
Definition: cp.py:12