summaryrefslogtreecommitdiff
path: root/fpdfsdk
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 /fpdfsdk
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 'fpdfsdk')
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp2
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp16
-rw-r--r--fpdfsdk/src/javascript/Document.cpp8
3 files changed, 13 insertions, 13 deletions
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index 4664037087..9f500b2768 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -200,7 +200,7 @@ FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,
// Special treatment to shading object, because the ClipPath for shading
// object is already transformed.
- if (pPageObj->m_Type != CPDF_PageObject::SHADING)
+ if (!pPageObj->IsShading())
pPageObj->TransformClipPath(matrix);
pPageObj->TransformGeneralState(matrix);
}
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 6c14079131..b833a61c02 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -140,9 +140,9 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
pPage->GetPageObjectList()->push_back(
std::unique_ptr<CPDF_PageObject>(pPageObj));
- switch (pPageObj->m_Type) {
+ switch (pPageObj->GetType()) {
case FPDF_PAGEOBJ_PATH: {
- CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj;
+ CPDF_PathObject* pPathObj = pPageObj->AsPath();
pPathObj->CalcBoundingBox();
break;
}
@@ -150,17 +150,17 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
break;
}
case FPDF_PAGEOBJ_IMAGE: {
- CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageObj;
+ CPDF_ImageObject* pImageObj = pPageObj->AsImage();
pImageObj->CalcBoundingBox();
break;
}
case FPDF_PAGEOBJ_SHADING: {
- CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)pPageObj;
+ CPDF_ShadingObject* pShadingObj = pPageObj->AsShading();
pShadingObj->CalcBoundingBox();
break;
}
case FPDF_PAGEOBJ_FORM: {
- CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
+ CPDF_FormObject* pFormObj = pPageObj->AsForm();
pFormObj->CalcBoundingBox();
break;
}
@@ -216,13 +216,13 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
if (pGeneralState && pGeneralState->m_FillAlpha != 1.0f)
return TRUE;
- if (pPageObj->m_Type == CPDF_PageObject::PATH) {
+ if (pPageObj->IsPath()) {
if (pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f)
return TRUE;
}
- if (pPageObj->m_Type == CPDF_PageObject::FORM) {
- CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
+ if (pPageObj->IsForm()) {
+ CPDF_FormObject* pFormObj = pPageObj->AsForm();
if (pFormObj->m_pForm &&
(pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED))
return TRUE;
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 733384a154..c49524d02f 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -1383,8 +1383,8 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc,
int nWords = 0;
CFX_WideString swRet;
for (auto& pPageObj : *page.GetPageObjectList()) {
- if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
- CPDF_TextObject* pTextObj = static_cast<CPDF_TextObject*>(pPageObj.get());
+ if (pPageObj->IsText()) {
+ CPDF_TextObject* pTextObj = pPageObj->AsText();
int nObjWords = CountWords(pTextObj);
if (nWords + nObjWords >= nWordNo) {
swRet = GetObjWordStr(pTextObj, nWordNo - nWords);
@@ -1438,8 +1438,8 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc,
int nWords = 0;
for (auto& pPageObj : *page.GetPageObjectList()) {
- if (pPageObj->m_Type == CPDF_PageObject::TEXT)
- nWords += CountWords(static_cast<CPDF_TextObject*>(pPageObj.get()));
+ if (pPageObj->IsText())
+ nWords += CountWords(pPageObj->AsText());
}
vRet = nWords;