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_syntax_parser.h" | 7 #include "core/fpdfapi/parser/cpdf_syntax_parser.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 if (word == "<") { | 407 if (word == "<") { |
408 CFX_ByteString str = ReadHexString(); | 408 CFX_ByteString str = ReadHexString(); |
409 if (m_pCryptoHandler && bDecrypt) | 409 if (m_pCryptoHandler && bDecrypt) |
410 m_pCryptoHandler->Decrypt(objnum, gennum, str); | 410 m_pCryptoHandler->Decrypt(objnum, gennum, str); |
411 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), true); | 411 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), true); |
412 } | 412 } |
413 if (word == "[") { | 413 if (word == "[") { |
414 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); | 414 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); |
415 while (std::unique_ptr<CPDF_Object> pObj = | 415 while (std::unique_ptr<CPDF_Object> pObj = |
416 GetObject(pObjList, objnum, gennum, true)) { | 416 GetObject(pObjList, objnum, gennum, true)) { |
417 pArray->Add(pObj.release()); | 417 pArray->Add(std::move(pObj)); |
418 } | 418 } |
419 return std::move(pArray); | 419 return std::move(pArray); |
420 } | 420 } |
421 if (word[0] == '/') { | 421 if (word[0] == '/') { |
422 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern( | 422 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern( |
423 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); | 423 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); |
424 } | 424 } |
425 if (word == "<<") { | 425 if (word == "<<") { |
426 int32_t nKeys = 0; | 426 int32_t nKeys = 0; |
427 FX_FILESIZE dwSignValuePos = 0; | 427 FX_FILESIZE dwSignValuePos = 0; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 if (word == "<") { | 527 if (word == "<") { |
528 CFX_ByteString str = ReadHexString(); | 528 CFX_ByteString str = ReadHexString(); |
529 if (m_pCryptoHandler) | 529 if (m_pCryptoHandler) |
530 m_pCryptoHandler->Decrypt(objnum, gennum, str); | 530 m_pCryptoHandler->Decrypt(objnum, gennum, str); |
531 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), true); | 531 return pdfium::MakeUnique<CPDF_String>(MaybeIntern(str), true); |
532 } | 532 } |
533 if (word == "[") { | 533 if (word == "[") { |
534 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); | 534 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); |
535 while (std::unique_ptr<CPDF_Object> pObj = | 535 while (std::unique_ptr<CPDF_Object> pObj = |
536 GetObject(pObjList, objnum, gennum, true)) { | 536 GetObject(pObjList, objnum, gennum, true)) { |
537 pArray->Add(pObj.release()); | 537 pArray->Add(std::move(pObj)); |
538 } | 538 } |
539 return m_WordBuffer[0] == ']' ? std::move(pArray) : nullptr; | 539 return m_WordBuffer[0] == ']' ? std::move(pArray) : nullptr; |
540 } | 540 } |
541 if (word[0] == '/') { | 541 if (word[0] == '/') { |
542 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern( | 542 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern( |
543 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); | 543 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); |
544 } | 544 } |
545 if (word == "<<") { | 545 if (word == "<<") { |
546 std::unique_ptr<CPDF_Dictionary> pDict = | 546 std::unique_ptr<CPDF_Dictionary> pDict = |
547 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool); | 547 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 } | 913 } |
914 | 914 |
915 void CPDF_SyntaxParser::SetEncrypt( | 915 void CPDF_SyntaxParser::SetEncrypt( |
916 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { | 916 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { |
917 m_pCryptoHandler = std::move(pCryptoHandler); | 917 m_pCryptoHandler = std::move(pCryptoHandler); |
918 } | 918 } |
919 | 919 |
920 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { | 920 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { |
921 return m_pPool ? m_pPool->Intern(str) : str; | 921 return m_pPool ? m_pPool->Intern(str) : str; |
922 } | 922 } |
OLD | NEW |