From fed4adb003db228ac7fbc0510a21c25b50ae0cab Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Fri, 13 Jul 2018 19:47:22 +0000 Subject: 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 Commit-Queue: Henrique Nakashima --- core/fpdfapi/page/cpdf_contentmark.cpp | 14 ++++++++++++++ core/fpdfapi/page/cpdf_contentmark.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'core') 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(); @@ -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: -- cgit v1.2.3