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" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 break; | 148 break; |
149 } | 149 } |
150 SetLastError(err_code); | 150 SetLastError(err_code); |
151 } | 151 } |
152 | 152 |
153 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, | 153 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, |
154 FPDF_BOOL enable) { | 154 FPDF_BOOL enable) { |
155 return FSDK_SetSandBoxPolicy(policy, enable); | 155 return FSDK_SetSandBoxPolicy(policy, enable); |
156 } | 156 } |
157 | 157 |
| 158 |
158 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, | 159 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, |
159 FPDF_BYTESTRING password) { | 160 FPDF_BYTESTRING password) { |
| 161 // NOTE: the creation of the file needs to be by the embedder on the |
| 162 // other side of this API. |
| 163 IFX_FileRead* pFileAccess = FX_CreateFileRead((const FX_CHAR*)file_path); |
| 164 if (!pFileAccess) { |
| 165 return nullptr; |
| 166 } |
| 167 |
160 CPDF_Parser* pParser = new CPDF_Parser; | 168 CPDF_Parser* pParser = new CPDF_Parser; |
161 pParser->SetPassword(password); | 169 pParser->SetPassword(password); |
162 | 170 |
163 FX_DWORD err_code = pParser->StartParse((const FX_CHAR*)file_path); | 171 FX_DWORD err_code = pParser->StartParse(pFileAccess); |
164 if (err_code) { | 172 if (err_code) { |
165 delete pParser; | 173 delete pParser; |
166 ProcessParseError(err_code); | 174 ProcessParseError(err_code); |
167 return NULL; | 175 return NULL; |
168 } | 176 } |
169 return pParser->GetDocument(); | 177 return pParser->GetDocument(); |
170 } | 178 } |
171 | 179 |
172 extern void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code); | 180 extern void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code); |
173 | 181 |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 if (!buffer) { | 908 if (!buffer) { |
901 *buflen = len; | 909 *buflen = len; |
902 } else if (*buflen >= len) { | 910 } else if (*buflen >= len) { |
903 memcpy(buffer, utf16Name.c_str(), len); | 911 memcpy(buffer, utf16Name.c_str(), len); |
904 *buflen = len; | 912 *buflen = len; |
905 } else { | 913 } else { |
906 *buflen = -1; | 914 *buflen = -1; |
907 } | 915 } |
908 return (FPDF_DEST)pDestObj; | 916 return (FPDF_DEST)pDestObj; |
909 } | 917 } |
OLD | NEW |