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 <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "../../../include/fpdfapi/fpdf_module.h" | 10 #include "../../../include/fpdfapi/fpdf_module.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { | 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 void* 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 int32_t iLen = m_Trailers.GetSize(); | 97 int32_t iLen = m_Trailers.GetSize(); |
(...skipping 19 matching lines...) Expand all Loading... |
117 if (*(FX_DWORD*)buf == tag) { | 117 if (*(FX_DWORD*)buf == tag) { |
118 return offset; | 118 return offset; |
119 } | 119 } |
120 offset ++; | 120 offset ++; |
121 if (offset > 1024) { | 121 if (offset > 1024) { |
122 return -1; | 122 return -1; |
123 } | 123 } |
124 } | 124 } |
125 return -1; | 125 return -1; |
126 } | 126 } |
127 FX_DWORD CPDF_Parser::StartParse(FX_LPCSTR filename, FX_BOOL bReParse) | 127 FX_DWORD CPDF_Parser::StartParse(const FX_CHAR* filename, FX_BOOL bReParse) |
128 { | 128 { |
129 IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); | 129 IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); |
130 if (!pFileAccess) { | 130 if (!pFileAccess) { |
131 return PDFPARSE_ERROR_FILE; | 131 return PDFPARSE_ERROR_FILE; |
132 } | 132 } |
133 return StartParse(pFileAccess, bReParse); | 133 return StartParse(pFileAccess, bReParse); |
134 } | 134 } |
135 FX_DWORD CPDF_Parser::StartParse(FX_LPCWSTR filename, FX_BOOL bReParse) | 135 FX_DWORD CPDF_Parser::StartParse(const FX_WCHAR* filename, FX_BOOL bReParse) |
136 { | 136 { |
137 IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); | 137 IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); |
138 if (!pFileAccess) { | 138 if (!pFileAccess) { |
139 return PDFPARSE_ERROR_FILE; | 139 return PDFPARSE_ERROR_FILE; |
140 } | 140 } |
141 return StartParse(pFileAccess, bReParse); | 141 return StartParse(pFileAccess, bReParse); |
142 } | 142 } |
143 CPDF_SecurityHandler* FPDF_CreateStandardSecurityHandler(); | 143 CPDF_SecurityHandler* FPDF_CreateStandardSecurityHandler(); |
144 CPDF_SecurityHandler* FPDF_CreatePubKeyHandler(void*); | 144 CPDF_SecurityHandler* FPDF_CreatePubKeyHandler(void*); |
145 FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse, FX
_BOOL bOwnFileRead) | 145 FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse, FX
_BOOL bOwnFileRead) |
(...skipping 26 matching lines...) Expand all Loading... |
172 if (m_Syntax.m_FileLen < m_Syntax.m_HeaderOffset + 9) { | 172 if (m_Syntax.m_FileLen < m_Syntax.m_HeaderOffset + 9) { |
173 return PDFPARSE_ERROR_FORMAT; | 173 return PDFPARSE_ERROR_FORMAT; |
174 } | 174 } |
175 m_Syntax.RestorePos(m_Syntax.m_FileLen - m_Syntax.m_HeaderOffset - 9); | 175 m_Syntax.RestorePos(m_Syntax.m_FileLen - m_Syntax.m_HeaderOffset - 9); |
176 if (!bReParse) { | 176 if (!bReParse) { |
177 m_pDocument = new CPDF_Document(this); | 177 m_pDocument = new CPDF_Document(this); |
178 } | 178 } |
179 FX_BOOL bXRefRebuilt = FALSE; | 179 FX_BOOL bXRefRebuilt = FALSE; |
180 if (m_Syntax.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, 4096)) { | 180 if (m_Syntax.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, 4096)) { |
181 FX_FILESIZE startxref_offset = m_Syntax.SavePos(); | 181 FX_FILESIZE startxref_offset = m_Syntax.SavePos(); |
182 FX_LPVOID pResult = FXSYS_bsearch(&startxref_offset, m_SortedOffset.GetD
ata(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 182 void* pResult = FXSYS_bsearch(&startxref_offset, m_SortedOffset.GetData(
), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
183 if (pResult == NULL) { | 183 if (pResult == NULL) { |
184 m_SortedOffset.Add(startxref_offset); | 184 m_SortedOffset.Add(startxref_offset); |
185 } | 185 } |
186 m_Syntax.GetKeyword(); | 186 m_Syntax.GetKeyword(); |
187 FX_BOOL bNumber; | 187 FX_BOOL bNumber; |
188 CFX_ByteString xrefpos_str = m_Syntax.GetNextWord(bNumber); | 188 CFX_ByteString xrefpos_str = m_Syntax.GetNextWord(bNumber); |
189 if (!bNumber) { | 189 if (!bNumber) { |
190 return PDFPARSE_ERROR_FORMAT; | 190 return PDFPARSE_ERROR_FORMAT; |
191 } | 191 } |
192 m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); | 192 m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 for (int32_t i = 1; i < CrossRefList.GetSize(); i ++) | 433 for (int32_t i = 1; i < CrossRefList.GetSize(); i ++) |
434 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE, i == 0))
{ | 434 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE, i == 0))
{ |
435 return FALSE; | 435 return FALSE; |
436 } | 436 } |
437 return TRUE; | 437 return TRUE; |
438 } | 438 } |
439 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou
nt) | 439 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou
nt) |
440 { | 440 { |
441 FX_FILESIZE dwStartPos = pos - m_Syntax.m_HeaderOffset; | 441 FX_FILESIZE dwStartPos = pos - m_Syntax.m_HeaderOffset; |
442 m_Syntax.RestorePos(dwStartPos); | 442 m_Syntax.RestorePos(dwStartPos); |
443 FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOf
fset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 443 void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset
.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
444 if (pResult == NULL) { | 444 if (pResult == NULL) { |
445 m_SortedOffset.Add(pos); | 445 m_SortedOffset.Add(pos); |
446 } | 446 } |
447 FX_DWORD start_objnum = 0; | 447 FX_DWORD start_objnum = 0; |
448 FX_DWORD count = dwObjCount; | 448 FX_DWORD count = dwObjCount; |
449 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 449 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
450 int32_t recordsize = 20; | 450 int32_t recordsize = 20; |
451 char* pBuf = FX_Alloc(char, 1024 * recordsize + 1); | 451 char* pBuf = FX_Alloc(char, 1024 * recordsize + 1); |
452 pBuf[1024 * recordsize] = '\0'; | 452 pBuf[1024 * recordsize] = '\0'; |
453 int32_t nBlocks = count / 1024 + 1; | 453 int32_t nBlocks = count / 1024 + 1; |
454 for (int32_t block = 0; block < nBlocks; block ++) { | 454 for (int32_t block = 0; block < nBlocks; block ++) { |
455 int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024; | 455 int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024; |
456 FX_DWORD dwReadSize = block_size * recordsize; | 456 FX_DWORD dwReadSize = block_size * recordsize; |
457 if ((FX_FILESIZE)(dwStartPos + dwReadSize) > m_Syntax.m_FileLen) { | 457 if ((FX_FILESIZE)(dwStartPos + dwReadSize) > m_Syntax.m_FileLen) { |
458 FX_Free(pBuf); | 458 FX_Free(pBuf); |
459 return FALSE; | 459 return FALSE; |
460 } | 460 } |
461 if (!m_Syntax.ReadBlock((FX_LPBYTE)pBuf, dwReadSize)) { | 461 if (!m_Syntax.ReadBlock((uint8_t*)pBuf, dwReadSize)) { |
462 FX_Free(pBuf); | 462 FX_Free(pBuf); |
463 return FALSE; | 463 return FALSE; |
464 } | 464 } |
465 for (int32_t i = 0; i < block_size; i ++) { | 465 for (int32_t i = 0; i < block_size; i ++) { |
466 FX_DWORD objnum = start_objnum + block * 1024 + i; | 466 FX_DWORD objnum = start_objnum + block * 1024 + i; |
467 char* pEntry = pBuf + i * recordsize; | 467 char* pEntry = pBuf + i * recordsize; |
468 if (pEntry[17] == 'f') { | 468 if (pEntry[17] == 'f') { |
469 m_CrossRef.SetAtGrow(objnum, 0); | 469 m_CrossRef.SetAtGrow(objnum, 0); |
470 m_V5Type.SetAtGrow(objnum, 0); | 470 m_V5Type.SetAtGrow(objnum, 0); |
471 } else { | 471 } else { |
472 int32_t offset = FXSYS_atoi(pEntry); | 472 int32_t offset = FXSYS_atoi(pEntry); |
473 if (offset == 0) { | 473 if (offset == 0) { |
474 for (int32_t c = 0; c < 10; c ++) { | 474 for (int32_t c = 0; c < 10; c ++) { |
475 if (pEntry[c] < '0' || pEntry[c] > '9') { | 475 if (pEntry[c] < '0' || pEntry[c] > '9') { |
476 FX_Free(pBuf); | 476 FX_Free(pBuf); |
477 return FALSE; | 477 return FALSE; |
478 } | 478 } |
479 } | 479 } |
480 } | 480 } |
481 m_CrossRef.SetAtGrow(objnum, offset); | 481 m_CrossRef.SetAtGrow(objnum, offset); |
482 int32_t version = FXSYS_atoi(pEntry + 11); | 482 int32_t version = FXSYS_atoi(pEntry + 11); |
483 if (version >= 1) { | 483 if (version >= 1) { |
484 m_bVersionUpdated = TRUE; | 484 m_bVersionUpdated = TRUE; |
485 } | 485 } |
486 m_ObjVersion.SetAtGrow(objnum, version); | 486 m_ObjVersion.SetAtGrow(objnum, version); |
487 if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { | 487 if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { |
488 FX_LPVOID pResult = FXSYS_bsearch(&m_CrossRef[objnum], m_Sor
tedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFile
Size); | 488 void* pResult = FXSYS_bsearch(&m_CrossRef[objnum], m_SortedO
ffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize
); |
489 if (pResult == NULL) { | 489 if (pResult == NULL) { |
490 m_SortedOffset.Add(m_CrossRef[objnum]); | 490 m_SortedOffset.Add(m_CrossRef[objnum]); |
491 } | 491 } |
492 } | 492 } |
493 m_V5Type.SetAtGrow(objnum, 1); | 493 m_V5Type.SetAtGrow(objnum, 1); |
494 } | 494 } |
495 } | 495 } |
496 } | 496 } |
497 FX_Free(pBuf); | 497 FX_Free(pBuf); |
498 m_Syntax.RestorePos(SavedPos + count * recordsize); | 498 m_Syntax.RestorePos(SavedPos + count * recordsize); |
499 return TRUE; | 499 return TRUE; |
500 } | 500 } |
501 FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B
OOL bSkip, FX_BOOL bFirst) | 501 FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B
OOL bSkip, FX_BOOL bFirst) |
502 { | 502 { |
503 m_Syntax.RestorePos(pos); | 503 m_Syntax.RestorePos(pos); |
504 if (m_Syntax.GetKeyword() != FX_BSTRC("xref")) { | 504 if (m_Syntax.GetKeyword() != FX_BSTRC("xref")) { |
505 return FALSE; | 505 return FALSE; |
506 } | 506 } |
507 FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOf
fset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 507 void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset
.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
508 if (pResult == NULL) { | 508 if (pResult == NULL) { |
509 m_SortedOffset.Add(pos); | 509 m_SortedOffset.Add(pos); |
510 } | 510 } |
511 if (streampos) { | 511 if (streampos) { |
512 FX_LPVOID pResult = FXSYS_bsearch(&streampos, m_SortedOffset.GetData(),
m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 512 void* pResult = FXSYS_bsearch(&streampos, m_SortedOffset.GetData(), m_So
rtedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
513 if (pResult == NULL) { | 513 if (pResult == NULL) { |
514 m_SortedOffset.Add(streampos); | 514 m_SortedOffset.Add(streampos); |
515 } | 515 } |
516 } | 516 } |
517 while (1) { | 517 while (1) { |
518 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 518 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
519 FX_BOOL bIsNumber; | 519 FX_BOOL bIsNumber; |
520 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); | 520 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); |
521 if (word.IsEmpty()) { | 521 if (word.IsEmpty()) { |
522 return FALSE; | 522 return FALSE; |
(...skipping 15 matching lines...) Expand all Loading... |
538 bFirstItem = TRUE; | 538 bFirstItem = TRUE; |
539 } | 539 } |
540 m_dwXrefStartObjNum = start_objnum; | 540 m_dwXrefStartObjNum = start_objnum; |
541 if (!bSkip) { | 541 if (!bSkip) { |
542 char* pBuf = FX_Alloc(char, 1024 * recordsize + 1); | 542 char* pBuf = FX_Alloc(char, 1024 * recordsize + 1); |
543 pBuf[1024 * recordsize] = '\0'; | 543 pBuf[1024 * recordsize] = '\0'; |
544 int32_t nBlocks = count / 1024 + 1; | 544 int32_t nBlocks = count / 1024 + 1; |
545 FX_BOOL bFirstBlock = TRUE; | 545 FX_BOOL bFirstBlock = TRUE; |
546 for (int32_t block = 0; block < nBlocks; block ++) { | 546 for (int32_t block = 0; block < nBlocks; block ++) { |
547 int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024; | 547 int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024; |
548 m_Syntax.ReadBlock((FX_LPBYTE)pBuf, block_size * recordsize); | 548 m_Syntax.ReadBlock((uint8_t*)pBuf, block_size * recordsize); |
549 for (int32_t i = 0; i < block_size; i ++) { | 549 for (int32_t i = 0; i < block_size; i ++) { |
550 FX_DWORD objnum = start_objnum + block * 1024 + i; | 550 FX_DWORD objnum = start_objnum + block * 1024 + i; |
551 char* pEntry = pBuf + i * recordsize; | 551 char* pEntry = pBuf + i * recordsize; |
552 if (pEntry[17] == 'f') { | 552 if (pEntry[17] == 'f') { |
553 if (bFirstItem) { | 553 if (bFirstItem) { |
554 objnum = 0; | 554 objnum = 0; |
555 bFirstItem = FALSE; | 555 bFirstItem = FALSE; |
556 } | 556 } |
557 if (bFirstBlock) { | 557 if (bFirstBlock) { |
558 FX_FILESIZE offset = (FX_FILESIZE)FXSYS_atoi64(pEntr
y); | 558 FX_FILESIZE offset = (FX_FILESIZE)FXSYS_atoi64(pEntr
y); |
(...skipping 15 matching lines...) Expand all Loading... |
574 } | 574 } |
575 } | 575 } |
576 } | 576 } |
577 m_CrossRef.SetAtGrow(objnum, offset); | 577 m_CrossRef.SetAtGrow(objnum, offset); |
578 int32_t version = FXSYS_atoi(pEntry + 11); | 578 int32_t version = FXSYS_atoi(pEntry + 11); |
579 if (version >= 1) { | 579 if (version >= 1) { |
580 m_bVersionUpdated = TRUE; | 580 m_bVersionUpdated = TRUE; |
581 } | 581 } |
582 m_ObjVersion.SetAtGrow(objnum, version); | 582 m_ObjVersion.SetAtGrow(objnum, version); |
583 if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { | 583 if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { |
584 FX_LPVOID pResult = FXSYS_bsearch(&m_CrossRef[objnum
], m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _Com
pareFileSize); | 584 void* pResult = FXSYS_bsearch(&m_CrossRef[objnum], m
_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _Compare
FileSize); |
585 if (pResult == NULL) { | 585 if (pResult == NULL) { |
586 m_SortedOffset.Add(m_CrossRef[objnum]); | 586 m_SortedOffset.Add(m_CrossRef[objnum]); |
587 } | 587 } |
588 } | 588 } |
589 m_V5Type.SetAtGrow(objnum, 1); | 589 m_V5Type.SetAtGrow(objnum, 1); |
590 } | 590 } |
591 if (bFirstBlock) { | 591 if (bFirstBlock) { |
592 bFirstBlock = FALSE; | 592 bFirstBlock = FALSE; |
593 } | 593 } |
594 } | 594 } |
(...skipping 28 matching lines...) Expand all Loading... |
623 m_SortedOffset.RemoveAll(); | 623 m_SortedOffset.RemoveAll(); |
624 m_ObjVersion.RemoveAll(); | 624 m_ObjVersion.RemoveAll(); |
625 if (m_pTrailer) { | 625 if (m_pTrailer) { |
626 m_pTrailer->Release(); | 626 m_pTrailer->Release(); |
627 m_pTrailer = NULL; | 627 m_pTrailer = NULL; |
628 } | 628 } |
629 int32_t status = 0; | 629 int32_t status = 0; |
630 int32_t inside_index = 0; | 630 int32_t inside_index = 0; |
631 FX_DWORD objnum = 0, gennum = 0; | 631 FX_DWORD objnum = 0, gennum = 0; |
632 int32_t depth = 0; | 632 int32_t depth = 0; |
633 FX_LPBYTE buffer = FX_Alloc(uint8_t, 4096); | 633 uint8_t* buffer = FX_Alloc(uint8_t, 4096); |
634 FX_FILESIZE pos = m_Syntax.m_HeaderOffset; | 634 FX_FILESIZE pos = m_Syntax.m_HeaderOffset; |
635 FX_FILESIZE start_pos = 0, start_pos1 = 0; | 635 FX_FILESIZE start_pos = 0, start_pos1 = 0; |
636 FX_FILESIZE last_obj = -1, last_xref = -1, last_trailer = -1; | 636 FX_FILESIZE last_obj = -1, last_xref = -1, last_trailer = -1; |
637 while (pos < m_Syntax.m_FileLen) { | 637 while (pos < m_Syntax.m_FileLen) { |
638 FX_BOOL bOverFlow = FALSE; | 638 FX_BOOL bOverFlow = FALSE; |
639 FX_DWORD size = (FX_DWORD)(m_Syntax.m_FileLen - pos); | 639 FX_DWORD size = (FX_DWORD)(m_Syntax.m_FileLen - pos); |
640 if (size > 4096) { | 640 if (size > 4096) { |
641 size = 4096; | 641 size = 4096; |
642 } | 642 } |
643 if (!m_Syntax.m_pFileAccess->ReadBlock(buffer, pos, size)) { | 643 if (!m_Syntax.m_pFileAccess->ReadBlock(buffer, pos, size)) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 } | 769 } |
770 break; | 770 break; |
771 case 3: | 771 case 3: |
772 if (PDF_CharType[byte] == 'W' || PDF_CharType[byte]
== 'D') { | 772 if (PDF_CharType[byte] == 'W' || PDF_CharType[byte]
== 'D') { |
773 if (objnum > 0x1000000) { | 773 if (objnum > 0x1000000) { |
774 status = 0; | 774 status = 0; |
775 break; | 775 break; |
776 } | 776 } |
777 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_Hea
derOffset; | 777 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_Hea
derOffset; |
778 last_obj = start_pos; | 778 last_obj = start_pos; |
779 FX_LPVOID pResult = FXSYS_bsearch(&obj_pos, m_So
rtedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFil
eSize); | 779 void* pResult = FXSYS_bsearch(&obj_pos, m_Sorted
Offset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSiz
e); |
780 if (pResult == NULL) { | 780 if (pResult == NULL) { |
781 m_SortedOffset.Add(obj_pos); | 781 m_SortedOffset.Add(obj_pos); |
782 } | 782 } |
783 FX_FILESIZE obj_end = 0; | 783 FX_FILESIZE obj_end = 0; |
784 CPDF_Object *pObject = ParseIndirectObjectAtBySt
rict(m_pDocument, obj_pos, objnum, NULL, &obj_end); | 784 CPDF_Object *pObject = ParseIndirectObjectAtBySt
rict(m_pDocument, obj_pos, objnum, NULL, &obj_end); |
785 if (pObject) { | 785 if (pObject) { |
786 int iType = pObject->GetType(); | 786 int iType = pObject->GetType(); |
787 if (iType == PDFOBJ_STREAM) { | 787 if (iType == PDFOBJ_STREAM) { |
788 CPDF_Stream* pStream = (CPDF_Stream*)pOb
ject; | 788 CPDF_Stream* pStream = (CPDF_Stream*)pOb
ject; |
789 CPDF_Dictionary* pDict = pStream->GetDic
t(); | 789 CPDF_Dictionary* pDict = pStream->GetDic
t(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 } | 972 } |
973 } | 973 } |
974 pos += size; | 974 pos += size; |
975 } | 975 } |
976 if (last_xref != -1 && last_xref > last_obj) { | 976 if (last_xref != -1 && last_xref > last_obj) { |
977 last_trailer = last_xref; | 977 last_trailer = last_xref; |
978 } else if (last_trailer == -1 || last_xref < last_obj) { | 978 } else if (last_trailer == -1 || last_xref < last_obj) { |
979 last_trailer = m_Syntax.m_FileLen; | 979 last_trailer = m_Syntax.m_FileLen; |
980 } | 980 } |
981 FX_FILESIZE offset = last_trailer - m_Syntax.m_HeaderOffset; | 981 FX_FILESIZE offset = last_trailer - m_Syntax.m_HeaderOffset; |
982 FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_Sorte
dOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 982 void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOff
set.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
983 if (pResult == NULL) { | 983 if (pResult == NULL) { |
984 m_SortedOffset.Add(offset); | 984 m_SortedOffset.Add(offset); |
985 } | 985 } |
986 FX_Free(buffer); | 986 FX_Free(buffer); |
987 return TRUE; | 987 return TRUE; |
988 } | 988 } |
989 static FX_DWORD _GetVarInt(FX_LPCBYTE p, int32_t n) | 989 static FX_DWORD _GetVarInt(const uint8_t* p, int32_t n) |
990 { | 990 { |
991 FX_DWORD result = 0; | 991 FX_DWORD result = 0; |
992 for (int32_t i = 0; i < n; i ++) { | 992 for (int32_t i = 0; i < n; i ++) { |
993 result = result * 256 + p[i]; | 993 result = result * 256 + p[i]; |
994 } | 994 } |
995 return result; | 995 return result; |
996 } | 996 } |
997 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL
bMainXRef) | 997 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL
bMainXRef) |
998 { | 998 { |
999 CPDF_Stream* pStream = (CPDF_Stream*)ParseIndirectObjectAt(m_pDocument, pos,
0, NULL); | 999 CPDF_Stream* pStream = (CPDF_Stream*)ParseIndirectObjectAt(m_pDocument, pos,
0, NULL); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 WidthArray.Add(pArray->GetInteger(i)); | 1060 WidthArray.Add(pArray->GetInteger(i)); |
1061 dwAccWidth += WidthArray[i]; | 1061 dwAccWidth += WidthArray[i]; |
1062 } | 1062 } |
1063 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) { | 1063 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) { |
1064 pStream->Release(); | 1064 pStream->Release(); |
1065 return FALSE; | 1065 return FALSE; |
1066 } | 1066 } |
1067 FX_DWORD totalWidth = dwAccWidth.ValueOrDie(); | 1067 FX_DWORD totalWidth = dwAccWidth.ValueOrDie(); |
1068 CPDF_StreamAcc acc; | 1068 CPDF_StreamAcc acc; |
1069 acc.LoadAllData(pStream); | 1069 acc.LoadAllData(pStream); |
1070 FX_LPCBYTE pData = acc.GetData(); | 1070 const uint8_t* pData = acc.GetData(); |
1071 FX_DWORD dwTotalSize = acc.GetSize(); | 1071 FX_DWORD dwTotalSize = acc.GetSize(); |
1072 FX_DWORD segindex = 0; | 1072 FX_DWORD segindex = 0; |
1073 for (FX_DWORD i = 0; i < arrIndex.size(); i ++) { | 1073 for (FX_DWORD i = 0; i < arrIndex.size(); i ++) { |
1074 int32_t startnum = arrIndex[i].first; | 1074 int32_t startnum = arrIndex[i].first; |
1075 if (startnum < 0) { | 1075 if (startnum < 0) { |
1076 continue; | 1076 continue; |
1077 } | 1077 } |
1078 m_dwXrefStartObjNum = pdfium::base::checked_cast<FX_DWORD, int32_t> (sta
rtnum); | 1078 m_dwXrefStartObjNum = pdfium::base::checked_cast<FX_DWORD, int32_t> (sta
rtnum); |
1079 FX_DWORD count = pdfium::base::checked_cast<FX_DWORD, int32_t> (arrIndex
[i].second); | 1079 FX_DWORD count = pdfium::base::checked_cast<FX_DWORD, int32_t> (arrIndex
[i].second); |
1080 FX_SAFE_DWORD dwCaculatedSize = segindex; | 1080 FX_SAFE_DWORD dwCaculatedSize = segindex; |
1081 dwCaculatedSize += count; | 1081 dwCaculatedSize += count; |
1082 dwCaculatedSize *= totalWidth; | 1082 dwCaculatedSize *= totalWidth; |
1083 if (!dwCaculatedSize.IsValid() || dwCaculatedSize.ValueOrDie() > dwTotal
Size) { | 1083 if (!dwCaculatedSize.IsValid() || dwCaculatedSize.ValueOrDie() > dwTotal
Size) { |
1084 continue; | 1084 continue; |
1085 } | 1085 } |
1086 FX_LPCBYTE segstart = pData + segindex * totalWidth; | 1086 const uint8_t* segstart = pData + segindex * totalWidth; |
1087 FX_SAFE_DWORD dwMaxObjNum = startnum; | 1087 FX_SAFE_DWORD dwMaxObjNum = startnum; |
1088 dwMaxObjNum += count; | 1088 dwMaxObjNum += count; |
1089 FX_DWORD dwV5Size = pdfium::base::checked_cast<FX_DWORD, int32_t> (m_V5T
ype.GetSize()); | 1089 FX_DWORD dwV5Size = pdfium::base::checked_cast<FX_DWORD, int32_t> (m_V5T
ype.GetSize()); |
1090 if (!dwMaxObjNum.IsValid() || dwMaxObjNum.ValueOrDie() > dwV5Size) { | 1090 if (!dwMaxObjNum.IsValid() || dwMaxObjNum.ValueOrDie() > dwV5Size) { |
1091 continue; | 1091 continue; |
1092 } | 1092 } |
1093 for (FX_DWORD j = 0; j < count; j ++) { | 1093 for (FX_DWORD j = 0; j < count; j ++) { |
1094 int32_t type = 1; | 1094 int32_t type = 1; |
1095 FX_LPCBYTE entrystart = segstart + j * totalWidth; | 1095 const uint8_t* entrystart = segstart + j * totalWidth; |
1096 if (WidthArray[0]) { | 1096 if (WidthArray[0]) { |
1097 type = _GetVarInt(entrystart, WidthArray[0]); | 1097 type = _GetVarInt(entrystart, WidthArray[0]); |
1098 } | 1098 } |
1099 if (m_V5Type[startnum + j] == 255) { | 1099 if (m_V5Type[startnum + j] == 255) { |
1100 FX_FILESIZE offset = _GetVarInt(entrystart + WidthArray[0], Widt
hArray[1]); | 1100 FX_FILESIZE offset = _GetVarInt(entrystart + WidthArray[0], Widt
hArray[1]); |
1101 m_CrossRef[startnum + j] = offset; | 1101 m_CrossRef[startnum + j] = offset; |
1102 FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetDat
a(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 1102 void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(),
m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
1103 if (pResult == NULL) { | 1103 if (pResult == NULL) { |
1104 m_SortedOffset.Add(offset); | 1104 m_SortedOffset.Add(offset); |
1105 } | 1105 } |
1106 continue; | 1106 continue; |
1107 } | 1107 } |
1108 if (m_V5Type[startnum + j]) { | 1108 if (m_V5Type[startnum + j]) { |
1109 continue; | 1109 continue; |
1110 } | 1110 } |
1111 m_V5Type[startnum + j] = type; | 1111 m_V5Type[startnum + j] = type; |
1112 if (type == 0) { | 1112 if (type == 0) { |
1113 m_CrossRef[startnum + j] = 0; | 1113 m_CrossRef[startnum + j] = 0; |
1114 } else { | 1114 } else { |
1115 FX_FILESIZE offset = _GetVarInt(entrystart + WidthArray[0], Widt
hArray[1]); | 1115 FX_FILESIZE offset = _GetVarInt(entrystart + WidthArray[0], Widt
hArray[1]); |
1116 m_CrossRef[startnum + j] = offset; | 1116 m_CrossRef[startnum + j] = offset; |
1117 if (type == 1) { | 1117 if (type == 1) { |
1118 FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.Ge
tData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 1118 void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetDat
a(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
1119 if (pResult == NULL) { | 1119 if (pResult == NULL) { |
1120 m_SortedOffset.Add(offset); | 1120 m_SortedOffset.Add(offset); |
1121 } | 1121 } |
1122 } else { | 1122 } else { |
1123 if (offset < 0 || offset >= m_V5Type.GetSize()) { | 1123 if (offset < 0 || offset >= m_V5Type.GetSize()) { |
1124 pStream->Release(); | 1124 pStream->Release(); |
1125 return FALSE; | 1125 return FALSE; |
1126 } | 1126 } |
1127 m_V5Type[offset] = 255; | 1127 m_V5Type[offset] = 255; |
1128 } | 1128 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { | 1170 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { |
1171 return TRUE; | 1171 return TRUE; |
1172 } | 1172 } |
1173 if (m_V5Type[objnum] == 0) { | 1173 if (m_V5Type[objnum] == 0) { |
1174 return TRUE; | 1174 return TRUE; |
1175 } | 1175 } |
1176 if (m_V5Type[objnum] == 2) { | 1176 if (m_V5Type[objnum] == 2) { |
1177 return TRUE; | 1177 return TRUE; |
1178 } | 1178 } |
1179 FX_FILESIZE pos = m_CrossRef[objnum]; | 1179 FX_FILESIZE pos = m_CrossRef[objnum]; |
1180 FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOf
fset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 1180 void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset
.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
1181 if (pResult == NULL) { | 1181 if (pResult == NULL) { |
1182 return TRUE; | 1182 return TRUE; |
1183 } | 1183 } |
1184 if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() == m_Sort
edOffset.GetSize() - 1) { | 1184 if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() == m_Sort
edOffset.GetSize() - 1) { |
1185 return FALSE; | 1185 return FALSE; |
1186 } | 1186 } |
1187 FX_FILESIZE size = ((FX_FILESIZE*)pResult)[1] - pos; | 1187 FX_FILESIZE size = ((FX_FILESIZE*)pResult)[1] - pos; |
1188 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 1188 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
1189 m_Syntax.RestorePos(pos); | 1189 m_Syntax.RestorePos(pos); |
1190 bForm = m_Syntax.SearchMultiWord(FX_BSTRC("/Form\0stream"), TRUE, size) == 0
; | 1190 bForm = m_Syntax.SearchMultiWord(FX_BSTRC("/Form\0stream"), TRUE, size) == 0
; |
(...skipping 13 matching lines...) Expand all Loading... |
1204 return ParseIndirectObjectAt(pObjList, pos, objnum, pContext); | 1204 return ParseIndirectObjectAt(pObjList, pos, objnum, pContext); |
1205 } | 1205 } |
1206 if (m_V5Type[objnum] == 2) { | 1206 if (m_V5Type[objnum] == 2) { |
1207 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum
]); | 1207 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum
]); |
1208 if (pObjStream == NULL) { | 1208 if (pObjStream == NULL) { |
1209 return NULL; | 1209 return NULL; |
1210 } | 1210 } |
1211 int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); | 1211 int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); |
1212 int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); | 1212 int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); |
1213 CPDF_SyntaxParser syntax; | 1213 CPDF_SyntaxParser syntax; |
1214 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p
ObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); | 1214 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pO
bjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); |
1215 syntax.InitParser(file.Get(), 0); | 1215 syntax.InitParser(file.Get(), 0); |
1216 CPDF_Object* pRet = NULL; | 1216 CPDF_Object* pRet = NULL; |
1217 while (n) { | 1217 while (n) { |
1218 FX_DWORD thisnum = syntax.GetDirectNum(); | 1218 FX_DWORD thisnum = syntax.GetDirectNum(); |
1219 FX_DWORD thisoff = syntax.GetDirectNum(); | 1219 FX_DWORD thisoff = syntax.GetDirectNum(); |
1220 if (thisnum == objnum) { | 1220 if (thisnum == objnum) { |
1221 syntax.RestorePos(offset + thisoff); | 1221 syntax.RestorePos(offset + thisoff); |
1222 pRet = syntax.GetObject(pObjList, 0, 0, pContext); | 1222 pRet = syntax.GetObject(pObjList, 0, 0, pContext); |
1223 break; | 1223 break; |
1224 } | 1224 } |
(...skipping 24 matching lines...) Expand all Loading... |
1249 return 0; | 1249 return 0; |
1250 } | 1250 } |
1251 if (m_V5Type[objnum] == 2) { | 1251 if (m_V5Type[objnum] == 2) { |
1252 objnum = (FX_DWORD)m_CrossRef[objnum]; | 1252 objnum = (FX_DWORD)m_CrossRef[objnum]; |
1253 } | 1253 } |
1254 if (m_V5Type[objnum] == 1 || m_V5Type[objnum] == 255) { | 1254 if (m_V5Type[objnum] == 1 || m_V5Type[objnum] == 255) { |
1255 FX_FILESIZE offset = m_CrossRef[objnum]; | 1255 FX_FILESIZE offset = m_CrossRef[objnum]; |
1256 if (offset == 0) { | 1256 if (offset == 0) { |
1257 return 0; | 1257 return 0; |
1258 } | 1258 } |
1259 FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_S
ortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 1259 void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_Sorte
dOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
1260 if (pResult == NULL) { | 1260 if (pResult == NULL) { |
1261 return 0; | 1261 return 0; |
1262 } | 1262 } |
1263 if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() == m_
SortedOffset.GetSize() - 1) { | 1263 if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() == m_
SortedOffset.GetSize() - 1) { |
1264 return 0; | 1264 return 0; |
1265 } | 1265 } |
1266 return ((FX_FILESIZE*)pResult)[1] - offset; | 1266 return ((FX_FILESIZE*)pResult)[1] - offset; |
1267 } | 1267 } |
1268 return 0; | 1268 return 0; |
1269 } | 1269 } |
1270 void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, FX_LPBYTE& pBuffer, FX_DWOR
D& size) | 1270 void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD
& size) |
1271 { | 1271 { |
1272 pBuffer = NULL; | 1272 pBuffer = NULL; |
1273 size = 0; | 1273 size = 0; |
1274 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { | 1274 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { |
1275 return; | 1275 return; |
1276 } | 1276 } |
1277 if (m_V5Type[objnum] == 2) { | 1277 if (m_V5Type[objnum] == 2) { |
1278 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum
]); | 1278 CPDF_StreamAcc* pObjStream = GetObjectStream((FX_DWORD)m_CrossRef[objnum
]); |
1279 if (pObjStream == NULL) { | 1279 if (pObjStream == NULL) { |
1280 return; | 1280 return; |
1281 } | 1281 } |
1282 int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); | 1282 int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); |
1283 int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); | 1283 int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); |
1284 CPDF_SyntaxParser syntax; | 1284 CPDF_SyntaxParser syntax; |
1285 FX_LPCBYTE pData = pObjStream->GetData(); | 1285 const uint8_t* pData = pObjStream->GetData(); |
1286 FX_DWORD totalsize = pObjStream->GetSize(); | 1286 FX_DWORD totalsize = pObjStream->GetSize(); |
1287 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)p
Data, (size_t)totalsize, FALSE)); | 1287 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pD
ata, (size_t)totalsize, FALSE)); |
1288 syntax.InitParser(file.Get(), 0); | 1288 syntax.InitParser(file.Get(), 0); |
1289 while (n) { | 1289 while (n) { |
1290 FX_DWORD thisnum = syntax.GetDirectNum(); | 1290 FX_DWORD thisnum = syntax.GetDirectNum(); |
1291 FX_DWORD thisoff = syntax.GetDirectNum(); | 1291 FX_DWORD thisoff = syntax.GetDirectNum(); |
1292 if (thisnum == objnum) { | 1292 if (thisnum == objnum) { |
1293 if (n == 1) { | 1293 if (n == 1) { |
1294 size = totalsize - (thisoff + offset); | 1294 size = totalsize - (thisoff + offset); |
1295 } else { | 1295 } else { |
1296 syntax.GetDirectNum(); // Skip nextnum. | 1296 syntax.GetDirectNum(); // Skip nextnum. |
1297 FX_DWORD nextoff = syntax.GetDirectNum(); | 1297 FX_DWORD nextoff = syntax.GetDirectNum(); |
(...skipping 27 matching lines...) Expand all Loading... |
1325 } | 1325 } |
1326 word = m_Syntax.GetNextWord(bIsNumber); | 1326 word = m_Syntax.GetNextWord(bIsNumber); |
1327 if (!bIsNumber) { | 1327 if (!bIsNumber) { |
1328 m_Syntax.RestorePos(SavedPos); | 1328 m_Syntax.RestorePos(SavedPos); |
1329 return; | 1329 return; |
1330 } | 1330 } |
1331 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | 1331 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { |
1332 m_Syntax.RestorePos(SavedPos); | 1332 m_Syntax.RestorePos(SavedPos); |
1333 return; | 1333 return; |
1334 } | 1334 } |
1335 FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_Sort
edOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 1335 void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOf
fset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
1336 if (pResult == NULL) { | 1336 if (pResult == NULL) { |
1337 m_Syntax.RestorePos(SavedPos); | 1337 m_Syntax.RestorePos(SavedPos); |
1338 return; | 1338 return; |
1339 } | 1339 } |
1340 FX_FILESIZE nextoff = ((FX_FILESIZE*)pResult)[1]; | 1340 FX_FILESIZE nextoff = ((FX_FILESIZE*)pResult)[1]; |
1341 FX_BOOL bNextOffValid = FALSE; | 1341 FX_BOOL bNextOffValid = FALSE; |
1342 if (nextoff != pos) { | 1342 if (nextoff != pos) { |
1343 m_Syntax.RestorePos(nextoff); | 1343 m_Syntax.RestorePos(nextoff); |
1344 word = m_Syntax.GetNextWord(bIsNumber); | 1344 word = m_Syntax.GetNextWord(bIsNumber); |
1345 if (word == FX_BSTRC("xref")) { | 1345 if (word == FX_BSTRC("xref")) { |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 ++dwCount; | 1655 ++dwCount; |
1656 if (m_Syntax.m_FileLen >= (FX_FILESIZE)(m_Syntax.SavePos() + m_Syntax.m_
HeaderOffset)) { | 1656 if (m_Syntax.m_FileLen >= (FX_FILESIZE)(m_Syntax.SavePos() + m_Syntax.m_
HeaderOffset)) { |
1657 break; | 1657 break; |
1658 } | 1658 } |
1659 m_Syntax.GetNextChar(ch); | 1659 m_Syntax.GetNextChar(ch); |
1660 type = PDF_CharType[ch]; | 1660 type = PDF_CharType[ch]; |
1661 } | 1661 } |
1662 m_LastXRefOffset += dwCount; | 1662 m_LastXRefOffset += dwCount; |
1663 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); | 1663 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); |
1664 while (pos) { | 1664 while (pos) { |
1665 FX_LPVOID objnum; | 1665 void* objnum; |
1666 CPDF_StreamAcc* pStream; | 1666 CPDF_StreamAcc* pStream; |
1667 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); | 1667 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); |
1668 delete pStream; | 1668 delete pStream; |
1669 } | 1669 } |
1670 m_ObjectStreamMap.RemoveAll(); | 1670 m_ObjectStreamMap.RemoveAll(); |
1671 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && !
LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1671 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && !
LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
1672 m_LastXRefOffset = 0; | 1672 m_LastXRefOffset = 0; |
1673 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; | 1673 m_Syntax.m_MetadataObjnum = dwSaveMetadataObjnum; |
1674 return PDFPARSE_ERROR_FORMAT; | 1674 return PDFPARSE_ERROR_FORMAT; |
1675 } | 1675 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 } | 1758 } |
1759 } | 1759 } |
1760 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) { | 1760 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) { |
1761 return FALSE; | 1761 return FALSE; |
1762 } | 1762 } |
1763 m_BufOffset = read_pos; | 1763 m_BufOffset = read_pos; |
1764 } | 1764 } |
1765 ch = m_pFileBuf[pos - m_BufOffset]; | 1765 ch = m_pFileBuf[pos - m_BufOffset]; |
1766 return TRUE; | 1766 return TRUE; |
1767 } | 1767 } |
1768 FX_BOOL CPDF_SyntaxParser::ReadBlock(FX_LPBYTE pBuf, FX_DWORD size) | 1768 FX_BOOL CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, FX_DWORD size) |
1769 { | 1769 { |
1770 if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) { | 1770 if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) { |
1771 return FALSE; | 1771 return FALSE; |
1772 } | 1772 } |
1773 m_Pos += size; | 1773 m_Pos += size; |
1774 return TRUE; | 1774 return TRUE; |
1775 } | 1775 } |
1776 #define MAX_WORD_BUFFER 256 | 1776 #define MAX_WORD_BUFFER 256 |
1777 void CPDF_SyntaxParser::GetNextWord() | 1777 void CPDF_SyntaxParser::GetNextWord() |
1778 { | 1778 { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2040 } | 2040 } |
2041 } | 2041 } |
2042 type = PDF_CharType[ch]; | 2042 type = PDF_CharType[ch]; |
2043 } | 2043 } |
2044 m_Pos --; | 2044 m_Pos --; |
2045 } | 2045 } |
2046 CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber) | 2046 CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber) |
2047 { | 2047 { |
2048 GetNextWord(); | 2048 GetNextWord(); |
2049 bIsNumber = m_bIsNumber; | 2049 bIsNumber = m_bIsNumber; |
2050 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); | 2050 return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); |
2051 } | 2051 } |
2052 CFX_ByteString CPDF_SyntaxParser::GetKeyword() | 2052 CFX_ByteString CPDF_SyntaxParser::GetKeyword() |
2053 { | 2053 { |
2054 GetNextWord(); | 2054 GetNextWord(); |
2055 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); | 2055 return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); |
2056 } | 2056 } |
2057 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
RD objnum, FX_DWORD gennum, PARSE_CONTEXT* pContext, FX_BOOL bDecrypt) | 2057 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
RD objnum, FX_DWORD gennum, PARSE_CONTEXT* pContext, FX_BOOL bDecrypt) |
2058 { | 2058 { |
2059 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); | 2059 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); |
2060 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) { | 2060 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) { |
2061 return NULL; | 2061 return NULL; |
2062 } | 2062 } |
2063 FX_FILESIZE SavedPos = m_Pos; | 2063 FX_FILESIZE SavedPos = m_Pos; |
2064 FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); | 2064 FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); |
2065 FX_BOOL bIsNumber; | 2065 FX_BOOL bIsNumber; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2470 } else { | 2470 } else { |
2471 m_Pos = StreamStartPos; | 2471 m_Pos = StreamStartPos; |
2472 if (FindTag(FX_BSTRC("endobj"), 0) < 0) { | 2472 if (FindTag(FX_BSTRC("endobj"), 0) < 0) { |
2473 return NULL; | 2473 return NULL; |
2474 } | 2474 } |
2475 } | 2475 } |
2476 } | 2476 } |
2477 m_Pos = StreamStartPos; | 2477 m_Pos = StreamStartPos; |
2478 } | 2478 } |
2479 CPDF_Stream* pStream; | 2479 CPDF_Stream* pStream; |
2480 FX_LPBYTE pData = FX_Alloc(uint8_t, len); | 2480 uint8_t* pData = FX_Alloc(uint8_t, len); |
2481 ReadBlock(pData, len); | 2481 ReadBlock(pData, len); |
2482 if (pCryptoHandler) { | 2482 if (pCryptoHandler) { |
2483 CFX_BinaryBuf dest_buf; | 2483 CFX_BinaryBuf dest_buf; |
2484 dest_buf.EstimateSize(pCryptoHandler->DecryptGetSize(len)); | 2484 dest_buf.EstimateSize(pCryptoHandler->DecryptGetSize(len)); |
2485 FX_LPVOID context = pCryptoHandler->DecryptStart(objnum, gennum); | 2485 void* context = pCryptoHandler->DecryptStart(objnum, gennum); |
2486 pCryptoHandler->DecryptStream(context, pData, len, dest_buf); | 2486 pCryptoHandler->DecryptStream(context, pData, len, dest_buf); |
2487 pCryptoHandler->DecryptFinish(context, dest_buf); | 2487 pCryptoHandler->DecryptFinish(context, dest_buf); |
2488 FX_Free(pData); | 2488 FX_Free(pData); |
2489 pData = dest_buf.GetBuffer(); | 2489 pData = dest_buf.GetBuffer(); |
2490 len = dest_buf.GetSize(); | 2490 len = dest_buf.GetSize(); |
2491 dest_buf.DetachBuffer(); | 2491 dest_buf.DetachBuffer(); |
2492 } | 2492 } |
2493 pStream = new CPDF_Stream(pData, len, pDict); | 2493 pStream = new CPDF_Stream(pData, len, pDict); |
2494 if (pContext) { | 2494 if (pContext) { |
2495 pContext->m_DataEnd = pContext->m_DataStart + len; | 2495 pContext->m_DataEnd = pContext->m_DataStart + len; |
(...skipping 19 matching lines...) Expand all Loading... |
2515 m_BufOffset = 0; | 2515 m_BufOffset = 0; |
2516 pFileAccess->ReadBlock(m_pFileBuf, 0, (size_t)((FX_FILESIZE)m_BufSize > m_Fi
leLen ? m_FileLen : m_BufSize)); | 2516 pFileAccess->ReadBlock(m_pFileBuf, 0, (size_t)((FX_FILESIZE)m_BufSize > m_Fi
leLen ? m_FileLen : m_BufSize)); |
2517 } | 2517 } |
2518 int32_t CPDF_SyntaxParser::GetDirectNum() | 2518 int32_t CPDF_SyntaxParser::GetDirectNum() |
2519 { | 2519 { |
2520 GetNextWord(); | 2520 GetNextWord(); |
2521 if (!m_bIsNumber) { | 2521 if (!m_bIsNumber) { |
2522 return 0; | 2522 return 0; |
2523 } | 2523 } |
2524 m_WordBuffer[m_WordSize] = 0; | 2524 m_WordBuffer[m_WordSize] = 0; |
2525 return FXSYS_atoi((FX_LPCSTR)m_WordBuffer); | 2525 return FXSYS_atoi((const FX_CHAR*)m_WordBuffer); |
2526 } | 2526 } |
2527 FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit,
FX_LPCBYTE tag, FX_DWORD taglen) | 2527 FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit,
const uint8_t* tag, FX_DWORD taglen) |
2528 { | 2528 { |
2529 uint8_t type = PDF_CharType[tag[0]]; | 2529 uint8_t type = PDF_CharType[tag[0]]; |
2530 FX_BOOL bCheckLeft = type != 'D' && type != 'W'; | 2530 FX_BOOL bCheckLeft = type != 'D' && type != 'W'; |
2531 type = PDF_CharType[tag[taglen - 1]]; | 2531 type = PDF_CharType[tag[taglen - 1]]; |
2532 FX_BOOL bCheckRight = type != 'D' && type != 'W'; | 2532 FX_BOOL bCheckRight = type != 'D' && type != 'W'; |
2533 uint8_t ch; | 2533 uint8_t ch; |
2534 if (bCheckRight && startpos + (int32_t)taglen <= limit && GetCharAt(startpos
+ (int32_t)taglen, ch)) { | 2534 if (bCheckRight && startpos + (int32_t)taglen <= limit && GetCharAt(startpos
+ (int32_t)taglen, ch)) { |
2535 uint8_t type = PDF_CharType[ch]; | 2535 uint8_t type = PDF_CharType[ch]; |
2536 if (type == 'N' || type == 'R') { | 2536 if (type == 'N' || type == 'R') { |
2537 return FALSE; | 2537 return FALSE; |
(...skipping 11 matching lines...) Expand all Loading... |
2549 { | 2549 { |
2550 int32_t taglen = tag.GetLength(); | 2550 int32_t taglen = tag.GetLength(); |
2551 if (taglen == 0) { | 2551 if (taglen == 0) { |
2552 return FALSE; | 2552 return FALSE; |
2553 } | 2553 } |
2554 FX_FILESIZE pos = m_Pos; | 2554 FX_FILESIZE pos = m_Pos; |
2555 int32_t offset = 0; | 2555 int32_t offset = 0; |
2556 if (!bForward) { | 2556 if (!bForward) { |
2557 offset = taglen - 1; | 2557 offset = taglen - 1; |
2558 } | 2558 } |
2559 FX_LPCBYTE tag_data = tag.GetPtr(); | 2559 const uint8_t* tag_data = tag.GetPtr(); |
2560 uint8_t byte; | 2560 uint8_t byte; |
2561 while (1) { | 2561 while (1) { |
2562 if (bForward) { | 2562 if (bForward) { |
2563 if (limit) { | 2563 if (limit) { |
2564 if (pos >= m_Pos + limit) { | 2564 if (pos >= m_Pos + limit) { |
2565 return FALSE; | 2565 return FALSE; |
2566 } | 2566 } |
2567 } | 2567 } |
2568 if (!GetCharAt(pos, byte)) { | 2568 if (!GetCharAt(pos, byte)) { |
2569 return FALSE; | 2569 return FALSE; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2605 offset = byte == tag_data[taglen - 1] ? taglen - 2 : taglen - 1; | 2605 offset = byte == tag_data[taglen - 1] ? taglen - 2 : taglen - 1; |
2606 pos --; | 2606 pos --; |
2607 } | 2607 } |
2608 if (pos < 0) { | 2608 if (pos < 0) { |
2609 return FALSE; | 2609 return FALSE; |
2610 } | 2610 } |
2611 } | 2611 } |
2612 return FALSE; | 2612 return FALSE; |
2613 } | 2613 } |
2614 struct _SearchTagRecord { | 2614 struct _SearchTagRecord { |
2615 FX_LPCBYTE» m_pTag; | 2615 const uint8_t*» m_pTag; |
2616 FX_DWORD m_Len; | 2616 FX_DWORD m_Len; |
2617 FX_DWORD m_Offset; | 2617 FX_DWORD m_Offset; |
2618 }; | 2618 }; |
2619 int32_t CPDF_SyntaxParser::SearchMultiWord(FX_BSTR tags, FX_BOOL bWholeWord, FX_
FILESIZE limit) | 2619 int32_t CPDF_SyntaxParser::SearchMultiWord(FX_BSTR tags, FX_BOOL bWholeWord, FX_
FILESIZE limit) |
2620 { | 2620 { |
2621 int32_t ntags = 1, i; | 2621 int32_t ntags = 1, i; |
2622 for (i = 0; i < tags.GetLength(); i ++) | 2622 for (i = 0; i < tags.GetLength(); i ++) |
2623 if (tags[i] == 0) { | 2623 if (tags[i] == 0) { |
2624 ntags ++; | 2624 ntags ++; |
2625 } | 2625 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2760 FX_BOOL CheckPage(IFX_DownloadHints* pHints); | 2760 FX_BOOL CheckPage(IFX_DownloadHints* pHints); |
2761 FX_BOOL CheckResources(IFX_DownloadHints* pHints
); | 2761 FX_BOOL CheckResources(IFX_DownloadHints* pHints
); |
2762 FX_BOOL CheckAnnots(IFX_DownloadHints* pHints); | 2762 FX_BOOL CheckAnnots(IFX_DownloadHints* pHints); |
2763 FX_BOOL CheckAcroForm(IFX_DownloadHints* pHints)
; | 2763 FX_BOOL CheckAcroForm(IFX_DownloadHints* pHints)
; |
2764 FX_BOOL CheckAcroFormSubObject(IFX_DownloadHints
* pHints); | 2764 FX_BOOL CheckAcroFormSubObject(IFX_DownloadHints
* pHints); |
2765 FX_BOOL CheckTrailerAppend(IFX_DownloadHints* pH
ints); | 2765 FX_BOOL CheckTrailerAppend(IFX_DownloadHints* pH
ints); |
2766 FX_BOOL CheckPageStatus(IFX_DownloadHints* pHint
s); | 2766 FX_BOOL CheckPageStatus(IFX_DownloadHints* pHint
s); |
2767 FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints
*pHints); | 2767 FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints
*pHints); |
2768 | 2768 |
2769 int32_t CheckCrossRefStream(IFX_DownloadHints *pH
ints, FX_FILESIZE &xref_offset); | 2769 int32_t CheckCrossRefStream(IFX_DownloadHints *pH
ints, FX_FILESIZE &xref_offset); |
2770 FX_BOOL IsLinearizedFile(FX_LPBYTE pData, FX_DWO
RD dwLen); | 2770 FX_BOOL IsLinearizedFile(uint8_t* pData, FX_DWOR
D dwLen); |
2771 void SetStartOffset(FX_FILESIZE dwOffset); | 2771 void SetStartOffset(FX_FILESIZE dwOffset); |
2772 FX_BOOL GetNextToken(CFX_ByteString &token); | 2772 FX_BOOL GetNextToken(CFX_ByteString &token); |
2773 FX_BOOL GetNextChar(uint8_t &ch); | 2773 FX_BOOL GetNextChar(uint8_t &ch); |
2774 CPDF_Object * ParseIndirectObjectAt(FX_FILESIZE pos, F
X_DWORD objnum); | 2774 CPDF_Object * ParseIndirectObjectAt(FX_FILESIZE pos, F
X_DWORD objnum); |
2775 CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadH
ints* pHints, FX_BOOL *pExistInFile); | 2775 CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadH
ints* pHints, FX_BOOL *pExistInFile); |
2776 FX_BOOL GetPageKids(CPDF_Parser *pParser, CPDF_O
bject *pPages); | 2776 FX_BOOL GetPageKids(CPDF_Parser *pParser, CPDF_O
bject *pPages); |
2777 FX_BOOL PreparePageItem(); | 2777 FX_BOOL PreparePageItem(); |
2778 FX_BOOL LoadPages(IFX_DownloadHints* pHints); | 2778 FX_BOOL LoadPages(IFX_DownloadHints* pHints); |
2779 FX_BOOL LoadAllXref(IFX_DownloadHints* pHints); | 2779 FX_BOOL LoadAllXref(IFX_DownloadHints* pHints); |
2780 FX_BOOL LoadAllFile(IFX_DownloadHints* pHints); | 2780 FX_BOOL LoadAllFile(IFX_DownloadHints* pHints); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3010 return 0; | 3010 return 0; |
3011 } | 3011 } |
3012 if (pParser->m_V5Type[objnum] == 2) { | 3012 if (pParser->m_V5Type[objnum] == 2) { |
3013 objnum = (FX_DWORD)pParser->m_CrossRef[objnum]; | 3013 objnum = (FX_DWORD)pParser->m_CrossRef[objnum]; |
3014 } | 3014 } |
3015 if (pParser->m_V5Type[objnum] == 1 || pParser->m_V5Type[objnum] == 255) { | 3015 if (pParser->m_V5Type[objnum] == 1 || pParser->m_V5Type[objnum] == 255) { |
3016 offset = pParser->m_CrossRef[objnum]; | 3016 offset = pParser->m_CrossRef[objnum]; |
3017 if (offset == 0) { | 3017 if (offset == 0) { |
3018 return 0; | 3018 return 0; |
3019 } | 3019 } |
3020 FX_LPVOID pResult = FXSYS_bsearch(&offset, pParser->m_SortedOffset.GetDa
ta(), pParser->m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); | 3020 void* pResult = FXSYS_bsearch(&offset, pParser->m_SortedOffset.GetData()
, pParser->m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); |
3021 if (pResult == NULL) { | 3021 if (pResult == NULL) { |
3022 return 0; | 3022 return 0; |
3023 } | 3023 } |
3024 if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)pParser->m_SortedOffset.GetDat
a() == pParser->m_SortedOffset.GetSize() - 1) { | 3024 if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)pParser->m_SortedOffset.GetDat
a() == pParser->m_SortedOffset.GetSize() - 1) { |
3025 return 0; | 3025 return 0; |
3026 } | 3026 } |
3027 return (FX_DWORD)(((FX_FILESIZE*)pResult)[1] - offset); | 3027 return (FX_DWORD)(((FX_FILESIZE*)pResult)[1] - offset); |
3028 } | 3028 } |
3029 return 0; | 3029 return 0; |
3030 } | 3030 } |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3699 if (dwSize < (FX_FILESIZE)req_size) { | 3699 if (dwSize < (FX_FILESIZE)req_size) { |
3700 return PDF_UNKNOW_LINEARIZED; | 3700 return PDF_UNKNOW_LINEARIZED; |
3701 } | 3701 } |
3702 uint8_t buffer[1024]; | 3702 uint8_t buffer[1024]; |
3703 m_pFileRead->ReadBlock(buffer, 0, req_size); | 3703 m_pFileRead->ReadBlock(buffer, 0, req_size); |
3704 if (IsLinearizedFile(buffer, req_size)) { | 3704 if (IsLinearizedFile(buffer, req_size)) { |
3705 return PDF_IS_LINEARIZED; | 3705 return PDF_IS_LINEARIZED; |
3706 } | 3706 } |
3707 return PDF_NOT_LINEARIZED; | 3707 return PDF_NOT_LINEARIZED; |
3708 } | 3708 } |
3709 FX_BOOL CPDF_DataAvail::IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen) | 3709 FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) |
3710 { | 3710 { |
3711 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pData, (size_t)d
wLen, FALSE)); | 3711 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pData, (size_t)d
wLen, FALSE)); |
3712 int32_t offset = GetHeaderOffset(file.Get()); | 3712 int32_t offset = GetHeaderOffset(file.Get()); |
3713 if (offset == -1) { | 3713 if (offset == -1) { |
3714 m_docStatus = PDF_DATAAVAIL_ERROR; | 3714 m_docStatus = PDF_DATAAVAIL_ERROR; |
3715 return FALSE; | 3715 return FALSE; |
3716 } | 3716 } |
3717 m_dwHeaderOffset = offset; | 3717 m_dwHeaderOffset = offset; |
3718 m_syntaxParser.InitParser(file.Get(), offset); | 3718 m_syntaxParser.InitParser(file.Get(), offset); |
3719 m_syntaxParser.RestorePos(m_syntaxParser.m_HeaderOffset + 9); | 3719 m_syntaxParser.RestorePos(m_syntaxParser.m_HeaderOffset + 9); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3783 pHints->AddSegment(req_pos, dwSize); | 3783 pHints->AddSegment(req_pos, dwSize); |
3784 return FALSE; | 3784 return FALSE; |
3785 } | 3785 } |
3786 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI
ZE &xref_offset) | 3786 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI
ZE &xref_offset) |
3787 { | 3787 { |
3788 xref_offset = 0; | 3788 xref_offset = 0; |
3789 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P
os : 512); | 3789 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P
os : 512); |
3790 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { | 3790 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { |
3791 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); | 3791 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); |
3792 CFX_BinaryBuf buf(iSize); | 3792 CFX_BinaryBuf buf(iSize); |
3793 FX_LPBYTE pBuf = buf.GetBuffer(); | 3793 uint8_t* pBuf = buf.GetBuffer(); |
3794 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); | 3794 m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); |
3795 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_
t)iSize, FALSE)); | 3795 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_
t)iSize, FALSE)); |
3796 m_parser.m_Syntax.InitParser(file.Get(), 0); | 3796 m_parser.m_Syntax.InitParser(file.Get(), 0); |
3797 FX_BOOL bNumber = FALSE; | 3797 FX_BOOL bNumber = FALSE; |
3798 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber); | 3798 CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber); |
3799 if (!bNumber) { | 3799 if (!bNumber) { |
3800 return -1; | 3800 return -1; |
3801 } | 3801 } |
3802 FX_DWORD objNum = FXSYS_atoi(objnum); | 3802 FX_DWORD objNum = FXSYS_atoi(objnum); |
3803 CPDF_Object *pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL
); | 3803 CPDF_Object *pObj = m_parser.ParseIndirectObjectAt(NULL, 0, objNum, NULL
); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4021 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; | 4021 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; |
4022 } | 4022 } |
4023 return TRUE; | 4023 return TRUE; |
4024 } | 4024 } |
4025 FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) | 4025 FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) |
4026 { | 4026 { |
4027 int32_t iTrailerSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m
_Pos : 512); | 4027 int32_t iTrailerSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m
_Pos : 512); |
4028 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { | 4028 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { |
4029 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); | 4029 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); |
4030 CFX_BinaryBuf buf(iSize); | 4030 CFX_BinaryBuf buf(iSize); |
4031 FX_LPBYTE pBuf = buf.GetBuffer(); | 4031 uint8_t* pBuf = buf.GetBuffer(); |
4032 if (!pBuf) { | 4032 if (!pBuf) { |
4033 m_docStatus = PDF_DATAAVAIL_ERROR; | 4033 m_docStatus = PDF_DATAAVAIL_ERROR; |
4034 return FALSE; | 4034 return FALSE; |
4035 } | 4035 } |
4036 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { | 4036 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { |
4037 return FALSE; | 4037 return FALSE; |
4038 } | 4038 } |
4039 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_
t)iSize, FALSE)); | 4039 CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_
t)iSize, FALSE)); |
4040 m_syntaxParser.InitParser(file.Get(), 0); | 4040 m_syntaxParser.InitParser(file.Get(), 0); |
4041 CPDF_Object *pTrailer = m_syntaxParser.GetObject(NULL, 0, 0, 0); | 4041 CPDF_Object *pTrailer = m_syntaxParser.GetObject(NULL, 0, 0, 0); |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4640 { | 4640 { |
4641 int32_t iSize = m_childNode.GetSize(); | 4641 int32_t iSize = m_childNode.GetSize(); |
4642 for (int32_t i = 0; i < iSize; ++i) { | 4642 for (int32_t i = 0; i < iSize; ++i) { |
4643 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; | 4643 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; |
4644 if (pNode) { | 4644 if (pNode) { |
4645 delete pNode; | 4645 delete pNode; |
4646 } | 4646 } |
4647 } | 4647 } |
4648 m_childNode.RemoveAll(); | 4648 m_childNode.RemoveAll(); |
4649 } | 4649 } |
OLD | NEW |