aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-03-01 22:43:35 +0100
committerJay Berkenbilt <ejb@ql.org>2021-03-03 23:05:49 +0100
commite17585c2d2df9fea296364c0768c2ce5adbc4b91 (patch)
tree356a5b3c7096175ed1ed08d1535a1e4d50f0484d /libqpdf/qpdf
parenta15ec6967dd3312223a6ab7d4198655234e1a4bf (diff)
downloadqpdf-e17585c2d2df9fea296364c0768c2ce5adbc4b91.tar.zst
Remove unreferenced: ignore names that are not Fonts or XObjects
Converted ResourceFinder to ParserCallbacks so we can better detect the name that precedes various operators and use the operators to sort the names into resource types. This enables us to be smarter about detecting unreferenced resources in pages and also sets the stage for reconciling differences in /DR across documents.
Diffstat (limited to 'libqpdf/qpdf')
-rw-r--r--libqpdf/qpdf/ResourceFinder.hh13
1 files changed, 10 insertions, 3 deletions
diff --git a/libqpdf/qpdf/ResourceFinder.hh b/libqpdf/qpdf/ResourceFinder.hh
index 0ac74eab..ac3d5b4c 100644
--- a/libqpdf/qpdf/ResourceFinder.hh
+++ b/libqpdf/qpdf/ResourceFinder.hh
@@ -3,19 +3,26 @@
#include <qpdf/QPDFObjectHandle.hh>
-class ResourceFinder: public QPDFObjectHandle::TokenFilter
+class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
{
public:
ResourceFinder();
virtual ~ResourceFinder() = default;
- virtual void handleToken(QPDFTokenizer::Token const&) override;
+ virtual void handleObject(QPDFObjectHandle, size_t, size_t) override;
+ virtual void handleWarning() override;
std::set<std::string> const& getNames() const;
+ std::map<std::string,
+ std::map<std::string,
+ std::set<size_t>>> const& getNamesByResourceType() const;
bool sawBad() const;
private:
std::string last_name;
+ size_t last_name_offset;
std::set<std::string> names;
- std::map<std::string, std::set<std::string>> names_by_resource_type;
+ std::map<std::string,
+ std::map<std::string,
+ std::set<size_t>>> names_by_resource_type;
bool saw_bad;
};