summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-26 11:47:43 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-26 11:47:43 -0800
commit66a9dc9dd65ed2b9c7ede448d046b770140f16d5 (patch)
tree9d44a3134e9cdc9e13004a633fd82a417410b102 /core
parente56b3ad57573c677ad84bf4a2ffd649d6134b990 (diff)
downloadpdfium-66a9dc9dd65ed2b9c7ede448d046b770140f16d5.tar.xz
War on #defines, part 1.
Make the two fundamental "object" types be enums. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1632143002 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_objects.h72
-rw-r--r--core/include/fpdfapi/fpdf_pageobj.h42
-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
-rw-r--r--core/src/fpdfdoc/doc_formfield.cpp8
-rw-r--r--core/src/fpdftext/fpdf_text.cpp4
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp12
-rw-r--r--core/src/fpdftext/fpdf_text_search.cpp4
18 files changed, 208 insertions, 215 deletions
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index d0617e01ab..ca4bb51fda 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -30,20 +30,21 @@ class CPDF_StreamFilter;
class CPDF_String;
class IFX_FileRead;
-#define PDFOBJ_INVALID 0
-#define PDFOBJ_BOOLEAN 1
-#define PDFOBJ_NUMBER 2
-#define PDFOBJ_STRING 3
-#define PDFOBJ_NAME 4
-#define PDFOBJ_ARRAY 5
-#define PDFOBJ_DICTIONARY 6
-#define PDFOBJ_STREAM 7
-#define PDFOBJ_NULL 8
-#define PDFOBJ_REFERENCE 9
-
class CPDF_Object {
public:
- int GetType() const { return m_Type; }
+ enum Type {
+ BOOLEAN = 1,
+ NUMBER,
+ STRING,
+ NAME,
+ ARRAY,
+ DICTIONARY,
+ STREAM,
+ NULLOBJ,
+ REFERENCE
+ };
+
+ Type GetType() const { return m_Type; }
FX_DWORD GetObjNum() const { return m_ObjNum; }
FX_DWORD GetGenNum() const { return m_GenNum; }
@@ -68,14 +69,14 @@ class CPDF_Object {
void SetString(const CFX_ByteString& str);
void SetUnicodeText(const FX_WCHAR* pUnicodes, int len = -1);
- bool IsArray() const { return m_Type == PDFOBJ_ARRAY; }
- bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; }
- bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; }
- bool IsName() const { return m_Type == PDFOBJ_NAME; }
- bool IsNumber() const { return m_Type == PDFOBJ_NUMBER; }
- bool IsReference() const { return m_Type == PDFOBJ_REFERENCE; }
- bool IsStream() const { return m_Type == PDFOBJ_STREAM; }
- bool IsString() const { return m_Type == PDFOBJ_STRING; }
+ bool IsArray() const { return m_Type == ARRAY; }
+ bool IsBoolean() const { return m_Type == BOOLEAN; }
+ bool IsDictionary() const { return m_Type == DICTIONARY; }
+ bool IsName() const { return m_Type == NAME; }
+ bool IsNumber() const { return m_Type == NUMBER; }
+ bool IsReference() const { return m_Type == REFERENCE; }
+ bool IsStream() const { return m_Type == STREAM; }
+ bool IsString() const { return m_Type == STRING; }
CPDF_Array* AsArray();
const CPDF_Array* AsArray() const;
@@ -95,14 +96,13 @@ class CPDF_Object {
const CPDF_String* AsString() const;
protected:
- explicit CPDF_Object(FX_DWORD type)
- : m_Type(type), m_ObjNum(0), m_GenNum(0) {}
+ explicit CPDF_Object(Type type) : m_Type(type), m_ObjNum(0), m_GenNum(0) {}
~CPDF_Object() {}
void Destroy();
const CPDF_Object* GetBasicObject() const;
- FX_DWORD m_Type;
+ const Type m_Type;
FX_DWORD m_ObjNum;
FX_DWORD m_GenNum;
@@ -111,15 +111,14 @@ class CPDF_Object {
friend class CPDF_SyntaxParser;
private:
- CPDF_Object(const CPDF_Object& src) {}
CPDF_Object* CloneInternal(FX_BOOL bDirect,
std::set<FX_DWORD>* visited) const;
};
class CPDF_Boolean : public CPDF_Object {
public:
- CPDF_Boolean() : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(false) {}
+ CPDF_Boolean() : CPDF_Object(BOOLEAN), m_bValue(false) {}
explicit CPDF_Boolean(FX_BOOL value)
- : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(value) {}
+ : CPDF_Object(BOOLEAN), m_bValue(value) {}
FX_BOOL Identical(CPDF_Boolean* pOther) const {
return m_bValue == pOther->m_bValue;
@@ -141,7 +140,7 @@ inline const CPDF_Boolean* ToBoolean(const CPDF_Object* obj) {
class CPDF_Number : public CPDF_Object {
public:
- CPDF_Number() : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(TRUE), m_Integer(0) {}
+ CPDF_Number() : CPDF_Object(NUMBER), m_bInteger(TRUE), m_Integer(0) {}
explicit CPDF_Number(int value);
@@ -190,10 +189,10 @@ inline const CPDF_Number* ToNumber(const CPDF_Object* obj) {
class CPDF_String : public CPDF_Object {
public:
- CPDF_String() : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) {}
+ CPDF_String() : CPDF_Object(STRING), m_bHex(FALSE) {}
CPDF_String(const CFX_ByteString& str, FX_BOOL bHex)
- : CPDF_Object(PDFOBJ_STRING), m_String(str), m_bHex(bHex) {}
+ : CPDF_Object(STRING), m_String(str), m_bHex(bHex) {}
explicit CPDF_String(const CFX_WideString& str);
@@ -221,11 +220,10 @@ inline const CPDF_String* ToString(const CPDF_Object* obj) {
class CPDF_Name : public CPDF_Object {
public:
explicit CPDF_Name(const CFX_ByteString& str)
- : CPDF_Object(PDFOBJ_NAME), m_Name(str) {}
+ : CPDF_Object(NAME), m_Name(str) {}
explicit CPDF_Name(const CFX_ByteStringC& str)
- : CPDF_Object(PDFOBJ_NAME), m_Name(str) {}
- explicit CPDF_Name(const FX_CHAR* str)
- : CPDF_Object(PDFOBJ_NAME), m_Name(str) {}
+ : CPDF_Object(NAME), m_Name(str) {}
+ explicit CPDF_Name(const FX_CHAR* str) : CPDF_Object(NAME), m_Name(str) {}
CFX_ByteString GetString() const { return m_Name; }
@@ -246,7 +244,7 @@ inline const CPDF_Name* ToName(const CPDF_Object* obj) {
class CPDF_Array : public CPDF_Object {
public:
- CPDF_Array() : CPDF_Object(PDFOBJ_ARRAY) {}
+ CPDF_Array() : CPDF_Object(ARRAY) {}
FX_DWORD GetCount() const { return m_Objects.GetSize(); }
@@ -324,7 +322,7 @@ class CPDF_Dictionary : public CPDF_Object {
using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator;
using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator;
- CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) {}
+ CPDF_Dictionary() : CPDF_Object(DICTIONARY) {}
CPDF_Object* GetElement(const CFX_ByteStringC& key) const;
@@ -527,13 +525,13 @@ class CPDF_StreamAcc {
class CPDF_Null : public CPDF_Object {
public:
- CPDF_Null() : CPDF_Object(PDFOBJ_NULL) {}
+ CPDF_Null() : CPDF_Object(NULLOBJ) {}
};
class CPDF_Reference : public CPDF_Object {
public:
CPDF_Reference(CPDF_IndirectObjectHolder* pDoc, int objnum)
- : CPDF_Object(PDFOBJ_REFERENCE), m_pObjList(pDoc), m_RefObjNum(objnum) {}
+ : CPDF_Object(REFERENCE), m_pObjList(pDoc), m_RefObjNum(objnum) {}
CPDF_IndirectObjectHolder* GetObjList() const { return m_pObjList; }
diff --git a/core/include/fpdfapi/fpdf_pageobj.h b/core/include/fpdfapi/fpdf_pageobj.h
index 2b6f78e63f..ca062b3461 100644
--- a/core/include/fpdfapi/fpdf_pageobj.h
+++ b/core/include/fpdfapi/fpdf_pageobj.h
@@ -328,12 +328,6 @@ class CPDF_ContentMark : public CFX_CountRef<CPDF_ContentMarkData> {
CPDF_Dictionary*& pDict) const;
};
-#define PDFPAGE_TEXT 1
-#define PDFPAGE_PATH 2
-#define PDFPAGE_IMAGE 3
-#define PDFPAGE_SHADING 4
-#define PDFPAGE_FORM 5
-
class CPDF_GraphicStates {
public:
void CopyStates(const CPDF_GraphicStates& src);
@@ -353,47 +347,42 @@ class CPDF_GraphicStates {
class CPDF_PageObject : public CPDF_GraphicStates {
public:
+ enum Type {
+ TEXT = 1,
+ PATH,
+ IMAGE,
+ SHADING,
+ FORM,
+ };
+
static CPDF_PageObject* Create(int type);
virtual ~CPDF_PageObject();
CPDF_PageObject* Clone() const;
-
void Copy(const CPDF_PageObject* pSrcObject);
virtual void Transform(const CFX_Matrix& matrix) = 0;
void RemoveClipPath();
-
void AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
-
void CopyClipPath(CPDF_PageObject* pObj);
-
void TransformClipPath(CFX_Matrix& matrix);
-
void TransformGeneralState(CFX_Matrix& matrix);
-
void SetColorState(CPDF_ColorState state) { m_ColorState = state; }
-
FX_RECT GetBBox(const CFX_Matrix* pMatrix) const;
- int m_Type;
-
+ const Type m_Type;
FX_FLOAT m_Left;
-
FX_FLOAT m_Right;
-
FX_FLOAT m_Top;
-
FX_FLOAT m_Bottom;
-
CPDF_ContentMark m_ContentMark;
protected:
virtual void CopyData(const CPDF_PageObject* pSrcObject) = 0;
void RecalcBBox();
-
- CPDF_PageObject() {}
+ CPDF_PageObject(Type type) : m_Type(type) {}
};
struct CPDF_TextObjectItem {
@@ -490,7 +479,7 @@ class CPDF_TextObject : public CPDF_PageObject {
class CPDF_PathObject : public CPDF_PageObject {
public:
- CPDF_PathObject() { m_Type = PDFPAGE_PATH; }
+ CPDF_PathObject() : CPDF_PageObject(PATH) {}
~CPDF_PathObject() override {}
void Transform(const CFX_Matrix& maxtrix) override;
@@ -547,20 +536,15 @@ class CPDF_ShadingObject : public CPDF_PageObject {
class CPDF_FormObject : public CPDF_PageObject {
public:
- CPDF_FormObject() {
- m_Type = PDFPAGE_FORM;
- m_pForm = NULL;
- }
+ CPDF_FormObject() : CPDF_PageObject(FORM), m_pForm(nullptr) {}
~CPDF_FormObject() override;
void Transform(const CFX_Matrix& matrix) override;
+ void CalcBoundingBox();
CPDF_Form* m_pForm;
-
CFX_Matrix m_FormMatrix;
- void CalcBoundingBox();
-
protected:
void CopyData(const CPDF_PageObject* pSrcObject) override;
};
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();
diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp
index 46ea01083d..dc31938b16 100644
--- a/core/src/fpdfdoc/doc_formfield.cpp
+++ b/core/src/fpdfdoc/doc_formfield.cpp
@@ -300,14 +300,16 @@ CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) {
}
}
switch (pValue->GetType()) {
- case PDFOBJ_STRING:
- case PDFOBJ_STREAM:
+ case CPDF_Object::STRING:
+ case CPDF_Object::STREAM:
return pValue->GetUnicodeText();
- case PDFOBJ_ARRAY:
+ case CPDF_Object::ARRAY:
pValue = pValue->AsArray()->GetElementValue(0);
if (pValue)
return pValue->GetUnicodeText();
break;
+ default:
+ break;
}
return CFX_WideString();
}
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index 4aea797c39..3871d25177 100644
--- a/core/src/fpdftext/fpdf_text.cpp
+++ b/core/src/fpdftext/fpdf_text.cpp
@@ -48,7 +48,7 @@ CTextPage::~CTextPage() {
}
}
void CTextPage::ProcessObject(CPDF_PageObject* pObject) {
- if (pObject->m_Type != PDFPAGE_TEXT) {
+ if (pObject->m_Type != CPDF_PageObject::TEXT) {
return;
}
CPDF_TextObject* pText = (CPDF_TextObject*)pObject;
@@ -682,7 +682,7 @@ static void CheckRotate(CPDF_Page& page, CFX_FloatRect& page_bbox) {
FX_POSITION pos = page.GetFirstObjectPosition();
while (pos) {
CPDF_PageObject* pObj = page.GetNextObject(pos);
- if (pObj->m_Type != PDFPAGE_TEXT) {
+ if (pObj->m_Type != CPDF_PageObject::TEXT) {
continue;
}
total_count++;
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index ae26cbd252..55f736ee9c 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -771,7 +771,7 @@ int32_t CPDF_TextPage::FindTextlineFlowDirection() {
if (NULL == pPageObj) {
continue;
}
- if (PDFPAGE_TEXT != pPageObj->m_Type) {
+ if (CPDF_PageObject::TEXT != pPageObj->m_Type) {
continue;
}
int32_t minH =
@@ -860,11 +860,11 @@ void CPDF_TextPage::ProcessObject() {
while (pos) {
pPageObj = m_pPage->GetNextObject(pos);
if (pPageObj) {
- if (pPageObj->m_Type == PDFPAGE_TEXT) {
+ if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
CFX_Matrix matrix;
ProcessTextObject((CPDF_TextObject*)pPageObj, matrix, pos);
nCount++;
- } else if (pPageObj->m_Type == PDFPAGE_FORM) {
+ } else if (pPageObj->m_Type == CPDF_PageObject::FORM) {
CFX_Matrix formMatrix(1, 0, 0, 1, 0, 0);
ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix);
}
@@ -895,9 +895,9 @@ void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj,
while (pos) {
pPageObj = pFormObj->m_pForm->GetNextObject(pos);
if (pPageObj) {
- if (pPageObj->m_Type == PDFPAGE_TEXT) {
+ if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
ProcessTextObject((CPDF_TextObject*)pPageObj, curFormMatrix, pos);
- } else if (pPageObj->m_Type == PDFPAGE_FORM) {
+ } else if (pPageObj->m_Type == CPDF_PageObject::FORM) {
ProcessFormObject((CPDF_FormObject*)pPageObj, curFormMatrix);
}
}
@@ -1967,7 +1967,7 @@ FX_BOOL CPDF_TextPage::IsSameAsPreTextObject(CPDF_TextObject* pTextObj,
if (pObj == pTextObj) {
continue;
}
- if (pObj->m_Type != PDFPAGE_TEXT) {
+ if (pObj->m_Type != CPDF_PageObject::TEXT) {
continue;
}
if (IsSameTextObject((CPDF_TextObject*)pObj, pTextObj)) {
diff --git a/core/src/fpdftext/fpdf_text_search.cpp b/core/src/fpdftext/fpdf_text_search.cpp
index de38a7f540..b77f9428cb 100644
--- a/core/src/fpdftext/fpdf_text_search.cpp
+++ b/core/src/fpdftext/fpdf_text_search.cpp
@@ -303,7 +303,7 @@ void GetTextStream_Unicode(CFX_WideTextBuf& buffer,
FX_POSITION pos = pPage->GetFirstObjectPosition();
while (pos) {
CPDF_PageObject* pObject = pPage->GetNextObject(pos);
- if (pObject && pObject->m_Type == PDFPAGE_TEXT)
+ if (pObject && pObject->m_Type == CPDF_PageObject::TEXT)
textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE);
}
}
@@ -321,7 +321,7 @@ CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc,
FX_POSITION pos = page.GetFirstObjectPosition();
while (pos) {
CPDF_PageObject* pObject = page.GetNextObject(pos);
- if (pObject->m_Type != PDFPAGE_TEXT) {
+ if (pObject->m_Type != CPDF_PageObject::TEXT) {
continue;
}
if (textstream.ProcessObject((CPDF_TextObject*)pObject, TRUE)) {