Merge to XFA: Create top-level public/ header directory.
[pdfium.git] / fpdfsdk / include / fsdk_define.h
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.
4  
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef _FPDFSDK_DEFINE_H
8 #define _FPDFSDK_DEFINE_H
9
10 #ifdef _WIN32
11 #include <tchar.h>
12 #include <math.h>
13 #endif
14
15 #include "../../core/include/fpdfapi/fpdf_parser.h" 
16 #include "../../core/include/fpdfapi/fpdfapi.h" 
17 #include "../../core/include/fpdfapi/fpdf_parser.h" 
18 #include "../../core/include/fpdfapi/fpdf_module.h" 
19 #include "../../core/include/fpdfapi/fpdf_render.h" 
20 #include "../../core/include/fpdfapi/fpdf_pageobj.h" 
21 #include "../../core/include/fpdfapi/fpdf_serial.h" 
22
23 #include "../../core/include/fpdftext/fpdf_text.h"
24
25 #include "../../core/include/fxge/fx_ge_win32.h"
26 #include "../../core/include/fxge/fx_ge.h"
27
28 #include "../../core/include/fxcodec/fx_codec.h"
29
30 #include "../../core/include/fpdfdoc/fpdf_doc.h" 
31 #include "../../core/include/fpdfdoc/fpdf_vt.h" 
32
33 #include "../../core/include/fxcrt/fx_xml.h" 
34 #include "../../xfa/include/fxbarcode/BC_BarCode.h"
35 #include "../../xfa/include/fxjse/fxjse.h"
36 #include "../../xfa/include/fxgraphics/fx_graphics.h"
37 #include "../../xfa/include/fxfa/fxfa.h"
38
39 #include "../../xfa/include/fwl/core/fwl_error.h"
40 #include "../../xfa/include/fwl/core/fwl_timer.h"
41 #include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h"
42
43
44 #ifndef FX_GetAValue
45 /** @brief It retrieves an intensity value for the alpha component of a #FX_ARGB value. */
46 #define FX_GetAValue(argb)                      ((argb & 0xFF000000) >> 24)
47 #endif
48
49 #ifndef FX_GetRValue
50 /** @brief It retrieves an intensity value for the red component of a #FX_ARGB value. */
51 #define FX_GetRValue(argb)                      ((argb & 0x00FF0000) >> 16)
52 #endif
53
54 #ifndef FX_GetGValue
55 /** @brief It retrieves an intensity value for the green component of a #FX_ARGB value. */
56 #define FX_GetGValue(argb)                      ((argb & 0x0000FF00) >> 8)
57 #endif
58
59 #ifndef FX_GetBValue
60 /** @brief It retrieves an intensity value for the blue component of a #FX_ARGB value. */
61 #define FX_GetBValue(argb)                      (argb & 0x000000FF)
62 #endif
63
64 #ifndef FX_ARGBTOCOLORREF
65 /** @brief Convert a #FX_ARGB to a #FX_COLORREF. */
66 #define FX_ARGBTOCOLORREF(argb)         ((((FX_DWORD)argb & 0x00FF0000) >> 16)|((FX_DWORD)argb & 0x0000FF00)|(((FX_DWORD)argb & 0x000000FF) << 16))
67 #endif
68
69 #ifndef FX_COLORREFTOARGB
70 /** @brief Convert a #FX_COLORREF to a #FX_ARGB. */
71 #define FX_COLORREFTOARGB(rgb)          ((FX_DWORD)0xFF000000|(((FX_DWORD)rgb & 0x000000FF) << 16)|((FX_DWORD)rgb & 0x0000FF00)|(((FX_DWORD)rgb & 0x00FF0000) >> 16))
72 #endif
73
74 typedef unsigned int FX_UINT;   
75
76 #include "../../public/fpdfview.h"
77
78 class CPDF_CustomAccess FX_FINAL : public IFX_FileRead
79 {
80 public:
81         CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
82         ~CPDF_CustomAccess() {}
83
84         virtual CFX_ByteString GetFullPath() { return ""; }
85         virtual FX_FILESIZE     GetSize() FX_OVERRIDE { return m_FileAccess.m_FileLen; }
86
87         virtual FX_BOOL         GetByte(FX_DWORD pos, FX_BYTE& ch);
88         virtual FX_BOOL         GetBlock(FX_DWORD pos, FX_LPBYTE pBuf, FX_DWORD size);
89         virtual void            Release() FX_OVERRIDE { delete this; }
90
91         virtual FX_BOOL         ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE;
92
93         FPDF_FILEACCESS         m_FileAccess;
94         FX_BYTE                         m_Buffer[512];
95         FX_DWORD                        m_BufferOffset;
96 };
97
98 class CFPDF_FileStream : public IFX_FileStream
99 {
100 public:
101         CFPDF_FileStream(FPDF_FILEHANDLER* pFS);
102         virtual ~CFPDF_FileStream() {}
103
104         virtual IFX_FileStream*         Retain();
105         virtual void                            Release();
106
107         virtual FX_FILESIZE                     GetSize();
108         virtual FX_BOOL                         IsEOF();
109         virtual FX_FILESIZE                     GetPosition() {return m_nCurPos;}
110         virtual void                            SetPosition(FX_FILESIZE pos) {m_nCurPos = pos; }
111         virtual FX_BOOL                         ReadBlock(void* buffer, FX_FILESIZE offset, size_t size);
112         virtual size_t                          ReadBlock(void* buffer, size_t size);
113         virtual FX_BOOL                         WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size);
114         virtual FX_BOOL                         Flush();
115
116 protected:
117         FPDF_FILEHANDLER*       m_pFS;
118         FX_FILESIZE             m_nCurPos;
119 };
120
121 void            FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
122 FPDF_BOOL       FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
123
124
125 #endif//_FPDFSDK_DEFINE_H