diff options
author | tsepez <tsepez@chromium.org> | 2016-10-14 16:59:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-14 16:59:10 -0700 |
commit | 3ba098595ae56b64eacc0c25ab76b89a4d78d920 (patch) | |
tree | 5c4db47295ea64cdf236c32ef7d5af5b8e7af232 /fpdfsdk/fpdfsave.cpp | |
parent | 1d023881cd53485303c0fcc0b5878e700dc470fd (diff) | |
download | pdfium-3ba098595ae56b64eacc0c25ab76b89a4d78d920.tar.xz |
Update CPDF_IndirectObjectHolder APIs for unique objects.
Doing so highlights a few places where ownership is dubious.
Add convenience functions to return an unowned reference to
a newly-created indirect object.
Review-Url: https://codereview.chromium.org/2419173002
Diffstat (limited to 'fpdfsdk/fpdfsave.cpp')
-rw-r--r-- | fpdfsdk/fpdfsave.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index 364f4d2d6f..b594084218 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -184,14 +184,12 @@ bool SaveXFADocumentData(CPDFXFA_Document* pDocument, if (pDataSetsStream) pDataSetsStream->InitStreamFromFile(pDsfileWrite.get(), pDataDict); } else { - CPDF_Stream* pData = new CPDF_Stream; + CPDF_Stream* pData = pPDFDocument->AddIndirectStream(); 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, new CPDF_String("datasets", false)); + pArray->InsertAt(iLast + 1, + new CPDF_Reference(pPDFDocument, pData->GetObjNum())); } fileList->push_back(std::move(pDsfileWrite)); } @@ -208,14 +206,12 @@ bool SaveXFADocumentData(CPDFXFA_Document* pDocument, if (pFormStream) pFormStream->InitStreamFromFile(pfileWrite.get(), pDataDict); } else { - CPDF_Stream* pData = new CPDF_Stream; + CPDF_Stream* pData = pPDFDocument->AddIndirectStream(); 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)); } |