summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_annot.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-04-16 21:48:37 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-16 21:48:37 +0000
commit6b26e1ae69321717c5ce098a1cd2c9f3e1099344 (patch)
tree0ede098fdef5fe788457ce2e9f793f745f634072 /fpdfsdk/fpdf_annot.cpp
parent8b0cf76f00c6e89e8bb7bf4bcf2189b27baac31c (diff)
downloadpdfium-6b26e1ae69321717c5ce098a1cd2c9f3e1099344.tar.xz
Remove non-const CPDF_PageObjectHolder::GetPageObjectList().
This makes it easier to control modifications to the page object list. Bug: pdfium:1051 Change-Id: Ia85c597fa6d39e89041b990b4b6c91e327ef811d Reviewed-on: https://pdfium-review.googlesource.com/30803 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_annot.cpp')
-rw-r--r--fpdfsdk/fpdf_annot.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
index ccc7596401..6504ee7402 100644
--- a/fpdfsdk/fpdf_annot.cpp
+++ b/fpdfsdk/fpdf_annot.cpp
@@ -381,7 +381,7 @@ FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) {
// Check that the object is already in this annotation's object list.
CPDF_Form* pForm = pAnnot->GetForm();
- CPDF_PageObjectList* pObjList = pForm->GetPageObjectList();
+ const CPDF_PageObjectList* pObjList = pForm->GetPageObjectList();
auto it =
std::find_if(pObjList->begin(), pObjList->end(),
[pObj](const std::unique_ptr<CPDF_PageObject>& candidate) {
@@ -432,7 +432,7 @@ FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) {
// Note that an object that came from a different annotation must not be
// passed here, since an object cannot belong to more than one annotation.
CPDF_Form* pForm = pAnnot->GetForm();
- CPDF_PageObjectList* pObjList = pForm->GetPageObjectList();
+ const CPDF_PageObjectList* pObjList = pForm->GetPageObjectList();
auto it =
std::find_if(pObjList->begin(), pObjList->end(),
[pObj](const std::unique_ptr<CPDF_PageObject>& candidate) {
@@ -442,8 +442,7 @@ FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) {
return false;
// Append the object to the object list.
- std::unique_ptr<CPDF_PageObject> pPageObjHolder(pObj);
- pObjList->push_back(std::move(pPageObjHolder));
+ pForm->AppendPageObject(pdfium::WrapUnique(pObj));
// Set the content stream data in the annotation's AP stream.
UpdateContentStream(pForm, pStream);
@@ -481,7 +480,7 @@ FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index) {
pAnnot->SetForm(pStream);
}
- return pAnnot->GetForm()->GetPageObjectList()->GetPageObjectByIndex(index);
+ return pAnnot->GetForm()->GetPageObjectByIndex(index);
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -501,11 +500,9 @@ FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index) {
if (!pStream)
return false;
- CPDF_PageObjectList* pObjList = pAnnot->GetForm()->GetPageObjectList();
- if (static_cast<size_t>(index) >= pObjList->size())
+ if (!pAnnot->GetForm()->ErasePageObjectAtIndex(index))
return false;
- pObjList->erase(pObjList->begin() + index);
UpdateContentStream(pAnnot->GetForm(), pStream);
return true;
}