summaryrefslogtreecommitdiff
path: root/core/fpdfapi
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
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')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp36
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.h10
-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
7 files changed, 74 insertions, 73 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index 946364d6d7..b0f0ca686a 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -15,7 +15,7 @@
#include "core/fpdfapi/edit/cpdf_pagecontentmanager.h"
#include "core/fpdfapi/edit/cpdf_stringarchivestream.h"
#include "core/fpdfapi/font/cpdf_font.h"
-#include "core/fpdfapi/page/cpdf_contentmark.h"
+#include "core/fpdfapi/page/cpdf_contentmarks.h"
#include "core/fpdfapi/page/cpdf_docpagedata.h"
#include "core/fpdfapi/page/cpdf_image.h"
#include "core/fpdfapi/page/cpdf_imageobject.h"
@@ -97,9 +97,9 @@ CPDF_PageContentGenerator::GenerateModifiedStreams() {
// Start regenerating dirty streams.
std::map<int32_t, std::unique_ptr<std::ostringstream>> streams;
std::set<int32_t> empty_streams;
- std::unique_ptr<const CPDF_ContentMark> empty_content_mark =
- pdfium::MakeUnique<CPDF_ContentMark>();
- std::map<int32_t, const CPDF_ContentMark*> current_content_mark;
+ std::unique_ptr<const CPDF_ContentMarks> empty_content_marks =
+ pdfium::MakeUnique<CPDF_ContentMarks>();
+ std::map<int32_t, const CPDF_ContentMarks*> current_content_marks;
for (int32_t dirty_stream : all_dirty_streams) {
std::unique_ptr<std::ostringstream> buf =
@@ -114,7 +114,7 @@ CPDF_PageContentGenerator::GenerateModifiedStreams() {
streams[dirty_stream] = std::move(buf);
empty_streams.insert(dirty_stream);
- current_content_mark[dirty_stream] = empty_content_mark.get();
+ current_content_marks[dirty_stream] = empty_content_marks.get();
}
// Process the page objects, write into each dirty stream.
@@ -126,8 +126,8 @@ CPDF_PageContentGenerator::GenerateModifiedStreams() {
std::ostringstream* buf = it->second.get();
empty_streams.erase(stream_index);
- current_content_mark[stream_index] = ProcessContentMarks(
- buf, pPageObj.Get(), current_content_mark[stream_index]);
+ current_content_marks[stream_index] = ProcessContentMarks(
+ buf, pPageObj.Get(), current_content_marks[stream_index]);
ProcessPageObject(buf, pPageObj.Get());
}
@@ -138,7 +138,7 @@ CPDF_PageContentGenerator::GenerateModifiedStreams() {
// Clear to show that this stream needs to be deleted.
buf->str("");
} else {
- FinishMarks(buf, current_content_mark[dirty_stream]);
+ FinishMarks(buf, current_content_marks[dirty_stream]);
// Return graphics to original state
*buf << "Q\n";
@@ -212,19 +212,19 @@ ByteString CPDF_PageContentGenerator::RealizeResource(
bool CPDF_PageContentGenerator::ProcessPageObjects(std::ostringstream* buf) {
bool bDirty = false;
- std::unique_ptr<const CPDF_ContentMark> empty_content_mark =
- pdfium::MakeUnique<CPDF_ContentMark>();
- const CPDF_ContentMark* content_mark = empty_content_mark.get();
+ std::unique_ptr<const CPDF_ContentMarks> empty_content_marks =
+ pdfium::MakeUnique<CPDF_ContentMarks>();
+ const CPDF_ContentMarks* content_marks = empty_content_marks.get();
for (auto& pPageObj : m_pageObjects) {
if (m_pObjHolder->IsPage() && !pPageObj->IsDirty())
continue;
bDirty = true;
- content_mark = ProcessContentMarks(buf, pPageObj.Get(), content_mark);
+ content_marks = ProcessContentMarks(buf, pPageObj.Get(), content_marks);
ProcessPageObject(buf, pPageObj.Get());
}
- FinishMarks(buf, content_mark);
+ FinishMarks(buf, content_marks);
return bDirty;
}
@@ -236,11 +236,11 @@ void CPDF_PageContentGenerator::UpdateStreamlessPageObjects(
}
}
-const CPDF_ContentMark* CPDF_PageContentGenerator::ProcessContentMarks(
+const CPDF_ContentMarks* CPDF_PageContentGenerator::ProcessContentMarks(
std::ostringstream* buf,
const CPDF_PageObject* pPageObj,
- const CPDF_ContentMark* pPrev) {
- const CPDF_ContentMark* pNext = &pPageObj->m_ContentMark;
+ const CPDF_ContentMarks* pPrev) {
+ const CPDF_ContentMarks* pNext = &pPageObj->m_ContentMarks;
size_t first_different = pPrev->FindFirstDifference(pNext);
@@ -290,11 +290,11 @@ const CPDF_ContentMark* CPDF_PageContentGenerator::ProcessContentMarks(
void CPDF_PageContentGenerator::FinishMarks(
std::ostringstream* buf,
- const CPDF_ContentMark* pContentMark) {
+ const CPDF_ContentMarks* pContentMarks) {
// Technically we should iterate backwards to close from the top to the
// bottom, but since the EMC operators do not identify which mark they are
// closing, it does not matter.
- for (size_t i = 0; i < pContentMark->CountItems(); ++i)
+ for (size_t i = 0; i < pContentMarks->CountItems(); ++i)
*buf << "EMC\n";
}
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h
index 029a77935b..ead3950f88 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h
@@ -16,7 +16,7 @@
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/unowned_ptr.h"
-class CPDF_ContentMark;
+class CPDF_ContentMarks;
class CPDF_Document;
class CPDF_ImageObject;
class CPDF_Object;
@@ -45,11 +45,11 @@ class CPDF_PageContentGenerator {
ByteString GetOrCreateDefaultGraphics() const;
ByteString RealizeResource(const CPDF_Object* pResource,
const ByteString& bsType) const;
- const CPDF_ContentMark* ProcessContentMarks(std::ostringstream* buf,
- const CPDF_PageObject* pPageObj,
- const CPDF_ContentMark* pPrev);
+ const CPDF_ContentMarks* ProcessContentMarks(std::ostringstream* buf,
+ const CPDF_PageObject* pPageObj,
+ const CPDF_ContentMarks* pPrev);
void FinishMarks(std::ostringstream* buf,
- const CPDF_ContentMark* pContentMark);
+ const CPDF_ContentMarks* pContentMarks);
// Returns a map from content stream index to new stream data. Unmodified
// streams are not touched.
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;