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/cpdfsdk_baannot.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/cpdfsdk_baannot.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_baannot.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 2c63780772..836298f50d 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -322,8 +322,8 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, if (!pStream) { pStream = new CPDF_Stream; CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); - int32_t objnum = pDoc->AddIndirectObject(pStream); - pParentDict->SetReferenceFor(sAPType, pDoc, objnum); + pParentDict->SetReferenceFor(sAPType, pDoc, + pDoc->AddIndirectObject(pStream)); } CPDF_Dictionary* pStreamDict = pStream->GetDict(); @@ -354,14 +354,11 @@ CPDF_Action CPDFSDK_BAAnnot::GetAction() const { } void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { - ASSERT(action.GetDict()); - if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictFor("A")) { + CPDF_Dictionary* pDict = action.GetDict(); + if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) { CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); - CPDF_Dictionary* pDict = action.GetDict(); - if (pDict && pDict->GetObjNum() == 0) { - pDoc->AddIndirectObject(pDict); - } - m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc, pDict->GetObjNum()); + m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc, + pDoc->AddIndirectObject(pDict)); } } |