Remove Object::dictIs
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc index a634909..cf857b4 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc
@@ -850,27 +850,28 @@ error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); return 0; } - Object pagesDict = catDict.dictLookup("Pages"); + Object pagesObj = catDict.dictLookup("Pages"); // This should really be isDict("Pages"), but I've seen at least one // PDF file where the /Type entry is missing. - if (!pagesDict.isDict()) { - error(errSyntaxError, -1, "Top-level pages object is wrong type ({0:s})", pagesDict.getTypeName()); + if (!pagesObj.isDict()) { + error(errSyntaxError, -1, "Top-level pages object is wrong type ({0:s})", pagesObj.getTypeName()); return 0; } - Object obj = pagesDict.dictLookup("Count"); + Dict *pagesDict = pagesObj.getDict(); + Object obj = pagesDict->lookup("Count"); // some PDF files actually use real numbers here ("/Count 9.0") if (!obj.isNum()) { - if (pagesDict.dictIs("Page")) { + if (pagesDict->is("Page")) { const Object &pageRootRef = catDict.dictLookupNF("Pages"); error(errSyntaxError, -1, "Pages top-level is a single Page. The document is malformed, trying to recover..."); - Dict *pageDict = pagesDict.getDict(); + Dict *pageDict = pagesDict; if (pageRootRef.isRef()) { const Ref pageRef = pageRootRef.getRef(); - auto p = std::make_unique<Page>(doc, 1, std::move(pagesDict), pageRef, std::make_unique<PageAttrs>(nullptr, pageDict)); + auto p = std::make_unique<Page>(doc, 1, std::move(pagesObj), pageRef, std::make_unique<PageAttrs>(nullptr, pageDict)); if (p->isOk()) { pages.emplace_back(std::move(p), pageRef); refPageMap.emplace(pageRef, pages.size());
diff --git a/poppler/Dict.h b/poppler/Dict.h index 569107e..504c2a6 100644 --- a/poppler/Dict.h +++ b/poppler/Dict.h
@@ -150,15 +150,9 @@ std::get<std::shared_ptr<Dict>>(data)->remove(key); } -inline bool Object::dictIs(std::string_view dictType) const -{ - OBJECT_TYPE_CHECK(objDict); - return std::get<std::shared_ptr<Dict>>(data)->is(dictType); -} - inline bool Object::isDict(std::string_view dictType) const { - return type == objDict && dictIs(dictType); + return type == objDict && std::get<std::shared_ptr<Dict>>(data)->is(dictType); } inline Object Object::dictLookup(std::string_view key, int recursion) const
diff --git a/poppler/Form.cc b/poppler/Form.cc index ed34552..805a137 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc
@@ -2712,7 +2712,7 @@ const char *key = fontDict->getKey(i); if (std::string_view(key).starts_with(kOurDictFontNamePrefix)) { const Object fontObj = fontDict->getVal(i); - if (fontObj.isDict() && fontObj.dictIs("Font")) { + if (fontObj.isDict("Font")) { const Object fontBaseFontObj = fontObj.dictLookup("BaseFont"); if (fontBaseFontObj.isName(fontFamilyAndStyle)) { return key;
diff --git a/poppler/Object.h b/poppler/Object.h index d0d6f36..b575aa8 100644 --- a/poppler/Object.h +++ b/poppler/Object.h
@@ -504,7 +504,6 @@ void dictAdd(std::string_view key, Object &&val); void dictSet(std::string_view key, Object &&val); void dictRemove(std::string_view key); - bool dictIs(std::string_view dictType) const; Object dictLookup(std::string_view key, int recursion = 0) const; const Object &dictLookupNF(std::string_view key) const; Object dictGetVal(int i) const;