summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-26 13:20:26 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-26 13:20:26 -0800
commit8e5cd19d174f259bfda5f7a9699b08fdc4289b56 (patch)
tree6c2382c4cfe0475ecbfafc1af981dcaa0a801c35 /core/src/fpdfapi
parentd834d55f902ccd18cba85f93ecf51e30c5e7e47b (diff)
downloadpdfium-8e5cd19d174f259bfda5f7a9699b08fdc4289b56.tar.xz
Merge to XFA: War on #defines, part 1.
Contains additional XFA-specific changes. Original Review URL: https://codereview.chromium.org/1632143002 . (cherry picked from commit 66a9dc9dd65ed2b9c7ede448d046b770140f16d5) R=thestig@chromium.org Review URL: https://codereview.chromium.org/1636503006 .
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp36
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp36
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp18
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp95
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp18
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp18
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp40
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp2
12 files changed, 145 insertions, 136 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
index f1565cd9a2..a7df332337 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
@@ -38,7 +38,7 @@ void CPDF_PageContentGenerator::GenerateContent() {
CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict;
for (int i = 0; i < m_pageObjects.GetSize(); ++i) {
CPDF_PageObject* pPageObj = m_pageObjects[i];
- if (!pPageObj || pPageObj->m_Type != PDFPAGE_IMAGE) {
+ if (!pPageObj || pPageObj->m_Type != CPDF_PageObject::IMAGE) {
continue;
}
ProcessImage(buf, (CPDF_ImageObject*)pPageObj);
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index f8e7cb86c3..8d0f6210d8 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -32,14 +32,14 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
return 1;
}
switch (pObj->GetType()) {
- case PDFOBJ_NULL:
+ case CPDF_Object::NULLOBJ:
if (pFile->AppendString(" null") < 0) {
return -1;
}
offset += 5;
break;
- case PDFOBJ_BOOLEAN:
- case PDFOBJ_NUMBER:
+ case CPDF_Object::BOOLEAN:
+ case CPDF_Object::NUMBER:
if (pFile->AppendString(" ") < 0) {
return -1;
}
@@ -48,7 +48,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
}
offset += len + 1;
break;
- case PDFOBJ_STRING: {
+ case CPDF_Object::STRING: {
CFX_ByteString str = pObj->GetString();
FX_BOOL bHex = pObj->AsString()->IsHex();
if ((len = pFile->AppendString(PDF_EncodeString(str, bHex))) < 0) {
@@ -57,7 +57,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
offset += len;
break;
}
- case PDFOBJ_NAME: {
+ case CPDF_Object::NAME: {
if (pFile->AppendString("/") < 0) {
return -1;
}
@@ -68,7 +68,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
offset += len + 1;
break;
}
- case PDFOBJ_REFERENCE: {
+ case CPDF_Object::REFERENCE: {
if (pFile->AppendString(" ") < 0)
return -1;
if ((len = pFile->AppendDWord(pObj->AsReference()->GetRefObjNum())) < 0)
@@ -78,7 +78,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
offset += len + 6;
break;
}
- case PDFOBJ_ARRAY: {
+ case CPDF_Object::ARRAY: {
if (pFile->AppendString("[") < 0) {
return -1;
}
@@ -109,7 +109,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
offset += 1;
break;
}
- case PDFOBJ_DICTIONARY: {
+ case CPDF_Object::DICTIONARY: {
if (pFile->AppendString("<<") < 0) {
return -1;
}
@@ -148,7 +148,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
offset += 2;
break;
}
- case PDFOBJ_STREAM: {
+ case CPDF_Object::STREAM: {
const CPDF_Stream* p = pObj->AsStream();
if (PDF_CreatorAppendObject(p->GetDict(), pFile, offset) < 0) {
return -1;
@@ -1109,14 +1109,14 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
return 1;
}
switch (pObj->GetType()) {
- case PDFOBJ_NULL:
+ case CPDF_Object::NULLOBJ:
if (m_File.AppendString(" null") < 0) {
return -1;
}
m_Offset += 5;
break;
- case PDFOBJ_BOOLEAN:
- case PDFOBJ_NUMBER:
+ case CPDF_Object::BOOLEAN:
+ case CPDF_Object::NUMBER:
if (m_File.AppendString(" ") < 0) {
return -1;
}
@@ -1125,7 +1125,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
}
m_Offset += len + 1;
break;
- case PDFOBJ_STRING: {
+ case CPDF_Object::STRING: {
CFX_ByteString str = pObj->GetString();
FX_BOOL bHex = pObj->AsString()->IsHex();
if (!m_pCryptoHandler || !bEncrypt) {
@@ -1148,7 +1148,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
m_Offset += len;
break;
}
- case PDFOBJ_STREAM: {
+ case CPDF_Object::STREAM: {
CPDF_FlateEncoder encoder;
encoder.Initialize(const_cast<CPDF_Stream*>(pObj->AsStream()),
m_bCompress);
@@ -1177,7 +1177,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
m_Offset += len;
break;
}
- case PDFOBJ_NAME: {
+ case CPDF_Object::NAME: {
if (m_File.AppendString("/") < 0) {
return -1;
}
@@ -1188,7 +1188,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
m_Offset += len + 1;
break;
}
- case PDFOBJ_REFERENCE: {
+ case CPDF_Object::REFERENCE: {
if (m_File.AppendString(" ") < 0)
return -1;
if ((len = m_File.AppendDWord(pObj->AsReference()->GetRefObjNum())) < 0)
@@ -1198,7 +1198,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
m_Offset += len + 5;
break;
}
- case PDFOBJ_ARRAY: {
+ case CPDF_Object::ARRAY: {
if (m_File.AppendString("[") < 0) {
return -1;
}
@@ -1229,7 +1229,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
m_Offset += 1;
break;
}
- case PDFOBJ_DICTIONARY: {
+ case CPDF_Object::DICTIONARY: {
if (!m_pCryptoHandler || pObj == m_pEncryptDict) {
return PDF_CreatorAppendObject(pObj, &m_File, m_Offset);
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index b1bd277bb5..5ec79000ac 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -11,15 +11,15 @@
CPDF_PageObject* CPDF_PageObject::Create(int type) {
switch (type) {
- case PDFPAGE_TEXT:
+ case TEXT:
return new CPDF_TextObject;
- case PDFPAGE_IMAGE:
+ case IMAGE:
return new CPDF_ImageObject;
- case PDFPAGE_PATH:
+ case PATH:
return new CPDF_PathObject;
- case PDFPAGE_SHADING:
+ case SHADING:
return new CPDF_ShadingObject;
- case PDFPAGE_FORM:
+ case FORM:
return new CPDF_FormObject;
}
return NULL;
@@ -54,15 +54,17 @@ void CPDF_PageObject::RemoveClipPath() {
}
void CPDF_PageObject::RecalcBBox() {
switch (m_Type) {
- case PDFPAGE_TEXT:
+ case TEXT:
((CPDF_TextObject*)this)->RecalcPositionData();
break;
- case PDFPAGE_PATH:
+ case PATH:
((CPDF_PathObject*)this)->CalcBoundingBox();
break;
- case PDFPAGE_SHADING:
+ case SHADING:
((CPDF_ShadingObject*)this)->CalcBoundingBox();
break;
+ default:
+ break;
}
}
void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) {
@@ -88,13 +90,12 @@ FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
}
CPDF_TextObject::CPDF_TextObject()
- : m_PosX(0),
+ : CPDF_PageObject(TEXT),
+ m_PosX(0),
m_PosY(0),
m_nChars(0),
m_pCharCodes(nullptr),
- m_pCharPos(nullptr) {
- m_Type = PDFPAGE_TEXT;
-}
+ m_pCharPos(nullptr) {}
CPDF_TextObject::~CPDF_TextObject() {
if (m_nChars > 1) {
@@ -607,11 +608,11 @@ void CPDF_TextObject::SetTextState(CPDF_TextState TextState) {
CalcPositionData(nullptr, nullptr, 0);
}
-CPDF_ShadingObject::CPDF_ShadingObject() {
- m_pShading = NULL;
- m_Type = PDFPAGE_SHADING;
-}
+CPDF_ShadingObject::CPDF_ShadingObject()
+ : CPDF_PageObject(SHADING), m_pShading(nullptr) {}
+
CPDF_ShadingObject::~CPDF_ShadingObject() {}
+
void CPDF_ShadingObject::CopyData(const CPDF_PageObject* pSrc) {
CPDF_ShadingObject* pSrcObj = (CPDF_ShadingObject*)pSrc;
m_pShading = pSrcObj->m_pShading;
@@ -623,6 +624,7 @@ void CPDF_ShadingObject::CopyData(const CPDF_PageObject* pSrc) {
}
m_Matrix = pSrcObj->m_Matrix;
}
+
void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
if (!m_ClipPath.IsNull()) {
m_ClipPath.GetModify();
@@ -635,6 +637,7 @@ void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
}
}
+
void CPDF_ShadingObject::CalcBoundingBox() {
if (m_ClipPath.IsNull()) {
return;
@@ -645,6 +648,7 @@ void CPDF_ShadingObject::CalcBoundingBox() {
m_Right = rect.right;
m_Top = rect.top;
}
+
CPDF_FormObject::~CPDF_FormObject() {
delete m_pForm;
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp
index edcb3cab2d..d1e6687999 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp
@@ -9,10 +9,8 @@
#include "core/include/fpdfapi/fpdf_page.h"
#include "core/include/fpdfapi/fpdf_pageobj.h"
-CPDF_ImageObject::CPDF_ImageObject() {
- m_pImage = NULL;
- m_Type = PDFPAGE_IMAGE;
-}
+CPDF_ImageObject::CPDF_ImageObject()
+ : CPDF_PageObject(IMAGE), m_pImage(nullptr) {}
CPDF_ImageObject::~CPDF_ImageObject() {
if (!m_pImage) {
return;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index c5e407d4ea..152fac8c37 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -209,7 +209,7 @@ void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) {
m_ParamBuf1[index].m_pObject =
new CPDF_Name(PDF_NameDecode(CFX_ByteStringC(name, len)));
} else {
- m_ParamBuf1[index].m_Type = PDFOBJ_NAME;
+ m_ParamBuf1[index].m_Type = CPDF_Object::NAME;
if (!FXSYS_memchr(name, '#', len)) {
FXSYS_memcpy(m_ParamBuf1[index].m_Name.m_Buffer, name, len);
m_ParamBuf1[index].m_Name.m_Len = len;
@@ -224,7 +224,7 @@ void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) {
void CPDF_StreamContentParser::AddNumberParam(const FX_CHAR* str, int len) {
int index = GetNextParamPos();
- m_ParamBuf1[index].m_Type = PDFOBJ_NUMBER;
+ m_ParamBuf1[index].m_Type = CPDF_Object::NUMBER;
FX_atonum(CFX_ByteStringC(str, len), m_ParamBuf1[index].m_Number.m_bInteger,
&m_ParamBuf1[index].m_Number.m_Integer);
}
@@ -258,7 +258,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(FX_DWORD index) {
real_index -= PARAM_BUF_SIZE;
}
ContentParam& param = m_ParamBuf1[real_index];
- if (param.m_Type == PDFOBJ_NUMBER) {
+ if (param.m_Type == CPDF_Object::NUMBER) {
CPDF_Number* pNumber = param.m_Number.m_bInteger
? new CPDF_Number(param.m_Number.m_Integer)
: new CPDF_Number(param.m_Number.m_Float);
@@ -267,7 +267,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(FX_DWORD index) {
param.m_pObject = pNumber;
return pNumber;
}
- if (param.m_Type == PDFOBJ_NAME) {
+ if (param.m_Type == CPDF_Object::NAME) {
CPDF_Name* pName = new CPDF_Name(
CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len));
param.m_Type = 0;
@@ -290,7 +290,7 @@ CFX_ByteString CPDF_StreamContentParser::GetString(FX_DWORD index) {
real_index -= PARAM_BUF_SIZE;
}
ContentParam& param = m_ParamBuf1[real_index];
- if (param.m_Type == PDFOBJ_NAME) {
+ if (param.m_Type == CPDF_Object::NAME) {
return CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len);
}
if (param.m_Type == 0 && param.m_pObject) {
@@ -308,7 +308,7 @@ FX_FLOAT CPDF_StreamContentParser::GetNumber(FX_DWORD index) {
real_index -= PARAM_BUF_SIZE;
}
ContentParam& param = m_ParamBuf1[real_index];
- if (param.m_Type == PDFOBJ_NUMBER) {
+ if (param.m_Type == CPDF_Object::NUMBER) {
return param.m_Number.m_bInteger ? (FX_FLOAT)param.m_Number.m_Integer
: param.m_Number.m_Float;
}
@@ -1759,7 +1759,7 @@ void CPDF_StreamContentParser::ParsePathObject() {
void PDF_ReplaceAbbr(CPDF_Object* pObj) {
switch (pObj->GetType()) {
- case PDFOBJ_DICTIONARY: {
+ case CPDF_Object::DICTIONARY: {
CPDF_Dictionary* pDict = pObj->AsDictionary();
std::vector<AbbrReplacementOp> replacements;
for (const auto& it : *pDict) {
@@ -1799,7 +1799,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
}
break;
}
- case PDFOBJ_ARRAY: {
+ case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetElement(i);
@@ -1816,5 +1816,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
}
break;
}
+ default:
+ break;
}
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 298f28235f..7b96c4f02c 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -855,7 +855,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
continue;
}
CPDF_Path ClipPath = pObj->m_ClipPath.GetPath(0);
- if (!ClipPath.IsRect() || pObj->m_Type == PDFPAGE_SHADING) {
+ if (!ClipPath.IsRect() || pObj->m_Type == CPDF_PageObject::SHADING) {
continue;
}
CFX_FloatRect old_rect(ClipPath.GetPointX(0), ClipPath.GetPointY(0),
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index 45f93d0afe..15edaf1b66 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -26,19 +26,19 @@ void CPDF_Object::Release() {
}
void CPDF_Object::Destroy() {
switch (m_Type) {
- case PDFOBJ_STRING:
+ case STRING:
delete AsString();
break;
- case PDFOBJ_NAME:
+ case NAME:
delete AsName();
break;
- case PDFOBJ_ARRAY:
+ case ARRAY:
delete AsArray();
break;
- case PDFOBJ_DICTIONARY:
+ case DICTIONARY:
delete AsDictionary();
break;
- case PDFOBJ_STREAM:
+ case STREAM:
delete AsStream();
break;
default:
@@ -61,14 +61,16 @@ CFX_ByteString CPDF_Object::GetString() const {
const CPDF_Object* obj = GetBasicObject();
if (obj) {
switch (obj->GetType()) {
- case PDFOBJ_BOOLEAN:
+ case BOOLEAN:
return obj->AsBoolean()->GetString();
- case PDFOBJ_NUMBER:
+ case NUMBER:
return obj->AsNumber()->GetString();
- case PDFOBJ_STRING:
+ case STRING:
return obj->AsString()->GetString();
- case PDFOBJ_NAME:
+ case NAME:
return obj->AsName()->GetString();
+ default:
+ break;
}
}
return CFX_ByteString();
@@ -78,11 +80,11 @@ CFX_ByteStringC CPDF_Object::GetConstString() const {
const CPDF_Object* obj = GetBasicObject();
if (obj) {
FX_DWORD type = obj->GetType();
- if (type == PDFOBJ_STRING) {
+ if (type == STRING) {
CFX_ByteString str = obj->AsString()->GetString();
return CFX_ByteStringC(str);
}
- if (type == PDFOBJ_NAME) {
+ if (type == NAME) {
CFX_ByteString name = obj->AsName()->GetString();
return CFX_ByteStringC(name);
}
@@ -92,7 +94,7 @@ CFX_ByteStringC CPDF_Object::GetConstString() const {
FX_FLOAT CPDF_Object::GetNumber() const {
const CPDF_Object* obj = GetBasicObject();
- if (obj && obj->GetType() == PDFOBJ_NUMBER)
+ if (obj && obj->GetType() == NUMBER)
return obj->AsNumber()->GetNumber();
return 0;
}
@@ -105,9 +107,9 @@ int CPDF_Object::GetInteger() const {
const CPDF_Object* obj = GetBasicObject();
if (obj) {
FX_DWORD type = obj->GetType();
- if (type == PDFOBJ_BOOLEAN)
+ if (type == BOOLEAN)
return obj->AsBoolean()->GetValue();
- if (type == PDFOBJ_NUMBER)
+ if (type == NUMBER)
return obj->AsNumber()->GetInteger();
}
return 0;
@@ -117,12 +119,12 @@ CPDF_Dictionary* CPDF_Object::GetDict() const {
const CPDF_Object* obj = GetBasicObject();
if (obj) {
FX_DWORD type = obj->GetType();
- if (type == PDFOBJ_DICTIONARY) {
+ if (type == DICTIONARY) {
// The method should be made non-const if we want to not be const.
// See bug #234.
return const_cast<CPDF_Dictionary*>(obj->AsDictionary());
}
- if (type == PDFOBJ_STREAM)
+ if (type == STREAM)
return obj->AsStream()->GetDict();
}
return nullptr;
@@ -136,18 +138,20 @@ CPDF_Array* CPDF_Object::GetArray() const {
void CPDF_Object::SetString(const CFX_ByteString& str) {
switch (m_Type) {
- case PDFOBJ_BOOLEAN:
+ case BOOLEAN:
AsBoolean()->m_bValue = (str == "true");
return;
- case PDFOBJ_NUMBER:
+ case NUMBER:
AsNumber()->SetString(str);
return;
- case PDFOBJ_STRING:
+ case STRING:
AsString()->m_String = str;
return;
- case PDFOBJ_NAME:
+ case NAME:
AsName()->m_Name = str;
return;
+ default:
+ break;
}
ASSERT(FALSE);
}
@@ -164,23 +168,23 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const {
return FALSE;
}
switch (m_Type) {
- case PDFOBJ_BOOLEAN:
+ case BOOLEAN:
return AsBoolean()->Identical(pOther->AsBoolean());
- case PDFOBJ_NUMBER:
+ case NUMBER:
return AsNumber()->Identical(pOther->AsNumber());
- case PDFOBJ_STRING:
+ case STRING:
return AsString()->Identical(pOther->AsString());
- case PDFOBJ_NAME:
+ case NAME:
return AsName()->Identical(pOther->AsName());
- case PDFOBJ_ARRAY:
+ case ARRAY:
return AsArray()->Identical(pOther->AsArray());
- case PDFOBJ_DICTIONARY:
+ case DICTIONARY:
return AsDictionary()->Identical(pOther->AsDictionary());
- case PDFOBJ_NULL:
+ case NULLOBJ:
return TRUE;
- case PDFOBJ_STREAM:
+ case STREAM:
return AsStream()->Identical(pOther->AsStream());
- case PDFOBJ_REFERENCE:
+ case REFERENCE:
return AsReference()->Identical(pOther->AsReference());
}
return FALSE;
@@ -202,20 +206,20 @@ CPDF_Object* CPDF_Object::Clone(FX_BOOL bDirect) const {
CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
std::set<FX_DWORD>* visited) const {
switch (m_Type) {
- case PDFOBJ_BOOLEAN:
+ case BOOLEAN:
return new CPDF_Boolean(AsBoolean()->m_bValue);
- case PDFOBJ_NUMBER: {
+ case NUMBER: {
const CPDF_Number* pThis = AsNumber();
return new CPDF_Number(pThis->m_bInteger ? pThis->m_Integer
: pThis->m_Float);
}
- case PDFOBJ_STRING: {
+ case STRING: {
const CPDF_String* pString = AsString();
return new CPDF_String(pString->m_String, pString->IsHex());
}
- case PDFOBJ_NAME:
+ case NAME:
return new CPDF_Name(AsName()->m_Name);
- case PDFOBJ_ARRAY: {
+ case ARRAY: {
CPDF_Array* pCopy = new CPDF_Array();
const CPDF_Array* pThis = AsArray();
int n = pThis->GetCount();
@@ -225,7 +229,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
}
return pCopy;
}
- case PDFOBJ_DICTIONARY: {
+ case DICTIONARY: {
CPDF_Dictionary* pCopy = new CPDF_Dictionary();
const CPDF_Dictionary* pThis = AsDictionary();
for (const auto& it : *pThis) {
@@ -234,10 +238,10 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
}
return pCopy;
}
- case PDFOBJ_NULL: {
+ case NULLOBJ: {
return new CPDF_Null;
}
- case PDFOBJ_STREAM: {
+ case STREAM: {
const CPDF_Stream* pThis = AsStream();
CPDF_StreamAcc acc;
acc.LoadAllData(pThis, TRUE);
@@ -248,7 +252,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
}
return new CPDF_Stream(acc.DetachData(), streamSize, pDict);
}
- case PDFOBJ_REFERENCE: {
+ case REFERENCE: {
const CPDF_Reference* pRef = AsReference();
FX_DWORD obj_num = pRef->GetRefObjNum();
if (bDirect && !pdfium::ContainsKey(*visited, obj_num)) {
@@ -357,13 +361,12 @@ const CPDF_String* CPDF_Object::AsString() const {
}
CPDF_Number::CPDF_Number(int value)
- : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(TRUE), m_Integer(value) {}
+ : CPDF_Object(NUMBER), m_bInteger(TRUE), m_Integer(value) {}
CPDF_Number::CPDF_Number(FX_FLOAT value)
- : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(FALSE), m_Float(value) {}
+ : CPDF_Object(NUMBER), m_bInteger(FALSE), m_Float(value) {}
-CPDF_Number::CPDF_Number(const CFX_ByteStringC& str)
- : CPDF_Object(PDFOBJ_NUMBER) {
+CPDF_Number::CPDF_Number(const CFX_ByteStringC& str) : CPDF_Object(NUMBER) {
FX_atonum(str, m_bInteger, &m_Integer);
}
@@ -382,7 +385,7 @@ void CPDF_Number::SetNumber(FX_FLOAT value) {
m_Float = value;
}
CPDF_String::CPDF_String(const CFX_WideString& str)
- : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) {
+ : CPDF_Object(STRING), m_bHex(FALSE) {
m_String = PDF_EncodeText(str);
}
CPDF_Array::~CPDF_Array() {
@@ -675,7 +678,7 @@ void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) {
m_Map.erase(it);
}
void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) {
- ASSERT(m_Type == PDFOBJ_DICTIONARY);
+ ASSERT(m_Type == DICTIONARY);
auto it = m_Map.find(key);
if (it == m_Map.end())
return;
@@ -685,7 +688,7 @@ void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) {
}
void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey,
const CFX_ByteStringC& newkey) {
- ASSERT(m_Type == PDFOBJ_DICTIONARY);
+ ASSERT(m_Type == DICTIONARY);
auto old_it = m_Map.find(oldkey);
if (old_it == m_Map.end())
return;
@@ -768,7 +771,7 @@ void CPDF_Dictionary::SetAtMatrix(const CFX_ByteStringC& key,
SetAt(key, pArray);
}
CPDF_Stream::CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict)
- : CPDF_Object(PDFOBJ_STREAM),
+ : CPDF_Object(STREAM),
m_pDict(pDict),
m_dwSize(size),
m_GenNum(kMemoryBasedGenNum),
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 9f6665d025..c0150b5435 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2940,15 +2940,15 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
int32_t type = pObj->GetType();
switch (type) {
- case PDFOBJ_ARRAY: {
+ case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->GetArray();
for (FX_DWORD k = 0; k < pArray->GetCount(); k++) {
new_obj_array.Add(pArray->GetElement(k));
}
} break;
- case PDFOBJ_STREAM:
+ case CPDF_Object::STREAM:
pObj = pObj->GetDict();
- case PDFOBJ_DICTIONARY: {
+ case CPDF_Object::DICTIONARY: {
CPDF_Dictionary* pDict = pObj->GetDict();
if (pDict && pDict->GetString("Type") == "Page" && !bParsePage) {
continue;
@@ -2961,7 +2961,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
}
}
} break;
- case PDFOBJ_REFERENCE: {
+ case CPDF_Object::REFERENCE: {
CPDF_Reference* pRef = pObj->AsReference();
FX_DWORD dwNum = pRef->GetRefObjNum();
FX_FILESIZE offset;
@@ -3348,10 +3348,10 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) {
return TRUE;
}
switch (pKids->GetType()) {
- case PDFOBJ_REFERENCE:
+ case CPDF_Object::REFERENCE:
m_PageObjList.Add(pKids->AsReference()->GetRefObjNum());
break;
- case PDFOBJ_ARRAY: {
+ case CPDF_Object::ARRAY: {
CPDF_Array* pKidsArray = pKids->AsArray();
for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
if (CPDF_Reference* pRef = ToReference(pKidsArray->GetElement(i)))
@@ -4042,13 +4042,13 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo,
return TRUE;
}
switch (pKids->GetType()) {
- case PDFOBJ_REFERENCE: {
+ case CPDF_Object::REFERENCE: {
CPDF_Reference* pKid = pKids->AsReference();
CPDF_PageNode* pNode = new CPDF_PageNode();
pPageNode->m_childNode.Add(pNode);
pNode->m_dwPageNo = pKid->GetRefObjNum();
} break;
- case PDFOBJ_ARRAY: {
+ case CPDF_Object::ARRAY: {
CPDF_Array* pKidsArray = pKids->AsArray();
for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
CPDF_Reference* pKid = ToReference(pKidsArray->GetElement(i));
@@ -4851,7 +4851,7 @@ FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
return FALSE;
CPDF_Dictionary* pDict = pHintStream->GetDict();
CPDF_Object* pOffset = pDict ? pDict->GetElement("S") : nullptr;
- if (!pOffset || pOffset->GetType() != PDFOBJ_NUMBER)
+ if (!pOffset || pOffset->GetType() != CPDF_Object::NUMBER)
return FALSE;
int shared_hint_table_offset = pOffset->GetInteger();
CPDF_StreamAcc acc;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index b3172dd848..141618030a 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -338,26 +338,26 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
return buf;
}
switch (pObj->GetType()) {
- case PDFOBJ_NULL:
+ case CPDF_Object::NULLOBJ:
buf << " null";
break;
- case PDFOBJ_BOOLEAN:
- case PDFOBJ_NUMBER:
+ case CPDF_Object::BOOLEAN:
+ case CPDF_Object::NUMBER:
buf << " " << pObj->GetString();
break;
- case PDFOBJ_STRING:
+ case CPDF_Object::STRING:
buf << PDF_EncodeString(pObj->GetString(), pObj->AsString()->IsHex());
break;
- case PDFOBJ_NAME: {
+ case CPDF_Object::NAME: {
CFX_ByteString str = pObj->GetString();
buf << "/" << PDF_NameEncode(str);
break;
}
- case PDFOBJ_REFERENCE: {
+ case CPDF_Object::REFERENCE: {
buf << " " << pObj->AsReference()->GetRefObjNum() << " 0 R ";
break;
}
- case PDFOBJ_ARRAY: {
+ case CPDF_Object::ARRAY: {
const CPDF_Array* p = pObj->AsArray();
buf << "[";
for (FX_DWORD i = 0; i < p->GetCount(); i++) {
@@ -371,7 +371,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
buf << "]";
break;
}
- case PDFOBJ_DICTIONARY: {
+ case CPDF_Object::DICTIONARY: {
const CPDF_Dictionary* p = pObj->AsDictionary();
buf << "<<";
for (const auto& it : *p) {
@@ -387,7 +387,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
buf << ">>";
break;
}
- case PDFOBJ_STREAM: {
+ case CPDF_Object::STREAM: {
const CPDF_Stream* p = pObj->AsStream();
buf << p->GetDict() << "stream\r\n";
CPDF_StreamAcc acc;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 583b19f7ab..28a5fe1eef 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -312,7 +312,7 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj,
if (ProcessTransparency(pObj, pObj2Device))
return FALSE;
- if (pObj->m_Type == PDFPAGE_IMAGE) {
+ if (pObj->m_Type == CPDF_PageObject::IMAGE) {
m_pObjectRenderer.reset(IPDF_ObjectRenderer::Create(pObj->m_Type));
if (!m_pObjectRenderer->Start(this, pObj, pObj2Device, FALSE)) {
if (!m_pObjectRenderer->m_Result)
@@ -328,7 +328,7 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj,
}
IPDF_ObjectRenderer* IPDF_ObjectRenderer::Create(int type) {
- if (type != PDFPAGE_IMAGE) {
+ if (type != CPDF_PageObject::IMAGE) {
return NULL;
}
return new CPDF_ImageRenderer;
@@ -381,19 +381,19 @@ void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device) {
FX_BOOL bRet = FALSE;
switch (pObj->m_Type) {
- case PDFPAGE_TEXT:
+ case CPDF_PageObject::TEXT:
bRet = ProcessText((CPDF_TextObject*)pObj, pObj2Device, NULL);
break;
- case PDFPAGE_PATH:
+ case CPDF_PageObject::PATH:
bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device);
break;
- case PDFPAGE_IMAGE:
+ case CPDF_PageObject::IMAGE:
bRet = ProcessImage((CPDF_ImageObject*)pObj, pObj2Device);
break;
- case PDFPAGE_SHADING:
+ case CPDF_PageObject::SHADING:
bRet = ProcessShading((CPDF_ShadingObject*)pObj, pObj2Device);
break;
- case PDFPAGE_FORM:
+ case CPDF_PageObject::FORM:
bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device);
break;
}
@@ -405,15 +405,17 @@ FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device) {
FX_BOOL bRet = FALSE;
switch (pObj->m_Type) {
- case PDFPAGE_PATH:
+ case CPDF_PageObject::PATH:
bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device);
break;
- case PDFPAGE_IMAGE:
+ case CPDF_PageObject::IMAGE:
bRet = ProcessImage((CPDF_ImageObject*)pObj, pObj2Device);
break;
- case PDFPAGE_FORM:
+ case CPDF_PageObject::FORM:
bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device);
break;
+ default:
+ break;
}
return bRet;
}
@@ -429,7 +431,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj,
return;
}
int res = 300;
- if (pObj->m_Type == PDFPAGE_IMAGE &&
+ if (pObj->m_Type == CPDF_PageObject::IMAGE &&
m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) {
res = 0;
}
@@ -441,7 +443,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj,
matrix.Concat(*buffer.GetMatrix());
GetScaledMatrix(matrix);
CPDF_Dictionary* pFormResource = NULL;
- if (pObj->m_Type == PDFPAGE_FORM) {
+ if (pObj->m_Type == CPDF_PageObject::FORM) {
CPDF_FormObject* pFormObj = (CPDF_FormObject*)pObj;
if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) {
pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources");
@@ -725,7 +727,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
CPDF_Dictionary* pSMaskDict =
pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : NULL;
if (pSMaskDict) {
- if (pPageObj->m_Type == PDFPAGE_IMAGE &&
+ if (pPageObj->m_Type == CPDF_PageObject::IMAGE &&
((CPDF_ImageObject*)pPageObj)->m_pImage->GetDict()->KeyExist("SMask")) {
pSMaskDict = NULL;
}
@@ -734,7 +736,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
FX_FLOAT group_alpha = 1.0f;
int Transparency = m_Transparency;
FX_BOOL bGroupTransparent = FALSE;
- if (pPageObj->m_Type == PDFPAGE_FORM) {
+ if (pPageObj->m_Type == CPDF_PageObject::FORM) {
CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
const CPDF_GeneralStateData* pStateData =
pFormObj->m_GeneralState.GetObject();
@@ -754,7 +756,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
bTextClip = TRUE;
}
if ((m_Options.m_Flags & RENDER_OVERPRINT) &&
- pPageObj->m_Type == PDFPAGE_IMAGE && pGeneralState &&
+ pPageObj->m_Type == CPDF_PageObject::IMAGE && pGeneralState &&
pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) {
CPDF_Document* pDocument = NULL;
CPDF_Page* pPage = NULL;
@@ -874,7 +876,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
bitmap->MultiplyAlpha((int32_t)(group_alpha * 255));
}
Transparency = m_Transparency;
- if (pPageObj->m_Type == PDFPAGE_FORM) {
+ if (pPageObj->m_Type == CPDF_PageObject::FORM) {
Transparency |= PDFTRANS_GROUP;
}
CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type,
@@ -1118,13 +1120,13 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
pPause)) {
return;
}
- if (pCurObj->m_Type == PDFPAGE_IMAGE &&
+ if (pCurObj->m_Type == CPDF_PageObject::IMAGE &&
m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
m_pContext->GetPageCache()->CacheOptimization(
m_pRenderStatus->m_Options.m_dwLimitCacheSize);
}
- if (pCurObj->m_Type == PDFPAGE_FORM ||
- pCurObj->m_Type == PDFPAGE_SHADING) {
+ if (pCurObj->m_Type == CPDF_PageObject::FORM ||
+ pCurObj->m_Type == CPDF_PageObject::SHADING) {
objs_to_go = 0;
} else {
objs_to_go--;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index c1bb6f6813..6aeed548a3 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -919,12 +919,12 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
return;
}
m_pDevice->SaveState();
- if (pPageObj->m_Type == PDFPAGE_PATH) {
+ if (pPageObj->m_Type == CPDF_PageObject::PATH) {
if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) {
m_pDevice->RestoreState();
return;
}
- } else if (pPageObj->m_Type == PDFPAGE_IMAGE) {
+ } else if (pPageObj->m_Type == CPDF_PageObject::IMAGE) {
FX_RECT rect = pPageObj->GetBBox(pObj2Device);
m_pDevice->SetClip_Rect(&rect);
} else {
@@ -1001,12 +1001,12 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
return;
}
m_pDevice->SaveState();
- if (pPageObj->m_Type == PDFPAGE_PATH) {
+ if (pPageObj->m_Type == CPDF_PageObject::PATH) {
if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) {
m_pDevice->RestoreState();
return;
}
- } else if (pPageObj->m_Type == PDFPAGE_IMAGE) {
+ } else if (pPageObj->m_Type == CPDF_PageObject::IMAGE) {
FX_RECT rect = pPageObj->GetBBox(pObj2Device);
m_pDevice->SetClip_Rect(&rect);
} else {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 05a5e040e3..a40284a1f8 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -319,7 +319,7 @@ FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) {
if (m_pForm->CountObjects() == 1 && !m_bColored) {
CPDF_PageObject* pPageObj =
m_pForm->GetObjectAt(m_pForm->GetFirstObjectPosition());
- if (pPageObj->m_Type == PDFPAGE_IMAGE) {
+ if (pPageObj->m_Type == CPDF_PageObject::IMAGE) {
CPDF_ImageObject* pImage = (CPDF_ImageObject*)pPageObj;
m_ImageMatrix = pImage->m_Matrix;
const CFX_DIBSource* pSource = pImage->m_pImage->LoadDIBSource();