summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_attachment.cpp
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-11 18:19:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-11 18:19:57 +0000
commitfb72726e51bfd0c7bfc61c9b354e2b60f46adac5 (patch)
treeb2a763c74a07b081a4b176c18c42569e377d6fc8 /fpdfsdk/fpdf_attachment.cpp
parent5e873f5ce8e407c97e966b9708d2560e908112d3 (diff)
downloadpdfium-fb72726e51bfd0c7bfc61c9b354e2b60f46adac5.tar.xz
Implement CPDF_Object::MakeReference method.chromium/3456
Change-Id: I153747ef587a184eaef58ff09dbf8f214c9ddfb3 Reviewed-on: https://pdfium-review.googlesource.com/17230 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'fpdfsdk/fpdf_attachment.cpp')
-rw-r--r--fpdfsdk/fpdf_attachment.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/fpdfsdk/fpdf_attachment.cpp b/fpdfsdk/fpdf_attachment.cpp
index f2ed684e40..6a4faf6c65 100644
--- a/fpdfsdk/fpdf_attachment.cpp
+++ b/fpdfsdk/fpdf_attachment.cpp
@@ -72,15 +72,14 @@ FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name) {
CPDF_Dictionary* pNames = pRoot->GetDictFor("Names");
if (!pNames) {
pNames = pDoc->NewIndirect<CPDF_Dictionary>();
- pRoot->SetNewFor<CPDF_Reference>("Names", pDoc, pNames->GetObjNum());
+ pRoot->SetFor("Names", pNames->MakeReference(pDoc));
}
// Create the EmbeddedFiles dictionary if missing.
if (!pNames->GetDictFor("EmbeddedFiles")) {
CPDF_Dictionary* pFiles = pDoc->NewIndirect<CPDF_Dictionary>();
pFiles->SetNewFor<CPDF_Array>("Names");
- pNames->SetNewFor<CPDF_Reference>("EmbeddedFiles", pDoc,
- pFiles->GetObjNum());
+ pNames->SetFor("EmbeddedFiles", pFiles->MakeReference(pDoc));
}
// Set up the basic entries in the filespec dictionary.
@@ -91,9 +90,7 @@ FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name) {
// Add the new attachment name and filespec into the document's EmbeddedFiles.
CPDF_NameTree nameTree(pDoc, "EmbeddedFiles");
- if (!nameTree.AddValueAndName(
- pdfium::MakeUnique<CPDF_Reference>(pDoc, pFile->GetObjNum()),
- wsName)) {
+ if (!nameTree.AddValueAndName(pFile->MakeReference(pDoc), wsName)) {
return nullptr;
}
@@ -254,7 +251,7 @@ FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment,
std::move(stream), len, std::move(pFileStreamDict));
CPDF_Dictionary* pEFDict =
pFile->AsDictionary()->SetNewFor<CPDF_Dictionary>("EF");
- pEFDict->SetNewFor<CPDF_Reference>("F", pDoc, pFileStream->GetObjNum());
+ pEFDict->SetFor("F", pFileStream->MakeReference(pDoc));
return true;
}