blob: bbf75e5690b0d0b4069b8ed7026c2435f05744d3 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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 Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez19922bb2015-05-28 13:23:12 -07007#ifndef FPDFSDK_INCLUDE_FSDK_DEFINE_H_
8#define FPDFSDK_INCLUDE_FSDK_DEFINE_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
10#ifdef _WIN32
11#include <tchar.h>
12#include <math.h>
13#endif
14
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070015#include "../../core/include/fpdfapi/fpdf_module.h"
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070016#include "../../core/include/fpdfapi/fpdf_pageobj.h"
Lei Zhange5b0bd12015-06-19 17:15:41 -070017#include "../../core/include/fpdfapi/fpdf_parser.h"
18#include "../../core/include/fpdfapi/fpdf_parser.h"
19#include "../../core/include/fpdfapi/fpdf_render.h"
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070020#include "../../core/include/fpdfapi/fpdf_serial.h"
Lei Zhange5b0bd12015-06-19 17:15:41 -070021#include "../../core/include/fpdfapi/fpdfapi.h"
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070022#include "../../core/include/fpdfdoc/fpdf_doc.h"
23#include "../../core/include/fpdfdoc/fpdf_vt.h"
John Abd-El-Malek207299b2014-12-15 12:13:45 -080024#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-Malek207299b2014-12-15 12:13:45 -080028#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-Malek3f3b45c2014-05-23 17:28:10 -070031
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 Zhanga6d9f0e2015-06-13 00:48:38 -070063typedef unsigned int FX_UINT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070064
Tom Sepez1ed8a212015-05-11 15:25:39 -070065#include "../../public/fpdfview.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070066
Tom Sepezb1161362015-06-09 11:29:12 -070067class CPDF_CustomAccess final : public IFX_FileRead
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070068{
69public:
70 CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
71 ~CPDF_CustomAccess() {}
72
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070073
Tom Sepezb1161362015-06-09 11:29:12 -070074 virtual CFX_ByteString GetFullPath() { return ""; }
75 virtual FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; }
Tom Sepezbfa9a822015-06-09 13:24:12 -070076 virtual FX_BOOL GetByte(FX_DWORD pos, uint8_t& ch);
Tom Sepezd7e5cc72015-06-10 14:33:37 -070077 virtual FX_BOOL GetBlock(FX_DWORD pos, uint8_t* pBuf, FX_DWORD size);
Tom Sepezb1161362015-06-09 11:29:12 -070078 virtual void Release() override { delete this; }
79 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070080
81 FPDF_FILEACCESS m_FileAccess;
Tom Sepezbfa9a822015-06-09 13:24:12 -070082 uint8_t m_Buffer[512];
Bo Xufdc00a72014-10-28 23:03:33 -070083 FX_DWORD m_BufferOffset;
84};
85
Tom Sepez6fc8cbb2015-04-14 13:50:34 -070086class CFPDF_FileStream : public IFX_FileStream
Bo Xufdc00a72014-10-28 23:03:33 -070087{
88public:
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
104protected:
105 FPDF_FILEHANDLER* m_pFS;
106 FX_FILESIZE m_nCurPos;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700107};
108
109void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
110FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
111
112
Tom Sepez19922bb2015-05-28 13:23:12 -0700113#endif // FPDFSDK_INCLUDE_FSDK_DEFINE_H_