Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Unified Diff: fpdfsdk/fpdfppo.cpp

Issue 2361713002: Remove some objnum locals with AddIndirectObject (Closed)
Patch Set: Same treatment for arrays Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/fpdfdoc_unittest.cpp ('k') | fpdfsdk/fpdfsave.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdfppo.cpp
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 8ed8384c24b88b78a9f622e9759e257326f530e3..d901a6114304cfceb1e0c79aeb0b5de5efb86388 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -71,8 +71,8 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
if (!pNewPages) {
pNewPages = new CPDF_Dictionary;
- uint32_t NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages);
- pNewRoot->SetFor("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON));
+ pNewRoot->SetReferenceFor("Pages", pDestPDFDoc,
+ pDestPDFDoc->AddIndirectObject(pNewPages));
}
CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", "");
@@ -80,13 +80,10 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
pNewPages->SetFor("Type", new CPDF_Name("Pages"));
}
- CPDF_Array* pKeysArray = pNewPages->GetArrayFor("Kids");
- if (!pKeysArray) {
- CPDF_Array* pNewKids = new CPDF_Array;
- uint32_t Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids);
-
- pNewPages->SetFor("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum));
- pNewPages->SetFor("Count", new CPDF_Number(0));
+ if (!pNewPages->GetArrayFor("Kids")) {
+ pNewPages->SetIntegerFor("Count", 0);
+ pNewPages->SetReferenceFor("Kids", pDestPDFDoc,
+ pDestPDFDoc->AddIndirectObject(new CPDF_Array));
}
return TRUE;
« no previous file with comments | « fpdfsdk/fpdfdoc_unittest.cpp ('k') | fpdfsdk/fpdfsave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698