Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1419643005: Merge to XFA: Add type cast definitions for CPDF_Array. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index f6e1ee895a91c8946c29ec7d07fb997416defc6e..717a5d1d5338b53bc02af47a32fdf2ca2e404a7c 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -1154,17 +1154,14 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos,
}
CPDF_Array* CPDF_Parser::GetIDArray() {
CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetElement(FX_BSTRC("ID")) : NULL;
- if (pID == NULL) {
- return NULL;
- }
+ if (!pID)
+ return nullptr;
+
if (pID->GetType() == PDFOBJ_REFERENCE) {
pID = ParseIndirectObject(NULL, ((CPDF_Reference*)pID)->GetRefObjNum());
m_pTrailer->SetAt(FX_BSTRC("ID"), pID);
}
- if (pID == NULL || pID->GetType() != PDFOBJ_ARRAY) {
- return NULL;
- }
- return (CPDF_Array*)pID;
+ return ToArray(pID);
}
FX_DWORD CPDF_Parser::GetRootObjNum() {
CPDF_Object* pRef =
@@ -3480,7 +3477,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) {
}
continue;
}
- if (pObj->GetType() == PDFOBJ_ARRAY) {
+ if (pObj->IsArray()) {
CPDF_Array* pArray = pObj->GetArray();
if (pArray) {
int32_t iSize = pArray->GetCount();
@@ -3549,7 +3546,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) {
m_PageObjList.Add(pKid->GetRefObjNum());
} break;
case PDFOBJ_ARRAY: {
- CPDF_Array* pKidsArray = (CPDF_Array*)pKids;
+ CPDF_Array* pKidsArray = pKids->AsArray();
for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
CPDF_Object* pKid = (CPDF_Object*)pKidsArray->GetElement(i);
if (pKid && pKid->GetType() == PDFOBJ_REFERENCE) {
@@ -4122,13 +4119,15 @@ FX_BOOL CPDF_DataAvail::CheckArrayPageNode(FX_DWORD dwPageNo,
}
return FALSE;
}
- if (pPages->GetType() != PDFOBJ_ARRAY) {
+
+ CPDF_Array* pArray = pPages->AsArray();
+ if (!pArray) {
pPages->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
return FALSE;
}
+
pPageNode->m_type = PDF_PAGENODE_PAGES;
- CPDF_Array* pArray = (CPDF_Array*)pPages;
for (FX_DWORD i = 0; i < pArray->GetCount(); ++i) {
CPDF_Object* pKid = (CPDF_Object*)pArray->GetElement(i);
if (!pKid || pKid->GetType() != PDFOBJ_REFERENCE) {
@@ -4157,7 +4156,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo,
}
return FALSE;
}
- if (pPage->GetType() == PDFOBJ_ARRAY) {
+ if (pPage->IsArray()) {
pPageNode->m_dwPageNo = dwPageNo;
pPageNode->m_type = PDF_PAGENODE_ARRAY;
pPage->Release();
@@ -4186,7 +4185,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo,
pNode->m_dwPageNo = pKid->GetRefObjNum();
} break;
case PDFOBJ_ARRAY: {
- CPDF_Array* pKidsArray = (CPDF_Array*)pKids;
+ CPDF_Array* pKidsArray = pKids->AsArray();
for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
CPDF_Object* pKid = (CPDF_Object*)pKidsArray->GetElement(i);
if (!pKid || pKid->GetType() != PDFOBJ_REFERENCE) {

Powered by Google App Engine
This is Rietveld 408576698