Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[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 //#define API5
16 #define API6
17 #define  _FPDFAPI_ASYNC_PARSING_
18 #define _FXSDK_OPENSOURCE_
19
20 #ifdef _FPDFEMB_WCE_
21         #include "../../core/include/fpdfapi/fpdfapi.h" 
22         #include "../../core/include/fpdfapi/fpdf_parser.h" 
23         #include "../../core/include/fpdfapi/fpdf_module.h" 
24         #include "../../core/include/fpdfapi/fpdf_render.h" 
25         #include "../../core/include/fpdfapi/fpdf_pageobj.h" 
26         #include "../../core/include/fpdfapi/fpdf_serial.h" 
27
28         #include "../../core/include/fpdftext/fpdf_text.h"
29
30         #include "../../core/include/fxge/fx_ge_win32.h"
31         #include "../../core/include/fxge/fx_ge.h"
32
33         #include "../../core/include/fxcodec/fx_codec.h"
34
35         #include "../../core/include/fpdfdoc/fpdf_doc.h" 
36         #include "../../core/include/fpdfdoc/fpdf_vt.h" 
37
38         #include "../../core/include/fxcrt/fx_xml.h" 
39         #include "../../core/include/fxcrt/fx_crypt.h"
40
41 #else
42         #ifdef API6
43                 #include "../../core/include/fpdfapi/fpdf_parser.h" 
44                 #include "../../core/include/fpdfapi/fpdfapi.h" 
45                 #include "../../core/include/fpdfapi/fpdf_parser.h" 
46                 #include "../../core/include/fpdfapi/fpdf_module.h" 
47                 #include "../../core/include/fpdfapi/fpdf_render.h" 
48                 #include "../../core/include/fpdfapi/fpdf_pageobj.h" 
49                 #include "../../core/include/fpdfapi/fpdf_serial.h" 
50
51                 #include "../../core/include/fpdftext/fpdf_text.h"
52
53                 #include "../../core/include/fxge/fx_ge_win32.h"
54                 #include "../../core/include/fxge/fx_ge.h"
55
56                 #include "../../core/include/fxcodec/fx_codec.h"
57
58                 #include "../../core/include/fpdfdoc/fpdf_doc.h" 
59                 #include "../../core/include/fpdfdoc/fpdf_vt.h" 
60
61                 #include "../../core/include/fxcrt/fx_xml.h" 
62                 #include "../../xfa/include/fxbarcode/BC_BarCode.h"
63                 #include "../../xfa/include/fxjse/fxjse.h"
64                 #include "../../xfa/include/fxgraphics/fx_graphics.h"
65                 #include "../../xfa/include/fxfa/fxfa.h"
66
67                 #include "../../xfa/include/fwl/core/fwl_error.h"
68                 #include "../../xfa/include/fwl/core/fwl_timer.h"
69                 #include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h"
70                 #ifdef _LICENSED_BUILD_
71                         #include "../../cryptopp/Cryptlib.h"
72                 #endif
73         #endif
74 #endif
75
76
77 #ifndef FX_GetAValue
78 /** @brief It retrieves an intensity value for the alpha component of a #FX_ARGB value. */
79 #define FX_GetAValue(argb)                      ((argb & 0xFF000000) >> 24)
80 #endif
81
82 #ifndef FX_GetRValue
83 /** @brief It retrieves an intensity value for the red component of a #FX_ARGB value. */
84 #define FX_GetRValue(argb)                      ((argb & 0x00FF0000) >> 16)
85 #endif
86
87 #ifndef FX_GetGValue
88 /** @brief It retrieves an intensity value for the green component of a #FX_ARGB value. */
89 #define FX_GetGValue(argb)                      ((argb & 0x0000FF00) >> 8)
90 #endif
91
92 #ifndef FX_GetBValue
93 /** @brief It retrieves an intensity value for the blue component of a #FX_ARGB value. */
94 #define FX_GetBValue(argb)                      (argb & 0x000000FF)
95 #endif
96
97 #ifndef FX_ARGBTOCOLORREF
98 /** @brief Convert a #FX_ARGB to a #FX_COLORREF. */
99 #define FX_ARGBTOCOLORREF(argb)         ((((FX_DWORD)argb & 0x00FF0000) >> 16)|((FX_DWORD)argb & 0x0000FF00)|(((FX_DWORD)argb & 0x000000FF) << 16))
100 #endif
101
102 #ifndef FX_COLORREFTOARGB
103 /** @brief Convert a #FX_COLORREF to a #FX_ARGB. */
104 #define FX_COLORREFTOARGB(rgb)          ((FX_DWORD)0xFF000000|(((FX_DWORD)rgb & 0x000000FF) << 16)|((FX_DWORD)rgb & 0x0000FF00)|(((FX_DWORD)rgb & 0x00FF0000) >> 16))
105 #endif
106
107 typedef unsigned int FX_UINT;   
108
109 #include "fpdfview.h"
110
111 class CPDF_CustomAccess FX_FINAL : public IFX_FileRead, public CFX_Object
112 {
113 public:
114         CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
115         ~CPDF_CustomAccess() {}
116
117         virtual CFX_ByteString GetFullPath() { return ""; }
118         virtual FX_FILESIZE     GetSize() FX_OVERRIDE { return m_FileAccess.m_FileLen; }
119
120         virtual FX_BOOL         GetByte(FX_DWORD pos, FX_BYTE& ch);
121         virtual FX_BOOL         GetBlock(FX_DWORD pos, FX_LPBYTE pBuf, FX_DWORD size);
122         virtual void            Release() FX_OVERRIDE { delete this; }
123
124         virtual FX_BOOL         ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE;
125
126         FPDF_FILEACCESS         m_FileAccess;
127         FX_BYTE                         m_Buffer[512];
128         FX_DWORD                        m_BufferOffset;
129 };
130
131 class CFPDF_FileStream : public IFX_FileStream, public CFX_Object
132 {
133 public:
134         CFPDF_FileStream(FPDF_FILEHANDLER* pFS);
135         virtual ~CFPDF_FileStream() {}
136
137         virtual IFX_FileStream*         Retain();
138         virtual void                            Release();
139
140         virtual FX_FILESIZE                     GetSize();
141         virtual FX_BOOL                         IsEOF();
142         virtual FX_FILESIZE                     GetPosition() {return m_nCurPos;}
143         virtual void                            SetPosition(FX_FILESIZE pos) {m_nCurPos = pos; }
144         virtual FX_BOOL                         ReadBlock(void* buffer, FX_FILESIZE offset, size_t size);
145         virtual size_t                          ReadBlock(void* buffer, size_t size);
146         virtual FX_BOOL                         WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size);
147         virtual FX_BOOL                         Flush();
148
149 protected:
150         FPDF_FILEHANDLER*       m_pFS;
151         FX_FILESIZE             m_nCurPos;
152 };
153
154 void            FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
155 FPDF_BOOL       FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
156
157
158 #endif//_FPDFSDK_DEFINE_H