| 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 "../../public/fpdf_ext.h" | 7 #include "../../public/fpdf_ext.h" |
| 8 #include "../../public/fpdf_formfill.h" | 8 #include "../../public/fpdf_formfill.h" |
| 9 #include "../../public/fpdf_progressive.h" | 9 #include "../../public/fpdf_progressive.h" |
| 10 #include "../../public/fpdfview.h" | 10 #include "../../public/fpdfview.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 else | 169 else |
| 170 return FALSE; | 170 return FALSE; |
| 171 } | 171 } |
| 172 break; | 172 break; |
| 173 default: | 173 default: |
| 174 break; | 174 break; |
| 175 } | 175 } |
| 176 return FALSE; | 176 return FALSE; |
| 177 } | 177 } |
| 178 | 178 |
| 179 | |
| 180 #ifndef _T | |
| 181 #define _T(x) x | |
| 182 #endif | |
| 183 | |
| 184 CCodec_ModuleMgr* g_pCodecModule = NULL; | 179 CCodec_ModuleMgr* g_pCodecModule = NULL; |
| 185 | 180 |
| 186 DLLEXPORT void STDCALL FPDF_InitLibrary() | 181 DLLEXPORT void STDCALL FPDF_InitLibrary() |
| 187 { | 182 { |
| 188 » g_pCodecModule = CCodec_ModuleMgr::Create(); | 183 g_pCodecModule = CCodec_ModuleMgr::Create(); |
| 189 » | |
| 190 » CFX_GEModule::Create(); | |
| 191 » CFX_GEModule::Get()->SetCodecModule(g_pCodecModule); | |
| 192 » | |
| 193 » CPDF_ModuleMgr::Create(); | |
| 194 » CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule); | |
| 195 » CPDF_ModuleMgr::Get()->InitPageModule(); | |
| 196 » CPDF_ModuleMgr::Get()->InitRenderModule(); | |
| 197 | 184 |
| 198 » CPDFXFA_App* pAppProvider = FPDFXFA_GetApp(); | 185 CFX_GEModule::Create(); |
| 199 » pAppProvider->Initialize(); | 186 CFX_GEModule::Get()->SetCodecModule(g_pCodecModule); |
| 187 |
| 188 CPDF_ModuleMgr::Create(); |
| 189 CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule); |
| 190 CPDF_ModuleMgr::Get()->InitPageModule(); |
| 191 CPDF_ModuleMgr::Get()->InitRenderModule(); |
| 192 |
| 193 CPDFXFA_App::GetInstance()->Initialize(); |
| 200 } | 194 } |
| 201 | 195 |
| 202 | |
| 203 DLLEXPORT void STDCALL FPDF_DestroyLibrary() | 196 DLLEXPORT void STDCALL FPDF_DestroyLibrary() |
| 204 { | 197 { |
| 205 » FPDFXFA_ReleaseApp(); | 198 CPDFXFA_App::ReleaseInstance(); |
| 206 » CPDF_ModuleMgr::Destroy(); | 199 CPDF_ModuleMgr::Destroy(); |
| 207 » CFX_GEModule::Destroy(); | 200 CFX_GEModule::Destroy(); |
| 208 » g_pCodecModule->Destroy(); | 201 g_pCodecModule->Destroy(); |
| 209 } | 202 } |
| 210 | 203 |
| 211 #ifndef _WIN32 | 204 #ifndef _WIN32 |
| 212 int g_LastError; | 205 int g_LastError; |
| 213 void SetLastError(int err) | 206 void SetLastError(int err) |
| 214 { | 207 { |
| 215 g_LastError = err; | 208 g_LastError = err; |
| 216 } | 209 } |
| 217 | 210 |
| 218 int GetLastError() | 211 int GetLastError() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 FX_DWORD err_code = pParser->StartParse((FX_LPCSTR)file_path); | 247 FX_DWORD err_code = pParser->StartParse((FX_LPCSTR)file_path); |
| 255 if (err_code) { | 248 if (err_code) { |
| 256 delete pParser; | 249 delete pParser; |
| 257 ProcessParseError(err_code); | 250 ProcessParseError(err_code); |
| 258 return NULL; | 251 return NULL; |
| 259 } | 252 } |
| 260 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 253 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
| 261 if (!pPDFDoc) | 254 if (!pPDFDoc) |
| 262 return NULL; | 255 return NULL; |
| 263 | 256 |
| 264 » CPDFXFA_App* pProvider = FPDFXFA_GetApp(); | 257 » CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 265 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); | 258 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); |
| 266 return pDocument; | 259 return pDocument; |
| 267 } | 260 } |
| 268 | 261 |
| 269 DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int* docType) | 262 DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int* docType) |
| 270 { | 263 { |
| 271 if (!document) | 264 if (!document) |
| 272 return FALSE; | 265 return FALSE; |
| 273 | 266 |
| 274 CPDF_Document *pdfDoc = (static_cast<CPDFXFA_Document *>(document))->Get
PDFDoc(); | 267 CPDF_Document *pdfDoc = (static_cast<CPDFXFA_Document *>(document))->Get
PDFDoc(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 ProcessParseError(err_code); | 333 ProcessParseError(err_code); |
| 341 return NULL; | 334 return NULL; |
| 342 } | 335 } |
| 343 CPDF_Document * pDoc = NULL; | 336 CPDF_Document * pDoc = NULL; |
| 344 pDoc = pParser?pParser->GetDocument():NULL; | 337 pDoc = pParser?pParser->GetDocument():NULL; |
| 345 CheckUnSupportError(pDoc, err_code); | 338 CheckUnSupportError(pDoc, err_code); |
| 346 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 339 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
| 347 if (!pPDFDoc) | 340 if (!pPDFDoc) |
| 348 return NULL; | 341 return NULL; |
| 349 | 342 |
| 350 » CPDFXFA_App* pProvider = FPDFXFA_GetApp(); | 343 » CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 351 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); | 344 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); |
| 352 //pDocument->LoadXFADoc(); | |
| 353 | |
| 354 return pDocument; | 345 return pDocument; |
| 355 } | 346 } |
| 356 | 347 |
| 357 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc
cess, FPDF_BYTESTRING password) | 348 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc
cess, FPDF_BYTESTRING password) |
| 358 { | 349 { |
| 359 CPDF_Parser* pParser = FX_NEW CPDF_Parser; | 350 CPDF_Parser* pParser = FX_NEW CPDF_Parser; |
| 360 pParser->SetPassword(password); | 351 pParser->SetPassword(password); |
| 361 CPDF_CustomAccess* pFile = FX_NEW CPDF_CustomAccess(pFileAccess); | 352 CPDF_CustomAccess* pFile = FX_NEW CPDF_CustomAccess(pFileAccess); |
| 362 FX_DWORD err_code = pParser->StartParse(pFile); | 353 FX_DWORD err_code = pParser->StartParse(pFile); |
| 363 if (err_code) { | 354 if (err_code) { |
| 364 delete pParser; | 355 delete pParser; |
| 365 ProcessParseError(err_code); | 356 ProcessParseError(err_code); |
| 366 return NULL; | 357 return NULL; |
| 367 } | 358 } |
| 368 CPDF_Document * pDoc = NULL; | 359 CPDF_Document * pDoc = NULL; |
| 369 pDoc = pParser?pParser->GetDocument():NULL; | 360 pDoc = pParser?pParser->GetDocument():NULL; |
| 370 CheckUnSupportError(pDoc, err_code); | 361 CheckUnSupportError(pDoc, err_code); |
| 371 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 362 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
| 372 if (!pPDFDoc) | 363 if (!pPDFDoc) |
| 373 return NULL; | 364 return NULL; |
| 374 | 365 |
| 375 » CPDFXFA_App* pProvider = FPDFXFA_GetApp(); | 366 » CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 376 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); | 367 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); |
| 377 //pDocument->LoadXFADoc(); | |
| 378 | |
| 379 return pDocument; | 368 return pDocument; |
| 380 } | 369 } |
| 381 | 370 |
| 382 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers
ion) | 371 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers
ion) |
| 383 { | 372 { |
| 384 if(!doc||!fileVersion) return FALSE; | 373 if(!doc||!fileVersion) return FALSE; |
| 385 *fileVersion = 0; | 374 *fileVersion = 0; |
| 386 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)doc; | 375 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)doc; |
| 387 CPDF_Document* pPDFDoc = pDoc->GetPDFDoc(); | 376 CPDF_Document* pPDFDoc = pDoc->GetPDFDoc(); |
| 388 if (!pPDFDoc) return (FX_DWORD)-1; | 377 if (!pPDFDoc) return (FX_DWORD)-1; |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 if (!buffer) { | 1042 if (!buffer) { |
| 1054 *buflen = len; | 1043 *buflen = len; |
| 1055 } else if (*buflen >= len) { | 1044 } else if (*buflen >= len) { |
| 1056 memcpy(buffer, utf16Name.c_str(), len); | 1045 memcpy(buffer, utf16Name.c_str(), len); |
| 1057 *buflen = len; | 1046 *buflen = len; |
| 1058 } else { | 1047 } else { |
| 1059 *buflen = -1; | 1048 *buflen = -1; |
| 1060 } | 1049 } |
| 1061 return (FPDF_DEST)pDestObj; | 1050 return (FPDF_DEST)pDestObj; |
| 1062 } | 1051 } |
| OLD | NEW |