summaryrefslogtreecommitdiff
path: root/core
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 /core
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 'core')
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp14
-rw-r--r--core/fpdfapi/page/cpdf_page.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index ba93f4a7d3..0c8d63de71 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -180,6 +180,20 @@ int CPDF_Page::GetPageRotation() const {
return (rotate < 0) ? (rotate + 4) : rotate;
}
+bool CPDF_Page::RemoveObject(CPDF_PageObject* pPageObj) {
+ pdfium::FakeUniquePtr<CPDF_PageObject> p(pPageObj);
+
+ auto* pPageObjectList = GetPageObjectList();
+ auto it =
+ std::find(std::begin(*pPageObjectList), std::end(*pPageObjectList), p);
+ if (it == std::end(*pPageObjectList))
+ return false;
+
+ it->release();
+ pPageObjectList->erase(it);
+ return true;
+}
+
bool GraphicsData::operator<(const GraphicsData& other) const {
if (fillAlpha != other.fillAlpha)
return fillAlpha < other.fillAlpha;
diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h
index c7aa12e474..995d99cf4e 100644
--- a/core/fpdfapi/page/cpdf_page.h
+++ b/core/fpdfapi/page/cpdf_page.h
@@ -54,6 +54,7 @@ class CPDF_Page : public CPDF_PageObjectHolder {
View* GetView() const { return m_pView; }
void SetView(View* pView) { m_pView = pView; }
+ bool RemoveObject(CPDF_PageObject* pPageObj);
private:
void StartParse();