summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_document.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 7968d1b019..2e4baabe91 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -602,6 +602,19 @@ bool CPDF_Document::InsertNewPage(int iPage, CPDF_Dictionary* pPageDict) {
return true;
}
+RetainPtr<CPDF_Page> CPDF_Document::GetOrCreatePDFPage(
+ CPDF_Dictionary* pPageDict) {
+ std::pair<uint32_t, uint32_t> key = {pPageDict->GetObjNum(),
+ pPageDict->GetGenNum()};
+ if (m_PageMap[key])
+ return RetainPtr<CPDF_Page>(m_PageMap[key].Get());
+
+ auto pPage = pdfium::MakeRetain<CPDF_Page>(this, pPageDict, true);
+ pPage->ParseContent();
+ m_PageMap[key].Reset(pPage.Get());
+ return pPage;
+}
+
void CPDF_Document::DeletePage(int iPage) {
CPDF_Dictionary* pPages = GetPagesDict();
if (!pPages)