summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_baannot.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-15 11:33:44 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-15 11:33:44 -0800
commit70c4afd5c3c5c44cd24f814423a23a6ef05bba02 (patch)
treecbe593d0b6c0bfc6fd5038bf60a77a94e49c69c9 /fpdfsdk/cpdfsdk_baannot.cpp
parentf16f6b8b52277348f5d571b7641bb0bbd5239589 (diff)
downloadpdfium-70c4afd5c3c5c44cd24f814423a23a6ef05bba02.tar.xz
Make AddIndirectObject() take a unique_ptr.
Add convenience routines to create and add object in one step. Review-Url: https://codereview.chromium.org/2489283003
Diffstat (limited to 'fpdfsdk/cpdfsdk_baannot.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_baannot.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index 0e6c53cc78..9436b3ba62 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -316,10 +316,9 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
}
if (!pStream) {
- pStream = new CPDF_Stream;
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- pParentDict->SetReferenceFor(sAPType, pDoc,
- pDoc->AddIndirectObject(pStream));
+ pStream = pDoc->NewIndirect<CPDF_Stream>();
+ pParentDict->SetReferenceFor(sAPType, pDoc, pStream);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
@@ -354,8 +353,9 @@ void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
CPDF_Dictionary* pDict = action.GetDict();
if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) {
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc,
- pDoc->AddIndirectObject(pDict));
+ if (pDict->IsInline())
+ pDict = pDoc->AddIndirectObject(pDict->Clone())->AsDictionary();
+ m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc, pDict);
}
}