/src/qpdf/libqpdf/ResourceFinder.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include <qpdf/ResourceFinder.hh> |
2 | | |
3 | | void |
4 | | ResourceFinder::handleObject(QPDFObjectHandle obj, size_t offset, size_t) |
5 | 0 | { |
6 | 0 | if (obj.isOperator() && (!this->last_name.empty())) { |
7 | 0 | static std::map<std::string, std::string> op_to_rtype = { |
8 | 0 | {"CS", "/ColorSpace"}, |
9 | 0 | {"cs", "/ColorSpace"}, |
10 | 0 | {"gs", "/ExtGState"}, |
11 | 0 | {"Tf", "/Font"}, |
12 | 0 | {"SCN", "/Pattern"}, |
13 | 0 | {"scn", "/Pattern"}, |
14 | 0 | {"BDC", "/Properties"}, |
15 | 0 | {"DP", "/Properties"}, |
16 | 0 | {"sh", "/Shading"}, |
17 | 0 | {"Do", "/XObject"}, |
18 | 0 | }; |
19 | 0 | std::string op = obj.getOperatorValue(); |
20 | 0 | std::string resource_type; |
21 | 0 | auto iter = op_to_rtype.find(op); |
22 | 0 | if (iter != op_to_rtype.end()) { |
23 | 0 | resource_type = iter->second; |
24 | 0 | } |
25 | 0 | if (!resource_type.empty()) { |
26 | 0 | this->names.insert(this->last_name); |
27 | 0 | this->names_by_resource_type[resource_type][this->last_name].insert( |
28 | 0 | this->last_name_offset); |
29 | 0 | } |
30 | 0 | } else if (obj.isName()) { |
31 | 0 | this->last_name = obj.getName(); |
32 | 0 | this->last_name_offset = offset; |
33 | 0 | } |
34 | 0 | } |
35 | | |
36 | | void |
37 | | ResourceFinder::handleEOF() |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | std::set<std::string> const& |
42 | | ResourceFinder::getNames() const |
43 | 0 | { |
44 | 0 | return this->names; |
45 | 0 | } |
46 | | |
47 | | std::map<std::string, std::map<std::string, std::set<size_t>>> const& |
48 | | ResourceFinder::getNamesByResourceType() const |
49 | 0 | { |
50 | 0 | return this->names_by_resource_type; |
51 | 0 | } |