summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
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/fpdf_page
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/fpdf_page')
-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
4 files changed, 33 insertions, 29 deletions
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),