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

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

Issue 1420583003: Revert "Revert "Add type cast definitions for CPDF_Dictionary."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
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 a36850bc2e60d53aecd85c14f8cbf9bb82e88d6b..b436ba16f555229942ab8128db35cc06607e8295 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -277,8 +277,8 @@ FX_DWORD CPDF_Parser::SetEncryptHandler() {
}
CPDF_Object* pEncryptObj = m_pTrailer->GetElement(FX_BSTRC("Encrypt"));
if (pEncryptObj) {
- if (pEncryptObj->GetType() == PDFOBJ_DICTIONARY) {
- SetEncryptDictionary((CPDF_Dictionary*)pEncryptObj);
+ if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) {
+ SetEncryptDictionary(pEncryptDict);
} else if (pEncryptObj->GetType() == PDFOBJ_REFERENCE) {
pEncryptObj = m_pDocument->GetIndirectObject(
((CPDF_Reference*)pEncryptObj)->GetRefObjNum());
@@ -804,7 +804,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
if (m_pTrailer) {
m_pTrailer->Release();
}
- m_pTrailer = (CPDF_Dictionary*)pDict->Clone();
+ m_pTrailer = ToDictionary(pDict->Clone());
}
}
}
@@ -857,15 +857,14 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
m_Syntax.RestorePos(pos + i - m_Syntax.m_HeaderOffset);
CPDF_Object* pObj = m_Syntax.GetObject(m_pDocument, 0, 0, 0);
if (pObj) {
- if (pObj->GetType() != PDFOBJ_DICTIONARY &&
- pObj->GetType() != PDFOBJ_STREAM) {
+ if (!pObj->IsDictionary() && pObj->GetType() != PDFOBJ_STREAM) {
pObj->Release();
} else {
CPDF_Dictionary* pTrailer = NULL;
if (pObj->GetType() == PDFOBJ_STREAM) {
pTrailer = ((CPDF_Stream*)pObj)->GetDict();
} else {
- pTrailer = (CPDF_Dictionary*)pObj;
+ pTrailer = pObj->AsDictionary();
}
if (pTrailer) {
if (m_pTrailer) {
@@ -890,7 +889,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
}
} else {
if (pObj->GetType() == PDFOBJ_STREAM) {
- m_pTrailer = (CPDF_Dictionary*)pTrailer->Clone();
+ m_pTrailer = ToDictionary(pTrailer->Clone());
pObj->Release();
} else {
m_pTrailer = pTrailer;
@@ -1034,13 +1033,13 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos,
return FALSE;
}
if (bMainXRef) {
- m_pTrailer = (CPDF_Dictionary*)pStream->GetDict()->Clone();
+ m_pTrailer = ToDictionary(pStream->GetDict()->Clone());
m_CrossRef.SetSize(size);
if (m_V5Type.SetSize(size)) {
FXSYS_memset(m_V5Type.GetData(), 0, size);
}
} else {
- m_Trailers.Add((CPDF_Dictionary*)pStream->GetDict()->Clone());
+ m_Trailers.Add(ToDictionary(pStream->GetDict()->Clone()));
}
std::vector<std::pair<int32_t, int32_t> > arrIndex;
CPDF_Array* pArray = pStream->GetDict()->GetArray(FX_BSTRC("Index"));
@@ -1490,9 +1489,9 @@ CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() {
nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
m_Syntax.GetObject(m_pDocument, 0, 0, 0));
- if (!pObj || pObj->GetType() != PDFOBJ_DICTIONARY)
+ if (!ToDictionary(pObj.get()))
return nullptr;
- return static_cast<CPDF_Dictionary*>(pObj.release());
+ return pObj.release()->AsDictionary();
}
FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) {
@@ -3490,7 +3489,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) {
}
}
}
- if (pObj->GetType() != PDFOBJ_DICTIONARY) {
+ if (!pObj->IsDictionary()) {
pObj->Release();
continue;
}
@@ -4043,7 +4042,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) {
pHints->AddSegment(m_Pos, iTrailerSize);
return FALSE;
}
- if (pTrailer->GetType() != PDFOBJ_DICTIONARY)
+ if (!pTrailer->IsDictionary())
return FALSE;
CPDF_Dictionary* pTrailerDict = pTrailer->GetDict();
@@ -4158,7 +4157,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo,
pPage->Release();
return TRUE;
}
- if (pPage->GetType() != PDFOBJ_DICTIONARY) {
+ if (!pPage->IsDictionary()) {
pPage->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
return FALSE;
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698