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 "core/fpdfapi/edit/cpdf_creator.h" | 9 #include "core/fpdfapi/edit/cpdf_creator.h" |
10 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 10 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) { | 51 void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) { |
52 m_pFile = pFile; | 52 m_pFile = pFile; |
53 m_bOwnFile = bOwnFile; | 53 m_bOwnFile = bOwnFile; |
54 CPDF_SyntaxParser parser; | 54 CPDF_SyntaxParser parser; |
55 parser.InitParser(m_pFile, 0); | 55 parser.InitParser(m_pFile, 0); |
56 while (1) { | 56 while (1) { |
57 bool bNumber; | 57 bool bNumber; |
58 CFX_ByteString word = parser.GetNextWord(&bNumber); | 58 CFX_ByteString word = parser.GetNextWord(&bNumber); |
59 if (bNumber) { | 59 if (bNumber) { |
60 uint32_t objnum = FXSYS_atoui(word.c_str()); | 60 uint32_t objnum = FXSYS_atoui(word.c_str()); |
| 61 if (!objnum) |
| 62 break; |
| 63 |
61 word = parser.GetNextWord(&bNumber); | 64 word = parser.GetNextWord(&bNumber); |
62 if (!bNumber) | 65 if (!bNumber) |
63 break; | 66 break; |
64 | 67 |
65 word = parser.GetNextWord(nullptr); | 68 word = parser.GetNextWord(nullptr); |
66 if (word != "obj") | 69 if (word != "obj") |
67 break; | 70 break; |
68 | 71 |
69 CPDF_Object* pObj = parser.GetObject(this, objnum, 0, true); | 72 CPDF_Object* pObj = parser.GetObject(this, objnum, 0, true); |
70 if (!pObj) | 73 if (!pObj) |
(...skipping 23 matching lines...) Expand all Loading... |
94 | 97 |
95 buf << "%FDF-1.2\r\n"; | 98 buf << "%FDF-1.2\r\n"; |
96 for (const auto& pair : *this) | 99 for (const auto& pair : *this) |
97 buf << pair.first << " 0 obj\r\n" | 100 buf << pair.first << " 0 obj\r\n" |
98 << pair.second.get() << "\r\nendobj\r\n\r\n"; | 101 << pair.second.get() << "\r\nendobj\r\n\r\n"; |
99 | 102 |
100 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() | 103 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() |
101 << " 0 R>>\r\n%%EOF\r\n"; | 104 << " 0 R>>\r\n%%EOF\r\n"; |
102 return true; | 105 return true; |
103 } | 106 } |
OLD | NEW |