| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 if (err_code) { | 258 if (err_code) { |
| 259 delete pParser; | 259 delete pParser; |
| 260 ProcessParseError(err_code); | 260 ProcessParseError(err_code); |
| 261 return NULL; | 261 return NULL; |
| 262 } | 262 } |
| 263 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 263 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
| 264 if (!pPDFDoc) | 264 if (!pPDFDoc) |
| 265 return NULL; | 265 return NULL; |
| 266 | 266 |
| 267 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); | 267 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 268 CPDFXFA_Document* pDocument = new CPDFXFA_Document(pPDFDoc, pProvider); | 268 return new CPDFXFA_Document(pPDFDoc, pProvider); |
| 269 return pDocument; | |
| 270 } | 269 } |
| 271 | 270 |
| 272 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, | 271 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, |
| 273 int* docType) { | 272 int* docType) { |
| 274 if (!document) | 273 if (!document) |
| 275 return FALSE; | 274 return FALSE; |
| 276 | 275 |
| 277 CPDF_Document* pdfDoc = | 276 CPDF_Document* pdfDoc = |
| 278 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); | 277 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); |
| 279 if (!pdfDoc) | 278 if (!pdfDoc) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 return NULL; | 343 return NULL; |
| 345 } | 344 } |
| 346 CPDF_Document* pDoc = NULL; | 345 CPDF_Document* pDoc = NULL; |
| 347 pDoc = pParser ? pParser->GetDocument() : NULL; | 346 pDoc = pParser ? pParser->GetDocument() : NULL; |
| 348 CheckUnSupportError(pDoc, err_code); | 347 CheckUnSupportError(pDoc, err_code); |
| 349 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 348 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
| 350 if (!pPDFDoc) | 349 if (!pPDFDoc) |
| 351 return NULL; | 350 return NULL; |
| 352 | 351 |
| 353 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); | 352 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 354 CPDFXFA_Document* pDocument = new CPDFXFA_Document(pPDFDoc, pProvider); | 353 return new CPDFXFA_Document(pPDFDoc, pProvider); |
| 355 return pDocument; | |
| 356 } | 354 } |
| 357 | 355 |
| 358 DLLEXPORT FPDF_DOCUMENT STDCALL | 356 DLLEXPORT FPDF_DOCUMENT STDCALL |
| 359 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, | 357 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, |
| 360 FPDF_BYTESTRING password) { | 358 FPDF_BYTESTRING password) { |
| 361 CPDF_Parser* pParser = new CPDF_Parser; | 359 CPDF_Parser* pParser = new CPDF_Parser; |
| 362 pParser->SetPassword(password); | 360 pParser->SetPassword(password); |
| 363 CPDF_CustomAccess* pFile = new CPDF_CustomAccess(pFileAccess); | 361 CPDF_CustomAccess* pFile = new CPDF_CustomAccess(pFileAccess); |
| 364 FX_DWORD err_code = pParser->StartParse(pFile); | 362 FX_DWORD err_code = pParser->StartParse(pFile); |
| 365 if (err_code) { | 363 if (err_code) { |
| 366 delete pParser; | 364 delete pParser; |
| 367 ProcessParseError(err_code); | 365 ProcessParseError(err_code); |
| 368 return NULL; | 366 return NULL; |
| 369 } | 367 } |
| 370 CPDF_Document* pDoc = NULL; | 368 CPDF_Document* pDoc = NULL; |
| 371 pDoc = pParser ? pParser->GetDocument() : NULL; | 369 pDoc = pParser ? pParser->GetDocument() : NULL; |
| 372 CheckUnSupportError(pDoc, err_code); | 370 CheckUnSupportError(pDoc, err_code); |
| 373 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 371 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
| 374 if (!pPDFDoc) | 372 if (!pPDFDoc) |
| 375 return NULL; | 373 return NULL; |
| 376 | 374 |
| 377 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); | 375 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 378 CPDFXFA_Document* pDocument = new CPDFXFA_Document(pPDFDoc, pProvider); | 376 return new CPDFXFA_Document(pPDFDoc, pProvider); |
| 379 return pDocument; | |
| 380 } | 377 } |
| 381 | 378 |
| 382 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, | 379 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, |
| 383 int* fileVersion) { | 380 int* fileVersion) { |
| 384 if (!doc || !fileVersion) | 381 if (!doc || !fileVersion) |
| 385 return FALSE; | 382 return FALSE; |
| 386 *fileVersion = 0; | 383 *fileVersion = 0; |
| 387 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)doc; | 384 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)doc; |
| 388 CPDF_Document* pPDFDoc = pDoc->GetPDFDoc(); | 385 CPDF_Document* pPDFDoc = pDoc->GetPDFDoc(); |
| 389 if (!pPDFDoc) | 386 if (!pPDFDoc) |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 pContext->m_pDevice->RestoreState(); | 875 pContext->m_pDevice->RestoreState(); |
| 879 } | 876 } |
| 880 | 877 |
| 881 //#endif | 878 //#endif |
| 882 } | 879 } |
| 883 | 880 |
| 884 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, | 881 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, |
| 885 int page_index, | 882 int page_index, |
| 886 double* width, | 883 double* width, |
| 887 double* height) { | 884 double* height) { |
| 888 // CPDF_Document* pDoc = (CPDF_Document*)document; | |
| 889 // if(pDoc == NULL) | |
| 890 // return FALSE; | |
| 891 // | |
| 892 // CPDF_Dictionary* pDict = pDoc->GetPage(page_index); | |
| 893 // if (pDict == NULL) return FALSE; | |
| 894 // | |
| 895 // CPDF_Page page; | |
| 896 // page.Load(pDoc, pDict); | |
| 897 // *width = page.GetPageWidth(); | |
| 898 // *height = page.GetPageHeight(); | |
| 899 | |
| 900 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; | 885 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; |
| 901 if (pDoc == NULL) | 886 if (pDoc == NULL) |
| 902 return FALSE; | 887 return FALSE; |
| 903 | 888 |
| 904 int count = pDoc->GetPageCount(); | 889 int count = pDoc->GetPageCount(); |
| 905 if (page_index < 0 || page_index >= count) | 890 if (page_index < 0 || page_index >= count) |
| 906 return FALSE; | 891 return FALSE; |
| 907 | 892 |
| 908 CPDFXFA_Page* pPage = pDoc->GetPage(page_index); | 893 CPDFXFA_Page* pPage = pDoc->GetPage(page_index); |
| 909 if (!pPage) | 894 if (!pPage) |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 if (!buffer) { | 1082 if (!buffer) { |
| 1098 *buflen = len; | 1083 *buflen = len; |
| 1099 } else if (*buflen >= len) { | 1084 } else if (*buflen >= len) { |
| 1100 memcpy(buffer, utf16Name.c_str(), len); | 1085 memcpy(buffer, utf16Name.c_str(), len); |
| 1101 *buflen = len; | 1086 *buflen = len; |
| 1102 } else { | 1087 } else { |
| 1103 *buflen = -1; | 1088 *buflen = -1; |
| 1104 } | 1089 } |
| 1105 return (FPDF_DEST)pDestObj; | 1090 return (FPDF_DEST)pDestObj; |
| 1106 } | 1091 } |
| OLD | NEW |