diff options
author | tsepez <tsepez@chromium.org> | 2016-11-15 11:33:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-15 11:33:44 -0800 |
commit | 70c4afd5c3c5c44cd24f814423a23a6ef05bba02 (patch) | |
tree | cbe593d0b6c0bfc6fd5038bf60a77a94e49c69c9 /fpdfsdk/fpdfsave.cpp | |
parent | f16f6b8b52277348f5d571b7641bb0bbd5239589 (diff) | |
download | pdfium-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/fpdfsave.cpp')
-rw-r--r-- | fpdfsdk/fpdfsave.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index 1b639b7cc4..e5d7a409ae 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -180,14 +180,12 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext, if (pDataSetsStream) pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); } else { - CPDF_Stream* pData = new CPDF_Stream; + CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); pData->InitStreamFromFile(pDsfileWrite.get(), pDataDict); iLast = pArray->GetCount() - 2; pArray->InsertAt(iLast, new CPDF_String("datasets", false)); - pArray->InsertAt( - iLast + 1, - new CPDF_Reference(pPDFDocument, - pPDFDocument->AddIndirectObject(pData))); + pArray->InsertAt(iLast + 1, + new CPDF_Reference(pPDFDocument, pData->GetObjNum())); } fileList->push_back(std::move(pDsfileWrite)); } @@ -204,14 +202,12 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext, if (pFormStream) pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); } else { - CPDF_Stream* pData = new CPDF_Stream; + CPDF_Stream* pData = pPDFDocument->NewIndirect<CPDF_Stream>(); pData->InitStreamFromFile(pfileWrite.get(), pDataDict); iLast = pArray->GetCount() - 2; pArray->InsertAt(iLast, new CPDF_String("form", false)); - pArray->InsertAt( - iLast + 1, - new CPDF_Reference(pPDFDocument, - pPDFDocument->AddIndirectObject(pData))); + pArray->InsertAt(iLast + 1, + new CPDF_Reference(pPDFDocument, pData->GetObjNum())); } fileList->push_back(std::move(pfileWrite)); } |