John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_INCLUDE_FSDK_DEFINE_H_ |
| 8 | #define FPDFSDK_INCLUDE_FSDK_DEFINE_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
| 10 | #ifdef _WIN32 |
| 11 | #include <tchar.h> |
| 12 | #include <math.h> |
| 13 | #endif |
| 14 | |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 15 | #include "../../core/include/fpdfapi/fpdf_module.h" |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 16 | #include "../../core/include/fpdfapi/fpdf_pageobj.h" |
Lei Zhang | e5b0bd1 | 2015-06-19 17:15:41 -0700 | [diff] [blame^] | 17 | #include "../../core/include/fpdfapi/fpdf_parser.h" |
| 18 | #include "../../core/include/fpdfapi/fpdf_parser.h" |
| 19 | #include "../../core/include/fpdfapi/fpdf_render.h" |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 20 | #include "../../core/include/fpdfapi/fpdf_serial.h" |
Lei Zhang | e5b0bd1 | 2015-06-19 17:15:41 -0700 | [diff] [blame^] | 21 | #include "../../core/include/fpdfapi/fpdfapi.h" |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 22 | #include "../../core/include/fpdfdoc/fpdf_doc.h" |
| 23 | #include "../../core/include/fpdfdoc/fpdf_vt.h" |
John Abd-El-Malek | 207299b | 2014-12-15 12:13:45 -0800 | [diff] [blame] | 24 | #include "../../xfa/include/fxbarcode/BC_BarCode.h" |
| 25 | #include "../../xfa/include/fxjse/fxjse.h" |
| 26 | #include "../../xfa/include/fxgraphics/fx_graphics.h" |
| 27 | #include "../../xfa/include/fxfa/fxfa.h" |
John Abd-El-Malek | 207299b | 2014-12-15 12:13:45 -0800 | [diff] [blame] | 28 | #include "../../xfa/include/fwl/core/fwl_error.h" |
| 29 | #include "../../xfa/include/fwl/core/fwl_timer.h" |
| 30 | #include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 31 | |
| 32 | |
| 33 | #ifndef FX_GetAValue |
| 34 | /** @brief It retrieves an intensity value for the alpha component of a #FX_ARGB value. */ |
| 35 | #define FX_GetAValue(argb) ((argb & 0xFF000000) >> 24) |
| 36 | #endif |
| 37 | |
| 38 | #ifndef FX_GetRValue |
| 39 | /** @brief It retrieves an intensity value for the red component of a #FX_ARGB value. */ |
| 40 | #define FX_GetRValue(argb) ((argb & 0x00FF0000) >> 16) |
| 41 | #endif |
| 42 | |
| 43 | #ifndef FX_GetGValue |
| 44 | /** @brief It retrieves an intensity value for the green component of a #FX_ARGB value. */ |
| 45 | #define FX_GetGValue(argb) ((argb & 0x0000FF00) >> 8) |
| 46 | #endif |
| 47 | |
| 48 | #ifndef FX_GetBValue |
| 49 | /** @brief It retrieves an intensity value for the blue component of a #FX_ARGB value. */ |
| 50 | #define FX_GetBValue(argb) (argb & 0x000000FF) |
| 51 | #endif |
| 52 | |
| 53 | #ifndef FX_ARGBTOCOLORREF |
| 54 | /** @brief Convert a #FX_ARGB to a #FX_COLORREF. */ |
| 55 | #define FX_ARGBTOCOLORREF(argb) ((((FX_DWORD)argb & 0x00FF0000) >> 16)|((FX_DWORD)argb & 0x0000FF00)|(((FX_DWORD)argb & 0x000000FF) << 16)) |
| 56 | #endif |
| 57 | |
| 58 | #ifndef FX_COLORREFTOARGB |
| 59 | /** @brief Convert a #FX_COLORREF to a #FX_ARGB. */ |
| 60 | #define FX_COLORREFTOARGB(rgb) ((FX_DWORD)0xFF000000|(((FX_DWORD)rgb & 0x000000FF) << 16)|((FX_DWORD)rgb & 0x0000FF00)|(((FX_DWORD)rgb & 0x00FF0000) >> 16)) |
| 61 | #endif |
| 62 | |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 63 | typedef unsigned int FX_UINT; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 64 | |
Tom Sepez | 1ed8a21 | 2015-05-11 15:25:39 -0700 | [diff] [blame] | 65 | #include "../../public/fpdfview.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 66 | |
Tom Sepez | b116136 | 2015-06-09 11:29:12 -0700 | [diff] [blame] | 67 | class CPDF_CustomAccess final : public IFX_FileRead |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 68 | { |
| 69 | public: |
| 70 | CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess); |
| 71 | ~CPDF_CustomAccess() {} |
| 72 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 73 | |
Tom Sepez | b116136 | 2015-06-09 11:29:12 -0700 | [diff] [blame] | 74 | virtual CFX_ByteString GetFullPath() { return ""; } |
| 75 | virtual FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; } |
Tom Sepez | bfa9a82 | 2015-06-09 13:24:12 -0700 | [diff] [blame] | 76 | virtual FX_BOOL GetByte(FX_DWORD pos, uint8_t& ch); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 77 | virtual FX_BOOL GetBlock(FX_DWORD pos, uint8_t* pBuf, FX_DWORD size); |
Tom Sepez | b116136 | 2015-06-09 11:29:12 -0700 | [diff] [blame] | 78 | virtual void Release() override { delete this; } |
| 79 | virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 80 | |
| 81 | FPDF_FILEACCESS m_FileAccess; |
Tom Sepez | bfa9a82 | 2015-06-09 13:24:12 -0700 | [diff] [blame] | 82 | uint8_t m_Buffer[512]; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 83 | FX_DWORD m_BufferOffset; |
| 84 | }; |
| 85 | |
Tom Sepez | 6fc8cbb | 2015-04-14 13:50:34 -0700 | [diff] [blame] | 86 | class CFPDF_FileStream : public IFX_FileStream |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 87 | { |
| 88 | public: |
| 89 | CFPDF_FileStream(FPDF_FILEHANDLER* pFS); |
| 90 | virtual ~CFPDF_FileStream() {} |
| 91 | |
| 92 | virtual IFX_FileStream* Retain(); |
| 93 | virtual void Release(); |
| 94 | |
| 95 | virtual FX_FILESIZE GetSize(); |
| 96 | virtual FX_BOOL IsEOF(); |
| 97 | virtual FX_FILESIZE GetPosition() {return m_nCurPos;} |
| 98 | virtual void SetPosition(FX_FILESIZE pos) {m_nCurPos = pos; } |
| 99 | virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); |
| 100 | virtual size_t ReadBlock(void* buffer, size_t size); |
| 101 | virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size); |
| 102 | virtual FX_BOOL Flush(); |
| 103 | |
| 104 | protected: |
| 105 | FPDF_FILEHANDLER* m_pFS; |
| 106 | FX_FILESIZE m_nCurPos; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); |
| 110 | FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy); |
| 111 | |
| 112 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 113 | #endif // FPDFSDK_INCLUDE_FSDK_DEFINE_H_ |