| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfapi/parser/cpdf_data_avail.h" | 7 #include "core/fpdfapi/parser/cpdf_data_avail.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 m_docStatus = PDF_DATAAVAIL_HEADER; | 76 m_docStatus = PDF_DATAAVAIL_HEADER; |
| 77 m_parser.m_bOwnFileRead = false; | 77 m_parser.m_bOwnFileRead = false; |
| 78 m_bTotalLoadPageTree = false; | 78 m_bTotalLoadPageTree = false; |
| 79 m_bCurPageDictLoadOK = false; | 79 m_bCurPageDictLoadOK = false; |
| 80 m_bLinearedDataOK = false; | 80 m_bLinearedDataOK = false; |
| 81 m_bSupportHintTable = bSupportHintTable; | 81 m_bSupportHintTable = bSupportHintTable; |
| 82 } | 82 } |
| 83 | 83 |
| 84 CPDF_DataAvail::~CPDF_DataAvail() { | 84 CPDF_DataAvail::~CPDF_DataAvail() { |
| 85 m_pHintTables.reset(); | 85 m_pHintTables.reset(); |
| 86 delete m_pLinearized; | 86 if (m_pLinearized) |
| 87 delete m_pRoot; | 87 m_pLinearized->Release(); |
| 88 delete m_pTrailer; | 88 |
| 89 if (m_pRoot) |
| 90 m_pRoot->Release(); |
| 91 |
| 92 if (m_pTrailer) |
| 93 m_pTrailer->Release(); |
| 89 | 94 |
| 90 for (CPDF_Object* pObject : m_arrayAcroforms) | 95 for (CPDF_Object* pObject : m_arrayAcroforms) |
| 91 delete pObject; | 96 pObject->Release(); |
| 92 } | 97 } |
| 93 | 98 |
| 94 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) { | 99 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) { |
| 95 m_pDocument = pDoc; | 100 m_pDocument = pDoc; |
| 96 } | 101 } |
| 97 | 102 |
| 98 uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) { | 103 uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) { |
| 99 CPDF_Parser* pParser = m_pDocument->GetParser(); | 104 CPDF_Parser* pParser = m_pDocument->GetParser(); |
| 100 if (!pParser || !pParser->IsValidObjectNumber(objnum)) | 105 if (!pParser || !pParser->IsValidObjectNumber(objnum)) |
| 101 return 0; | 106 return 0; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return true; | 223 return true; |
| 219 } | 224 } |
| 220 | 225 |
| 221 std::vector<CPDF_Object*> new_objs_array; | 226 std::vector<CPDF_Object*> new_objs_array; |
| 222 if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) { | 227 if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) { |
| 223 m_objs_array = new_objs_array; | 228 m_objs_array = new_objs_array; |
| 224 return false; | 229 return false; |
| 225 } | 230 } |
| 226 | 231 |
| 227 for (CPDF_Object* pObject : m_arrayAcroforms) | 232 for (CPDF_Object* pObject : m_arrayAcroforms) |
| 228 delete pObject; | 233 pObject->Release(); |
| 229 | 234 |
| 230 m_arrayAcroforms.clear(); | 235 m_arrayAcroforms.clear(); |
| 231 return true; | 236 return true; |
| 232 } | 237 } |
| 233 | 238 |
| 234 bool CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) { | 239 bool CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) { |
| 235 bool bExist = false; | 240 bool bExist = false; |
| 236 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); | 241 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); |
| 237 if (!bExist) { | 242 if (!bExist) { |
| 238 m_docStatus = PDF_DATAAVAIL_PAGETREE; | 243 m_docStatus = PDF_DATAAVAIL_PAGETREE; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 393 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
| 389 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 394 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 390 return true; | 395 return true; |
| 391 } | 396 } |
| 392 | 397 |
| 393 if (m_Pos == m_dwFileLen) | 398 if (m_Pos == m_dwFileLen) |
| 394 m_docStatus = PDF_DATAAVAIL_ERROR; | 399 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 395 return false; | 400 return false; |
| 396 } | 401 } |
| 397 | 402 |
| 398 delete pInfo; | 403 if (pInfo) |
| 404 pInfo->Release(); |
| 405 |
| 399 m_docStatus = | 406 m_docStatus = |
| 400 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); | 407 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); |
| 401 | 408 |
| 402 return true; | 409 return true; |
| 403 } | 410 } |
| 404 | 411 |
| 405 bool CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { | 412 bool CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { |
| 406 bool bExist = false; | 413 bool bExist = false; |
| 407 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist); | 414 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist); |
| 408 if (!bExist) { | 415 if (!bExist) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 492 |
| 486 CPDF_Array* pArray = ToArray(pObj); | 493 CPDF_Array* pArray = ToArray(pObj); |
| 487 if (pArray) { | 494 if (pArray) { |
| 488 for (CPDF_Object* pArrayObj : *pArray) { | 495 for (CPDF_Object* pArrayObj : *pArray) { |
| 489 if (CPDF_Reference* pRef = ToReference(pArrayObj)) | 496 if (CPDF_Reference* pRef = ToReference(pArrayObj)) |
| 490 UnavailObjList.Add(pRef->GetRefObjNum()); | 497 UnavailObjList.Add(pRef->GetRefObjNum()); |
| 491 } | 498 } |
| 492 } | 499 } |
| 493 | 500 |
| 494 if (!pObj->IsDictionary()) { | 501 if (!pObj->IsDictionary()) { |
| 495 delete pObj; | 502 pObj->Release(); |
| 496 continue; | 503 continue; |
| 497 } | 504 } |
| 498 | 505 |
| 499 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type"); | 506 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type"); |
| 500 if (type == "Pages") { | 507 if (type == "Pages") { |
| 501 m_PagesArray.push_back(pObj); | 508 m_PagesArray.push_back(pObj); |
| 502 continue; | 509 continue; |
| 503 } | 510 } |
| 504 delete pObj; | 511 pObj->Release(); |
| 505 } | 512 } |
| 506 | 513 |
| 507 m_PageObjList.RemoveAll(); | 514 m_PageObjList.RemoveAll(); |
| 508 if (UnavailObjList.GetSize()) { | 515 if (UnavailObjList.GetSize()) { |
| 509 m_PageObjList.Append(UnavailObjList); | 516 m_PageObjList.Append(UnavailObjList); |
| 510 return false; | 517 return false; |
| 511 } | 518 } |
| 512 | 519 |
| 513 uint32_t iPages = m_PagesArray.size(); | 520 uint32_t iPages = m_PagesArray.size(); |
| 514 for (uint32_t i = 0; i < iPages; i++) { | 521 for (uint32_t i = 0; i < iPages; i++) { |
| 515 CPDF_Object* pPages = m_PagesArray[i]; | 522 CPDF_Object* pPages = m_PagesArray[i]; |
| 516 if (!pPages) | 523 if (!pPages) |
| 517 continue; | 524 continue; |
| 518 | 525 |
| 519 if (!GetPageKids(m_pCurrentParser, pPages)) { | 526 if (!GetPageKids(m_pCurrentParser, pPages)) { |
| 520 delete pPages; | 527 pPages->Release(); |
| 521 while (++i < iPages) | 528 while (++i < iPages) |
| 522 delete m_PagesArray[i]; | 529 m_PagesArray[i]->Release(); |
| 523 | 530 |
| 524 m_PagesArray.clear(); | 531 m_PagesArray.clear(); |
| 525 m_docStatus = PDF_DATAAVAIL_ERROR; | 532 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 526 return false; | 533 return false; |
| 527 } | 534 } |
| 528 delete pPages; | 535 pPages->Release(); |
| 529 } | 536 } |
| 530 | 537 |
| 531 m_PagesArray.clear(); | 538 m_PagesArray.clear(); |
| 532 if (!m_PageObjList.GetSize()) | 539 if (!m_PageObjList.GetSize()) |
| 533 m_docStatus = PDF_DATAAVAIL_DONE; | 540 m_docStatus = PDF_DATAAVAIL_DONE; |
| 534 return true; | 541 return true; |
| 535 } | 542 } |
| 536 | 543 |
| 537 bool CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { | 544 bool CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { |
| 538 if (!pParser) { | 545 if (!pParser) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 | 580 |
| 574 if (!pPages) { | 581 if (!pPages) { |
| 575 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 582 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
| 576 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 583 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 577 return true; | 584 return true; |
| 578 } | 585 } |
| 579 return false; | 586 return false; |
| 580 } | 587 } |
| 581 | 588 |
| 582 if (!GetPageKids(m_pCurrentParser, pPages)) { | 589 if (!GetPageKids(m_pCurrentParser, pPages)) { |
| 583 delete pPages; | 590 pPages->Release(); |
| 584 m_docStatus = PDF_DATAAVAIL_ERROR; | 591 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 585 return false; | 592 return false; |
| 586 } | 593 } |
| 587 | 594 |
| 588 delete pPages; | 595 pPages->Release(); |
| 589 m_docStatus = PDF_DATAAVAIL_PAGE; | 596 m_docStatus = PDF_DATAAVAIL_PAGE; |
| 590 return true; | 597 return true; |
| 591 } | 598 } |
| 592 | 599 |
| 593 bool CPDF_DataAvail::CheckHeader(DownloadHints* pHints) { | 600 bool CPDF_DataAvail::CheckHeader(DownloadHints* pHints) { |
| 594 ASSERT(m_dwFileLen >= 0); | 601 ASSERT(m_dwFileLen >= 0); |
| 595 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U); | 602 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U); |
| 596 | 603 |
| 597 if (m_pFileAvail->IsDataAvail(0, kReqSize)) { | 604 if (m_pFileAvail->IsDataAvail(0, kReqSize)) { |
| 598 uint8_t buffer[1024]; | 605 uint8_t buffer[1024]; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 return false; | 756 return false; |
| 750 } | 757 } |
| 751 | 758 |
| 752 if (!IsDataAvail(szHintStart, szHintLength, pHints)) | 759 if (!IsDataAvail(szHintStart, szHintLength, pHints)) |
| 753 return false; | 760 return false; |
| 754 | 761 |
| 755 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); | 762 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); |
| 756 | 763 |
| 757 std::unique_ptr<CPDF_HintTables> pHintTables( | 764 std::unique_ptr<CPDF_HintTables> pHintTables( |
| 758 new CPDF_HintTables(this, pDict)); | 765 new CPDF_HintTables(this, pDict)); |
| 759 std::unique_ptr<CPDF_Object> pHintStream( | 766 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream( |
| 760 ParseIndirectObjectAt(szHintStart, 0)); | 767 ParseIndirectObjectAt(szHintStart, 0)); |
| 761 CPDF_Stream* pStream = ToStream(pHintStream.get()); | 768 CPDF_Stream* pStream = ToStream(pHintStream.get()); |
| 762 if (pStream && pHintTables->LoadHintStream(pStream)) | 769 if (pStream && pHintTables->LoadHintStream(pStream)) |
| 763 m_pHintTables = std::move(pHintTables); | 770 m_pHintTables = std::move(pHintTables); |
| 764 | 771 |
| 765 m_docStatus = PDF_DATAAVAIL_DONE; | 772 m_docStatus = PDF_DATAAVAIL_DONE; |
| 766 return true; | 773 return true; |
| 767 } | 774 } |
| 768 | 775 |
| 769 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt( | 776 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt( |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 m_Pos += m_parser.m_pSyntax->SavePos(); | 944 m_Pos += m_parser.m_pSyntax->SavePos(); |
| 938 return 0; | 945 return 0; |
| 939 } | 946 } |
| 940 | 947 |
| 941 CPDF_Dictionary* pDict = pObj->GetDict(); | 948 CPDF_Dictionary* pDict = pObj->GetDict(); |
| 942 CPDF_Name* pName = ToName(pDict ? pDict->GetObjectFor("Type") : nullptr); | 949 CPDF_Name* pName = ToName(pDict ? pDict->GetObjectFor("Type") : nullptr); |
| 943 if (pName) { | 950 if (pName) { |
| 944 if (pName->GetString() == "XRef") { | 951 if (pName->GetString() == "XRef") { |
| 945 m_Pos += m_parser.m_pSyntax->SavePos(); | 952 m_Pos += m_parser.m_pSyntax->SavePos(); |
| 946 xref_offset = pObj->GetDict()->GetIntegerFor("Prev"); | 953 xref_offset = pObj->GetDict()->GetIntegerFor("Prev"); |
| 947 delete pObj; | 954 pObj->Release(); |
| 948 return 1; | 955 return 1; |
| 949 } | 956 } |
| 950 } | 957 } |
| 951 delete pObj; | 958 pObj->Release(); |
| 952 return -1; | 959 return -1; |
| 953 } | 960 } |
| 954 pHints->AddSegment(m_Pos, req_size); | 961 pHints->AddSegment(m_Pos, req_size); |
| 955 return 0; | 962 return 0; |
| 956 } | 963 } |
| 957 | 964 |
| 958 void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) { | 965 void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) { |
| 959 m_Pos = dwOffset; | 966 m_Pos = dwOffset; |
| 960 } | 967 } |
| 961 | 968 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 m_docStatus = PDF_DATAAVAIL_ERROR; | 1174 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1168 return false; | 1175 return false; |
| 1169 } | 1176 } |
| 1170 | 1177 |
| 1171 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) | 1178 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) |
| 1172 return false; | 1179 return false; |
| 1173 | 1180 |
| 1174 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false)); | 1181 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false)); |
| 1175 m_syntaxParser.InitParser(file.get(), 0); | 1182 m_syntaxParser.InitParser(file.get(), 0); |
| 1176 | 1183 |
| 1177 std::unique_ptr<CPDF_Object> pTrailer( | 1184 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer( |
| 1178 m_syntaxParser.GetObject(nullptr, 0, 0, true)); | 1185 m_syntaxParser.GetObject(nullptr, 0, 0, true)); |
| 1179 if (!pTrailer) { | 1186 if (!pTrailer) { |
| 1180 m_Pos += m_syntaxParser.SavePos(); | 1187 m_Pos += m_syntaxParser.SavePos(); |
| 1181 pHints->AddSegment(m_Pos, iTrailerSize); | 1188 pHints->AddSegment(m_Pos, iTrailerSize); |
| 1182 return false; | 1189 return false; |
| 1183 } | 1190 } |
| 1184 | 1191 |
| 1185 if (!pTrailer->IsDictionary()) | 1192 if (!pTrailer->IsDictionary()) |
| 1186 return false; | 1193 return false; |
| 1187 | 1194 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 if (!pPages) { | 1259 if (!pPages) { |
| 1253 if (m_docStatus == PDF_DATAAVAIL_ERROR) { | 1260 if (m_docStatus == PDF_DATAAVAIL_ERROR) { |
| 1254 m_docStatus = PDF_DATAAVAIL_ERROR; | 1261 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1255 return false; | 1262 return false; |
| 1256 } | 1263 } |
| 1257 return false; | 1264 return false; |
| 1258 } | 1265 } |
| 1259 | 1266 |
| 1260 CPDF_Array* pArray = pPages->AsArray(); | 1267 CPDF_Array* pArray = pPages->AsArray(); |
| 1261 if (!pArray) { | 1268 if (!pArray) { |
| 1262 delete pPages; | 1269 pPages->Release(); |
| 1263 m_docStatus = PDF_DATAAVAIL_ERROR; | 1270 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1264 return false; | 1271 return false; |
| 1265 } | 1272 } |
| 1266 | 1273 |
| 1267 pPageNode->m_type = PDF_PAGENODE_PAGES; | 1274 pPageNode->m_type = PDF_PAGENODE_PAGES; |
| 1268 for (size_t i = 0; i < pArray->GetCount(); ++i) { | 1275 for (size_t i = 0; i < pArray->GetCount(); ++i) { |
| 1269 CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i)); | 1276 CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i)); |
| 1270 if (!pKid) | 1277 if (!pKid) |
| 1271 continue; | 1278 continue; |
| 1272 | 1279 |
| 1273 PageNode* pNode = new PageNode(); | 1280 PageNode* pNode = new PageNode(); |
| 1274 pPageNode->m_childNode.Add(pNode); | 1281 pPageNode->m_childNode.Add(pNode); |
| 1275 pNode->m_dwPageNo = pKid->GetRefObjNum(); | 1282 pNode->m_dwPageNo = pKid->GetRefObjNum(); |
| 1276 } | 1283 } |
| 1277 delete pPages; | 1284 pPages->Release(); |
| 1278 return true; | 1285 return true; |
| 1279 } | 1286 } |
| 1280 | 1287 |
| 1281 bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, | 1288 bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, |
| 1282 PageNode* pPageNode, | 1289 PageNode* pPageNode, |
| 1283 DownloadHints* pHints) { | 1290 DownloadHints* pHints) { |
| 1284 bool bExist = false; | 1291 bool bExist = false; |
| 1285 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist); | 1292 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist); |
| 1286 if (!bExist) { | 1293 if (!bExist) { |
| 1287 m_docStatus = PDF_DATAAVAIL_ERROR; | 1294 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1288 return false; | 1295 return false; |
| 1289 } | 1296 } |
| 1290 | 1297 |
| 1291 if (!pPage) { | 1298 if (!pPage) { |
| 1292 if (m_docStatus == PDF_DATAAVAIL_ERROR) | 1299 if (m_docStatus == PDF_DATAAVAIL_ERROR) |
| 1293 m_docStatus = PDF_DATAAVAIL_ERROR; | 1300 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1294 return false; | 1301 return false; |
| 1295 } | 1302 } |
| 1296 | 1303 |
| 1297 if (pPage->IsArray()) { | 1304 if (pPage->IsArray()) { |
| 1298 pPageNode->m_dwPageNo = dwPageNo; | 1305 pPageNode->m_dwPageNo = dwPageNo; |
| 1299 pPageNode->m_type = PDF_PAGENODE_ARRAY; | 1306 pPageNode->m_type = PDF_PAGENODE_ARRAY; |
| 1300 delete pPage; | 1307 pPage->Release(); |
| 1301 return true; | 1308 return true; |
| 1302 } | 1309 } |
| 1303 | 1310 |
| 1304 if (!pPage->IsDictionary()) { | 1311 if (!pPage->IsDictionary()) { |
| 1305 delete pPage; | 1312 pPage->Release(); |
| 1306 m_docStatus = PDF_DATAAVAIL_ERROR; | 1313 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1307 return false; | 1314 return false; |
| 1308 } | 1315 } |
| 1309 | 1316 |
| 1310 pPageNode->m_dwPageNo = dwPageNo; | 1317 pPageNode->m_dwPageNo = dwPageNo; |
| 1311 CPDF_Dictionary* pDict = pPage->GetDict(); | 1318 CPDF_Dictionary* pDict = pPage->GetDict(); |
| 1312 CFX_ByteString type = pDict->GetStringFor("Type"); | 1319 CFX_ByteString type = pDict->GetStringFor("Type"); |
| 1313 if (type == "Pages") { | 1320 if (type == "Pages") { |
| 1314 pPageNode->m_type = PDF_PAGENODE_PAGES; | 1321 pPageNode->m_type = PDF_PAGENODE_PAGES; |
| 1315 CPDF_Object* pKids = pDict->GetObjectFor("Kids"); | 1322 CPDF_Object* pKids = pDict->GetObjectFor("Kids"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1336 pPageNode->m_childNode.Add(pNode); | 1343 pPageNode->m_childNode.Add(pNode); |
| 1337 pNode->m_dwPageNo = pKid->GetRefObjNum(); | 1344 pNode->m_dwPageNo = pKid->GetRefObjNum(); |
| 1338 } | 1345 } |
| 1339 } break; | 1346 } break; |
| 1340 default: | 1347 default: |
| 1341 break; | 1348 break; |
| 1342 } | 1349 } |
| 1343 } else if (type == "Page") { | 1350 } else if (type == "Page") { |
| 1344 pPageNode->m_type = PDF_PAGENODE_PAGE; | 1351 pPageNode->m_type = PDF_PAGENODE_PAGE; |
| 1345 } else { | 1352 } else { |
| 1346 delete pPage; | 1353 pPage->Release(); |
| 1347 m_docStatus = PDF_DATAAVAIL_ERROR; | 1354 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1348 return false; | 1355 return false; |
| 1349 } | 1356 } |
| 1350 delete pPage; | 1357 pPage->Release(); |
| 1351 return true; | 1358 return true; |
| 1352 } | 1359 } |
| 1353 | 1360 |
| 1354 bool CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes, | 1361 bool CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes, |
| 1355 int32_t iPage, | 1362 int32_t iPage, |
| 1356 int32_t& iCount, | 1363 int32_t& iCount, |
| 1357 DownloadHints* pHints, | 1364 DownloadHints* pHints, |
| 1358 int level) { | 1365 int level) { |
| 1359 if (level >= kMaxPageRecursionDepth) | 1366 if (level >= kMaxPageRecursionDepth) |
| 1360 return false; | 1367 return false; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 if (!bExist) { | 1435 if (!bExist) { |
| 1429 m_docStatus = PDF_DATAAVAIL_ERROR; | 1436 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1430 return false; | 1437 return false; |
| 1431 } | 1438 } |
| 1432 | 1439 |
| 1433 if (!pPages) | 1440 if (!pPages) |
| 1434 return false; | 1441 return false; |
| 1435 | 1442 |
| 1436 CPDF_Dictionary* pPagesDict = pPages->GetDict(); | 1443 CPDF_Dictionary* pPagesDict = pPages->GetDict(); |
| 1437 if (!pPagesDict) { | 1444 if (!pPagesDict) { |
| 1438 delete pPages; | 1445 pPages->Release(); |
| 1439 m_docStatus = PDF_DATAAVAIL_ERROR; | 1446 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 1440 return false; | 1447 return false; |
| 1441 } | 1448 } |
| 1442 | 1449 |
| 1443 if (!pPagesDict->KeyExist("Kids")) { | 1450 if (!pPagesDict->KeyExist("Kids")) { |
| 1444 delete pPages; | 1451 pPages->Release(); |
| 1445 return true; | 1452 return true; |
| 1446 } | 1453 } |
| 1447 | 1454 |
| 1448 int count = pPagesDict->GetIntegerFor("Count"); | 1455 int count = pPagesDict->GetIntegerFor("Count"); |
| 1449 if (count > 0) { | 1456 if (count > 0) { |
| 1450 delete pPages; | 1457 pPages->Release(); |
| 1451 return true; | 1458 return true; |
| 1452 } | 1459 } |
| 1453 | 1460 |
| 1454 delete pPages; | 1461 pPages->Release(); |
| 1455 return false; | 1462 return false; |
| 1456 } | 1463 } |
| 1457 | 1464 |
| 1458 bool CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) { | 1465 bool CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) { |
| 1459 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) | 1466 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) |
| 1460 return false; | 1467 return false; |
| 1461 | 1468 |
| 1462 if (CheckPageCount(pHints)) { | 1469 if (CheckPageCount(pHints)) { |
| 1463 m_docStatus = PDF_DATAAVAIL_PAGE; | 1470 m_docStatus = PDF_DATAAVAIL_PAGE; |
| 1464 return true; | 1471 return true; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 return FormAvailable; | 1816 return FormAvailable; |
| 1810 } | 1817 } |
| 1811 | 1818 |
| 1812 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} | 1819 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} |
| 1813 | 1820 |
| 1814 CPDF_DataAvail::PageNode::~PageNode() { | 1821 CPDF_DataAvail::PageNode::~PageNode() { |
| 1815 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) | 1822 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) |
| 1816 delete m_childNode[i]; | 1823 delete m_childNode[i]; |
| 1817 m_childNode.RemoveAll(); | 1824 m_childNode.RemoveAll(); |
| 1818 } | 1825 } |
| OLD | NEW |