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/include/fpdfapi/fpdf_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
8 | 8 |
9 #include "core/include/fpdfapi/fpdf_serial.h" | 9 #include "core/include/fpdfapi/fpdf_serial.h" |
10 | 10 |
11 CFDF_Document::CFDF_Document() : CPDF_IndirectObjects(NULL) { | 11 CFDF_Document::CFDF_Document() : CPDF_IndirectObjectHolder(NULL) { |
12 m_pRootDict = NULL; | 12 m_pRootDict = NULL; |
13 m_pFile = NULL; | 13 m_pFile = NULL; |
14 m_bOwnFile = FALSE; | 14 m_bOwnFile = FALSE; |
15 } | 15 } |
16 CFDF_Document::~CFDF_Document() { | 16 CFDF_Document::~CFDF_Document() { |
17 if (m_bOwnFile && m_pFile) { | 17 if (m_bOwnFile && m_pFile) { |
18 m_pFile->Release(); | 18 m_pFile->Release(); |
19 } | 19 } |
20 } | 20 } |
21 CFDF_Document* CFDF_Document::CreateNewDoc() { | 21 CFDF_Document* CFDF_Document::CreateNewDoc() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 break; | 81 break; |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const { | 85 FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const { |
86 if (!m_pRootDict) { | 86 if (!m_pRootDict) { |
87 return FALSE; | 87 return FALSE; |
88 } | 88 } |
89 buf << "%FDF-1.2\r\n"; | 89 buf << "%FDF-1.2\r\n"; |
90 FX_POSITION pos = m_IndirectObjs.GetStartPosition(); | 90 for (const auto& pair : m_IndirectObjs) { |
91 while (pos) { | 91 buf << pair.first << " 0 obj\r\n" << pair.second << "\r\nendobj\r\n\r\n"; |
92 size_t objnum; | |
93 CPDF_Object* pObj; | |
94 m_IndirectObjs.GetNextAssoc(pos, (void*&)objnum, (void*&)pObj); | |
95 buf << (FX_DWORD)objnum << " 0 obj\r\n" << pObj << "\r\nendobj\r\n\r\n"; | |
96 } | 92 } |
97 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() | 93 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() |
98 << " 0 R>>\r\n%%EOF\r\n"; | 94 << " 0 R>>\r\n%%EOF\r\n"; |
99 return TRUE; | 95 return TRUE; |
100 } | 96 } |
101 CFX_WideString CFDF_Document::GetWin32Path() const { | 97 CFX_WideString CFDF_Document::GetWin32Path() const { |
102 CPDF_Dictionary* pDict = m_pRootDict ? m_pRootDict->GetDict("FDF") : NULL; | 98 CPDF_Dictionary* pDict = m_pRootDict ? m_pRootDict->GetDict("FDF") : NULL; |
103 CPDF_Object* pFileSpec = pDict ? pDict->GetElementValue("F") : NULL; | 99 CPDF_Object* pFileSpec = pDict ? pDict->GetElementValue("F") : NULL; |
104 if (!pFileSpec) | 100 if (!pFileSpec) |
105 return CFX_WideString(); | 101 return CFX_WideString(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 result += wsFileName[1]; | 168 result += wsFileName[1]; |
173 result += ':'; | 169 result += ':'; |
174 result += ChangeSlash(wsFileName.c_str() + 2); | 170 result += ChangeSlash(wsFileName.c_str() + 2); |
175 return result; | 171 return result; |
176 } | 172 } |
177 CFX_WideString result; | 173 CFX_WideString result; |
178 result += '\\'; | 174 result += '\\'; |
179 result += ChangeSlash(wsFileName.c_str()); | 175 result += ChangeSlash(wsFileName.c_str()); |
180 return result; | 176 return result; |
181 } | 177 } |
OLD | NEW |