diff options
author | tsepez <tsepez@chromium.org> | 2016-09-21 19:10:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-21 19:10:19 -0700 |
commit | bb577af2f17467a55c04fbff21a8f0ec1016601a (patch) | |
tree | 5a5321b1aff1bcc6ee6dc19928aa729a4ddc9a3d /fpdfsdk/fpdfppo.cpp | |
parent | 7149abce42b211ad3c0eaa39a340825acd41a1ec (diff) | |
download | pdfium-bb577af2f17467a55c04fbff21a8f0ec1016601a.tar.xz |
Remove some objnum locals with AddIndirectObject
Also, it's idempotent, so simplify some logic in callers to
not care if objnum is zero.
The alternate forms are rarely used, using the objnum form
makes it clear that SetReferenceFor() can't possibly register
the object as a side-effect.
Review-Url: https://codereview.chromium.org/2361713002
Diffstat (limited to 'fpdfsdk/fpdfppo.cpp')
-rw-r--r-- | fpdfsdk/fpdfppo.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp index 8ed8384c24..d901a61143 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; |