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/fxcodec/fx_codec.h" | 7 #include "../../core/include/fxcodec/fx_codec.h" |
8 #include "../../core/include/fxcrt/fx_safe_types.h" | 8 #include "../../core/include/fxcrt/fx_safe_types.h" |
9 #include "../../public/fpdf_ext.h" | 9 #include "../../public/fpdf_ext.h" |
10 #include "../../public/fpdf_progressive.h" | 10 #include "../../public/fpdf_progressive.h" |
11 #include "../../public/fpdfview.h" | 11 #include "../../public/fpdfview.h" |
12 #include "../../third_party/base/nonstd_unique_ptr.h" | 12 #include "../../third_party/base/nonstd_unique_ptr.h" |
13 #include "../../third_party/base/numerics/safe_conversions_impl.h" | 13 #include "../../third_party/base/numerics/safe_conversions_impl.h" |
14 #include "../include/fsdk_define.h" | 14 #include "../include/fsdk_define.h" |
15 #include "../include/fsdk_mgr.h" | 15 #include "../include/fsdk_mgr.h" |
16 #include "../include/fsdk_rendercontext.h" | 16 #include "../include/fsdk_rendercontext.h" |
17 #include "../include/javascript/IJavaScript.h" | 17 #include "../include/javascript/IJavaScript.h" |
18 | 18 |
19 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { | 19 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { |
20 return static_cast<CPDF_Document*>(doc); | 20 return static_cast<CPDF_Document*>(doc); |
21 } | 21 } |
22 | 22 |
| 23 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { |
| 24 return static_cast<FPDF_DOCUMENT>(doc); |
| 25 } |
| 26 |
23 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { | 27 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { |
24 return static_cast<CPDF_Page*>(page); | 28 return static_cast<CPDF_Page*>(page); |
25 } | 29 } |
26 | 30 |
27 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) { | 31 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) { |
28 if (pFileAccess) | 32 if (pFileAccess) |
29 m_FileAccess = *pFileAccess; | 33 m_FileAccess = *pFileAccess; |
30 } | 34 } |
31 | 35 |
32 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, | 36 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); | 201 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); |
198 FX_DWORD err_code = pParser->StartParse(pMemFile); | 202 FX_DWORD err_code = pParser->StartParse(pMemFile); |
199 if (err_code) { | 203 if (err_code) { |
200 delete pParser; | 204 delete pParser; |
201 ProcessParseError(err_code); | 205 ProcessParseError(err_code); |
202 return NULL; | 206 return NULL; |
203 } | 207 } |
204 CPDF_Document* pDoc = NULL; | 208 CPDF_Document* pDoc = NULL; |
205 pDoc = pParser ? pParser->GetDocument() : NULL; | 209 pDoc = pParser ? pParser->GetDocument() : NULL; |
206 CheckUnSupportError(pDoc, err_code); | 210 CheckUnSupportError(pDoc, err_code); |
207 return pParser->GetDocument(); | 211 return FPDFDocumentFromCPDFDocument(pParser->GetDocument()); |
208 } | 212 } |
209 | 213 |
210 DLLEXPORT FPDF_DOCUMENT STDCALL | 214 DLLEXPORT FPDF_DOCUMENT STDCALL |
211 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, | 215 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, |
212 FPDF_BYTESTRING password) { | 216 FPDF_BYTESTRING password) { |
213 CPDF_Parser* pParser = new CPDF_Parser; | 217 CPDF_Parser* pParser = new CPDF_Parser; |
214 pParser->SetPassword(password); | 218 pParser->SetPassword(password); |
215 CPDF_CustomAccess* pFile = new CPDF_CustomAccess(pFileAccess); | 219 CPDF_CustomAccess* pFile = new CPDF_CustomAccess(pFileAccess); |
216 FX_DWORD err_code = pParser->StartParse(pFile); | 220 FX_DWORD err_code = pParser->StartParse(pFile); |
217 if (err_code) { | 221 if (err_code) { |
218 delete pParser; | 222 delete pParser; |
219 ProcessParseError(err_code); | 223 ProcessParseError(err_code); |
220 return NULL; | 224 return NULL; |
221 } | 225 } |
222 CPDF_Document* pDoc = NULL; | 226 CPDF_Document* pDoc = NULL; |
223 pDoc = pParser ? pParser->GetDocument() : NULL; | 227 pDoc = pParser ? pParser->GetDocument() : NULL; |
224 CheckUnSupportError(pDoc, err_code); | 228 CheckUnSupportError(pDoc, err_code); |
225 return pParser->GetDocument(); | 229 return FPDFDocumentFromCPDFDocument(pParser->GetDocument()); |
226 } | 230 } |
227 | 231 |
228 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, | 232 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, |
229 int* fileVersion) { | 233 int* fileVersion) { |
230 if (!fileVersion) | 234 if (!fileVersion) |
231 return FALSE; | 235 return FALSE; |
232 | 236 |
233 *fileVersion = 0; | 237 *fileVersion = 0; |
234 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); | 238 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); |
235 if (!pDoc) | 239 if (!pDoc) |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 if (!buffer) { | 899 if (!buffer) { |
896 *buflen = len; | 900 *buflen = len; |
897 } else if (*buflen >= len) { | 901 } else if (*buflen >= len) { |
898 memcpy(buffer, utf16Name.c_str(), len); | 902 memcpy(buffer, utf16Name.c_str(), len); |
899 *buflen = len; | 903 *buflen = len; |
900 } else { | 904 } else { |
901 *buflen = -1; | 905 *buflen = -1; |
902 } | 906 } |
903 return (FPDF_DEST)pDestObj; | 907 return (FPDF_DEST)pDestObj; |
904 } | 908 } |
OLD | NEW |