summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfeditpage.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-03-15 15:25:16 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-15 15:25:16 +0000
commit35841fa4e3dbf8f9146f78def048c4a287894a8a (patch)
tree2252389ad952f6bdb0c9a55b6441f3b195e38ff3 /fpdfsdk/fpdfeditpage.cpp
parentd14dd4316d04f0982c340ad25bb283198a4d5c32 (diff)
downloadpdfium-35841fa4e3dbf8f9146f78def048c4a287894a8a.tar.xz
Create FPDFPage_RemoveObject().
This call removes a page object from a page. We currently offer an API to insert these objects, but not to remove. Bug: pdfium:1037 Change-Id: I35ff596f9e7c87a39051f0cb1de40a5bec40fee5 Reviewed-on: https://pdfium-review.googlesource.com/28492 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfeditpage.cpp')
-rw-r--r--fpdfsdk/fpdfeditpage.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index ca2cf3fb6e..800613348b 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -174,10 +174,25 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page,
if (!IsPageObject(pPage))
return;
pPageObj->SetDirty(true);
+
+ // TODO(hnakashima): Move into CPDF_Page.
pPage->GetPageObjectList()->push_back(std::move(pPageObjHolder));
CalcBoundingBox(pPageObj);
}
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFPage_RemoveObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj) {
+ CPDF_PageObject* pPageObj = CPDFPageObjectFromFPDFPageObject(page_obj);
+ if (!pPageObj)
+ return false;
+
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!IsPageObject(pPage))
+ return false;
+
+ return pPage->RemoveObject(pPageObj);
+}
+
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObject(FPDF_PAGE page) {
return FPDFPage_CountObjects(page);
}
@@ -186,6 +201,8 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!IsPageObject(pPage))
return -1;
+
+ // TODO(hnakashima): Move into CPDF_Page.
return pdfium::CollectionSize<int>(*pPage->GetPageObjectList());
}
@@ -194,6 +211,8 @@ FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page,
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!IsPageObject(pPage))
return nullptr;
+
+ // TODO(hnakashima): Move into CPDF_Page.
return pPage->GetPageObjectList()->GetPageObjectByIndex(index);
}