summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-10-10 23:17:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 23:17:03 +0000
commit673b90ad5b21a3d17e64ef65d7053d582920fcbe (patch)
treed113f769e004a52f3789f36f73d4f5d99098a9fa /core/fpdfapi/page
parentfc41e77c97173592ea2abb88c3f6f4dc7c43349d (diff)
downloadpdfium-673b90ad5b21a3d17e64ef65d7053d582920fcbe.tar.xz
Rename CPDF_ContentMark to CPDF_ContentMarks.
Also change variable names and member names of this type. This better reflects the fact that this class contains all the marks in a page objects, not just one mark. Change-Id: I4fe3d2620e78cbe423f18634f19fa82530d7efe1 Reviewed-on: https://pdfium-review.googlesource.com/c/43813 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_contentmarks.cpp (renamed from core/fpdfapi/page/cpdf_contentmark.cpp)69
-rw-r--r--core/fpdfapi/page/cpdf_contentmarks.h (renamed from core/fpdfapi/page/cpdf_contentmark.h)16
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.h4
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.h4
5 files changed, 51 insertions, 50 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmarks.cpp
index c1cdf392e0..caaf6e391d 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmarks.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdfapi/page/cpdf_contentmark.h"
+#include "core/fpdfapi/page/cpdf_contentmarks.h"
#include <algorithm>
#include <utility>
@@ -12,51 +12,51 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "third_party/base/ptr_util.h"
-CPDF_ContentMark::CPDF_ContentMark() {}
+CPDF_ContentMarks::CPDF_ContentMarks() {}
-CPDF_ContentMark::~CPDF_ContentMark() {}
+CPDF_ContentMarks::~CPDF_ContentMarks() {}
-std::unique_ptr<CPDF_ContentMark> CPDF_ContentMark::Clone() {
- auto result = pdfium::MakeUnique<CPDF_ContentMark>();
+std::unique_ptr<CPDF_ContentMarks> CPDF_ContentMarks::Clone() {
+ auto result = pdfium::MakeUnique<CPDF_ContentMarks>();
if (m_pMarkData)
result->m_pMarkData = pdfium::MakeRetain<MarkData>(*m_pMarkData);
return result;
}
-size_t CPDF_ContentMark::CountItems() const {
+size_t CPDF_ContentMarks::CountItems() const {
return m_pMarkData ? m_pMarkData->CountItems() : 0;
}
-bool CPDF_ContentMark::ContainsItem(const CPDF_ContentMarkItem* pItem) const {
+bool CPDF_ContentMarks::ContainsItem(const CPDF_ContentMarkItem* pItem) const {
return m_pMarkData && m_pMarkData->ContainsItem(pItem);
}
-CPDF_ContentMarkItem* CPDF_ContentMark::GetItem(size_t index) {
+CPDF_ContentMarkItem* CPDF_ContentMarks::GetItem(size_t index) {
return const_cast<CPDF_ContentMarkItem*>(
- static_cast<const CPDF_ContentMark*>(this)->GetItem(index));
+ static_cast<const CPDF_ContentMarks*>(this)->GetItem(index));
}
-const CPDF_ContentMarkItem* CPDF_ContentMark::GetItem(size_t index) const {
+const CPDF_ContentMarkItem* CPDF_ContentMarks::GetItem(size_t index) const {
ASSERT(index < CountItems());
return m_pMarkData->GetItem(index);
}
-int CPDF_ContentMark::GetMarkedContentID() const {
+int CPDF_ContentMarks::GetMarkedContentID() const {
return m_pMarkData ? m_pMarkData->GetMarkedContentID() : -1;
}
-void CPDF_ContentMark::AddMark(ByteString name) {
+void CPDF_ContentMarks::AddMark(ByteString name) {
EnsureMarkDataExists();
m_pMarkData->AddMark(std::move(name));
}
-void CPDF_ContentMark::AddMarkWithDirectDict(ByteString name,
- CPDF_Dictionary* pDict) {
+void CPDF_ContentMarks::AddMarkWithDirectDict(ByteString name,
+ CPDF_Dictionary* pDict) {
EnsureMarkDataExists();
m_pMarkData->AddMarkWithDirectDict(std::move(name), pDict);
}
-void CPDF_ContentMark::AddMarkWithPropertiesDict(
+void CPDF_ContentMarks::AddMarkWithPropertiesDict(
ByteString name,
CPDF_Dictionary* pDict,
const ByteString& property_name) {
@@ -64,16 +64,16 @@ void CPDF_ContentMark::AddMarkWithPropertiesDict(
m_pMarkData->AddMarkWithPropertiesDict(std::move(name), pDict, property_name);
}
-bool CPDF_ContentMark::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
+bool CPDF_ContentMarks::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
return m_pMarkData && m_pMarkData->RemoveMark(pMarkItem);
}
-void CPDF_ContentMark::EnsureMarkDataExists() {
+void CPDF_ContentMarks::EnsureMarkDataExists() {
if (!m_pMarkData)
m_pMarkData = pdfium::MakeRetain<MarkData>();
}
-void CPDF_ContentMark::DeleteLastMark() {
+void CPDF_ContentMarks::DeleteLastMark() {
if (!m_pMarkData)
return;
@@ -82,8 +82,8 @@ void CPDF_ContentMark::DeleteLastMark() {
m_pMarkData.Reset();
}
-size_t CPDF_ContentMark::FindFirstDifference(
- const CPDF_ContentMark* other) const {
+size_t CPDF_ContentMarks::FindFirstDifference(
+ const CPDF_ContentMarks* other) const {
if (m_pMarkData == other->m_pMarkData)
return CountItems();
@@ -96,18 +96,18 @@ size_t CPDF_ContentMark::FindFirstDifference(
return min_len;
}
-CPDF_ContentMark::MarkData::MarkData() {}
+CPDF_ContentMarks::MarkData::MarkData() {}
-CPDF_ContentMark::MarkData::MarkData(const MarkData& src)
+CPDF_ContentMarks::MarkData::MarkData(const MarkData& src)
: m_Marks(src.m_Marks) {}
-CPDF_ContentMark::MarkData::~MarkData() {}
+CPDF_ContentMarks::MarkData::~MarkData() {}
-size_t CPDF_ContentMark::MarkData::CountItems() const {
+size_t CPDF_ContentMarks::MarkData::CountItems() const {
return m_Marks.size();
}
-bool CPDF_ContentMark::MarkData::ContainsItem(
+bool CPDF_ContentMarks::MarkData::ContainsItem(
const CPDF_ContentMarkItem* pItem) const {
for (const auto pMark : m_Marks) {
if (pMark.Get() == pItem)
@@ -116,16 +116,16 @@ bool CPDF_ContentMark::MarkData::ContainsItem(
return false;
}
-CPDF_ContentMarkItem* CPDF_ContentMark::MarkData::GetItem(size_t index) {
+CPDF_ContentMarkItem* CPDF_ContentMarks::MarkData::GetItem(size_t index) {
return m_Marks[index].Get();
}
-const CPDF_ContentMarkItem* CPDF_ContentMark::MarkData::GetItem(
+const CPDF_ContentMarkItem* CPDF_ContentMarks::MarkData::GetItem(
size_t index) const {
return m_Marks[index].Get();
}
-int CPDF_ContentMark::MarkData::GetMarkedContentID() const {
+int CPDF_ContentMarks::MarkData::GetMarkedContentID() const {
for (const auto pMark : m_Marks) {
const CPDF_Dictionary* pDict = pMark->GetParam();
if (pDict && pDict->KeyExist("MCID"))
@@ -134,19 +134,20 @@ int CPDF_ContentMark::MarkData::GetMarkedContentID() const {
return -1;
}
-void CPDF_ContentMark::MarkData::AddMark(ByteString name) {
+void CPDF_ContentMarks::MarkData::AddMark(ByteString name) {
auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(std::move(name));
m_Marks.push_back(pItem);
}
-void CPDF_ContentMark::MarkData::AddMarkWithDirectDict(ByteString name,
- CPDF_Dictionary* pDict) {
+void CPDF_ContentMarks::MarkData::AddMarkWithDirectDict(
+ ByteString name,
+ CPDF_Dictionary* pDict) {
auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(std::move(name));
pItem->SetDirectDict(ToDictionary(pDict->Clone()));
m_Marks.push_back(pItem);
}
-void CPDF_ContentMark::MarkData::AddMarkWithPropertiesDict(
+void CPDF_ContentMarks::MarkData::AddMarkWithPropertiesDict(
ByteString name,
CPDF_Dictionary* pDict,
const ByteString& property_name) {
@@ -155,7 +156,7 @@ void CPDF_ContentMark::MarkData::AddMarkWithPropertiesDict(
m_Marks.push_back(pItem);
}
-bool CPDF_ContentMark::MarkData::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
+bool CPDF_ContentMarks::MarkData::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
for (auto it = m_Marks.begin(); it != m_Marks.end(); ++it) {
if (it->Get() == pMarkItem) {
m_Marks.erase(it);
@@ -165,7 +166,7 @@ bool CPDF_ContentMark::MarkData::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
return false;
}
-void CPDF_ContentMark::MarkData::DeleteLastMark() {
+void CPDF_ContentMarks::MarkData::DeleteLastMark() {
if (!m_Marks.empty())
m_Marks.pop_back();
}
diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmarks.h
index 1395db12f8..335592b940 100644
--- a/core/fpdfapi/page/cpdf_contentmark.h
+++ b/core/fpdfapi/page/cpdf_contentmarks.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FPDFAPI_PAGE_CPDF_CONTENTMARK_H_
-#define CORE_FPDFAPI_PAGE_CPDF_CONTENTMARK_H_
+#ifndef CORE_FPDFAPI_PAGE_CPDF_CONTENTMARKS_H_
+#define CORE_FPDFAPI_PAGE_CPDF_CONTENTMARKS_H_
#include <memory>
#include <vector>
@@ -16,12 +16,12 @@
class CPDF_Dictionary;
-class CPDF_ContentMark {
+class CPDF_ContentMarks {
public:
- CPDF_ContentMark();
- ~CPDF_ContentMark();
+ CPDF_ContentMarks();
+ ~CPDF_ContentMarks();
- std::unique_ptr<CPDF_ContentMark> Clone();
+ std::unique_ptr<CPDF_ContentMarks> Clone();
int GetMarkedContentID() const;
size_t CountItems() const;
bool ContainsItem(const CPDF_ContentMarkItem* pItem) const;
@@ -37,7 +37,7 @@ class CPDF_ContentMark {
const ByteString& property_name);
bool RemoveMark(CPDF_ContentMarkItem* pMarkItem);
void DeleteLastMark();
- size_t FindFirstDifference(const CPDF_ContentMark* other) const;
+ size_t FindFirstDifference(const CPDF_ContentMarks* other) const;
private:
class MarkData final : public Retainable {
@@ -69,4 +69,4 @@ class CPDF_ContentMark {
RetainPtr<MarkData> m_pMarkData;
};
-#endif // CORE_FPDFAPI_PAGE_CPDF_CONTENTMARK_H_
+#endif // CORE_FPDFAPI_PAGE_CPDF_CONTENTMARKS_H_
diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h
index 013ef0d03b..6bbaff3c58 100644
--- a/core/fpdfapi/page/cpdf_pageobject.h
+++ b/core/fpdfapi/page/cpdf_pageobject.h
@@ -7,7 +7,7 @@
#ifndef CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECT_H_
#define CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECT_H_
-#include "core/fpdfapi/page/cpdf_contentmark.h"
+#include "core/fpdfapi/page/cpdf_contentmarks.h"
#include "core/fpdfapi/page/cpdf_graphicstates.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -74,7 +74,7 @@ class CPDF_PageObject : public CPDF_GraphicStates {
m_ContentStream = new_content_stream;
}
- CPDF_ContentMark m_ContentMark;
+ CPDF_ContentMarks m_ContentMarks;
protected:
void CopyData(const CPDF_PageObject* pSrcObject);
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index b381705123..d84d4d62ec 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -290,7 +290,7 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
}
// Add the sentinel.
- m_ContentMarksStack.push(pdfium::MakeUnique<CPDF_ContentMark>());
+ m_ContentMarksStack.push(pdfium::MakeUnique<CPDF_ContentMarks>());
}
CPDF_StreamContentParser::~CPDF_StreamContentParser() {
@@ -428,7 +428,7 @@ void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj,
bool bGraph) {
pObj->m_GeneralState = m_pCurStates->m_GeneralState;
pObj->m_ClipPath = m_pCurStates->m_ClipPath;
- pObj->m_ContentMark = *m_ContentMarksStack.top();
+ pObj->m_ContentMarks = *m_ContentMarksStack.top();
if (bColor) {
pObj->m_ColorState = m_pCurStates->m_ColorState;
}
@@ -602,7 +602,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
return;
}
if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
- std::unique_ptr<CPDF_ContentMark> new_marks =
+ std::unique_ptr<CPDF_ContentMarks> new_marks =
m_ContentMarksStack.top()->Clone();
if (bIndirect) {
new_marks->AddMarkWithPropertiesDict(std::move(tag), pDict,
@@ -675,7 +675,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
- std::unique_ptr<CPDF_ContentMark> new_marks =
+ std::unique_ptr<CPDF_ContentMarks> new_marks =
m_ContentMarksStack.top()->Clone();
new_marks->AddMark(GetString(0));
m_ContentMarksStack.push(std::move(new_marks));
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index d9239fd6fa..05556ff5d2 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -13,7 +13,7 @@
#include <stack>
#include <vector>
-#include "core/fpdfapi/page/cpdf_contentmark.h"
+#include "core/fpdfapi/page/cpdf_contentmarks.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fxcrt/fx_number.h"
#include "core/fxcrt/fx_string.h"
@@ -213,7 +213,7 @@ class CPDF_StreamContentParser {
uint32_t m_ParamCount;
UnownedPtr<CPDF_StreamParser> m_pSyntax;
std::unique_ptr<CPDF_AllStates> m_pCurStates;
- std::stack<std::unique_ptr<CPDF_ContentMark>> m_ContentMarksStack;
+ std::stack<std::unique_ptr<CPDF_ContentMarks>> m_ContentMarksStack;
std::vector<std::unique_ptr<CPDF_TextObject>> m_ClipTextList;
UnownedPtr<CPDF_TextObject> m_pLastTextObject;
float m_DefFontSize;