| 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" |
| 11 #include "../../public/fpdfview.h" | 11 #include "../../public/fpdfview.h" |
| 12 #include "../../third_party/base/nonstd_unique_ptr.h" | 12 #include "../../third_party/base/nonstd_unique_ptr.h" |
| 13 #include "../../third_party/base/numerics/safe_conversions_impl.h" | 13 #include "../../third_party/base/numerics/safe_conversions_impl.h" |
| 14 #include "../include/fsdk_define.h" | 14 #include "../include/fsdk_define.h" |
| 15 #include "../include/fsdk_mgr.h" | 15 #include "../include/fsdk_mgr.h" |
| 16 #include "../include/fsdk_rendercontext.h" | 16 #include "../include/fsdk_rendercontext.h" |
| 17 | 17 |
| 18 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) | 18 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) |
| 19 { | 19 { |
| 20 if (pFileAccess) | 20 if (pFileAccess) |
| 21 m_FileAccess = *pFileAccess; | 21 m_FileAccess = *pFileAccess; |
| 22 } | 22 } |
| 23 | 23 |
| 24 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si
ze) | 24 bool CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) |
| 25 { | 25 { |
| 26 if (offset < 0) { | 26 if (offset < 0) { |
| 27 return FALSE; | 27 return false; |
| 28 } | 28 } |
| 29 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, size_t>(si
ze); | 29 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, size_t>(si
ze); |
| 30 newPos += offset; | 30 newPos += offset; |
| 31 if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { | 31 if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { |
| 32 return FALSE; | 32 return false; |
| 33 } | 33 } |
| 34 return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(uint8_t*) buffe
r, size); | 34 return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(uint8_t*) buffe
r, size); |
| 35 } | 35 } |
| 36 | 36 |
| 37 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS | 37 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS |
| 38 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; | 38 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; |
| 39 | 39 |
| 40 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) | 40 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) |
| 41 { | 41 { |
| 42 switch(policy) | 42 switch(policy) |
| 43 { | 43 { |
| 44 case FPDF_POLICY_MACHINETIME_ACCESS: | 44 case FPDF_POLICY_MACHINETIME_ACCESS: |
| 45 { | 45 { |
| 46 if(enable) | 46 if(enable) |
| 47 foxit_sandbox_policy |= 0x01; | 47 foxit_sandbox_policy |= 0x01; |
| 48 else | 48 else |
| 49 foxit_sandbox_policy &= 0xFFFFFFFE; | 49 foxit_sandbox_policy &= 0xFFFFFFFE; |
| 50 } | 50 } |
| 51 break; | 51 break; |
| 52 default: | 52 default: |
| 53 break; | 53 break; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) | 57 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) |
| 58 { | 58 { |
| 59 switch(policy) | 59 switch(policy) |
| 60 { | 60 { |
| 61 case FPDF_POLICY_MACHINETIME_ACCESS: | 61 case FPDF_POLICY_MACHINETIME_ACCESS: |
| 62 return (foxit_sandbox_policy & 0x01) ? TRUE : FALSE; | 62 return (foxit_sandbox_policy & 0x01) ? true : false; |
| 63 default: | 63 default: |
| 64 return FALSE; | 64 return false; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 #ifndef _T | 68 #ifndef _T |
| 69 #define _T(x) x | 69 #define _T(x) x |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 CCodec_ModuleMgr* g_pCodecModule = nullptr; | 72 CCodec_ModuleMgr* g_pCodecModule = nullptr; |
| 73 | 73 |
| 74 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ | 74 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ |
| 75 class CFontMapper : public IPDF_FontMapper | 75 class CFontMapper : public IPDF_FontMapper |
| 76 { | 76 { |
| 77 public: | 77 public: |
| 78 CFontMapper(); | 78 CFontMapper(); |
| 79 virtual ~CFontMapper(); | 79 virtual ~CFontMapper(); |
| 80 | 80 |
| 81 virtual FT_Face FindSubstFont( | 81 virtual FT_Face FindSubstFont( |
| 82 CPDF_Document* pDoc, // [IN] The PDF
document | 82 CPDF_Document* pDoc, // [IN] The PDF
document |
| 83 const CFX_ByteString& face_name, // [IN] Original
name | 83 const CFX_ByteString& face_name, // [IN] Original
name |
| 84 FX_BOOL bTrueType, // [IN] TrueType
or Type1 | 84 bool bTrueType, // [IN] TrueType or
Type1 |
| 85 FX_DWORD flags, // [IN] PDF font
flags (see PDF Reference section 5.7.1) | 85 FX_DWORD flags, // [IN] PDF font
flags (see PDF Reference section 5.7.1) |
| 86 int font_weight, // [IN] original
font weight. 0 for not specified | 86 int font_weight, // [IN] original
font weight. 0 for not specified |
| 87 int CharsetCP, // [IN] code pag
e for charset (see Win32 GetACP()) | 87 int CharsetCP, // [IN] code pag
e for charset (see Win32 GetACP()) |
| 88 FX_BOOL bVertical, | 88 bool bVertical, |
| 89 CPDF_SubstFont* pSubstFont // [OUT] Subst f
ont data | 89 CPDF_SubstFont* pSubstFont // [OUT] Subst f
ont data |
| 90 ); | 90 ); |
| 91 | 91 |
| 92 FT_Face m_SysFace; | 92 FT_Face m_SysFace; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 CFontMapper* g_pFontMapper = NULL; | 95 CFontMapper* g_pFontMapper = NULL; |
| 96 #endif // #if _FX_OS_ == _FX_LINUX_EMBEDDED_ | 96 #endif // #if _FX_OS_ == _FX_LINUX_EMBEDDED_ |
| 97 | 97 |
| 98 DLLEXPORT void STDCALL FPDF_InitLibrary() | 98 DLLEXPORT void STDCALL FPDF_InitLibrary() |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); | 185 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); |
| 186 | 186 |
| 187 class CMemFile final: public IFX_FileRead | 187 class CMemFile final: public IFX_FileRead |
| 188 { | 188 { |
| 189 public: | 189 public: |
| 190 CMemFile(uint8_t* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} | 190 CMemFile(uint8_t* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} |
| 191 | 191 |
| 192 virtual void Release() {delete this;} | 192 virtual void Release() {delete this;} |
| 193 virtual FX_FILESIZE GetSize() {return m_size;} | 193 virtual FX_FILESIZE GetSize() {return m_size;} |
| 194 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t s
ize) | 194 virtual bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size
) |
| 195 { | 195 { |
| 196 if (offset < 0) { | 196 if (offset < 0) { |
| 197 return FALSE; | 197 return false; |
| 198 } | 198 } |
| 199 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, si
ze_t>(size); | 199 FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, si
ze_t>(size); |
| 200 newPos += offset; | 200 newPos += offset; |
| 201 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { | 201 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { |
| 202 return FALSE; | 202 return false; |
| 203 } | 203 } |
| 204 FXSYS_memcpy(buffer, m_pBuf+offset, size); | 204 FXSYS_memcpy(buffer, m_pBuf+offset, size); |
| 205 return TRUE; | 205 return true; |
| 206 } | 206 } |
| 207 private: | 207 private: |
| 208 uint8_t* m_pBuf; | 208 uint8_t* m_pBuf; |
| 209 FX_FILESIZE m_size; | 209 FX_FILESIZE m_size; |
| 210 }; | 210 }; |
| 211 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s
ize, FPDF_BYTESTRING password) | 211 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s
ize, FPDF_BYTESTRING password) |
| 212 { | 212 { |
| 213 CPDF_Parser* pParser = new CPDF_Parser; | 213 CPDF_Parser* pParser = new CPDF_Parser; |
| 214 pParser->SetPassword(password); | 214 pParser->SetPassword(password); |
| 215 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); | 215 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 237 return NULL; | 237 return NULL; |
| 238 } | 238 } |
| 239 CPDF_Document * pDoc = NULL; | 239 CPDF_Document * pDoc = NULL; |
| 240 pDoc = pParser?pParser->GetDocument():NULL; | 240 pDoc = pParser?pParser->GetDocument():NULL; |
| 241 CheckUnSupportError(pDoc, err_code); | 241 CheckUnSupportError(pDoc, err_code); |
| 242 return pParser->GetDocument(); | 242 return pParser->GetDocument(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers
ion) | 245 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers
ion) |
| 246 { | 246 { |
| 247 if(!doc||!fileVersion) return FALSE; | 247 if(!doc||!fileVersion) return false; |
| 248 *fileVersion = 0; | 248 *fileVersion = 0; |
| 249 CPDF_Document* pDoc = (CPDF_Document*)doc; | 249 CPDF_Document* pDoc = (CPDF_Document*)doc; |
| 250 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); | 250 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); |
| 251 if(!pParser) | 251 if(!pParser) |
| 252 return FALSE; | 252 return false; |
| 253 *fileVersion = pParser->GetFileVersion(); | 253 *fileVersion = pParser->GetFileVersion(); |
| 254 return TRUE; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 // jabdelmalek: changed return type from FX_DWORD to build on Linux (and match h
eader). | 257 // jabdelmalek: changed return type from FX_DWORD to build on Linux (and match h
eader). |
| 258 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) | 258 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) |
| 259 { | 259 { |
| 260 if (document == NULL) return 0; | 260 if (document == NULL) return 0; |
| 261 CPDF_Document*pDoc = (CPDF_Document*)document; | 261 CPDF_Document*pDoc = (CPDF_Document*)document; |
| 262 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); | 262 CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); |
| 263 CPDF_Dictionary* pDict = pParser->GetEncryptDict(); | 263 CPDF_Dictionary* pDict = pParser->GetEncryptDict(); |
| 264 if (pDict == NULL) return (FX_DWORD)-1; | 264 if (pDict == NULL) return (FX_DWORD)-1; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 int rotate, int flags) | 325 int rotate, int flags) |
| 326 { | 326 { |
| 327 if (page==NULL) return; | 327 if (page==NULL) return; |
| 328 CPDF_Page* pPage = (CPDF_Page*)page; | 328 CPDF_Page* pPage = (CPDF_Page*)page; |
| 329 | 329 |
| 330 CRenderContext* pContext = new CRenderContext; | 330 CRenderContext* pContext = new CRenderContext; |
| 331 pPage->SetPrivateData((void*)1, pContext, DropContext); | 331 pPage->SetPrivateData((void*)1, pContext, DropContext); |
| 332 | 332 |
| 333 #ifndef _WIN32_WCE | 333 #ifndef _WIN32_WCE |
| 334 CFX_DIBitmap* pBitmap = NULL; | 334 CFX_DIBitmap* pBitmap = NULL; |
| 335 FX_BOOL bBackgroundAlphaNeeded=FALSE; | 335 bool bBackgroundAlphaNeeded=false; |
| 336 bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); | 336 bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); |
| 337 if (bBackgroundAlphaNeeded) | 337 if (bBackgroundAlphaNeeded) |
| 338 { | 338 { |
| 339 | 339 |
| 340 pBitmap = new CFX_DIBitmap; | 340 pBitmap = new CFX_DIBitmap; |
| 341 pBitmap->Create(size_x, size_y, FXDIB_Argb); | 341 pBitmap->Create(size_x, size_y, FXDIB_Argb); |
| 342 pBitmap->Clear(0x00ffffff); | 342 pBitmap->Clear(0x00ffffff); |
| 343 #ifdef _SKIA_SUPPORT_ | 343 #ifdef _SKIA_SUPPORT_ |
| 344 pContext->m_pDevice = new CFX_SkiaDevice; | 344 pContext->m_pDevice = new CFX_SkiaDevice; |
| 345 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); | 345 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); |
| 346 #else | 346 #else |
| 347 pContext->m_pDevice = new CFX_FxgeDevice; | 347 pContext->m_pDevice = new CFX_FxgeDevice; |
| 348 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); | 348 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); |
| 349 #endif | 349 #endif |
| 350 } | 350 } |
| 351 else | 351 else |
| 352 pContext->m_pDevice = new CFX_WindowsDevice(dc); | 352 pContext->m_pDevice = new CFX_WindowsDevice(dc); |
| 353 | 353 |
| 354 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 354 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
| 355 rotate, flags, TRUE, NULL); | 355 rotate, flags, true, NULL); |
| 356 | 356 |
| 357 if (bBackgroundAlphaNeeded) | 357 if (bBackgroundAlphaNeeded) |
| 358 { | 358 { |
| 359 if (pBitmap) | 359 if (pBitmap) |
| 360 { | 360 { |
| 361 CFX_WindowsDevice WinDC(dc); | 361 CFX_WindowsDevice WinDC(dc); |
| 362 | 362 |
| 363 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) | 363 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) |
| 364 { | 364 { |
| 365 CFX_DIBitmap* pDst = new CFX_DIBitmap; | 365 CFX_DIBitmap* pDst = new CFX_DIBitmap; |
| 366 int pitch = pBitmap->GetPitch(); | 366 int pitch = pBitmap->GetPitch(); |
| 367 pDst->Create(size_x, size_y, FXDIB_Rgb32); | 367 pDst->Create(size_x, size_y, FXDIB_Rgb32); |
| 368 FXSYS_memset(pDst->GetBuffer(), -1, pitch*size_y); | 368 FXSYS_memset(pDst->GetBuffer(), -1, pitch*size_y); |
| 369 pDst->CompositeBitmap(0, 0, size_x, size_y, pBitmap, 0, 0, FXDIB
_BLEND_NORMAL, NULL, FALSE, NULL); | 369 pDst->CompositeBitmap(0, 0, size_x, size_y, pBitmap, 0, 0, FXDIB
_BLEND_NORMAL, NULL, false, NULL); |
| 370 WinDC.StretchDIBits(pDst,0,0,size_x,size_y); | 370 WinDC.StretchDIBits(pDst,0,0,size_x,size_y); |
| 371 delete pDst; | 371 delete pDst; |
| 372 } | 372 } |
| 373 else | 373 else |
| 374 WinDC.SetDIBits(pBitmap,0,0); | 374 WinDC.SetDIBits(pBitmap,0,0); |
| 375 | 375 |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 #else | 378 #else |
| 379 // get clip region | 379 // get clip region |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 if (bitmap == NULL || page == NULL) return; | 485 if (bitmap == NULL || page == NULL) return; |
| 486 CPDF_Page* pPage = (CPDF_Page*)page; | 486 CPDF_Page* pPage = (CPDF_Page*)page; |
| 487 | 487 |
| 488 | 488 |
| 489 CRenderContext* pContext = new CRenderContext; | 489 CRenderContext* pContext = new CRenderContext; |
| 490 pPage->SetPrivateData((void*)1, pContext, DropContext); | 490 pPage->SetPrivateData((void*)1, pContext, DropContext); |
| 491 #ifdef _SKIA_SUPPORT_ | 491 #ifdef _SKIA_SUPPORT_ |
| 492 pContext->m_pDevice = new CFX_SkiaDevice; | 492 pContext->m_pDevice = new CFX_SkiaDevice; |
| 493 | 493 |
| 494 if (flags & FPDF_REVERSE_BYTE_ORDER) | 494 if (flags & FPDF_REVERSE_BYTE_ORDER) |
| 495 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,T
RUE); | 495 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,t
rue); |
| 496 else | 496 else |
| 497 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); | 497 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
| 498 #else | 498 #else |
| 499 pContext->m_pDevice = new CFX_FxgeDevice; | 499 pContext->m_pDevice = new CFX_FxgeDevice; |
| 500 | 500 |
| 501 if (flags & FPDF_REVERSE_BYTE_ORDER) | 501 if (flags & FPDF_REVERSE_BYTE_ORDER) |
| 502 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,T
RUE); | 502 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,t
rue); |
| 503 else | 503 else |
| 504 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); | 504 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
| 505 #endif | 505 #endif |
| 506 | 506 |
| 507 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 507 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
| 508 rotate, flags, TRUE, NULL); | 508 rotate, flags, true, NULL); |
| 509 | 509 |
| 510 delete pContext; | 510 delete pContext; |
| 511 pPage->RemovePrivateData((void*)1); | 511 pPage->RemovePrivateData((void*)1); |
| 512 } | 512 } |
| 513 | 513 |
| 514 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) | 514 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) |
| 515 { | 515 { |
| 516 if (!page) return; | 516 if (!page) return; |
| 517 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->G
etPrivateData((void*)page); | 517 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->G
etPrivateData((void*)page); |
| 518 if (pPageView && pPageView->IsLocked()) { | 518 if (pPageView && pPageView->IsLocked()) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 if (bitmap == NULL) return 0; | 646 if (bitmap == NULL) return 0; |
| 647 return ((CFX_DIBitmap*)bitmap)->GetPitch(); | 647 return ((CFX_DIBitmap*)bitmap)->GetPitch(); |
| 648 } | 648 } |
| 649 | 649 |
| 650 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) | 650 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) |
| 651 { | 651 { |
| 652 delete (CFX_DIBitmap*)bitmap; | 652 delete (CFX_DIBitmap*)bitmap; |
| 653 } | 653 } |
| 654 | 654 |
| 655 void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_
x, int start_y, int size_x, int size_y, | 655 void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_
x, int start_y, int size_x, int size_y, |
| 656 int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_
PAUSE_Adapter * pause ) | 656 int rotate, int flags,bool bNeedToRestore, IFSDK_PAU
SE_Adapter * pause ) |
| 657 { | 657 { |
| 658 CPDF_Page* pPage = (CPDF_Page*)page; | 658 CPDF_Page* pPage = (CPDF_Page*)page; |
| 659 if (pPage == NULL) return; | 659 if (pPage == NULL) return; |
| 660 | 660 |
| 661 if (!pContext->m_pOptions) | 661 if (!pContext->m_pOptions) |
| 662 pContext->m_pOptions = new CPDF_RenderOptions; | 662 pContext->m_pOptions = new CPDF_RenderOptions; |
| 663 | 663 |
| 664 if (flags & FPDF_LCD_TEXT) | 664 if (flags & FPDF_LCD_TEXT) |
| 665 pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE; | 665 pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE; |
| 666 else | 666 else |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 clip.bottom = start_y + size_y; | 698 clip.bottom = start_y + size_y; |
| 699 pContext->m_pDevice->SaveState(); | 699 pContext->m_pDevice->SaveState(); |
| 700 pContext->m_pDevice->SetClip_Rect(&clip); | 700 pContext->m_pDevice->SetClip_Rect(&clip); |
| 701 | 701 |
| 702 pContext->m_pContext = new CPDF_RenderContext; | 702 pContext->m_pContext = new CPDF_RenderContext; |
| 703 pContext->m_pContext->Create(pPage); | 703 pContext->m_pContext->Create(pPage); |
| 704 pContext->m_pContext->AppendObjectList(pPage, &matrix); | 704 pContext->m_pContext->AppendObjectList(pPage, &matrix); |
| 705 | 705 |
| 706 if (flags & FPDF_ANNOT) { | 706 if (flags & FPDF_ANNOT) { |
| 707 pContext->m_pAnnots = new CPDF_AnnotList(pPage); | 707 pContext->m_pAnnots = new CPDF_AnnotList(pPage); |
| 708 FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLA
Y; | 708 bool bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLAY; |
| 709 pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext, bPrintin
g, &matrix, TRUE, NULL); | 709 pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext, bPrintin
g, &matrix, true, NULL); |
| 710 } | 710 } |
| 711 | 711 |
| 712 pContext->m_pRenderer = new CPDF_ProgressiveRenderer( | 712 pContext->m_pRenderer = new CPDF_ProgressiveRenderer( |
| 713 pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions); | 713 pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions); |
| 714 pContext->m_pRenderer->Start(pause); | 714 pContext->m_pRenderer->Start(pause); |
| 715 if (bNeedToRestore) | 715 if (bNeedToRestore) |
| 716 pContext->m_pDevice->RestoreState(); | 716 pContext->m_pDevice->RestoreState(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_i
ndex, double* width, double* height) | 719 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_i
ndex, double* width, double* height) |
| 720 { | 720 { |
| 721 CPDF_Document* pDoc = (CPDF_Document*)document; | 721 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 722 if(pDoc == NULL) | 722 if(pDoc == NULL) |
| 723 return FALSE; | 723 return false; |
| 724 | 724 |
| 725 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); | 725 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); |
| 726 if (pDict == NULL) return FALSE; | 726 if (pDict == NULL) return false; |
| 727 | 727 |
| 728 CPDF_Page page; | 728 CPDF_Page page; |
| 729 page.Load(pDoc, pDict); | 729 page.Load(pDoc, pDict); |
| 730 *width = page.GetPageWidth(); | 730 *width = page.GetPageWidth(); |
| 731 *height = page.GetPageHeight(); | 731 *height = page.GetPageHeight(); |
| 732 | 732 |
| 733 return TRUE; | 733 return true; |
| 734 } | 734 } |
| 735 | 735 |
| 736 DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT documen
t) | 736 DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT documen
t) |
| 737 { | 737 { |
| 738 CPDF_Document* pDoc = (CPDF_Document*)document; | 738 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 739 if (!pDoc) return TRUE; | 739 if (!pDoc) return true; |
| 740 CPDF_ViewerPreferences viewRef(pDoc); | 740 CPDF_ViewerPreferences viewRef(pDoc); |
| 741 return viewRef.PrintScaling(); | 741 return viewRef.PrintScaling(); |
| 742 } | 742 } |
| 743 | 743 |
| 744 DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document) | 744 DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document) |
| 745 { | 745 { |
| 746 CPDF_Document* pDoc = (CPDF_Document*)document; | 746 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 747 if (!pDoc) return 1; | 747 if (!pDoc) return 1; |
| 748 CPDF_ViewerPreferences viewRef(pDoc); | 748 CPDF_ViewerPreferences viewRef(pDoc); |
| 749 return viewRef.NumCopies(); | 749 return viewRef.NumCopies(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 if (!buffer) { | 842 if (!buffer) { |
| 843 *buflen = len; | 843 *buflen = len; |
| 844 } else if (*buflen >= len) { | 844 } else if (*buflen >= len) { |
| 845 memcpy(buffer, utf16Name.c_str(), len); | 845 memcpy(buffer, utf16Name.c_str(), len); |
| 846 *buflen = len; | 846 *buflen = len; |
| 847 } else { | 847 } else { |
| 848 *buflen = -1; | 848 *buflen = -1; |
| 849 } | 849 } |
| 850 return (FPDF_DEST)pDestObj; | 850 return (FPDF_DEST)pDestObj; |
| 851 } | 851 } |
| OLD | NEW |