From 7cf13c9c8b9b69b01e5debb5e8dc8b265983dfa8 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Fri, 19 Feb 2016 11:53:03 -0800 Subject: Remove PageObject's m_Type and add As functions For CPDF_PageObject and its subclasses, remove m_Type and use GetType() instead. Also, add As functions to avoid casting all over the places. BUG=pdfium:397 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1709393002 . --- core/src/fpdfapi/fpdf_page/fpdf_page.cpp | 14 ++++++-------- core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp | 3 +-- core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'core/src/fpdfapi/fpdf_page') 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), -- cgit v1.2.3