| 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 "core/fpdfapi/parser/cfdf_document.h" | 7 #include "core/fpdfapi/parser/cfdf_document.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 if (!pFile) | 38 if (!pFile) |
| 39 return nullptr; | 39 return nullptr; |
| 40 | 40 |
| 41 auto pDoc = pdfium::MakeUnique<CFDF_Document>(); | 41 auto pDoc = pdfium::MakeUnique<CFDF_Document>(); |
| 42 pDoc->ParseStream(pFile, bOwnFile); | 42 pDoc->ParseStream(pFile, bOwnFile); |
| 43 return pDoc->m_pRootDict ? std::move(pDoc) : nullptr; | 43 return pDoc->m_pRootDict ? std::move(pDoc) : nullptr; |
| 44 } | 44 } |
| 45 | 45 |
| 46 std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(const uint8_t* pData, | 46 std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(const uint8_t* pData, |
| 47 uint32_t size) { | 47 uint32_t size) { |
| 48 return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size), | 48 return CFDF_Document::ParseFile( |
| 49 true); | 49 IFX_MemoryStream::Create((uint8_t*)pData, size), true); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) { | 52 void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) { |
| 53 m_pFile = pFile; | 53 m_pFile = pFile; |
| 54 m_bOwnFile = bOwnFile; | 54 m_bOwnFile = bOwnFile; |
| 55 CPDF_SyntaxParser parser; | 55 CPDF_SyntaxParser parser; |
| 56 parser.InitParser(m_pFile, 0); | 56 parser.InitParser(m_pFile, 0); |
| 57 while (1) { | 57 while (1) { |
| 58 bool bNumber; | 58 bool bNumber; |
| 59 CFX_ByteString word = parser.GetNextWord(&bNumber); | 59 CFX_ByteString word = parser.GetNextWord(&bNumber); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 buf << "%FDF-1.2\r\n"; | 100 buf << "%FDF-1.2\r\n"; |
| 101 for (const auto& pair : *this) | 101 for (const auto& pair : *this) |
| 102 buf << pair.first << " 0 obj\r\n" | 102 buf << pair.first << " 0 obj\r\n" |
| 103 << pair.second.get() << "\r\nendobj\r\n\r\n"; | 103 << pair.second.get() << "\r\nendobj\r\n\r\n"; |
| 104 | 104 |
| 105 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() | 105 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() |
| 106 << " 0 R>>\r\n%%EOF\r\n"; | 106 << " 0 R>>\r\n%%EOF\r\n"; |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| OLD | NEW |