summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-07-13 19:47:22 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-13 19:47:22 +0000
commitfed4adb003db228ac7fbc0510a21c25b50ae0cab (patch)
treef9a73333d86d5abb1cf890e320f0800a2dd875c9 /core/fpdfapi/page
parenta34067721d6630975c356a621a12753bbdab1cdb (diff)
downloadpdfium-fed4adb003db228ac7fbc0510a21c25b50ae0cab.tar.xz
Create API to remove a content mark from a page object.
- FPDFPageObj_RemoveMark() Bug: pdfium:1037 Change-Id: I7ff320261d64e3ead45375ccc72301e7c64dd6e3 Reviewed-on: https://pdfium-review.googlesource.com/37710 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.cpp14
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp
index 4932ee6231..615d31f3eb 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmark.cpp
@@ -73,6 +73,10 @@ void CPDF_ContentMark::AddMarkWithPropertiesDict(
m_pMarkData->AddMarkWithPropertiesDict(std::move(name), pDict, property_name);
}
+bool CPDF_ContentMark::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
+ return m_pMarkData && m_pMarkData->RemoveMark(pMarkItem);
+}
+
void CPDF_ContentMark::EnsureMarkDataExists() {
if (!m_pMarkData)
m_pMarkData = pdfium::MakeRetain<MarkData>();
@@ -160,6 +164,16 @@ void CPDF_ContentMark::MarkData::AddMarkWithPropertiesDict(
m_Marks.push_back(pItem);
}
+bool CPDF_ContentMark::MarkData::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
+ for (auto it = m_Marks.begin(); it != m_Marks.end(); ++it) {
+ if (it->Get() == pMarkItem) {
+ m_Marks.erase(it);
+ return true;
+ }
+ }
+ return false;
+}
+
void CPDF_ContentMark::MarkData::DeleteLastMark() {
if (!m_Marks.empty())
m_Marks.pop_back();
diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h
index 8dc98370e6..4f678aff8e 100644
--- a/core/fpdfapi/page/cpdf_contentmark.h
+++ b/core/fpdfapi/page/cpdf_contentmark.h
@@ -35,6 +35,7 @@ class CPDF_ContentMark {
void AddMarkWithPropertiesDict(ByteString name,
CPDF_Dictionary* pDict,
const ByteString& property_name);
+ bool RemoveMark(CPDF_ContentMarkItem* pMarkItem);
void DeleteLastMark();
size_t FindFirstDifference(const CPDF_ContentMark* other) const;
@@ -56,6 +57,7 @@ class CPDF_ContentMark {
void AddMarkWithPropertiesDict(ByteString name,
CPDF_Dictionary* pDict,
const ByteString& property_name);
+ bool RemoveMark(CPDF_ContentMarkItem* pMarkItem);
void DeleteLastMark();
private: