diff options
author | Jane Liu <janeliulwq@google.com> | 2017-07-25 18:11:27 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-27 13:52:39 +0000 |
commit | f63e8133d7a767c6f162e700056ae8ba8512820d (patch) | |
tree | f0a8aab3dfb06b5c121d4f3350bf97aeceab4d7e /fpdfsdk/fpdfattachment.cpp | |
parent | f9d60598992f3d9ce2f4b5860a7835fa44d55c88 (diff) | |
download | pdfium-f63e8133d7a767c6f162e700056ae8ba8512820d.tar.xz |
Added FPDFDoc_DeleteAttachment()
Added an API for deleting an attachment and an embedder test for it.
Bug=pdfium:174
Change-Id: I97a1367a197bceb96ecef55c36b1599beccd95a6
Reviewed-on: https://pdfium-review.googlesource.com/8932
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfattachment.cpp')
-rw-r--r-- | fpdfsdk/fpdfattachment.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfattachment.cpp b/fpdfsdk/fpdfattachment.cpp index 78fccf4d60..0cb623f81c 100644 --- a/fpdfsdk/fpdfattachment.cpp +++ b/fpdfsdk/fpdfattachment.cpp @@ -112,6 +112,19 @@ DLLEXPORT FPDF_ATTACHMENT STDCALL FPDFDoc_GetAttachment(FPDF_DOCUMENT document, return nameTree.LookupValueAndName(index, &csName); } +DLLEXPORT FPDF_BOOL STDCALL FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document, + int index) { + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); + if (!pDoc || index < 0) + return false; + + CPDF_NameTree nameTree(pDoc, "EmbeddedFiles"); + if (static_cast<size_t>(index) >= nameTree.GetCount()) + return false; + + return nameTree.DeleteValueAndName(index); +} + DLLEXPORT unsigned long STDCALL FPDFAttachment_GetName(FPDF_ATTACHMENT attachment, void* buffer, |