Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "../../../../third_party/base/nonstd_unique_ptr.h" | 11 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
| 12 #include "../../../include/fpdfapi/fpdf_module.h" | 12 #include "../../../include/fpdfapi/fpdf_module.h" |
| 13 #include "../../../include/fpdfapi/fpdf_page.h" | 13 #include "../../../include/fpdfapi/fpdf_page.h" |
| 14 #include "../../../include/fpdfapi/fpdf_parser.h" | 14 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 15 #include "../../../include/fxcrt/fx_safe_types.h" | 15 #include "../../../include/fxcrt/fx_safe_types.h" |
| 16 #include "../fpdf_page/pageint.h" | 16 #include "../fpdf_page/pageint.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 struct SearchTagRecord { | |
| 21 const uint8_t* m_pTag; | |
| 22 FX_DWORD m_Len; | |
| 23 FX_DWORD m_Offset; | |
| 24 }; | |
| 25 | |
| 20 int CompareFileSize(const void* p1, const void* p2) { | 26 int CompareFileSize(const void* p1, const void* p2) { |
| 21 return *(FX_FILESIZE*)p1 - *(FX_FILESIZE*)p2; | 27 return *(FX_FILESIZE*)p1 - *(FX_FILESIZE*)p2; |
| 22 } | 28 } |
| 23 | 29 |
| 24 int32_t GetHeaderOffset(IFX_FileRead* pFile) { | 30 int32_t GetHeaderOffset(IFX_FileRead* pFile) { |
| 25 const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025); | 31 const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025); |
| 26 const size_t kBufSize = 4; | 32 const size_t kBufSize = 4; |
| 27 uint8_t buf[kBufSize]; | 33 uint8_t buf[kBufSize]; |
| 28 int32_t offset = 0; | 34 int32_t offset = 0; |
| 29 while (offset <= 1024) { | 35 while (offset <= 1024) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 52 return !pObj || pObj->GetType() == iType; | 58 return !pObj || pObj->GetType() == iType; |
| 53 } | 59 } |
| 54 | 60 |
| 55 FX_DWORD GetVarInt(const uint8_t* p, int32_t n) { | 61 FX_DWORD GetVarInt(const uint8_t* p, int32_t n) { |
| 56 FX_DWORD result = 0; | 62 FX_DWORD result = 0; |
| 57 for (int32_t i = 0; i < n; ++i) | 63 for (int32_t i = 0; i < n; ++i) |
| 58 result = result * 256 + p[i]; | 64 result = result * 256 + p[i]; |
| 59 return result; | 65 return result; |
| 60 } | 66 } |
| 61 | 67 |
| 68 int32_t GetStreamNCount(CPDF_StreamAcc* pObjStream) { | |
| 69 return pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); | |
|
Tom Sepez
2015/10/09 16:47:32
I don't think we need the BSTRC() macros, really,
Lei Zhang
2015/10/19 08:05:51
Acknowledged.
| |
| 70 } | |
| 71 | |
| 72 int32_t GetStreamFirst(CPDF_StreamAcc* pObjStream) { | |
| 73 return pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); | |
| 74 } | |
| 75 | |
| 62 } // namespace | 76 } // namespace |
| 63 | 77 |
| 64 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) { | 78 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) { |
| 65 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); | 79 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); |
| 66 if (!pType) { | 80 if (!pType) { |
| 67 pType = pDict->GetElementValue(FX_BSTRC("FT")); | 81 pType = pDict->GetElementValue(FX_BSTRC("FT")); |
| 68 if (!pType) { | 82 if (!pType) { |
| 69 return FALSE; | 83 return FALSE; |
| 70 } | 84 } |
| 71 } | 85 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 return FALSE; | 368 return FALSE; |
| 355 } | 369 } |
| 356 FX_FILESIZE newxrefpos = GetDirectInteger(m_pTrailer, FX_BSTRC("Prev")); | 370 FX_FILESIZE newxrefpos = GetDirectInteger(m_pTrailer, FX_BSTRC("Prev")); |
| 357 if (newxrefpos == xrefpos) { | 371 if (newxrefpos == xrefpos) { |
| 358 return FALSE; | 372 return FALSE; |
| 359 } | 373 } |
| 360 xrefpos = newxrefpos; | 374 xrefpos = newxrefpos; |
| 361 while (xrefpos) { | 375 while (xrefpos) { |
| 362 CrossRefList.InsertAt(0, xrefpos); | 376 CrossRefList.InsertAt(0, xrefpos); |
| 363 LoadCrossRefV4(xrefpos, 0, TRUE, FALSE); | 377 LoadCrossRefV4(xrefpos, 0, TRUE, FALSE); |
| 364 CPDF_Dictionary* pDict = LoadTrailerV4(); | 378 nonstd::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( |
| 365 if (pDict == NULL) { | 379 LoadTrailerV4()); |
| 380 if (!pDict) | |
| 366 return FALSE; | 381 return FALSE; |
| 367 } | 382 |
| 368 if (!CheckDirectType(pDict, FX_BSTRC("Prev"), PDFOBJ_NUMBER)) { | 383 if (!CheckDirectType(pDict.get(), FX_BSTRC("Prev"), PDFOBJ_NUMBER)) |
| 369 pDict->Release(); | |
| 370 return FALSE; | 384 return FALSE; |
| 371 } | 385 |
| 372 newxrefpos = GetDirectInteger(pDict, FX_BSTRC("Prev")); | 386 newxrefpos = GetDirectInteger(pDict.get(), FX_BSTRC("Prev")); |
| 373 if (newxrefpos == xrefpos) { | 387 if (newxrefpos == xrefpos) |
| 374 pDict->Release(); | |
| 375 return FALSE; | 388 return FALSE; |
| 376 } | 389 |
| 377 xrefpos = newxrefpos; | 390 xrefpos = newxrefpos; |
| 378 XRefStreamList.InsertAt(0, pDict->GetInteger(FX_BSTRC("XRefStm"))); | 391 XRefStreamList.InsertAt(0, pDict->GetInteger(FX_BSTRC("XRefStm"))); |
| 379 m_Trailers.Add(pDict); | 392 m_Trailers.Add(pDict.release()); |
| 380 } | 393 } |
| 381 for (int32_t i = 0; i < CrossRefList.GetSize(); i++) | 394 for (int32_t i = 0; i < CrossRefList.GetSize(); i++) { |
| 382 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE, i == 0)) { | 395 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE, i == 0)) { |
|
Tom Sepez
2015/10/09 16:47:31
nit: no braces here. Yes braces above.
Lei Zhang
2015/10/19 08:05:51
Done.
| |
| 383 return FALSE; | 396 return FALSE; |
| 384 } | 397 } |
| 398 } | |
| 385 return TRUE; | 399 return TRUE; |
| 386 } | 400 } |
| 387 FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, | 401 FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, |
| 388 FX_DWORD dwObjCount) { | 402 FX_DWORD dwObjCount) { |
| 389 if (!LoadLinearizedCrossRefV4(xrefpos, dwObjCount)) { | 403 if (!LoadLinearizedCrossRefV4(xrefpos, dwObjCount)) { |
| 390 return FALSE; | 404 return FALSE; |
| 391 } | 405 } |
| 392 m_pTrailer = LoadTrailerV4(); | 406 m_pTrailer = LoadTrailerV4(); |
| 393 if (m_pTrailer == NULL) { | 407 if (m_pTrailer == NULL) { |
| 394 return FALSE; | 408 return FALSE; |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 m_SortedOffset.GetSize() - 1) { | 1204 m_SortedOffset.GetSize() - 1) { |
| 1191 return FALSE; | 1205 return FALSE; |
| 1192 } | 1206 } |
| 1193 FX_FILESIZE size = ((FX_FILESIZE*)pResult)[1] - pos; | 1207 FX_FILESIZE size = ((FX_FILESIZE*)pResult)[1] - pos; |
| 1194 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 1208 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
| 1195 m_Syntax.RestorePos(pos); | 1209 m_Syntax.RestorePos(pos); |
| 1196 bForm = m_Syntax.SearchMultiWord(FX_BSTRC("/Form\0stream"), TRUE, size) == 0; | 1210 bForm = m_Syntax.SearchMultiWord(FX_BSTRC("/Form\0stream"), TRUE, size) == 0; |
| 1197 m_Syntax.RestorePos(SavedPos); | 1211 m_Syntax.RestorePos(SavedPos); |
| 1198 return TRUE; | 1212 return TRUE; |
| 1199 } | 1213 } |
| 1214 | |
| 1200 CPDF_Object* CPDF_Parser::ParseIndirectObject(CPDF_IndirectObjects* pObjList, | 1215 CPDF_Object* CPDF_Parser::ParseIndirectObject(CPDF_IndirectObjects* pObjList, |
| 1201 FX_DWORD objnum, | 1216 FX_DWORD objnum, |
| 1202 PARSE_CONTEXT* pContext) { | 1217 PARSE_CONTEXT* pContext) { |
| 1203 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { | 1218 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) |
| 1204 return NULL; | 1219 return nullptr; |
| 1205 } | 1220 |
| 1206 if (m_V5Type[objnum] == 1 || m_V5Type[objnum] == 255) { | 1221 if (m_V5Type[objnum] == 1 || m_V5Type[objnum] == 255) { |
| 1207 FX_FILESIZE pos = m_CrossRef[objnum]; | 1222 FX_FILESIZE pos = m_CrossRef[objnum]; |
| 1208 if (pos <= 0) { | 1223 if (pos <= 0) |
| 1209 return NULL; | 1224 return nullptr; |
| 1210 } | |
| 1211 return ParseIndirectObjectAt(pObjList, pos, objnum, pContext); | 1225 return ParseIndirectObjectAt(pObjList, pos, objnum, pContext); |
| 1212 } | 1226 } |
| 1213 if (m_V5Type[objnum] == 2) { | 1227 if (m_V5Type[objnum] != 2) |
| 1214 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum]); | 1228 return nullptr; |
| 1215 if (pObjStream == NULL) { | 1229 |
| 1216 return NULL; | 1230 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum]); |
| 1231 if (!pObjStream) | |
| 1232 return nullptr; | |
| 1233 | |
| 1234 nonstd::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>> file( | |
| 1235 FX_CreateMemoryStream((uint8_t*)pObjStream->GetData(), | |
| 1236 (size_t)pObjStream->GetSize(), FALSE)); | |
| 1237 CPDF_SyntaxParser syntax; | |
| 1238 syntax.InitParser(file.get(), 0); | |
| 1239 int32_t offset = GetStreamFirst(pObjStream); | |
| 1240 for (int32_t i = GetStreamNCount(pObjStream); i > 0; --i) { | |
| 1241 FX_DWORD thisnum = syntax.GetDirectNum(); | |
| 1242 FX_DWORD thisoff = syntax.GetDirectNum(); | |
| 1243 if (thisnum == objnum) { | |
| 1244 syntax.RestorePos(offset + thisoff); | |
| 1245 return syntax.GetObject(pObjList, 0, 0, pContext); | |
| 1217 } | 1246 } |
| 1218 int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); | |
| 1219 int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); | |
| 1220 CPDF_SyntaxParser syntax; | |
| 1221 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream( | |
| 1222 (uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); | |
| 1223 syntax.InitParser(file.Get(), 0); | |
| 1224 CPDF_Object* pRet = NULL; | |
| 1225 while (n) { | |
| 1226 FX_DWORD thisnum = syntax.GetDirectNum(); | |
| 1227 FX_DWORD thisoff = syntax.GetDirectNum(); | |
| 1228 if (thisnum == objnum) { | |
| 1229 syntax.RestorePos(offset + thisoff); | |
| 1230 pRet = syntax.GetObject(pObjList, 0, 0, pContext); | |
| 1231 break; | |
| 1232 } | |
| 1233 n--; | |
| 1234 } | |
| 1235 return pRet; | |
| 1236 } | 1247 } |
| 1237 return NULL; | 1248 return nullptr; |
| 1238 } | 1249 } |
| 1250 | |
| 1239 CPDF_StreamAcc* CPDF_Parser::GetObjectStream(FX_DWORD objnum) { | 1251 CPDF_StreamAcc* CPDF_Parser::GetObjectStream(FX_DWORD objnum) { |
| 1240 CPDF_StreamAcc* pStreamAcc = NULL; | 1252 CPDF_StreamAcc* pStreamAcc = NULL; |
| 1241 if (m_ObjectStreamMap.Lookup((void*)(uintptr_t)objnum, (void*&)pStreamAcc)) { | 1253 if (m_ObjectStreamMap.Lookup((void*)(uintptr_t)objnum, (void*&)pStreamAcc)) { |
| 1242 return pStreamAcc; | 1254 return pStreamAcc; |
| 1243 } | 1255 } |
| 1244 const CPDF_Stream* pStream = | 1256 const CPDF_Stream* pStream = |
| 1245 m_pDocument ? (CPDF_Stream*)m_pDocument->GetIndirectObject(objnum) : NULL; | 1257 m_pDocument ? (CPDF_Stream*)m_pDocument->GetIndirectObject(objnum) : NULL; |
| 1246 if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM) { | 1258 if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM) { |
| 1247 return NULL; | 1259 return NULL; |
| 1248 } | 1260 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1279 } | 1291 } |
| 1280 void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, | 1292 void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, |
| 1281 uint8_t*& pBuffer, | 1293 uint8_t*& pBuffer, |
| 1282 FX_DWORD& size) { | 1294 FX_DWORD& size) { |
| 1283 pBuffer = NULL; | 1295 pBuffer = NULL; |
| 1284 size = 0; | 1296 size = 0; |
| 1285 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { | 1297 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { |
| 1286 return; | 1298 return; |
| 1287 } | 1299 } |
| 1288 if (m_V5Type[objnum] == 2) { | 1300 if (m_V5Type[objnum] == 2) { |
| 1289 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum]); | 1301 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum]); |
|
Tom Sepez
2015/10/09 16:47:32
nit: for another day, every time we seem to use m_
Lei Zhang
2015/10/19 08:05:51
Acknowledged.
| |
| 1290 if (pObjStream == NULL) { | 1302 if (!pObjStream) |
| 1291 return; | 1303 return; |
| 1292 } | 1304 |
| 1293 int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); | 1305 int32_t offset = GetStreamFirst(pObjStream); |
| 1294 int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); | |
| 1295 CPDF_SyntaxParser syntax; | |
| 1296 const uint8_t* pData = pObjStream->GetData(); | 1306 const uint8_t* pData = pObjStream->GetData(); |
| 1297 FX_DWORD totalsize = pObjStream->GetSize(); | 1307 FX_DWORD totalsize = pObjStream->GetSize(); |
| 1298 CFX_SmartPointer<IFX_FileStream> file( | 1308 nonstd::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>> file( |
| 1299 FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, FALSE)); | 1309 FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, FALSE)); |
| 1300 syntax.InitParser(file.Get(), 0); | 1310 CPDF_SyntaxParser syntax; |
| 1301 while (n) { | 1311 syntax.InitParser(file.get(), 0); |
| 1312 for (int i = GetStreamNCount(pObjStream); i > 0; --i) { | |
| 1302 FX_DWORD thisnum = syntax.GetDirectNum(); | 1313 FX_DWORD thisnum = syntax.GetDirectNum(); |
| 1303 FX_DWORD thisoff = syntax.GetDirectNum(); | 1314 FX_DWORD thisoff = syntax.GetDirectNum(); |
| 1304 if (thisnum == objnum) { | 1315 if (thisnum != objnum) |
| 1305 if (n == 1) { | 1316 continue; |
| 1306 size = totalsize - (thisoff + offset); | 1317 |
| 1307 } else { | 1318 if (i == 1) { |
| 1308 syntax.GetDirectNum(); // Skip nextnum. | 1319 size = totalsize - (thisoff + offset); |
| 1309 FX_DWORD nextoff = syntax.GetDirectNum(); | 1320 } else { |
| 1310 size = nextoff - thisoff; | 1321 syntax.GetDirectNum(); // Skip nextnum. |
| 1311 } | 1322 FX_DWORD nextoff = syntax.GetDirectNum(); |
| 1312 pBuffer = FX_Alloc(uint8_t, size); | 1323 size = nextoff - thisoff; |
| 1313 FXSYS_memcpy(pBuffer, pData + thisoff + offset, size); | |
| 1314 return; | |
| 1315 } | 1324 } |
| 1316 n--; | 1325 pBuffer = FX_Alloc(uint8_t, size); |
| 1326 FXSYS_memcpy(pBuffer, pData + thisoff + offset, size); | |
| 1327 return; | |
| 1317 } | 1328 } |
| 1318 return; | 1329 return; |
| 1319 } | 1330 } |
| 1320 if (m_V5Type[objnum] == 1) { | 1331 |
| 1321 FX_FILESIZE pos = m_CrossRef[objnum]; | 1332 if (m_V5Type[objnum] != 1) |
| 1322 if (pos == 0) { | 1333 return; |
| 1323 return; | 1334 |
| 1324 } | 1335 FX_FILESIZE pos = m_CrossRef[objnum]; |
| 1325 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 1336 if (pos == 0) { |
| 1326 m_Syntax.RestorePos(pos); | 1337 return; |
| 1327 FX_BOOL bIsNumber; | 1338 } |
| 1328 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); | 1339 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
| 1329 if (!bIsNumber) { | 1340 m_Syntax.RestorePos(pos); |
| 1330 m_Syntax.RestorePos(SavedPos); | 1341 FX_BOOL bIsNumber; |
| 1331 return; | 1342 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); |
|
Tom Sepez
2015/10/09 16:47:32
nit: someday getnextword should take &bIsNumber ra
Lei Zhang
2015/10/19 08:05:51
Acknowledged.
| |
| 1332 } | 1343 if (!bIsNumber) { |
| 1333 FX_DWORD parser_objnum = FXSYS_atoi(word); | 1344 m_Syntax.RestorePos(SavedPos); |
| 1334 if (parser_objnum && parser_objnum != objnum) { | 1345 return; |
| 1335 m_Syntax.RestorePos(SavedPos); | 1346 } |
| 1336 return; | 1347 FX_DWORD parser_objnum = FXSYS_atoi(word); |
| 1337 } | 1348 if (parser_objnum && parser_objnum != objnum) { |
| 1349 m_Syntax.RestorePos(SavedPos); | |
| 1350 return; | |
| 1351 } | |
| 1352 word = m_Syntax.GetNextWord(bIsNumber); | |
| 1353 if (!bIsNumber) { | |
| 1354 m_Syntax.RestorePos(SavedPos); | |
| 1355 return; | |
| 1356 } | |
| 1357 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | |
| 1358 m_Syntax.RestorePos(SavedPos); | |
| 1359 return; | |
| 1360 } | |
| 1361 void* pResult = | |
| 1362 FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), | |
| 1363 sizeof(FX_FILESIZE), CompareFileSize); | |
| 1364 if (pResult == NULL) { | |
| 1365 m_Syntax.RestorePos(SavedPos); | |
| 1366 return; | |
| 1367 } | |
| 1368 FX_FILESIZE nextoff = ((FX_FILESIZE*)pResult)[1]; | |
| 1369 FX_BOOL bNextOffValid = FALSE; | |
| 1370 if (nextoff != pos) { | |
| 1371 m_Syntax.RestorePos(nextoff); | |
| 1338 word = m_Syntax.GetNextWord(bIsNumber); | 1372 word = m_Syntax.GetNextWord(bIsNumber); |
| 1339 if (!bIsNumber) { | 1373 if (word == FX_BSTRC("xref")) { |
| 1340 m_Syntax.RestorePos(SavedPos); | 1374 bNextOffValid = TRUE; |
| 1341 return; | 1375 } else if (bIsNumber) { |
| 1342 } | |
| 1343 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | |
| 1344 m_Syntax.RestorePos(SavedPos); | |
| 1345 return; | |
| 1346 } | |
| 1347 void* pResult = | |
| 1348 FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), | |
| 1349 sizeof(FX_FILESIZE), CompareFileSize); | |
| 1350 if (pResult == NULL) { | |
| 1351 m_Syntax.RestorePos(SavedPos); | |
| 1352 return; | |
| 1353 } | |
| 1354 FX_FILESIZE nextoff = ((FX_FILESIZE*)pResult)[1]; | |
| 1355 FX_BOOL bNextOffValid = FALSE; | |
| 1356 if (nextoff != pos) { | |
| 1357 m_Syntax.RestorePos(nextoff); | |
| 1358 word = m_Syntax.GetNextWord(bIsNumber); | 1376 word = m_Syntax.GetNextWord(bIsNumber); |
| 1359 if (word == FX_BSTRC("xref")) { | 1377 if (bIsNumber && m_Syntax.GetKeyword() == FX_BSTRC("obj")) { |
| 1360 bNextOffValid = TRUE; | 1378 bNextOffValid = TRUE; |
| 1361 } else if (bIsNumber) { | |
| 1362 word = m_Syntax.GetNextWord(bIsNumber); | |
| 1363 if (bIsNumber && m_Syntax.GetKeyword() == FX_BSTRC("obj")) { | |
| 1364 bNextOffValid = TRUE; | |
| 1365 } | |
| 1366 } | 1379 } |
| 1367 } | 1380 } |
| 1368 if (!bNextOffValid) { | 1381 } |
| 1369 m_Syntax.RestorePos(pos); | 1382 if (!bNextOffValid) { |
| 1370 while (1) { | 1383 m_Syntax.RestorePos(pos); |
| 1371 if (m_Syntax.GetKeyword() == FX_BSTRC("endobj")) { | 1384 while (1) { |
| 1372 break; | 1385 if (m_Syntax.GetKeyword() == FX_BSTRC("endobj")) { |
| 1373 } | 1386 break; |
| 1374 if (m_Syntax.SavePos() == m_Syntax.m_FileLen) { | |
| 1375 break; | |
| 1376 } | |
| 1377 } | 1387 } |
| 1378 nextoff = m_Syntax.SavePos(); | 1388 if (m_Syntax.SavePos() == m_Syntax.m_FileLen) { |
| 1389 break; | |
| 1390 } | |
| 1379 } | 1391 } |
| 1380 size = (FX_DWORD)(nextoff - pos); | 1392 nextoff = m_Syntax.SavePos(); |
| 1381 pBuffer = FX_Alloc(uint8_t, size); | |
| 1382 m_Syntax.RestorePos(pos); | |
| 1383 m_Syntax.ReadBlock(pBuffer, size); | |
| 1384 m_Syntax.RestorePos(SavedPos); | |
| 1385 } | 1393 } |
| 1394 size = (FX_DWORD)(nextoff - pos); | |
| 1395 pBuffer = FX_Alloc(uint8_t, size); | |
| 1396 m_Syntax.RestorePos(pos); | |
| 1397 m_Syntax.ReadBlock(pBuffer, size); | |
| 1398 m_Syntax.RestorePos(SavedPos); | |
| 1386 } | 1399 } |
| 1400 | |
| 1387 CPDF_Object* CPDF_Parser::ParseIndirectObjectAt(CPDF_IndirectObjects* pObjList, | 1401 CPDF_Object* CPDF_Parser::ParseIndirectObjectAt(CPDF_IndirectObjects* pObjList, |
| 1388 FX_FILESIZE pos, | 1402 FX_FILESIZE pos, |
| 1389 FX_DWORD objnum, | 1403 FX_DWORD objnum, |
| 1390 PARSE_CONTEXT* pContext) { | 1404 PARSE_CONTEXT* pContext) { |
| 1391 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 1405 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
| 1392 m_Syntax.RestorePos(pos); | 1406 m_Syntax.RestorePos(pos); |
| 1393 FX_BOOL bIsNumber; | 1407 FX_BOOL bIsNumber; |
| 1394 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); | 1408 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); |
| 1395 if (!bIsNumber) { | 1409 if (!bIsNumber) { |
| 1396 m_Syntax.RestorePos(SavedPos); | 1410 m_Syntax.RestorePos(SavedPos); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1459 return NULL; | 1473 return NULL; |
| 1460 } | 1474 } |
| 1461 CPDF_Object* pObj = | 1475 CPDF_Object* pObj = |
| 1462 m_Syntax.GetObjectByStrict(pObjList, objnum, gennum, pContext); | 1476 m_Syntax.GetObjectByStrict(pObjList, objnum, gennum, pContext); |
| 1463 if (pResultPos) { | 1477 if (pResultPos) { |
| 1464 *pResultPos = m_Syntax.m_Pos; | 1478 *pResultPos = m_Syntax.m_Pos; |
| 1465 } | 1479 } |
| 1466 m_Syntax.RestorePos(SavedPos); | 1480 m_Syntax.RestorePos(SavedPos); |
| 1467 return pObj; | 1481 return pObj; |
| 1468 } | 1482 } |
| 1483 | |
| 1469 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { | 1484 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { |
| 1470 if (m_Syntax.GetKeyword() != FX_BSTRC("trailer")) { | 1485 if (m_Syntax.GetKeyword() != FX_BSTRC("trailer")) |
| 1471 return NULL; | 1486 return nullptr; |
| 1472 } | 1487 |
| 1473 CPDF_Object* pObj = m_Syntax.GetObject(m_pDocument, 0, 0, 0); | 1488 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( |
| 1474 if (pObj == NULL || pObj->GetType() != PDFOBJ_DICTIONARY) { | 1489 m_Syntax.GetObject(m_pDocument, 0, 0, 0)); |
| 1475 if (pObj) { | 1490 if (!pObj || pObj->GetType() != PDFOBJ_DICTIONARY) |
| 1476 pObj->Release(); | 1491 return nullptr; |
| 1477 } | 1492 return static_cast<CPDF_Dictionary*>(pObj.release()); |
| 1478 return NULL; | |
| 1479 } | |
| 1480 return (CPDF_Dictionary*)pObj; | |
| 1481 } | 1493 } |
| 1494 | |
| 1482 FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) { | 1495 FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) { |
| 1483 if (m_pSecurityHandler == NULL) { | 1496 if (m_pSecurityHandler == NULL) { |
| 1484 return (FX_DWORD)-1; | 1497 return (FX_DWORD)-1; |
| 1485 } | 1498 } |
| 1486 FX_DWORD dwPermission = m_pSecurityHandler->GetPermissions(); | 1499 FX_DWORD dwPermission = m_pSecurityHandler->GetPermissions(); |
| 1487 if (m_pEncryptDict && | 1500 if (m_pEncryptDict && |
| 1488 m_pEncryptDict->GetString(FX_BSTRC("Filter")) == FX_BSTRC("Standard")) { | 1501 m_pEncryptDict->GetString(FX_BSTRC("Filter")) == FX_BSTRC("Standard")) { |
| 1489 dwPermission &= 0xFFFFFFFC; | 1502 dwPermission &= 0xFFFFFFFC; |
| 1490 dwPermission |= 0xFFFFF0C0; | 1503 dwPermission |= 0xFFFFF0C0; |
| 1491 if (bCheckRevision && m_pEncryptDict->GetInteger(FX_BSTRC("R")) == 2) { | 1504 if (bCheckRevision && m_pEncryptDict->GetInteger(FX_BSTRC("R")) == 2) { |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2126 if (m_pCryptoHandler && bDecrypt) { | 2139 if (m_pCryptoHandler && bDecrypt) { |
| 2127 m_pCryptoHandler->Decrypt(objnum, gennum, str); | 2140 m_pCryptoHandler->Decrypt(objnum, gennum, str); |
| 2128 } | 2141 } |
| 2129 return CPDF_String::Create(str, TRUE); | 2142 return CPDF_String::Create(str, TRUE); |
| 2130 } | 2143 } |
| 2131 if (word == FX_BSTRC("[")) { | 2144 if (word == FX_BSTRC("[")) { |
| 2132 if (bTypeOnly) { | 2145 if (bTypeOnly) { |
| 2133 return (CPDF_Object*)PDFOBJ_ARRAY; | 2146 return (CPDF_Object*)PDFOBJ_ARRAY; |
| 2134 } | 2147 } |
| 2135 CPDF_Array* pArray = CPDF_Array::Create(); | 2148 CPDF_Array* pArray = CPDF_Array::Create(); |
| 2136 while (1) { | 2149 while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum)) |
| 2137 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); | |
| 2138 if (pObj == NULL) { | |
| 2139 return pArray; | |
| 2140 } | |
| 2141 pArray->Add(pObj); | 2150 pArray->Add(pObj); |
| 2142 } | 2151 return pArray; |
|
Tom Sepez
2015/10/09 16:47:32
nit: maybe blank line here.
Lei Zhang
2015/10/19 08:05:51
Done.
| |
| 2143 } | 2152 } |
| 2144 if (word[0] == '/') { | 2153 if (word[0] == '/') { |
| 2145 if (bTypeOnly) { | 2154 if (bTypeOnly) { |
| 2146 return (CPDF_Object*)PDFOBJ_NAME; | 2155 return (CPDF_Object*)PDFOBJ_NAME; |
| 2147 } | 2156 } |
| 2148 return CPDF_Name::Create( | 2157 return CPDF_Name::Create( |
| 2149 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); | 2158 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); |
| 2150 } | 2159 } |
| 2151 if (word == FX_BSTRC("<<")) { | 2160 if (word == FX_BSTRC("<<")) { |
| 2152 if (bTypeOnly) { | 2161 if (bTypeOnly) |
| 2153 return (CPDF_Object*)PDFOBJ_DICTIONARY; | 2162 return (CPDF_Object*)PDFOBJ_DICTIONARY; |
| 2154 } | 2163 |
| 2155 if (pContext) { | 2164 if (pContext) |
| 2156 pContext->m_DictStart = SavedPos; | 2165 pContext->m_DictStart = SavedPos; |
| 2157 } | 2166 |
| 2158 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); | |
| 2159 int32_t nKeys = 0; | 2167 int32_t nKeys = 0; |
| 2160 FX_FILESIZE dwSignValuePos = 0; | 2168 FX_FILESIZE dwSignValuePos = 0; |
| 2169 nonstd::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( | |
| 2170 CPDF_Dictionary::Create()); | |
| 2161 while (1) { | 2171 while (1) { |
| 2162 FX_BOOL bIsNumber; | 2172 FX_BOOL bIsNumber; |
| 2163 CFX_ByteString key = GetNextWord(bIsNumber); | 2173 CFX_ByteString key = GetNextWord(bIsNumber); |
| 2164 if (key.IsEmpty()) { | 2174 if (key.IsEmpty()) |
| 2165 if (pDict) | 2175 return nullptr; |
| 2166 pDict->Release(); | 2176 |
| 2167 return NULL; | |
| 2168 } | |
| 2169 FX_FILESIZE SavedPos = m_Pos - key.GetLength(); | 2177 FX_FILESIZE SavedPos = m_Pos - key.GetLength(); |
| 2170 if (key == FX_BSTRC(">>")) { | 2178 if (key == FX_BSTRC(">>")) |
| 2171 break; | 2179 break; |
| 2172 } | 2180 |
| 2173 if (key == FX_BSTRC("endobj")) { | 2181 if (key == FX_BSTRC("endobj")) { |
| 2174 m_Pos = SavedPos; | 2182 m_Pos = SavedPos; |
| 2175 break; | 2183 break; |
| 2176 } | 2184 } |
| 2177 if (key[0] != '/') { | 2185 if (key[0] != '/') |
| 2178 continue; | 2186 continue; |
| 2179 } | 2187 |
| 2180 nKeys++; | 2188 ++nKeys; |
| 2181 key = PDF_NameDecode(key); | 2189 key = PDF_NameDecode(key); |
| 2182 if (key == FX_BSTRC("/Contents")) { | 2190 if (key == FX_BSTRC("/Contents")) |
| 2183 dwSignValuePos = m_Pos; | 2191 dwSignValuePos = m_Pos; |
| 2184 } | 2192 |
| 2185 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); | 2193 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); |
| 2186 if (pObj == NULL) { | 2194 if (!pObj) |
| 2187 continue; | 2195 continue; |
| 2188 } | 2196 |
| 2189 if (key.GetLength() >= 1) { | 2197 if (key.GetLength() >= 1) { |
| 2190 if (nKeys < 32) { | 2198 if (nKeys < 32) { |
| 2191 pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), | 2199 pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), |
| 2192 pObj); | 2200 pObj); |
| 2193 } else { | 2201 } else { |
| 2194 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), | 2202 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), |
| 2195 pObj); | 2203 pObj); |
| 2196 } | 2204 } |
| 2197 } | 2205 } |
| 2198 } | 2206 } |
| 2199 if (IsSignatureDict(pDict)) { | 2207 |
| 2208 if (IsSignatureDict(pDict.get())) { | |
| 2200 FX_FILESIZE dwSavePos = m_Pos; | 2209 FX_FILESIZE dwSavePos = m_Pos; |
| 2201 m_Pos = dwSignValuePos; | 2210 m_Pos = dwSignValuePos; |
| 2202 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, NULL, FALSE); | 2211 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, NULL, FALSE); |
| 2203 pDict->SetAt(FX_BSTRC("Contents"), pObj); | 2212 pDict->SetAt(FX_BSTRC("Contents"), pObj); |
| 2204 m_Pos = dwSavePos; | 2213 m_Pos = dwSavePos; |
| 2205 } | 2214 } |
| 2206 if (pContext) { | 2215 if (pContext) { |
| 2207 pContext->m_DictEnd = m_Pos; | 2216 pContext->m_DictEnd = m_Pos; |
| 2208 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { | 2217 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { |
| 2209 return pDict; | 2218 return pDict.release(); |
| 2210 } | 2219 } |
| 2211 } | 2220 } |
| 2212 FX_FILESIZE SavedPos = m_Pos; | 2221 FX_FILESIZE SavedPos = m_Pos; |
| 2213 FX_BOOL bIsNumber; | 2222 FX_BOOL bIsNumber; |
| 2214 CFX_ByteString nextword = GetNextWord(bIsNumber); | 2223 CFX_ByteString nextword = GetNextWord(bIsNumber); |
| 2215 if (nextword == FX_BSTRC("stream")) { | 2224 if (nextword != FX_BSTRC("stream")) { |
| 2216 CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum); | |
| 2217 if (pStream) { | |
| 2218 return pStream; | |
| 2219 } | |
| 2220 if (pDict) | |
| 2221 pDict->Release(); | |
| 2222 return NULL; | |
| 2223 } else { | |
| 2224 m_Pos = SavedPos; | 2225 m_Pos = SavedPos; |
| 2225 return pDict; | 2226 return pDict.release(); |
| 2226 } | 2227 } |
| 2228 | |
| 2229 return ReadStream(pDict.release(), pContext, objnum, gennum); | |
| 2227 } | 2230 } |
| 2228 if (word == FX_BSTRC(">>")) { | 2231 if (word == FX_BSTRC(">>")) { |
| 2229 m_Pos = SavedPos; | 2232 m_Pos = SavedPos; |
| 2230 return NULL; | 2233 return nullptr; |
| 2231 } | 2234 } |
| 2232 if (bTypeOnly) { | 2235 if (bTypeOnly) |
| 2233 return (CPDF_Object*)PDFOBJ_INVALID; | 2236 return (CPDF_Object*)PDFOBJ_INVALID; |
| 2234 } | 2237 |
| 2235 return NULL; | 2238 return nullptr; |
| 2236 } | 2239 } |
| 2240 | |
| 2237 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( | 2241 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( |
| 2238 CPDF_IndirectObjects* pObjList, | 2242 CPDF_IndirectObjects* pObjList, |
| 2239 FX_DWORD objnum, | 2243 FX_DWORD objnum, |
| 2240 FX_DWORD gennum, | 2244 FX_DWORD gennum, |
| 2241 struct PARSE_CONTEXT* pContext) { | 2245 struct PARSE_CONTEXT* pContext) { |
| 2242 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); | 2246 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); |
| 2243 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) { | 2247 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) { |
| 2244 return NULL; | 2248 return NULL; |
| 2245 } | 2249 } |
| 2246 FX_FILESIZE SavedPos = m_Pos; | 2250 FX_FILESIZE SavedPos = m_Pos; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2301 CFX_ByteString str = ReadHexString(); | 2305 CFX_ByteString str = ReadHexString(); |
| 2302 if (m_pCryptoHandler) { | 2306 if (m_pCryptoHandler) { |
| 2303 m_pCryptoHandler->Decrypt(objnum, gennum, str); | 2307 m_pCryptoHandler->Decrypt(objnum, gennum, str); |
| 2304 } | 2308 } |
| 2305 return CPDF_String::Create(str, TRUE); | 2309 return CPDF_String::Create(str, TRUE); |
| 2306 } | 2310 } |
| 2307 if (word == FX_BSTRC("[")) { | 2311 if (word == FX_BSTRC("[")) { |
| 2308 if (bTypeOnly) { | 2312 if (bTypeOnly) { |
| 2309 return (CPDF_Object*)PDFOBJ_ARRAY; | 2313 return (CPDF_Object*)PDFOBJ_ARRAY; |
| 2310 } | 2314 } |
| 2311 CPDF_Array* pArray = CPDF_Array::Create(); | 2315 nonstd::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray( |
| 2312 while (1) { | 2316 CPDF_Array::Create()); |
| 2313 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum); | 2317 while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum)) |
| 2314 if (pObj == NULL) { | |
| 2315 if (m_WordBuffer[0] == ']') { | |
| 2316 return pArray; | |
| 2317 } | |
| 2318 if (pArray) { | |
| 2319 pArray->Release(); | |
| 2320 } | |
| 2321 return NULL; | |
| 2322 } | |
| 2323 pArray->Add(pObj); | 2318 pArray->Add(pObj); |
| 2324 } | 2319 return (m_WordBuffer[0] == ']') ? pArray.release() : nullptr; |
|
Tom Sepez
2015/10/09 16:47:32
nit: overparenthesized.
Lei Zhang
2015/10/19 08:05:51
Done.
| |
| 2325 } | 2320 } |
| 2326 if (word[0] == '/') { | 2321 if (word[0] == '/') { |
| 2327 if (bTypeOnly) { | 2322 if (bTypeOnly) { |
| 2328 return (CPDF_Object*)PDFOBJ_NAME; | 2323 return (CPDF_Object*)PDFOBJ_NAME; |
| 2329 } | 2324 } |
| 2330 return CPDF_Name::Create( | 2325 return CPDF_Name::Create( |
| 2331 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); | 2326 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); |
| 2332 } | 2327 } |
| 2333 if (word == FX_BSTRC("<<")) { | 2328 if (word == FX_BSTRC("<<")) { |
| 2334 if (bTypeOnly) { | 2329 if (bTypeOnly) { |
| 2335 return (CPDF_Object*)PDFOBJ_DICTIONARY; | 2330 return (CPDF_Object*)PDFOBJ_DICTIONARY; |
| 2336 } | 2331 } |
| 2337 if (pContext) { | 2332 if (pContext) { |
| 2338 pContext->m_DictStart = SavedPos; | 2333 pContext->m_DictStart = SavedPos; |
| 2339 } | 2334 } |
| 2340 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); | 2335 nonstd::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( |
| 2336 CPDF_Dictionary::Create()); | |
| 2341 while (1) { | 2337 while (1) { |
| 2342 FX_BOOL bIsNumber; | 2338 FX_BOOL bIsNumber; |
| 2343 FX_FILESIZE SavedPos = m_Pos; | 2339 FX_FILESIZE SavedPos = m_Pos; |
| 2344 CFX_ByteString key = GetNextWord(bIsNumber); | 2340 CFX_ByteString key = GetNextWord(bIsNumber); |
| 2345 if (key.IsEmpty()) { | 2341 if (key.IsEmpty()) |
| 2346 if (pDict) { | 2342 return nullptr; |
| 2347 pDict->Release(); | 2343 |
| 2348 } | 2344 if (key == FX_BSTRC(">>")) |
| 2349 return NULL; | |
| 2350 } | |
| 2351 if (key == FX_BSTRC(">>")) { | |
| 2352 break; | 2345 break; |
| 2353 } | 2346 |
| 2354 if (key == FX_BSTRC("endobj")) { | 2347 if (key == FX_BSTRC("endobj")) { |
| 2355 m_Pos = SavedPos; | 2348 m_Pos = SavedPos; |
| 2356 break; | 2349 break; |
| 2357 } | 2350 } |
| 2358 if (key[0] != '/') { | 2351 if (key[0] != '/') |
| 2359 continue; | 2352 continue; |
| 2360 } | 2353 |
| 2361 key = PDF_NameDecode(key); | 2354 key = PDF_NameDecode(key); |
| 2362 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> obj( | 2355 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> obj( |
| 2363 GetObject(pObjList, objnum, gennum)); | 2356 GetObject(pObjList, objnum, gennum)); |
| 2364 if (!obj) { | 2357 if (!obj) { |
| 2365 if (pDict) { | |
| 2366 pDict->Release(); | |
| 2367 } | |
| 2368 uint8_t ch; | 2358 uint8_t ch; |
| 2369 while (1) { | 2359 while (1) { |
| 2370 if (!GetNextChar(ch)) { | 2360 if (!GetNextChar(ch)) |
|
Tom Sepez
2015/10/09 16:47:32
nit: maybe combine with subsequent if.
nit: then i
Lei Zhang
2015/10/19 08:05:51
Done.
| |
| 2371 break; | 2361 break; |
| 2372 } | 2362 if (ch == 0x0A || ch == 0x0D) |
|
Tom Sepez
2015/10/09 16:47:32
nit: do we want '\n' and '\r'? A fascintating phi
Lei Zhang
2015/10/19 08:05:51
Meh. I'm just going to leave it as is.
| |
| 2373 if (ch == 0x0A || ch == 0x0D) { | |
| 2374 break; | 2363 break; |
| 2375 } | |
| 2376 } | 2364 } |
| 2377 return NULL; | 2365 return nullptr; |
| 2378 } | 2366 } |
| 2379 if (key.GetLength() > 1) { | 2367 if (key.GetLength() > 1) { |
| 2380 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), | 2368 pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), |
| 2381 obj.release()); | 2369 obj.release()); |
| 2382 } | 2370 } |
| 2383 } | 2371 } |
| 2384 if (pContext) { | 2372 if (pContext) { |
| 2385 pContext->m_DictEnd = m_Pos; | 2373 pContext->m_DictEnd = m_Pos; |
| 2386 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { | 2374 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { |
| 2387 return pDict; | 2375 return pDict.release(); |
| 2388 } | 2376 } |
| 2389 } | 2377 } |
| 2390 FX_FILESIZE SavedPos = m_Pos; | 2378 FX_FILESIZE SavedPos = m_Pos; |
| 2391 FX_BOOL bIsNumber; | 2379 FX_BOOL bIsNumber; |
| 2392 CFX_ByteString nextword = GetNextWord(bIsNumber); | 2380 CFX_ByteString nextword = GetNextWord(bIsNumber); |
| 2393 if (nextword == FX_BSTRC("stream")) { | 2381 if (nextword != FX_BSTRC("stream")) { |
| 2394 CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum); | |
| 2395 if (pStream) { | |
| 2396 return pStream; | |
| 2397 } | |
| 2398 if (pDict) { | |
| 2399 pDict->Release(); | |
| 2400 } | |
| 2401 return NULL; | |
| 2402 } else { | |
| 2403 m_Pos = SavedPos; | 2382 m_Pos = SavedPos; |
| 2404 return pDict; | 2383 return pDict.release(); |
| 2405 } | 2384 } |
| 2385 | |
| 2386 return ReadStream(pDict.release(), pContext, objnum, gennum); | |
| 2406 } | 2387 } |
| 2407 if (word == FX_BSTRC(">>")) { | 2388 if (word == FX_BSTRC(">>")) { |
| 2408 m_Pos = SavedPos; | 2389 m_Pos = SavedPos; |
| 2409 return NULL; | 2390 return nullptr; |
| 2410 } | 2391 } |
| 2411 if (bTypeOnly) { | 2392 if (bTypeOnly) |
| 2412 return (CPDF_Object*)PDFOBJ_INVALID; | 2393 return (CPDF_Object*)PDFOBJ_INVALID; |
| 2413 } | 2394 |
| 2414 return NULL; | 2395 return nullptr; |
| 2415 } | 2396 } |
| 2397 | |
| 2416 unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) { | 2398 unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) { |
| 2417 unsigned char byte1 = 0; | 2399 unsigned char byte1 = 0; |
| 2418 unsigned char byte2 = 0; | 2400 unsigned char byte2 = 0; |
| 2419 GetCharAt(pos, byte1); | 2401 GetCharAt(pos, byte1); |
| 2420 GetCharAt(pos + 1, byte2); | 2402 GetCharAt(pos + 1, byte2); |
| 2421 unsigned int markers = 0; | 2403 unsigned int markers = 0; |
| 2422 if (byte1 == '\r' && byte2 == '\n') { | 2404 if (byte1 == '\r' && byte2 == '\n') { |
| 2423 markers = 2; | 2405 markers = 2; |
| 2424 } else if (byte1 == '\r' || byte1 == '\n') { | 2406 } else if (byte1 == '\r' || byte1 == '\n') { |
| 2425 markers = 1; | 2407 markers = 1; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2670 offset = byte == tag_data[taglen - 1] ? taglen - 2 : taglen - 1; | 2652 offset = byte == tag_data[taglen - 1] ? taglen - 2 : taglen - 1; |
| 2671 pos--; | 2653 pos--; |
| 2672 } | 2654 } |
| 2673 if (pos < 0) { | 2655 if (pos < 0) { |
| 2674 return FALSE; | 2656 return FALSE; |
| 2675 } | 2657 } |
| 2676 } | 2658 } |
| 2677 return FALSE; | 2659 return FALSE; |
| 2678 } | 2660 } |
| 2679 | 2661 |
| 2680 struct _SearchTagRecord { | |
| 2681 const uint8_t* m_pTag; | |
| 2682 FX_DWORD m_Len; | |
| 2683 FX_DWORD m_Offset; | |
| 2684 }; | |
| 2685 | |
| 2686 int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags, | 2662 int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags, |
| 2687 FX_BOOL bWholeWord, | 2663 FX_BOOL bWholeWord, |
| 2688 FX_FILESIZE limit) { | 2664 FX_FILESIZE limit) { |
| 2689 int32_t ntags = 1; | 2665 int32_t ntags = 1; |
| 2690 for (int i = 0; i < tags.GetLength(); ++i) { | 2666 for (int i = 0; i < tags.GetLength(); ++i) { |
| 2691 if (tags[i] == 0) { | 2667 if (tags[i] == 0) { |
| 2692 ++ntags; | 2668 ++ntags; |
| 2693 } | 2669 } |
| 2694 } | 2670 } |
| 2695 | 2671 |
| 2696 std::vector<_SearchTagRecord> patterns(ntags); | 2672 std::vector<SearchTagRecord> patterns(ntags); |
|
Tom Sepez
2015/10/09 16:47:31
Good, _CAPITAL is reserved anyways. This irks me
Lei Zhang
2015/10/19 08:05:51
Ack. There's plenty more in other files.
| |
| 2697 FX_DWORD start = 0; | 2673 FX_DWORD start = 0; |
| 2698 FX_DWORD itag = 0; | 2674 FX_DWORD itag = 0; |
| 2699 FX_DWORD max_len = 0; | 2675 FX_DWORD max_len = 0; |
| 2700 for (int i = 0; i <= tags.GetLength(); ++i) { | 2676 for (int i = 0; i <= tags.GetLength(); ++i) { |
| 2701 if (tags[i] == 0) { | 2677 if (tags[i] == 0) { |
| 2702 FX_DWORD len = i - start; | 2678 FX_DWORD len = i - start; |
| 2703 max_len = std::max(len, max_len); | 2679 max_len = std::max(len, max_len); |
| 2704 patterns[itag].m_pTag = tags.GetPtr() + start; | 2680 patterns[itag].m_pTag = tags.GetPtr() + start; |
| 2705 patterns[itag].m_Len = len; | 2681 patterns[itag].m_Len = len; |
| 2706 patterns[itag].m_Offset = 0; | 2682 patterns[itag].m_Offset = 0; |
| 2707 start = i + 1; | 2683 start = i + 1; |
| 2708 ++itag; | 2684 ++itag; |
| 2709 } | 2685 } |
| 2710 } | 2686 } |
| 2711 | 2687 |
| 2712 const FX_FILESIZE pos_limit = m_Pos + limit; | 2688 const FX_FILESIZE pos_limit = m_Pos + limit; |
| 2713 for (FX_FILESIZE pos = m_Pos; !limit || pos < pos_limit; ++pos) { | 2689 for (FX_FILESIZE pos = m_Pos; !limit || pos < pos_limit; ++pos) { |
| 2714 uint8_t byte; | 2690 uint8_t byte; |
| 2715 if (!GetCharAt(pos, byte)) | 2691 if (!GetCharAt(pos, byte)) |
| 2716 break; | 2692 break; |
| 2717 | 2693 |
| 2718 for (int i = 0; i < ntags; ++i) { | 2694 for (int i = 0; i < ntags; ++i) { |
|
Tom Sepez
2015/10/09 16:47:32
nit: can we use an iterator here now that you got
Lei Zhang
2015/10/19 08:05:51
Annoyingly we still have a "return i" below in the
| |
| 2719 _SearchTagRecord& pat = patterns[i]; | 2695 SearchTagRecord& pat = patterns[i]; |
| 2720 if (pat.m_pTag[pat.m_Offset] != byte) { | 2696 if (pat.m_pTag[pat.m_Offset] != byte) { |
| 2721 pat.m_Offset = (pat.m_pTag[0] == byte) ? 1 : 0; | 2697 pat.m_Offset = (pat.m_pTag[0] == byte) ? 1 : 0; |
| 2722 continue; | 2698 continue; |
| 2723 } | 2699 } |
| 2724 | 2700 |
| 2725 ++pat.m_Offset; | 2701 ++pat.m_Offset; |
| 2726 if (pat.m_Offset != pat.m_Len) | 2702 if (pat.m_Offset != pat.m_Len) |
| 2727 continue; | 2703 continue; |
| 2728 | 2704 |
| 2729 if (!bWholeWord || | 2705 if (!bWholeWord || |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3728 return PDF_UNKNOW_LINEARIZED; | 3704 return PDF_UNKNOW_LINEARIZED; |
| 3729 } | 3705 } |
| 3730 uint8_t buffer[1024]; | 3706 uint8_t buffer[1024]; |
| 3731 m_pFileRead->ReadBlock(buffer, 0, req_size); | 3707 m_pFileRead->ReadBlock(buffer, 0, req_size); |
| 3732 if (IsLinearizedFile(buffer, req_size)) { | 3708 if (IsLinearizedFile(buffer, req_size)) { |
| 3733 return PDF_IS_LINEARIZED; | 3709 return PDF_IS_LINEARIZED; |
| 3734 } | 3710 } |
| 3735 return PDF_NOT_LINEARIZED; | 3711 return PDF_NOT_LINEARIZED; |
| 3736 } | 3712 } |
| 3737 FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) { | 3713 FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) { |
| 3738 CFX_SmartPointer<IFX_FileStream> file( | 3714 nonstd::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>> file( |
| 3739 FX_CreateMemoryStream(pData, (size_t)dwLen, FALSE)); | 3715 FX_CreateMemoryStream(pData, (size_t)dwLen, FALSE)); |
| 3740 int32_t offset = GetHeaderOffset(file.Get()); | 3716 int32_t offset = GetHeaderOffset(file.get()); |
| 3741 if (offset == -1) { | 3717 if (offset == -1) { |
| 3742 m_docStatus = PDF_DATAAVAIL_ERROR; | 3718 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 3743 return FALSE; | 3719 return FALSE; |
| 3744 } | 3720 } |
| 3745 m_dwHeaderOffset = offset; | 3721 m_dwHeaderOffset = offset; |
| 3746 m_syntaxParser.InitParser(file.Get(), offset); | 3722 m_syntaxParser.InitParser(file.get(), offset); |
| 3747 m_syntaxParser.RestorePos(m_syntaxParser.m_HeaderOffset + 9); | 3723 m_syntaxParser.RestorePos(m_syntaxParser.m_HeaderOffset + 9); |
| 3748 FX_BOOL bNumber = FALSE; | 3724 FX_BOOL bNumber = FALSE; |
| 3749 CFX_ByteString wordObjNum = m_syntaxParser.GetNextWord(bNumber); | 3725 CFX_ByteString wordObjNum = m_syntaxParser.GetNextWord(bNumber); |
| 3750 if (!bNumber) { | 3726 if (!bNumber) { |
| 3751 return FALSE; | 3727 return FALSE; |
| 3752 } | 3728 } |
| 3753 FX_DWORD objnum = FXSYS_atoi(wordObjNum); | 3729 FX_DWORD objnum = FXSYS_atoi(wordObjNum); |
| 3754 if (m_pLinearized) { | 3730 if (m_pLinearized) { |
| 3755 m_pLinearized->Release(); | 3731 m_pLinearized->Release(); |
| 3756 m_pLinearized = NULL; | 3732 m_pLinearized = NULL; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 3777 return TRUE; | 3753 return TRUE; |
| 3778 } | 3754 } |
| 3779 return FALSE; | 3755 return FALSE; |
| 3780 } | 3756 } |
| 3781 FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints) { | 3757 FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints) { |
| 3782 FX_DWORD req_pos = (FX_DWORD)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); | 3758 FX_DWORD req_pos = (FX_DWORD)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); |
| 3783 FX_DWORD dwSize = (FX_DWORD)(m_dwFileLen - req_pos); | 3759 FX_DWORD dwSize = (FX_DWORD)(m_dwFileLen - req_pos); |
| 3784 if (m_pFileAvail->IsDataAvail(req_pos, dwSize)) { | 3760 if (m_pFileAvail->IsDataAvail(req_pos, dwSize)) { |
| 3785 uint8_t buffer[1024]; | 3761 uint8_t buffer[1024]; |
| 3786 m_pFileRead->ReadBlock(buffer, req_pos, dwSize); | 3762 m_pFileRead->ReadBlock(buffer, req_pos, dwSize); |
| 3787 CFX_SmartPointer<IFX_FileStream> file( | 3763 nonstd::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>> file( |
| 3788 FX_CreateMemoryStream(buffer, (size_t)dwSize, FALSE)); | 3764 FX_CreateMemoryStream(buffer, (size_t)dwSize, FALSE)); |
| 3789 m_syntaxParser.InitParser(file.Get(), 0); | 3765 m_syntaxParser.InitParser(file.get(), 0); |
| 3790 m_syntaxParser.RestorePos(dwSize - 1); | 3766 m_syntaxParser.RestorePos(dwSize - 1); |
| 3791 if (m_syntaxParser.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, dwSize)) { | 3767 if (m_syntaxParser.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, dwSize)) { |
| 3792 FX_BOOL bNumber; | 3768 FX_BOOL bNumber; |
| 3793 m_syntaxParser.GetNextWord(bNumber); | 3769 m_syntaxParser.GetNextWord(bNumber); |
| 3794 CFX_ByteString xrefpos_str = m_syntaxParser.GetNextWord(bNumber); | 3770 CFX_ByteString xrefpos_str = m_syntaxParser.GetNextWord(bNumber); |
| 3795 if (!bNumber) { | 3771 if (!bNumber) { |
| 3796 m_docStatus = PDF_DATAAVAIL_ERROR; | 3772 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 3797 return FALSE; | 3773 return FALSE; |
| 3798 } | 3774 } |
| 3799 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); | 3775 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 3815 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, | 3791 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, |
| 3816 FX_FILESIZE& xref_offset) { | 3792 FX_FILESIZE& xref_offset) { |
| 3817 xref_offset = 0; | 3793 xref_offset = 0; |
| 3818 FX_DWORD req_size = | 3794 FX_DWORD req_size = |
| 3819 (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); | 3795 (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); |
| 3820 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { | 3796 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { |
| 3821 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); | 3797 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); |
| 3822 CFX_BinaryBuf buf(iSize); | 3798 CFX_BinaryBuf buf(iSize); |
| 3823 uint8_t* pBuf = buf.GetBuffer(); | 3799 uint8_t* pBuf = buf.GetBuffer(); |
| 3824 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); | 3800 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); |
| 3825 CFX_SmartPointer<IFX_FileStream> file( | 3801 nonstd::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>> file( |
| 3826 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); | 3802 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); |
| 3827 m_parser.m_Syntax.InitParser(file.Get(), 0); | 3803 m_parser.m_Syntax.InitParser(file.get(), 0); |
| 3828 FX_BOOL bNumber = FALSE; | 3804 FX_BOOL bNumber = FALSE; |
| 3829 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber); | 3805 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber); |
| 3830 if (!bNumber) { | 3806 if (!bNumber) { |
| 3831 return -1; | 3807 return -1; |
| 3832 } | 3808 } |
| 3833 FX_DWORD objNum = FXSYS_atoi(objnum); | 3809 FX_DWORD objNum = FXSYS_atoi(objnum); |
| 3834 CPDF_Object* pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL); | 3810 CPDF_Object* pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL); |
| 3835 if (!pObj) { | 3811 if (!pObj) { |
| 3836 m_Pos += m_parser.m_Syntax.SavePos(); | 3812 m_Pos += m_parser.m_Syntax.SavePos(); |
| 3837 return 0; | 3813 return 0; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4055 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); | 4031 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); |
| 4056 CFX_BinaryBuf buf(iSize); | 4032 CFX_BinaryBuf buf(iSize); |
| 4057 uint8_t* pBuf = buf.GetBuffer(); | 4033 uint8_t* pBuf = buf.GetBuffer(); |
| 4058 if (!pBuf) { | 4034 if (!pBuf) { |
| 4059 m_docStatus = PDF_DATAAVAIL_ERROR; | 4035 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 4060 return FALSE; | 4036 return FALSE; |
| 4061 } | 4037 } |
| 4062 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { | 4038 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { |
| 4063 return FALSE; | 4039 return FALSE; |
| 4064 } | 4040 } |
| 4065 CFX_SmartPointer<IFX_FileStream> file( | 4041 nonstd::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>> file( |
| 4066 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); | 4042 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); |
| 4067 m_syntaxParser.InitParser(file.Get(), 0); | 4043 m_syntaxParser.InitParser(file.get(), 0); |
| 4068 CPDF_Object* pTrailer = m_syntaxParser.GetObject(nullptr, 0, 0); | 4044 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer( |
| 4045 m_syntaxParser.GetObject(nullptr, 0, 0)); | |
| 4069 if (!pTrailer) { | 4046 if (!pTrailer) { |
| 4070 m_Pos += m_syntaxParser.SavePos(); | 4047 m_Pos += m_syntaxParser.SavePos(); |
| 4071 pHints->AddSegment(m_Pos, iTrailerSize); | 4048 pHints->AddSegment(m_Pos, iTrailerSize); |
| 4072 return FALSE; | 4049 return FALSE; |
| 4073 } | 4050 } |
| 4074 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) { | 4051 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) |
| 4075 pTrailer->Release(); | |
| 4076 return FALSE; | 4052 return FALSE; |
| 4077 } | 4053 |
| 4078 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); | 4054 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); |
| 4079 CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); | 4055 CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); |
| 4080 if (pEncrypt && pEncrypt->GetType() == PDFOBJ_REFERENCE) { | 4056 if (pEncrypt && pEncrypt->GetType() == PDFOBJ_REFERENCE) { |
| 4081 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 4057 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 4082 pTrailer->Release(); | |
| 4083 return TRUE; | 4058 return TRUE; |
| 4084 } | 4059 } |
| 4085 FX_DWORD xrefpos = GetDirectInteger(pTrailer->GetDict(), FX_BSTRC("Prev")); | 4060 |
| 4061 FX_DWORD xrefpos = GetDirectInteger(pTrailerDict, FX_BSTRC("Prev")); | |
| 4086 if (xrefpos) { | 4062 if (xrefpos) { |
| 4087 m_dwPrevXRefOffset = | 4063 m_dwPrevXRefOffset = GetDirectInteger(pTrailerDict, FX_BSTRC("XRefStm")); |
| 4088 GetDirectInteger(pTrailer->GetDict(), FX_BSTRC("XRefStm")); | |
| 4089 pTrailer->Release(); | |
| 4090 if (m_dwPrevXRefOffset) { | 4064 if (m_dwPrevXRefOffset) { |
| 4091 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 4065 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 4092 } else { | 4066 } else { |
| 4093 m_dwPrevXRefOffset = xrefpos; | 4067 m_dwPrevXRefOffset = xrefpos; |
| 4094 if (m_dwPrevXRefOffset >= m_dwFileLen) { | 4068 if (m_dwPrevXRefOffset >= m_dwFileLen) { |
| 4095 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 4069 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 4096 } else { | 4070 } else { |
| 4097 SetStartOffset(m_dwPrevXRefOffset); | 4071 SetStartOffset(m_dwPrevXRefOffset); |
| 4098 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; | 4072 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; |
| 4099 } | 4073 } |
| 4100 } | 4074 } |
| 4101 return TRUE; | 4075 return TRUE; |
| 4102 } | 4076 } |
| 4103 m_dwPrevXRefOffset = 0; | 4077 m_dwPrevXRefOffset = 0; |
| 4104 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; | 4078 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; |
| 4105 pTrailer->Release(); | |
| 4106 return TRUE; | 4079 return TRUE; |
| 4107 } | 4080 } |
| 4108 pHints->AddSegment(m_Pos, iTrailerSize); | 4081 pHints->AddSegment(m_Pos, iTrailerSize); |
| 4109 return FALSE; | 4082 return FALSE; |
| 4110 } | 4083 } |
| 4111 | 4084 |
| 4112 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) { | 4085 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) { |
| 4113 while (TRUE) { | 4086 while (TRUE) { |
| 4114 switch (m_docStatus) { | 4087 switch (m_docStatus) { |
| 4115 case PDF_DATAAVAIL_PAGETREE: | 4088 case PDF_DATAAVAIL_PAGETREE: |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4649 return FALSE; | 4622 return FALSE; |
| 4650 } | 4623 } |
| 4651 CPDF_PageNode::~CPDF_PageNode() { | 4624 CPDF_PageNode::~CPDF_PageNode() { |
| 4652 int32_t iSize = m_childNode.GetSize(); | 4625 int32_t iSize = m_childNode.GetSize(); |
| 4653 for (int32_t i = 0; i < iSize; ++i) { | 4626 for (int32_t i = 0; i < iSize; ++i) { |
| 4654 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; | 4627 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; |
| 4655 delete pNode; | 4628 delete pNode; |
| 4656 } | 4629 } |
| 4657 m_childNode.RemoveAll(); | 4630 m_childNode.RemoveAll(); |
| 4658 } | 4631 } |
| OLD | NEW |