summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-02-19 11:53:03 -0800
committerWei Li <weili@chromium.org>2016-02-19 11:53:03 -0800
commit7cf13c9c8b9b69b01e5debb5e8dc8b265983dfa8 (patch)
tree3a5b016ba365f11d775df0009c51b5a554ec302e /core/src/fpdfapi/fpdf_page
parent31c7b73b71bd7352f96a82716b5e81d7fa24f37f (diff)
downloadpdfium-7cf13c9c8b9b69b01e5debb5e8dc8b265983dfa8.tar.xz
Remove PageObject's m_Type and add As<Type> functions
For CPDF_PageObject and its subclasses, remove m_Type and use GetType() instead. Also, add As<Type> functions to avoid casting all over the places. BUG=pdfium:397 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1709393002 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_page')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp14
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp2
3 files changed, 8 insertions, 11 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index b1de6d6de2..0bcd15be20 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -12,7 +12,7 @@
#include "core/include/fpdfapi/fpdf_page.h"
#include "third_party/base/stl_util.h"
-CPDF_PageObject* CPDF_PageObject::Create(int type) {
+CPDF_PageObject* CPDF_PageObject::Create(Type type) {
switch (type) {
case TEXT:
return new CPDF_TextObject;
@@ -29,12 +29,12 @@ CPDF_PageObject* CPDF_PageObject::Create(int type) {
}
CPDF_PageObject::~CPDF_PageObject() {}
CPDF_PageObject* CPDF_PageObject::Clone() const {
- CPDF_PageObject* pObj = Create(m_Type);
+ CPDF_PageObject* pObj = Create(GetType());
pObj->Copy(this);
return pObj;
}
void CPDF_PageObject::Copy(const CPDF_PageObject* pSrc) {
- if (m_Type != pSrc->m_Type) {
+ if (GetType() != pSrc->GetType()) {
return;
}
CopyData(pSrc);
@@ -56,7 +56,7 @@ void CPDF_PageObject::RemoveClipPath() {
m_ClipPath.SetNull();
}
void CPDF_PageObject::RecalcBBox() {
- switch (m_Type) {
+ switch (GetType()) {
case TEXT:
((CPDF_TextObject*)this)->RecalcPositionData();
break;
@@ -93,8 +93,7 @@ FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
}
CPDF_TextObject::CPDF_TextObject()
- : CPDF_PageObject(TEXT),
- m_PosX(0),
+ : m_PosX(0),
m_PosY(0),
m_nChars(0),
m_pCharCodes(nullptr),
@@ -611,8 +610,7 @@ void CPDF_TextObject::SetTextState(CPDF_TextState TextState) {
CalcPositionData(nullptr, nullptr, 0);
}
-CPDF_ShadingObject::CPDF_ShadingObject()
- : CPDF_PageObject(SHADING), m_pShading(nullptr) {}
+CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {}
CPDF_ShadingObject::~CPDF_ShadingObject() {}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp
index 01322b5c1f..93c0aca4f1 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp
@@ -9,8 +9,7 @@
#include "core/include/fpdfapi/fpdf_page.h"
#include "core/include/fpdfapi/fpdf_pageobj.h"
-CPDF_ImageObject::CPDF_ImageObject()
- : CPDF_PageObject(IMAGE), m_pImage(nullptr) {}
+CPDF_ImageObject::CPDF_ImageObject() : m_pImage(nullptr) {}
CPDF_ImageObject::~CPDF_ImageObject() {
if (!m_pImage) {
return;
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 20f0c39c25..02e3617feb 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -853,7 +853,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
continue;
}
CPDF_Path ClipPath = pObj->m_ClipPath.GetPath(0);
- if (!ClipPath.IsRect() || pObj->m_Type == CPDF_PageObject::SHADING) {
+ if (!ClipPath.IsRect() || pObj->IsShading()) {
continue;
}
CFX_FloatRect old_rect(ClipPath.GetPointX(0), ClipPath.GetPointY(0),