summaryrefslogtreecommitdiff
path: root/core/include/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/fpdfapi')
-rw-r--r--core/include/fpdfapi/fpdf_module.h410
-rw-r--r--core/include/fpdfapi/fpdf_objects.h1570
-rw-r--r--core/include/fpdfapi/fpdf_page.h498
-rw-r--r--core/include/fpdfapi/fpdf_pageobj.h1442
-rw-r--r--core/include/fpdfapi/fpdf_parser.h2298
-rw-r--r--core/include/fpdfapi/fpdf_render.h636
-rw-r--r--core/include/fpdfapi/fpdf_resource.h1920
-rw-r--r--core/include/fpdfapi/fpdf_serial.h406
-rw-r--r--core/include/fpdfapi/fpdfapi.h30
9 files changed, 4605 insertions, 4605 deletions
diff --git a/core/include/fpdfapi/fpdf_module.h b/core/include/fpdfapi/fpdf_module.h
index bc11a96caf..8f0621a57b 100644
--- a/core/include/fpdfapi/fpdf_module.h
+++ b/core/include/fpdfapi/fpdf_module.h
@@ -1,205 +1,205 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_MODULE_
-#define _FPDF_MODULE_
-#ifndef _FXCRT_EXTENSION_
-#include "../fxcrt/fx_ext.h"
-#endif
-class CPDF_ModuleMgr;
-class CPDF_PageModuleDef;
-class CPDF_RenderModuleDef;
-class CPDF_SecurityHandler;
-class CCodec_ModuleMgr;
-class CPDF_Dictionary;
-class ICodec_JpegModule;
-class ICodec_JpxModule;
-class ICodec_FaxModule;
-class ICodec_Jbig2Module;
-class ICodec_IccModule;
-class ICodec_FlateModule;
-#define ADDIN_NAME_CJK "Eastern Asian Language Support"
-#define ADDIN_NAME_DECODER "JPEG2000 and JBIG2 Image Decoders"
-class CPDF_ModuleMgr : public CFX_Object
-{
-public:
-
- static void Create();
-
- static CPDF_ModuleMgr* Get();
-
- static void Destroy();
-
-
-
- void SetCodecModule(CCodec_ModuleMgr* pModule)
- {
- m_pCodecModule = pModule;
- }
- CCodec_ModuleMgr* GetCodecModule()
- {
- return m_pCodecModule;
- }
-
- void InitPageModule();
-
- void InitRenderModule();
-
-
- void SetModulePath(FX_LPCSTR module_name, FX_LPCSTR path);
-
- CFX_ByteString GetModuleFilePath(FX_LPCSTR module_name, FX_LPCSTR name);
-
- void SetDownloadCallback(FX_BOOL (*callback)(FX_LPCSTR module_name));
-
- FX_BOOL DownloadModule(FX_LPCSTR module_name);
-
- void NotifyModuleAvailable(FX_LPCSTR module_name);
-
-
-
- CPDF_RenderModuleDef* GetRenderModule() const
- {
- return m_pRenderModule;
- }
-
- CPDF_PageModuleDef* GetPageModule() const
- {
- return m_pPageModule;
- }
-
-
-
-
- void LoadEmbeddedGB1CMaps();
-
- void LoadEmbeddedCNS1CMaps();
-
- void LoadEmbeddedJapan1CMaps();
-
- void LoadEmbeddedKorea1CMaps();
-
- ICodec_FaxModule* GetFaxModule();
- ICodec_JpegModule* GetJpegModule();
- ICodec_JpxModule* GetJpxModule();
- ICodec_Jbig2Module* GetJbig2Module();
- ICodec_IccModule* GetIccModule();
- ICodec_FlateModule* GetFlateModule();
-
- void RegisterSecurityHandler(FX_LPCSTR name, CPDF_SecurityHandler * (*CreateHandler)(void* param), void* param);
-
- CPDF_SecurityHandler* CreateSecurityHandler(FX_LPCSTR name);
-
- void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
-
- FX_LPVOID GetPrivateData(FX_LPVOID module_id);
-
- int m_FileBufSize;
-protected:
-
- CPDF_ModuleMgr();
-
- ~CPDF_ModuleMgr();
- void Initialize();
-
- void InitModules();
-
-
-
- CCodec_ModuleMgr* m_pCodecModule;
-
- CPDF_RenderModuleDef* m_pRenderModule;
-
- CPDF_PageModuleDef* m_pPageModule;
-
-
- FX_BOOL (*m_pDownloadCallback)(FX_LPCSTR module_name);
-
- CFX_ByteString m_DefaultModulePath;
-
- CFX_CMapByteStringToPtr m_ModulePathList;
-
- CFX_MapByteStringToPtr m_SecurityHandlerMap;
-
- CFX_PrivateData m_privateData;
-};
-class CPDF_Document;
-class CPDF_DocPageData;
-class CPDF_FontGlobals;
-class IPDF_FontMgr;
-class IPDF_FontMapper;
-class CPDF_ColorSpace;
-class CPDF_PageModuleDef : public CFX_Object
-{
-public:
- virtual ~CPDF_PageModuleDef() {}
-
- virtual CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc)
- {
- return NULL;
- }
-
- virtual void ReleaseDoc(CPDF_Document*) {}
- virtual void ClearDoc(CPDF_Document*) {}
-
- virtual CPDF_FontGlobals* GetFontGlobals()
- {
- return NULL;
- }
-
- virtual void ClearStockFont(CPDF_Document* pDoc) {}
-
- virtual void NotifyCJKAvailable() {}
-
- virtual CPDF_ColorSpace* GetStockCS(int family)
- {
- return NULL;
- }
-};
-class CPDF_PageObjects;
-class CFX_AffineMatrix;
-class CPDF_RenderOptions;
-class CPDF_Page;
-class CPDF_DocRenderData;
-class CPDF_PageRenderCache;
-class CFX_BitmapDevice;
-class CPDF_Stream;
-class CFX_DIBSource;
-class CPDF_RenderConfig;
-class CPDF_Image;
-class CPDF_RenderModuleDef : public CFX_Object
-{
-public:
- virtual ~CPDF_RenderModuleDef() {}
-
- virtual CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc)
- {
- return NULL;
- }
-
- virtual void DestroyDocData(CPDF_DocRenderData*) {}
- virtual void ClearDocData(CPDF_DocRenderData*) {}
-
- virtual CPDF_DocRenderData* GetRenderData()
- {
- return NULL;
- }
-
- virtual CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage)
- {
- return NULL;
- }
-
- virtual void DestroyPageCache(CPDF_PageRenderCache*) {}
-
- virtual void NotifyDecoderAvailable() {}
-
- virtual CPDF_RenderConfig* GetConfig()
- {
- return NULL;
- }
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_MODULE_
+#define _FPDF_MODULE_
+#ifndef _FXCRT_EXTENSION_
+#include "../fxcrt/fx_ext.h"
+#endif
+class CPDF_ModuleMgr;
+class CPDF_PageModuleDef;
+class CPDF_RenderModuleDef;
+class CPDF_SecurityHandler;
+class CCodec_ModuleMgr;
+class CPDF_Dictionary;
+class ICodec_JpegModule;
+class ICodec_JpxModule;
+class ICodec_FaxModule;
+class ICodec_Jbig2Module;
+class ICodec_IccModule;
+class ICodec_FlateModule;
+#define ADDIN_NAME_CJK "Eastern Asian Language Support"
+#define ADDIN_NAME_DECODER "JPEG2000 and JBIG2 Image Decoders"
+class CPDF_ModuleMgr : public CFX_Object
+{
+public:
+
+ static void Create();
+
+ static CPDF_ModuleMgr* Get();
+
+ static void Destroy();
+
+
+
+ void SetCodecModule(CCodec_ModuleMgr* pModule)
+ {
+ m_pCodecModule = pModule;
+ }
+ CCodec_ModuleMgr* GetCodecModule()
+ {
+ return m_pCodecModule;
+ }
+
+ void InitPageModule();
+
+ void InitRenderModule();
+
+
+ void SetModulePath(FX_LPCSTR module_name, FX_LPCSTR path);
+
+ CFX_ByteString GetModuleFilePath(FX_LPCSTR module_name, FX_LPCSTR name);
+
+ void SetDownloadCallback(FX_BOOL (*callback)(FX_LPCSTR module_name));
+
+ FX_BOOL DownloadModule(FX_LPCSTR module_name);
+
+ void NotifyModuleAvailable(FX_LPCSTR module_name);
+
+
+
+ CPDF_RenderModuleDef* GetRenderModule() const
+ {
+ return m_pRenderModule;
+ }
+
+ CPDF_PageModuleDef* GetPageModule() const
+ {
+ return m_pPageModule;
+ }
+
+
+
+
+ void LoadEmbeddedGB1CMaps();
+
+ void LoadEmbeddedCNS1CMaps();
+
+ void LoadEmbeddedJapan1CMaps();
+
+ void LoadEmbeddedKorea1CMaps();
+
+ ICodec_FaxModule* GetFaxModule();
+ ICodec_JpegModule* GetJpegModule();
+ ICodec_JpxModule* GetJpxModule();
+ ICodec_Jbig2Module* GetJbig2Module();
+ ICodec_IccModule* GetIccModule();
+ ICodec_FlateModule* GetFlateModule();
+
+ void RegisterSecurityHandler(FX_LPCSTR name, CPDF_SecurityHandler * (*CreateHandler)(void* param), void* param);
+
+ CPDF_SecurityHandler* CreateSecurityHandler(FX_LPCSTR name);
+
+ void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
+
+ FX_LPVOID GetPrivateData(FX_LPVOID module_id);
+
+ int m_FileBufSize;
+protected:
+
+ CPDF_ModuleMgr();
+
+ ~CPDF_ModuleMgr();
+ void Initialize();
+
+ void InitModules();
+
+
+
+ CCodec_ModuleMgr* m_pCodecModule;
+
+ CPDF_RenderModuleDef* m_pRenderModule;
+
+ CPDF_PageModuleDef* m_pPageModule;
+
+
+ FX_BOOL (*m_pDownloadCallback)(FX_LPCSTR module_name);
+
+ CFX_ByteString m_DefaultModulePath;
+
+ CFX_CMapByteStringToPtr m_ModulePathList;
+
+ CFX_MapByteStringToPtr m_SecurityHandlerMap;
+
+ CFX_PrivateData m_privateData;
+};
+class CPDF_Document;
+class CPDF_DocPageData;
+class CPDF_FontGlobals;
+class IPDF_FontMgr;
+class IPDF_FontMapper;
+class CPDF_ColorSpace;
+class CPDF_PageModuleDef : public CFX_Object
+{
+public:
+ virtual ~CPDF_PageModuleDef() {}
+
+ virtual CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc)
+ {
+ return NULL;
+ }
+
+ virtual void ReleaseDoc(CPDF_Document*) {}
+ virtual void ClearDoc(CPDF_Document*) {}
+
+ virtual CPDF_FontGlobals* GetFontGlobals()
+ {
+ return NULL;
+ }
+
+ virtual void ClearStockFont(CPDF_Document* pDoc) {}
+
+ virtual void NotifyCJKAvailable() {}
+
+ virtual CPDF_ColorSpace* GetStockCS(int family)
+ {
+ return NULL;
+ }
+};
+class CPDF_PageObjects;
+class CFX_AffineMatrix;
+class CPDF_RenderOptions;
+class CPDF_Page;
+class CPDF_DocRenderData;
+class CPDF_PageRenderCache;
+class CFX_BitmapDevice;
+class CPDF_Stream;
+class CFX_DIBSource;
+class CPDF_RenderConfig;
+class CPDF_Image;
+class CPDF_RenderModuleDef : public CFX_Object
+{
+public:
+ virtual ~CPDF_RenderModuleDef() {}
+
+ virtual CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc)
+ {
+ return NULL;
+ }
+
+ virtual void DestroyDocData(CPDF_DocRenderData*) {}
+ virtual void ClearDocData(CPDF_DocRenderData*) {}
+
+ virtual CPDF_DocRenderData* GetRenderData()
+ {
+ return NULL;
+ }
+
+ virtual CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage)
+ {
+ return NULL;
+ }
+
+ virtual void DestroyPageCache(CPDF_PageRenderCache*) {}
+
+ virtual void NotifyDecoderAvailable() {}
+
+ virtual CPDF_RenderConfig* GetConfig()
+ {
+ return NULL;
+ }
+};
+#endif
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index e67144b592..622f39d35f 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -1,785 +1,785 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_OBJECTS_
-#define _FPDF_OBJECTS_
-#ifndef _FXCRT_EXTENSION_
-#include "../fxcrt/fx_ext.h"
-#endif
-class CPDF_Document;
-class CPDF_IndirectObjects;
-class CPDF_Null;
-class CPDF_Boolean;
-class CPDF_Number;
-class CPDF_String;
-class CPDF_Stream;
-class CPDF_StreamAcc;
-class CPDF_StreamFilter;
-class CPDF_Array;
-class CPDF_Dictionary;
-class CPDF_Reference;
-class IPDF_DocParser;
-class IFX_FileRead;
-class CPDF_CryptoHandler;
-#define PDFOBJ_INVALID 0
-#define PDFOBJ_BOOLEAN 1
-#define PDFOBJ_NUMBER 2
-#define PDFOBJ_STRING 3
-#define PDFOBJ_NAME 4
-#define PDFOBJ_ARRAY 5
-#define PDFOBJ_DICTIONARY 6
-#define PDFOBJ_STREAM 7
-#define PDFOBJ_NULL 8
-#define PDFOBJ_REFERENCE 9
-typedef IFX_FileStream* (*FPDF_LPFCloneStreamCallback)(CPDF_Stream *pStream, FX_LPVOID pUserData);
-class CPDF_Object : public CFX_Object
-{
-public:
-
- int GetType() const
- {
- return m_Type;
- }
-
- FX_DWORD GetObjNum() const
- {
- return m_ObjNum;
- }
-
- FX_BOOL IsIdentical(CPDF_Object* pObj) const;
-
- CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const;
-
- CPDF_Object* CloneRef(CPDF_IndirectObjects* pObjs) const;
-
- CPDF_Object* GetDirect() const;
-
- void Release();
-
- CFX_ByteString GetString() const;
-
- CFX_ByteStringC GetConstString() const;
-
- CFX_WideString GetUnicodeText(CFX_CharMap* pCharMap = NULL) const;
-
- FX_FLOAT GetNumber() const;
-
- FX_FLOAT GetNumber16() const;
-
- int GetInteger() const;
-
- CPDF_Dictionary* GetDict() const;
-
- CPDF_Array* GetArray() const;
-
- void SetString(const CFX_ByteString& str);
-
- void SetUnicodeText(FX_LPCWSTR pUnicodes, int len = -1);
-
- int GetDirectType() const;
-
- FX_BOOL IsModified() const
- {
- return FALSE;
- }
-protected:
- FX_DWORD m_Type;
- CPDF_Object()
- {
- m_ObjNum = 0;
- }
-
- FX_DWORD m_ObjNum;
-
- void Destroy();
-
-
- ~CPDF_Object() {}
- friend class CPDF_IndirectObjects;
- friend class CPDF_Parser;
- friend class CPDF_SyntaxParser;
-private:
- CPDF_Object(const CPDF_Object& src) {}
- CPDF_Object* CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visited) const;
-};
-class CPDF_Boolean : public CPDF_Object
-{
-public:
-
- static CPDF_Boolean* Create(FX_BOOL value)
- {
- return FX_NEW CPDF_Boolean(value);
- }
-
- CPDF_Boolean()
- {
- m_Type = PDFOBJ_BOOLEAN;
- }
-
- CPDF_Boolean(FX_BOOL value)
- {
- m_Type = PDFOBJ_BOOLEAN;
- m_bValue = value;
- }
-
- FX_BOOL Identical(CPDF_Boolean* pOther) const
- {
- return m_bValue == pOther->m_bValue;
- }
-protected:
-
- FX_BOOL m_bValue;
- friend class CPDF_Object;
-};
-class CPDF_Number : public CPDF_Object
-{
-public:
-
- static CPDF_Number* Create(int value)
- {
- return FX_NEW CPDF_Number(value);
- }
-
- static CPDF_Number* Create(FX_FLOAT value)
- {
- return FX_NEW CPDF_Number(value);
- }
-
- static CPDF_Number* Create(FX_BSTR str)
- {
- return FX_NEW CPDF_Number(str);
- }
-
- static CPDF_Number* Create(FX_BOOL bInteger, void* pData)
- {
- return FX_NEW CPDF_Number(bInteger, pData);
- }
-
- CPDF_Number()
- {
- m_Type = PDFOBJ_NUMBER;
- }
-
- CPDF_Number(FX_BOOL bInteger, void* pData);
-
- CPDF_Number(int value);
-
- CPDF_Number(FX_FLOAT value);
-
- CPDF_Number(FX_BSTR str);
-
- FX_BOOL Identical(CPDF_Number* pOther) const;
-
- CFX_ByteString GetString() const;
-
- void SetString(FX_BSTR str);
-
- FX_BOOL IsInteger() const
- {
- return m_bInteger;
- }
-
- int GetInteger() const
- {
- return m_bInteger ? m_Integer : (int)m_Float;
- }
-
- FX_FLOAT GetNumber() const
- {
- return m_bInteger ? (FX_FLOAT)m_Integer : m_Float;
- }
-
- void SetNumber(FX_FLOAT value);
-
- FX_FLOAT GetNumber16() const
- {
- return GetNumber();
- }
-
- FX_FLOAT GetFloat() const
- {
- return m_bInteger ? (FX_FLOAT)m_Integer : m_Float;
- }
-protected:
-
- FX_BOOL m_bInteger;
-
- union {
-
- int m_Integer;
-
- FX_FLOAT m_Float;
- };
- friend class CPDF_Object;
-};
-class CPDF_String : public CPDF_Object
-{
-public:
-
- static CPDF_String* Create(const CFX_ByteString& str, FX_BOOL bHex = FALSE)
- {
- return FX_NEW CPDF_String(str, bHex);
- }
-
- static CPDF_String* Create(const CFX_WideString& str)
- {
- return FX_NEW CPDF_String(str);
- }
-
- CPDF_String()
- {
- m_Type = PDFOBJ_STRING;
- m_bHex = FALSE;
- }
-
- CPDF_String(const CFX_ByteString& str, FX_BOOL bHex = FALSE) : m_String(str)
- {
- m_Type = PDFOBJ_STRING;
- m_bHex = bHex;
- }
-
- CPDF_String(const CFX_WideString& str);
-
- CFX_ByteString& GetString()
- {
- return m_String;
- }
-
- FX_BOOL Identical(CPDF_String* pOther) const
- {
- return m_String == pOther->m_String;
- }
-
- FX_BOOL IsHex() const
- {
- return m_bHex;
- }
-protected:
-
- CFX_ByteString m_String;
-
- FX_BOOL m_bHex;
- friend class CPDF_Object;
-};
-class CPDF_Name : public CPDF_Object
-{
-public:
-
- static CPDF_Name* Create(const CFX_ByteString& str)
- {
- return FX_NEW CPDF_Name(str);
- }
-
- static CPDF_Name* Create(FX_BSTR str)
- {
- return FX_NEW CPDF_Name(str);
- }
-
- static CPDF_Name* Create(FX_LPCSTR str)
- {
- return FX_NEW CPDF_Name(str);
- }
-
- CPDF_Name(const CFX_ByteString& str) : m_Name(str)
- {
- m_Type = PDFOBJ_NAME;
- }
-
- CPDF_Name(FX_BSTR str) : m_Name(str)
- {
- m_Type = PDFOBJ_NAME;
- }
-
- CPDF_Name(FX_LPCSTR str) : m_Name(str)
- {
- m_Type = PDFOBJ_NAME;
- }
-
- CFX_ByteString& GetString()
- {
- return m_Name;
- }
-
- FX_BOOL Identical(CPDF_Name* pOther) const
- {
- return m_Name == pOther->m_Name;
- }
-protected:
-
- CFX_ByteString m_Name;
- friend class CPDF_Object;
-};
-class CPDF_Array : public CPDF_Object
-{
-public:
-
- static CPDF_Array* Create()
- {
- return FX_NEW CPDF_Array();
- }
-
- CPDF_Array()
- {
- m_Type = PDFOBJ_ARRAY;
- }
-
- FX_DWORD GetCount() const
- {
- return m_Objects.GetSize();
- }
-
- CPDF_Object* GetElement(FX_DWORD index) const;
-
- CPDF_Object* GetElementValue(FX_DWORD index) const;
-
-
-
- CFX_AffineMatrix GetMatrix();
-
- CFX_FloatRect GetRect();
-
-
-
-
- CFX_ByteString GetString(FX_DWORD index) const;
-
- CFX_ByteStringC GetConstString(FX_DWORD index) const;
-
- int GetInteger(FX_DWORD index) const;
-
- FX_FLOAT GetNumber(FX_DWORD index) const;
-
- CPDF_Dictionary* GetDict(FX_DWORD index) const;
-
- CPDF_Stream* GetStream(FX_DWORD index) const;
-
- CPDF_Array* GetArray(FX_DWORD index) const;
-
- FX_FLOAT GetFloat(FX_DWORD index) const
- {
- return GetNumber(index);
- }
-
-
-
-
- void SetAt(FX_DWORD index, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
-
-
- void InsertAt(FX_DWORD index, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
-
- void RemoveAt(FX_DWORD index);
-
-
- void Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
-
-
-
- void AddNumber(FX_FLOAT f);
-
- void AddInteger(int i);
-
- void AddString(const CFX_ByteString& str);
-
- void AddName(const CFX_ByteString& str);
-
- void AddReference(CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
-
- void AddReference(CPDF_IndirectObjects* pDoc, CPDF_Object* obj)
- {
- AddReference(pDoc, obj->GetObjNum());
- }
-
-
- FX_FLOAT GetNumber16(FX_DWORD index) const
- {
- return GetNumber(index);
- }
-
- void AddNumber16(FX_FLOAT value)
- {
- AddNumber(value);
- }
-
- FX_BOOL Identical(CPDF_Array* pOther) const;
-protected:
-
- ~CPDF_Array();
-
- CFX_PtrArray m_Objects;
- friend class CPDF_Object;
-};
-class CPDF_Dictionary : public CPDF_Object
-{
-public:
-
- static CPDF_Dictionary* Create()
- {
- return FX_NEW CPDF_Dictionary();
- }
-
- CPDF_Dictionary()
- {
- m_Type = PDFOBJ_DICTIONARY;
- }
-
-
-
- CPDF_Object* GetElement(FX_BSTR key) const;
-
- CPDF_Object* GetElementValue(FX_BSTR key) const;
-
-
-
-
-
- CFX_ByteString GetString(FX_BSTR key) const;
-
- CFX_ByteStringC GetConstString(FX_BSTR key) const;
-
- CFX_ByteString GetString(FX_BSTR key, FX_BSTR default_str) const;
-
- CFX_ByteStringC GetConstString(FX_BSTR key, FX_BSTR default_str) const;
-
- CFX_WideString GetUnicodeText(FX_BSTR key, CFX_CharMap* pCharMap = NULL) const;
-
- int GetInteger(FX_BSTR key) const;
-
- int GetInteger(FX_BSTR key, int default_int) const;
-
- FX_BOOL GetBoolean(FX_BSTR key, FX_BOOL bDefault = FALSE) const;
-
- FX_FLOAT GetNumber(FX_BSTR key) const;
-
- CPDF_Dictionary* GetDict(FX_BSTR key) const;
-
- CPDF_Stream* GetStream(FX_BSTR key) const;
-
- CPDF_Array* GetArray(FX_BSTR key) const;
-
- CFX_FloatRect GetRect(FX_BSTR key) const;
-
- CFX_AffineMatrix GetMatrix(FX_BSTR key) const;
-
- FX_FLOAT GetFloat(FX_BSTR key) const
- {
- return GetNumber(key);
- }
-
-
- FX_BOOL KeyExist(FX_BSTR key) const;
-
- FX_POSITION GetStartPos() const;
-
- CPDF_Object* GetNextElement(FX_POSITION& pos, CFX_ByteString& key) const;
-
- void SetAt(FX_BSTR key, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
-
-
-
- void SetAtName(FX_BSTR key, const CFX_ByteString& name);
-
-
- void SetAtString(FX_BSTR key, const CFX_ByteString& string);
-
-
- void SetAtInteger(FX_BSTR key, int i);
-
-
- void SetAtNumber(FX_BSTR key, FX_FLOAT f);
-
- void SetAtReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
-
- void SetAtReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, CPDF_Object* obj)
- {
- SetAtReference(key, pDoc, obj->GetObjNum());
- }
-
- void AddReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
-
- void AddReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, CPDF_Object* obj)
- {
- AddReference(key, pDoc, obj->GetObjNum());
- }
-
- void SetAtRect(FX_BSTR key, const CFX_FloatRect& rect);
-
- void SetAtMatrix(FX_BSTR key, const CFX_AffineMatrix& matrix);
-
- void SetAtBoolean(FX_BSTR key, FX_BOOL bValue);
-
-
-
- void RemoveAt(FX_BSTR key);
-
-
- void ReplaceKey(FX_BSTR oldkey, FX_BSTR newkey);
-
- FX_BOOL Identical(CPDF_Dictionary* pDict) const;
-
- int GetCount() const
- {
- return m_Map.GetCount();
- }
-
- void AddValue(FX_BSTR key, CPDF_Object* pObj);
-protected:
-
- ~CPDF_Dictionary();
-
- CFX_CMapByteStringToPtr m_Map;
-
- friend class CPDF_Object;
-};
-class CPDF_Stream : public CPDF_Object
-{
-public:
-
- static CPDF_Stream* Create(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict)
- {
- return FX_NEW CPDF_Stream(pData, size, pDict);
- }
-
- CPDF_Stream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict);
-
- CPDF_Dictionary* GetDict() const
- {
- return m_pDict;
- }
-
- void SetData(FX_LPCBYTE pData, FX_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf);
-
- void InitStream(FX_BYTE* pData, FX_DWORD size, CPDF_Dictionary* pDict);
-
- void InitStream(IFX_FileRead *pFile, CPDF_Dictionary* pDict);
-
- FX_BOOL Identical(CPDF_Stream* pOther) const;
-
- CPDF_StreamFilter* GetStreamFilter(FX_BOOL bRaw = FALSE) const;
-
-
-
- FX_DWORD GetRawSize() const
- {
- return m_dwSize;
- }
-
- FX_BOOL ReadRawData(FX_FILESIZE start_pos, FX_LPBYTE pBuf, FX_DWORD buf_size) const;
-
-
- FX_BOOL IsMemoryBased() const
- {
- return m_GenNum == (FX_DWORD) - 1;
- }
-
- CPDF_Stream* Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpfCallback, FX_LPVOID pUserData) const;
-protected:
-
- ~CPDF_Stream();
-
- CPDF_Dictionary* m_pDict;
-
- FX_DWORD m_dwSize;
-
- FX_DWORD m_GenNum;
-
- union {
-
- FX_LPBYTE m_pDataBuf;
-
- IFX_FileRead* m_pFile;
- };
-
- FX_FILESIZE m_FileOffset;
-
- CPDF_CryptoHandler* m_pCryptoHandler;
-
- void InitStream(CPDF_Dictionary* pDict);
- friend class CPDF_Object;
- friend class CPDF_StreamAcc;
- friend class CPDF_AttachmentAcc;
-};
-class CPDF_StreamAcc : public CFX_Object
-{
-public:
-
- CPDF_StreamAcc();
-
- ~CPDF_StreamAcc();
-
- void LoadAllData(const CPDF_Stream* pStream, FX_BOOL bRawAccess = FALSE,
- FX_DWORD estimated_size = 0, FX_BOOL bImageAcc = FALSE);
-
- const CPDF_Stream* GetStream() const
- {
- return m_pStream;
- }
-
- CPDF_Dictionary* GetDict() const
- {
- return m_pStream->GetDict();
- }
-
- FX_LPCBYTE GetData() const;
-
- FX_DWORD GetSize() const;
-
- FX_LPBYTE DetachData();
-
- const CFX_ByteString& GetImageDecoder()
- {
- return m_ImageDecoder;
- }
-
- const CPDF_Dictionary* GetImageParam()
- {
- return m_pImageParam;
- }
-protected:
-
- FX_LPBYTE m_pData;
-
- FX_DWORD m_dwSize;
-
- FX_BOOL m_bNewBuf;
-
- CFX_ByteString m_ImageDecoder;
-
- CPDF_Dictionary* m_pImageParam;
-
- const CPDF_Stream* m_pStream;
-
- FX_LPBYTE m_pSrcData;
-};
-CFX_DataFilter* FPDF_CreateFilter(FX_BSTR name, const CPDF_Dictionary* pParam, int width = 0, int height = 0);
-#define FPDF_FILTER_BUFFER_SIZE 20480
-class CPDF_StreamFilter : public CFX_Object
-{
-public:
-
- ~CPDF_StreamFilter();
-
- FX_DWORD ReadBlock(FX_LPBYTE buffer, FX_DWORD size);
-
- FX_DWORD GetSrcPos()
- {
- return m_SrcOffset;
- }
-
- const CPDF_Stream* GetStream()
- {
- return m_pStream;
- }
-protected:
-
- CPDF_StreamFilter() {}
-
- FX_DWORD ReadLeftOver(FX_LPBYTE buffer, FX_DWORD buf_size);
-
- const CPDF_Stream* m_pStream;
-
- CFX_DataFilter* m_pFilter;
-
- CFX_BinaryBuf* m_pBuffer;
-
- FX_DWORD m_BufOffset;
-
- FX_DWORD m_SrcOffset;
-
- FX_BYTE m_SrcBuffer[FPDF_FILTER_BUFFER_SIZE];
- friend class CPDF_Stream;
-};
-class CPDF_Null : public CPDF_Object
-{
-public:
-
- static CPDF_Null* Create()
- {
- return FX_NEW CPDF_Null();
- }
-
- CPDF_Null()
- {
- m_Type = PDFOBJ_NULL;
- }
-};
-class CPDF_Reference : public CPDF_Object
-{
-public:
-
- static CPDF_Reference* Create(CPDF_IndirectObjects* pDoc, int objnum)
- {
- return FX_NEW CPDF_Reference(pDoc, objnum);
- }
-
- CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum)
- {
- m_Type = PDFOBJ_REFERENCE;
- m_pObjList = pDoc;
- m_RefObjNum = objnum;
- }
-
- CPDF_IndirectObjects* GetObjList() const
- {
- return m_pObjList;
- }
-
- FX_DWORD GetRefObjNum() const
- {
- return m_RefObjNum;
- }
-
- void SetRef(CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
-
- FX_BOOL Identical(CPDF_Reference* pOther) const
- {
- return m_RefObjNum == pOther->m_RefObjNum;
- }
-protected:
-
- CPDF_IndirectObjects* m_pObjList;
-
- FX_DWORD m_RefObjNum;
- friend class CPDF_Object;
-};
-class CPDF_IndirectObjects : public CFX_Object
-{
-public:
-
- CPDF_IndirectObjects(IPDF_DocParser* pParser);
-
- ~CPDF_IndirectObjects();
-
- CPDF_Object* GetIndirectObject(FX_DWORD objnum, struct PARSE_CONTEXT* pContext = NULL);
-
- int GetIndirectType(FX_DWORD objnum);
-
- FX_DWORD AddIndirectObject(CPDF_Object* pObj);
-
- void ReleaseIndirectObject(FX_DWORD objnum);
-
- void InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pObj);
-
- FX_DWORD GetLastObjNum() const;
-
- FX_POSITION GetStartPosition() const
- {
- return m_IndirectObjs.GetStartPosition();
- }
-
- void GetNextAssoc(FX_POSITION& rPos, FX_DWORD& objnum, CPDF_Object*& pObject) const
- {
- m_IndirectObjs.GetNextAssoc(rPos, (void*&)objnum, (void*&)pObject);
- }
-protected:
-
- CFX_MapPtrToPtr m_IndirectObjs;
-
- IPDF_DocParser* m_pParser;
-
- FX_DWORD m_LastObjNum;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_OBJECTS_
+#define _FPDF_OBJECTS_
+#ifndef _FXCRT_EXTENSION_
+#include "../fxcrt/fx_ext.h"
+#endif
+class CPDF_Document;
+class CPDF_IndirectObjects;
+class CPDF_Null;
+class CPDF_Boolean;
+class CPDF_Number;
+class CPDF_String;
+class CPDF_Stream;
+class CPDF_StreamAcc;
+class CPDF_StreamFilter;
+class CPDF_Array;
+class CPDF_Dictionary;
+class CPDF_Reference;
+class IPDF_DocParser;
+class IFX_FileRead;
+class CPDF_CryptoHandler;
+#define PDFOBJ_INVALID 0
+#define PDFOBJ_BOOLEAN 1
+#define PDFOBJ_NUMBER 2
+#define PDFOBJ_STRING 3
+#define PDFOBJ_NAME 4
+#define PDFOBJ_ARRAY 5
+#define PDFOBJ_DICTIONARY 6
+#define PDFOBJ_STREAM 7
+#define PDFOBJ_NULL 8
+#define PDFOBJ_REFERENCE 9
+typedef IFX_FileStream* (*FPDF_LPFCloneStreamCallback)(CPDF_Stream *pStream, FX_LPVOID pUserData);
+class CPDF_Object : public CFX_Object
+{
+public:
+
+ int GetType() const
+ {
+ return m_Type;
+ }
+
+ FX_DWORD GetObjNum() const
+ {
+ return m_ObjNum;
+ }
+
+ FX_BOOL IsIdentical(CPDF_Object* pObj) const;
+
+ CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const;
+
+ CPDF_Object* CloneRef(CPDF_IndirectObjects* pObjs) const;
+
+ CPDF_Object* GetDirect() const;
+
+ void Release();
+
+ CFX_ByteString GetString() const;
+
+ CFX_ByteStringC GetConstString() const;
+
+ CFX_WideString GetUnicodeText(CFX_CharMap* pCharMap = NULL) const;
+
+ FX_FLOAT GetNumber() const;
+
+ FX_FLOAT GetNumber16() const;
+
+ int GetInteger() const;
+
+ CPDF_Dictionary* GetDict() const;
+
+ CPDF_Array* GetArray() const;
+
+ void SetString(const CFX_ByteString& str);
+
+ void SetUnicodeText(FX_LPCWSTR pUnicodes, int len = -1);
+
+ int GetDirectType() const;
+
+ FX_BOOL IsModified() const
+ {
+ return FALSE;
+ }
+protected:
+ FX_DWORD m_Type;
+ CPDF_Object()
+ {
+ m_ObjNum = 0;
+ }
+
+ FX_DWORD m_ObjNum;
+
+ void Destroy();
+
+
+ ~CPDF_Object() {}
+ friend class CPDF_IndirectObjects;
+ friend class CPDF_Parser;
+ friend class CPDF_SyntaxParser;
+private:
+ CPDF_Object(const CPDF_Object& src) {}
+ CPDF_Object* CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visited) const;
+};
+class CPDF_Boolean : public CPDF_Object
+{
+public:
+
+ static CPDF_Boolean* Create(FX_BOOL value)
+ {
+ return FX_NEW CPDF_Boolean(value);
+ }
+
+ CPDF_Boolean()
+ {
+ m_Type = PDFOBJ_BOOLEAN;
+ }
+
+ CPDF_Boolean(FX_BOOL value)
+ {
+ m_Type = PDFOBJ_BOOLEAN;
+ m_bValue = value;
+ }
+
+ FX_BOOL Identical(CPDF_Boolean* pOther) const
+ {
+ return m_bValue == pOther->m_bValue;
+ }
+protected:
+
+ FX_BOOL m_bValue;
+ friend class CPDF_Object;
+};
+class CPDF_Number : public CPDF_Object
+{
+public:
+
+ static CPDF_Number* Create(int value)
+ {
+ return FX_NEW CPDF_Number(value);
+ }
+
+ static CPDF_Number* Create(FX_FLOAT value)
+ {
+ return FX_NEW CPDF_Number(value);
+ }
+
+ static CPDF_Number* Create(FX_BSTR str)
+ {
+ return FX_NEW CPDF_Number(str);
+ }
+
+ static CPDF_Number* Create(FX_BOOL bInteger, void* pData)
+ {
+ return FX_NEW CPDF_Number(bInteger, pData);
+ }
+
+ CPDF_Number()
+ {
+ m_Type = PDFOBJ_NUMBER;
+ }
+
+ CPDF_Number(FX_BOOL bInteger, void* pData);
+
+ CPDF_Number(int value);
+
+ CPDF_Number(FX_FLOAT value);
+
+ CPDF_Number(FX_BSTR str);
+
+ FX_BOOL Identical(CPDF_Number* pOther) const;
+
+ CFX_ByteString GetString() const;
+
+ void SetString(FX_BSTR str);
+
+ FX_BOOL IsInteger() const
+ {
+ return m_bInteger;
+ }
+
+ int GetInteger() const
+ {
+ return m_bInteger ? m_Integer : (int)m_Float;
+ }
+
+ FX_FLOAT GetNumber() const
+ {
+ return m_bInteger ? (FX_FLOAT)m_Integer : m_Float;
+ }
+
+ void SetNumber(FX_FLOAT value);
+
+ FX_FLOAT GetNumber16() const
+ {
+ return GetNumber();
+ }
+
+ FX_FLOAT GetFloat() const
+ {
+ return m_bInteger ? (FX_FLOAT)m_Integer : m_Float;
+ }
+protected:
+
+ FX_BOOL m_bInteger;
+
+ union {
+
+ int m_Integer;
+
+ FX_FLOAT m_Float;
+ };
+ friend class CPDF_Object;
+};
+class CPDF_String : public CPDF_Object
+{
+public:
+
+ static CPDF_String* Create(const CFX_ByteString& str, FX_BOOL bHex = FALSE)
+ {
+ return FX_NEW CPDF_String(str, bHex);
+ }
+
+ static CPDF_String* Create(const CFX_WideString& str)
+ {
+ return FX_NEW CPDF_String(str);
+ }
+
+ CPDF_String()
+ {
+ m_Type = PDFOBJ_STRING;
+ m_bHex = FALSE;
+ }
+
+ CPDF_String(const CFX_ByteString& str, FX_BOOL bHex = FALSE) : m_String(str)
+ {
+ m_Type = PDFOBJ_STRING;
+ m_bHex = bHex;
+ }
+
+ CPDF_String(const CFX_WideString& str);
+
+ CFX_ByteString& GetString()
+ {
+ return m_String;
+ }
+
+ FX_BOOL Identical(CPDF_String* pOther) const
+ {
+ return m_String == pOther->m_String;
+ }
+
+ FX_BOOL IsHex() const
+ {
+ return m_bHex;
+ }
+protected:
+
+ CFX_ByteString m_String;
+
+ FX_BOOL m_bHex;
+ friend class CPDF_Object;
+};
+class CPDF_Name : public CPDF_Object
+{
+public:
+
+ static CPDF_Name* Create(const CFX_ByteString& str)
+ {
+ return FX_NEW CPDF_Name(str);
+ }
+
+ static CPDF_Name* Create(FX_BSTR str)
+ {
+ return FX_NEW CPDF_Name(str);
+ }
+
+ static CPDF_Name* Create(FX_LPCSTR str)
+ {
+ return FX_NEW CPDF_Name(str);
+ }
+
+ CPDF_Name(const CFX_ByteString& str) : m_Name(str)
+ {
+ m_Type = PDFOBJ_NAME;
+ }
+
+ CPDF_Name(FX_BSTR str) : m_Name(str)
+ {
+ m_Type = PDFOBJ_NAME;
+ }
+
+ CPDF_Name(FX_LPCSTR str) : m_Name(str)
+ {
+ m_Type = PDFOBJ_NAME;
+ }
+
+ CFX_ByteString& GetString()
+ {
+ return m_Name;
+ }
+
+ FX_BOOL Identical(CPDF_Name* pOther) const
+ {
+ return m_Name == pOther->m_Name;
+ }
+protected:
+
+ CFX_ByteString m_Name;
+ friend class CPDF_Object;
+};
+class CPDF_Array : public CPDF_Object
+{
+public:
+
+ static CPDF_Array* Create()
+ {
+ return FX_NEW CPDF_Array();
+ }
+
+ CPDF_Array()
+ {
+ m_Type = PDFOBJ_ARRAY;
+ }
+
+ FX_DWORD GetCount() const
+ {
+ return m_Objects.GetSize();
+ }
+
+ CPDF_Object* GetElement(FX_DWORD index) const;
+
+ CPDF_Object* GetElementValue(FX_DWORD index) const;
+
+
+
+ CFX_AffineMatrix GetMatrix();
+
+ CFX_FloatRect GetRect();
+
+
+
+
+ CFX_ByteString GetString(FX_DWORD index) const;
+
+ CFX_ByteStringC GetConstString(FX_DWORD index) const;
+
+ int GetInteger(FX_DWORD index) const;
+
+ FX_FLOAT GetNumber(FX_DWORD index) const;
+
+ CPDF_Dictionary* GetDict(FX_DWORD index) const;
+
+ CPDF_Stream* GetStream(FX_DWORD index) const;
+
+ CPDF_Array* GetArray(FX_DWORD index) const;
+
+ FX_FLOAT GetFloat(FX_DWORD index) const
+ {
+ return GetNumber(index);
+ }
+
+
+
+
+ void SetAt(FX_DWORD index, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
+
+
+ void InsertAt(FX_DWORD index, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
+
+ void RemoveAt(FX_DWORD index);
+
+
+ void Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
+
+
+
+ void AddNumber(FX_FLOAT f);
+
+ void AddInteger(int i);
+
+ void AddString(const CFX_ByteString& str);
+
+ void AddName(const CFX_ByteString& str);
+
+ void AddReference(CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
+
+ void AddReference(CPDF_IndirectObjects* pDoc, CPDF_Object* obj)
+ {
+ AddReference(pDoc, obj->GetObjNum());
+ }
+
+
+ FX_FLOAT GetNumber16(FX_DWORD index) const
+ {
+ return GetNumber(index);
+ }
+
+ void AddNumber16(FX_FLOAT value)
+ {
+ AddNumber(value);
+ }
+
+ FX_BOOL Identical(CPDF_Array* pOther) const;
+protected:
+
+ ~CPDF_Array();
+
+ CFX_PtrArray m_Objects;
+ friend class CPDF_Object;
+};
+class CPDF_Dictionary : public CPDF_Object
+{
+public:
+
+ static CPDF_Dictionary* Create()
+ {
+ return FX_NEW CPDF_Dictionary();
+ }
+
+ CPDF_Dictionary()
+ {
+ m_Type = PDFOBJ_DICTIONARY;
+ }
+
+
+
+ CPDF_Object* GetElement(FX_BSTR key) const;
+
+ CPDF_Object* GetElementValue(FX_BSTR key) const;
+
+
+
+
+
+ CFX_ByteString GetString(FX_BSTR key) const;
+
+ CFX_ByteStringC GetConstString(FX_BSTR key) const;
+
+ CFX_ByteString GetString(FX_BSTR key, FX_BSTR default_str) const;
+
+ CFX_ByteStringC GetConstString(FX_BSTR key, FX_BSTR default_str) const;
+
+ CFX_WideString GetUnicodeText(FX_BSTR key, CFX_CharMap* pCharMap = NULL) const;
+
+ int GetInteger(FX_BSTR key) const;
+
+ int GetInteger(FX_BSTR key, int default_int) const;
+
+ FX_BOOL GetBoolean(FX_BSTR key, FX_BOOL bDefault = FALSE) const;
+
+ FX_FLOAT GetNumber(FX_BSTR key) const;
+
+ CPDF_Dictionary* GetDict(FX_BSTR key) const;
+
+ CPDF_Stream* GetStream(FX_BSTR key) const;
+
+ CPDF_Array* GetArray(FX_BSTR key) const;
+
+ CFX_FloatRect GetRect(FX_BSTR key) const;
+
+ CFX_AffineMatrix GetMatrix(FX_BSTR key) const;
+
+ FX_FLOAT GetFloat(FX_BSTR key) const
+ {
+ return GetNumber(key);
+ }
+
+
+ FX_BOOL KeyExist(FX_BSTR key) const;
+
+ FX_POSITION GetStartPos() const;
+
+ CPDF_Object* GetNextElement(FX_POSITION& pos, CFX_ByteString& key) const;
+
+ void SetAt(FX_BSTR key, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL);
+
+
+
+ void SetAtName(FX_BSTR key, const CFX_ByteString& name);
+
+
+ void SetAtString(FX_BSTR key, const CFX_ByteString& string);
+
+
+ void SetAtInteger(FX_BSTR key, int i);
+
+
+ void SetAtNumber(FX_BSTR key, FX_FLOAT f);
+
+ void SetAtReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
+
+ void SetAtReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, CPDF_Object* obj)
+ {
+ SetAtReference(key, pDoc, obj->GetObjNum());
+ }
+
+ void AddReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
+
+ void AddReference(FX_BSTR key, CPDF_IndirectObjects* pDoc, CPDF_Object* obj)
+ {
+ AddReference(key, pDoc, obj->GetObjNum());
+ }
+
+ void SetAtRect(FX_BSTR key, const CFX_FloatRect& rect);
+
+ void SetAtMatrix(FX_BSTR key, const CFX_AffineMatrix& matrix);
+
+ void SetAtBoolean(FX_BSTR key, FX_BOOL bValue);
+
+
+
+ void RemoveAt(FX_BSTR key);
+
+
+ void ReplaceKey(FX_BSTR oldkey, FX_BSTR newkey);
+
+ FX_BOOL Identical(CPDF_Dictionary* pDict) const;
+
+ int GetCount() const
+ {
+ return m_Map.GetCount();
+ }
+
+ void AddValue(FX_BSTR key, CPDF_Object* pObj);
+protected:
+
+ ~CPDF_Dictionary();
+
+ CFX_CMapByteStringToPtr m_Map;
+
+ friend class CPDF_Object;
+};
+class CPDF_Stream : public CPDF_Object
+{
+public:
+
+ static CPDF_Stream* Create(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict)
+ {
+ return FX_NEW CPDF_Stream(pData, size, pDict);
+ }
+
+ CPDF_Stream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict);
+
+ CPDF_Dictionary* GetDict() const
+ {
+ return m_pDict;
+ }
+
+ void SetData(FX_LPCBYTE pData, FX_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf);
+
+ void InitStream(FX_BYTE* pData, FX_DWORD size, CPDF_Dictionary* pDict);
+
+ void InitStream(IFX_FileRead *pFile, CPDF_Dictionary* pDict);
+
+ FX_BOOL Identical(CPDF_Stream* pOther) const;
+
+ CPDF_StreamFilter* GetStreamFilter(FX_BOOL bRaw = FALSE) const;
+
+
+
+ FX_DWORD GetRawSize() const
+ {
+ return m_dwSize;
+ }
+
+ FX_BOOL ReadRawData(FX_FILESIZE start_pos, FX_LPBYTE pBuf, FX_DWORD buf_size) const;
+
+
+ FX_BOOL IsMemoryBased() const
+ {
+ return m_GenNum == (FX_DWORD) - 1;
+ }
+
+ CPDF_Stream* Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpfCallback, FX_LPVOID pUserData) const;
+protected:
+
+ ~CPDF_Stream();
+
+ CPDF_Dictionary* m_pDict;
+
+ FX_DWORD m_dwSize;
+
+ FX_DWORD m_GenNum;
+
+ union {
+
+ FX_LPBYTE m_pDataBuf;
+
+ IFX_FileRead* m_pFile;
+ };
+
+ FX_FILESIZE m_FileOffset;
+
+ CPDF_CryptoHandler* m_pCryptoHandler;
+
+ void InitStream(CPDF_Dictionary* pDict);
+ friend class CPDF_Object;
+ friend class CPDF_StreamAcc;
+ friend class CPDF_AttachmentAcc;
+};
+class CPDF_StreamAcc : public CFX_Object
+{
+public:
+
+ CPDF_StreamAcc();
+
+ ~CPDF_StreamAcc();
+
+ void LoadAllData(const CPDF_Stream* pStream, FX_BOOL bRawAccess = FALSE,
+ FX_DWORD estimated_size = 0, FX_BOOL bImageAcc = FALSE);
+
+ const CPDF_Stream* GetStream() const
+ {
+ return m_pStream;
+ }
+
+ CPDF_Dictionary* GetDict() const
+ {
+ return m_pStream->GetDict();
+ }
+
+ FX_LPCBYTE GetData() const;
+
+ FX_DWORD GetSize() const;
+
+ FX_LPBYTE DetachData();
+
+ const CFX_ByteString& GetImageDecoder()
+ {
+ return m_ImageDecoder;
+ }
+
+ const CPDF_Dictionary* GetImageParam()
+ {
+ return m_pImageParam;
+ }
+protected:
+
+ FX_LPBYTE m_pData;
+
+ FX_DWORD m_dwSize;
+
+ FX_BOOL m_bNewBuf;
+
+ CFX_ByteString m_ImageDecoder;
+
+ CPDF_Dictionary* m_pImageParam;
+
+ const CPDF_Stream* m_pStream;
+
+ FX_LPBYTE m_pSrcData;
+};
+CFX_DataFilter* FPDF_CreateFilter(FX_BSTR name, const CPDF_Dictionary* pParam, int width = 0, int height = 0);
+#define FPDF_FILTER_BUFFER_SIZE 20480
+class CPDF_StreamFilter : public CFX_Object
+{
+public:
+
+ ~CPDF_StreamFilter();
+
+ FX_DWORD ReadBlock(FX_LPBYTE buffer, FX_DWORD size);
+
+ FX_DWORD GetSrcPos()
+ {
+ return m_SrcOffset;
+ }
+
+ const CPDF_Stream* GetStream()
+ {
+ return m_pStream;
+ }
+protected:
+
+ CPDF_StreamFilter() {}
+
+ FX_DWORD ReadLeftOver(FX_LPBYTE buffer, FX_DWORD buf_size);
+
+ const CPDF_Stream* m_pStream;
+
+ CFX_DataFilter* m_pFilter;
+
+ CFX_BinaryBuf* m_pBuffer;
+
+ FX_DWORD m_BufOffset;
+
+ FX_DWORD m_SrcOffset;
+
+ FX_BYTE m_SrcBuffer[FPDF_FILTER_BUFFER_SIZE];
+ friend class CPDF_Stream;
+};
+class CPDF_Null : public CPDF_Object
+{
+public:
+
+ static CPDF_Null* Create()
+ {
+ return FX_NEW CPDF_Null();
+ }
+
+ CPDF_Null()
+ {
+ m_Type = PDFOBJ_NULL;
+ }
+};
+class CPDF_Reference : public CPDF_Object
+{
+public:
+
+ static CPDF_Reference* Create(CPDF_IndirectObjects* pDoc, int objnum)
+ {
+ return FX_NEW CPDF_Reference(pDoc, objnum);
+ }
+
+ CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum)
+ {
+ m_Type = PDFOBJ_REFERENCE;
+ m_pObjList = pDoc;
+ m_RefObjNum = objnum;
+ }
+
+ CPDF_IndirectObjects* GetObjList() const
+ {
+ return m_pObjList;
+ }
+
+ FX_DWORD GetRefObjNum() const
+ {
+ return m_RefObjNum;
+ }
+
+ void SetRef(CPDF_IndirectObjects* pDoc, FX_DWORD objnum);
+
+ FX_BOOL Identical(CPDF_Reference* pOther) const
+ {
+ return m_RefObjNum == pOther->m_RefObjNum;
+ }
+protected:
+
+ CPDF_IndirectObjects* m_pObjList;
+
+ FX_DWORD m_RefObjNum;
+ friend class CPDF_Object;
+};
+class CPDF_IndirectObjects : public CFX_Object
+{
+public:
+
+ CPDF_IndirectObjects(IPDF_DocParser* pParser);
+
+ ~CPDF_IndirectObjects();
+
+ CPDF_Object* GetIndirectObject(FX_DWORD objnum, struct PARSE_CONTEXT* pContext = NULL);
+
+ int GetIndirectType(FX_DWORD objnum);
+
+ FX_DWORD AddIndirectObject(CPDF_Object* pObj);
+
+ void ReleaseIndirectObject(FX_DWORD objnum);
+
+ void InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pObj);
+
+ FX_DWORD GetLastObjNum() const;
+
+ FX_POSITION GetStartPosition() const
+ {
+ return m_IndirectObjs.GetStartPosition();
+ }
+
+ void GetNextAssoc(FX_POSITION& rPos, FX_DWORD& objnum, CPDF_Object*& pObject) const
+ {
+ m_IndirectObjs.GetNextAssoc(rPos, (void*&)objnum, (void*&)pObject);
+ }
+protected:
+
+ CFX_MapPtrToPtr m_IndirectObjs;
+
+ IPDF_DocParser* m_pParser;
+
+ FX_DWORD m_LastObjNum;
+};
+#endif
diff --git a/core/include/fpdfapi/fpdf_page.h b/core/include/fpdfapi/fpdf_page.h
index 29b8c684a8..3fea866730 100644
--- a/core/include/fpdfapi/fpdf_page.h
+++ b/core/include/fpdfapi/fpdf_page.h
@@ -1,249 +1,249 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_PAGE_
-#define _FPDF_PAGE_
-#ifndef _FPDF_PARSER_
-#include "fpdf_parser.h"
-#endif
-#ifndef _FPDF_RESOURCE_
-#include "fpdf_resource.h"
-#endif
-#ifndef _FX_DIB_H_
-#include "../fxge/fx_dib.h"
-#endif
-class CPDF_PageObjects;
-class CPDF_Page;
-class CPDF_Form;
-class CPDF_ParseOptions;
-class CPDF_PageObject;
-class CPDF_PageRenderCache;
-class CPDF_StreamFilter;
-class CPDF_AllStates;
-class CPDF_ContentParser;
-class CPDF_StreamContentParser;
-class CPDF_ResourceNaming;
-#define PDFTRANS_GROUP 0x0100
-#define PDFTRANS_ISOLATED 0x0200
-#define PDFTRANS_KNOCKOUT 0x0400
-#define PDF_CONTENT_NOT_PARSED 0
-#define PDF_CONTENT_PARSING 1
-#define PDF_CONTENT_PARSED 2
-class CPDF_PageObjects : public CFX_Object
-{
-public:
-
- CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE);
-
- ~CPDF_PageObjects();
-
-
-
-
- void ContinueParse(IFX_Pause* pPause);
-
- int GetParseState() const
- {
- return m_ParseState;
- }
-
- FX_BOOL IsParsed() const
- {
- return m_ParseState == PDF_CONTENT_PARSED;
- }
-
- int EstimateParseProgress() const;
-
-
-
-
- FX_POSITION GetFirstObjectPosition() const
- {
- return m_ObjectList.GetHeadPosition();
- }
-
- FX_POSITION GetLastObjectPosition() const
- {
- return m_ObjectList.GetTailPosition();
- }
-
- CPDF_PageObject* GetNextObject(FX_POSITION& pos) const
- {
- return (CPDF_PageObject*)m_ObjectList.GetNext(pos);
- }
-
- CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const
- {
- return (CPDF_PageObject*)m_ObjectList.GetPrev(pos);
- }
-
- CPDF_PageObject* GetObjectAt(FX_POSITION pos) const
- {
- return (CPDF_PageObject*)m_ObjectList.GetAt(pos);
- }
-
- FX_DWORD CountObjects() const
- {
- return m_ObjectList.GetCount();
- }
-
- int GetObjectIndex(CPDF_PageObject* pObj) const;
-
- CPDF_PageObject* GetObjectByIndex(int index) const;
-
-
-
-
-
- FX_POSITION InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject);
-
- void Transform(const CFX_AffineMatrix& matrix);
-
- FX_BOOL BackgroundAlphaNeeded() const
- {
- return m_bBackgroundAlphaNeeded;
- }
-
- CFX_FloatRect CalcBoundingBox() const;
-
- CPDF_Dictionary* m_pFormDict;
-
- CPDF_Stream* m_pFormStream;
-
- CPDF_Document* m_pDocument;
-
- CPDF_Dictionary* m_pPageResources;
-
- CPDF_Dictionary* m_pResources;
-
- CFX_FloatRect m_BBox;
-
- int m_Transparency;
-
-protected:
- friend class CPDF_ContentParser;
- friend class CPDF_StreamContentParser;
- friend class CPDF_AllStates;
-
- CFX_PtrList m_ObjectList;
-
- FX_BOOL m_bBackgroundAlphaNeeded;
-
- FX_BOOL m_bReleaseMembers;
- void LoadTransInfo();
- void ClearCacheObjects();
-
- CPDF_ContentParser* m_pParser;
-
- FX_BOOL m_ParseState;
-};
-class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData
-{
-public:
-
- CPDF_Page();
-
- ~CPDF_Page();
-
- void Load(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, FX_BOOL bPageCache = TRUE);
-
- void StartParse(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE);
-
- void ParseContent(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE);
-
- void GetDisplayMatrix(CFX_AffineMatrix& matrix, int xPos, int yPos,
- int xSize, int ySize, int iRotate) const;
-
- FX_FLOAT GetPageWidth() const
- {
- return m_PageWidth;
- }
-
- FX_FLOAT GetPageHeight() const
- {
- return m_PageHeight;
- }
-
- CFX_FloatRect GetPageBBox() const
- {
- return m_BBox;
- }
-
- const CFX_AffineMatrix& GetPageMatrix() const
- {
- return m_PageMatrix;
- }
-
- CPDF_Object* GetPageAttr(FX_BSTR name) const;
-
-
-
- CPDF_PageRenderCache* GetRenderCache() const
- {
- return m_pPageRender;
- }
-
- void ClearRenderCache();
-
-protected:
- friend class CPDF_ContentParser;
-
- FX_FLOAT m_PageWidth;
-
- FX_FLOAT m_PageHeight;
-
- CFX_AffineMatrix m_PageMatrix;
-
- CPDF_PageRenderCache* m_pPageRender;
-};
-class CPDF_ParseOptions : public CFX_Object
-{
-public:
-
- CPDF_ParseOptions();
-
- FX_BOOL m_bTextOnly;
-
- FX_BOOL m_bMarkedContent;
-
- FX_BOOL m_bSeparateForm;
-
- FX_BOOL m_bDecodeInlineImage;
-};
-class CPDF_Form : public CPDF_PageObjects
-{
-public:
-
- CPDF_Form(CPDF_Document* pDocument, CPDF_Dictionary* pPageResources, CPDF_Stream* pFormStream, CPDF_Dictionary* pParentResources = NULL);
-
- ~CPDF_Form();
-
- void StartParse(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
- CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level = 0);
-
- void ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
- CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level = 0);
-
- CPDF_Form* Clone() const;
-};
-class CPDF_PageContentGenerate : public CFX_Object
-{
-public:
- CPDF_PageContentGenerate(CPDF_Page* pPage);
- ~CPDF_PageContentGenerate();
- FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject);
- void GenerateContent();
- void TransformContent(CFX_Matrix& matrix);
-protected:
- void ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageObj);
- void ProcessForm(CFX_ByteTextBuf& buf, FX_LPCBYTE data, FX_DWORD size, CFX_Matrix& matrix);
- CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, const FX_CHAR* szType);
-private:
- CPDF_Page* m_pPage;
- CPDF_Document* m_pDocument;
- CFX_PtrArray m_pageObjects;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_PAGE_
+#define _FPDF_PAGE_
+#ifndef _FPDF_PARSER_
+#include "fpdf_parser.h"
+#endif
+#ifndef _FPDF_RESOURCE_
+#include "fpdf_resource.h"
+#endif
+#ifndef _FX_DIB_H_
+#include "../fxge/fx_dib.h"
+#endif
+class CPDF_PageObjects;
+class CPDF_Page;
+class CPDF_Form;
+class CPDF_ParseOptions;
+class CPDF_PageObject;
+class CPDF_PageRenderCache;
+class CPDF_StreamFilter;
+class CPDF_AllStates;
+class CPDF_ContentParser;
+class CPDF_StreamContentParser;
+class CPDF_ResourceNaming;
+#define PDFTRANS_GROUP 0x0100
+#define PDFTRANS_ISOLATED 0x0200
+#define PDFTRANS_KNOCKOUT 0x0400
+#define PDF_CONTENT_NOT_PARSED 0
+#define PDF_CONTENT_PARSING 1
+#define PDF_CONTENT_PARSED 2
+class CPDF_PageObjects : public CFX_Object
+{
+public:
+
+ CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE);
+
+ ~CPDF_PageObjects();
+
+
+
+
+ void ContinueParse(IFX_Pause* pPause);
+
+ int GetParseState() const
+ {
+ return m_ParseState;
+ }
+
+ FX_BOOL IsParsed() const
+ {
+ return m_ParseState == PDF_CONTENT_PARSED;
+ }
+
+ int EstimateParseProgress() const;
+
+
+
+
+ FX_POSITION GetFirstObjectPosition() const
+ {
+ return m_ObjectList.GetHeadPosition();
+ }
+
+ FX_POSITION GetLastObjectPosition() const
+ {
+ return m_ObjectList.GetTailPosition();
+ }
+
+ CPDF_PageObject* GetNextObject(FX_POSITION& pos) const
+ {
+ return (CPDF_PageObject*)m_ObjectList.GetNext(pos);
+ }
+
+ CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const
+ {
+ return (CPDF_PageObject*)m_ObjectList.GetPrev(pos);
+ }
+
+ CPDF_PageObject* GetObjectAt(FX_POSITION pos) const
+ {
+ return (CPDF_PageObject*)m_ObjectList.GetAt(pos);
+ }
+
+ FX_DWORD CountObjects() const
+ {
+ return m_ObjectList.GetCount();
+ }
+
+ int GetObjectIndex(CPDF_PageObject* pObj) const;
+
+ CPDF_PageObject* GetObjectByIndex(int index) const;
+
+
+
+
+
+ FX_POSITION InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject);
+
+ void Transform(const CFX_AffineMatrix& matrix);
+
+ FX_BOOL BackgroundAlphaNeeded() const
+ {
+ return m_bBackgroundAlphaNeeded;
+ }
+
+ CFX_FloatRect CalcBoundingBox() const;
+
+ CPDF_Dictionary* m_pFormDict;
+
+ CPDF_Stream* m_pFormStream;
+
+ CPDF_Document* m_pDocument;
+
+ CPDF_Dictionary* m_pPageResources;
+
+ CPDF_Dictionary* m_pResources;
+
+ CFX_FloatRect m_BBox;
+
+ int m_Transparency;
+
+protected:
+ friend class CPDF_ContentParser;
+ friend class CPDF_StreamContentParser;
+ friend class CPDF_AllStates;
+
+ CFX_PtrList m_ObjectList;
+
+ FX_BOOL m_bBackgroundAlphaNeeded;
+
+ FX_BOOL m_bReleaseMembers;
+ void LoadTransInfo();
+ void ClearCacheObjects();
+
+ CPDF_ContentParser* m_pParser;
+
+ FX_BOOL m_ParseState;
+};
+class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData
+{
+public:
+
+ CPDF_Page();
+
+ ~CPDF_Page();
+
+ void Load(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, FX_BOOL bPageCache = TRUE);
+
+ void StartParse(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE);
+
+ void ParseContent(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE);
+
+ void GetDisplayMatrix(CFX_AffineMatrix& matrix, int xPos, int yPos,
+ int xSize, int ySize, int iRotate) const;
+
+ FX_FLOAT GetPageWidth() const
+ {
+ return m_PageWidth;
+ }
+
+ FX_FLOAT GetPageHeight() const
+ {
+ return m_PageHeight;
+ }
+
+ CFX_FloatRect GetPageBBox() const
+ {
+ return m_BBox;
+ }
+
+ const CFX_AffineMatrix& GetPageMatrix() const
+ {
+ return m_PageMatrix;
+ }
+
+ CPDF_Object* GetPageAttr(FX_BSTR name) const;
+
+
+
+ CPDF_PageRenderCache* GetRenderCache() const
+ {
+ return m_pPageRender;
+ }
+
+ void ClearRenderCache();
+
+protected:
+ friend class CPDF_ContentParser;
+
+ FX_FLOAT m_PageWidth;
+
+ FX_FLOAT m_PageHeight;
+
+ CFX_AffineMatrix m_PageMatrix;
+
+ CPDF_PageRenderCache* m_pPageRender;
+};
+class CPDF_ParseOptions : public CFX_Object
+{
+public:
+
+ CPDF_ParseOptions();
+
+ FX_BOOL m_bTextOnly;
+
+ FX_BOOL m_bMarkedContent;
+
+ FX_BOOL m_bSeparateForm;
+
+ FX_BOOL m_bDecodeInlineImage;
+};
+class CPDF_Form : public CPDF_PageObjects
+{
+public:
+
+ CPDF_Form(CPDF_Document* pDocument, CPDF_Dictionary* pPageResources, CPDF_Stream* pFormStream, CPDF_Dictionary* pParentResources = NULL);
+
+ ~CPDF_Form();
+
+ void StartParse(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
+ CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level = 0);
+
+ void ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
+ CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level = 0);
+
+ CPDF_Form* Clone() const;
+};
+class CPDF_PageContentGenerate : public CFX_Object
+{
+public:
+ CPDF_PageContentGenerate(CPDF_Page* pPage);
+ ~CPDF_PageContentGenerate();
+ FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject);
+ void GenerateContent();
+ void TransformContent(CFX_Matrix& matrix);
+protected:
+ void ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageObj);
+ void ProcessForm(CFX_ByteTextBuf& buf, FX_LPCBYTE data, FX_DWORD size, CFX_Matrix& matrix);
+ CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, const FX_CHAR* szType);
+private:
+ CPDF_Page* m_pPage;
+ CPDF_Document* m_pDocument;
+ CFX_PtrArray m_pageObjects;
+};
+#endif
diff --git a/core/include/fpdfapi/fpdf_pageobj.h b/core/include/fpdfapi/fpdf_pageobj.h
index 1e82680907..90e1b0b90b 100644
--- a/core/include/fpdfapi/fpdf_pageobj.h
+++ b/core/include/fpdfapi/fpdf_pageobj.h
@@ -1,721 +1,721 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_PAGEOBJ_H_
-#define _FPDF_PAGEOBJ_H_
-#ifndef _FPDF_RESOURCE_
-#include "fpdf_resource.h"
-#endif
-#ifndef _FX_GE_H_
-#include "../fxge/fx_ge.h"
-#endif
-class CPDF_Path;
-class CPDF_ClipPathData;
-class CPDF_ClipPath;
-class CPDF_ColorStateData;
-class CPDF_ColorState;
-class CPDF_GraphState;
-class CPDF_TextStateData;
-class CPDF_TextState;
-class CPDF_GeneralStateData;
-class CPDF_GeneralState;
-class CPDF_ContentMarkItem;
-class CPDF_ContentMark;
-class CPDF_GraphicStates;
-class CPDF_PageObject;
-class CPDF_TextObject;
-class CPDF_PathObject;
-class CPDF_ImageObject;
-class CPDF_ShadingObject;
-class CPDF_FormObject;
-class CPDF_InlineImages;
-typedef CFX_PathData CPDF_PathData;
-class CPDF_Path : public CFX_CountRef<CFX_PathData>
-{
-public:
-
-
-
-
- int GetPointCount()
- {
- return m_pObject->m_PointCount;
- }
-
- int GetFlag(int index)
- {
- return m_pObject->m_pPoints[index].m_Flag;
- }
-
- FX_FLOAT GetPointX(int index)
- {
- return m_pObject->m_pPoints[index].m_PointX;
- }
-
- FX_FLOAT GetPointY(int index)
- {
- return m_pObject->m_pPoints[index].m_PointY;
- }
-
-
-
-
- FX_PATHPOINT* GetPoints()
- {
- return m_pObject->m_pPoints;
- }
-
-
- CFX_FloatRect GetBoundingBox() const
- {
- return m_pObject->GetBoundingBox();
- }
-
- CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const
- {
- return m_pObject->GetBoundingBox(line_width, miter_limit);
- }
-
- void Transform(const CFX_AffineMatrix* pMatrix)
- {
- GetModify()->Transform(pMatrix);
- }
-
- void Append(CPDF_Path src, const CFX_AffineMatrix* pMatrix)
- {
- m_pObject->Append(src.m_pObject, pMatrix);
- }
-
- void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
- {
- m_pObject->AppendRect(left, bottom, right, top);
- }
-
- FX_BOOL IsRect() const
- {
- return m_pObject->IsRect();
- }
-};
-class CPDF_ClipPathData : public CFX_Object
-{
-public:
-
- CPDF_ClipPathData();
-
- CPDF_ClipPathData(const CPDF_ClipPathData&);
-
- ~CPDF_ClipPathData();
-
- void SetCount(int path_count, int text_count);
-public:
-
- int m_PathCount;
-
- CPDF_Path* m_pPathList;
-
- FX_BYTE* m_pTypeList;
-
- int m_TextCount;
-
- CPDF_TextObject** m_pTextList;
-};
-class CPDF_ClipPath : public CFX_CountRef<CPDF_ClipPathData>
-{
-public:
-
- FX_DWORD GetPathCount() const
- {
- return m_pObject->m_PathCount;
- }
-
- CPDF_Path GetPath(int i) const
- {
- return m_pObject->m_pPathList[i];
- }
-
- int GetClipType(int i) const
- {
- return m_pObject->m_pTypeList[i];
- }
-
- FX_DWORD GetTextCount() const
- {
- return m_pObject->m_TextCount;
- }
-
- CPDF_TextObject* GetText(int i) const
- {
- return m_pObject->m_pTextList[i];
- }
-
- CFX_FloatRect GetClipBox() const;
-
- void AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
-
- void DeletePath(int layer_index);
-
- void AppendTexts(CPDF_TextObject** pTexts, int count);
-
- void Transform(const CFX_AffineMatrix& matrix);
-};
-class CPDF_ColorStateData : public CFX_Object
-{
-public:
-
- CPDF_ColorStateData() {}
-
- CPDF_ColorStateData(const CPDF_ColorStateData& src);
-
- void Default();
-
- CPDF_Color m_FillColor;
-
- FX_DWORD m_FillRGB;
-
- CPDF_Color m_StrokeColor;
-
- FX_DWORD m_StrokeRGB;
-};
-class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData>
-{
-public:
-
- CPDF_Color* GetFillColor() const
- {
- return m_pObject ? &m_pObject->m_FillColor : NULL;
- }
-
- CPDF_Color* GetStrokeColor() const
- {
- return m_pObject ? &m_pObject->m_StrokeColor : NULL;
- }
-
- void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
-
- void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
-
- void SetFillPattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);
-
- void SetStrokePattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);
-private:
- void SetColor(CPDF_Color& color, FX_DWORD& rgb, CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
-};
-typedef CFX_GraphStateData CPDF_GraphStateData;
-class CPDF_GraphState : public CFX_CountRef<CFX_GraphStateData>
-{
-public:
-};
-class CPDF_TextStateData : public CFX_Object
-{
-public:
-
- CPDF_TextStateData();
-
- CPDF_TextStateData(const CPDF_TextStateData& src);
-
- ~CPDF_TextStateData();
-
- CPDF_Font* m_pFont;
-
- FX_FLOAT m_FontSize;
-
- FX_FLOAT m_CharSpace;
-
- FX_FLOAT m_WordSpace;
-
- FX_FLOAT m_Matrix[4];
-
- int m_TextMode;
-
- FX_FLOAT m_CTM[4];
-};
-class CPDF_TextState : public CFX_CountRef<CPDF_TextStateData>
-{
-public:
-
- CPDF_Font* GetFont() const
- {
- return m_pObject->m_pFont;
- }
-
- void SetFont(CPDF_Font* pFont);
-
- FX_FLOAT GetFontSize() const
- {
- return m_pObject->m_FontSize;
- }
-
- FX_FLOAT* GetMatrix() const
- {
- return m_pObject->m_Matrix;
- }
-
-
-
- FX_FLOAT GetFontSizeV() const;
-
- FX_FLOAT GetFontSizeH() const;
-
- FX_FLOAT GetBaselineAngle() const;
-
- FX_FLOAT GetShearAngle() const;
-
-};
-class CPDF_TransferFunc;
-class CPDF_GeneralStateData : public CFX_Object
-{
-public:
-
- CPDF_GeneralStateData();
-
- CPDF_GeneralStateData(const CPDF_GeneralStateData& src);
- ~CPDF_GeneralStateData();
-
- void SetBlendMode(FX_BSTR blend_mode);
-
- char m_BlendMode[16];
-
- int m_BlendType;
-
- CPDF_Object* m_pSoftMask;
-
- FX_FLOAT m_SMaskMatrix[6];
-
- FX_FLOAT m_StrokeAlpha;
-
- FX_FLOAT m_FillAlpha;
-
- CPDF_Object* m_pTR;
-
- CPDF_TransferFunc* m_pTransferFunc;
-
- CFX_Matrix m_Matrix;
-
- int m_RenderIntent;
-
- FX_BOOL m_StrokeAdjust;
-
- FX_BOOL m_AlphaSource;
-
- FX_BOOL m_TextKnockout;
-
- FX_BOOL m_StrokeOP;
-
- FX_BOOL m_FillOP;
-
- int m_OPMode;
-
- CPDF_Object* m_pBG;
-
- CPDF_Object* m_pUCR;
-
- CPDF_Object* m_pHT;
-
- FX_FLOAT m_Flatness;
-
- FX_FLOAT m_Smoothness;
-};
-class CPDF_GeneralState : public CFX_CountRef<CPDF_GeneralStateData>
-{
-public:
-
- void SetRenderIntent(const CFX_ByteString& ri);
-
- int GetBlendType() const
- {
- return m_pObject ? m_pObject->m_BlendType : FXDIB_BLEND_NORMAL;
- }
-
- int GetAlpha(FX_BOOL bStroke) const
- {
- return m_pObject ? FXSYS_round((bStroke ? m_pObject->m_StrokeAlpha : m_pObject->m_FillAlpha) * 255) : 255;
- }
-};
-class CPDF_ContentMarkItem : public CFX_Object
-{
-public:
-
- typedef enum {
- None,
- PropertiesDict,
- DirectDict,
- MCID
- } ParamType;
-
- CPDF_ContentMarkItem();
-
- CPDF_ContentMarkItem(const CPDF_ContentMarkItem& src);
-
- ~CPDF_ContentMarkItem();
-
- inline const CFX_ByteString& GetName() const
- {
- return m_MarkName;
- }
-
- inline ParamType GetParamType() const
- {
- return m_ParamType;
- }
-
- inline void* GetParam() const
- {
- return m_pParam;
- }
-
- inline FX_BOOL HasMCID() const;
-
- inline void SetName(const CFX_ByteString& name)
- {
- m_MarkName = name;
- }
-
- inline void SetParam(ParamType type, void* param)
- {
- m_ParamType = type;
- m_pParam = param;
- }
-private:
-
- CFX_ByteString m_MarkName;
-
- ParamType m_ParamType;
-
- void* m_pParam;
-};
-class CPDF_ContentMarkData : public CFX_Object
-{
-public:
-
- CPDF_ContentMarkData() { }
-
- CPDF_ContentMarkData(const CPDF_ContentMarkData& src);
-
- inline int CountItems() const
- {
- return m_Marks.GetSize();
- }
-
- inline CPDF_ContentMarkItem& GetItem(int index) const
- {
- return m_Marks[index];
- }
-
- int GetMCID() const;
-
- void AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, FX_BOOL bDictNeedClone);
-
- void DeleteLastMark();
-private:
-
- CFX_ObjectArray<CPDF_ContentMarkItem> m_Marks;
-};
-class CPDF_ContentMark : public CFX_CountRef<CPDF_ContentMarkData>
-{
-public:
-
- int GetMCID() const
- {
- return m_pObject ? m_pObject->GetMCID() : -1;
- }
-
- FX_BOOL HasMark(FX_BSTR mark) const;
-
- FX_BOOL LookupMark(FX_BSTR mark, CPDF_Dictionary*& pDict) const;
-};
-#define PDFPAGE_TEXT 1
-#define PDFPAGE_PATH 2
-#define PDFPAGE_IMAGE 3
-#define PDFPAGE_SHADING 4
-#define PDFPAGE_FORM 5
-#define PDFPAGE_INLINES 6
-class CPDF_GraphicStates : public CFX_Object
-{
-public:
-
- void CopyStates(const CPDF_GraphicStates& src);
-
- void DefaultStates();
-
- CPDF_ClipPath m_ClipPath;
-
- CPDF_GraphState m_GraphState;
-
- CPDF_ColorState m_ColorState;
-
- CPDF_TextState m_TextState;
-
- CPDF_GeneralState m_GeneralState;
-};
-class CPDF_PageObject : public CPDF_GraphicStates
-{
-public:
-
- static CPDF_PageObject* Create(int type);
-
- void Release();
-
- CPDF_PageObject* Clone() const;
-
- void Copy(const CPDF_PageObject* pSrcObject);
-
- virtual void Transform(const CFX_AffineMatrix& matrix) = 0;
-
-
-
- void RemoveClipPath();
-
- void AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
-
- void CopyClipPath(CPDF_PageObject* pObj);
-
- void TransformClipPath(CFX_AffineMatrix& matrix);
-
- void TransformGeneralState(CFX_AffineMatrix& matrix);
-
-
- void SetColorState(CPDF_ColorState state)
- {
- m_ColorState = state;
- }
-
- FX_RECT GetBBox(const CFX_AffineMatrix* pMatrix) const;
-
- int m_Type;
-
- FX_FLOAT m_Left;
-
- FX_FLOAT m_Right;
-
- FX_FLOAT m_Top;
-
- FX_FLOAT m_Bottom;
-
- CPDF_ContentMark m_ContentMark;
-protected:
-
- virtual void CopyData(const CPDF_PageObject* pSrcObject) {}
-
- void RecalcBBox();
-
- CPDF_PageObject() {}
-
- virtual ~CPDF_PageObject() {}
-};
-struct CPDF_TextObjectItem : public CFX_Object {
-
- FX_DWORD m_CharCode;
-
- FX_FLOAT m_OriginX;
-
- FX_FLOAT m_OriginY;
-};
-class CPDF_TextObject : public CPDF_PageObject
-{
-public:
-
- CPDF_TextObject();
-
- virtual ~CPDF_TextObject();
-
- int CountItems() const
- {
- return m_nChars;
- }
-
- void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;
-
- int CountChars() const;
-
- void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const;
- void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;
-
- void GetCharRect(int index, CFX_FloatRect& rect) const;
-
-
- FX_FLOAT GetCharWidth(FX_DWORD charcode) const;
- FX_FLOAT GetSpaceCharWidth() const;
-
- FX_FLOAT GetPosX() const
- {
- return m_PosX;
- }
-
- FX_FLOAT GetPosY() const
- {
- return m_PosY;
- }
-
- void GetTextMatrix(CFX_AffineMatrix* pMatrix) const;
-
- CPDF_Font* GetFont() const
- {
- return m_TextState.GetFont();
- }
-
- FX_FLOAT GetFontSize() const
- {
- return m_TextState.GetFontSize();
- }
-
- void SetEmpty();
-
- void SetText(const CFX_ByteString& text);
-
- void SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
-
- void SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings);
-
- void SetPosition(FX_FLOAT x, FX_FLOAT y);
-
- void SetTextState(CPDF_TextState TextState);
- virtual void Transform(const CFX_AffineMatrix& matrix);
-
- void CalcCharPos(FX_FLOAT* pPosArray) const;
-
-
-
- void SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, FX_FLOAT x, FX_FLOAT y);
-
- void GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos)
- {
- nChars = m_nChars;
- pCharCodes = m_pCharCodes;
- pCharPos = m_pCharPos;
- }
-
-
- void RecalcPositionData()
- {
- CalcPositionData(NULL, NULL, 1);
- }
-protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObject);
-
- FX_FLOAT m_PosX;
-
- FX_FLOAT m_PosY;
-
- int m_nChars;
-
- FX_DWORD* m_pCharCodes;
-
- FX_FLOAT* m_pCharPos;
-
- void SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
-
- void CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextAdvanceY, FX_FLOAT horz_scale, int level = 0);
- friend class CPDF_StreamContentParser;
- friend class CPDF_RenderStatus;
- friend class CPDF_QuickDrawer;
- friend class CPDF_TextRenderer;
- friend class CTextPage;
- friend class CPDF_ContentGenerator;
-};
-class CPDF_PathObject : public CPDF_PageObject
-{
-public:
-
- CPDF_PathObject()
- {
- m_Type = PDFPAGE_PATH;
- }
-
- virtual ~CPDF_PathObject() {}
- virtual void Transform(const CFX_AffineMatrix& maxtrix);
-
- void SetGraphState(CPDF_GraphState GraphState);
-
- CPDF_Path m_Path;
-
- int m_FillType;
-
- FX_BOOL m_bStroke;
-
- CFX_AffineMatrix m_Matrix;
-
-
- void CalcBoundingBox();
-protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
-};
-class CPDF_ImageObject : public CPDF_PageObject
-{
-public:
-
- CPDF_ImageObject();
-
- virtual ~CPDF_ImageObject();
- virtual void Transform(const CFX_AffineMatrix& matrix);
-
- CPDF_Image* m_pImage;
-
- CFX_AffineMatrix m_Matrix;
-
- void CalcBoundingBox();
-private:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
-};
-class CPDF_ShadingObject : public CPDF_PageObject
-{
-public:
-
- CPDF_ShadingObject();
-
- virtual ~CPDF_ShadingObject();
-
- CPDF_ShadingPattern* m_pShading;
-
- CFX_AffineMatrix m_Matrix;
-
- CPDF_Page* m_pPage;
- virtual void Transform(const CFX_AffineMatrix& matrix);
-
- void CalcBoundingBox();
-protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
-};
-class CPDF_FormObject : public CPDF_PageObject
-{
-public:
-
- CPDF_FormObject()
- {
- m_Type = PDFPAGE_FORM;
- m_pForm = NULL;
- }
-
- virtual ~CPDF_FormObject();
- virtual void Transform(const CFX_AffineMatrix& matrix);
-
- CPDF_Form* m_pForm;
-
- CFX_AffineMatrix m_FormMatrix;
-
- void CalcBoundingBox();
-protected:
- virtual void CopyData(const CPDF_PageObject* pSrcObjet);
-};
-class CPDF_InlineImages : public CPDF_PageObject
-{
-public:
-
- CPDF_InlineImages();
-
- virtual ~CPDF_InlineImages();
-
- CPDF_Stream* m_pStream;
-
- CFX_DIBitmap* m_pBitmap;
-
- CFX_ArrayTemplate<CFX_AffineMatrix> m_Matrices;
-
- void AddMatrix(CFX_AffineMatrix& matrix);
-protected:
- virtual void Transform(const CFX_AffineMatrix& matrix) {}
- virtual void CopyData(const CPDF_PageObject* pSrcObjet) {}
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_PAGEOBJ_H_
+#define _FPDF_PAGEOBJ_H_
+#ifndef _FPDF_RESOURCE_
+#include "fpdf_resource.h"
+#endif
+#ifndef _FX_GE_H_
+#include "../fxge/fx_ge.h"
+#endif
+class CPDF_Path;
+class CPDF_ClipPathData;
+class CPDF_ClipPath;
+class CPDF_ColorStateData;
+class CPDF_ColorState;
+class CPDF_GraphState;
+class CPDF_TextStateData;
+class CPDF_TextState;
+class CPDF_GeneralStateData;
+class CPDF_GeneralState;
+class CPDF_ContentMarkItem;
+class CPDF_ContentMark;
+class CPDF_GraphicStates;
+class CPDF_PageObject;
+class CPDF_TextObject;
+class CPDF_PathObject;
+class CPDF_ImageObject;
+class CPDF_ShadingObject;
+class CPDF_FormObject;
+class CPDF_InlineImages;
+typedef CFX_PathData CPDF_PathData;
+class CPDF_Path : public CFX_CountRef<CFX_PathData>
+{
+public:
+
+
+
+
+ int GetPointCount()
+ {
+ return m_pObject->m_PointCount;
+ }
+
+ int GetFlag(int index)
+ {
+ return m_pObject->m_pPoints[index].m_Flag;
+ }
+
+ FX_FLOAT GetPointX(int index)
+ {
+ return m_pObject->m_pPoints[index].m_PointX;
+ }
+
+ FX_FLOAT GetPointY(int index)
+ {
+ return m_pObject->m_pPoints[index].m_PointY;
+ }
+
+
+
+
+ FX_PATHPOINT* GetPoints()
+ {
+ return m_pObject->m_pPoints;
+ }
+
+
+ CFX_FloatRect GetBoundingBox() const
+ {
+ return m_pObject->GetBoundingBox();
+ }
+
+ CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const
+ {
+ return m_pObject->GetBoundingBox(line_width, miter_limit);
+ }
+
+ void Transform(const CFX_AffineMatrix* pMatrix)
+ {
+ GetModify()->Transform(pMatrix);
+ }
+
+ void Append(CPDF_Path src, const CFX_AffineMatrix* pMatrix)
+ {
+ m_pObject->Append(src.m_pObject, pMatrix);
+ }
+
+ void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
+ {
+ m_pObject->AppendRect(left, bottom, right, top);
+ }
+
+ FX_BOOL IsRect() const
+ {
+ return m_pObject->IsRect();
+ }
+};
+class CPDF_ClipPathData : public CFX_Object
+{
+public:
+
+ CPDF_ClipPathData();
+
+ CPDF_ClipPathData(const CPDF_ClipPathData&);
+
+ ~CPDF_ClipPathData();
+
+ void SetCount(int path_count, int text_count);
+public:
+
+ int m_PathCount;
+
+ CPDF_Path* m_pPathList;
+
+ FX_BYTE* m_pTypeList;
+
+ int m_TextCount;
+
+ CPDF_TextObject** m_pTextList;
+};
+class CPDF_ClipPath : public CFX_CountRef<CPDF_ClipPathData>
+{
+public:
+
+ FX_DWORD GetPathCount() const
+ {
+ return m_pObject->m_PathCount;
+ }
+
+ CPDF_Path GetPath(int i) const
+ {
+ return m_pObject->m_pPathList[i];
+ }
+
+ int GetClipType(int i) const
+ {
+ return m_pObject->m_pTypeList[i];
+ }
+
+ FX_DWORD GetTextCount() const
+ {
+ return m_pObject->m_TextCount;
+ }
+
+ CPDF_TextObject* GetText(int i) const
+ {
+ return m_pObject->m_pTextList[i];
+ }
+
+ CFX_FloatRect GetClipBox() const;
+
+ void AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
+
+ void DeletePath(int layer_index);
+
+ void AppendTexts(CPDF_TextObject** pTexts, int count);
+
+ void Transform(const CFX_AffineMatrix& matrix);
+};
+class CPDF_ColorStateData : public CFX_Object
+{
+public:
+
+ CPDF_ColorStateData() {}
+
+ CPDF_ColorStateData(const CPDF_ColorStateData& src);
+
+ void Default();
+
+ CPDF_Color m_FillColor;
+
+ FX_DWORD m_FillRGB;
+
+ CPDF_Color m_StrokeColor;
+
+ FX_DWORD m_StrokeRGB;
+};
+class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData>
+{
+public:
+
+ CPDF_Color* GetFillColor() const
+ {
+ return m_pObject ? &m_pObject->m_FillColor : NULL;
+ }
+
+ CPDF_Color* GetStrokeColor() const
+ {
+ return m_pObject ? &m_pObject->m_StrokeColor : NULL;
+ }
+
+ void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
+
+ void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
+
+ void SetFillPattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);
+
+ void SetStrokePattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);
+private:
+ void SetColor(CPDF_Color& color, FX_DWORD& rgb, CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
+};
+typedef CFX_GraphStateData CPDF_GraphStateData;
+class CPDF_GraphState : public CFX_CountRef<CFX_GraphStateData>
+{
+public:
+};
+class CPDF_TextStateData : public CFX_Object
+{
+public:
+
+ CPDF_TextStateData();
+
+ CPDF_TextStateData(const CPDF_TextStateData& src);
+
+ ~CPDF_TextStateData();
+
+ CPDF_Font* m_pFont;
+
+ FX_FLOAT m_FontSize;
+
+ FX_FLOAT m_CharSpace;
+
+ FX_FLOAT m_WordSpace;
+
+ FX_FLOAT m_Matrix[4];
+
+ int m_TextMode;
+
+ FX_FLOAT m_CTM[4];
+};
+class CPDF_TextState : public CFX_CountRef<CPDF_TextStateData>
+{
+public:
+
+ CPDF_Font* GetFont() const
+ {
+ return m_pObject->m_pFont;
+ }
+
+ void SetFont(CPDF_Font* pFont);
+
+ FX_FLOAT GetFontSize() const
+ {
+ return m_pObject->m_FontSize;
+ }
+
+ FX_FLOAT* GetMatrix() const
+ {
+ return m_pObject->m_Matrix;
+ }
+
+
+
+ FX_FLOAT GetFontSizeV() const;
+
+ FX_FLOAT GetFontSizeH() const;
+
+ FX_FLOAT GetBaselineAngle() const;
+
+ FX_FLOAT GetShearAngle() const;
+
+};
+class CPDF_TransferFunc;
+class CPDF_GeneralStateData : public CFX_Object
+{
+public:
+
+ CPDF_GeneralStateData();
+
+ CPDF_GeneralStateData(const CPDF_GeneralStateData& src);
+ ~CPDF_GeneralStateData();
+
+ void SetBlendMode(FX_BSTR blend_mode);
+
+ char m_BlendMode[16];
+
+ int m_BlendType;
+
+ CPDF_Object* m_pSoftMask;
+
+ FX_FLOAT m_SMaskMatrix[6];
+
+ FX_FLOAT m_StrokeAlpha;
+
+ FX_FLOAT m_FillAlpha;
+
+ CPDF_Object* m_pTR;
+
+ CPDF_TransferFunc* m_pTransferFunc;
+
+ CFX_Matrix m_Matrix;
+
+ int m_RenderIntent;
+
+ FX_BOOL m_StrokeAdjust;
+
+ FX_BOOL m_AlphaSource;
+
+ FX_BOOL m_TextKnockout;
+
+ FX_BOOL m_StrokeOP;
+
+ FX_BOOL m_FillOP;
+
+ int m_OPMode;
+
+ CPDF_Object* m_pBG;
+
+ CPDF_Object* m_pUCR;
+
+ CPDF_Object* m_pHT;
+
+ FX_FLOAT m_Flatness;
+
+ FX_FLOAT m_Smoothness;
+};
+class CPDF_GeneralState : public CFX_CountRef<CPDF_GeneralStateData>
+{
+public:
+
+ void SetRenderIntent(const CFX_ByteString& ri);
+
+ int GetBlendType() const
+ {
+ return m_pObject ? m_pObject->m_BlendType : FXDIB_BLEND_NORMAL;
+ }
+
+ int GetAlpha(FX_BOOL bStroke) const
+ {
+ return m_pObject ? FXSYS_round((bStroke ? m_pObject->m_StrokeAlpha : m_pObject->m_FillAlpha) * 255) : 255;
+ }
+};
+class CPDF_ContentMarkItem : public CFX_Object
+{
+public:
+
+ typedef enum {
+ None,
+ PropertiesDict,
+ DirectDict,
+ MCID
+ } ParamType;
+
+ CPDF_ContentMarkItem();
+
+ CPDF_ContentMarkItem(const CPDF_ContentMarkItem& src);
+
+ ~CPDF_ContentMarkItem();
+
+ inline const CFX_ByteString& GetName() const
+ {
+ return m_MarkName;
+ }
+
+ inline ParamType GetParamType() const
+ {
+ return m_ParamType;
+ }
+
+ inline void* GetParam() const
+ {
+ return m_pParam;
+ }
+
+ inline FX_BOOL HasMCID() const;
+
+ inline void SetName(const CFX_ByteString& name)
+ {
+ m_MarkName = name;
+ }
+
+ inline void SetParam(ParamType type, void* param)
+ {
+ m_ParamType = type;
+ m_pParam = param;
+ }
+private:
+
+ CFX_ByteString m_MarkName;
+
+ ParamType m_ParamType;
+
+ void* m_pParam;
+};
+class CPDF_ContentMarkData : public CFX_Object
+{
+public:
+
+ CPDF_ContentMarkData() { }
+
+ CPDF_ContentMarkData(const CPDF_ContentMarkData& src);
+
+ inline int CountItems() const
+ {
+ return m_Marks.GetSize();
+ }
+
+ inline CPDF_ContentMarkItem& GetItem(int index) const
+ {
+ return m_Marks[index];
+ }
+
+ int GetMCID() const;
+
+ void AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, FX_BOOL bDictNeedClone);
+
+ void DeleteLastMark();
+private:
+
+ CFX_ObjectArray<CPDF_ContentMarkItem> m_Marks;
+};
+class CPDF_ContentMark : public CFX_CountRef<CPDF_ContentMarkData>
+{
+public:
+
+ int GetMCID() const
+ {
+ return m_pObject ? m_pObject->GetMCID() : -1;
+ }
+
+ FX_BOOL HasMark(FX_BSTR mark) const;
+
+ FX_BOOL LookupMark(FX_BSTR mark, CPDF_Dictionary*& pDict) const;
+};
+#define PDFPAGE_TEXT 1
+#define PDFPAGE_PATH 2
+#define PDFPAGE_IMAGE 3
+#define PDFPAGE_SHADING 4
+#define PDFPAGE_FORM 5
+#define PDFPAGE_INLINES 6
+class CPDF_GraphicStates : public CFX_Object
+{
+public:
+
+ void CopyStates(const CPDF_GraphicStates& src);
+
+ void DefaultStates();
+
+ CPDF_ClipPath m_ClipPath;
+
+ CPDF_GraphState m_GraphState;
+
+ CPDF_ColorState m_ColorState;
+
+ CPDF_TextState m_TextState;
+
+ CPDF_GeneralState m_GeneralState;
+};
+class CPDF_PageObject : public CPDF_GraphicStates
+{
+public:
+
+ static CPDF_PageObject* Create(int type);
+
+ void Release();
+
+ CPDF_PageObject* Clone() const;
+
+ void Copy(const CPDF_PageObject* pSrcObject);
+
+ virtual void Transform(const CFX_AffineMatrix& matrix) = 0;
+
+
+
+ void RemoveClipPath();
+
+ void AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
+
+ void CopyClipPath(CPDF_PageObject* pObj);
+
+ void TransformClipPath(CFX_AffineMatrix& matrix);
+
+ void TransformGeneralState(CFX_AffineMatrix& matrix);
+
+
+ void SetColorState(CPDF_ColorState state)
+ {
+ m_ColorState = state;
+ }
+
+ FX_RECT GetBBox(const CFX_AffineMatrix* pMatrix) const;
+
+ int m_Type;
+
+ FX_FLOAT m_Left;
+
+ FX_FLOAT m_Right;
+
+ FX_FLOAT m_Top;
+
+ FX_FLOAT m_Bottom;
+
+ CPDF_ContentMark m_ContentMark;
+protected:
+
+ virtual void CopyData(const CPDF_PageObject* pSrcObject) {}
+
+ void RecalcBBox();
+
+ CPDF_PageObject() {}
+
+ virtual ~CPDF_PageObject() {}
+};
+struct CPDF_TextObjectItem : public CFX_Object {
+
+ FX_DWORD m_CharCode;
+
+ FX_FLOAT m_OriginX;
+
+ FX_FLOAT m_OriginY;
+};
+class CPDF_TextObject : public CPDF_PageObject
+{
+public:
+
+ CPDF_TextObject();
+
+ virtual ~CPDF_TextObject();
+
+ int CountItems() const
+ {
+ return m_nChars;
+ }
+
+ void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;
+
+ int CountChars() const;
+
+ void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const;
+ void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;
+
+ void GetCharRect(int index, CFX_FloatRect& rect) const;
+
+
+ FX_FLOAT GetCharWidth(FX_DWORD charcode) const;
+ FX_FLOAT GetSpaceCharWidth() const;
+
+ FX_FLOAT GetPosX() const
+ {
+ return m_PosX;
+ }
+
+ FX_FLOAT GetPosY() const
+ {
+ return m_PosY;
+ }
+
+ void GetTextMatrix(CFX_AffineMatrix* pMatrix) const;
+
+ CPDF_Font* GetFont() const
+ {
+ return m_TextState.GetFont();
+ }
+
+ FX_FLOAT GetFontSize() const
+ {
+ return m_TextState.GetFontSize();
+ }
+
+ void SetEmpty();
+
+ void SetText(const CFX_ByteString& text);
+
+ void SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
+
+ void SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings);
+
+ void SetPosition(FX_FLOAT x, FX_FLOAT y);
+
+ void SetTextState(CPDF_TextState TextState);
+ virtual void Transform(const CFX_AffineMatrix& matrix);
+
+ void CalcCharPos(FX_FLOAT* pPosArray) const;
+
+
+
+ void SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, FX_FLOAT x, FX_FLOAT y);
+
+ void GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos)
+ {
+ nChars = m_nChars;
+ pCharCodes = m_pCharCodes;
+ pCharPos = m_pCharPos;
+ }
+
+
+ void RecalcPositionData()
+ {
+ CalcPositionData(NULL, NULL, 1);
+ }
+protected:
+ virtual void CopyData(const CPDF_PageObject* pSrcObject);
+
+ FX_FLOAT m_PosX;
+
+ FX_FLOAT m_PosY;
+
+ int m_nChars;
+
+ FX_DWORD* m_pCharCodes;
+
+ FX_FLOAT* m_pCharPos;
+
+ void SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
+
+ void CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextAdvanceY, FX_FLOAT horz_scale, int level = 0);
+ friend class CPDF_StreamContentParser;
+ friend class CPDF_RenderStatus;
+ friend class CPDF_QuickDrawer;
+ friend class CPDF_TextRenderer;
+ friend class CTextPage;
+ friend class CPDF_ContentGenerator;
+};
+class CPDF_PathObject : public CPDF_PageObject
+{
+public:
+
+ CPDF_PathObject()
+ {
+ m_Type = PDFPAGE_PATH;
+ }
+
+ virtual ~CPDF_PathObject() {}
+ virtual void Transform(const CFX_AffineMatrix& maxtrix);
+
+ void SetGraphState(CPDF_GraphState GraphState);
+
+ CPDF_Path m_Path;
+
+ int m_FillType;
+
+ FX_BOOL m_bStroke;
+
+ CFX_AffineMatrix m_Matrix;
+
+
+ void CalcBoundingBox();
+protected:
+ virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_ImageObject : public CPDF_PageObject
+{
+public:
+
+ CPDF_ImageObject();
+
+ virtual ~CPDF_ImageObject();
+ virtual void Transform(const CFX_AffineMatrix& matrix);
+
+ CPDF_Image* m_pImage;
+
+ CFX_AffineMatrix m_Matrix;
+
+ void CalcBoundingBox();
+private:
+ virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_ShadingObject : public CPDF_PageObject
+{
+public:
+
+ CPDF_ShadingObject();
+
+ virtual ~CPDF_ShadingObject();
+
+ CPDF_ShadingPattern* m_pShading;
+
+ CFX_AffineMatrix m_Matrix;
+
+ CPDF_Page* m_pPage;
+ virtual void Transform(const CFX_AffineMatrix& matrix);
+
+ void CalcBoundingBox();
+protected:
+ virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_FormObject : public CPDF_PageObject
+{
+public:
+
+ CPDF_FormObject()
+ {
+ m_Type = PDFPAGE_FORM;
+ m_pForm = NULL;
+ }
+
+ virtual ~CPDF_FormObject();
+ virtual void Transform(const CFX_AffineMatrix& matrix);
+
+ CPDF_Form* m_pForm;
+
+ CFX_AffineMatrix m_FormMatrix;
+
+ void CalcBoundingBox();
+protected:
+ virtual void CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_InlineImages : public CPDF_PageObject
+{
+public:
+
+ CPDF_InlineImages();
+
+ virtual ~CPDF_InlineImages();
+
+ CPDF_Stream* m_pStream;
+
+ CFX_DIBitmap* m_pBitmap;
+
+ CFX_ArrayTemplate<CFX_AffineMatrix> m_Matrices;
+
+ void AddMatrix(CFX_AffineMatrix& matrix);
+protected:
+ virtual void Transform(const CFX_AffineMatrix& matrix) {}
+ virtual void CopyData(const CPDF_PageObject* pSrcObjet) {}
+};
+#endif
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index 9d41539d52..c6c80778a1 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -1,1149 +1,1149 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_PARSER_
-#define _FPDF_PARSER_
-#ifndef _FX_BASIC_H_
-#include "../fxcrt/fx_ext.h"
-#endif
-#ifndef _FPDF_OBJECTS_
-#include "fpdf_objects.h"
-#endif
-class CPDF_Document;
-class IPDF_DocParser;
-class CPDF_Parser;
-class CPDF_SecurityHandler;
-class CPDF_StandardSecurityHandler;
-class CPDF_CryptoHandler;
-class CPDF_Object;
-class IFX_FileRead;
-class CFDF_Document;
-class CFDF_Parser;
-class CFX_Font;
-class CFX_AffineMatrix;
-class CFX_FloatRect;
-class CPDF_Point;
-class CPDF_DocPageData;
-class CPDF_DocRenderData;
-class CPDF_ModuleMgr;
-class CFX_DIBSource;
-class CPDF_Font;
-class CPDF_Image;
-class CPDF_ColorSpace;
-class CPDF_Pattern;
-class CPDF_FontEncoding;
-class CPDF_IccProfile;
-class CFX_PrivateData;
-#define FPDFPERM_PRINT 0x0004
-#define FPDFPERM_MODIFY 0x0008
-#define FPDFPERM_EXTRACT 0x0010
-#define FPDFPERM_ANNOT_FORM 0x0020
-#define FPDFPERM_FILL_FORM 0x0100
-#define FPDFPERM_EXTRACT_ACCESS 0x0200
-#define FPDFPERM_ASSEMBLE 0x0400
-#define FPDFPERM_PRINT_HIGH 0x0800
-#define FPDF_PAGE_MAX_NUM 0xFFFFF
-class IPDF_EnumPageHandler
-{
-public:
-
- virtual FX_BOOL EnumPage(CPDF_Dictionary* pPageDict) = 0;
-};
-class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjects
-{
-public:
-
- CPDF_Document(IPDF_DocParser* pParser);
-
- CPDF_Document();
-
- ~CPDF_Document();
-
- IPDF_DocParser* GetParser() const
- {
- return m_pParser;
- }
-
- CPDF_Dictionary* GetRoot() const
- {
- return m_pRootDict;
- }
-
- CPDF_Dictionary* GetInfo() const
- {
- return m_pInfoDict;
- }
-
- void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const
- {
- id1 = m_ID1;
- id2 = m_ID2;
- }
-
- int GetPageCount() const;
-
- CPDF_Dictionary* GetPage(int iPage);
-
- int GetPageIndex(FX_DWORD objnum);
-
- void EnumPages(IPDF_EnumPageHandler* pHandler);
-
- FX_DWORD GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const;
-
- FX_BOOL IsOwner() const;
-
-
-
- CPDF_DocPageData* GetPageData()
- {
- return GetValidatePageData();
- }
-
- void ClearPageData();
-
- void RemoveColorSpaceFromPageData(CPDF_Object* pObject);
-
-
- CPDF_DocRenderData* GetRenderData()
- {
- return GetValidateRenderData();
- }
-
- void ClearRenderData();
-
- void ClearRenderFont();
-
-
- FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const;
-
-
-
-
- CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict);
-
- CPDF_Font* FindFont(CPDF_Dictionary* pFontDict);
-
- CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, CPDF_Dictionary* pResources = NULL);
-
- CPDF_Pattern* LoadPattern(CPDF_Object* pObj, FX_BOOL bShading, const CFX_AffineMatrix* matrix = NULL);
-
- CPDF_Image* LoadImageF(CPDF_Object* pObj);
-
- CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream);
-
- CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream, int nComponents);
-
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-
- CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);
- CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);
-#endif
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- CPDF_Font* AddMacFont(CTFontRef pFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);
-#endif
-
- CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding);
-
-
- CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert);
-
- void CreateNewDoc();
-
- CPDF_Dictionary* CreateNewPage(int iPage);
-
- void DeletePage(int iPage);
-
- void LoadDoc();
- void LoadAsynDoc(CPDF_Dictionary *pLinearized);
- void LoadPages();
-protected:
-
- CPDF_Dictionary* m_pRootDict;
-
- CPDF_Dictionary* m_pInfoDict;
-
- CFX_ByteString m_ID1;
-
- CFX_ByteString m_ID2;
-
-
- FX_BOOL m_bLinearized;
-
- FX_DWORD m_dwFirstPageNo;
-
- FX_DWORD m_dwFirstPageObjNum;
-
- CFX_DWordArray m_PageList;
-
- int _GetPageCount() const;
- CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, int iPage, int nPagesToGo, int level);
- int _FindPageIndex(CPDF_Dictionary* pNode, FX_DWORD& skip_count, FX_DWORD objnum, int& index, int level = 0);
- FX_BOOL IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary* pPageDict);
- FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting);
- CPDF_DocPageData* GetValidatePageData();
- CPDF_DocRenderData* GetValidateRenderData();
- friend class CPDF_Creator;
- friend class CPDF_Parser;
- friend class CPDF_DataAvail;
- friend class CPDF_OCContext;
-
-
-
- CPDF_DocPageData* m_pDocPage;
-
- CPDF_DocRenderData* m_pDocRender;
-
-};
-
-#define PDFWORD_EOF 0
-#define PDFWORD_NUMBER 1
-#define PDFWORD_TEXT 2
-#define PDFWORD_DELIMITER 3
-#define PDFWORD_NAME 4
-class CPDF_SimpleParser : public CFX_Object
-{
-public:
-
- CPDF_SimpleParser(FX_LPCBYTE pData, FX_DWORD dwSize);
-
- CPDF_SimpleParser(FX_BSTR str);
-
- CFX_ByteStringC GetWord();
-
- FX_BOOL SearchToken(FX_BSTR token);
-
- FX_BOOL SkipWord(FX_BSTR token);
-
- FX_BOOL FindTagPair(FX_BSTR start_token, FX_BSTR end_token,
- FX_DWORD& start_pos, FX_DWORD& end_pos);
-
- FX_BOOL FindTagParam(FX_BSTR token, int nParams);
-
- FX_DWORD GetPos()
- {
- return m_dwCurPos;
- }
-
- void SetPos(FX_DWORD pos)
- {
- ASSERT(pos <= m_dwSize);
- m_dwCurPos = pos;
- }
-private:
-
- void ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& type);
-
- FX_LPCBYTE m_pData;
-
- FX_DWORD m_dwSize;
-
- FX_DWORD m_dwCurPos;
-};
-class CPDF_SyntaxParser : public CFX_Object
-{
-public:
-
- CPDF_SyntaxParser();
-
- ~CPDF_SyntaxParser();
-
- void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset);
-
- FX_FILESIZE SavePos()
- {
- return m_Pos;
- }
-
- void RestorePos(FX_FILESIZE pos)
- {
- m_Pos = pos;
- }
-
- CPDF_Object* GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL, FX_BOOL bDecrypt = TRUE);
-
-
- CPDF_Object* GetObjectByStrict(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL);
-
- int GetDirectNum();
-
- CFX_ByteString GetString(FX_DWORD objnum, FX_DWORD gennum);
-
- CFX_ByteString GetName();
-
- CFX_ByteString GetKeyword();
-
- void GetBinary(FX_BYTE* buffer, FX_DWORD size);
-
- void ToNextLine();
-
- void ToNextWord();
-
- FX_BOOL SearchWord(FX_BSTR word, FX_BOOL bWholeWord, FX_BOOL bForward, FX_FILESIZE limit);
-
- int SearchMultiWord(FX_BSTR words, FX_BOOL bWholeWord, FX_FILESIZE limit);
-
- FX_FILESIZE FindTag(FX_BSTR tag, FX_FILESIZE limit);
-
- void SetEncrypt(CPDF_CryptoHandler* pCryptoHandler)
- {
- m_pCryptoHandler = pCryptoHandler;
- }
-
- FX_BOOL IsEncrypted()
- {
- return m_pCryptoHandler != NULL;
- }
-
- FX_BOOL GetCharAt(FX_FILESIZE pos, FX_BYTE& ch);
-
- FX_BOOL ReadBlock(FX_BYTE* pBuf, FX_DWORD size);
-
- CFX_ByteString GetNextWord(FX_BOOL& bIsNumber);
-protected:
-
- virtual FX_BOOL GetNextChar(FX_BYTE& ch);
-
- FX_BOOL GetCharAtBackward(FX_FILESIZE pos, FX_BYTE& ch);
-
- void GetNextWord();
-
- FX_BOOL IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen);
-
- CFX_ByteString ReadString();
-
- CFX_ByteString ReadHexString();
-
- CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT* pContext, FX_DWORD objnum, FX_DWORD gennum);
-
- FX_FILESIZE m_Pos;
-
- FX_BOOL m_bFileStream;
-
- int m_MetadataObjnum;
-
- IFX_FileRead* m_pFileAccess;
-
- FX_DWORD m_HeaderOffset;
-
- FX_FILESIZE m_FileLen;
-
- FX_BYTE* m_pFileBuf;
-
- FX_DWORD m_BufSize;
-
- FX_FILESIZE m_BufOffset;
-
- CPDF_CryptoHandler* m_pCryptoHandler;
-
- FX_BYTE m_WordBuffer[257];
-
- FX_DWORD m_WordSize;
-
- FX_BOOL m_bIsNumber;
-
- FX_FILESIZE m_dwWordPos;
- friend class CPDF_Parser;
- friend class CPDF_DataAvail;
-};
-
-#define PDFPARSE_TYPEONLY 1
-#define PDFPARSE_NOSTREAM 2
-struct PARSE_CONTEXT {
-
- FX_BOOL m_Flags;
-
- FX_FILESIZE m_DictStart;
-
- FX_FILESIZE m_DictEnd;
-
- FX_FILESIZE m_DataStart;
-
- FX_FILESIZE m_DataEnd;
-};
-class IPDF_DocParser : public CFX_Object
-{
-public:
-
- virtual FX_DWORD GetRootObjNum() = 0;
-
- virtual FX_DWORD GetInfoObjNum() = 0;
-
- virtual CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) = 0;
-
- virtual FX_DWORD GetLastObjNum() = 0;
-
- virtual CPDF_Array* GetIDArray() = 0;
-
- virtual CPDF_Dictionary* GetEncryptDict() = 0;
-
- FX_BOOL IsEncrypted()
- {
- return GetEncryptDict() != NULL;
- }
-
- virtual FX_DWORD GetPermissions(FX_BOOL bCheckRevision = FALSE) = 0;
-
- virtual FX_BOOL IsOwner() = 0;
-
- virtual FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) = 0;
-};
-
-#define PDFPARSE_ERROR_SUCCESS 0
-#define PDFPARSE_ERROR_FILE 1
-#define PDFPARSE_ERROR_FORMAT 2
-#define PDFPARSE_ERROR_PASSWORD 3
-#define PDFPARSE_ERROR_HANDLER 4
-#define PDFPARSE_ERROR_CERT 5
-class CPDF_Parser : public IPDF_DocParser
-{
-public:
-
- CPDF_Parser();
-
- ~CPDF_Parser();
-
- FX_DWORD StartParse(FX_LPCSTR filename, FX_BOOL bReParse = FALSE);
-
- FX_DWORD StartParse(FX_LPCWSTR filename, FX_BOOL bReParse = FALSE);
-
- FX_DWORD StartParse(IFX_FileRead* pFile, FX_BOOL bReParse = FALSE, FX_BOOL bOwnFileRead = TRUE);
-
- void CloseParser(FX_BOOL bReParse = FALSE);
-
- virtual FX_DWORD GetPermissions(FX_BOOL bCheckRevision = FALSE);
-
- virtual FX_BOOL IsOwner();
-
- void SetPassword(const FX_CHAR* password)
- {
- m_Password = password;
- }
-
- CFX_ByteString GetPassword()
- {
- return m_Password;
- }
-
- CPDF_SecurityHandler* GetSecurityHandler()
- {
- return m_pSecurityHandler;
- }
-
- CPDF_CryptoHandler* GetCryptoHandler()
- {
- return m_Syntax.m_pCryptoHandler;
- }
-
- void SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_BOOL bForced = FALSE);
-
- CFX_ByteString GetRecipient()
- {
- return m_bsRecipient;
- }
-
- CPDF_Dictionary* GetTrailer()
- {
- return m_pTrailer;
- }
-
- FX_FILESIZE GetLastXRefOffset()
- {
- return m_LastXRefOffset;
- }
-
- CPDF_Document* GetDocument()
- {
- return m_pDocument;
- }
- CFX_ArrayTemplate<CPDF_Dictionary *> * GetOtherTrailers()
- {
- return &m_Trailers;
- }
-
- virtual FX_DWORD GetRootObjNum();
- virtual FX_DWORD GetInfoObjNum();
- virtual CPDF_Array* GetIDArray();
- virtual CPDF_Dictionary* GetEncryptDict()
- {
- return m_pEncryptDict;
- }
- virtual CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL);
- virtual FX_DWORD GetLastObjNum();
- virtual FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm);
-
- FX_FILESIZE GetObjectOffset(FX_DWORD objnum);
-
- FX_FILESIZE GetObjectSize(FX_DWORD objnum);
-
- int GetObjectVersion(FX_DWORD objnum)
- {
- return m_ObjVersion[objnum];
- }
-
- void GetIndirectBinary(FX_DWORD objnum, FX_BYTE*& pBuffer, FX_DWORD& size);
-
- FX_BOOL GetFileStreamOption()
- {
- return m_Syntax.m_bFileStream;
- }
-
- void SetFileStreamOption(FX_BOOL b)
- {
- m_Syntax.m_bFileStream = b;
- }
-
- IFX_FileRead* GetFileAccess() const
- {
- return m_Syntax.m_pFileAccess;
- }
-
- int GetFileVersion() const
- {
- return m_FileVersion;
- }
-
- FX_BOOL IsXRefStream() const
- {
- return m_bXRefStream;
- }
- CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjects* pObjList, FX_FILESIZE pos, FX_DWORD objnum,
- struct PARSE_CONTEXT* pContext);
-
- CPDF_Object* ParseIndirectObjectAtByStrict(CPDF_IndirectObjects* pObjList, FX_FILESIZE pos, FX_DWORD objnum,
- struct PARSE_CONTEXT* pContext, FX_FILESIZE *pResultPos);
-
- FX_DWORD StartAsynParse(IFX_FileRead* pFile, FX_BOOL bReParse = FALSE, FX_BOOL bOwnFileRead = TRUE);
-
- FX_DWORD GetFirstPageNo()
- {
- return m_dwFirstPageNo;
- }
-protected:
-
- CPDF_Document* m_pDocument;
-
- CPDF_SyntaxParser m_Syntax;
- FX_BOOL m_bOwnFileRead;
- CPDF_Object* ParseDirect(CPDF_Object* pObj);
-
- FX_BOOL LoadAllCrossRefV4(FX_FILESIZE pos);
-
- FX_BOOL LoadAllCrossRefV5(FX_FILESIZE pos);
-
- FX_BOOL LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_BOOL bSkip, FX_BOOL bFirst);
-
- FX_BOOL LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL bMainXRef);
-
- CPDF_Dictionary* LoadTrailerV4();
-
- FX_BOOL RebuildCrossRef();
-
- FX_DWORD SetEncryptHandler();
-
- void ReleaseEncryptHandler();
-
- FX_BOOL LoadLinearizedAllCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount);
-
- FX_BOOL LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount);
-
- FX_BOOL LoadLinearizedAllCrossRefV5(FX_FILESIZE pos);
-
- FX_DWORD LoadLinearizedMainXRefTable();
-
- CFX_MapPtrToPtr m_ObjectStreamMap;
-
- CPDF_StreamAcc* GetObjectStream(FX_DWORD number);
-
- FX_BOOL IsLinearizedFile(IFX_FileRead* pFileAccess, FX_DWORD offset);
-
-
-
- int m_FileVersion;
-
- CPDF_Dictionary* m_pTrailer;
-
- CPDF_Dictionary* m_pEncryptDict;
- void SetEncryptDictionary(CPDF_Dictionary* pDict);
-
- FX_FILESIZE m_LastXRefOffset;
-
- FX_BOOL m_bXRefStream;
-
-
- CPDF_SecurityHandler* m_pSecurityHandler;
-
- FX_BOOL m_bForceUseSecurityHandler;
-
- CFX_ByteString m_bsRecipient;
-
- CFX_ByteString m_FilePath;
-
- CFX_ByteString m_Password;
-
- CFX_FileSizeArray m_CrossRef;
-
- CFX_ByteArray m_V5Type;
-
- CFX_FileSizeArray m_SortedOffset;
-
- CFX_WordArray m_ObjVersion;
- CFX_ArrayTemplate<CPDF_Dictionary *> m_Trailers;
-
- FX_BOOL m_bVersionUpdated;
-
- CPDF_Object* m_pLinearized;
-
- FX_DWORD m_dwFirstPageNo;
-
- FX_DWORD m_dwXrefStartObjNum;
- friend class CPDF_Creator;
- friend class CPDF_DataAvail;
-};
-#define FXCIPHER_NONE 0
-#define FXCIPHER_RC4 1
-#define FXCIPHER_AES 2
-#define FXCIPHER_AES2 3
-class CPDF_SecurityHandler : public CFX_Object
-{
-public:
-
- virtual ~CPDF_SecurityHandler() {}
-
- virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) = 0;
-
- virtual FX_DWORD GetPermissions() = 0;
-
- virtual FX_BOOL IsOwner() = 0;
-
- virtual FX_BOOL GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, int& keylen) = 0;
-
- virtual FX_BOOL IsMetadataEncrypted()
- {
- return TRUE;
- }
-
- virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0;
-
- virtual CPDF_StandardSecurityHandler* GetStandardHandler()
- {
- return NULL;
- }
-};
-#define PDF_ENCRYPT_CONTENT 0
-class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler
-{
-public:
- CPDF_StandardSecurityHandler();
-
- virtual ~CPDF_StandardSecurityHandler();
- virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);
- virtual FX_DWORD GetPermissions();
- virtual FX_BOOL IsOwner()
- {
- return m_bOwner;
- }
- virtual FX_BOOL GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, int& keylen);
- virtual FX_BOOL IsMetadataEncrypted();
- virtual CPDF_CryptoHandler* CreateCryptoHandler();
- virtual CPDF_StandardSecurityHandler* GetStandardHandler()
- {
- return this;
- }
-
- void OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,
- FX_LPCBYTE user_pass, FX_DWORD user_size,
- FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_DWORD type = PDF_ENCRYPT_CONTENT);
-
- void OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,
- FX_LPCBYTE user_pass, FX_DWORD user_size, FX_DWORD type = PDF_ENCRYPT_CONTENT);
-
- CFX_ByteString GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size);
- CFX_ByteString GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size, FX_INT32 key_len);
- int GetVersion()
- {
- return m_Version;
- }
- int GetRevision()
- {
- return m_Revision;
- }
-
- int CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key);
- int CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key, int key_len);
-private:
-
- int m_Version;
-
- int m_Revision;
-
- CPDF_Parser* m_pParser;
-
- CPDF_Dictionary* m_pEncryptDict;
-
- FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict);
- FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict, FX_DWORD type, int& cipher, int& key_len);
-
- FX_BOOL CheckUserPassword(FX_LPCBYTE password, FX_DWORD pass_size,
- FX_BOOL bIgnoreEncryptMeta, FX_LPBYTE key, FX_INT32 key_len);
-
- FX_BOOL CheckOwnerPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_LPBYTE key, FX_INT32 key_len);
- FX_BOOL AES256_CheckPassword(FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPBYTE key);
- void AES256_SetPassword(CPDF_Dictionary* pEncryptDict, FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPCBYTE key);
- void AES256_SetPerms(CPDF_Dictionary* pEncryptDict, FX_DWORD permission, FX_BOOL bEncryptMetadata, FX_LPCBYTE key);
- void OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,
- FX_LPCBYTE user_pass, FX_DWORD user_size,
- FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_BOOL bDefault, FX_DWORD type);
- FX_BOOL CheckSecurity(FX_INT32 key_len);
-
- FX_BOOL m_bOwner;
-
- FX_DWORD m_Permissions;
-
- int m_Cipher;
-
- FX_BYTE m_EncryptKey[32];
-
- int m_KeyLen;
-};
-class CPDF_CryptoHandler : public CFX_Object
-{
-public:
-
- virtual ~CPDF_CryptoHandler() {}
-
- virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler) = 0;
-
- virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0;
-
- virtual FX_LPVOID DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0;
-
- virtual FX_BOOL DecryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0;
-
- virtual FX_BOOL DecryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf) = 0;
-
-
- virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size) = 0;
-
- virtual FX_BOOL EncryptContent(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size,
- FX_LPBYTE dest_buf, FX_DWORD& dest_size) = 0;
-
- void Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str);
-};
-class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler
-{
-public:
-
- CPDF_StandardCryptoHandler();
-
- virtual ~CPDF_StandardCryptoHandler();
-
- FX_BOOL Init(int cipher, FX_LPCBYTE key, int keylen);
- virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler);
- virtual FX_DWORD DecryptGetSize(FX_DWORD src_size);
- virtual FX_LPVOID DecryptStart(FX_DWORD objnum, FX_DWORD gennum);
- virtual FX_BOOL DecryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
- virtual FX_BOOL DecryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf);
- virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size);
- virtual FX_BOOL EncryptContent(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size,
- FX_LPBYTE dest_buf, FX_DWORD& dest_size);
-protected:
-
- virtual void CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX_DWORD gennum, FX_LPCBYTE src_buf, FX_DWORD src_size,
- FX_LPBYTE dest_buf, FX_DWORD& dest_size);
- virtual FX_LPVOID CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt);
- virtual FX_BOOL CryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);
- virtual FX_BOOL CryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);
-
- FX_BYTE m_EncryptKey[32];
-
- int m_KeyLen;
-
- int m_Cipher;
-
- FX_LPBYTE m_pAESContext;
-};
-class CPDF_Point : public CFX_Object
-{
-public:
-
- CPDF_Point(FX_FLOAT xx, FX_FLOAT yy)
- {
- x = xx;
- y = yy;
- }
-
- FX_FLOAT x;
-
- FX_FLOAT y;
-};
-
-#define CPDF_Rect CFX_FloatRect
-#define CPDF_Matrix CFX_AffineMatrix
-CFX_ByteString PDF_NameDecode(FX_BSTR orig);
-CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig);
-CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig);
-CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex = FALSE);
-CFX_WideString PDF_DecodeText(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
-CFX_WideString PDF_DecodeText(FX_LPCBYTE pData, FX_DWORD size, CFX_CharMap* pCharMap = NULL);
-CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len = -1, CFX_CharMap* pCharMap = NULL);
-FX_FLOAT PDF_ClipFloat(FX_FLOAT f);
-class CFDF_Document : public CPDF_IndirectObjects
-{
-public:
-
- static CFDF_Document* CreateNewDoc();
-
- static CFDF_Document* ParseFile(FX_LPCSTR file_path);
-
- static CFDF_Document* ParseFile(FX_LPCWSTR file_path);
-
- static CFDF_Document* ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile = FALSE);
-
- static CFDF_Document* ParseMemory(FX_LPCBYTE pData, FX_DWORD size);
-
- ~CFDF_Document();
-
- FX_BOOL WriteFile(FX_LPCSTR file_path) const;
-
- FX_BOOL WriteFile(FX_LPCWSTR file_path) const;
-
- FX_BOOL WriteFile(IFX_FileWrite *pFile) const;
-
- FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const;
-
- CPDF_Dictionary* GetRoot() const
- {
- return m_pRootDict;
- }
-
- CFX_WideString GetWin32Path() const;
-protected:
-
- CFDF_Document();
- void ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile);
- CPDF_Dictionary* m_pRootDict;
- IFX_FileRead* m_pFile;
- FX_BOOL m_bOwnFile;
-};
-
-CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec);
-void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const CFX_WideString& fullpath);
-
-void FlateEncode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);
-FX_DWORD FlateDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);
-FX_DWORD RunLengthDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);
-class CPDF_NumberTree : public CFX_Object
-{
-public:
-
- CPDF_NumberTree(CPDF_Dictionary* pRoot)
- {
- m_pRoot = pRoot;
- }
-
- CPDF_Object* LookupValue(int num);
-protected:
-
- CPDF_Dictionary* m_pRoot;
-};
-
-class IFX_FileAvail
-{
-public:
-
- virtual FX_BOOL IsDataAvail( FX_FILESIZE offset, FX_DWORD size) = 0;
-};
-class IFX_DownloadHints
-{
-public:
-
- virtual void AddSegment(FX_FILESIZE offset, FX_DWORD size) = 0;
-};
-#define PDF_IS_LINEARIZED 1
-#define PDF_NOT_LINEARIZED 0
-#define PDF_UNKNOW_LINEARIZED -1
-#define PDFFORM_NOTAVAIL 0
-#define PDFFORM_AVAIL 1
-#define PDFFORM_NOTEXIST 2
-class IPDF_DataAvail
-{
-public:
-
- virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) = 0;
-
-
- virtual void SetDocument(CPDF_Document* pDoc) = 0;
-
-
- virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints* pHints) = 0;
-
- virtual FX_BOOL IsLinearized() = 0;
-
- virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints) = 0;
-
- virtual FX_INT32 IsLinearizedPDF() = 0;
-
- virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize) = 0;
-};
-class CPDF_SortObjNumArray : public CFX_Object
-{
-public:
-
- void AddObjNum(FX_DWORD dwObjNum);
-
- FX_BOOL Find(FX_DWORD dwObjNum);
-
- void RemoveAll()
- {
- m_number_array.RemoveAll();
- }
-protected:
-
- FX_BOOL BinarySearch(FX_DWORD value, int &iNext);
-protected:
-
- CFX_DWordArray m_number_array;
-};
-enum PDF_PAGENODE_TYPE {
- PDF_PAGENODE_UNKOWN = 0,
- PDF_PAGENODE_PAGE,
- PDF_PAGENODE_PAGES,
- PDF_PAGENODE_ARRAY,
-};
-class CPDF_PageNode : public CFX_Object
-{
-public:
- CPDF_PageNode() : m_type(PDF_PAGENODE_UNKOWN) {}
- ~CPDF_PageNode();
- PDF_PAGENODE_TYPE m_type;
- FX_DWORD m_dwPageNo;
- CFX_PtrArray m_childNode;
-};
-enum PDF_DATAAVAIL_STATUS {
- PDF_DATAAVAIL_HEADER = 0,
- PDF_DATAAVAIL_FIRSTPAGE,
- PDF_DATAAVAIL_FIRSTPAGE_PREPARE,
- PDF_DATAAVAIL_END,
- PDF_DATAAVAIL_CROSSREF,
- PDF_DATAAVAIL_CROSSREF_ITEM,
- PDF_DATAAVAIL_CROSSREF_STREAM,
- PDF_DATAAVAIL_TRAILER,
- PDF_DATAAVAIL_LOADALLCRSOSSREF,
- PDF_DATAAVAIL_ROOT,
- PDF_DATAAVAIL_INFO,
- PDF_DATAAVAIL_ACROFORM,
- PDF_DATAAVAIL_ACROFORM_SUBOBJECT,
- PDF_DATAAVAIL_PAGETREE,
- PDF_DATAAVAIL_PAGE,
- PDF_DATAAVAIL_PAGE_LATERLOAD,
- PDF_DATAAVAIL_RESOURCES,
- PDF_DATAAVAIL_DONE,
- PDF_DATAAVAIL_ERROR,
- PDF_DATAAVAIL_LOADALLFILE,
- PDF_DATAAVAIL_TRAILER_APPEND
-};
-class CPDF_DataAvail : public CFX_Object, public IPDF_DataAvail
-{
-public:
-
- CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead);
- ~CPDF_DataAvail();
-
- virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints);
-
-
- virtual void SetDocument(CPDF_Document* pDoc);
-
-
- virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints* pHints);
-
- virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints);
-
- virtual FX_INT32 IsLinearizedPDF();
-
- virtual FX_BOOL IsLinearized()
- {
- return m_bLinearized;
- }
-
- virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize);
- IFX_FileRead* GetFileRead() const
- {
- return m_pFileRead;
- }
- IFX_FileAvail* GetFileAvail() const
- {
- return m_pFileAvail;
- }
-protected:
- FX_DWORD GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset);
- FX_BOOL IsObjectsAvail(CFX_PtrArray& obj_array, FX_BOOL bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array);
- FX_BOOL CheckDocStatus(IFX_DownloadHints *pHints);
- FX_BOOL CheckHeader(IFX_DownloadHints* pHints);
- FX_BOOL CheckFirstPage(IFX_DownloadHints *pHints);
- FX_BOOL CheckEnd(IFX_DownloadHints *pHints);
- FX_BOOL CheckCrossRef(IFX_DownloadHints* pHints);
- FX_BOOL CheckCrossRefItem(IFX_DownloadHints *pHints);
- FX_BOOL CheckTrailer(IFX_DownloadHints* pHints);
- FX_BOOL CheckRoot(IFX_DownloadHints* pHints);
- FX_BOOL CheckInfo(IFX_DownloadHints* pHints);
- FX_BOOL CheckPages(IFX_DownloadHints* pHints);
- FX_BOOL CheckPage(IFX_DownloadHints* pHints);
- FX_BOOL CheckResources(IFX_DownloadHints* pHints);
- FX_BOOL CheckAnnots(IFX_DownloadHints* pHints);
- FX_BOOL CheckAcroForm(IFX_DownloadHints* pHints);
- FX_BOOL CheckAcroFormSubObject(IFX_DownloadHints* pHints);
- FX_BOOL CheckTrailerAppend(IFX_DownloadHints* pHints);
- FX_BOOL CheckPageStatus(IFX_DownloadHints* pHints);
- FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints *pHints);
-
- FX_DWORD CheckCrossRefStream(IFX_DownloadHints *pHints, FX_FILESIZE &xref_offset);
- FX_BOOL IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen);
- void SetStartOffset(FX_FILESIZE dwOffset);
- FX_BOOL GetNextToken(CFX_ByteString &token);
- FX_BOOL GetNextChar(FX_BYTE &ch);
- CPDF_Object * ParseIndirectObjectAt(FX_FILESIZE pos, FX_DWORD objnum);
- CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadHints* pHints, FX_BOOL *pExistInFile);
- FX_BOOL GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages);
- FX_BOOL PreparePageItem();
- FX_BOOL LoadPages(IFX_DownloadHints* pHints);
- FX_BOOL LoadAllXref(IFX_DownloadHints* pHints);
- FX_BOOL LoadAllFile(IFX_DownloadHints* pHints);
- FX_BOOL CheckLinearizedData(IFX_DownloadHints* pHints);
- FX_BOOL CheckFileResources(IFX_DownloadHints* pHints);
- FX_BOOL CheckPageAnnots(int iPage, IFX_DownloadHints* pHints);
-
- FX_BOOL CheckLinearizedFirstPage(int iPage, IFX_DownloadHints* pHints);
- FX_BOOL HaveResourceAncestor(CPDF_Dictionary *pDict);
- FX_BOOL CheckPage(FX_INT32 iPage, IFX_DownloadHints* pHints);
- FX_BOOL LoadDocPages(IFX_DownloadHints* pHints);
- FX_BOOL LoadDocPage(FX_INT32 iPage, IFX_DownloadHints* pHints);
- FX_BOOL CheckPageNode(CPDF_PageNode &pageNodes, FX_INT32 iPage, FX_INT32 &iCount, IFX_DownloadHints* pHints);
- FX_BOOL CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints);
- FX_BOOL CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints);
- FX_BOOL CheckPageCount(IFX_DownloadHints* pHints);
- FX_BOOL IsFirstCheck(int iPage);
- void ResetFirstCheck(int iPage);
-
- CPDF_Parser m_parser;
-
- CPDF_SyntaxParser m_syntaxParser;
-
- CPDF_Object *m_pRoot;
-
- FX_DWORD m_dwRootObjNum;
-
- FX_DWORD m_dwInfoObjNum;
-
- CPDF_Object *m_pLinearized;
-
- CPDF_Object *m_pTrailer;
-
- FX_BOOL m_bDocAvail;
-
- FX_FILESIZE m_dwHeaderOffset;
-
- FX_FILESIZE m_dwLastXRefOffset;
-
- FX_FILESIZE m_dwXRefOffset;
-
- FX_FILESIZE m_dwTrailerOffset;
-
- FX_FILESIZE m_dwCurrentOffset;
-
- PDF_DATAAVAIL_STATUS m_docStatus;
-
- IFX_FileAvail* m_pFileAvail;
-
- IFX_FileRead* m_pFileRead;
-
- FX_FILESIZE m_dwFileLen;
-
- CPDF_Document* m_pDocument;
-
- CPDF_SortObjNumArray m_objnum_array;
-
- CFX_PtrArray m_objs_array;
-
- FX_FILESIZE m_Pos;
-
- FX_FILESIZE m_bufferOffset;
-
- FX_DWORD m_bufferSize;
-
- CFX_ByteString m_WordBuf;
-
- FX_BYTE m_WordBuffer[257];
-
- FX_DWORD m_WordSize;
-
- FX_BYTE m_bufferData[512];
-
- CFX_FileSizeArray m_CrossOffset;
-
- CFX_DWordArray m_XRefStreamList;
-
- CFX_DWordArray m_PageObjList;
-
- FX_DWORD m_PagesObjNum;
-
- FX_BOOL m_bLinearized;
-
- FX_DWORD m_dwFirstPageNo;
-
- FX_BOOL m_bLinearedDataOK;
-
- FX_BOOL m_bMainXRefLoad;
-
- FX_BOOL m_bMainXRefLoadedOK;
-
- FX_BOOL m_bPagesTreeLoad;
-
- FX_BOOL m_bPagesLoad;
-
- CPDF_Parser * m_pCurrentParser;
-
- FX_FILESIZE m_dwCurrentXRefSteam;
-
- FX_BOOL m_bAnnotsLoad;
-
- FX_BOOL m_bHaveAcroForm;
-
- FX_DWORD m_dwAcroFormObjNum;
-
- FX_BOOL m_bAcroFormLoad;
-
- CPDF_Object * m_pAcroForm;
-
- CFX_PtrArray m_arrayAcroforms;
-
- CPDF_Dictionary * m_pPageDict;
-
- CPDF_Object * m_pPageResource;
-
- FX_BOOL m_bNeedDownLoadResource;
-
- FX_BOOL m_bPageLoadedOK;
-
- FX_BOOL m_bLinearizedFormParamLoad;
-
- CFX_PtrArray m_PagesArray;
-
- FX_DWORD m_dwEncryptObjNum;
-
- FX_FILESIZE m_dwPrevXRefOffset;
-
- FX_BOOL m_bTotalLoadPageTree;
-
- FX_BOOL m_bCurPageDictLoadOK;
-
- CPDF_PageNode m_pageNodes;
-
- CFX_CMapDWordToDWord * m_pageMapCheckState;
-
- CFX_CMapDWordToDWord * m_pagesLoadState;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_PARSER_
+#define _FPDF_PARSER_
+#ifndef _FX_BASIC_H_
+#include "../fxcrt/fx_ext.h"
+#endif
+#ifndef _FPDF_OBJECTS_
+#include "fpdf_objects.h"
+#endif
+class CPDF_Document;
+class IPDF_DocParser;
+class CPDF_Parser;
+class CPDF_SecurityHandler;
+class CPDF_StandardSecurityHandler;
+class CPDF_CryptoHandler;
+class CPDF_Object;
+class IFX_FileRead;
+class CFDF_Document;
+class CFDF_Parser;
+class CFX_Font;
+class CFX_AffineMatrix;
+class CFX_FloatRect;
+class CPDF_Point;
+class CPDF_DocPageData;
+class CPDF_DocRenderData;
+class CPDF_ModuleMgr;
+class CFX_DIBSource;
+class CPDF_Font;
+class CPDF_Image;
+class CPDF_ColorSpace;
+class CPDF_Pattern;
+class CPDF_FontEncoding;
+class CPDF_IccProfile;
+class CFX_PrivateData;
+#define FPDFPERM_PRINT 0x0004
+#define FPDFPERM_MODIFY 0x0008
+#define FPDFPERM_EXTRACT 0x0010
+#define FPDFPERM_ANNOT_FORM 0x0020
+#define FPDFPERM_FILL_FORM 0x0100
+#define FPDFPERM_EXTRACT_ACCESS 0x0200
+#define FPDFPERM_ASSEMBLE 0x0400
+#define FPDFPERM_PRINT_HIGH 0x0800
+#define FPDF_PAGE_MAX_NUM 0xFFFFF
+class IPDF_EnumPageHandler
+{
+public:
+
+ virtual FX_BOOL EnumPage(CPDF_Dictionary* pPageDict) = 0;
+};
+class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjects
+{
+public:
+
+ CPDF_Document(IPDF_DocParser* pParser);
+
+ CPDF_Document();
+
+ ~CPDF_Document();
+
+ IPDF_DocParser* GetParser() const
+ {
+ return m_pParser;
+ }
+
+ CPDF_Dictionary* GetRoot() const
+ {
+ return m_pRootDict;
+ }
+
+ CPDF_Dictionary* GetInfo() const
+ {
+ return m_pInfoDict;
+ }
+
+ void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const
+ {
+ id1 = m_ID1;
+ id2 = m_ID2;
+ }
+
+ int GetPageCount() const;
+
+ CPDF_Dictionary* GetPage(int iPage);
+
+ int GetPageIndex(FX_DWORD objnum);
+
+ void EnumPages(IPDF_EnumPageHandler* pHandler);
+
+ FX_DWORD GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const;
+
+ FX_BOOL IsOwner() const;
+
+
+
+ CPDF_DocPageData* GetPageData()
+ {
+ return GetValidatePageData();
+ }
+
+ void ClearPageData();
+
+ void RemoveColorSpaceFromPageData(CPDF_Object* pObject);
+
+
+ CPDF_DocRenderData* GetRenderData()
+ {
+ return GetValidateRenderData();
+ }
+
+ void ClearRenderData();
+
+ void ClearRenderFont();
+
+
+ FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const;
+
+
+
+
+ CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict);
+
+ CPDF_Font* FindFont(CPDF_Dictionary* pFontDict);
+
+ CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, CPDF_Dictionary* pResources = NULL);
+
+ CPDF_Pattern* LoadPattern(CPDF_Object* pObj, FX_BOOL bShading, const CFX_AffineMatrix* matrix = NULL);
+
+ CPDF_Image* LoadImageF(CPDF_Object* pObj);
+
+ CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream);
+
+ CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream, int nComponents);
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
+ CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);
+ CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);
+#endif
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+ CPDF_Font* AddMacFont(CTFontRef pFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);
+#endif
+
+ CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding);
+
+
+ CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert);
+
+ void CreateNewDoc();
+
+ CPDF_Dictionary* CreateNewPage(int iPage);
+
+ void DeletePage(int iPage);
+
+ void LoadDoc();
+ void LoadAsynDoc(CPDF_Dictionary *pLinearized);
+ void LoadPages();
+protected:
+
+ CPDF_Dictionary* m_pRootDict;
+
+ CPDF_Dictionary* m_pInfoDict;
+
+ CFX_ByteString m_ID1;
+
+ CFX_ByteString m_ID2;
+
+
+ FX_BOOL m_bLinearized;
+
+ FX_DWORD m_dwFirstPageNo;
+
+ FX_DWORD m_dwFirstPageObjNum;
+
+ CFX_DWordArray m_PageList;
+
+ int _GetPageCount() const;
+ CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, int iPage, int nPagesToGo, int level);
+ int _FindPageIndex(CPDF_Dictionary* pNode, FX_DWORD& skip_count, FX_DWORD objnum, int& index, int level = 0);
+ FX_BOOL IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary* pPageDict);
+ FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting);
+ CPDF_DocPageData* GetValidatePageData();
+ CPDF_DocRenderData* GetValidateRenderData();
+ friend class CPDF_Creator;
+ friend class CPDF_Parser;
+ friend class CPDF_DataAvail;
+ friend class CPDF_OCContext;
+
+
+
+ CPDF_DocPageData* m_pDocPage;
+
+ CPDF_DocRenderData* m_pDocRender;
+
+};
+
+#define PDFWORD_EOF 0
+#define PDFWORD_NUMBER 1
+#define PDFWORD_TEXT 2
+#define PDFWORD_DELIMITER 3
+#define PDFWORD_NAME 4
+class CPDF_SimpleParser : public CFX_Object
+{
+public:
+
+ CPDF_SimpleParser(FX_LPCBYTE pData, FX_DWORD dwSize);
+
+ CPDF_SimpleParser(FX_BSTR str);
+
+ CFX_ByteStringC GetWord();
+
+ FX_BOOL SearchToken(FX_BSTR token);
+
+ FX_BOOL SkipWord(FX_BSTR token);
+
+ FX_BOOL FindTagPair(FX_BSTR start_token, FX_BSTR end_token,
+ FX_DWORD& start_pos, FX_DWORD& end_pos);
+
+ FX_BOOL FindTagParam(FX_BSTR token, int nParams);
+
+ FX_DWORD GetPos()
+ {
+ return m_dwCurPos;
+ }
+
+ void SetPos(FX_DWORD pos)
+ {
+ ASSERT(pos <= m_dwSize);
+ m_dwCurPos = pos;
+ }
+private:
+
+ void ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& type);
+
+ FX_LPCBYTE m_pData;
+
+ FX_DWORD m_dwSize;
+
+ FX_DWORD m_dwCurPos;
+};
+class CPDF_SyntaxParser : public CFX_Object
+{
+public:
+
+ CPDF_SyntaxParser();
+
+ ~CPDF_SyntaxParser();
+
+ void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset);
+
+ FX_FILESIZE SavePos()
+ {
+ return m_Pos;
+ }
+
+ void RestorePos(FX_FILESIZE pos)
+ {
+ m_Pos = pos;
+ }
+
+ CPDF_Object* GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL, FX_BOOL bDecrypt = TRUE);
+
+
+ CPDF_Object* GetObjectByStrict(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL);
+
+ int GetDirectNum();
+
+ CFX_ByteString GetString(FX_DWORD objnum, FX_DWORD gennum);
+
+ CFX_ByteString GetName();
+
+ CFX_ByteString GetKeyword();
+
+ void GetBinary(FX_BYTE* buffer, FX_DWORD size);
+
+ void ToNextLine();
+
+ void ToNextWord();
+
+ FX_BOOL SearchWord(FX_BSTR word, FX_BOOL bWholeWord, FX_BOOL bForward, FX_FILESIZE limit);
+
+ int SearchMultiWord(FX_BSTR words, FX_BOOL bWholeWord, FX_FILESIZE limit);
+
+ FX_FILESIZE FindTag(FX_BSTR tag, FX_FILESIZE limit);
+
+ void SetEncrypt(CPDF_CryptoHandler* pCryptoHandler)
+ {
+ m_pCryptoHandler = pCryptoHandler;
+ }
+
+ FX_BOOL IsEncrypted()
+ {
+ return m_pCryptoHandler != NULL;
+ }
+
+ FX_BOOL GetCharAt(FX_FILESIZE pos, FX_BYTE& ch);
+
+ FX_BOOL ReadBlock(FX_BYTE* pBuf, FX_DWORD size);
+
+ CFX_ByteString GetNextWord(FX_BOOL& bIsNumber);
+protected:
+
+ virtual FX_BOOL GetNextChar(FX_BYTE& ch);
+
+ FX_BOOL GetCharAtBackward(FX_FILESIZE pos, FX_BYTE& ch);
+
+ void GetNextWord();
+
+ FX_BOOL IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen);
+
+ CFX_ByteString ReadString();
+
+ CFX_ByteString ReadHexString();
+
+ CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT* pContext, FX_DWORD objnum, FX_DWORD gennum);
+
+ FX_FILESIZE m_Pos;
+
+ FX_BOOL m_bFileStream;
+
+ int m_MetadataObjnum;
+
+ IFX_FileRead* m_pFileAccess;
+
+ FX_DWORD m_HeaderOffset;
+
+ FX_FILESIZE m_FileLen;
+
+ FX_BYTE* m_pFileBuf;
+
+ FX_DWORD m_BufSize;
+
+ FX_FILESIZE m_BufOffset;
+
+ CPDF_CryptoHandler* m_pCryptoHandler;
+
+ FX_BYTE m_WordBuffer[257];
+
+ FX_DWORD m_WordSize;
+
+ FX_BOOL m_bIsNumber;
+
+ FX_FILESIZE m_dwWordPos;
+ friend class CPDF_Parser;
+ friend class CPDF_DataAvail;
+};
+
+#define PDFPARSE_TYPEONLY 1
+#define PDFPARSE_NOSTREAM 2
+struct PARSE_CONTEXT {
+
+ FX_BOOL m_Flags;
+
+ FX_FILESIZE m_DictStart;
+
+ FX_FILESIZE m_DictEnd;
+
+ FX_FILESIZE m_DataStart;
+
+ FX_FILESIZE m_DataEnd;
+};
+class IPDF_DocParser : public CFX_Object
+{
+public:
+
+ virtual FX_DWORD GetRootObjNum() = 0;
+
+ virtual FX_DWORD GetInfoObjNum() = 0;
+
+ virtual CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) = 0;
+
+ virtual FX_DWORD GetLastObjNum() = 0;
+
+ virtual CPDF_Array* GetIDArray() = 0;
+
+ virtual CPDF_Dictionary* GetEncryptDict() = 0;
+
+ FX_BOOL IsEncrypted()
+ {
+ return GetEncryptDict() != NULL;
+ }
+
+ virtual FX_DWORD GetPermissions(FX_BOOL bCheckRevision = FALSE) = 0;
+
+ virtual FX_BOOL IsOwner() = 0;
+
+ virtual FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) = 0;
+};
+
+#define PDFPARSE_ERROR_SUCCESS 0
+#define PDFPARSE_ERROR_FILE 1
+#define PDFPARSE_ERROR_FORMAT 2
+#define PDFPARSE_ERROR_PASSWORD 3
+#define PDFPARSE_ERROR_HANDLER 4
+#define PDFPARSE_ERROR_CERT 5
+class CPDF_Parser : public IPDF_DocParser
+{
+public:
+
+ CPDF_Parser();
+
+ ~CPDF_Parser();
+
+ FX_DWORD StartParse(FX_LPCSTR filename, FX_BOOL bReParse = FALSE);
+
+ FX_DWORD StartParse(FX_LPCWSTR filename, FX_BOOL bReParse = FALSE);
+
+ FX_DWORD StartParse(IFX_FileRead* pFile, FX_BOOL bReParse = FALSE, FX_BOOL bOwnFileRead = TRUE);
+
+ void CloseParser(FX_BOOL bReParse = FALSE);
+
+ virtual FX_DWORD GetPermissions(FX_BOOL bCheckRevision = FALSE);
+
+ virtual FX_BOOL IsOwner();
+
+ void SetPassword(const FX_CHAR* password)
+ {
+ m_Password = password;
+ }
+
+ CFX_ByteString GetPassword()
+ {
+ return m_Password;
+ }
+
+ CPDF_SecurityHandler* GetSecurityHandler()
+ {
+ return m_pSecurityHandler;
+ }
+
+ CPDF_CryptoHandler* GetCryptoHandler()
+ {
+ return m_Syntax.m_pCryptoHandler;
+ }
+
+ void SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_BOOL bForced = FALSE);
+
+ CFX_ByteString GetRecipient()
+ {
+ return m_bsRecipient;
+ }
+
+ CPDF_Dictionary* GetTrailer()
+ {
+ return m_pTrailer;
+ }
+
+ FX_FILESIZE GetLastXRefOffset()
+ {
+ return m_LastXRefOffset;
+ }
+
+ CPDF_Document* GetDocument()
+ {
+ return m_pDocument;
+ }
+ CFX_ArrayTemplate<CPDF_Dictionary *> * GetOtherTrailers()
+ {
+ return &m_Trailers;
+ }
+
+ virtual FX_DWORD GetRootObjNum();
+ virtual FX_DWORD GetInfoObjNum();
+ virtual CPDF_Array* GetIDArray();
+ virtual CPDF_Dictionary* GetEncryptDict()
+ {
+ return m_pEncryptDict;
+ }
+ virtual CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL);
+ virtual FX_DWORD GetLastObjNum();
+ virtual FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm);
+
+ FX_FILESIZE GetObjectOffset(FX_DWORD objnum);
+
+ FX_FILESIZE GetObjectSize(FX_DWORD objnum);
+
+ int GetObjectVersion(FX_DWORD objnum)
+ {
+ return m_ObjVersion[objnum];
+ }
+
+ void GetIndirectBinary(FX_DWORD objnum, FX_BYTE*& pBuffer, FX_DWORD& size);
+
+ FX_BOOL GetFileStreamOption()
+ {
+ return m_Syntax.m_bFileStream;
+ }
+
+ void SetFileStreamOption(FX_BOOL b)
+ {
+ m_Syntax.m_bFileStream = b;
+ }
+
+ IFX_FileRead* GetFileAccess() const
+ {
+ return m_Syntax.m_pFileAccess;
+ }
+
+ int GetFileVersion() const
+ {
+ return m_FileVersion;
+ }
+
+ FX_BOOL IsXRefStream() const
+ {
+ return m_bXRefStream;
+ }
+ CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjects* pObjList, FX_FILESIZE pos, FX_DWORD objnum,
+ struct PARSE_CONTEXT* pContext);
+
+ CPDF_Object* ParseIndirectObjectAtByStrict(CPDF_IndirectObjects* pObjList, FX_FILESIZE pos, FX_DWORD objnum,
+ struct PARSE_CONTEXT* pContext, FX_FILESIZE *pResultPos);
+
+ FX_DWORD StartAsynParse(IFX_FileRead* pFile, FX_BOOL bReParse = FALSE, FX_BOOL bOwnFileRead = TRUE);
+
+ FX_DWORD GetFirstPageNo()
+ {
+ return m_dwFirstPageNo;
+ }
+protected:
+
+ CPDF_Document* m_pDocument;
+
+ CPDF_SyntaxParser m_Syntax;
+ FX_BOOL m_bOwnFileRead;
+ CPDF_Object* ParseDirect(CPDF_Object* pObj);
+
+ FX_BOOL LoadAllCrossRefV4(FX_FILESIZE pos);
+
+ FX_BOOL LoadAllCrossRefV5(FX_FILESIZE pos);
+
+ FX_BOOL LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_BOOL bSkip, FX_BOOL bFirst);
+
+ FX_BOOL LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL bMainXRef);
+
+ CPDF_Dictionary* LoadTrailerV4();
+
+ FX_BOOL RebuildCrossRef();
+
+ FX_DWORD SetEncryptHandler();
+
+ void ReleaseEncryptHandler();
+
+ FX_BOOL LoadLinearizedAllCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount);
+
+ FX_BOOL LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount);
+
+ FX_BOOL LoadLinearizedAllCrossRefV5(FX_FILESIZE pos);
+
+ FX_DWORD LoadLinearizedMainXRefTable();
+
+ CFX_MapPtrToPtr m_ObjectStreamMap;
+
+ CPDF_StreamAcc* GetObjectStream(FX_DWORD number);
+
+ FX_BOOL IsLinearizedFile(IFX_FileRead* pFileAccess, FX_DWORD offset);
+
+
+
+ int m_FileVersion;
+
+ CPDF_Dictionary* m_pTrailer;
+
+ CPDF_Dictionary* m_pEncryptDict;
+ void SetEncryptDictionary(CPDF_Dictionary* pDict);
+
+ FX_FILESIZE m_LastXRefOffset;
+
+ FX_BOOL m_bXRefStream;
+
+
+ CPDF_SecurityHandler* m_pSecurityHandler;
+
+ FX_BOOL m_bForceUseSecurityHandler;
+
+ CFX_ByteString m_bsRecipient;
+
+ CFX_ByteString m_FilePath;
+
+ CFX_ByteString m_Password;
+
+ CFX_FileSizeArray m_CrossRef;
+
+ CFX_ByteArray m_V5Type;
+
+ CFX_FileSizeArray m_SortedOffset;
+
+ CFX_WordArray m_ObjVersion;
+ CFX_ArrayTemplate<CPDF_Dictionary *> m_Trailers;
+
+ FX_BOOL m_bVersionUpdated;
+
+ CPDF_Object* m_pLinearized;
+
+ FX_DWORD m_dwFirstPageNo;
+
+ FX_DWORD m_dwXrefStartObjNum;
+ friend class CPDF_Creator;
+ friend class CPDF_DataAvail;
+};
+#define FXCIPHER_NONE 0
+#define FXCIPHER_RC4 1
+#define FXCIPHER_AES 2
+#define FXCIPHER_AES2 3
+class CPDF_SecurityHandler : public CFX_Object
+{
+public:
+
+ virtual ~CPDF_SecurityHandler() {}
+
+ virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) = 0;
+
+ virtual FX_DWORD GetPermissions() = 0;
+
+ virtual FX_BOOL IsOwner() = 0;
+
+ virtual FX_BOOL GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, int& keylen) = 0;
+
+ virtual FX_BOOL IsMetadataEncrypted()
+ {
+ return TRUE;
+ }
+
+ virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0;
+
+ virtual CPDF_StandardSecurityHandler* GetStandardHandler()
+ {
+ return NULL;
+ }
+};
+#define PDF_ENCRYPT_CONTENT 0
+class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler
+{
+public:
+ CPDF_StandardSecurityHandler();
+
+ virtual ~CPDF_StandardSecurityHandler();
+ virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);
+ virtual FX_DWORD GetPermissions();
+ virtual FX_BOOL IsOwner()
+ {
+ return m_bOwner;
+ }
+ virtual FX_BOOL GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, int& keylen);
+ virtual FX_BOOL IsMetadataEncrypted();
+ virtual CPDF_CryptoHandler* CreateCryptoHandler();
+ virtual CPDF_StandardSecurityHandler* GetStandardHandler()
+ {
+ return this;
+ }
+
+ void OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,
+ FX_LPCBYTE user_pass, FX_DWORD user_size,
+ FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_DWORD type = PDF_ENCRYPT_CONTENT);
+
+ void OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,
+ FX_LPCBYTE user_pass, FX_DWORD user_size, FX_DWORD type = PDF_ENCRYPT_CONTENT);
+
+ CFX_ByteString GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size);
+ CFX_ByteString GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size, FX_INT32 key_len);
+ int GetVersion()
+ {
+ return m_Version;
+ }
+ int GetRevision()
+ {
+ return m_Revision;
+ }
+
+ int CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key);
+ int CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key, int key_len);
+private:
+
+ int m_Version;
+
+ int m_Revision;
+
+ CPDF_Parser* m_pParser;
+
+ CPDF_Dictionary* m_pEncryptDict;
+
+ FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict);
+ FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict, FX_DWORD type, int& cipher, int& key_len);
+
+ FX_BOOL CheckUserPassword(FX_LPCBYTE password, FX_DWORD pass_size,
+ FX_BOOL bIgnoreEncryptMeta, FX_LPBYTE key, FX_INT32 key_len);
+
+ FX_BOOL CheckOwnerPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_LPBYTE key, FX_INT32 key_len);
+ FX_BOOL AES256_CheckPassword(FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPBYTE key);
+ void AES256_SetPassword(CPDF_Dictionary* pEncryptDict, FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPCBYTE key);
+ void AES256_SetPerms(CPDF_Dictionary* pEncryptDict, FX_DWORD permission, FX_BOOL bEncryptMetadata, FX_LPCBYTE key);
+ void OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,
+ FX_LPCBYTE user_pass, FX_DWORD user_size,
+ FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_BOOL bDefault, FX_DWORD type);
+ FX_BOOL CheckSecurity(FX_INT32 key_len);
+
+ FX_BOOL m_bOwner;
+
+ FX_DWORD m_Permissions;
+
+ int m_Cipher;
+
+ FX_BYTE m_EncryptKey[32];
+
+ int m_KeyLen;
+};
+class CPDF_CryptoHandler : public CFX_Object
+{
+public:
+
+ virtual ~CPDF_CryptoHandler() {}
+
+ virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler) = 0;
+
+ virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0;
+
+ virtual FX_LPVOID DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0;
+
+ virtual FX_BOOL DecryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0;
+
+ virtual FX_BOOL DecryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf) = 0;
+
+
+ virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size) = 0;
+
+ virtual FX_BOOL EncryptContent(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size,
+ FX_LPBYTE dest_buf, FX_DWORD& dest_size) = 0;
+
+ void Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str);
+};
+class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler
+{
+public:
+
+ CPDF_StandardCryptoHandler();
+
+ virtual ~CPDF_StandardCryptoHandler();
+
+ FX_BOOL Init(int cipher, FX_LPCBYTE key, int keylen);
+ virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler);
+ virtual FX_DWORD DecryptGetSize(FX_DWORD src_size);
+ virtual FX_LPVOID DecryptStart(FX_DWORD objnum, FX_DWORD gennum);
+ virtual FX_BOOL DecryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
+ virtual FX_BOOL DecryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf);
+ virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size);
+ virtual FX_BOOL EncryptContent(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size,
+ FX_LPBYTE dest_buf, FX_DWORD& dest_size);
+protected:
+
+ virtual void CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX_DWORD gennum, FX_LPCBYTE src_buf, FX_DWORD src_size,
+ FX_LPBYTE dest_buf, FX_DWORD& dest_size);
+ virtual FX_LPVOID CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt);
+ virtual FX_BOOL CryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);
+ virtual FX_BOOL CryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);
+
+ FX_BYTE m_EncryptKey[32];
+
+ int m_KeyLen;
+
+ int m_Cipher;
+
+ FX_LPBYTE m_pAESContext;
+};
+class CPDF_Point : public CFX_Object
+{
+public:
+
+ CPDF_Point(FX_FLOAT xx, FX_FLOAT yy)
+ {
+ x = xx;
+ y = yy;
+ }
+
+ FX_FLOAT x;
+
+ FX_FLOAT y;
+};
+
+#define CPDF_Rect CFX_FloatRect
+#define CPDF_Matrix CFX_AffineMatrix
+CFX_ByteString PDF_NameDecode(FX_BSTR orig);
+CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig);
+CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig);
+CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex = FALSE);
+CFX_WideString PDF_DecodeText(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
+CFX_WideString PDF_DecodeText(FX_LPCBYTE pData, FX_DWORD size, CFX_CharMap* pCharMap = NULL);
+CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len = -1, CFX_CharMap* pCharMap = NULL);
+FX_FLOAT PDF_ClipFloat(FX_FLOAT f);
+class CFDF_Document : public CPDF_IndirectObjects
+{
+public:
+
+ static CFDF_Document* CreateNewDoc();
+
+ static CFDF_Document* ParseFile(FX_LPCSTR file_path);
+
+ static CFDF_Document* ParseFile(FX_LPCWSTR file_path);
+
+ static CFDF_Document* ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile = FALSE);
+
+ static CFDF_Document* ParseMemory(FX_LPCBYTE pData, FX_DWORD size);
+
+ ~CFDF_Document();
+
+ FX_BOOL WriteFile(FX_LPCSTR file_path) const;
+
+ FX_BOOL WriteFile(FX_LPCWSTR file_path) const;
+
+ FX_BOOL WriteFile(IFX_FileWrite *pFile) const;
+
+ FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const;
+
+ CPDF_Dictionary* GetRoot() const
+ {
+ return m_pRootDict;
+ }
+
+ CFX_WideString GetWin32Path() const;
+protected:
+
+ CFDF_Document();
+ void ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile);
+ CPDF_Dictionary* m_pRootDict;
+ IFX_FileRead* m_pFile;
+ FX_BOOL m_bOwnFile;
+};
+
+CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec);
+void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const CFX_WideString& fullpath);
+
+void FlateEncode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);
+FX_DWORD FlateDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);
+FX_DWORD RunLengthDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);
+class CPDF_NumberTree : public CFX_Object
+{
+public:
+
+ CPDF_NumberTree(CPDF_Dictionary* pRoot)
+ {
+ m_pRoot = pRoot;
+ }
+
+ CPDF_Object* LookupValue(int num);
+protected:
+
+ CPDF_Dictionary* m_pRoot;
+};
+
+class IFX_FileAvail
+{
+public:
+
+ virtual FX_BOOL IsDataAvail( FX_FILESIZE offset, FX_DWORD size) = 0;
+};
+class IFX_DownloadHints
+{
+public:
+
+ virtual void AddSegment(FX_FILESIZE offset, FX_DWORD size) = 0;
+};
+#define PDF_IS_LINEARIZED 1
+#define PDF_NOT_LINEARIZED 0
+#define PDF_UNKNOW_LINEARIZED -1
+#define PDFFORM_NOTAVAIL 0
+#define PDFFORM_AVAIL 1
+#define PDFFORM_NOTEXIST 2
+class IPDF_DataAvail
+{
+public:
+
+ virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) = 0;
+
+
+ virtual void SetDocument(CPDF_Document* pDoc) = 0;
+
+
+ virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints* pHints) = 0;
+
+ virtual FX_BOOL IsLinearized() = 0;
+
+ virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints) = 0;
+
+ virtual FX_INT32 IsLinearizedPDF() = 0;
+
+ virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize) = 0;
+};
+class CPDF_SortObjNumArray : public CFX_Object
+{
+public:
+
+ void AddObjNum(FX_DWORD dwObjNum);
+
+ FX_BOOL Find(FX_DWORD dwObjNum);
+
+ void RemoveAll()
+ {
+ m_number_array.RemoveAll();
+ }
+protected:
+
+ FX_BOOL BinarySearch(FX_DWORD value, int &iNext);
+protected:
+
+ CFX_DWordArray m_number_array;
+};
+enum PDF_PAGENODE_TYPE {
+ PDF_PAGENODE_UNKOWN = 0,
+ PDF_PAGENODE_PAGE,
+ PDF_PAGENODE_PAGES,
+ PDF_PAGENODE_ARRAY,
+};
+class CPDF_PageNode : public CFX_Object
+{
+public:
+ CPDF_PageNode() : m_type(PDF_PAGENODE_UNKOWN) {}
+ ~CPDF_PageNode();
+ PDF_PAGENODE_TYPE m_type;
+ FX_DWORD m_dwPageNo;
+ CFX_PtrArray m_childNode;
+};
+enum PDF_DATAAVAIL_STATUS {
+ PDF_DATAAVAIL_HEADER = 0,
+ PDF_DATAAVAIL_FIRSTPAGE,
+ PDF_DATAAVAIL_FIRSTPAGE_PREPARE,
+ PDF_DATAAVAIL_END,
+ PDF_DATAAVAIL_CROSSREF,
+ PDF_DATAAVAIL_CROSSREF_ITEM,
+ PDF_DATAAVAIL_CROSSREF_STREAM,
+ PDF_DATAAVAIL_TRAILER,
+ PDF_DATAAVAIL_LOADALLCRSOSSREF,
+ PDF_DATAAVAIL_ROOT,
+ PDF_DATAAVAIL_INFO,
+ PDF_DATAAVAIL_ACROFORM,
+ PDF_DATAAVAIL_ACROFORM_SUBOBJECT,
+ PDF_DATAAVAIL_PAGETREE,
+ PDF_DATAAVAIL_PAGE,
+ PDF_DATAAVAIL_PAGE_LATERLOAD,
+ PDF_DATAAVAIL_RESOURCES,
+ PDF_DATAAVAIL_DONE,
+ PDF_DATAAVAIL_ERROR,
+ PDF_DATAAVAIL_LOADALLFILE,
+ PDF_DATAAVAIL_TRAILER_APPEND
+};
+class CPDF_DataAvail : public CFX_Object, public IPDF_DataAvail
+{
+public:
+
+ CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead);
+ ~CPDF_DataAvail();
+
+ virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints);
+
+
+ virtual void SetDocument(CPDF_Document* pDoc);
+
+
+ virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints* pHints);
+
+ virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints);
+
+ virtual FX_INT32 IsLinearizedPDF();
+
+ virtual FX_BOOL IsLinearized()
+ {
+ return m_bLinearized;
+ }
+
+ virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize);
+ IFX_FileRead* GetFileRead() const
+ {
+ return m_pFileRead;
+ }
+ IFX_FileAvail* GetFileAvail() const
+ {
+ return m_pFileAvail;
+ }
+protected:
+ FX_DWORD GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset);
+ FX_BOOL IsObjectsAvail(CFX_PtrArray& obj_array, FX_BOOL bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array);
+ FX_BOOL CheckDocStatus(IFX_DownloadHints *pHints);
+ FX_BOOL CheckHeader(IFX_DownloadHints* pHints);
+ FX_BOOL CheckFirstPage(IFX_DownloadHints *pHints);
+ FX_BOOL CheckEnd(IFX_DownloadHints *pHints);
+ FX_BOOL CheckCrossRef(IFX_DownloadHints* pHints);
+ FX_BOOL CheckCrossRefItem(IFX_DownloadHints *pHints);
+ FX_BOOL CheckTrailer(IFX_DownloadHints* pHints);
+ FX_BOOL CheckRoot(IFX_DownloadHints* pHints);
+ FX_BOOL CheckInfo(IFX_DownloadHints* pHints);
+ FX_BOOL CheckPages(IFX_DownloadHints* pHints);
+ FX_BOOL CheckPage(IFX_DownloadHints* pHints);
+ FX_BOOL CheckResources(IFX_DownloadHints* pHints);
+ FX_BOOL CheckAnnots(IFX_DownloadHints* pHints);
+ FX_BOOL CheckAcroForm(IFX_DownloadHints* pHints);
+ FX_BOOL CheckAcroFormSubObject(IFX_DownloadHints* pHints);
+ FX_BOOL CheckTrailerAppend(IFX_DownloadHints* pHints);
+ FX_BOOL CheckPageStatus(IFX_DownloadHints* pHints);
+ FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints *pHints);
+
+ FX_DWORD CheckCrossRefStream(IFX_DownloadHints *pHints, FX_FILESIZE &xref_offset);
+ FX_BOOL IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen);
+ void SetStartOffset(FX_FILESIZE dwOffset);
+ FX_BOOL GetNextToken(CFX_ByteString &token);
+ FX_BOOL GetNextChar(FX_BYTE &ch);
+ CPDF_Object * ParseIndirectObjectAt(FX_FILESIZE pos, FX_DWORD objnum);
+ CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadHints* pHints, FX_BOOL *pExistInFile);
+ FX_BOOL GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages);
+ FX_BOOL PreparePageItem();
+ FX_BOOL LoadPages(IFX_DownloadHints* pHints);
+ FX_BOOL LoadAllXref(IFX_DownloadHints* pHints);
+ FX_BOOL LoadAllFile(IFX_DownloadHints* pHints);
+ FX_BOOL CheckLinearizedData(IFX_DownloadHints* pHints);
+ FX_BOOL CheckFileResources(IFX_DownloadHints* pHints);
+ FX_BOOL CheckPageAnnots(int iPage, IFX_DownloadHints* pHints);
+
+ FX_BOOL CheckLinearizedFirstPage(int iPage, IFX_DownloadHints* pHints);
+ FX_BOOL HaveResourceAncestor(CPDF_Dictionary *pDict);
+ FX_BOOL CheckPage(FX_INT32 iPage, IFX_DownloadHints* pHints);
+ FX_BOOL LoadDocPages(IFX_DownloadHints* pHints);
+ FX_BOOL LoadDocPage(FX_INT32 iPage, IFX_DownloadHints* pHints);
+ FX_BOOL CheckPageNode(CPDF_PageNode &pageNodes, FX_INT32 iPage, FX_INT32 &iCount, IFX_DownloadHints* pHints);
+ FX_BOOL CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints);
+ FX_BOOL CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints);
+ FX_BOOL CheckPageCount(IFX_DownloadHints* pHints);
+ FX_BOOL IsFirstCheck(int iPage);
+ void ResetFirstCheck(int iPage);
+
+ CPDF_Parser m_parser;
+
+ CPDF_SyntaxParser m_syntaxParser;
+
+ CPDF_Object *m_pRoot;
+
+ FX_DWORD m_dwRootObjNum;
+
+ FX_DWORD m_dwInfoObjNum;
+
+ CPDF_Object *m_pLinearized;
+
+ CPDF_Object *m_pTrailer;
+
+ FX_BOOL m_bDocAvail;
+
+ FX_FILESIZE m_dwHeaderOffset;
+
+ FX_FILESIZE m_dwLastXRefOffset;
+
+ FX_FILESIZE m_dwXRefOffset;
+
+ FX_FILESIZE m_dwTrailerOffset;
+
+ FX_FILESIZE m_dwCurrentOffset;
+
+ PDF_DATAAVAIL_STATUS m_docStatus;
+
+ IFX_FileAvail* m_pFileAvail;
+
+ IFX_FileRead* m_pFileRead;
+
+ FX_FILESIZE m_dwFileLen;
+
+ CPDF_Document* m_pDocument;
+
+ CPDF_SortObjNumArray m_objnum_array;
+
+ CFX_PtrArray m_objs_array;
+
+ FX_FILESIZE m_Pos;
+
+ FX_FILESIZE m_bufferOffset;
+
+ FX_DWORD m_bufferSize;
+
+ CFX_ByteString m_WordBuf;
+
+ FX_BYTE m_WordBuffer[257];
+
+ FX_DWORD m_WordSize;
+
+ FX_BYTE m_bufferData[512];
+
+ CFX_FileSizeArray m_CrossOffset;
+
+ CFX_DWordArray m_XRefStreamList;
+
+ CFX_DWordArray m_PageObjList;
+
+ FX_DWORD m_PagesObjNum;
+
+ FX_BOOL m_bLinearized;
+
+ FX_DWORD m_dwFirstPageNo;
+
+ FX_BOOL m_bLinearedDataOK;
+
+ FX_BOOL m_bMainXRefLoad;
+
+ FX_BOOL m_bMainXRefLoadedOK;
+
+ FX_BOOL m_bPagesTreeLoad;
+
+ FX_BOOL m_bPagesLoad;
+
+ CPDF_Parser * m_pCurrentParser;
+
+ FX_FILESIZE m_dwCurrentXRefSteam;
+
+ FX_BOOL m_bAnnotsLoad;
+
+ FX_BOOL m_bHaveAcroForm;
+
+ FX_DWORD m_dwAcroFormObjNum;
+
+ FX_BOOL m_bAcroFormLoad;
+
+ CPDF_Object * m_pAcroForm;
+
+ CFX_PtrArray m_arrayAcroforms;
+
+ CPDF_Dictionary * m_pPageDict;
+
+ CPDF_Object * m_pPageResource;
+
+ FX_BOOL m_bNeedDownLoadResource;
+
+ FX_BOOL m_bPageLoadedOK;
+
+ FX_BOOL m_bLinearizedFormParamLoad;
+
+ CFX_PtrArray m_PagesArray;
+
+ FX_DWORD m_dwEncryptObjNum;
+
+ FX_FILESIZE m_dwPrevXRefOffset;
+
+ FX_BOOL m_bTotalLoadPageTree;
+
+ FX_BOOL m_bCurPageDictLoadOK;
+
+ CPDF_PageNode m_pageNodes;
+
+ CFX_CMapDWordToDWord * m_pageMapCheckState;
+
+ CFX_CMapDWordToDWord * m_pagesLoadState;
+};
+#endif
diff --git a/core/include/fpdfapi/fpdf_render.h b/core/include/fpdfapi/fpdf_render.h
index 22ba56fa66..c059bedb2b 100644
--- a/core/include/fpdfapi/fpdf_render.h
+++ b/core/include/fpdfapi/fpdf_render.h
@@ -1,318 +1,318 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_RENDER_
-#define _FPDF_RENDER_
-#ifndef _FPDF_PAGE_
-#include "fpdf_page.h"
-#endif
-#ifndef _FX_GE_H_
-#include "../fxge/fx_ge.h"
-#endif
-class CPDF_RenderContext;
-class CPDF_RenderOptions;
-class CPDF_ImageCache;
-class IPDF_OCContext;
-class CPDF_QuickStretcher;
-class CFX_PathData;
-class CFX_GraphStateData;
-class CFX_RenderDevice;
-class CPDF_TextObject;
-class CPDF_PathObject;
-class CPDF_ImageObject;
-class CPDF_ShadingObject;
-class CPDF_FormObject;
-class IPDF_OCContext
-{
-public:
-
- virtual ~IPDF_OCContext() {}
-
- virtual FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCG) = 0;
-
- FX_BOOL CheckObjectVisible(const CPDF_PageObject* pObj);
-};
-#define RENDER_COLOR_NORMAL 0
-#define RENDER_COLOR_GRAY 1
-#define RENDER_COLOR_TWOCOLOR 2
-#define RENDER_COLOR_ALPHA 3
-#define RENDER_CLEARTYPE 0x00000001
-#define RENDER_PRINTGRAPHICTEXT 0x00000002
-#define RENDER_FORCE_DOWNSAMPLE 0x00000004
-#define RENDER_PRINTPREVIEW 0x00000008
-#define RENDER_BGR_STRIPE 0x00000010
-#define RENDER_NO_NATIVETEXT 0x00000020
-#define RENDER_FORCE_HALFTONE 0x00000040
-#define RENDER_RECT_AA 0x00000080
-#define RENDER_FILL_FULLCOVER 0x00000100
-#define RENDER_PRINTIMAGETEXT 0x00000200
-#define RENDER_OVERPRINT 0x00000400
-#define RENDER_THINLINE 0x00000800
-#define RENDER_NOTEXTSMOOTH 0x10000000
-#define RENDER_NOPATHSMOOTH 0x20000000
-#define RENDER_NOIMAGESMOOTH 0x40000000
-#define RENDER_LIMITEDIMAGECACHE 0x80000000
-class CPDF_RenderOptions : public CFX_Object
-{
-public:
-
- CPDF_RenderOptions();
-
- int m_ColorMode;
-
- FX_COLORREF m_BackColor;
-
- FX_COLORREF m_ForeColor;
-
- FX_DWORD m_Flags;
-
- int m_Interpolation;
-
- FX_DWORD m_AddFlags;
-
- IPDF_OCContext* m_pOCContext;
-
- FX_DWORD m_dwLimitCacheSize;
-
- int m_HalftoneLimit;
-
- FX_ARGB TranslateColor(FX_ARGB argb) const;
-};
-class CPDF_RenderContext : public CFX_Object
-{
-public:
-
- CPDF_RenderContext();
-
- void Create(CPDF_Page* pPage, FX_BOOL bFirstLayer = TRUE);
-
- void Create(CPDF_Document* pDoc = NULL, CPDF_PageRenderCache* pPageCache = NULL,
- CPDF_Dictionary* pPageResources = NULL, FX_BOOL bFirstLayer = TRUE);
-
- ~CPDF_RenderContext();
-
- void Clear();
-
- void AppendObjectList(CPDF_PageObjects* pObjs, const CFX_AffineMatrix* pObject2Device);
-
- void SetBackground(class IPDF_BackgroundDraw* pBackground);
-
- void Render(CFX_RenderDevice* pDevice, const CPDF_RenderOptions* pOptions = NULL,
- const CFX_AffineMatrix* pFinalMatrix = NULL);
-
- void DrawObjectList(CFX_RenderDevice* pDevice, CPDF_PageObjects* pObjs,
- const CFX_AffineMatrix* pObject2Device, const CPDF_RenderOptions* pOptions);
-
- void GetBackground(CFX_DIBitmap* pBuffer, const CPDF_PageObject* pObj,
- const CPDF_RenderOptions* pOptions, CFX_AffineMatrix* pFinalMatrix);
-
- CPDF_PageRenderCache* GetPageCache() const
- {
- return m_pPageCache;
- }
-
-
-
- CPDF_Document* m_pDocument;
-
- CPDF_Dictionary* m_pPageResources;
-
- CPDF_PageRenderCache* m_pPageCache;
-
-protected:
-
- CFX_ArrayTemplate<struct _PDF_RenderItem> m_ContentList;
-
- IPDF_BackgroundDraw* m_pBackgroundDraw;
-
- FX_BOOL m_bFirstLayer;
-
- void Render(CFX_RenderDevice* pDevice, const CPDF_PageObject* pStopObj,
- const CPDF_RenderOptions* pOptions, const CFX_AffineMatrix* pFinalMatrix);
- friend class CPDF_RenderStatus;
- friend class CPDF_ProgressiveRenderer;
-};
-class IPDF_BackgroundDraw
-{
-public:
-
- virtual void OnDrawBackground(
- CFX_RenderDevice* pBitmapDevice,
- const CFX_AffineMatrix* pOriginal2Bitmap
- ) = 0;
-};
-class CPDF_ProgressiveRenderer : public CFX_Object
-{
-public:
-
- CPDF_ProgressiveRenderer();
-
- ~CPDF_ProgressiveRenderer();
-
- typedef enum {
- Ready,
- ToBeContinued,
- Done,
- Failed
- } RenderStatus;
-
- RenderStatus GetStatus()
- {
- return m_Status;
- }
-
-
-
- void Start(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice,
- const CPDF_RenderOptions* pOptions, class IFX_Pause* pPause, FX_BOOL bDropObjects = FALSE);
-
- void Continue(class IFX_Pause* pPause);
-
-
- int EstimateProgress();
-
- void Clear();
-protected:
-
- RenderStatus m_Status;
-
- CPDF_RenderContext* m_pContext;
-
- CFX_RenderDevice* m_pDevice;
-
- const CPDF_RenderOptions* m_pOptions;
-
- FX_BOOL m_bDropObjects;
-
- class CPDF_RenderStatus* m_pRenderer;
-
- CFX_FloatRect m_ClipRect;
-
- FX_DWORD m_LayerIndex;
-
- FX_DWORD m_ObjectIndex;
-
- FX_POSITION m_ObjectPos;
-
- FX_POSITION m_PrevLastPos;
-
- void RenderStep();
-};
-class CPDF_TextRenderer : public CFX_Object
-{
-public:
-
- static void DrawTextString(CFX_RenderDevice* pDevice, int left, int top,
- CPDF_Font* pFont,
- int height,
- const CFX_ByteString& str,
- FX_ARGB argb);
-
- static void DrawTextString(CFX_RenderDevice* pDevice, FX_FLOAT origin_x, FX_FLOAT origin_y,
- CPDF_Font* pFont,
- FX_FLOAT font_size,
- const CFX_AffineMatrix* matrix,
- const CFX_ByteString& str,
- FX_ARGB fill_argb,
- FX_ARGB stroke_argb = 0,
- const CFX_GraphStateData* pGraphState = NULL,
- const CPDF_RenderOptions* pOptions = NULL
- );
-
- static FX_BOOL DrawTextPath(CFX_RenderDevice* pDevice, int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos,
- CPDF_Font* pFont, FX_FLOAT font_size,
- const CFX_AffineMatrix* pText2User, const CFX_AffineMatrix* pUser2Device,
- const CFX_GraphStateData* pGraphState,
- FX_ARGB fill_argb, FX_ARGB stroke_argb, CFX_PathData* pClippingPath, int nFlag = 0);
-
- static FX_BOOL DrawNormalText(CFX_RenderDevice* pDevice, int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos,
- CPDF_Font* pFont, FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device,
- FX_ARGB fill_argb, const CPDF_RenderOptions* pOptions);
-
- static FX_BOOL DrawType3Text(CFX_RenderDevice* pDevice, int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos,
- CPDF_Font* pFont, FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device,
- FX_ARGB fill_argb);
-};
-class IPDF_PageImageCache
-{
-public:
-
- static IPDF_PageImageCache* Create();
-
- virtual ~IPDF_PageImageCache() {}
-
- virtual void OutputPage(CFX_RenderDevice* pDevice, CPDF_Page* pPage,
- int pos_x, int pos_y, int size_x, int size_y, int rotate) = 0;
-
- virtual void SetCacheLimit(FX_DWORD limit) = 0;
-};
-class CPDF_PageRenderCache : public CFX_Object
-{
-public:
- CPDF_PageRenderCache(CPDF_Page* pPage)
- {
- m_pPage = pPage;
- m_nTimeCount = 0;
- m_nCacheSize = 0;
- m_pCurImageCache = NULL;
- m_bCurFindCache = FALSE;
- m_pCurImageCaches = NULL;
- }
- ~CPDF_PageRenderCache()
- {
- ClearAll();
- }
- void ClearAll();
- void ClearImageData();
-
- FX_DWORD EstimateSize();
- void CacheOptimization(FX_INT32 dwLimitCacheSize);
- FX_DWORD GetCachedSize(CPDF_Stream* pStream) const;
- FX_DWORD GetTimeCount() const
- {
- return m_nTimeCount;
- }
- void SetTimeCount(FX_DWORD dwTimeCount)
- {
- m_nTimeCount = dwTimeCount;
- }
-
- void GetCachedBitmap(CPDF_Stream* pStream, CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, FX_DWORD& MatteColor,
- FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE,
- CPDF_RenderStatus* pRenderStatus = NULL, FX_INT32 downsampleWidth = 0, FX_INT32 downsampleHeight = 0);
-
- void ResetBitmap(CPDF_Stream* pStream, const CFX_DIBitmap* pBitmap);
- void ClearImageCache(CPDF_Stream* pStream);
- CPDF_Page* GetPage()
- {
- return m_pPage;
- }
- CFX_MapPtrToPtr m_ImageCaches;
-public:
- FX_BOOL StartGetCachedBitmap(CPDF_Stream* pStream, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0,
- FX_BOOL bLoadMask = FALSE, CPDF_RenderStatus* pRenderStatus = NULL,
- FX_INT32 downsampleWidth = 0, FX_INT32 downsampleHeight = 0);
-
- FX_BOOL Continue(IFX_Pause* pPause);
- CPDF_ImageCache* m_pCurImageCache;
- CFX_PtrArray* m_pCurImageCaches;
-protected:
- friend class CPDF_Page;
- CPDF_Page* m_pPage;
-
- FX_DWORD m_nTimeCount;
- FX_DWORD m_nCacheSize;
- FX_BOOL m_bCurFindCache;
-};
-class CPDF_RenderConfig : public CFX_Object
-{
-public:
- CPDF_RenderConfig();
- ~CPDF_RenderConfig();
- int m_HalftoneLimit;
- int m_RenderStepLimit;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_RENDER_
+#define _FPDF_RENDER_
+#ifndef _FPDF_PAGE_
+#include "fpdf_page.h"
+#endif
+#ifndef _FX_GE_H_
+#include "../fxge/fx_ge.h"
+#endif
+class CPDF_RenderContext;
+class CPDF_RenderOptions;
+class CPDF_ImageCache;
+class IPDF_OCContext;
+class CPDF_QuickStretcher;
+class CFX_PathData;
+class CFX_GraphStateData;
+class CFX_RenderDevice;
+class CPDF_TextObject;
+class CPDF_PathObject;
+class CPDF_ImageObject;
+class CPDF_ShadingObject;
+class CPDF_FormObject;
+class IPDF_OCContext
+{
+public:
+
+ virtual ~IPDF_OCContext() {}
+
+ virtual FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCG) = 0;
+
+ FX_BOOL CheckObjectVisible(const CPDF_PageObject* pObj);
+};
+#define RENDER_COLOR_NORMAL 0
+#define RENDER_COLOR_GRAY 1
+#define RENDER_COLOR_TWOCOLOR 2
+#define RENDER_COLOR_ALPHA 3
+#define RENDER_CLEARTYPE 0x00000001
+#define RENDER_PRINTGRAPHICTEXT 0x00000002
+#define RENDER_FORCE_DOWNSAMPLE 0x00000004
+#define RENDER_PRINTPREVIEW 0x00000008
+#define RENDER_BGR_STRIPE 0x00000010
+#define RENDER_NO_NATIVETEXT 0x00000020
+#define RENDER_FORCE_HALFTONE 0x00000040
+#define RENDER_RECT_AA 0x00000080
+#define RENDER_FILL_FULLCOVER 0x00000100
+#define RENDER_PRINTIMAGETEXT 0x00000200
+#define RENDER_OVERPRINT 0x00000400
+#define RENDER_THINLINE 0x00000800
+#define RENDER_NOTEXTSMOOTH 0x10000000
+#define RENDER_NOPATHSMOOTH 0x20000000
+#define RENDER_NOIMAGESMOOTH 0x40000000
+#define RENDER_LIMITEDIMAGECACHE 0x80000000
+class CPDF_RenderOptions : public CFX_Object
+{
+public:
+
+ CPDF_RenderOptions();
+
+ int m_ColorMode;
+
+ FX_COLORREF m_BackColor;
+
+ FX_COLORREF m_ForeColor;
+
+ FX_DWORD m_Flags;
+
+ int m_Interpolation;
+
+ FX_DWORD m_AddFlags;
+
+ IPDF_OCContext* m_pOCContext;
+
+ FX_DWORD m_dwLimitCacheSize;
+
+ int m_HalftoneLimit;
+
+ FX_ARGB TranslateColor(FX_ARGB argb) const;
+};
+class CPDF_RenderContext : public CFX_Object
+{
+public:
+
+ CPDF_RenderContext();
+
+ void Create(CPDF_Page* pPage, FX_BOOL bFirstLayer = TRUE);
+
+ void Create(CPDF_Document* pDoc = NULL, CPDF_PageRenderCache* pPageCache = NULL,
+ CPDF_Dictionary* pPageResources = NULL, FX_BOOL bFirstLayer = TRUE);
+
+ ~CPDF_RenderContext();
+
+ void Clear();
+
+ void AppendObjectList(CPDF_PageObjects* pObjs, const CFX_AffineMatrix* pObject2Device);
+
+ void SetBackground(class IPDF_BackgroundDraw* pBackground);
+
+ void Render(CFX_RenderDevice* pDevice, const CPDF_RenderOptions* pOptions = NULL,
+ const CFX_AffineMatrix* pFinalMatrix = NULL);
+
+ void DrawObjectList(CFX_RenderDevice* pDevice, CPDF_PageObjects* pObjs,
+ const CFX_AffineMatrix* pObject2Device, const CPDF_RenderOptions* pOptions);
+
+ void GetBackground(CFX_DIBitmap* pBuffer, const CPDF_PageObject* pObj,
+ const CPDF_RenderOptions* pOptions, CFX_AffineMatrix* pFinalMatrix);
+
+ CPDF_PageRenderCache* GetPageCache() const
+ {
+ return m_pPageCache;
+ }
+
+
+
+ CPDF_Document* m_pDocument;
+
+ CPDF_Dictionary* m_pPageResources;
+
+ CPDF_PageRenderCache* m_pPageCache;
+
+protected:
+
+ CFX_ArrayTemplate<struct _PDF_RenderItem> m_ContentList;
+
+ IPDF_BackgroundDraw* m_pBackgroundDraw;
+
+ FX_BOOL m_bFirstLayer;
+
+ void Render(CFX_RenderDevice* pDevice, const CPDF_PageObject* pStopObj,
+ const CPDF_RenderOptions* pOptions, const CFX_AffineMatrix* pFinalMatrix);
+ friend class CPDF_RenderStatus;
+ friend class CPDF_ProgressiveRenderer;
+};
+class IPDF_BackgroundDraw
+{
+public:
+
+ virtual void OnDrawBackground(
+ CFX_RenderDevice* pBitmapDevice,
+ const CFX_AffineMatrix* pOriginal2Bitmap
+ ) = 0;
+};
+class CPDF_ProgressiveRenderer : public CFX_Object
+{
+public:
+
+ CPDF_ProgressiveRenderer();
+
+ ~CPDF_ProgressiveRenderer();
+
+ typedef enum {
+ Ready,
+ ToBeContinued,
+ Done,
+ Failed
+ } RenderStatus;
+
+ RenderStatus GetStatus()
+ {
+ return m_Status;
+ }
+
+
+
+ void Start(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice,
+ const CPDF_RenderOptions* pOptions, class IFX_Pause* pPause, FX_BOOL bDropObjects = FALSE);
+
+ void Continue(class IFX_Pause* pPause);
+
+
+ int EstimateProgress();
+
+ void Clear();
+protected:
+
+ RenderStatus m_Status;
+
+ CPDF_RenderContext* m_pContext;
+
+ CFX_RenderDevice* m_pDevice;
+
+ const CPDF_RenderOptions* m_pOptions;
+
+ FX_BOOL m_bDropObjects;
+
+ class CPDF_RenderStatus* m_pRenderer;
+
+ CFX_FloatRect m_ClipRect;
+
+ FX_DWORD m_LayerIndex;
+
+ FX_DWORD m_ObjectIndex;
+
+ FX_POSITION m_ObjectPos;
+
+ FX_POSITION m_PrevLastPos;
+
+ void RenderStep();
+};
+class CPDF_TextRenderer : public CFX_Object
+{
+public:
+
+ static void DrawTextString(CFX_RenderDevice* pDevice, int left, int top,
+ CPDF_Font* pFont,
+ int height,
+ const CFX_ByteString& str,
+ FX_ARGB argb);
+
+ static void DrawTextString(CFX_RenderDevice* pDevice, FX_FLOAT origin_x, FX_FLOAT origin_y,
+ CPDF_Font* pFont,
+ FX_FLOAT font_size,
+ const CFX_AffineMatrix* matrix,
+ const CFX_ByteString& str,
+ FX_ARGB fill_argb,
+ FX_ARGB stroke_argb = 0,
+ const CFX_GraphStateData* pGraphState = NULL,
+ const CPDF_RenderOptions* pOptions = NULL
+ );
+
+ static FX_BOOL DrawTextPath(CFX_RenderDevice* pDevice, int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos,
+ CPDF_Font* pFont, FX_FLOAT font_size,
+ const CFX_AffineMatrix* pText2User, const CFX_AffineMatrix* pUser2Device,
+ const CFX_GraphStateData* pGraphState,
+ FX_ARGB fill_argb, FX_ARGB stroke_argb, CFX_PathData* pClippingPath, int nFlag = 0);
+
+ static FX_BOOL DrawNormalText(CFX_RenderDevice* pDevice, int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos,
+ CPDF_Font* pFont, FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device,
+ FX_ARGB fill_argb, const CPDF_RenderOptions* pOptions);
+
+ static FX_BOOL DrawType3Text(CFX_RenderDevice* pDevice, int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos,
+ CPDF_Font* pFont, FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device,
+ FX_ARGB fill_argb);
+};
+class IPDF_PageImageCache
+{
+public:
+
+ static IPDF_PageImageCache* Create();
+
+ virtual ~IPDF_PageImageCache() {}
+
+ virtual void OutputPage(CFX_RenderDevice* pDevice, CPDF_Page* pPage,
+ int pos_x, int pos_y, int size_x, int size_y, int rotate) = 0;
+
+ virtual void SetCacheLimit(FX_DWORD limit) = 0;
+};
+class CPDF_PageRenderCache : public CFX_Object
+{
+public:
+ CPDF_PageRenderCache(CPDF_Page* pPage)
+ {
+ m_pPage = pPage;
+ m_nTimeCount = 0;
+ m_nCacheSize = 0;
+ m_pCurImageCache = NULL;
+ m_bCurFindCache = FALSE;
+ m_pCurImageCaches = NULL;
+ }
+ ~CPDF_PageRenderCache()
+ {
+ ClearAll();
+ }
+ void ClearAll();
+ void ClearImageData();
+
+ FX_DWORD EstimateSize();
+ void CacheOptimization(FX_INT32 dwLimitCacheSize);
+ FX_DWORD GetCachedSize(CPDF_Stream* pStream) const;
+ FX_DWORD GetTimeCount() const
+ {
+ return m_nTimeCount;
+ }
+ void SetTimeCount(FX_DWORD dwTimeCount)
+ {
+ m_nTimeCount = dwTimeCount;
+ }
+
+ void GetCachedBitmap(CPDF_Stream* pStream, CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, FX_DWORD& MatteColor,
+ FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE,
+ CPDF_RenderStatus* pRenderStatus = NULL, FX_INT32 downsampleWidth = 0, FX_INT32 downsampleHeight = 0);
+
+ void ResetBitmap(CPDF_Stream* pStream, const CFX_DIBitmap* pBitmap);
+ void ClearImageCache(CPDF_Stream* pStream);
+ CPDF_Page* GetPage()
+ {
+ return m_pPage;
+ }
+ CFX_MapPtrToPtr m_ImageCaches;
+public:
+ FX_BOOL StartGetCachedBitmap(CPDF_Stream* pStream, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0,
+ FX_BOOL bLoadMask = FALSE, CPDF_RenderStatus* pRenderStatus = NULL,
+ FX_INT32 downsampleWidth = 0, FX_INT32 downsampleHeight = 0);
+
+ FX_BOOL Continue(IFX_Pause* pPause);
+ CPDF_ImageCache* m_pCurImageCache;
+ CFX_PtrArray* m_pCurImageCaches;
+protected:
+ friend class CPDF_Page;
+ CPDF_Page* m_pPage;
+
+ FX_DWORD m_nTimeCount;
+ FX_DWORD m_nCacheSize;
+ FX_BOOL m_bCurFindCache;
+};
+class CPDF_RenderConfig : public CFX_Object
+{
+public:
+ CPDF_RenderConfig();
+ ~CPDF_RenderConfig();
+ int m_HalftoneLimit;
+ int m_RenderStepLimit;
+};
+#endif
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h
index eea3afc4c6..49e7148ee6 100644
--- a/core/include/fpdfapi/fpdf_resource.h
+++ b/core/include/fpdfapi/fpdf_resource.h
@@ -1,960 +1,960 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_RESOURCE_
-#define _FPDF_RESOURCE_
-#ifndef _FPDF_PARSER_
-#include "fpdf_parser.h"
-#endif
-#ifndef _FX_FONT_H_
-#include "../fxge/fx_font.h"
-#endif
-class CPDF_Font;
-class CPDF_Type1Font;
-class CPDF_TrueTypeFont;
-class CPDF_CIDFont;
-class CPDF_Type3Font;
-class CPDF_FontEncoding;
-class CPDF_CMap;
-class CPDF_CID2UnicodeMap;
-class CPDF_ColorSpace;
-class CPDF_Color;
-class CPDF_Function;
-class CPDF_Pattern;
-class CPDF_TilingPattern;
-class CPDF_ShadingPattern;
-class CPDF_Image;
-class CPDF_Face;
-class CPDF_ToUnicodeMap;
-class CFX_SubstFont;
-class CFX_Font;
-class CPDF_RenderContext;
-class CPDF_Form;
-class CPDF_ImageObject;
-class CFX_DIBitmap;
-typedef struct FT_FaceRec_* FXFT_Face;
-class CFX_CTTGSUBTable;
-class CPDF_Page;
-#define PDFFONT_TYPE1 1
-#define PDFFONT_TRUETYPE 2
-#define PDFFONT_TYPE3 3
-#define PDFFONT_CIDFONT 4
-#define PDFFONT_FIXEDPITCH 1
-#define PDFFONT_SERIF 2
-#define PDFFONT_SYMBOLIC 4
-#define PDFFONT_SCRIPT 8
-#define PDFFONT_NONSYMBOLIC 32
-#define PDFFONT_ITALIC 64
-#define PDFFONT_ALLCAP 0x10000
-#define PDFFONT_SMALLCAP 0x20000
-#define PDFFONT_FORCEBOLD 0x40000
-#define PDFFONT_USEEXTERNATTR 0x80000
-FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name);
-CFX_ByteString PDF_AdobeNameFromUnicode(FX_WCHAR unicode);
-class CPDF_Font : public CFX_Object
-{
-public:
-
- static CPDF_Font* CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDict);
-
- static CPDF_Font* GetStockFont(CPDF_Document* pDoc, FX_BSTR fontname);
-
- virtual ~CPDF_Font();
-
-
-
-
- int GetFontType() const
- {
- return m_FontType;
- }
-
- CFX_ByteString GetFontTypeName() const;
-
- const CFX_ByteString& GetBaseFont() const
- {
- return m_BaseFont;
- }
-
- const CFX_SubstFont* GetSubstFont() const
- {
- return m_Font.GetSubstFont();
- }
-
- FX_DWORD GetFlags() const
- {
- return m_Flags;
- }
-
- virtual FX_BOOL IsVertWriting()const;
-
-
-
-
- CPDF_Type1Font* GetType1Font() const
- {
- return m_FontType == PDFFONT_TYPE1 ? (CPDF_Type1Font*)(void*)this : NULL;
- }
-
- CPDF_TrueTypeFont* GetTrueTypeFont() const
- {
- return m_FontType == PDFFONT_TRUETYPE ? (CPDF_TrueTypeFont*)(void*)this : NULL;
- }
-
- CPDF_CIDFont* GetCIDFont() const
- {
- return (m_FontType == PDFFONT_CIDFONT) ? (CPDF_CIDFont*)(void*)this : NULL;
- }
-
- CPDF_Type3Font* GetType3Font() const
- {
- return (m_FontType == PDFFONT_TYPE3) ? (CPDF_Type3Font*)(void*)this : NULL;
- }
-
-
- FX_BOOL IsEmbedded() const
- {
- return m_FontType == PDFFONT_TYPE3 || m_pFontFile != NULL;
- }
-
- virtual FX_BOOL IsUnicodeCompatible() const
- {
- return FALSE;
- }
-
- CPDF_StreamAcc* GetFontFile() const
- {
- return m_pFontFile;
- }
-
- CPDF_Dictionary* GetFontDict() const
- {
- return m_pFontDict;
- }
-
- FX_BOOL IsStandardFont() const;
-
- FXFT_Face GetFace() const
- {
- return m_Font.GetFace();
- }
-
-
-
- virtual FX_DWORD GetNextChar(FX_LPCSTR pString, int& offset) const
- {
- return (FX_BYTE)pString[offset++];
- }
-
- virtual int CountChar(FX_LPCSTR pString, int size) const
- {
- return size;
- }
-
- void AppendChar(CFX_ByteString& str, FX_DWORD charcode) const;
-
- virtual int AppendChar(FX_LPSTR buf, FX_DWORD charcode) const
- {
- *buf = (FX_CHAR)charcode;
- return 1;
- }
-
- virtual int GetCharSize(FX_DWORD charcode) const
- {
- return 1;
- }
-
-
-
-
- virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL) = 0;
- virtual int GlyphFromCharCodeExt(FX_DWORD charcode)
- {
- return GlyphFromCharCode(charcode);
- }
-
- CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const;
-
- FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const;
-
- CFX_CharMap* GetCharMap()
- {
- return m_pCharMap;
- }
-
- CFX_ByteString EncodeString(const CFX_WideString& str) const;
-
- CFX_WideString DecodeString(const CFX_ByteString& str) const;
-
-
-
-
- void GetFontBBox(FX_RECT& rect) const
- {
- rect = m_FontBBox;
- }
-
- int GetTypeAscent() const
- {
- return m_Ascent;
- }
-
- int GetTypeDescent() const
- {
- return m_Descent;
- }
-
- int GetItalicAngle() const
- {
- return m_ItalicAngle;
- }
-
- int GetStemV() const
- {
- return m_StemV;
- }
-
- int GetStringWidth(const FX_CHAR* pString, int size);
-
- virtual int GetCharWidthF(FX_DWORD charcode, int level = 0) = 0;
-
- virtual int GetCharTypeWidth(FX_DWORD charcode);
-
- virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0) = 0;
-
-
-
- CPDF_Document* m_pDocument;
-
- class CFX_PathData* LoadGlyphPath(FX_DWORD charcode, int dest_width = 0);
-
- CFX_Font m_Font;
-protected:
-
- CPDF_Font();
-
- FX_BOOL Initialize();
-
- FX_BOOL Load();
-
- virtual FX_BOOL _Load() = 0;
-
- virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const = 0;
-
- virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const = 0;
-
- void LoadUnicodeMap();
-
- void LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding,
- CFX_ByteString*& pCharNames, FX_BOOL bEmbedded, FX_BOOL bTrueType);
-
- void LoadFontDescriptor(CPDF_Dictionary*);
-
- void LoadCharWidths(FX_WORD* pWidths);
-
- void CheckFontMetrics();
-
- CFX_CharMap* m_pCharMap;
-
-
-
- int m_FontType;
-
- CFX_ByteString m_BaseFont;
-
- CPDF_StreamAcc* m_pFontFile;
-
- CPDF_Dictionary* m_pFontDict;
-
- CPDF_ToUnicodeMap* m_pToUnicodeMap;
-
- FX_BOOL m_bToUnicodeLoaded;
-
-
-
-
- int m_Flags;
-
- FX_RECT m_FontBBox;
-
- int m_StemV;
-
- int m_Ascent;
-
- int m_Descent;
-
- int m_ItalicAngle;
-
-};
-#define PDFFONT_ENCODING_BUILTIN 0
-#define PDFFONT_ENCODING_WINANSI 1
-#define PDFFONT_ENCODING_MACROMAN 2
-#define PDFFONT_ENCODING_MACEXPERT 3
-#define PDFFONT_ENCODING_STANDARD 4
-#define PDFFONT_ENCODING_ADOBE_SYMBOL 5
-#define PDFFONT_ENCODING_ZAPFDINGBATS 6
-#define PDFFONT_ENCODING_PDFDOC 7
-#define PDFFONT_ENCODING_MS_SYMBOL 8
-#define PDFFONT_ENCODING_UNICODE 9
-class CPDF_FontEncoding : public CFX_Object
-{
-public:
-
- CPDF_FontEncoding();
-
- CPDF_FontEncoding(int PredefinedEncoding);
-
- void LoadEncoding(CPDF_Object* pEncoding);
-
- FX_BOOL IsIdentical(CPDF_FontEncoding* pAnother) const;
-
- FX_WCHAR UnicodeFromCharCode(FX_BYTE charcode) const
- {
- return m_Unicodes[charcode];
- }
-
- int CharCodeFromUnicode(FX_WCHAR unicode) const;
-
- void SetUnicode(FX_BYTE charcode, FX_WCHAR unicode)
- {
- m_Unicodes[charcode] = unicode;
- }
-
- CPDF_Object* Realize();
-public:
-
- FX_WCHAR m_Unicodes[256];
-};
-class CPDF_SimpleFont : public CPDF_Font
-{
-public:
-
- CPDF_SimpleFont();
-
- virtual ~CPDF_SimpleFont();
-
- CPDF_FontEncoding* GetEncoding()
- {
- return &m_Encoding;
- }
- virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
- virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
- virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL);
- virtual FX_BOOL IsUnicodeCompatible() const;
-protected:
-
- FX_BOOL LoadCommon();
-
- void LoadSubstFont();
-
- void LoadFaceMetrics();
-
- virtual void LoadGlyphMap() = 0;
- virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const
- {
- return m_Encoding.UnicodeFromCharCode((FX_BYTE)charcode);
- }
- virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const
- {
- return m_Encoding.CharCodeFromUnicode(Unicode);
- }
-
-
-
- CPDF_FontEncoding m_Encoding;
-
- FX_WORD m_GlyphIndex[256];
- FX_WORD m_ExtGID[256];
-
-
-
-
- CFX_ByteString* m_pCharNames;
-
- int m_BaseEncoding;
-
-
-
-
- FX_WORD m_CharWidth[256];
-
- FX_SMALL_RECT m_CharBBox[256];
-
- FX_BOOL m_bUseFontWidth;
-
- void LoadCharMetrics(int charcode);
-
-};
-class CPDF_Type1Font : public CPDF_SimpleFont
-{
-public:
-
- CPDF_Type1Font();
-
- int GetBase14Font()
- {
- return m_Base14Font;
- }
- virtual int GlyphFromCharCodeExt(FX_DWORD charcode);
-protected:
- virtual FX_BOOL _Load();
-
- int m_Base14Font;
- virtual void LoadGlyphMap();
-};
-class CPDF_TrueTypeFont : public CPDF_SimpleFont
-{
-public:
-
- CPDF_TrueTypeFont();
-protected:
- virtual FX_BOOL _Load();
- virtual void LoadGlyphMap();
-};
-class CPDF_Type3Char : public CFX_Object
-{
-public:
-
- CPDF_Type3Char();
-
- ~CPDF_Type3Char();
-
- FX_BOOL LoadBitmap(CPDF_RenderContext* pContext);
-
- FX_BOOL m_bColored;
-
- FX_BOOL m_bPageRequired;
-
-
-
- CPDF_Form* m_pForm;
-
- CFX_AffineMatrix m_ImageMatrix;
-
- CFX_DIBitmap* m_pBitmap;
-
-
- int m_Width;
-
- FX_RECT m_BBox;
-};
-class CPDF_Type3Font : public CPDF_SimpleFont
-{
-public:
- CPDF_Type3Font();
- virtual ~CPDF_Type3Font();
- void SetPageResources(CPDF_Dictionary* pResources)
- {
- m_pPageResources = pResources;
- }
- CPDF_Type3Char* LoadChar(FX_DWORD charcode, int level = 0);
- virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
- virtual int GetCharTypeWidth(FX_DWORD charcode)
- {
- return GetCharWidthF(charcode);
- }
- virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
- CFX_AffineMatrix& GetFontMatrix()
- {
- return m_FontMatrix;
- }
- void CheckType3FontMetrics();
-private:
- virtual FX_BOOL _Load();
- virtual void LoadGlyphMap() {}
- int m_CharWidthL[256];
- CPDF_Dictionary* m_pCharProcs;
- CPDF_Dictionary* m_pPageResources;
- CPDF_Dictionary* m_pFontResources;
- CFX_MapPtrToPtr m_CacheMap;
- CFX_MapPtrToPtr m_DeletedMap;
-protected:
- CFX_AffineMatrix m_FontMatrix;
-};
-#define CIDSET_UNKNOWN 0
-#define CIDSET_GB1 1
-#define CIDSET_CNS1 2
-#define CIDSET_JAPAN1 3
-#define CIDSET_KOREA1 4
-#define CIDSET_UNICODE 5
-class CPDF_CIDFont : public CPDF_Font
-{
-public:
-
- CPDF_CIDFont();
-
- virtual ~CPDF_CIDFont();
-
- FX_BOOL LoadGB2312();
- virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL);
- virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
- virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
-
- FX_WORD CIDFromCharCode(FX_DWORD charcode) const;
-
- FX_BOOL IsTrueType()
- {
- return !m_bType1;
- }
-
-
- virtual FX_DWORD GetNextChar(const FX_CHAR* pString, int& offset) const;
- virtual int CountChar(const FX_CHAR* pString, int size) const;
- virtual int AppendChar(FX_LPSTR str, FX_DWORD charcode) const;
- virtual int GetCharSize(FX_DWORD charcode) const;
-
-
- int GetCharset() const
- {
- return m_Charset;
- }
-
- FX_LPCBYTE GetCIDTransform(FX_WORD CID) const;
-
-
-
- virtual FX_BOOL IsVertWriting() const;
-
- short GetVertWidth(FX_WORD CID) const;
-
- void GetVertOrigin(FX_WORD CID, short& vx, short& vy) const;
-
- virtual FX_BOOL IsUnicodeCompatible() const;
- virtual FX_BOOL IsFontStyleFromCharCode(FX_DWORD charcode) const;
-protected:
- friend class CPDF_Font;
- virtual FX_BOOL _Load();
- virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const;
- virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const;
- int GetGlyphIndex(FX_DWORD unicodeb, FX_BOOL *pVertGlyph);
-
- CPDF_CMap* m_pCMap;
-
- CPDF_CMap* m_pAllocatedCMap;
-
- CPDF_CID2UnicodeMap* m_pCID2UnicodeMap;
-
- int m_Charset;
-
- FX_BOOL m_bType1;
-
- CPDF_StreamAcc* m_pCIDToGIDMap;
- FX_BOOL m_bCIDIsGID;
-
-
-
- FX_WORD m_DefaultWidth;
-
- FX_WORD* m_pAnsiWidths;
-
- FX_SMALL_RECT m_CharBBox[256];
-
- CFX_DWordArray m_WidthList;
-
- short m_DefaultVY;
-
- short m_DefaultW1;
-
- CFX_DWordArray m_VertMetrics;
-
-
- void LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, int nElements);
-
- void LoadSubstFont();
-
- FX_BOOL m_bAdobeCourierStd;
-
- CFX_CTTGSUBTable* m_pTTGSUBTable;
-};
-#define PDFCS_DEVICEGRAY 1
-
-#define PDFCS_DEVICERGB 2
-#define PDFCS_DEVICECMYK 3
-#define PDFCS_CALGRAY 4
-#define PDFCS_CALRGB 5
-#define PDFCS_LAB 6
-#define PDFCS_ICCBASED 7
-#define PDFCS_SEPARATION 8
-#define PDFCS_DEVICEN 9
-#define PDFCS_INDEXED 10
-#define PDFCS_PATTERN 11
-class CPDF_ColorSpace : public CFX_Object
-{
-public:
-
- static CPDF_ColorSpace* GetStockCS(int Family);
-
- static CPDF_ColorSpace* Load(CPDF_Document* pDoc, CPDF_Object* pCSObj);
-
- void ReleaseCS();
-
- int GetBufSize() const;
-
- FX_FLOAT* CreateBuf();
-
- void GetDefaultColor(FX_FLOAT* buf) const;
-
- int CountComponents() const
- {
- return m_nComponents;
- }
-
- int GetFamily() const
- {
- return m_Family;
- }
-
- virtual void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const
- {
- value = 0;
- min = 0;
- max = 1.0f;
- }
-
- FX_BOOL sRGB() const;
-
-
-
- virtual FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const = 0;
-
- virtual FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const
- {
- return FALSE;
- }
-
-
-
-
- FX_BOOL GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const;
-
- FX_BOOL SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const;
-
-
- virtual void TranslateImageLine(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels,
- int image_width, int image_height, FX_BOOL bTransMask = FALSE) const;
-
- CPDF_Array*& GetArray()
- {
- return m_pArray;
- }
-
- int GetMaxIndex() const;
-
- virtual CPDF_ColorSpace* GetBaseCS() const
- {
- return NULL;
- }
-
- virtual void EnableStdConversion(FX_BOOL bEnabled);
- CPDF_Document* m_pDocument;
-protected:
-
- CPDF_ColorSpace();
-
- virtual ~CPDF_ColorSpace() {}
- virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
- {
- return TRUE;
- }
- virtual FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const
- {
- return FALSE;
- }
- virtual FX_BOOL v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const
- {
- return FALSE;
- }
-
- int m_Family;
-
- int m_nComponents;
-
- CPDF_Array* m_pArray;
-
- FX_DWORD m_dwStdConversion;
-};
-class CPDF_Color : public CFX_Object
-{
-public:
-
- CPDF_Color()
- {
- m_pBuffer = NULL;
- m_pCS = NULL;
- }
-
- CPDF_Color(int family);
-
- ~CPDF_Color();
-
- FX_BOOL IsNull() const
- {
- return m_pBuffer == NULL;
- }
-
- FX_BOOL IsEqual(const CPDF_Color& other) const;
-
- FX_BOOL IsPattern() const
- {
- return m_pCS && m_pCS->GetFamily() == PDFCS_PATTERN;
- }
-
- void Copy(const CPDF_Color* pSrc);
-
- void SetColorSpace(CPDF_ColorSpace* pCS);
-
- void SetValue(FX_FLOAT* comp);
-
- void SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comp, int ncomps);
-
- FX_BOOL GetRGB(int& R, int& G, int& B) const;
-
- CPDF_Pattern* GetPattern() const;
-
- CPDF_ColorSpace* GetPatternCS() const;
-
- FX_FLOAT* GetPatternColor() const;
-
- CPDF_ColorSpace* m_pCS;
-
- FX_FLOAT* m_pBuffer;
-protected:
- void ReleaseBuffer();
- void ReleaseColorSpace();
-};
-#define PATTERN_TILING 1
-#define PATTERN_SHADING 2
-class CPDF_Pattern : public CFX_Object
-{
-public:
-
- virtual ~CPDF_Pattern() {}
-
- CPDF_Object* m_pPatternObj;
-
- int m_PatternType;
-
- CFX_AffineMatrix m_Pattern2Form;
- CFX_AffineMatrix m_ParentMatrix;
-
- CPDF_Document* m_pDocument;
-
-protected:
-
- CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix)
- {
- if (pParentMatrix) {
- m_ParentMatrix = *pParentMatrix;
- }
- }
-};
-class CPDF_TilingPattern : public CPDF_Pattern
-{
-public:
-
- CPDF_TilingPattern(CPDF_Document* pDoc, CPDF_Object* pPatternObj, const CFX_AffineMatrix* parentMatrix);
-
- virtual ~CPDF_TilingPattern();
-
- FX_BOOL Load();
-
-
-
- FX_BOOL m_bColored;
-
- CFX_FloatRect m_BBox;
-
- FX_FLOAT m_XStep;
-
- FX_FLOAT m_YStep;
-
-
-
- CPDF_Form* m_pForm;
-};
-class CPDF_ShadingPattern : public CPDF_Pattern
-{
-public:
-
- CPDF_ShadingPattern(CPDF_Document* pDoc, CPDF_Object* pPatternObj, FX_BOOL bShading, const CFX_AffineMatrix* parentMatrix);
-
- virtual ~CPDF_ShadingPattern();
-
- CPDF_Object* m_pShadingObj;
-
- FX_BOOL m_bShadingObj;
-
- FX_BOOL Load();
-
- FX_BOOL Reload();
-
- int m_ShadingType;
-
- CPDF_ColorSpace* m_pCS;
-
-
- CPDF_Function* m_pFunctions[4];
-
- int m_nFuncs;
-protected:
- void Clear();
-};
-struct CPDF_MeshVertex {
- FX_FLOAT x, y;
- FX_FLOAT r, g, b;
-};
-class CPDF_MeshStream : public CFX_Object
-{
-public:
-
- FX_BOOL Load(CPDF_Stream* pShadingStream, CPDF_Function** pFuncs, int nFuncs, CPDF_ColorSpace* pCS);
-
- FX_DWORD GetFlag();
-
- void GetCoords(FX_FLOAT& x, FX_FLOAT& y);
-
- void GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b);
-
- FX_DWORD GetVertex(CPDF_MeshVertex& vertex, CFX_AffineMatrix* pObject2Bitmap);
-
- FX_BOOL GetVertexRow(CPDF_MeshVertex* vertex, int count, CFX_AffineMatrix* pObject2Bitmap);
- CPDF_Function** m_pFuncs;
- CPDF_ColorSpace* m_pCS;
- FX_DWORD m_nFuncs, m_nCoordBits, m_nCompBits, m_nFlagBits, m_nComps;
- FX_DWORD m_CoordMax, m_CompMax;
- FX_FLOAT m_xmin, m_xmax, m_ymin, m_ymax;
- FX_FLOAT m_ColorMin[8], m_ColorMax[8];
- CPDF_StreamAcc m_Stream;
- CFX_BitStream m_BitStream;
-};
-#define PDF_IMAGE_NO_COMPRESS 0x0000
-#define PDF_IMAGE_LOSSY_COMPRESS 0x0001
-#define PDF_IMAGE_LOSSLESS_COMPRESS 0x0002
-#define PDF_IMAGE_MASK_LOSSY_COMPRESS 0x0004
-#define PDF_IMAGE_MASK_LOSSLESS_COMPRESS 0x0008
-class CPDF_ImageSetParam
-{
-public:
- CPDF_ImageSetParam()
- : pMatteColor(NULL)
- , nQuality(80)
- {
- }
- FX_ARGB* pMatteColor;
- FX_INT32 nQuality;
-};
-class CPDF_Image : public CFX_Object
-{
-public:
-
- CPDF_Image(CPDF_Document* pDoc);
-
- ~CPDF_Image();
-
- FX_BOOL LoadImageF(CPDF_Stream* pImageStream, FX_BOOL bInline);
-
- void Release();
-
- CPDF_Image* Clone();
-
- FX_BOOL IsInline()
- {
- return m_bInline;
- }
-
- void SetInlineDict(CPDF_Dictionary* pDict)
- {
- m_pInlineDict = pDict;
- }
-
- CPDF_Dictionary* GetInlineDict() const
- {
- return m_pInlineDict;
- }
-
- CPDF_Stream* GetStream() const
- {
- return m_pStream;
- }
-
- CPDF_Dictionary* GetDict() const
- {
- return m_pStream->GetDict();
- }
-
- CPDF_Dictionary* GetOC() const
- {
- return m_pOC;
- }
-
- CPDF_Document* GetDocument() const
- {
- return m_pDocument;
- }
-
-
-
- FX_INT32 GetPixelHeight() const
- {
- return m_Height;
- }
-
- FX_INT32 GetPixelWidth() const
- {
- return m_Width;
- }
-
-
- FX_BOOL IsMask() const
- {
- return m_bIsMask;
- }
-
- FX_BOOL IsInterpol() const
- {
- return m_bInterpolate;
- }
-
- CFX_DIBSource* LoadDIBSource(CFX_DIBSource** ppMask = NULL, FX_DWORD* pMatteColor = NULL, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE) const;
-
-
-
- void SetImage(const CFX_DIBitmap* pDIBitmap, FX_INT32 iCompress, IFX_FileWrite *pFileWrite = NULL, IFX_FileRead *pFileRead = NULL, const CFX_DIBitmap* pMask = NULL, const CPDF_ImageSetParam* pParam = NULL);
-
- void SetJpegImage(FX_BYTE* pImageData, FX_DWORD size);
-
- void SetJpegImage(IFX_FileRead *pFile);
-
- void ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pDIBitmap);
-
-public:
- FX_BOOL StartLoadDIBSource(CPDF_Dictionary* pFormResource, CPDF_Dictionary* pPageResource, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE);
- FX_BOOL Continue(IFX_Pause* pPause);
- CFX_DIBSource* DetachBitmap();
- CFX_DIBSource* DetachMask();
- CFX_DIBSource* m_pDIBSource;
- CFX_DIBSource* m_pMask;
- FX_DWORD m_MatteColor;
-private:
-
- CPDF_Stream* m_pStream;
- FX_BOOL m_bInline;
- CPDF_Dictionary* m_pInlineDict;
-
- FX_INT32 m_Height;
-
- FX_INT32 m_Width;
-
- FX_BOOL m_bIsMask;
-
- FX_BOOL m_bInterpolate;
-
- CPDF_Document* m_pDocument;
-
- CPDF_Dictionary* m_pOC;
- CPDF_Dictionary* InitJPEG(FX_LPBYTE pData, FX_DWORD size);
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_RESOURCE_
+#define _FPDF_RESOURCE_
+#ifndef _FPDF_PARSER_
+#include "fpdf_parser.h"
+#endif
+#ifndef _FX_FONT_H_
+#include "../fxge/fx_font.h"
+#endif
+class CPDF_Font;
+class CPDF_Type1Font;
+class CPDF_TrueTypeFont;
+class CPDF_CIDFont;
+class CPDF_Type3Font;
+class CPDF_FontEncoding;
+class CPDF_CMap;
+class CPDF_CID2UnicodeMap;
+class CPDF_ColorSpace;
+class CPDF_Color;
+class CPDF_Function;
+class CPDF_Pattern;
+class CPDF_TilingPattern;
+class CPDF_ShadingPattern;
+class CPDF_Image;
+class CPDF_Face;
+class CPDF_ToUnicodeMap;
+class CFX_SubstFont;
+class CFX_Font;
+class CPDF_RenderContext;
+class CPDF_Form;
+class CPDF_ImageObject;
+class CFX_DIBitmap;
+typedef struct FT_FaceRec_* FXFT_Face;
+class CFX_CTTGSUBTable;
+class CPDF_Page;
+#define PDFFONT_TYPE1 1
+#define PDFFONT_TRUETYPE 2
+#define PDFFONT_TYPE3 3
+#define PDFFONT_CIDFONT 4
+#define PDFFONT_FIXEDPITCH 1
+#define PDFFONT_SERIF 2
+#define PDFFONT_SYMBOLIC 4
+#define PDFFONT_SCRIPT 8
+#define PDFFONT_NONSYMBOLIC 32
+#define PDFFONT_ITALIC 64
+#define PDFFONT_ALLCAP 0x10000
+#define PDFFONT_SMALLCAP 0x20000
+#define PDFFONT_FORCEBOLD 0x40000
+#define PDFFONT_USEEXTERNATTR 0x80000
+FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name);
+CFX_ByteString PDF_AdobeNameFromUnicode(FX_WCHAR unicode);
+class CPDF_Font : public CFX_Object
+{
+public:
+
+ static CPDF_Font* CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDict);
+
+ static CPDF_Font* GetStockFont(CPDF_Document* pDoc, FX_BSTR fontname);
+
+ virtual ~CPDF_Font();
+
+
+
+
+ int GetFontType() const
+ {
+ return m_FontType;
+ }
+
+ CFX_ByteString GetFontTypeName() const;
+
+ const CFX_ByteString& GetBaseFont() const
+ {
+ return m_BaseFont;
+ }
+
+ const CFX_SubstFont* GetSubstFont() const
+ {
+ return m_Font.GetSubstFont();
+ }
+
+ FX_DWORD GetFlags() const
+ {
+ return m_Flags;
+ }
+
+ virtual FX_BOOL IsVertWriting()const;
+
+
+
+
+ CPDF_Type1Font* GetType1Font() const
+ {
+ return m_FontType == PDFFONT_TYPE1 ? (CPDF_Type1Font*)(void*)this : NULL;
+ }
+
+ CPDF_TrueTypeFont* GetTrueTypeFont() const
+ {
+ return m_FontType == PDFFONT_TRUETYPE ? (CPDF_TrueTypeFont*)(void*)this : NULL;
+ }
+
+ CPDF_CIDFont* GetCIDFont() const
+ {
+ return (m_FontType == PDFFONT_CIDFONT) ? (CPDF_CIDFont*)(void*)this : NULL;
+ }
+
+ CPDF_Type3Font* GetType3Font() const
+ {
+ return (m_FontType == PDFFONT_TYPE3) ? (CPDF_Type3Font*)(void*)this : NULL;
+ }
+
+
+ FX_BOOL IsEmbedded() const
+ {
+ return m_FontType == PDFFONT_TYPE3 || m_pFontFile != NULL;
+ }
+
+ virtual FX_BOOL IsUnicodeCompatible() const
+ {
+ return FALSE;
+ }
+
+ CPDF_StreamAcc* GetFontFile() const
+ {
+ return m_pFontFile;
+ }
+
+ CPDF_Dictionary* GetFontDict() const
+ {
+ return m_pFontDict;
+ }
+
+ FX_BOOL IsStandardFont() const;
+
+ FXFT_Face GetFace() const
+ {
+ return m_Font.GetFace();
+ }
+
+
+
+ virtual FX_DWORD GetNextChar(FX_LPCSTR pString, int& offset) const
+ {
+ return (FX_BYTE)pString[offset++];
+ }
+
+ virtual int CountChar(FX_LPCSTR pString, int size) const
+ {
+ return size;
+ }
+
+ void AppendChar(CFX_ByteString& str, FX_DWORD charcode) const;
+
+ virtual int AppendChar(FX_LPSTR buf, FX_DWORD charcode) const
+ {
+ *buf = (FX_CHAR)charcode;
+ return 1;
+ }
+
+ virtual int GetCharSize(FX_DWORD charcode) const
+ {
+ return 1;
+ }
+
+
+
+
+ virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL) = 0;
+ virtual int GlyphFromCharCodeExt(FX_DWORD charcode)
+ {
+ return GlyphFromCharCode(charcode);
+ }
+
+ CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const;
+
+ FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const;
+
+ CFX_CharMap* GetCharMap()
+ {
+ return m_pCharMap;
+ }
+
+ CFX_ByteString EncodeString(const CFX_WideString& str) const;
+
+ CFX_WideString DecodeString(const CFX_ByteString& str) const;
+
+
+
+
+ void GetFontBBox(FX_RECT& rect) const
+ {
+ rect = m_FontBBox;
+ }
+
+ int GetTypeAscent() const
+ {
+ return m_Ascent;
+ }
+
+ int GetTypeDescent() const
+ {
+ return m_Descent;
+ }
+
+ int GetItalicAngle() const
+ {
+ return m_ItalicAngle;
+ }
+
+ int GetStemV() const
+ {
+ return m_StemV;
+ }
+
+ int GetStringWidth(const FX_CHAR* pString, int size);
+
+ virtual int GetCharWidthF(FX_DWORD charcode, int level = 0) = 0;
+
+ virtual int GetCharTypeWidth(FX_DWORD charcode);
+
+ virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0) = 0;
+
+
+
+ CPDF_Document* m_pDocument;
+
+ class CFX_PathData* LoadGlyphPath(FX_DWORD charcode, int dest_width = 0);
+
+ CFX_Font m_Font;
+protected:
+
+ CPDF_Font();
+
+ FX_BOOL Initialize();
+
+ FX_BOOL Load();
+
+ virtual FX_BOOL _Load() = 0;
+
+ virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const = 0;
+
+ virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const = 0;
+
+ void LoadUnicodeMap();
+
+ void LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding,
+ CFX_ByteString*& pCharNames, FX_BOOL bEmbedded, FX_BOOL bTrueType);
+
+ void LoadFontDescriptor(CPDF_Dictionary*);
+
+ void LoadCharWidths(FX_WORD* pWidths);
+
+ void CheckFontMetrics();
+
+ CFX_CharMap* m_pCharMap;
+
+
+
+ int m_FontType;
+
+ CFX_ByteString m_BaseFont;
+
+ CPDF_StreamAcc* m_pFontFile;
+
+ CPDF_Dictionary* m_pFontDict;
+
+ CPDF_ToUnicodeMap* m_pToUnicodeMap;
+
+ FX_BOOL m_bToUnicodeLoaded;
+
+
+
+
+ int m_Flags;
+
+ FX_RECT m_FontBBox;
+
+ int m_StemV;
+
+ int m_Ascent;
+
+ int m_Descent;
+
+ int m_ItalicAngle;
+
+};
+#define PDFFONT_ENCODING_BUILTIN 0
+#define PDFFONT_ENCODING_WINANSI 1
+#define PDFFONT_ENCODING_MACROMAN 2
+#define PDFFONT_ENCODING_MACEXPERT 3
+#define PDFFONT_ENCODING_STANDARD 4
+#define PDFFONT_ENCODING_ADOBE_SYMBOL 5
+#define PDFFONT_ENCODING_ZAPFDINGBATS 6
+#define PDFFONT_ENCODING_PDFDOC 7
+#define PDFFONT_ENCODING_MS_SYMBOL 8
+#define PDFFONT_ENCODING_UNICODE 9
+class CPDF_FontEncoding : public CFX_Object
+{
+public:
+
+ CPDF_FontEncoding();
+
+ CPDF_FontEncoding(int PredefinedEncoding);
+
+ void LoadEncoding(CPDF_Object* pEncoding);
+
+ FX_BOOL IsIdentical(CPDF_FontEncoding* pAnother) const;
+
+ FX_WCHAR UnicodeFromCharCode(FX_BYTE charcode) const
+ {
+ return m_Unicodes[charcode];
+ }
+
+ int CharCodeFromUnicode(FX_WCHAR unicode) const;
+
+ void SetUnicode(FX_BYTE charcode, FX_WCHAR unicode)
+ {
+ m_Unicodes[charcode] = unicode;
+ }
+
+ CPDF_Object* Realize();
+public:
+
+ FX_WCHAR m_Unicodes[256];
+};
+class CPDF_SimpleFont : public CPDF_Font
+{
+public:
+
+ CPDF_SimpleFont();
+
+ virtual ~CPDF_SimpleFont();
+
+ CPDF_FontEncoding* GetEncoding()
+ {
+ return &m_Encoding;
+ }
+ virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
+ virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
+ virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL);
+ virtual FX_BOOL IsUnicodeCompatible() const;
+protected:
+
+ FX_BOOL LoadCommon();
+
+ void LoadSubstFont();
+
+ void LoadFaceMetrics();
+
+ virtual void LoadGlyphMap() = 0;
+ virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const
+ {
+ return m_Encoding.UnicodeFromCharCode((FX_BYTE)charcode);
+ }
+ virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const
+ {
+ return m_Encoding.CharCodeFromUnicode(Unicode);
+ }
+
+
+
+ CPDF_FontEncoding m_Encoding;
+
+ FX_WORD m_GlyphIndex[256];
+ FX_WORD m_ExtGID[256];
+
+
+
+
+ CFX_ByteString* m_pCharNames;
+
+ int m_BaseEncoding;
+
+
+
+
+ FX_WORD m_CharWidth[256];
+
+ FX_SMALL_RECT m_CharBBox[256];
+
+ FX_BOOL m_bUseFontWidth;
+
+ void LoadCharMetrics(int charcode);
+
+};
+class CPDF_Type1Font : public CPDF_SimpleFont
+{
+public:
+
+ CPDF_Type1Font();
+
+ int GetBase14Font()
+ {
+ return m_Base14Font;
+ }
+ virtual int GlyphFromCharCodeExt(FX_DWORD charcode);
+protected:
+ virtual FX_BOOL _Load();
+
+ int m_Base14Font;
+ virtual void LoadGlyphMap();
+};
+class CPDF_TrueTypeFont : public CPDF_SimpleFont
+{
+public:
+
+ CPDF_TrueTypeFont();
+protected:
+ virtual FX_BOOL _Load();
+ virtual void LoadGlyphMap();
+};
+class CPDF_Type3Char : public CFX_Object
+{
+public:
+
+ CPDF_Type3Char();
+
+ ~CPDF_Type3Char();
+
+ FX_BOOL LoadBitmap(CPDF_RenderContext* pContext);
+
+ FX_BOOL m_bColored;
+
+ FX_BOOL m_bPageRequired;
+
+
+
+ CPDF_Form* m_pForm;
+
+ CFX_AffineMatrix m_ImageMatrix;
+
+ CFX_DIBitmap* m_pBitmap;
+
+
+ int m_Width;
+
+ FX_RECT m_BBox;
+};
+class CPDF_Type3Font : public CPDF_SimpleFont
+{
+public:
+ CPDF_Type3Font();
+ virtual ~CPDF_Type3Font();
+ void SetPageResources(CPDF_Dictionary* pResources)
+ {
+ m_pPageResources = pResources;
+ }
+ CPDF_Type3Char* LoadChar(FX_DWORD charcode, int level = 0);
+ virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
+ virtual int GetCharTypeWidth(FX_DWORD charcode)
+ {
+ return GetCharWidthF(charcode);
+ }
+ virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
+ CFX_AffineMatrix& GetFontMatrix()
+ {
+ return m_FontMatrix;
+ }
+ void CheckType3FontMetrics();
+private:
+ virtual FX_BOOL _Load();
+ virtual void LoadGlyphMap() {}
+ int m_CharWidthL[256];
+ CPDF_Dictionary* m_pCharProcs;
+ CPDF_Dictionary* m_pPageResources;
+ CPDF_Dictionary* m_pFontResources;
+ CFX_MapPtrToPtr m_CacheMap;
+ CFX_MapPtrToPtr m_DeletedMap;
+protected:
+ CFX_AffineMatrix m_FontMatrix;
+};
+#define CIDSET_UNKNOWN 0
+#define CIDSET_GB1 1
+#define CIDSET_CNS1 2
+#define CIDSET_JAPAN1 3
+#define CIDSET_KOREA1 4
+#define CIDSET_UNICODE 5
+class CPDF_CIDFont : public CPDF_Font
+{
+public:
+
+ CPDF_CIDFont();
+
+ virtual ~CPDF_CIDFont();
+
+ FX_BOOL LoadGB2312();
+ virtual int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph = NULL);
+ virtual int GetCharWidthF(FX_DWORD charcode, int level = 0);
+ virtual void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0);
+
+ FX_WORD CIDFromCharCode(FX_DWORD charcode) const;
+
+ FX_BOOL IsTrueType()
+ {
+ return !m_bType1;
+ }
+
+
+ virtual FX_DWORD GetNextChar(const FX_CHAR* pString, int& offset) const;
+ virtual int CountChar(const FX_CHAR* pString, int size) const;
+ virtual int AppendChar(FX_LPSTR str, FX_DWORD charcode) const;
+ virtual int GetCharSize(FX_DWORD charcode) const;
+
+
+ int GetCharset() const
+ {
+ return m_Charset;
+ }
+
+ FX_LPCBYTE GetCIDTransform(FX_WORD CID) const;
+
+
+
+ virtual FX_BOOL IsVertWriting() const;
+
+ short GetVertWidth(FX_WORD CID) const;
+
+ void GetVertOrigin(FX_WORD CID, short& vx, short& vy) const;
+
+ virtual FX_BOOL IsUnicodeCompatible() const;
+ virtual FX_BOOL IsFontStyleFromCharCode(FX_DWORD charcode) const;
+protected:
+ friend class CPDF_Font;
+ virtual FX_BOOL _Load();
+ virtual FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const;
+ virtual FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const;
+ int GetGlyphIndex(FX_DWORD unicodeb, FX_BOOL *pVertGlyph);
+
+ CPDF_CMap* m_pCMap;
+
+ CPDF_CMap* m_pAllocatedCMap;
+
+ CPDF_CID2UnicodeMap* m_pCID2UnicodeMap;
+
+ int m_Charset;
+
+ FX_BOOL m_bType1;
+
+ CPDF_StreamAcc* m_pCIDToGIDMap;
+ FX_BOOL m_bCIDIsGID;
+
+
+
+ FX_WORD m_DefaultWidth;
+
+ FX_WORD* m_pAnsiWidths;
+
+ FX_SMALL_RECT m_CharBBox[256];
+
+ CFX_DWordArray m_WidthList;
+
+ short m_DefaultVY;
+
+ short m_DefaultW1;
+
+ CFX_DWordArray m_VertMetrics;
+
+
+ void LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, int nElements);
+
+ void LoadSubstFont();
+
+ FX_BOOL m_bAdobeCourierStd;
+
+ CFX_CTTGSUBTable* m_pTTGSUBTable;
+};
+#define PDFCS_DEVICEGRAY 1
+
+#define PDFCS_DEVICERGB 2
+#define PDFCS_DEVICECMYK 3
+#define PDFCS_CALGRAY 4
+#define PDFCS_CALRGB 5
+#define PDFCS_LAB 6
+#define PDFCS_ICCBASED 7
+#define PDFCS_SEPARATION 8
+#define PDFCS_DEVICEN 9
+#define PDFCS_INDEXED 10
+#define PDFCS_PATTERN 11
+class CPDF_ColorSpace : public CFX_Object
+{
+public:
+
+ static CPDF_ColorSpace* GetStockCS(int Family);
+
+ static CPDF_ColorSpace* Load(CPDF_Document* pDoc, CPDF_Object* pCSObj);
+
+ void ReleaseCS();
+
+ int GetBufSize() const;
+
+ FX_FLOAT* CreateBuf();
+
+ void GetDefaultColor(FX_FLOAT* buf) const;
+
+ int CountComponents() const
+ {
+ return m_nComponents;
+ }
+
+ int GetFamily() const
+ {
+ return m_Family;
+ }
+
+ virtual void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const
+ {
+ value = 0;
+ min = 0;
+ max = 1.0f;
+ }
+
+ FX_BOOL sRGB() const;
+
+
+
+ virtual FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const = 0;
+
+ virtual FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const
+ {
+ return FALSE;
+ }
+
+
+
+
+ FX_BOOL GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const;
+
+ FX_BOOL SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const;
+
+
+ virtual void TranslateImageLine(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels,
+ int image_width, int image_height, FX_BOOL bTransMask = FALSE) const;
+
+ CPDF_Array*& GetArray()
+ {
+ return m_pArray;
+ }
+
+ int GetMaxIndex() const;
+
+ virtual CPDF_ColorSpace* GetBaseCS() const
+ {
+ return NULL;
+ }
+
+ virtual void EnableStdConversion(FX_BOOL bEnabled);
+ CPDF_Document* m_pDocument;
+protected:
+
+ CPDF_ColorSpace();
+
+ virtual ~CPDF_ColorSpace() {}
+ virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
+ {
+ return TRUE;
+ }
+ virtual FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const
+ {
+ return FALSE;
+ }
+ virtual FX_BOOL v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const
+ {
+ return FALSE;
+ }
+
+ int m_Family;
+
+ int m_nComponents;
+
+ CPDF_Array* m_pArray;
+
+ FX_DWORD m_dwStdConversion;
+};
+class CPDF_Color : public CFX_Object
+{
+public:
+
+ CPDF_Color()
+ {
+ m_pBuffer = NULL;
+ m_pCS = NULL;
+ }
+
+ CPDF_Color(int family);
+
+ ~CPDF_Color();
+
+ FX_BOOL IsNull() const
+ {
+ return m_pBuffer == NULL;
+ }
+
+ FX_BOOL IsEqual(const CPDF_Color& other) const;
+
+ FX_BOOL IsPattern() const
+ {
+ return m_pCS && m_pCS->GetFamily() == PDFCS_PATTERN;
+ }
+
+ void Copy(const CPDF_Color* pSrc);
+
+ void SetColorSpace(CPDF_ColorSpace* pCS);
+
+ void SetValue(FX_FLOAT* comp);
+
+ void SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comp, int ncomps);
+
+ FX_BOOL GetRGB(int& R, int& G, int& B) const;
+
+ CPDF_Pattern* GetPattern() const;
+
+ CPDF_ColorSpace* GetPatternCS() const;
+
+ FX_FLOAT* GetPatternColor() const;
+
+ CPDF_ColorSpace* m_pCS;
+
+ FX_FLOAT* m_pBuffer;
+protected:
+ void ReleaseBuffer();
+ void ReleaseColorSpace();
+};
+#define PATTERN_TILING 1
+#define PATTERN_SHADING 2
+class CPDF_Pattern : public CFX_Object
+{
+public:
+
+ virtual ~CPDF_Pattern() {}
+
+ CPDF_Object* m_pPatternObj;
+
+ int m_PatternType;
+
+ CFX_AffineMatrix m_Pattern2Form;
+ CFX_AffineMatrix m_ParentMatrix;
+
+ CPDF_Document* m_pDocument;
+
+protected:
+
+ CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix)
+ {
+ if (pParentMatrix) {
+ m_ParentMatrix = *pParentMatrix;
+ }
+ }
+};
+class CPDF_TilingPattern : public CPDF_Pattern
+{
+public:
+
+ CPDF_TilingPattern(CPDF_Document* pDoc, CPDF_Object* pPatternObj, const CFX_AffineMatrix* parentMatrix);
+
+ virtual ~CPDF_TilingPattern();
+
+ FX_BOOL Load();
+
+
+
+ FX_BOOL m_bColored;
+
+ CFX_FloatRect m_BBox;
+
+ FX_FLOAT m_XStep;
+
+ FX_FLOAT m_YStep;
+
+
+
+ CPDF_Form* m_pForm;
+};
+class CPDF_ShadingPattern : public CPDF_Pattern
+{
+public:
+
+ CPDF_ShadingPattern(CPDF_Document* pDoc, CPDF_Object* pPatternObj, FX_BOOL bShading, const CFX_AffineMatrix* parentMatrix);
+
+ virtual ~CPDF_ShadingPattern();
+
+ CPDF_Object* m_pShadingObj;
+
+ FX_BOOL m_bShadingObj;
+
+ FX_BOOL Load();
+
+ FX_BOOL Reload();
+
+ int m_ShadingType;
+
+ CPDF_ColorSpace* m_pCS;
+
+
+ CPDF_Function* m_pFunctions[4];
+
+ int m_nFuncs;
+protected:
+ void Clear();
+};
+struct CPDF_MeshVertex {
+ FX_FLOAT x, y;
+ FX_FLOAT r, g, b;
+};
+class CPDF_MeshStream : public CFX_Object
+{
+public:
+
+ FX_BOOL Load(CPDF_Stream* pShadingStream, CPDF_Function** pFuncs, int nFuncs, CPDF_ColorSpace* pCS);
+
+ FX_DWORD GetFlag();
+
+ void GetCoords(FX_FLOAT& x, FX_FLOAT& y);
+
+ void GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b);
+
+ FX_DWORD GetVertex(CPDF_MeshVertex& vertex, CFX_AffineMatrix* pObject2Bitmap);
+
+ FX_BOOL GetVertexRow(CPDF_MeshVertex* vertex, int count, CFX_AffineMatrix* pObject2Bitmap);
+ CPDF_Function** m_pFuncs;
+ CPDF_ColorSpace* m_pCS;
+ FX_DWORD m_nFuncs, m_nCoordBits, m_nCompBits, m_nFlagBits, m_nComps;
+ FX_DWORD m_CoordMax, m_CompMax;
+ FX_FLOAT m_xmin, m_xmax, m_ymin, m_ymax;
+ FX_FLOAT m_ColorMin[8], m_ColorMax[8];
+ CPDF_StreamAcc m_Stream;
+ CFX_BitStream m_BitStream;
+};
+#define PDF_IMAGE_NO_COMPRESS 0x0000
+#define PDF_IMAGE_LOSSY_COMPRESS 0x0001
+#define PDF_IMAGE_LOSSLESS_COMPRESS 0x0002
+#define PDF_IMAGE_MASK_LOSSY_COMPRESS 0x0004
+#define PDF_IMAGE_MASK_LOSSLESS_COMPRESS 0x0008
+class CPDF_ImageSetParam
+{
+public:
+ CPDF_ImageSetParam()
+ : pMatteColor(NULL)
+ , nQuality(80)
+ {
+ }
+ FX_ARGB* pMatteColor;
+ FX_INT32 nQuality;
+};
+class CPDF_Image : public CFX_Object
+{
+public:
+
+ CPDF_Image(CPDF_Document* pDoc);
+
+ ~CPDF_Image();
+
+ FX_BOOL LoadImageF(CPDF_Stream* pImageStream, FX_BOOL bInline);
+
+ void Release();
+
+ CPDF_Image* Clone();
+
+ FX_BOOL IsInline()
+ {
+ return m_bInline;
+ }
+
+ void SetInlineDict(CPDF_Dictionary* pDict)
+ {
+ m_pInlineDict = pDict;
+ }
+
+ CPDF_Dictionary* GetInlineDict() const
+ {
+ return m_pInlineDict;
+ }
+
+ CPDF_Stream* GetStream() const
+ {
+ return m_pStream;
+ }
+
+ CPDF_Dictionary* GetDict() const
+ {
+ return m_pStream->GetDict();
+ }
+
+ CPDF_Dictionary* GetOC() const
+ {
+ return m_pOC;
+ }
+
+ CPDF_Document* GetDocument() const
+ {
+ return m_pDocument;
+ }
+
+
+
+ FX_INT32 GetPixelHeight() const
+ {
+ return m_Height;
+ }
+
+ FX_INT32 GetPixelWidth() const
+ {
+ return m_Width;
+ }
+
+
+ FX_BOOL IsMask() const
+ {
+ return m_bIsMask;
+ }
+
+ FX_BOOL IsInterpol() const
+ {
+ return m_bInterpolate;
+ }
+
+ CFX_DIBSource* LoadDIBSource(CFX_DIBSource** ppMask = NULL, FX_DWORD* pMatteColor = NULL, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE) const;
+
+
+
+ void SetImage(const CFX_DIBitmap* pDIBitmap, FX_INT32 iCompress, IFX_FileWrite *pFileWrite = NULL, IFX_FileRead *pFileRead = NULL, const CFX_DIBitmap* pMask = NULL, const CPDF_ImageSetParam* pParam = NULL);
+
+ void SetJpegImage(FX_BYTE* pImageData, FX_DWORD size);
+
+ void SetJpegImage(IFX_FileRead *pFile);
+
+ void ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pDIBitmap);
+
+public:
+ FX_BOOL StartLoadDIBSource(CPDF_Dictionary* pFormResource, CPDF_Dictionary* pPageResource, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE);
+ FX_BOOL Continue(IFX_Pause* pPause);
+ CFX_DIBSource* DetachBitmap();
+ CFX_DIBSource* DetachMask();
+ CFX_DIBSource* m_pDIBSource;
+ CFX_DIBSource* m_pMask;
+ FX_DWORD m_MatteColor;
+private:
+
+ CPDF_Stream* m_pStream;
+ FX_BOOL m_bInline;
+ CPDF_Dictionary* m_pInlineDict;
+
+ FX_INT32 m_Height;
+
+ FX_INT32 m_Width;
+
+ FX_BOOL m_bIsMask;
+
+ FX_BOOL m_bInterpolate;
+
+ CPDF_Document* m_pDocument;
+
+ CPDF_Dictionary* m_pOC;
+ CPDF_Dictionary* InitJPEG(FX_LPBYTE pData, FX_DWORD size);
+};
+#endif
diff --git a/core/include/fpdfapi/fpdf_serial.h b/core/include/fpdfapi/fpdf_serial.h
index 9b1642e4a7..87ec7b5a05 100644
--- a/core/include/fpdfapi/fpdf_serial.h
+++ b/core/include/fpdfapi/fpdf_serial.h
@@ -1,203 +1,203 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDF_SERIAL_
-#define _FPDF_SERIAL_
-#ifndef _FPDF_PAGE_
-#include "fpdf_page.h"
-#endif
-#ifndef _FPDF_PAGEOBJ_H_
-#include "fpdf_pageobj.h"
-#endif
-class CPDF_ObjectStream;
-class CPDF_XRefStream;
-CFX_ByteTextBuf& operator << (CFX_ByteTextBuf& buf, const CPDF_Object* pObj);
-class CPDF_ObjArchiveSaver : public CFX_ArchiveSaver
-{
-public:
-
- friend CPDF_ObjArchiveSaver& operator << (CPDF_ObjArchiveSaver& ar, const CPDF_Object* pObj);
-protected:
-
- CFX_MapPtrToPtr m_ObjectMap;
-};
-class CPDF_ObjArchiveLoader : public CFX_ArchiveLoader
-{
-public:
-
- CPDF_ObjArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize) : CFX_ArchiveLoader(pData, dwSize),
- m_IndirectObjects(NULL) {}
-
- friend CPDF_ObjArchiveLoader& operator >> (CPDF_ObjArchiveLoader& ar, CPDF_Object*& pObj);
-protected:
-
- CPDF_IndirectObjects m_IndirectObjects;
-};
-class CPDF_PageArchiveSaver : public CPDF_ObjArchiveSaver
-{
-public:
-
- CPDF_PageArchiveSaver(CPDF_PageObjects* pPageObjs);
-
- friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_PageObject* pObj);
-
-
-
- friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_ClipPath clip_path);
-
- friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_GraphState graph_state);
-
- friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_TextState text_state);
-
- friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_ColorState color_state);
-
- friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_GeneralState general_state);
-
-protected:
-
- CPDF_ClipPath m_LastClipPath;
-
- CPDF_GraphState m_LastGraphState;
-
- CPDF_ColorState m_LastColorState;
-
- CPDF_TextState m_LastTextState;
-
- CPDF_GeneralState m_LastGeneralState;
-
- CPDF_PageObjects* m_pCurPage;
-};
-class CPDF_PageArchiveLoader : public CPDF_ObjArchiveLoader
-{
-public:
-
- CPDF_PageArchiveLoader(CPDF_PageObjects* pPageObjs, FX_LPCBYTE pData, FX_DWORD dwSize);
-
- friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_PageObject*& pObj);
-
-
-
- friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_ClipPath& clip_path);
-
- friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_GraphState& graph_state);
-
- friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_TextState& text_state);
-
- friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_ColorState& color_state);
-
- friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_GeneralState& general_state);
-
-protected:
- void PostProcColor(CPDF_Color& color);
-
- CPDF_Object* AddResource(CPDF_Object* pSrcObj, FX_LPCSTR type);
-
- CPDF_ClipPath m_LastClipPath;
-
- CPDF_GraphState m_LastGraphState;
-
- CPDF_ColorState m_LastColorState;
-
- CPDF_TextState m_LastTextState;
-
- CPDF_GeneralState m_LastGeneralState;
-
- CPDF_PageObjects* m_pCurPage;
-
- CFX_MapPtrToPtr m_ObjectMap;
-};
-#define FPDFCREATE_INCREMENTAL 1
-#define FPDFCREATE_NO_ORIGINAL 2
-#define FPDFCREATE_PROGRESSIVE 4
-#define FPDFCREATE_OBJECTSTREAM 8
-class CPDF_Creator : public CFX_Object
-{
-public:
-
- CPDF_Creator(CPDF_Document* pDoc);
-
- ~CPDF_Creator();
-
- FX_BOOL Create(FX_LPCWSTR filename, FX_DWORD flags = 0);
-
- FX_BOOL Create(FX_LPCSTR filename, FX_DWORD flags = 0);
-
- FX_BOOL Create(IFX_StreamWrite* pFile, FX_DWORD flags = 0);
-
- FX_INT32 Continue(IFX_Pause *pPause = NULL);
-
- FX_BOOL SetFileVersion(FX_INT32 fileVersion = 17);
-protected:
-
- CPDF_Document* m_pDocument;
-
- CPDF_Parser* m_pParser;
-
- FX_BOOL m_bCompress;
-
- FX_BOOL m_bSecurityChanged;
-
- CPDF_Dictionary* m_pEncryptDict;
- FX_DWORD m_dwEnryptObjNum;
- FX_BOOL m_bEncryptCloned;
-
- FX_BOOL m_bStandardSecurity;
-
- CPDF_CryptoHandler* m_pCryptoHandler;
- FX_BOOL m_bNewCrypto;
-
- FX_BOOL m_bEncryptMetadata;
-
- CPDF_Object* m_pMetadata;
-
- CPDF_XRefStream* m_pXRefStream;
-
- FX_INT32 m_ObjectStreamSize;
-
- FX_DWORD m_dwLastObjNum;
- FX_BOOL Create(FX_DWORD flags);
- void ResetStandardSecurity();
- void Clear();
- FX_INT32 WriteDoc_Stage1(IFX_Pause *pPause);
- FX_INT32 WriteDoc_Stage2(IFX_Pause *pPause);
- FX_INT32 WriteDoc_Stage3(IFX_Pause *pPause);
- FX_INT32 WriteDoc_Stage4(IFX_Pause *pPause);
-
- CFX_FileBufferArchive m_File;
-
- FX_FILESIZE m_Offset;
- void InitOldObjNumOffsets();
- void InitNewObjNumOffsets();
- void AppendNewObjNum(FX_DWORD objbum);
- FX_INT32 WriteOldIndirectObject(FX_DWORD objnum);
- FX_INT32 WriteOldObjs(IFX_Pause *pPause);
- FX_INT32 WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause);
- FX_INT32 WriteIndirectObj(const CPDF_Object* pObj);
- FX_INT32 WriteDirectObj(FX_DWORD objnum, const CPDF_Object* pObj, FX_BOOL bEncrypt = TRUE);
- FX_INT32 WriteIndirectObjectToStream(const CPDF_Object* pObj);
- FX_INT32 WriteIndirectObj(FX_DWORD objnum, const CPDF_Object* pObj);
- FX_INT32 WriteIndirectObjectToStream(FX_DWORD objnum, FX_LPCBYTE pBuffer, FX_DWORD dwSize);
- FX_INT32 AppendObjectNumberToXRef(FX_DWORD objnum);
- void InitID(FX_BOOL bDefault = TRUE);
- FX_INT32 WriteStream(const CPDF_Object* pStream, FX_DWORD objnum, CPDF_CryptoHandler* pCrypto);
-
- FX_INT32 m_iStage;
- FX_DWORD m_dwFlags;
- FX_POSITION m_Pos;
- FX_FILESIZE m_XrefStart;
-
- CFX_FileSizeListArray m_ObjectOffset;
-
- CFX_DWordListArray m_ObjectSize;
- CFX_DWordArray m_NewObjNumArray;
-
- CPDF_Array* m_pIDArray;
-
- FX_INT32 m_FileVersion;
- friend class CPDF_ObjectStream;
- friend class CPDF_XRefStream;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDF_SERIAL_
+#define _FPDF_SERIAL_
+#ifndef _FPDF_PAGE_
+#include "fpdf_page.h"
+#endif
+#ifndef _FPDF_PAGEOBJ_H_
+#include "fpdf_pageobj.h"
+#endif
+class CPDF_ObjectStream;
+class CPDF_XRefStream;
+CFX_ByteTextBuf& operator << (CFX_ByteTextBuf& buf, const CPDF_Object* pObj);
+class CPDF_ObjArchiveSaver : public CFX_ArchiveSaver
+{
+public:
+
+ friend CPDF_ObjArchiveSaver& operator << (CPDF_ObjArchiveSaver& ar, const CPDF_Object* pObj);
+protected:
+
+ CFX_MapPtrToPtr m_ObjectMap;
+};
+class CPDF_ObjArchiveLoader : public CFX_ArchiveLoader
+{
+public:
+
+ CPDF_ObjArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize) : CFX_ArchiveLoader(pData, dwSize),
+ m_IndirectObjects(NULL) {}
+
+ friend CPDF_ObjArchiveLoader& operator >> (CPDF_ObjArchiveLoader& ar, CPDF_Object*& pObj);
+protected:
+
+ CPDF_IndirectObjects m_IndirectObjects;
+};
+class CPDF_PageArchiveSaver : public CPDF_ObjArchiveSaver
+{
+public:
+
+ CPDF_PageArchiveSaver(CPDF_PageObjects* pPageObjs);
+
+ friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_PageObject* pObj);
+
+
+
+ friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_ClipPath clip_path);
+
+ friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_GraphState graph_state);
+
+ friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_TextState text_state);
+
+ friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_ColorState color_state);
+
+ friend CPDF_PageArchiveSaver& operator << (CPDF_PageArchiveSaver& ar, CPDF_GeneralState general_state);
+
+protected:
+
+ CPDF_ClipPath m_LastClipPath;
+
+ CPDF_GraphState m_LastGraphState;
+
+ CPDF_ColorState m_LastColorState;
+
+ CPDF_TextState m_LastTextState;
+
+ CPDF_GeneralState m_LastGeneralState;
+
+ CPDF_PageObjects* m_pCurPage;
+};
+class CPDF_PageArchiveLoader : public CPDF_ObjArchiveLoader
+{
+public:
+
+ CPDF_PageArchiveLoader(CPDF_PageObjects* pPageObjs, FX_LPCBYTE pData, FX_DWORD dwSize);
+
+ friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_PageObject*& pObj);
+
+
+
+ friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_ClipPath& clip_path);
+
+ friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_GraphState& graph_state);
+
+ friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_TextState& text_state);
+
+ friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_ColorState& color_state);
+
+ friend CPDF_PageArchiveLoader& operator >> (CPDF_PageArchiveLoader& ar, CPDF_GeneralState& general_state);
+
+protected:
+ void PostProcColor(CPDF_Color& color);
+
+ CPDF_Object* AddResource(CPDF_Object* pSrcObj, FX_LPCSTR type);
+
+ CPDF_ClipPath m_LastClipPath;
+
+ CPDF_GraphState m_LastGraphState;
+
+ CPDF_ColorState m_LastColorState;
+
+ CPDF_TextState m_LastTextState;
+
+ CPDF_GeneralState m_LastGeneralState;
+
+ CPDF_PageObjects* m_pCurPage;
+
+ CFX_MapPtrToPtr m_ObjectMap;
+};
+#define FPDFCREATE_INCREMENTAL 1
+#define FPDFCREATE_NO_ORIGINAL 2
+#define FPDFCREATE_PROGRESSIVE 4
+#define FPDFCREATE_OBJECTSTREAM 8
+class CPDF_Creator : public CFX_Object
+{
+public:
+
+ CPDF_Creator(CPDF_Document* pDoc);
+
+ ~CPDF_Creator();
+
+ FX_BOOL Create(FX_LPCWSTR filename, FX_DWORD flags = 0);
+
+ FX_BOOL Create(FX_LPCSTR filename, FX_DWORD flags = 0);
+
+ FX_BOOL Create(IFX_StreamWrite* pFile, FX_DWORD flags = 0);
+
+ FX_INT32 Continue(IFX_Pause *pPause = NULL);
+
+ FX_BOOL SetFileVersion(FX_INT32 fileVersion = 17);
+protected:
+
+ CPDF_Document* m_pDocument;
+
+ CPDF_Parser* m_pParser;
+
+ FX_BOOL m_bCompress;
+
+ FX_BOOL m_bSecurityChanged;
+
+ CPDF_Dictionary* m_pEncryptDict;
+ FX_DWORD m_dwEnryptObjNum;
+ FX_BOOL m_bEncryptCloned;
+
+ FX_BOOL m_bStandardSecurity;
+
+ CPDF_CryptoHandler* m_pCryptoHandler;
+ FX_BOOL m_bNewCrypto;
+
+ FX_BOOL m_bEncryptMetadata;
+
+ CPDF_Object* m_pMetadata;
+
+ CPDF_XRefStream* m_pXRefStream;
+
+ FX_INT32 m_ObjectStreamSize;
+
+ FX_DWORD m_dwLastObjNum;
+ FX_BOOL Create(FX_DWORD flags);
+ void ResetStandardSecurity();
+ void Clear();
+ FX_INT32 WriteDoc_Stage1(IFX_Pause *pPause);
+ FX_INT32 WriteDoc_Stage2(IFX_Pause *pPause);
+ FX_INT32 WriteDoc_Stage3(IFX_Pause *pPause);
+ FX_INT32 WriteDoc_Stage4(IFX_Pause *pPause);
+
+ CFX_FileBufferArchive m_File;
+
+ FX_FILESIZE m_Offset;
+ void InitOldObjNumOffsets();
+ void InitNewObjNumOffsets();
+ void AppendNewObjNum(FX_DWORD objbum);
+ FX_INT32 WriteOldIndirectObject(FX_DWORD objnum);
+ FX_INT32 WriteOldObjs(IFX_Pause *pPause);
+ FX_INT32 WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause);
+ FX_INT32 WriteIndirectObj(const CPDF_Object* pObj);
+ FX_INT32 WriteDirectObj(FX_DWORD objnum, const CPDF_Object* pObj, FX_BOOL bEncrypt = TRUE);
+ FX_INT32 WriteIndirectObjectToStream(const CPDF_Object* pObj);
+ FX_INT32 WriteIndirectObj(FX_DWORD objnum, const CPDF_Object* pObj);
+ FX_INT32 WriteIndirectObjectToStream(FX_DWORD objnum, FX_LPCBYTE pBuffer, FX_DWORD dwSize);
+ FX_INT32 AppendObjectNumberToXRef(FX_DWORD objnum);
+ void InitID(FX_BOOL bDefault = TRUE);
+ FX_INT32 WriteStream(const CPDF_Object* pStream, FX_DWORD objnum, CPDF_CryptoHandler* pCrypto);
+
+ FX_INT32 m_iStage;
+ FX_DWORD m_dwFlags;
+ FX_POSITION m_Pos;
+ FX_FILESIZE m_XrefStart;
+
+ CFX_FileSizeListArray m_ObjectOffset;
+
+ CFX_DWordListArray m_ObjectSize;
+ CFX_DWordArray m_NewObjNumArray;
+
+ CPDF_Array* m_pIDArray;
+
+ FX_INT32 m_FileVersion;
+ friend class CPDF_ObjectStream;
+ friend class CPDF_XRefStream;
+};
+#endif
diff --git a/core/include/fpdfapi/fpdfapi.h b/core/include/fpdfapi/fpdfapi.h
index e9fc528dc1..9407735267 100644
--- a/core/include/fpdfapi/fpdfapi.h
+++ b/core/include/fpdfapi/fpdfapi.h
@@ -1,15 +1,15 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _FPDFAPI_H_
-#define _FPDFAPI_H_
-#include "../../include/fxcrt/fx_basic.h"
-#include "../../include/fxge/fx_ge.h"
-#include "fpdf_module.h"
-#include "fpdf_pageobj.h"
-#include "fpdf_render.h"
-#include "fpdf_serial.h"
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDFAPI_H_
+#define _FPDFAPI_H_
+#include "../../include/fxcrt/fx_basic.h"
+#include "../../include/fxge/fx_ge.h"
+#include "fpdf_module.h"
+#include "fpdf_pageobj.h"
+#include "fpdf_render.h"
+#include "fpdf_serial.h"
+#endif