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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 361553002: Remove "this==NULL" and adjust corresponding callers (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix if check warning Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fpdfapi/fpdf_parser.h" 7 #include "../../../include/fpdfapi/fpdf_parser.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_page.h" 9 #include "../../../include/fpdfapi/fpdf_page.h"
10 #include "../fpdf_page/pageint.h" 10 #include "../fpdf_page/pageint.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (m_pDocument && !bReParse) { 71 if (m_pDocument && !bReParse) {
72 delete m_pDocument; 72 delete m_pDocument;
73 m_pDocument = NULL; 73 m_pDocument = NULL;
74 } 74 }
75 if (m_pTrailer) { 75 if (m_pTrailer) {
76 m_pTrailer->Release(); 76 m_pTrailer->Release();
77 m_pTrailer = NULL; 77 m_pTrailer = NULL;
78 } 78 }
79 ReleaseEncryptHandler(); 79 ReleaseEncryptHandler();
80 SetEncryptDictionary(NULL); 80 SetEncryptDictionary(NULL);
81 if (m_bOwnFileRead && m_Syntax.m_pFileAccess != NULL) { 81 if (m_bOwnFileRead && m_Syntax.m_pFileAccess) {
82 m_Syntax.m_pFileAccess->Release(); 82 m_Syntax.m_pFileAccess->Release();
83 m_Syntax.m_pFileAccess = NULL; 83 m_Syntax.m_pFileAccess = NULL;
84 } 84 }
85 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); 85 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition();
86 while (pos) { 86 while (pos) {
87 FX_LPVOID objnum; 87 FX_LPVOID objnum;
88 CPDF_StreamAcc* pStream; 88 CPDF_StreamAcc* pStream;
89 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); 89 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream);
90 delete pStream; 90 delete pStream;
91 } 91 }
92 m_ObjectStreamMap.RemoveAll(); 92 m_ObjectStreamMap.RemoveAll();
93 m_SortedOffset.RemoveAll(); 93 m_SortedOffset.RemoveAll();
94 m_CrossRef.RemoveAll(); 94 m_CrossRef.RemoveAll();
95 m_V5Type.RemoveAll(); 95 m_V5Type.RemoveAll();
96 m_ObjVersion.RemoveAll(); 96 m_ObjVersion.RemoveAll();
97 FX_INT32 iLen = m_Trailers.GetSize(); 97 FX_INT32 iLen = m_Trailers.GetSize();
98 for (FX_INT32 i = 0; i < iLen; ++i) { 98 for (FX_INT32 i = 0; i < iLen; ++i) {
99 m_Trailers.GetAt(i)->Release(); 99 if (CPDF_Dictionary* trailer = m_Trailers.GetAt(i))
100 trailer->Release();
100 } 101 }
101 m_Trailers.RemoveAll(); 102 m_Trailers.RemoveAll();
102 if (m_pLinearized) { 103 if (m_pLinearized) {
103 m_pLinearized->Release(); 104 m_pLinearized->Release();
104 m_pLinearized = NULL; 105 m_pLinearized = NULL;
105 } 106 }
106 } 107 }
107 static FX_INT32 GetHeaderOffset(IFX_FileRead* pFile) 108 static FX_INT32 GetHeaderOffset(IFX_FileRead* pFile)
108 { 109 {
109 FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025); 110 FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025);
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 } 1104 }
1104 } 1105 }
1105 } 1106 }
1106 segindex += count; 1107 segindex += count;
1107 } 1108 }
1108 pStream->Release(); 1109 pStream->Release();
1109 return TRUE; 1110 return TRUE;
1110 } 1111 }
1111 CPDF_Array* CPDF_Parser::GetIDArray() 1112 CPDF_Array* CPDF_Parser::GetIDArray()
1112 { 1113 {
1113 CPDF_Object* pID = m_pTrailer->GetElement(FX_BSTRC("ID")); 1114 CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetElement(FX_BSTRC("ID")) : NUL L;
1114 if (pID == NULL) { 1115 if (pID == NULL) {
1115 return NULL; 1116 return NULL;
1116 } 1117 }
1117 if (pID->GetType() == PDFOBJ_REFERENCE) { 1118 if (pID->GetType() == PDFOBJ_REFERENCE) {
1118 pID = ParseIndirectObject(NULL, ((CPDF_Reference*)pID)->GetRefObjNum()); 1119 pID = ParseIndirectObject(NULL, ((CPDF_Reference*)pID)->GetRefObjNum());
1119 m_pTrailer->SetAt(FX_BSTRC("ID"), pID); 1120 m_pTrailer->SetAt(FX_BSTRC("ID"), pID);
1120 } 1121 }
1121 if (pID == NULL || pID->GetType() != PDFOBJ_ARRAY) { 1122 if (pID == NULL || pID->GetType() != PDFOBJ_ARRAY) {
1122 return NULL; 1123 return NULL;
1123 } 1124 }
1124 return (CPDF_Array*)pID; 1125 return (CPDF_Array*)pID;
1125 } 1126 }
1126 FX_DWORD CPDF_Parser::GetRootObjNum() 1127 FX_DWORD CPDF_Parser::GetRootObjNum()
1127 { 1128 {
1128 CPDF_Reference* pRef = (CPDF_Reference*)m_pTrailer->GetElement(FX_BSTRC("Roo t")); 1129 CPDF_Reference* pRef = m_pTrailer ? (CPDF_Reference*)m_pTrailer->GetElement( FX_BSTRC("Root")) : NULL;
1129 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) { 1130 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) {
1130 return 0; 1131 return 0;
1131 } 1132 }
1132 return pRef->GetRefObjNum(); 1133 return pRef->GetRefObjNum();
1133 } 1134 }
1134 FX_DWORD CPDF_Parser::GetInfoObjNum() 1135 FX_DWORD CPDF_Parser::GetInfoObjNum()
1135 { 1136 {
1136 CPDF_Reference* pRef = (CPDF_Reference*)m_pTrailer->GetElement(FX_BSTRC("Inf o")); 1137 CPDF_Reference* pRef = m_pTrailer ? (CPDF_Reference*)m_pTrailer->GetElement( FX_BSTRC("Info")) : NULL;
1137 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) { 1138 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) {
1138 return 0; 1139 return 0;
1139 } 1140 }
1140 return pRef->GetRefObjNum(); 1141 return pRef->GetRefObjNum();
1141 } 1142 }
1142 FX_BOOL CPDF_Parser::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) 1143 FX_BOOL CPDF_Parser::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm)
1143 { 1144 {
1144 bForm = FALSE; 1145 bForm = FALSE;
1145 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { 1146 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) {
1146 return TRUE; 1147 return TRUE;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 } 1485 }
1485 FX_DWORD gennum = FXSYS_atoi(word); 1486 FX_DWORD gennum = FXSYS_atoi(word);
1486 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { 1487 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) {
1487 m_Syntax.RestorePos(SavedPos); 1488 m_Syntax.RestorePos(SavedPos);
1488 return FALSE; 1489 return FALSE;
1489 } 1490 }
1490 m_pLinearized = m_Syntax.GetObject(NULL, objnum, gennum, 0); 1491 m_pLinearized = m_Syntax.GetObject(NULL, objnum, gennum, 0);
1491 if (!m_pLinearized) { 1492 if (!m_pLinearized) {
1492 return FALSE; 1493 return FALSE;
1493 } 1494 }
1494 if (m_pLinearized->GetDict()->GetElement(FX_BSTRC("Linearized"))) { 1495 if (m_pLinearized->GetDict() && m_pLinearized->GetDict()->GetElement(FX_BSTR C("Linearized"))) {
1495 m_Syntax.GetNextWord(bIsNumber); 1496 m_Syntax.GetNextWord(bIsNumber);
1496 CPDF_Object *pLen = m_pLinearized->GetDict()->GetElement(FX_BSTRC("L")); 1497 CPDF_Object *pLen = m_pLinearized->GetDict()->GetElement(FX_BSTRC("L"));
1497 if (!pLen) { 1498 if (!pLen) {
1498 m_pLinearized->Release(); 1499 m_pLinearized->Release();
1499 return FALSE; 1500 return FALSE;
1500 } 1501 }
1501 if (pLen->GetInteger() != (int)pFileAccess->GetSize()) { 1502 if (pLen->GetInteger() != (int)pFileAccess->GetSize()) {
1502 return FALSE; 1503 return FALSE;
1503 } 1504 }
1504 CPDF_Object *pNo = m_pLinearized->GetDict()->GetElement(FX_BSTRC("P")); 1505 CPDF_Object *pNo = m_pLinearized->GetDict()->GetElement(FX_BSTRC("P"));
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 if (pContext) { 2144 if (pContext) {
2144 pContext->m_DictStart = SavedPos; 2145 pContext->m_DictStart = SavedPos;
2145 } 2146 }
2146 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); 2147 CPDF_Dictionary* pDict = CPDF_Dictionary::Create();
2147 FX_INT32 nKeys = 0; 2148 FX_INT32 nKeys = 0;
2148 FX_FILESIZE dwSignValuePos = 0; 2149 FX_FILESIZE dwSignValuePos = 0;
2149 while (1) { 2150 while (1) {
2150 FX_BOOL bIsNumber; 2151 FX_BOOL bIsNumber;
2151 CFX_ByteString key = GetNextWord(bIsNumber); 2152 CFX_ByteString key = GetNextWord(bIsNumber);
2152 if (key.IsEmpty()) { 2153 if (key.IsEmpty()) {
2153 pDict->Release(); 2154 if (pDict)
2155 pDict->Release();
2154 return NULL; 2156 return NULL;
2155 } 2157 }
2156 FX_FILESIZE SavedPos = m_Pos - key.GetLength(); 2158 FX_FILESIZE SavedPos = m_Pos - key.GetLength();
2157 if (key == FX_BSTRC(">>")) { 2159 if (key == FX_BSTRC(">>")) {
2158 dwDictSize = m_Pos - saveDictOffset; 2160 dwDictSize = m_Pos - saveDictOffset;
2159 break; 2161 break;
2160 } 2162 }
2161 if (key == FX_BSTRC("endobj")) { 2163 if (key == FX_BSTRC("endobj")) {
2162 dwDictSize = m_Pos - 6 - saveDictOffset; 2164 dwDictSize = m_Pos - 6 - saveDictOffset;
2163 m_Pos = SavedPos; 2165 m_Pos = SavedPos;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 } 2201 }
2200 } 2202 }
2201 FX_FILESIZE SavedPos = m_Pos; 2203 FX_FILESIZE SavedPos = m_Pos;
2202 FX_BOOL bIsNumber; 2204 FX_BOOL bIsNumber;
2203 CFX_ByteString nextword = GetNextWord(bIsNumber); 2205 CFX_ByteString nextword = GetNextWord(bIsNumber);
2204 if (nextword == FX_BSTRC("stream")) { 2206 if (nextword == FX_BSTRC("stream")) {
2205 CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum); 2207 CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum);
2206 if (pStream) { 2208 if (pStream) {
2207 return pStream; 2209 return pStream;
2208 } 2210 }
2209 pDict->Release(); 2211 if (pDict)
2212 pDict->Release();
2210 return NULL; 2213 return NULL;
2211 } else { 2214 } else {
2212 m_Pos = SavedPos; 2215 m_Pos = SavedPos;
2213 return pDict; 2216 return pDict;
2214 } 2217 }
2215 } 2218 }
2216 if (word == FX_BSTRC(">>")) { 2219 if (word == FX_BSTRC(">>")) {
2217 m_Pos = SavedPos; 2220 m_Pos = SavedPos;
2218 return NULL; 2221 return NULL;
2219 } 2222 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 if (bTypeOnly) { 2303 if (bTypeOnly) {
2301 return (CPDF_Object*)PDFOBJ_ARRAY; 2304 return (CPDF_Object*)PDFOBJ_ARRAY;
2302 } 2305 }
2303 CPDF_Array* pArray = CPDF_Array::Create(); 2306 CPDF_Array* pArray = CPDF_Array::Create();
2304 while (1) { 2307 while (1) {
2305 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1); 2308 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1);
2306 if (pObj == NULL) { 2309 if (pObj == NULL) {
2307 if (m_WordBuffer[0] == ']') { 2310 if (m_WordBuffer[0] == ']') {
2308 return pArray; 2311 return pArray;
2309 } 2312 }
2310 pArray->Release(); 2313 if (pArray)
2314 pArray->Release();
2311 return NULL; 2315 return NULL;
2312 } 2316 }
2313 pArray->Add(pObj); 2317 pArray->Add(pObj);
2314 } 2318 }
2315 } 2319 }
2316 if (word[0] == '/') { 2320 if (word[0] == '/') {
2317 if (bTypeOnly) { 2321 if (bTypeOnly) {
2318 return (CPDF_Object*)PDFOBJ_NAME; 2322 return (CPDF_Object*)PDFOBJ_NAME;
2319 } 2323 }
2320 return CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1 , m_WordSize - 1))); 2324 return CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1 , m_WordSize - 1)));
2321 } 2325 }
2322 if (word == FX_BSTRC("<<")) { 2326 if (word == FX_BSTRC("<<")) {
2323 if (bTypeOnly) { 2327 if (bTypeOnly) {
2324 return (CPDF_Object*)PDFOBJ_DICTIONARY; 2328 return (CPDF_Object*)PDFOBJ_DICTIONARY;
2325 } 2329 }
2326 if (pContext) { 2330 if (pContext) {
2327 pContext->m_DictStart = SavedPos; 2331 pContext->m_DictStart = SavedPos;
2328 } 2332 }
2329 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); 2333 CPDF_Dictionary* pDict = CPDF_Dictionary::Create();
2330 while (1) { 2334 while (1) {
2331 FX_BOOL bIsNumber; 2335 FX_BOOL bIsNumber;
2332 FX_FILESIZE SavedPos = m_Pos; 2336 FX_FILESIZE SavedPos = m_Pos;
2333 CFX_ByteString key = GetNextWord(bIsNumber); 2337 CFX_ByteString key = GetNextWord(bIsNumber);
2334 if (key.IsEmpty()) { 2338 if (key.IsEmpty()) {
2335 pDict->Release(); 2339 if (pDict)
2340 pDict->Release();
2336 return NULL; 2341 return NULL;
2337 } 2342 }
2338 if (key == FX_BSTRC(">>")) { 2343 if (key == FX_BSTRC(">>")) {
2339 break; 2344 break;
2340 } 2345 }
2341 if (key == FX_BSTRC("endobj")) { 2346 if (key == FX_BSTRC("endobj")) {
2342 m_Pos = SavedPos; 2347 m_Pos = SavedPos;
2343 break; 2348 break;
2344 } 2349 }
2345 if (key[0] != '/') { 2350 if (key[0] != '/') {
2346 continue; 2351 continue;
2347 } 2352 }
2348 key = PDF_NameDecode(key); 2353 key = PDF_NameDecode(key);
2349 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1); 2354 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, level + 1);
2350 if (pObj == NULL) { 2355 if (pObj == NULL) {
2351 pDict->Release(); 2356 if (pDict)
2357 pDict->Release();
2352 FX_BYTE ch; 2358 FX_BYTE ch;
2353 while (1) { 2359 while (1) {
2354 if (!GetNextChar(ch)) { 2360 if (!GetNextChar(ch)) {
2355 break; 2361 break;
2356 } 2362 }
2357 if (ch == 0x0A || ch == 0x0D) { 2363 if (ch == 0x0A || ch == 0x0D) {
2358 break; 2364 break;
2359 } 2365 }
2360 } 2366 }
2361 return NULL; 2367 return NULL;
(...skipping 11 matching lines...) Expand all
2373 } 2379 }
2374 } 2380 }
2375 FX_FILESIZE SavedPos = m_Pos; 2381 FX_FILESIZE SavedPos = m_Pos;
2376 FX_BOOL bIsNumber; 2382 FX_BOOL bIsNumber;
2377 CFX_ByteString nextword = GetNextWord(bIsNumber); 2383 CFX_ByteString nextword = GetNextWord(bIsNumber);
2378 if (nextword == FX_BSTRC("stream")) { 2384 if (nextword == FX_BSTRC("stream")) {
2379 CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum); 2385 CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum);
2380 if (pStream) { 2386 if (pStream) {
2381 return pStream; 2387 return pStream;
2382 } 2388 }
2383 pDict->Release(); 2389 if (pDict)
2390 pDict->Release();
2384 return NULL; 2391 return NULL;
2385 } else { 2392 } else {
2386 m_Pos = SavedPos; 2393 m_Pos = SavedPos;
2387 return pDict; 2394 return pDict;
2388 } 2395 }
2389 } 2396 }
2390 if (word == FX_BSTRC(">>")) { 2397 if (word == FX_BSTRC(">>")) {
2391 m_Pos = SavedPos; 2398 m_Pos = SavedPos;
2392 return NULL; 2399 return NULL;
2393 } 2400 }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 CPDF_Array *pArray = pObj->GetArray(); 2835 CPDF_Array *pArray = pObj->GetArray();
2829 for (FX_DWORD k = 0; k < pArray->GetCount(); k++) { 2836 for (FX_DWORD k = 0; k < pArray->GetCount(); k++) {
2830 new_obj_array.Add(pArray->GetElement(k)); 2837 new_obj_array.Add(pArray->GetElement(k));
2831 } 2838 }
2832 } 2839 }
2833 break; 2840 break;
2834 case PDFOBJ_STREAM: 2841 case PDFOBJ_STREAM:
2835 pObj = pObj->GetDict(); 2842 pObj = pObj->GetDict();
2836 case PDFOBJ_DICTIONARY: { 2843 case PDFOBJ_DICTIONARY: {
2837 CPDF_Dictionary *pDict = pObj->GetDict(); 2844 CPDF_Dictionary *pDict = pObj->GetDict();
2838 if (pDict->GetString("Type") == "Page" && !bParsePage) { 2845 if (pDict && pDict->GetString("Type") == "Page" && !bParsePa ge) {
2839 continue; 2846 continue;
2840 } 2847 }
2841 FX_POSITION pos = pDict->GetStartPos(); 2848 FX_POSITION pos = pDict->GetStartPos();
2842 while (pos) { 2849 while (pos) {
2843 CPDF_Object *value; 2850 CPDF_Object *value;
2844 CFX_ByteString key; 2851 CFX_ByteString key;
2845 value = pDict->GetNextElement(pos, key); 2852 value = pDict->GetNextElement(pos, key);
2846 if (key != "Parent") { 2853 if (key != "Parent") {
2847 new_obj_array.Add(value); 2854 new_obj_array.Add(value);
2848 } 2855 }
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 m_docStatus = PDF_DATAAVAIL_ACROFORM; 3157 m_docStatus = PDF_DATAAVAIL_ACROFORM;
3151 } else { 3158 } else {
3152 m_docStatus = PDF_DATAAVAIL_PAGETREE; 3159 m_docStatus = PDF_DATAAVAIL_PAGETREE;
3153 } 3160 }
3154 } 3161 }
3155 return TRUE; 3162 return TRUE;
3156 } 3163 }
3157 FX_BOOL CPDF_DataAvail::PreparePageItem() 3164 FX_BOOL CPDF_DataAvail::PreparePageItem()
3158 { 3165 {
3159 CPDF_Dictionary *pRoot = m_pDocument->GetRoot(); 3166 CPDF_Dictionary *pRoot = m_pDocument->GetRoot();
3160 CPDF_Reference* pRef = (CPDF_Reference*)pRoot->GetElement(FX_BSTRC("Pages")) ; 3167 CPDF_Reference* pRef = pRoot ? (CPDF_Reference*)pRoot->GetElement(FX_BSTRC(" Pages")) : NULL;
3161 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) { 3168 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) {
3162 m_docStatus = PDF_DATAAVAIL_ERROR; 3169 m_docStatus = PDF_DATAAVAIL_ERROR;
3163 return FALSE; 3170 return FALSE;
3164 } 3171 }
3165 m_PagesObjNum = pRef->GetRefObjNum(); 3172 m_PagesObjNum = pRef->GetRefObjNum();
3166 m_pCurrentParser = (CPDF_Parser *)m_pDocument->GetParser(); 3173 m_pCurrentParser = (CPDF_Parser *)m_pDocument->GetParser();
3167 m_docStatus = PDF_DATAAVAIL_PAGETREE; 3174 m_docStatus = PDF_DATAAVAIL_PAGETREE;
3168 return TRUE; 3175 return TRUE;
3169 } 3176 }
3170 FX_BOOL CPDF_DataAvail::IsFirstCheck(int iPage) 3177 FX_BOOL CPDF_DataAvail::IsFirstCheck(int iPage)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 return TRUE; 3270 return TRUE;
3264 } 3271 }
3265 return TRUE; 3272 return TRUE;
3266 } 3273 }
3267 FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages) 3274 FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages)
3268 { 3275 {
3269 if (!pParser) { 3276 if (!pParser) {
3270 m_docStatus = PDF_DATAAVAIL_ERROR; 3277 m_docStatus = PDF_DATAAVAIL_ERROR;
3271 return FALSE; 3278 return FALSE;
3272 } 3279 }
3273 CPDF_Object *pKids = pPages->GetDict()->GetElement(FX_BSTRC("Kids")); 3280 CPDF_Dictionary* pDict = pPages->GetDict();
3281 CPDF_Object *pKids = pDict ? pDict->GetElement(FX_BSTRC("Kids")) : NULL;
3274 if (!pKids) { 3282 if (!pKids) {
3275 return TRUE; 3283 return TRUE;
3276 } 3284 }
3277 switch (pKids->GetType()) { 3285 switch (pKids->GetType()) {
3278 case PDFOBJ_REFERENCE: { 3286 case PDFOBJ_REFERENCE: {
3279 CPDF_Reference *pKid = (CPDF_Reference *)pKids; 3287 CPDF_Reference *pKid = (CPDF_Reference *)pKids;
3280 m_PageObjList.Add(pKid->GetRefObjNum()); 3288 m_PageObjList.Add(pKid->GetRefObjNum());
3281 } 3289 }
3282 break; 3290 break;
3283 case PDFOBJ_ARRAY: { 3291 case PDFOBJ_ARRAY: {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 m_docStatus = PDF_DATAAVAIL_END; 3345 m_docStatus = PDF_DATAAVAIL_END;
3338 } 3346 }
3339 return TRUE; 3347 return TRUE;
3340 } 3348 }
3341 pHints->AddSegment(0, req_size); 3349 pHints->AddSegment(0, req_size);
3342 return FALSE; 3350 return FALSE;
3343 } 3351 }
3344 FX_BOOL CPDF_DataAvail::CheckFirstPage(IFX_DownloadHints *pHints) 3352 FX_BOOL CPDF_DataAvail::CheckFirstPage(IFX_DownloadHints *pHints)
3345 { 3353 {
3346 FX_DWORD dwFirstPageEndOffset = 0; 3354 FX_DWORD dwFirstPageEndOffset = 0;
3347 CPDF_Object *pEndOffSet = m_pLinearized->GetDict()->GetElement(FX_BSTRC("E") ); 3355 CPDF_Dictionary* pDict = m_pLinearized->GetDict();
3356 CPDF_Object *pEndOffSet = pDict ? pDict->GetElement(FX_BSTRC("E")) : NULL;
3348 if (!pEndOffSet) { 3357 if (!pEndOffSet) {
3349 m_docStatus = PDF_DATAAVAIL_ERROR; 3358 m_docStatus = PDF_DATAAVAIL_ERROR;
3350 return FALSE; 3359 return FALSE;
3351 } 3360 }
3352 CPDF_Object *pXRefOffset = m_pLinearized->GetDict()->GetElement(FX_BSTRC("T ")); 3361 CPDF_Object *pXRefOffset = pDict ? pDict->GetElement(FX_BSTRC("T")) : NULL;
3353 if (!pXRefOffset) { 3362 if (!pXRefOffset) {
3354 m_docStatus = PDF_DATAAVAIL_ERROR; 3363 m_docStatus = PDF_DATAAVAIL_ERROR;
3355 return FALSE; 3364 return FALSE;
3356 } 3365 }
3357 CPDF_Object *pFileLen = m_pLinearized->GetDict()->GetElement(FX_BSTRC("L")); 3366 CPDF_Object *pFileLen = pDict ? pDict->GetElement(FX_BSTRC("L")) : NULL;
3358 if (!pFileLen) { 3367 if (!pFileLen) {
3359 m_docStatus = PDF_DATAAVAIL_ERROR; 3368 m_docStatus = PDF_DATAAVAIL_ERROR;
3360 return FALSE; 3369 return FALSE;
3361 } 3370 }
3362 FX_BOOL bNeedDownLoad = FALSE; 3371 FX_BOOL bNeedDownLoad = FALSE;
3363 if (pEndOffSet->GetType() == PDFOBJ_NUMBER) { 3372 if (pEndOffSet->GetType() == PDFOBJ_NUMBER) {
3364 FX_DWORD dwEnd = pEndOffSet->GetInteger(); 3373 FX_DWORD dwEnd = pEndOffSet->GetInteger();
3365 dwEnd += 512; 3374 dwEnd += 512;
3366 if ((FX_FILESIZE)dwEnd > m_dwFileLen) { 3375 if ((FX_FILESIZE)dwEnd > m_dwFileLen) {
3367 dwEnd = (FX_DWORD)m_dwFileLen; 3376 dwEnd = (FX_DWORD)m_dwFileLen;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3466 } 3475 }
3467 FX_DWORD objnum = FXSYS_atoi(wordObjNum); 3476 FX_DWORD objnum = FXSYS_atoi(wordObjNum);
3468 if (m_pLinearized) { 3477 if (m_pLinearized) {
3469 m_pLinearized->Release(); 3478 m_pLinearized->Release();
3470 m_pLinearized = NULL; 3479 m_pLinearized = NULL;
3471 } 3480 }
3472 m_pLinearized = ParseIndirectObjectAt(m_syntaxParser.m_HeaderOffset + 9, obj num); 3481 m_pLinearized = ParseIndirectObjectAt(m_syntaxParser.m_HeaderOffset + 9, obj num);
3473 if (!m_pLinearized) { 3482 if (!m_pLinearized) {
3474 return FALSE; 3483 return FALSE;
3475 } 3484 }
3476 if (m_pLinearized->GetDict()->GetElement(FX_BSTRC("Linearized"))) { 3485 if (m_pLinearized->GetDict() && m_pLinearized->GetDict()->GetElement(FX_BSTR C("Linearized"))) {
3477 CPDF_Object *pLen = m_pLinearized->GetDict()->GetElement(FX_BSTRC("L")); 3486 CPDF_Object *pLen = m_pLinearized->GetDict()->GetElement(FX_BSTRC("L"));
3478 if (!pLen) { 3487 if (!pLen) {
3479 return FALSE; 3488 return FALSE;
3480 } 3489 }
3481 if ((FX_FILESIZE)pLen->GetInteger() != m_pFileRead->GetSize()) { 3490 if ((FX_FILESIZE)pLen->GetInteger() != m_pFileRead->GetSize()) {
3482 return FALSE; 3491 return FALSE;
3483 } 3492 }
3484 m_bLinearized = TRUE; 3493 m_bLinearized = TRUE;
3485 CPDF_Object *pNo = m_pLinearized->GetDict()->GetElement(FX_BSTRC("P")); 3494 CPDF_Object *pNo = m_pLinearized->GetDict()->GetElement(FX_BSTRC("P"));
3486 if (pNo && pNo->GetType() == PDFOBJ_NUMBER) { 3495 if (pNo && pNo->GetType() == PDFOBJ_NUMBER) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber); 3550 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber);
3542 if (!bNumber) { 3551 if (!bNumber) {
3543 return -1; 3552 return -1;
3544 } 3553 }
3545 FX_DWORD objNum = FXSYS_atoi(objnum); 3554 FX_DWORD objNum = FXSYS_atoi(objnum);
3546 CPDF_Object *pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL ); 3555 CPDF_Object *pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL );
3547 if (!pObj) { 3556 if (!pObj) {
3548 m_Pos += m_parser.m_Syntax.SavePos(); 3557 m_Pos += m_parser.m_Syntax.SavePos();
3549 return 0; 3558 return 0;
3550 } 3559 }
3551 CPDF_Object *pName = pObj->GetDict()->GetElement(FX_BSTRC("Type")); 3560 CPDF_Dictionary* pDict = pObj->GetDict();
3561 CPDF_Object *pName = pDict ? pDict->GetElement(FX_BSTRC("Type")) : NULL;
3552 if (pName && pName->GetType() == PDFOBJ_NAME) { 3562 if (pName && pName->GetType() == PDFOBJ_NAME) {
3553 if (pName->GetString() == FX_BSTRC("XRef")) { 3563 if (pName->GetString() == FX_BSTRC("XRef")) {
3554 m_Pos += m_parser.m_Syntax.SavePos(); 3564 m_Pos += m_parser.m_Syntax.SavePos();
3555 xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev")); 3565 xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev"));
3556 pObj->Release(); 3566 pObj->Release();
3557 return 1; 3567 return 1;
3558 } else { 3568 } else {
3559 pObj->Release(); 3569 pObj->Release();
3560 return -1; 3570 return -1;
3561 } 3571 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
3901 pPageNode->m_type = PDF_PAGENODE_ARRAY; 3911 pPageNode->m_type = PDF_PAGENODE_ARRAY;
3902 pPage->Release(); 3912 pPage->Release();
3903 return TRUE; 3913 return TRUE;
3904 } 3914 }
3905 if (pPage->GetType() != PDFOBJ_DICTIONARY) { 3915 if (pPage->GetType() != PDFOBJ_DICTIONARY) {
3906 pPage->Release(); 3916 pPage->Release();
3907 m_docStatus = PDF_DATAAVAIL_ERROR; 3917 m_docStatus = PDF_DATAAVAIL_ERROR;
3908 return FALSE; 3918 return FALSE;
3909 } 3919 }
3910 pPageNode->m_dwPageNo = dwPageNo; 3920 pPageNode->m_dwPageNo = dwPageNo;
3911 CFX_ByteString type = pPage->GetDict()->GetString(FX_BSTRC("Type")); 3921 CPDF_Dictionary* pDict = pPage->GetDict();
3922 CFX_ByteString type = pDict ? pDict->GetString(FX_BSTRC("Type")) : CFX_ByteS tring();
3912 if (type == FX_BSTRC("Pages")) { 3923 if (type == FX_BSTRC("Pages")) {
3913 pPageNode->m_type = PDF_PAGENODE_PAGES; 3924 pPageNode->m_type = PDF_PAGENODE_PAGES;
3914 CPDF_Object *pKids = pPage->GetDict()->GetElement(FX_BSTRC("Kids")); 3925 CPDF_Object *pKids = pDict->GetElement(FX_BSTRC("Kids"));
3915 if (!pKids) { 3926 if (!pKids) {
3916 m_docStatus = PDF_DATAAVAIL_PAGE; 3927 m_docStatus = PDF_DATAAVAIL_PAGE;
3917 return TRUE; 3928 return TRUE;
3918 } 3929 }
3919 switch (pKids->GetType()) { 3930 switch (pKids->GetType()) {
3920 case PDFOBJ_REFERENCE: { 3931 case PDFOBJ_REFERENCE: {
3921 CPDF_Reference *pKid = (CPDF_Reference *)pKids; 3932 CPDF_Reference *pKid = (CPDF_Reference *)pKids;
3922 CPDF_PageNode *pNode = FX_NEW CPDF_PageNode(); 3933 CPDF_PageNode *pNode = FX_NEW CPDF_PageNode();
3923 pPageNode->m_childNode.Add(pNode); 3934 pPageNode->m_childNode.Add(pNode);
3924 pNode->m_dwPageNo = pKid->GetRefObjNum(); 3935 pNode->m_dwPageNo = pKid->GetRefObjNum();
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
4369 { 4380 {
4370 FX_INT32 iSize = m_childNode.GetSize(); 4381 FX_INT32 iSize = m_childNode.GetSize();
4371 for (FX_INT32 i = 0; i < iSize; ++i) { 4382 for (FX_INT32 i = 0; i < iSize; ++i) {
4372 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; 4383 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i];
4373 if (pNode) { 4384 if (pNode) {
4374 delete pNode; 4385 delete pNode;
4375 } 4386 }
4376 } 4387 }
4377 m_childNode.RemoveAll(); 4388 m_childNode.RemoveAll();
4378 } 4389 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698