7#include "core/fpdfapi/page/cpdf_contentmarks.h"
12#include "core/fpdfapi/parser/cpdf_dictionary.h"
13#include "third_party/base/check_op.h"
22 result->m_pMarkData = pdfium::MakeRetain<MarkData>(*m_pMarkData);
27 return m_pMarkData ? m_pMarkData->CountItems() : 0;
31 return m_pMarkData && m_pMarkData->ContainsItem(pItem);
35 return m_pMarkData->GetItem(index);
39 return m_pMarkData->GetItem(index);
43 return m_pMarkData ? m_pMarkData->GetMarkedContentID() : -1;
47 EnsureMarkDataExists();
48 m_pMarkData->AddMark(std::move(name));
54 EnsureMarkDataExists();
55 m_pMarkData->AddMarkWithDirectDict(std::move(name), std::move(pDict));
59 const ByteString& name,
61 const ByteString& property_name) {
62 EnsureMarkDataExists();
63 m_pMarkData->AddMarkWithPropertiesHolder(name, std::move(pDict),
68 return m_pMarkData && m_pMarkData->RemoveMark(pMarkItem);
73 m_pMarkData = pdfium::MakeRetain<MarkData>();
78 if (m_pMarkData == other->m_pMarkData)
81 size_t min_len = std::min(CountItems(), other->CountItems());
83 for (size_t i = 0; i < min_len; ++i) {
84 if (GetItem(i) != other->GetItem(i))
93 : m_Marks(src.m_Marks) {}
98 return m_Marks.size();
102 const CPDF_ContentMarkItem* pItem)
const {
103 for (
const auto& pMark : m_Marks) {
111 CHECK_LT(index, m_Marks.size());
112 return m_Marks[index].Get();
116 size_t index)
const {
117 CHECK_LT(index, m_Marks.size());
118 return m_Marks[index].Get();
122 for (
const auto& pMark : m_Marks) {
123 RetainPtr<
const CPDF_Dictionary> pDict = pMark->GetParam();
124 if (pDict && pDict->KeyExist(
"MCID"))
125 return pDict->GetIntegerFor(
"MCID");
131 auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(
std::move(name));
132 m_Marks.push_back(pItem);
138 auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(
std::move(name));
139 pItem->SetDirectDict(ToDictionary(pDict->Clone()));
140 m_Marks.push_back(pItem);
144 const ByteString& name,
146 const ByteString& property_name) {
147 auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(name);
148 pItem->SetPropertiesHolder(
std::move(pDict), property_name);
149 m_Marks.push_back(std::move(pItem));
153 for (
auto it = m_Marks.begin(); it != m_Marks.end(); ++it) {
154 if (*it == pMarkItem) {
void AddMarkWithDirectDict(ByteString name, RetainPtr< CPDF_Dictionary > pDict)
bool RemoveMark(CPDF_ContentMarkItem *pMarkItem)
void AddMarkWithPropertiesHolder(const ByteString &name, RetainPtr< CPDF_Dictionary > pDict, const ByteString &property_name)
bool ContainsItem(const CPDF_ContentMarkItem *pItem) const
const CPDF_ContentMarkItem * GetItem(size_t index) const
size_t CountItems() const
CPDF_ContentMarkItem * GetItem(size_t index)
std::unique_ptr< CPDF_ContentMarks > Clone()
int GetMarkedContentID() const
size_t FindFirstDifference(const CPDF_ContentMarks *other) const
void AddMark(ByteString name)