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_module.h" | 7 #include "../../core/include/fpdfapi/fpdf_module.h" |
8 #include "../../core/include/fxcodec/fx_codec.h" | 8 #include "../../core/include/fxcodec/fx_codec.h" |
9 #include "../../core/include/fxcrt/fx_safe_types.h" | 9 #include "../../core/include/fxcrt/fx_safe_types.h" |
10 #include "../../public/fpdf_ext.h" | 10 #include "../../public/fpdf_ext.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 break; | 230 break; |
231 } | 231 } |
232 SetLastError(err_code); | 232 SetLastError(err_code); |
233 } | 233 } |
234 | 234 |
235 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, | 235 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, |
236 FPDF_BOOL enable) { | 236 FPDF_BOOL enable) { |
237 return FSDK_SetSandBoxPolicy(policy, enable); | 237 return FSDK_SetSandBoxPolicy(policy, enable); |
238 } | 238 } |
239 | 239 |
| 240 |
240 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, | 241 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, |
241 FPDF_BYTESTRING password) { | 242 FPDF_BYTESTRING password) { |
242 CPDF_Parser* pParser = FX_NEW CPDF_Parser; | 243 // NOTE: the creation of the file needs to be by the embedder on the |
| 244 // other side of this API. |
| 245 IFX_FileRead* pFileAccess = FX_CreateFileRead((const FX_CHAR*)file_path); |
| 246 if (!pFileAccess) { |
| 247 return nullptr; |
| 248 } |
| 249 |
| 250 CPDF_Parser* pParser = new CPDF_Parser; |
243 pParser->SetPassword(password); | 251 pParser->SetPassword(password); |
244 | 252 |
245 FX_DWORD err_code = pParser->StartParse((const FX_CHAR*)file_path); | 253 FX_DWORD err_code = pParser->StartParse(pFileAccess); |
246 if (err_code) { | 254 if (err_code) { |
247 delete pParser; | 255 delete pParser; |
248 ProcessParseError(err_code); | 256 ProcessParseError(err_code); |
249 return NULL; | 257 return NULL; |
250 } | 258 } |
251 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 259 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
252 if (!pPDFDoc) | 260 if (!pPDFDoc) |
253 return NULL; | 261 return NULL; |
254 | 262 |
255 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); | 263 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 if (!buffer) { | 1093 if (!buffer) { |
1086 *buflen = len; | 1094 *buflen = len; |
1087 } else if (*buflen >= len) { | 1095 } else if (*buflen >= len) { |
1088 memcpy(buffer, utf16Name.c_str(), len); | 1096 memcpy(buffer, utf16Name.c_str(), len); |
1089 *buflen = len; | 1097 *buflen = len; |
1090 } else { | 1098 } else { |
1091 *buflen = -1; | 1099 *buflen = -1; |
1092 } | 1100 } |
1093 return (FPDF_DEST)pDestObj; | 1101 return (FPDF_DEST)pDestObj; |
1094 } | 1102 } |
OLD | NEW |