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/fxcrt/fx_safe_types.h" | 7 #include "../../core/include/fxcrt/fx_safe_types.h" |
8 #include "../../public/fpdf_ext.h" | 8 #include "../../public/fpdf_ext.h" |
9 #include "../../public/fpdf_progressive.h" | 9 #include "../../public/fpdf_progressive.h" |
10 #include "../../public/fpdfview.h" | 10 #include "../../public/fpdfview.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si
ze) | 23 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si
ze) |
24 { | 24 { |
25 if (offset < 0) { | 25 if (offset < 0) { |
26 return FALSE; | 26 return FALSE; |
27 } | 27 } |
28 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, size_t>(si
ze); | 28 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, size_t>(si
ze); |
29 newPos += offset; | 29 newPos += offset; |
30 if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { | 30 if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { |
31 return FALSE; | 31 return FALSE; |
32 } | 32 } |
33 return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(FX_LPBYTE) buff
er, size); | 33 return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(uint8_t*) buffe
r, size); |
34 } | 34 } |
35 | 35 |
36 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS | 36 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS |
37 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; | 37 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; |
38 | 38 |
39 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) | 39 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) |
40 { | 40 { |
41 switch(policy) | 41 switch(policy) |
42 { | 42 { |
43 case FPDF_POLICY_MACHINETIME_ACCESS: | 43 case FPDF_POLICY_MACHINETIME_ACCESS: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enabl
e) | 181 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enabl
e) |
182 { | 182 { |
183 return FSDK_SetSandBoxPolicy(policy, enable); | 183 return FSDK_SetSandBoxPolicy(policy, enable); |
184 } | 184 } |
185 | 185 |
186 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
TESTRING password) | 186 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
TESTRING password) |
187 { | 187 { |
188 CPDF_Parser* pParser = new CPDF_Parser; | 188 CPDF_Parser* pParser = new CPDF_Parser; |
189 pParser->SetPassword(password); | 189 pParser->SetPassword(password); |
190 | 190 |
191 » FX_DWORD err_code = pParser->StartParse((FX_LPCSTR)file_path); | 191 » FX_DWORD err_code = pParser->StartParse((const FX_CHAR*)file_path); |
192 if (err_code) { | 192 if (err_code) { |
193 delete pParser; | 193 delete pParser; |
194 ProcessParseError(err_code); | 194 ProcessParseError(err_code); |
195 return NULL; | 195 return NULL; |
196 } | 196 } |
197 return pParser->GetDocument(); | 197 return pParser->GetDocument(); |
198 } | 198 } |
199 | 199 |
200 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); | 200 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); |
201 | 201 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 FXSYS_memset(pBuffer, 0xff, height*((width*3+3)/4*4)); | 438 FXSYS_memset(pBuffer, 0xff, height*((width*3+3)/4*4)); |
439 | 439 |
440 #ifdef DEBUG_TRACE | 440 #ifdef DEBUG_TRACE |
441 { | 441 { |
442 CPDF_ModuleMgr::Get()->ReportError(999, "DIBSection created"); | 442 CPDF_ModuleMgr::Get()->ReportError(999, "DIBSection created"); |
443 } | 443 } |
444 #endif | 444 #endif |
445 | 445 |
446 // Create a device with this external buffer | 446 // Create a device with this external buffer |
447 pContext->m_pBitmap = new CFX_DIBitmap; | 447 pContext->m_pBitmap = new CFX_DIBitmap; |
448 » pContext->m_pBitmap->Create(width, height, FXDIB_Rgb, (FX_LPBYTE)pBuffer
); | 448 » pContext->m_pBitmap->Create(width, height, FXDIB_Rgb, (uint8_t*)pBuffer)
; |
449 pContext->m_pDevice = new CPDF_FxgeDevice; | 449 pContext->m_pDevice = new CPDF_FxgeDevice; |
450 ((CPDF_FxgeDevice*)pContext->m_pDevice)->Attach(pContext->m_pBitmap); | 450 ((CPDF_FxgeDevice*)pContext->m_pDevice)->Attach(pContext->m_pBitmap); |
451 | 451 |
452 #ifdef DEBUG_TRACE | 452 #ifdef DEBUG_TRACE |
453 CPDF_ModuleMgr::Get()->ReportError(999, "Ready for PDF rendering"); | 453 CPDF_ModuleMgr::Get()->ReportError(999, "Ready for PDF rendering"); |
454 #endif | 454 #endif |
455 | 455 |
456 // output to bitmap device | 456 // output to bitmap device |
457 Func_RenderPage(pContext, page, start_x - rect.left, start_y - rect.top,
size_x, size_y, rotate, flags); | 457 Func_RenderPage(pContext, page, start_x - rect.left, start_y - rect.top,
size_x, size_y, rotate, flags); |
458 | 458 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 526 |
527 Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate
, flags,TRUE,NULL); | 527 Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate
, flags,TRUE,NULL); |
528 | 528 |
529 delete pContext; | 529 delete pContext; |
530 pPage->RemovePrivateData((void*)1); | 530 pPage->RemovePrivateData((void*)1); |
531 } | 531 } |
532 | 532 |
533 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) | 533 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) |
534 { | 534 { |
535 if (!page) return; | 535 if (!page) return; |
536 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->G
etPrivateData((FX_LPVOID)page); | 536 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->G
etPrivateData((void*)page); |
537 if (pPageView && pPageView->IsLocked()) { | 537 if (pPageView && pPageView->IsLocked()) { |
538 pPageView->TakeOverPage(); | 538 pPageView->TakeOverPage(); |
539 return; | 539 return; |
540 } | 540 } |
541 delete (CPDF_Page*)page; | 541 delete (CPDF_Page*)page; |
542 | 542 |
543 } | 543 } |
544 | 544 |
545 DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document) | 545 DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document) |
546 { | 546 { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 case FPDFBitmap_BGRx: | 618 case FPDFBitmap_BGRx: |
619 fx_format = FXDIB_Rgb32; | 619 fx_format = FXDIB_Rgb32; |
620 break; | 620 break; |
621 case FPDFBitmap_BGRA: | 621 case FPDFBitmap_BGRA: |
622 fx_format = FXDIB_Argb; | 622 fx_format = FXDIB_Argb; |
623 break; | 623 break; |
624 default: | 624 default: |
625 return NULL; | 625 return NULL; |
626 } | 626 } |
627 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 627 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
628 » pBitmap->Create(width, height, fx_format, (FX_LPBYTE)first_scan, stride)
; | 628 » pBitmap->Create(width, height, fx_format, (uint8_t*)first_scan, stride); |
629 return pBitmap; | 629 return pBitmap; |
630 } | 630 } |
631 | 631 |
632 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top
, int width, int height, FPDF_DWORD color) | 632 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top
, int width, int height, FPDF_DWORD color) |
633 { | 633 { |
634 if (bitmap == NULL) return; | 634 if (bitmap == NULL) return; |
635 #ifdef _SKIA_SUPPORT_ | 635 #ifdef _SKIA_SUPPORT_ |
636 CFX_SkiaDevice device; | 636 CFX_SkiaDevice device; |
637 #else | 637 #else |
638 CFX_FxgeDevice device; | 638 CFX_FxgeDevice device; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 if (!buffer) { | 867 if (!buffer) { |
868 *buflen = len; | 868 *buflen = len; |
869 } else if (*buflen >= len) { | 869 } else if (*buflen >= len) { |
870 memcpy(buffer, utf16Name.c_str(), len); | 870 memcpy(buffer, utf16Name.c_str(), len); |
871 *buflen = len; | 871 *buflen = len; |
872 } else { | 872 } else { |
873 *buflen = -1; | 873 *buflen = -1; |
874 } | 874 } |
875 return (FPDF_DEST)pDestObj; | 875 return (FPDF_DEST)pDestObj; |
876 } | 876 } |
OLD | NEW |