summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
Diffstat (limited to 'core/include')
-rw-r--r--core/include/fdrm/fx_crypt.h86
-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
-rw-r--r--core/include/fpdfdoc/fpdf_ap.h184
-rw-r--r--core/include/fpdfdoc/fpdf_doc.h3584
-rw-r--r--core/include/fpdfdoc/fpdf_tagged.h198
-rw-r--r--core/include/fpdfdoc/fpdf_vt.h888
-rw-r--r--core/include/fpdftext/fpdf_text.h346
-rw-r--r--core/include/fxcodec/fx_codec.h576
-rw-r--r--core/include/fxcodec/fx_codec_def.h142
-rw-r--r--core/include/fxcodec/fx_codec_provider.h106
-rw-r--r--core/include/fxcrt/fx_basic.h3284
-rw-r--r--core/include/fxcrt/fx_coordinates.h1800
-rw-r--r--core/include/fxcrt/fx_ext.h206
-rw-r--r--core/include/fxcrt/fx_memory.h600
-rw-r--r--core/include/fxcrt/fx_stream.h400
-rw-r--r--core/include/fxcrt/fx_string.h1740
-rw-r--r--core/include/fxcrt/fx_system.h558
-rw-r--r--core/include/fxcrt/fx_xml.h418
-rw-r--r--core/include/fxge/fx_dib.h1212
-rw-r--r--core/include/fxge/fx_font.h856
-rw-r--r--core/include/fxge/fx_freetype.h288
-rw-r--r--core/include/fxge/fx_ge.h1466
-rw-r--r--core/include/fxge/fx_ge_apple.h52
-rw-r--r--core/include/fxge/fx_ge_win32.h210
-rw-r--r--core/include/thirdparties/freetype/foxitnames.h566
-rw-r--r--core/include/thirdparties/freetype/freetype/config/ftconfig.h2
-rw-r--r--core/include/thirdparties/freetype/freetype/freetype.h8032
-rw-r--r--core/include/thirdparties/freetype/freetype/ftsystem.h8
-rw-r--r--core/include/thirdparties/freetype/freetype/internal/ftmemory.h238
-rw-r--r--core/include/thirdparties/freetype/ft2build.h2
-rw-r--r--core/include/thirdparties/libjpeg/jconfig.h90
-rw-r--r--core/include/thirdparties/libjpeg/jerror.h582
-rw-r--r--core/include/thirdparties/libjpeg/jmorecfg.h752
-rw-r--r--core/include/thirdparties/libjpeg/jpegint.h784
-rw-r--r--core/include/thirdparties/libjpeg/jpeglib.h2330
-rw-r--r--core/include/thirdparties/zlib/zconf.h1038
-rw-r--r--core/include/thirdparties/zlib/zlib.h3656
45 files changed, 23245 insertions, 23245 deletions
diff --git a/core/include/fdrm/fx_crypt.h b/core/include/fdrm/fx_crypt.h
index 5e0b786ad0..ec7d55ab8c 100644
--- a/core/include/fdrm/fx_crypt.h
+++ b/core/include/fdrm/fx_crypt.h
@@ -1,43 +1,43 @@
-// 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 _FX_CRYPT_H_
-#define _FX_CRYPT_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-void CRYPT_ArcFourCryptBlock(FX_LPBYTE data, FX_DWORD size, FX_LPCBYTE key, FX_DWORD keylen);
-void CRYPT_ArcFourSetup(FX_LPVOID context, FX_LPCBYTE key, FX_DWORD length);
-void CRYPT_ArcFourCrypt(FX_LPVOID context, FX_LPBYTE data, FX_DWORD size);
-void CRYPT_AESSetKey(FX_LPVOID context, FX_DWORD blocklen, FX_LPCBYTE key, FX_DWORD keylen, FX_BOOL bEncrypt);
-void CRYPT_AESSetIV(FX_LPVOID context, FX_LPCBYTE iv);
-void CRYPT_AESDecrypt(FX_LPVOID context, FX_LPBYTE dest, FX_LPCBYTE src, FX_DWORD size);
-void CRYPT_AESEncrypt(FX_LPVOID context, FX_LPBYTE dest, FX_LPCBYTE src, FX_DWORD size);
-void CRYPT_MD5Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[16]);
-void CRYPT_MD5Start(FX_LPVOID context);
-void CRYPT_MD5Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
-void CRYPT_MD5Finish(FX_LPVOID context, FX_BYTE digest[16]);
-void CRYPT_SHA1Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[20]);
-void CRYPT_SHA1Start(FX_LPVOID context);
-void CRYPT_SHA1Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
-void CRYPT_SHA1Finish(FX_LPVOID context, FX_BYTE digest[20]);
-void CRYPT_SHA256Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[32]);
-void CRYPT_SHA256Start(FX_LPVOID context);
-void CRYPT_SHA256Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
-void CRYPT_SHA256Finish(FX_LPVOID context, FX_BYTE digest[32]);
-void CRYPT_SHA384Start(FX_LPVOID context);
-void CRYPT_SHA384Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
-void CRYPT_SHA384Finish(FX_LPVOID context, FX_BYTE digest[48]);
-void CRYPT_SHA384Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[48]);
-void CRYPT_SHA512Start(FX_LPVOID context);
-void CRYPT_SHA512Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
-void CRYPT_SHA512Finish(FX_LPVOID context, FX_BYTE digest[64]);
-void CRYPT_SHA512Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[64]);
-void CRYPT_SetPubKeyDecryptor(FX_BOOL (*func)(FX_LPCBYTE pData, FX_DWORD size, FX_LPBYTE data_buf, FX_DWORD& data_len));
-#ifdef __cplusplus
-};
-#endif
-#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 _FX_CRYPT_H_
+#define _FX_CRYPT_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+void CRYPT_ArcFourCryptBlock(FX_LPBYTE data, FX_DWORD size, FX_LPCBYTE key, FX_DWORD keylen);
+void CRYPT_ArcFourSetup(FX_LPVOID context, FX_LPCBYTE key, FX_DWORD length);
+void CRYPT_ArcFourCrypt(FX_LPVOID context, FX_LPBYTE data, FX_DWORD size);
+void CRYPT_AESSetKey(FX_LPVOID context, FX_DWORD blocklen, FX_LPCBYTE key, FX_DWORD keylen, FX_BOOL bEncrypt);
+void CRYPT_AESSetIV(FX_LPVOID context, FX_LPCBYTE iv);
+void CRYPT_AESDecrypt(FX_LPVOID context, FX_LPBYTE dest, FX_LPCBYTE src, FX_DWORD size);
+void CRYPT_AESEncrypt(FX_LPVOID context, FX_LPBYTE dest, FX_LPCBYTE src, FX_DWORD size);
+void CRYPT_MD5Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[16]);
+void CRYPT_MD5Start(FX_LPVOID context);
+void CRYPT_MD5Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
+void CRYPT_MD5Finish(FX_LPVOID context, FX_BYTE digest[16]);
+void CRYPT_SHA1Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[20]);
+void CRYPT_SHA1Start(FX_LPVOID context);
+void CRYPT_SHA1Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
+void CRYPT_SHA1Finish(FX_LPVOID context, FX_BYTE digest[20]);
+void CRYPT_SHA256Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[32]);
+void CRYPT_SHA256Start(FX_LPVOID context);
+void CRYPT_SHA256Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
+void CRYPT_SHA256Finish(FX_LPVOID context, FX_BYTE digest[32]);
+void CRYPT_SHA384Start(FX_LPVOID context);
+void CRYPT_SHA384Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
+void CRYPT_SHA384Finish(FX_LPVOID context, FX_BYTE digest[48]);
+void CRYPT_SHA384Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[48]);
+void CRYPT_SHA512Start(FX_LPVOID context);
+void CRYPT_SHA512Update(FX_LPVOID context, FX_LPCBYTE data, FX_DWORD size);
+void CRYPT_SHA512Finish(FX_LPVOID context, FX_BYTE digest[64]);
+void CRYPT_SHA512Generate(FX_LPCBYTE data, FX_DWORD size, FX_BYTE digest[64]);
+void CRYPT_SetPubKeyDecryptor(FX_BOOL (*func)(FX_LPCBYTE pData, FX_DWORD size, FX_LPBYTE data_buf, FX_DWORD& data_len));
+#ifdef __cplusplus
+};
+#endif
+#endif
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
diff --git a/core/include/fpdfdoc/fpdf_ap.h b/core/include/fpdfdoc/fpdf_ap.h
index 4b6a371110..c2299fc0fc 100644
--- a/core/include/fpdfdoc/fpdf_ap.h
+++ b/core/include/fpdfdoc/fpdf_ap.h
@@ -1,92 +1,92 @@
-// 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
-
-#define _FPDF_AP_H_
-#include "../fxcrt/fx_basic.h"
-#include "../fpdfapi/fpdf_parser.h"
-#include "fpdf_vt.h"
-class IPVT_FontMap
-{
-public:
-
- virtual CPDF_Font* GetPDFFont(FX_INT32 nFontIndex) = 0;
-
- virtual CFX_ByteString GetPDFFontAlias(FX_INT32 nFontIndex) = 0;
-};
-struct CPVT_Dash {
-
- CPVT_Dash(FX_INT32 dash, FX_INT32 gap, FX_INT32 phase) : nDash(dash), nGap(gap), nPhase(phase)
- {}
-
- FX_INT32 nDash;
-
- FX_INT32 nGap;
-
- FX_INT32 nPhase;
-};
-#define CT_TRANSPARENT 0
-#define CT_GRAY 1
-#define CT_RGB 2
-#define CT_CMYK 3
-struct CPVT_Color {
-
- CPVT_Color(FX_INT32 type = 0, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f)
- : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4)
- {}
-
- FX_INT32 nColorType;
- FX_FLOAT fColor1;
- FX_FLOAT fColor2;
- FX_FLOAT fColor3;
- FX_FLOAT fColor4;
-};
-class CPVT_Provider : public IPDF_VariableText_Provider
-{
-public:
-
- CPVT_Provider(IPVT_FontMap * pFontMap);
-
- virtual ~CPVT_Provider();
-
- FX_INT32 GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32 nWordStyle);
-
- FX_INT32 GetTypeAscent(FX_INT32 nFontIndex);
-
- FX_INT32 GetTypeDescent(FX_INT32 nFontIndex);
-
- FX_INT32 GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex);
-
- FX_BOOL IsLatinWord(FX_WORD word);
-
- FX_INT32 GetDefaultFontIndex();
-private:
-
- IPVT_FontMap * m_pFontMap;
-};
-#define PBS_SOLID 0
-#define PBS_DASH 1
-#define PBS_BEVELED 2
-#define PBS_INSET 3
-#define PBS_UNDERLINED 4
-class CPVT_GenerateAP
-{
-public:
-
- static FX_BOOL GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
-
- static FX_BOOL GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
-
- static FX_BOOL GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
-
- static CFX_ByteString GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_VariableText_Iterator * pIterator,
- const CPDF_Point & ptOffset, FX_BOOL bContinuous, FX_WORD SubWord = 0, const CPVT_WordRange * pVisible = NULL);
-
- static CFX_ByteString GenerateBorderAP(const CPDF_Rect & rect, FX_FLOAT fWidth,
- const CPVT_Color & color, const CPVT_Color & crLeftTop, const CPVT_Color & crRightBottom,
- FX_INT32 nStyle, const CPVT_Dash & dash);
-
- static CFX_ByteString GenerateColorAP(const CPVT_Color & color, const FX_BOOL & bFillOrStroke);
-};
+// 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
+
+#define _FPDF_AP_H_
+#include "../fxcrt/fx_basic.h"
+#include "../fpdfapi/fpdf_parser.h"
+#include "fpdf_vt.h"
+class IPVT_FontMap
+{
+public:
+
+ virtual CPDF_Font* GetPDFFont(FX_INT32 nFontIndex) = 0;
+
+ virtual CFX_ByteString GetPDFFontAlias(FX_INT32 nFontIndex) = 0;
+};
+struct CPVT_Dash {
+
+ CPVT_Dash(FX_INT32 dash, FX_INT32 gap, FX_INT32 phase) : nDash(dash), nGap(gap), nPhase(phase)
+ {}
+
+ FX_INT32 nDash;
+
+ FX_INT32 nGap;
+
+ FX_INT32 nPhase;
+};
+#define CT_TRANSPARENT 0
+#define CT_GRAY 1
+#define CT_RGB 2
+#define CT_CMYK 3
+struct CPVT_Color {
+
+ CPVT_Color(FX_INT32 type = 0, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f)
+ : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4)
+ {}
+
+ FX_INT32 nColorType;
+ FX_FLOAT fColor1;
+ FX_FLOAT fColor2;
+ FX_FLOAT fColor3;
+ FX_FLOAT fColor4;
+};
+class CPVT_Provider : public IPDF_VariableText_Provider
+{
+public:
+
+ CPVT_Provider(IPVT_FontMap * pFontMap);
+
+ virtual ~CPVT_Provider();
+
+ FX_INT32 GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32 nWordStyle);
+
+ FX_INT32 GetTypeAscent(FX_INT32 nFontIndex);
+
+ FX_INT32 GetTypeDescent(FX_INT32 nFontIndex);
+
+ FX_INT32 GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex);
+
+ FX_BOOL IsLatinWord(FX_WORD word);
+
+ FX_INT32 GetDefaultFontIndex();
+private:
+
+ IPVT_FontMap * m_pFontMap;
+};
+#define PBS_SOLID 0
+#define PBS_DASH 1
+#define PBS_BEVELED 2
+#define PBS_INSET 3
+#define PBS_UNDERLINED 4
+class CPVT_GenerateAP
+{
+public:
+
+ static FX_BOOL GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
+
+ static FX_BOOL GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
+
+ static FX_BOOL GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
+
+ static CFX_ByteString GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_VariableText_Iterator * pIterator,
+ const CPDF_Point & ptOffset, FX_BOOL bContinuous, FX_WORD SubWord = 0, const CPVT_WordRange * pVisible = NULL);
+
+ static CFX_ByteString GenerateBorderAP(const CPDF_Rect & rect, FX_FLOAT fWidth,
+ const CPVT_Color & color, const CPVT_Color & crLeftTop, const CPVT_Color & crRightBottom,
+ FX_INT32 nStyle, const CPVT_Dash & dash);
+
+ static CFX_ByteString GenerateColorAP(const CPVT_Color & color, const FX_BOOL & bFillOrStroke);
+};
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h
index fc19441309..cbb0fd4a11 100644
--- a/core/include/fpdfdoc/fpdf_doc.h
+++ b/core/include/fpdfdoc/fpdf_doc.h
@@ -1,1792 +1,1792 @@
-// 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_DOC_H_
-#define _FPDF_DOC_H_
-#ifndef _FPDF_PARSER_
-#include "../fpdfapi/fpdf_parser.h"
-#endif
-#ifndef _FPDF_RENDER_
-#include "../fpdfapi/fpdf_render.h"
-#endif
-class CPDF_Action;
-class CPDF_Annot;
-class CPDF_AnnotList;
-class CPDF_Bookmark;
-class CPDF_BookmarkTree;
-class CPDF_Dest;
-class CPDF_Link;
-class CPDF_LinkList;
-class CPDF_Metadata;
-class CPDF_NameTree;
-class CPDF_NumberTree;
-class CPDF_TextObject;
-class CPDF_ViewerPreferences;
-class CPDF_Page;
-class CPDF_RenderOptions;
-class CXML_Element;
-class CPDF_OCContext;
-class CPDF_DocJSActions;
-class CPDF_ActionFields;
-class CPDF_AAction;
-class CPDF_FileSpec;
-class CPDF_IconFit;
-class CPDF_DefaultAppearance;
-class CPDF_InterForm;
-class CPDF_FormField;
-class CPDF_FormNotify;
-class CPDF_FormControl;
-class CPDF_LWinParam;
-class CFieldTree;
-class CPDF_ApSettings;
-class CPDF_NameTree : public CFX_Object
-{
-public:
-
- CPDF_NameTree(CPDF_Dictionary* pRoot)
- {
- m_pRoot = pRoot;
- }
-
- CPDF_NameTree(CPDF_Document* pDoc, FX_BSTR category);
-
- CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const;
-
- CPDF_Object* LookupValue(const CFX_ByteString& csName) const;
-
- CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, FX_BSTR sName);
-
- int GetIndex(const CFX_ByteString& csName) const;
-
- int GetCount() const;
-
-
- CPDF_Dictionary* GetRoot() const
- {
- return m_pRoot;
- }
-
-protected:
-
- CPDF_Dictionary* m_pRoot;
-};
-class CPDF_BookmarkTree : public CFX_Object
-{
-public:
-
- CPDF_BookmarkTree(CPDF_Document* pDoc)
- {
- m_pDocument = pDoc;
- }
-public:
-
-
-
- CPDF_Bookmark GetFirstChild(CPDF_Bookmark parent);
-
- CPDF_Bookmark GetNextSibling(CPDF_Bookmark bookmark);
-
-
- CPDF_Document* GetDocument() const
- {
- return m_pDocument;
- }
-protected:
-
- CPDF_Document* m_pDocument;
-};
-#define PDFBOOKMARK_ITALIC 1
-#define PDFBOOKMARK_BOLD 2
-class CPDF_Bookmark : public CFX_Object
-{
-public:
-
- CPDF_Bookmark(CPDF_Dictionary* pDict = NULL)
- {
- m_pDict = pDict;
- }
-
- operator CPDF_Dictionary*() const
- {
- return m_pDict;
- }
-
-
-
- FX_DWORD GetColorRef();
-
- FX_DWORD GetFontStyle();
-
- CFX_WideString GetTitle();
-
-
-
-
- CPDF_Dest GetDest(CPDF_Document* pDocument);
-
- CPDF_Action GetAction();
-
-
- CPDF_Dictionary* m_pDict;
-};
-#define PDFZOOM_XYZ 1
-#define PDFZOOM_FITPAGE 2
-#define PDFZOOM_FITHORZ 3
-#define PDFZOOM_FITVERT 4
-#define PDFZOOM_FITRECT 5
-#define PDFZOOM_FITBBOX 6
-#define PDFZOOM_FITBHORZ 7
-
-#define PDFZOOM_FITBVERT 8
-class CPDF_Dest : public CFX_Object
-{
-public:
-
- CPDF_Dest(CPDF_Object* pObj = NULL)
- {
- m_pObj = pObj;
- }
-
- operator CPDF_Object* () const
- {
- return m_pObj;
- }
-
- CFX_ByteString GetRemoteName();
-
- int GetPageIndex(CPDF_Document* pDoc);
-
- FX_DWORD GetPageObjNum();
-
- int GetZoomMode();
-
- FX_FLOAT GetParam(int index);
-
-
- CPDF_Object* m_pObj;
-};
-class CPDF_OCContext : public CFX_Object, public IPDF_OCContext
-{
-public:
-
- enum UsageType {
- View = 0,
- Design,
- Print,
- Export
- };
-
- CPDF_OCContext(CPDF_Document *pDoc, UsageType eUsageType = View);
-
- virtual ~CPDF_OCContext();
-
- CPDF_Document* GetDocument() const
- {
- return m_pDocument;
- }
-
- UsageType GetUsageType() const
- {
- return m_eUsageType;
- }
-
- FX_BOOL CheckOCGVisible(const CPDF_Dictionary *pOCGDict);
-
- void ResetOCContext();
-protected:
-
- FX_BOOL LoadOCGStateFromConfig(FX_BSTR csConfig, const CPDF_Dictionary *pOCGDict, FX_BOOL &bValidConfig) const;
-
- FX_BOOL LoadOCGState(const CPDF_Dictionary *pOCGDict) const;
-
- FX_BOOL GetOCGVisible(const CPDF_Dictionary *pOCGDict);
-
- FX_BOOL GetOCGVE(CPDF_Array *pExpression, FX_BOOL bFromConfig, int nLevel = 0);
-
- FX_BOOL LoadOCMDState(const CPDF_Dictionary *pOCMDDict, FX_BOOL bFromConfig);
-
- CPDF_Document *m_pDocument;
-
- UsageType m_eUsageType;
-
- CFX_MapPtrTemplate<const CPDF_Dictionary*, void*> m_OCGStates;
-};
-class CPDF_LWinParam : public CFX_Object
-{
-public:
-
- CPDF_LWinParam(CPDF_Dictionary* pDict)
- {
- m_pDict = pDict;
- }
-
- operator CPDF_Dictionary* () const
- {
- return m_pDict;
- }
-
- inline CFX_ByteString GetFileName()
- {
- return m_pDict->GetString("F");
- }
-
-
- inline CFX_ByteString GetDefaultDirectory()
- {
- return m_pDict->GetString("D");
- }
-
-
- inline CFX_ByteString GetOperation()
- {
- return m_pDict->GetString("O");
- }
-
-
- inline CFX_ByteString GetParameter()
- {
- return m_pDict->GetString("P");
- }
-
- CPDF_Dictionary* m_pDict;
-};
-class CPDF_ActionFields : public CFX_Object
-{
-public:
-
- CPDF_ActionFields(const CPDF_Action* pAction)
- {
- m_pAction = (CPDF_Action*)pAction;
- }
-
- operator CPDF_Action*() const
- {
- return m_pAction;
- }
-
- FX_DWORD GetFieldsCount() const;
-
- void GetAllFields(CFX_PtrArray& fieldObjects) const;
-
- CPDF_Object* GetField(FX_DWORD iIndex) const;
-
- CPDF_Action* m_pAction;
-};
-
-#define PDFNAMED_NEXTPAGE 1
-#define PDFNAMED_PREVPAGE 2
-#define PDFNAMED_FIRSTPAGE 3
-#define PDFNAMED_LASTPAGE 4
-#define PDFJS_MAXLENGTH 64
-class CPDF_Action : public CFX_Object
-{
-public:
-
- CPDF_Action(CPDF_Dictionary* pDict = NULL)
- {
- m_pDict = pDict;
- }
-
- operator CPDF_Dictionary* () const
- {
- return m_pDict;
- }
-
- enum ActionType {
- Unknown = 0,
- GoTo,
- GoToR,
- GoToE,
- Launch,
- Thread,
- URI,
- Sound,
- Movie,
- Hide,
- Named,
- SubmitForm,
- ResetForm,
- ImportData,
- JavaScript,
- SetOCGState,
- Rendition,
- Trans,
- GoTo3DView
- };
-
- CFX_ByteString GetTypeName() const
- {
- return m_pDict->GetString("S");
- }
-
- ActionType GetType() const;
-
-
-
- CPDF_Dest GetDest(CPDF_Document* pDoc) const;
-
-
-
-
-
- CFX_WideString GetFilePath() const;
-
-
-
-
- FX_BOOL GetNewWindow() const
- {
- return m_pDict->GetBoolean("NewWindow");
- }
-
-
-
-
- CPDF_LWinParam GetWinParam() const;
-
-
-
-
- CFX_ByteString GetURI(CPDF_Document* pDoc) const;
-
-
-
-
- FX_BOOL GetMouseMap() const
- {
- return m_pDict->GetBoolean("IsMap");
- }
-
-
-
-
- CPDF_ActionFields GetWidgets() const
- {
- return this;
- }
-
-
-
-
- FX_BOOL GetHideStatus() const
- {
- return m_pDict->GetBoolean("H", TRUE);
- }
-
-
-
-
- CFX_ByteString GetNamedAction() const
- {
- return m_pDict->GetString("N");
- }
-
-
-
-
- FX_DWORD GetFlags() const
- {
- return m_pDict->GetInteger("Flags");
- }
-
-
-
-
- CFX_WideString GetJavaScript() const;
-
-
-
-
- CPDF_Dictionary* GetAnnot() const;
-
-
-
-
- FX_INT32 GetOperationType() const;
-
-
-
-
- CPDF_Stream* GetSoundStream() const
- {
- return m_pDict->GetStream("Sound");
- }
-
- FX_FLOAT GetVolume() const
- {
- return m_pDict->GetNumber("Volume");
- }
-
- FX_BOOL IsSynchronous() const
- {
- return m_pDict->GetBoolean("Synchronous");
- }
-
- FX_BOOL IsRepeat() const
- {
- return m_pDict->GetBoolean("Repeat");
- }
-
- FX_BOOL IsMixPlay() const
- {
- return m_pDict->GetBoolean("Mix");
- }
-
-
-
-
- FX_DWORD GetSubActionsCount() const;
-
- CPDF_Action GetSubAction(FX_DWORD iIndex) const;
-
-
- CPDF_Dictionary* m_pDict;
-};
-class CPDF_AAction : public CFX_Object
-{
-public:
-
- CPDF_AAction(CPDF_Dictionary* pDict = NULL)
- {
- m_pDict = pDict;
- }
-
- operator CPDF_Dictionary*() const
- {
- return m_pDict;
- }
-
- enum AActionType {
- CursorEnter = 0,
- CursorExit,
- ButtonDown,
- ButtonUp,
- GetFocus,
- LoseFocus,
- PageOpen,
- PageClose,
- PageVisible,
- PageInvisible,
- OpenPage,
- ClosePage,
- KeyStroke,
- Format,
- Validate,
- Calculate,
- CloseDocument,
- SaveDocument,
- DocumentSaved,
- PrintDocument,
- DocumentPrinted
- };
-
- FX_BOOL ActionExist(AActionType eType) const;
-
- CPDF_Action GetAction(AActionType eType) const;
-
- FX_POSITION GetStartPos() const;
-
- CPDF_Action GetNextAction(FX_POSITION& pos, AActionType& eType) const;
-
- CPDF_Dictionary* m_pDict;
-};
-class CPDF_DocJSActions : public CFX_Object
-{
-public:
- CPDF_DocJSActions(CPDF_Document* pDoc);
-
-
- int CountJSActions() const;
-
- CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const;
-
- CPDF_Action GetJSAction(const CFX_ByteString& csName) const;
-
- int FindJSAction(const CFX_ByteString& csName) const;
-
-
- CPDF_Document* GetDocument() const
- {
- return m_pDocument;
- }
-
-protected:
-
- CPDF_Document* m_pDocument;
-};
-class CPDF_FileSpec : public CFX_Object
-{
-public:
-
- CPDF_FileSpec();
-
- CPDF_FileSpec(CPDF_Object *pObj)
- {
- m_pObj = pObj;
- }
-
- operator CPDF_Object*() const
- {
- return m_pObj;
- }
-
- FX_BOOL IsURL() const;
-
- FX_BOOL GetFileName(CFX_WideString &wsFileName) const;
-
- CPDF_Stream* GetFileStream() const;
-
- void SetFileName(FX_WSTR wsFileName, FX_BOOL bURL = FALSE);
-protected:
-
- CPDF_Object *m_pObj;
-};
-class CPDF_LinkList : public CFX_Object
-{
-public:
-
- CPDF_LinkList(CPDF_Document* pDoc)
- {
- m_pDocument = pDoc;
- }
-
- ~CPDF_LinkList();
-
- CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y);
-
- int CountLinks(CPDF_Page* pPage);
-
- CPDF_Link GetLink(CPDF_Page* pPage, int index);
-
- CPDF_Document* GetDocument() const
- {
- return m_pDocument;
- }
-protected:
-
- CPDF_Document* m_pDocument;
-
- CFX_MapPtrToPtr m_PageMap;
-
- CFX_PtrArray* GetPageLinks(CPDF_Page* pPage);
-
- void LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList);
-};
-class CPDF_Link : public CFX_Object
-{
-public:
-
- CPDF_Link(CPDF_Dictionary* pDict = NULL)
- {
- m_pDict = pDict;
- }
-
- operator CPDF_Dictionary*() const
- {
- return m_pDict;
- }
-
- CFX_FloatRect GetRect();
-
-
-
- CPDF_Dest GetDest(CPDF_Document* pDoc);
-
- CPDF_Action GetAction();
-
-
- CPDF_Dictionary* m_pDict;
-};
-#define ANNOTFLAG_INVISIBLE 1
-#define ANNOTFLAG_HIDDEN 2
-#define ANNOTFLAG_PRINT 4
-#define ANNOTFLAG_NOZOOM 8
-#define ANNOTFLAG_NOROTATE 0x10
-#define ANNOTFLAG_NOVIEW 0x20
-#define ANNOTFLAG_READONLY 0x40
-#define ANNOTFLAG_LOCKED 0x80
-#define ANNOTFLAG_TOGGLENOVIEW 0x100
-class CPDF_Annot : public CFX_PrivateData, public CFX_Object
-{
-public:
-
- CPDF_Annot(CPDF_Dictionary* pDict);
-
- ~CPDF_Annot();
-
- CPDF_Dictionary* m_pAnnotDict;
-
- CFX_ByteString GetSubType() const;
-
- FX_DWORD GetFlags() const
- {
- return m_pAnnotDict->GetInteger("F");
- }
-
- void GetRect(CFX_FloatRect& rect) const;
-
- enum AppearanceMode {
- Normal,
- Rollover,
- Down
- };
-
- FX_BOOL DrawAppearance(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
- AppearanceMode mode, const CPDF_RenderOptions* pOptions);
-
- FX_BOOL DrawInContext(const CPDF_Page* pPage, const CPDF_RenderContext* pContext,
- const CFX_AffineMatrix* pUser2Device, AppearanceMode mode);
-
- void ClearCachedAP();
-
-
- void DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
- const CPDF_RenderOptions* pOptions);
-
- CPDF_PageObject* GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions* pOptions);
-
-
-
- int CountIRTNotes();
-
- CPDF_Annot* GetIRTNote(int index);
-
-
- CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode);
-private:
-
- CFX_MapPtrToPtr m_APMap;
-protected:
- friend class CPDF_AnnotList;
-
- CPDF_AnnotList* m_pList;
-
- CPDF_Reference* NewAnnotRef();
-};
-class CPDF_AnnotList : public CFX_Object
-{
-public:
-
- CPDF_AnnotList(CPDF_Page* pPage);
-
- ~CPDF_AnnotList();
-
- void GetAnnotMatrix(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CFX_Matrix &matrix) const;
-
- void GetAnnotRect(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CPDF_Rect &rtAnnot) const;
-
- void DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
- CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
- CPDF_RenderOptions* pOptions);
-
- void DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
- FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
- CPDF_RenderOptions* pOptions)
- {
- DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, NULL);
- }
-
- void DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
- FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
- CPDF_RenderOptions* pOptions, FX_RECT *pClipRect)
- {
- DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, pClipRect);
- }
-
- void DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, CPDF_RenderContext* pContext,
- FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_DWORD dwAnnotFlags,
- CPDF_RenderOptions* pOptions, FX_RECT* pClipRect);
-
-
-
- CPDF_Annot* GetAt(int index)
- {
- return (CPDF_Annot*)m_AnnotList.GetAt(index);
- }
-
- int Count()
- {
- return m_AnnotList.GetSize();
- }
-
- int GetIndex(CPDF_Annot* pAnnot);
-
-
- CPDF_Document* GetDocument() const
- {
- return m_pDocument;
- }
-protected:
-
- CFX_PtrArray m_AnnotList;
-
- CPDF_Dictionary* m_pPageDict;
-
- CPDF_Document* m_pDocument;
-
- CFX_PtrArray m_Borders;
-
- void DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
- CPDF_RenderContext* pContext, FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix,
- FX_BOOL bWidget, CPDF_RenderOptions* pOptions, FX_RECT* clip_rect);
- friend class CPDF_Annot;
-};
-#define COLORTYPE_TRANSPARENT 0
-#define COLORTYPE_GRAY 1
-#define COLORTYPE_RGB 2
-#define COLORTYPE_CMYK 3
-class CPDF_DefaultAppearance : public CFX_Object
-{
-public:
-
- CPDF_DefaultAppearance(const CFX_ByteString& csDA = "")
- {
- m_csDA = csDA;
- }
-
- CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA)
- {
- m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
- }
-
-
- operator CFX_ByteString() const
- {
- return m_csDA;
- }
-
- const CPDF_DefaultAppearance& operator =(const CFX_ByteString& csDA)
- {
- m_csDA = csDA;
- return *this;
- }
-
- const CPDF_DefaultAppearance& operator =(const CPDF_DefaultAppearance& cDA)
- {
- m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
- return *this;
- }
-
-
-
- FX_BOOL HasFont();
-
- CFX_ByteString GetFontString();
-
- void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize);
-
-
-
-
- FX_BOOL HasColor(FX_BOOL bStrokingOperation = FALSE);
-
- CFX_ByteString GetColorString(FX_BOOL bStrokingOperation = FALSE);
-
- void GetColor(int& iColorType, FX_FLOAT fc[4], FX_BOOL bStrokingOperation = FALSE);
-
- void GetColor(FX_ARGB& color, int& iColorType, FX_BOOL bStrokingOperation = FALSE);
-
-
-
-
- FX_BOOL HasTextMatrix();
-
- CFX_ByteString GetTextMatrixString();
-
- CFX_AffineMatrix GetTextMatrix();
-
-protected:
-
- CFX_ByteString m_csDA;
-};
-#define FIELDTYPE_UNKNOWN 0
-#define FIELDTYPE_PUSHBUTTON 1
-#define FIELDTYPE_CHECKBOX 2
-#define FIELDTYPE_RADIOBUTTON 3
-#define FIELDTYPE_COMBOBOX 4
-#define FIELDTYPE_LISTBOX 5
-#define FIELDTYPE_TEXTFIELD 6
-#define FIELDTYPE_SIGNATURE 7
-class CPDF_InterForm : public CFX_PrivateData, public CFX_Object
-{
-public:
-
- CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bUpdateAP);
-
- ~CPDF_InterForm();
-
-
-
- static void EnableUpdateAP(FX_BOOL bUpdateAP);
-
- static FX_BOOL UpdatingAPEnabled();
-
-
- static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, FX_LPCSTR csType, int iMinLen = 2, FX_LPCSTR csPrefix = "");
-
-
-
- static CPDF_Font* AddSystemDefaultFont(const CPDF_Document* pDocument);
-
- static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, CFX_ByteString csFontName, FX_BYTE iCharSet = 1);
-
- static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, CFX_WideString csFontName, FX_BYTE iCharSet = 1);
-
- static CPDF_Font* AddStandardFont(const CPDF_Document* pDocument, CFX_ByteString csFontName);
-
- static CFX_ByteString GetNativeFont(FX_BYTE iCharSet, FX_LPVOID pLogFont = NULL);
-
- static CFX_ByteString GetNativeFont(FX_LPVOID pLogFont = NULL);
-
- static FX_BYTE GetNativeCharSet();
-
- static CPDF_Font* AddNativeFont(FX_BYTE iCharSet, const CPDF_Document* pDocument);
-
- static CPDF_Font* AddNativeFont(const CPDF_Document* pDocument);
-
-
-
-
- FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType);
-
- FX_BOOL ValidateFieldName(const CPDF_FormField* pField, CFX_WideString& csNewFieldName);
-
- FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName);
-
-
-
-
- FX_DWORD CountFields(const CFX_WideString &csFieldName = L"");
-
- CPDF_FormField* GetField(FX_DWORD index, const CFX_WideString &csFieldName = L"");
-
- void GetAllFieldNames(CFX_WideStringArray& allFieldNames);
-
- FX_BOOL IsValidFormField(const void* pField);
-
- CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
-
-
-
-
- FX_DWORD CountControls(CFX_WideString csFieldName = L"");
-
- CPDF_FormControl* GetControl(FX_DWORD index, CFX_WideString csFieldName = L"");
-
- FX_BOOL IsValidFormControl(const void* pControl);
-
- int CountPageControls(CPDF_Page* pPage) const;
-
- CPDF_FormControl* GetPageControl(CPDF_Page* pPage, int index) const;
-
-
- CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y) const;
-
- CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const;
-
-
-
-
- FX_DWORD CountInternalFields(const CFX_WideString& csFieldName = L"") const;
-
- CPDF_Dictionary* GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName = L"") const;
-
-
-
-
-
- CPDF_Document* GetDocument() const
- {
- return m_pDocument;
- }
-
- CPDF_Dictionary* GetFormDict() const
- {
- return m_pFormDict;
- }
-
-
-
-
- FX_BOOL NeedConstructAP();
-
- void NeedConstructAP(FX_BOOL bNeedAP);
-
-
-
-
- int CountFieldsInCalculationOrder();
-
- CPDF_FormField* GetFieldInCalculationOrder(int index);
-
- int FindFieldInCalculationOrder(const CPDF_FormField* pField);
-
-
-
-
- FX_DWORD CountFormFonts();
-
- CPDF_Font* GetFormFont(FX_DWORD index, CFX_ByteString& csNameTag);
-
- CPDF_Font* GetFormFont(CFX_ByteString csNameTag);
-
- CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag);
-
- CPDF_Font* GetNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
-
- CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag);
-
- FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
-
- FX_BOOL FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag);
-
- inline FX_BOOL FindFormFont(CFX_WideString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag)
- {
- return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag);
- }
-
-
-
-
-
- void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
-
- CPDF_Font* AddNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
-
- CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag);
-
- void RemoveFormFont(const CPDF_Font* pFont);
-
- void RemoveFormFont(CFX_ByteString csNameTag);
-
-
-
-
- CPDF_DefaultAppearance GetDefaultAppearance();
-
- CPDF_Font* GetDefaultFormFont();
-
-
-
- int GetFormAlignment();
-
-
-
-
- CPDF_FormField* CheckRequiredFields(const CFX_PtrArray *fields = NULL, FX_BOOL bIncludeOrExclude = TRUE) const;
-
- CFDF_Document* ExportToFDF(FX_WSTR pdf_path, FX_BOOL bSimpleFileSpec = FALSE) const;
-
- CFDF_Document* ExportToFDF(FX_WSTR pdf_path, CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bSimpleFileSpec = FALSE) const;
-
- FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE);
-
-
-
-
- FX_BOOL ResetForm(const CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bNotify = FALSE);
-
- FX_BOOL ResetForm(FX_BOOL bNotify = FALSE);
-
- void ReloadForm();
-
- CPDF_FormNotify* GetFormNotify() const
- {
- return m_pFormNotify;
- }
-
- void SetFormNotify(const CPDF_FormNotify* pNotify);
-
-
- int GetPageWithWidget(int iCurPage, FX_BOOL bNext);
-
-
-
- FX_BOOL IsUpdated()
- {
- return m_bUpdated;
- }
-
- void ClearUpdatedFlag()
- {
- m_bUpdated = FALSE;
- }
-
-
- FX_BOOL HasXFAForm() const;
-
- void FixPageFields(const CPDF_Page* pPage);
-protected:
-
- static FX_BOOL m_bUpdateAP;
-
- void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0);
-
- CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name);
-
- CPDF_FormField* AddTerminalField(const CPDF_Dictionary* pFieldDict);
-
- CPDF_FormControl* AddControl(const CPDF_FormField* pField, const CPDF_Dictionary* pWidgetDict);
-
- void FDF_ImportField(CPDF_Dictionary* pField, const CFX_WideString& parent_name, FX_BOOL bNotify = FALSE, int nLevel = 0);
-
- FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl);
-
- int CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2);
-
- int CompareFieldName(const CFX_ByteString& name1, const CFX_ByteString& name2);
-
- CPDF_Document* m_pDocument;
-
- FX_BOOL m_bGenerateAP;
-
- CPDF_Dictionary* m_pFormDict;
-
- CFX_MapPtrToPtr m_ControlMap;
-
- CFieldTree *m_pFieldTree;
-
- CFX_ByteString m_bsEncoding;
-
- CPDF_FormNotify* m_pFormNotify;
-
- FX_BOOL m_bUpdated;
- friend class CPDF_FormControl;
- friend class CPDF_FormField;
-};
-#define FORMFIELD_READONLY 0x01
-#define FORMFIELD_REQUIRED 0x02
-#define FORMFIELD_NOEXPORT 0x04
-#define FORMRADIO_NOTOGGLEOFF 0x100
-#define FORMRADIO_UNISON 0x200
-#define FORMTEXT_MULTILINE 0x100
-#define FORMTEXT_PASSWORD 0x200
-#define FORMTEXT_NOSCROLL 0x400
-#define FORMTEXT_COMB 0x800
-#define FORMCOMBO_EDIT 0x100
-#define FORMLIST_MULTISELECT 0x100
-class CPDF_FormField : public CFX_Object
-{
-public:
-
- enum Type {
- Unknown,
- PushButton,
- RadioButton,
- CheckBox,
- Text,
- RichText,
- File,
- ListBox,
- ComboBox,
- Sign
- };
-
- CFX_WideString GetFullName();
-
- Type GetType()
- {
- return m_Type;
- }
-
- FX_DWORD GetFlags()
- {
- return m_Flags;
- }
-
- CPDF_InterForm* GetInterForm() const
- {
- return m_pForm;
- }
-
- CPDF_Dictionary* GetFieldDict() const
- {
- return m_pDict;
- }
-
- void SetFieldDict(CPDF_Dictionary* pDict)
- {
- m_pDict = pDict;
- }
-
- FX_BOOL ResetField(FX_BOOL bNotify = FALSE);
-
-
-
- int CountControls()
- {
- return m_ControlList.GetSize();
- }
-
- CPDF_FormControl* GetControl(int index)
- {
- return (CPDF_FormControl*)m_ControlList.GetAt(index);
- }
-
- int GetControlIndex(const CPDF_FormControl* pControl);
-
-
-
-
- int GetFieldType();
-
-
-
-
- CPDF_AAction GetAdditionalAction();
-
-
-
-
- CFX_WideString GetAlternateName();
-
-
-
-
- CFX_WideString GetMappingName();
-
-
-
-
- FX_DWORD GetFieldFlags();
-
-
-
-
- CFX_ByteString GetDefaultStyle();
-
-
-
-
- CFX_WideString GetRichTextString();
-
-
-
- CFX_WideString GetValue();
-
- CFX_WideString GetDefaultValue();
-
- FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE);
-
-
-
-
-
- int GetMaxLen();
-
-
-
-
- int CountSelectedItems();
-
- int GetSelectedIndex(int index);
-
- FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE);
-
- FX_BOOL IsItemSelected(int index);
-
- FX_BOOL SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
-
- FX_BOOL IsItemDefaultSelected(int index);
-
- int GetDefaultSelectedItem();
-
-
-
-
- int CountOptions();
-
- CFX_WideString GetOptionLabel(int index);
-
- CFX_WideString GetOptionValue(int index);
-
- int FindOption(CFX_WideString csOptLabel);
-
- int FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex = 0);
-
-
-
-
- FX_BOOL CheckControl(int iControlIndex, FX_BOOL bChecked, FX_BOOL bNotify = FALSE);
-
-
-
-
- int GetTopVisibleIndex();
-
-
-
-
- int CountSelectedOptions();
-
- int GetSelectedOptionIndex(int index);
-
- FX_BOOL IsOptionSelected(int iOptIndex);
-
- FX_BOOL SelectOption(int iOptIndex, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
-
- FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE);
-
-
-
-
- FX_FLOAT GetFontSize()
- {
- return m_FontSize;
- }
-
- CPDF_Font* GetFont()
- {
- return m_pFont;
- }
-
-protected:
-
- CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict);
-
- ~CPDF_FormField();
-
- CPDF_FormField::Type m_Type;
-
- FX_DWORD m_Flags;
-
- CPDF_InterForm* m_pForm;
-
- CPDF_Dictionary* m_pDict;
-
- CFX_PtrArray m_ControlList;
- friend class CPDF_InterForm;
- friend class CPDF_FormControl;
-
-
-
- CFX_WideString GetValue(FX_BOOL bDefault);
-
- FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
-
-
- void SyncFieldFlags();
-
- int FindListSel(CPDF_String* str);
-
- CFX_WideString GetOptionText(int index, int sub_index);
-
- void LoadDA();
-
- void UpdateAP(CPDF_FormControl* pControl);
-
-
-
- CFX_WideString GetCheckValue(FX_BOOL bDefault);
-
- FX_BOOL SetCheckValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
-
-
- FX_FLOAT m_FontSize;
-
- CPDF_Font* m_pFont;
-};
-CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel = 0);
-class CPDF_IconFit : public CFX_Object
-{
-public:
-
- CPDF_IconFit(CPDF_Dictionary* pDict = NULL)
- {
- m_pDict = pDict;
- }
-
- operator CPDF_Dictionary*() const
- {
- return m_pDict;
- }
-
-
-
-
- enum ScaleMethod {
- Always = 0,
- Bigger,
- Smaller,
- Never
- };
-
- ScaleMethod GetScaleMethod();
-
-
-
-
- FX_BOOL IsProportionalScale();
-
-
-
-
- void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom);
-
-
-
-
- FX_BOOL GetFittingBounds();
-
-
- CPDF_Dictionary* m_pDict;
-};
-
-#define TEXTPOS_CAPTION 0
-#define TEXTPOS_ICON 1
-#define TEXTPOS_BELOW 2
-#define TEXTPOS_ABOVE 3
-#define TEXTPOS_RIGHT 4
-#define TEXTPOS_LEFT 5
-#define TEXTPOS_OVERLAID 6
-class CPDF_FormControl : public CFX_Object
-{
-public:
-
- CPDF_FormField::Type GetType()
- {
- return m_pField->GetType();
- }
-
- CPDF_InterForm* GetInterForm() const
- {
- return m_pForm;
- }
-
- CPDF_FormField* GetField() const
- {
- return m_pField;
- }
-
- CPDF_Dictionary* GetWidget() const
- {
- return m_pWidgetDict;
- }
-
- CFX_FloatRect GetRect();
-
- void DrawControl(CFX_RenderDevice* pDevice, CFX_AffineMatrix* pMatrix,
- CPDF_Page* pPage, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions = NULL);
-
-
-
- CFX_ByteString GetCheckedAPState();
-
- CFX_WideString GetExportValue();
-
- FX_BOOL IsChecked();
-
- FX_BOOL IsDefaultChecked();
-
-
-
-
- enum HighlightingMode {
- None = 0,
- Invert,
- Outline,
- Push,
- Toggle
- };
-
- HighlightingMode GetHighlightingMode();
-
-
-
-
- FX_BOOL HasMKEntry(CFX_ByteString csEntry);
-
-
-
-
- int GetRotation();
-
-
-
-
- inline FX_ARGB GetBorderColor(int& iColorType)
- {
- return GetColor(iColorType, "BC");
- }
-
- inline FX_FLOAT GetOriginalBorderColor(int index)
- {
- return GetOriginalColor(index, "BC");
- }
-
- inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
- {
- GetOriginalColor(iColorType, fc, "BC");
- }
-
-
-
-
- inline FX_ARGB GetBackgroundColor(int& iColorType)
- {
- return GetColor(iColorType, "BG");
- }
-
- inline FX_FLOAT GetOriginalBackgroundColor(int index)
- {
- return GetOriginalColor(index, "BG");
- }
-
- inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
- {
- GetOriginalColor(iColorType, fc, "BG");
- }
-
-
-
-
- inline CFX_WideString GetNormalCaption()
- {
- return GetCaption("CA");
- }
-
-
-
-
- inline CFX_WideString GetRolloverCaption()
- {
- return GetCaption("RC");
- }
-
-
-
-
- inline CFX_WideString GetDownCaption()
- {
- return GetCaption("AC");
- }
-
-
-
-
- inline CPDF_Stream* GetNormalIcon()
- {
- return GetIcon("I");
- }
-
-
-
-
- inline CPDF_Stream* GetRolloverIcon()
- {
- return GetIcon("RI");
- }
-
-
-
-
- inline CPDF_Stream* GetDownIcon()
- {
- return GetIcon("IX");
- }
-
-
-
-
- CPDF_IconFit GetIconFit();
-
-
-
-
- int GetTextPosition();
-
-
-
-
- CPDF_Action GetAction();
-
-
-
-
- CPDF_AAction GetAdditionalAction();
-
-
-
-
- CPDF_DefaultAppearance GetDefaultAppearance();
-
- CPDF_Font* GetDefaultControlFont();
-
-
-
-
- int GetControlAlignment();
-
-protected:
-
- CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict);
-
- CFX_ByteString GetOnStateName();
-
- void SetOnStateName(const CFX_ByteString& csOn);
-
- void CheckControl(FX_BOOL bChecked);
-
- FX_ARGB GetColor(int& iColorType, CFX_ByteString csEntry);
-
- FX_FLOAT GetOriginalColor(int index, CFX_ByteString csEntry);
-
- void GetOriginalColor(int& iColorType, FX_FLOAT fc[4], CFX_ByteString csEntry);
-
- CFX_WideString GetCaption(CFX_ByteString csEntry);
-
- CPDF_Stream* GetIcon(CFX_ByteString csEntry);
-
- CPDF_ApSettings GetMK(FX_BOOL bCreate);
-
- CPDF_InterForm* m_pForm;
-
- CPDF_FormField* m_pField;
-
- CPDF_Dictionary* m_pWidgetDict;
- friend class CPDF_InterForm;
- friend class CPDF_FormField;
-};
-class CPDF_FormNotify : public CFX_Object
-{
-public:
-
- virtual ~CPDF_FormNotify() {}
-
- virtual int BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue)
- {
- return 0;
- }
-
- virtual int AfterValueChange(const CPDF_FormField* pField)
- {
- return 0;
- }
-
- virtual int BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue)
- {
- return 0;
- }
-
- virtual int AfterSelectionChange(const CPDF_FormField* pField)
- {
- return 0;
- }
-
- virtual int AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray)
- {
- return 0;
- }
-
- virtual int BeforeFormReset(const CPDF_InterForm* pForm)
- {
- return 0;
- }
-
- virtual int AfterFormReset(const CPDF_InterForm* pForm)
- {
- return 0;
- }
-
- virtual int BeforeFormImportData(const CPDF_InterForm* pForm)
- {
- return 0;
- }
-
- virtual int AfterFormImportData(const CPDF_InterForm* pForm)
- {
- return 0;
- }
-};
-FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
-class CPDF_PageLabel : public CFX_Object
-{
-public:
-
- CPDF_PageLabel(CPDF_Document* pDocument)
- {
- m_pDocument = pDocument;
- }
-
-
- CFX_WideString GetLabel(int nPage) const;
-
- FX_INT32 GetPageByLabel(FX_BSTR bsLabel) const;
-
-
- FX_INT32 GetPageByLabel(FX_WSTR wsLabel) const;
-
-protected:
- CPDF_Document* m_pDocument;
-};
-class CPDF_Metadata
-{
-public:
-
- CPDF_Metadata();
-
-
- ~CPDF_Metadata();
-
- void LoadDoc(CPDF_Document *pDoc);
-
-
- FX_INT32 GetString(FX_BSTR bsItem, CFX_WideString &wsStr);
-
- CXML_Element* GetRoot() const;
-
- CXML_Element* GetRDF() const;
-
-protected:
- FX_LPVOID m_pData;
-};
-class CPDF_ViewerPreferences
-{
-public:
-
- CPDF_ViewerPreferences(CPDF_Document *pDoc);
-
-
- ~CPDF_ViewerPreferences();
-
-
- FX_BOOL IsDirectionR2L() const;
-
- FX_BOOL PrintScaling() const;
-
-
-protected:
- CPDF_Document* m_pDoc;
-};
-class CPDF_ApSettings : public CFX_Object
-{
-public:
-
- CPDF_ApSettings(CPDF_Dictionary* pDict = NULL)
- {
- m_pDict = pDict;
- }
-
- operator CPDF_Dictionary* () const
- {
- return m_pDict;
- }
-
- FX_BOOL HasMKEntry(FX_BSTR csEntry);
-
-
-
- int GetRotation();
-
-
-
-
- inline FX_ARGB GetBorderColor(int& iColorType)
- {
- return GetColor(iColorType, FX_BSTRC("BC"));
- }
-
- inline FX_FLOAT GetOriginalBorderColor(int index)
- {
- return GetOriginalColor(index, FX_BSTRC("BC"));
- }
-
- inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
- {
- GetOriginalColor(iColorType, fc, FX_BSTRC("BC"));
- }
-
-
-
-
- inline FX_ARGB GetBackgroundColor(int& iColorType)
- {
- return GetColor(iColorType, FX_BSTRC("BG"));
- }
-
- inline FX_FLOAT GetOriginalBackgroundColor(int index)
- {
- return GetOriginalColor(index, FX_BSTRC("BG"));
- }
-
- inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
- {
- GetOriginalColor(iColorType, fc, FX_BSTRC("BG"));
- }
-
-
-
-
- inline CFX_WideString GetNormalCaption()
- {
- return GetCaption(FX_BSTRC("CA"));
- }
-
-
-
-
- inline CFX_WideString GetRolloverCaption()
- {
- return GetCaption(FX_BSTRC("RC"));
- }
-
-
-
-
- inline CFX_WideString GetDownCaption()
- {
- return GetCaption(FX_BSTRC("AC"));
- }
-
-
-
-
- inline CPDF_Stream* GetNormalIcon()
- {
- return GetIcon(FX_BSTRC("I"));
- }
-
-
-
-
- inline CPDF_Stream* GetRolloverIcon()
- {
- return GetIcon(FX_BSTRC("RI"));
- }
-
-
-
-
- inline CPDF_Stream* GetDownIcon()
- {
- return GetIcon(FX_BSTRC("IX"));
- }
-
-
-
-
- CPDF_IconFit GetIconFit();
-
-
-
-
- int GetTextPosition();
-
- CPDF_Dictionary* m_pDict;
-protected:
-
- FX_ARGB GetColor(int& iColorType, FX_BSTR csEntry);
-
- FX_FLOAT GetOriginalColor(int index, FX_BSTR csEntry);
-
- void GetOriginalColor(int& iColorType, FX_FLOAT fc[4], FX_BSTR csEntry);
-
- CFX_WideString GetCaption(FX_BSTR csEntry);
-
- CPDF_Stream* GetIcon(FX_BSTR csEntry);
- friend class CPDF_FormControl;
-};
-#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_DOC_H_
+#define _FPDF_DOC_H_
+#ifndef _FPDF_PARSER_
+#include "../fpdfapi/fpdf_parser.h"
+#endif
+#ifndef _FPDF_RENDER_
+#include "../fpdfapi/fpdf_render.h"
+#endif
+class CPDF_Action;
+class CPDF_Annot;
+class CPDF_AnnotList;
+class CPDF_Bookmark;
+class CPDF_BookmarkTree;
+class CPDF_Dest;
+class CPDF_Link;
+class CPDF_LinkList;
+class CPDF_Metadata;
+class CPDF_NameTree;
+class CPDF_NumberTree;
+class CPDF_TextObject;
+class CPDF_ViewerPreferences;
+class CPDF_Page;
+class CPDF_RenderOptions;
+class CXML_Element;
+class CPDF_OCContext;
+class CPDF_DocJSActions;
+class CPDF_ActionFields;
+class CPDF_AAction;
+class CPDF_FileSpec;
+class CPDF_IconFit;
+class CPDF_DefaultAppearance;
+class CPDF_InterForm;
+class CPDF_FormField;
+class CPDF_FormNotify;
+class CPDF_FormControl;
+class CPDF_LWinParam;
+class CFieldTree;
+class CPDF_ApSettings;
+class CPDF_NameTree : public CFX_Object
+{
+public:
+
+ CPDF_NameTree(CPDF_Dictionary* pRoot)
+ {
+ m_pRoot = pRoot;
+ }
+
+ CPDF_NameTree(CPDF_Document* pDoc, FX_BSTR category);
+
+ CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const;
+
+ CPDF_Object* LookupValue(const CFX_ByteString& csName) const;
+
+ CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, FX_BSTR sName);
+
+ int GetIndex(const CFX_ByteString& csName) const;
+
+ int GetCount() const;
+
+
+ CPDF_Dictionary* GetRoot() const
+ {
+ return m_pRoot;
+ }
+
+protected:
+
+ CPDF_Dictionary* m_pRoot;
+};
+class CPDF_BookmarkTree : public CFX_Object
+{
+public:
+
+ CPDF_BookmarkTree(CPDF_Document* pDoc)
+ {
+ m_pDocument = pDoc;
+ }
+public:
+
+
+
+ CPDF_Bookmark GetFirstChild(CPDF_Bookmark parent);
+
+ CPDF_Bookmark GetNextSibling(CPDF_Bookmark bookmark);
+
+
+ CPDF_Document* GetDocument() const
+ {
+ return m_pDocument;
+ }
+protected:
+
+ CPDF_Document* m_pDocument;
+};
+#define PDFBOOKMARK_ITALIC 1
+#define PDFBOOKMARK_BOLD 2
+class CPDF_Bookmark : public CFX_Object
+{
+public:
+
+ CPDF_Bookmark(CPDF_Dictionary* pDict = NULL)
+ {
+ m_pDict = pDict;
+ }
+
+ operator CPDF_Dictionary*() const
+ {
+ return m_pDict;
+ }
+
+
+
+ FX_DWORD GetColorRef();
+
+ FX_DWORD GetFontStyle();
+
+ CFX_WideString GetTitle();
+
+
+
+
+ CPDF_Dest GetDest(CPDF_Document* pDocument);
+
+ CPDF_Action GetAction();
+
+
+ CPDF_Dictionary* m_pDict;
+};
+#define PDFZOOM_XYZ 1
+#define PDFZOOM_FITPAGE 2
+#define PDFZOOM_FITHORZ 3
+#define PDFZOOM_FITVERT 4
+#define PDFZOOM_FITRECT 5
+#define PDFZOOM_FITBBOX 6
+#define PDFZOOM_FITBHORZ 7
+
+#define PDFZOOM_FITBVERT 8
+class CPDF_Dest : public CFX_Object
+{
+public:
+
+ CPDF_Dest(CPDF_Object* pObj = NULL)
+ {
+ m_pObj = pObj;
+ }
+
+ operator CPDF_Object* () const
+ {
+ return m_pObj;
+ }
+
+ CFX_ByteString GetRemoteName();
+
+ int GetPageIndex(CPDF_Document* pDoc);
+
+ FX_DWORD GetPageObjNum();
+
+ int GetZoomMode();
+
+ FX_FLOAT GetParam(int index);
+
+
+ CPDF_Object* m_pObj;
+};
+class CPDF_OCContext : public CFX_Object, public IPDF_OCContext
+{
+public:
+
+ enum UsageType {
+ View = 0,
+ Design,
+ Print,
+ Export
+ };
+
+ CPDF_OCContext(CPDF_Document *pDoc, UsageType eUsageType = View);
+
+ virtual ~CPDF_OCContext();
+
+ CPDF_Document* GetDocument() const
+ {
+ return m_pDocument;
+ }
+
+ UsageType GetUsageType() const
+ {
+ return m_eUsageType;
+ }
+
+ FX_BOOL CheckOCGVisible(const CPDF_Dictionary *pOCGDict);
+
+ void ResetOCContext();
+protected:
+
+ FX_BOOL LoadOCGStateFromConfig(FX_BSTR csConfig, const CPDF_Dictionary *pOCGDict, FX_BOOL &bValidConfig) const;
+
+ FX_BOOL LoadOCGState(const CPDF_Dictionary *pOCGDict) const;
+
+ FX_BOOL GetOCGVisible(const CPDF_Dictionary *pOCGDict);
+
+ FX_BOOL GetOCGVE(CPDF_Array *pExpression, FX_BOOL bFromConfig, int nLevel = 0);
+
+ FX_BOOL LoadOCMDState(const CPDF_Dictionary *pOCMDDict, FX_BOOL bFromConfig);
+
+ CPDF_Document *m_pDocument;
+
+ UsageType m_eUsageType;
+
+ CFX_MapPtrTemplate<const CPDF_Dictionary*, void*> m_OCGStates;
+};
+class CPDF_LWinParam : public CFX_Object
+{
+public:
+
+ CPDF_LWinParam(CPDF_Dictionary* pDict)
+ {
+ m_pDict = pDict;
+ }
+
+ operator CPDF_Dictionary* () const
+ {
+ return m_pDict;
+ }
+
+ inline CFX_ByteString GetFileName()
+ {
+ return m_pDict->GetString("F");
+ }
+
+
+ inline CFX_ByteString GetDefaultDirectory()
+ {
+ return m_pDict->GetString("D");
+ }
+
+
+ inline CFX_ByteString GetOperation()
+ {
+ return m_pDict->GetString("O");
+ }
+
+
+ inline CFX_ByteString GetParameter()
+ {
+ return m_pDict->GetString("P");
+ }
+
+ CPDF_Dictionary* m_pDict;
+};
+class CPDF_ActionFields : public CFX_Object
+{
+public:
+
+ CPDF_ActionFields(const CPDF_Action* pAction)
+ {
+ m_pAction = (CPDF_Action*)pAction;
+ }
+
+ operator CPDF_Action*() const
+ {
+ return m_pAction;
+ }
+
+ FX_DWORD GetFieldsCount() const;
+
+ void GetAllFields(CFX_PtrArray& fieldObjects) const;
+
+ CPDF_Object* GetField(FX_DWORD iIndex) const;
+
+ CPDF_Action* m_pAction;
+};
+
+#define PDFNAMED_NEXTPAGE 1
+#define PDFNAMED_PREVPAGE 2
+#define PDFNAMED_FIRSTPAGE 3
+#define PDFNAMED_LASTPAGE 4
+#define PDFJS_MAXLENGTH 64
+class CPDF_Action : public CFX_Object
+{
+public:
+
+ CPDF_Action(CPDF_Dictionary* pDict = NULL)
+ {
+ m_pDict = pDict;
+ }
+
+ operator CPDF_Dictionary* () const
+ {
+ return m_pDict;
+ }
+
+ enum ActionType {
+ Unknown = 0,
+ GoTo,
+ GoToR,
+ GoToE,
+ Launch,
+ Thread,
+ URI,
+ Sound,
+ Movie,
+ Hide,
+ Named,
+ SubmitForm,
+ ResetForm,
+ ImportData,
+ JavaScript,
+ SetOCGState,
+ Rendition,
+ Trans,
+ GoTo3DView
+ };
+
+ CFX_ByteString GetTypeName() const
+ {
+ return m_pDict->GetString("S");
+ }
+
+ ActionType GetType() const;
+
+
+
+ CPDF_Dest GetDest(CPDF_Document* pDoc) const;
+
+
+
+
+
+ CFX_WideString GetFilePath() const;
+
+
+
+
+ FX_BOOL GetNewWindow() const
+ {
+ return m_pDict->GetBoolean("NewWindow");
+ }
+
+
+
+
+ CPDF_LWinParam GetWinParam() const;
+
+
+
+
+ CFX_ByteString GetURI(CPDF_Document* pDoc) const;
+
+
+
+
+ FX_BOOL GetMouseMap() const
+ {
+ return m_pDict->GetBoolean("IsMap");
+ }
+
+
+
+
+ CPDF_ActionFields GetWidgets() const
+ {
+ return this;
+ }
+
+
+
+
+ FX_BOOL GetHideStatus() const
+ {
+ return m_pDict->GetBoolean("H", TRUE);
+ }
+
+
+
+
+ CFX_ByteString GetNamedAction() const
+ {
+ return m_pDict->GetString("N");
+ }
+
+
+
+
+ FX_DWORD GetFlags() const
+ {
+ return m_pDict->GetInteger("Flags");
+ }
+
+
+
+
+ CFX_WideString GetJavaScript() const;
+
+
+
+
+ CPDF_Dictionary* GetAnnot() const;
+
+
+
+
+ FX_INT32 GetOperationType() const;
+
+
+
+
+ CPDF_Stream* GetSoundStream() const
+ {
+ return m_pDict->GetStream("Sound");
+ }
+
+ FX_FLOAT GetVolume() const
+ {
+ return m_pDict->GetNumber("Volume");
+ }
+
+ FX_BOOL IsSynchronous() const
+ {
+ return m_pDict->GetBoolean("Synchronous");
+ }
+
+ FX_BOOL IsRepeat() const
+ {
+ return m_pDict->GetBoolean("Repeat");
+ }
+
+ FX_BOOL IsMixPlay() const
+ {
+ return m_pDict->GetBoolean("Mix");
+ }
+
+
+
+
+ FX_DWORD GetSubActionsCount() const;
+
+ CPDF_Action GetSubAction(FX_DWORD iIndex) const;
+
+
+ CPDF_Dictionary* m_pDict;
+};
+class CPDF_AAction : public CFX_Object
+{
+public:
+
+ CPDF_AAction(CPDF_Dictionary* pDict = NULL)
+ {
+ m_pDict = pDict;
+ }
+
+ operator CPDF_Dictionary*() const
+ {
+ return m_pDict;
+ }
+
+ enum AActionType {
+ CursorEnter = 0,
+ CursorExit,
+ ButtonDown,
+ ButtonUp,
+ GetFocus,
+ LoseFocus,
+ PageOpen,
+ PageClose,
+ PageVisible,
+ PageInvisible,
+ OpenPage,
+ ClosePage,
+ KeyStroke,
+ Format,
+ Validate,
+ Calculate,
+ CloseDocument,
+ SaveDocument,
+ DocumentSaved,
+ PrintDocument,
+ DocumentPrinted
+ };
+
+ FX_BOOL ActionExist(AActionType eType) const;
+
+ CPDF_Action GetAction(AActionType eType) const;
+
+ FX_POSITION GetStartPos() const;
+
+ CPDF_Action GetNextAction(FX_POSITION& pos, AActionType& eType) const;
+
+ CPDF_Dictionary* m_pDict;
+};
+class CPDF_DocJSActions : public CFX_Object
+{
+public:
+ CPDF_DocJSActions(CPDF_Document* pDoc);
+
+
+ int CountJSActions() const;
+
+ CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const;
+
+ CPDF_Action GetJSAction(const CFX_ByteString& csName) const;
+
+ int FindJSAction(const CFX_ByteString& csName) const;
+
+
+ CPDF_Document* GetDocument() const
+ {
+ return m_pDocument;
+ }
+
+protected:
+
+ CPDF_Document* m_pDocument;
+};
+class CPDF_FileSpec : public CFX_Object
+{
+public:
+
+ CPDF_FileSpec();
+
+ CPDF_FileSpec(CPDF_Object *pObj)
+ {
+ m_pObj = pObj;
+ }
+
+ operator CPDF_Object*() const
+ {
+ return m_pObj;
+ }
+
+ FX_BOOL IsURL() const;
+
+ FX_BOOL GetFileName(CFX_WideString &wsFileName) const;
+
+ CPDF_Stream* GetFileStream() const;
+
+ void SetFileName(FX_WSTR wsFileName, FX_BOOL bURL = FALSE);
+protected:
+
+ CPDF_Object *m_pObj;
+};
+class CPDF_LinkList : public CFX_Object
+{
+public:
+
+ CPDF_LinkList(CPDF_Document* pDoc)
+ {
+ m_pDocument = pDoc;
+ }
+
+ ~CPDF_LinkList();
+
+ CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y);
+
+ int CountLinks(CPDF_Page* pPage);
+
+ CPDF_Link GetLink(CPDF_Page* pPage, int index);
+
+ CPDF_Document* GetDocument() const
+ {
+ return m_pDocument;
+ }
+protected:
+
+ CPDF_Document* m_pDocument;
+
+ CFX_MapPtrToPtr m_PageMap;
+
+ CFX_PtrArray* GetPageLinks(CPDF_Page* pPage);
+
+ void LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList);
+};
+class CPDF_Link : public CFX_Object
+{
+public:
+
+ CPDF_Link(CPDF_Dictionary* pDict = NULL)
+ {
+ m_pDict = pDict;
+ }
+
+ operator CPDF_Dictionary*() const
+ {
+ return m_pDict;
+ }
+
+ CFX_FloatRect GetRect();
+
+
+
+ CPDF_Dest GetDest(CPDF_Document* pDoc);
+
+ CPDF_Action GetAction();
+
+
+ CPDF_Dictionary* m_pDict;
+};
+#define ANNOTFLAG_INVISIBLE 1
+#define ANNOTFLAG_HIDDEN 2
+#define ANNOTFLAG_PRINT 4
+#define ANNOTFLAG_NOZOOM 8
+#define ANNOTFLAG_NOROTATE 0x10
+#define ANNOTFLAG_NOVIEW 0x20
+#define ANNOTFLAG_READONLY 0x40
+#define ANNOTFLAG_LOCKED 0x80
+#define ANNOTFLAG_TOGGLENOVIEW 0x100
+class CPDF_Annot : public CFX_PrivateData, public CFX_Object
+{
+public:
+
+ CPDF_Annot(CPDF_Dictionary* pDict);
+
+ ~CPDF_Annot();
+
+ CPDF_Dictionary* m_pAnnotDict;
+
+ CFX_ByteString GetSubType() const;
+
+ FX_DWORD GetFlags() const
+ {
+ return m_pAnnotDict->GetInteger("F");
+ }
+
+ void GetRect(CFX_FloatRect& rect) const;
+
+ enum AppearanceMode {
+ Normal,
+ Rollover,
+ Down
+ };
+
+ FX_BOOL DrawAppearance(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
+ AppearanceMode mode, const CPDF_RenderOptions* pOptions);
+
+ FX_BOOL DrawInContext(const CPDF_Page* pPage, const CPDF_RenderContext* pContext,
+ const CFX_AffineMatrix* pUser2Device, AppearanceMode mode);
+
+ void ClearCachedAP();
+
+
+ void DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
+ const CPDF_RenderOptions* pOptions);
+
+ CPDF_PageObject* GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions* pOptions);
+
+
+
+ int CountIRTNotes();
+
+ CPDF_Annot* GetIRTNote(int index);
+
+
+ CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode);
+private:
+
+ CFX_MapPtrToPtr m_APMap;
+protected:
+ friend class CPDF_AnnotList;
+
+ CPDF_AnnotList* m_pList;
+
+ CPDF_Reference* NewAnnotRef();
+};
+class CPDF_AnnotList : public CFX_Object
+{
+public:
+
+ CPDF_AnnotList(CPDF_Page* pPage);
+
+ ~CPDF_AnnotList();
+
+ void GetAnnotMatrix(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CFX_Matrix &matrix) const;
+
+ void GetAnnotRect(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CPDF_Rect &rtAnnot) const;
+
+ void DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
+ CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
+ CPDF_RenderOptions* pOptions);
+
+ void DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
+ FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
+ CPDF_RenderOptions* pOptions)
+ {
+ DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, NULL);
+ }
+
+ void DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext,
+ FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget,
+ CPDF_RenderOptions* pOptions, FX_RECT *pClipRect)
+ {
+ DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, pClipRect);
+ }
+
+ void DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, CPDF_RenderContext* pContext,
+ FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_DWORD dwAnnotFlags,
+ CPDF_RenderOptions* pOptions, FX_RECT* pClipRect);
+
+
+
+ CPDF_Annot* GetAt(int index)
+ {
+ return (CPDF_Annot*)m_AnnotList.GetAt(index);
+ }
+
+ int Count()
+ {
+ return m_AnnotList.GetSize();
+ }
+
+ int GetIndex(CPDF_Annot* pAnnot);
+
+
+ CPDF_Document* GetDocument() const
+ {
+ return m_pDocument;
+ }
+protected:
+
+ CFX_PtrArray m_AnnotList;
+
+ CPDF_Dictionary* m_pPageDict;
+
+ CPDF_Document* m_pDocument;
+
+ CFX_PtrArray m_Borders;
+
+ void DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevice,
+ CPDF_RenderContext* pContext, FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix,
+ FX_BOOL bWidget, CPDF_RenderOptions* pOptions, FX_RECT* clip_rect);
+ friend class CPDF_Annot;
+};
+#define COLORTYPE_TRANSPARENT 0
+#define COLORTYPE_GRAY 1
+#define COLORTYPE_RGB 2
+#define COLORTYPE_CMYK 3
+class CPDF_DefaultAppearance : public CFX_Object
+{
+public:
+
+ CPDF_DefaultAppearance(const CFX_ByteString& csDA = "")
+ {
+ m_csDA = csDA;
+ }
+
+ CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA)
+ {
+ m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
+ }
+
+
+ operator CFX_ByteString() const
+ {
+ return m_csDA;
+ }
+
+ const CPDF_DefaultAppearance& operator =(const CFX_ByteString& csDA)
+ {
+ m_csDA = csDA;
+ return *this;
+ }
+
+ const CPDF_DefaultAppearance& operator =(const CPDF_DefaultAppearance& cDA)
+ {
+ m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA;
+ return *this;
+ }
+
+
+
+ FX_BOOL HasFont();
+
+ CFX_ByteString GetFontString();
+
+ void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize);
+
+
+
+
+ FX_BOOL HasColor(FX_BOOL bStrokingOperation = FALSE);
+
+ CFX_ByteString GetColorString(FX_BOOL bStrokingOperation = FALSE);
+
+ void GetColor(int& iColorType, FX_FLOAT fc[4], FX_BOOL bStrokingOperation = FALSE);
+
+ void GetColor(FX_ARGB& color, int& iColorType, FX_BOOL bStrokingOperation = FALSE);
+
+
+
+
+ FX_BOOL HasTextMatrix();
+
+ CFX_ByteString GetTextMatrixString();
+
+ CFX_AffineMatrix GetTextMatrix();
+
+protected:
+
+ CFX_ByteString m_csDA;
+};
+#define FIELDTYPE_UNKNOWN 0
+#define FIELDTYPE_PUSHBUTTON 1
+#define FIELDTYPE_CHECKBOX 2
+#define FIELDTYPE_RADIOBUTTON 3
+#define FIELDTYPE_COMBOBOX 4
+#define FIELDTYPE_LISTBOX 5
+#define FIELDTYPE_TEXTFIELD 6
+#define FIELDTYPE_SIGNATURE 7
+class CPDF_InterForm : public CFX_PrivateData, public CFX_Object
+{
+public:
+
+ CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bUpdateAP);
+
+ ~CPDF_InterForm();
+
+
+
+ static void EnableUpdateAP(FX_BOOL bUpdateAP);
+
+ static FX_BOOL UpdatingAPEnabled();
+
+
+ static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, FX_LPCSTR csType, int iMinLen = 2, FX_LPCSTR csPrefix = "");
+
+
+
+ static CPDF_Font* AddSystemDefaultFont(const CPDF_Document* pDocument);
+
+ static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, CFX_ByteString csFontName, FX_BYTE iCharSet = 1);
+
+ static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, CFX_WideString csFontName, FX_BYTE iCharSet = 1);
+
+ static CPDF_Font* AddStandardFont(const CPDF_Document* pDocument, CFX_ByteString csFontName);
+
+ static CFX_ByteString GetNativeFont(FX_BYTE iCharSet, FX_LPVOID pLogFont = NULL);
+
+ static CFX_ByteString GetNativeFont(FX_LPVOID pLogFont = NULL);
+
+ static FX_BYTE GetNativeCharSet();
+
+ static CPDF_Font* AddNativeFont(FX_BYTE iCharSet, const CPDF_Document* pDocument);
+
+ static CPDF_Font* AddNativeFont(const CPDF_Document* pDocument);
+
+
+
+
+ FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType);
+
+ FX_BOOL ValidateFieldName(const CPDF_FormField* pField, CFX_WideString& csNewFieldName);
+
+ FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName);
+
+
+
+
+ FX_DWORD CountFields(const CFX_WideString &csFieldName = L"");
+
+ CPDF_FormField* GetField(FX_DWORD index, const CFX_WideString &csFieldName = L"");
+
+ void GetAllFieldNames(CFX_WideStringArray& allFieldNames);
+
+ FX_BOOL IsValidFormField(const void* pField);
+
+ CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
+
+
+
+
+ FX_DWORD CountControls(CFX_WideString csFieldName = L"");
+
+ CPDF_FormControl* GetControl(FX_DWORD index, CFX_WideString csFieldName = L"");
+
+ FX_BOOL IsValidFormControl(const void* pControl);
+
+ int CountPageControls(CPDF_Page* pPage) const;
+
+ CPDF_FormControl* GetPageControl(CPDF_Page* pPage, int index) const;
+
+
+ CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y) const;
+
+ CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const;
+
+
+
+
+ FX_DWORD CountInternalFields(const CFX_WideString& csFieldName = L"") const;
+
+ CPDF_Dictionary* GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName = L"") const;
+
+
+
+
+
+ CPDF_Document* GetDocument() const
+ {
+ return m_pDocument;
+ }
+
+ CPDF_Dictionary* GetFormDict() const
+ {
+ return m_pFormDict;
+ }
+
+
+
+
+ FX_BOOL NeedConstructAP();
+
+ void NeedConstructAP(FX_BOOL bNeedAP);
+
+
+
+
+ int CountFieldsInCalculationOrder();
+
+ CPDF_FormField* GetFieldInCalculationOrder(int index);
+
+ int FindFieldInCalculationOrder(const CPDF_FormField* pField);
+
+
+
+
+ FX_DWORD CountFormFonts();
+
+ CPDF_Font* GetFormFont(FX_DWORD index, CFX_ByteString& csNameTag);
+
+ CPDF_Font* GetFormFont(CFX_ByteString csNameTag);
+
+ CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag);
+
+ CPDF_Font* GetNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
+
+ CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag);
+
+ FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
+
+ FX_BOOL FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag);
+
+ inline FX_BOOL FindFormFont(CFX_WideString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag)
+ {
+ return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag);
+ }
+
+
+
+
+
+ void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
+
+ CPDF_Font* AddNativeFormFont(FX_BYTE iCharSet, CFX_ByteString& csNameTag);
+
+ CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag);
+
+ void RemoveFormFont(const CPDF_Font* pFont);
+
+ void RemoveFormFont(CFX_ByteString csNameTag);
+
+
+
+
+ CPDF_DefaultAppearance GetDefaultAppearance();
+
+ CPDF_Font* GetDefaultFormFont();
+
+
+
+ int GetFormAlignment();
+
+
+
+
+ CPDF_FormField* CheckRequiredFields(const CFX_PtrArray *fields = NULL, FX_BOOL bIncludeOrExclude = TRUE) const;
+
+ CFDF_Document* ExportToFDF(FX_WSTR pdf_path, FX_BOOL bSimpleFileSpec = FALSE) const;
+
+ CFDF_Document* ExportToFDF(FX_WSTR pdf_path, CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bSimpleFileSpec = FALSE) const;
+
+ FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE);
+
+
+
+
+ FX_BOOL ResetForm(const CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bNotify = FALSE);
+
+ FX_BOOL ResetForm(FX_BOOL bNotify = FALSE);
+
+ void ReloadForm();
+
+ CPDF_FormNotify* GetFormNotify() const
+ {
+ return m_pFormNotify;
+ }
+
+ void SetFormNotify(const CPDF_FormNotify* pNotify);
+
+
+ int GetPageWithWidget(int iCurPage, FX_BOOL bNext);
+
+
+
+ FX_BOOL IsUpdated()
+ {
+ return m_bUpdated;
+ }
+
+ void ClearUpdatedFlag()
+ {
+ m_bUpdated = FALSE;
+ }
+
+
+ FX_BOOL HasXFAForm() const;
+
+ void FixPageFields(const CPDF_Page* pPage);
+protected:
+
+ static FX_BOOL m_bUpdateAP;
+
+ void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0);
+
+ CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name);
+
+ CPDF_FormField* AddTerminalField(const CPDF_Dictionary* pFieldDict);
+
+ CPDF_FormControl* AddControl(const CPDF_FormField* pField, const CPDF_Dictionary* pWidgetDict);
+
+ void FDF_ImportField(CPDF_Dictionary* pField, const CFX_WideString& parent_name, FX_BOOL bNotify = FALSE, int nLevel = 0);
+
+ FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl);
+
+ int CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2);
+
+ int CompareFieldName(const CFX_ByteString& name1, const CFX_ByteString& name2);
+
+ CPDF_Document* m_pDocument;
+
+ FX_BOOL m_bGenerateAP;
+
+ CPDF_Dictionary* m_pFormDict;
+
+ CFX_MapPtrToPtr m_ControlMap;
+
+ CFieldTree *m_pFieldTree;
+
+ CFX_ByteString m_bsEncoding;
+
+ CPDF_FormNotify* m_pFormNotify;
+
+ FX_BOOL m_bUpdated;
+ friend class CPDF_FormControl;
+ friend class CPDF_FormField;
+};
+#define FORMFIELD_READONLY 0x01
+#define FORMFIELD_REQUIRED 0x02
+#define FORMFIELD_NOEXPORT 0x04
+#define FORMRADIO_NOTOGGLEOFF 0x100
+#define FORMRADIO_UNISON 0x200
+#define FORMTEXT_MULTILINE 0x100
+#define FORMTEXT_PASSWORD 0x200
+#define FORMTEXT_NOSCROLL 0x400
+#define FORMTEXT_COMB 0x800
+#define FORMCOMBO_EDIT 0x100
+#define FORMLIST_MULTISELECT 0x100
+class CPDF_FormField : public CFX_Object
+{
+public:
+
+ enum Type {
+ Unknown,
+ PushButton,
+ RadioButton,
+ CheckBox,
+ Text,
+ RichText,
+ File,
+ ListBox,
+ ComboBox,
+ Sign
+ };
+
+ CFX_WideString GetFullName();
+
+ Type GetType()
+ {
+ return m_Type;
+ }
+
+ FX_DWORD GetFlags()
+ {
+ return m_Flags;
+ }
+
+ CPDF_InterForm* GetInterForm() const
+ {
+ return m_pForm;
+ }
+
+ CPDF_Dictionary* GetFieldDict() const
+ {
+ return m_pDict;
+ }
+
+ void SetFieldDict(CPDF_Dictionary* pDict)
+ {
+ m_pDict = pDict;
+ }
+
+ FX_BOOL ResetField(FX_BOOL bNotify = FALSE);
+
+
+
+ int CountControls()
+ {
+ return m_ControlList.GetSize();
+ }
+
+ CPDF_FormControl* GetControl(int index)
+ {
+ return (CPDF_FormControl*)m_ControlList.GetAt(index);
+ }
+
+ int GetControlIndex(const CPDF_FormControl* pControl);
+
+
+
+
+ int GetFieldType();
+
+
+
+
+ CPDF_AAction GetAdditionalAction();
+
+
+
+
+ CFX_WideString GetAlternateName();
+
+
+
+
+ CFX_WideString GetMappingName();
+
+
+
+
+ FX_DWORD GetFieldFlags();
+
+
+
+
+ CFX_ByteString GetDefaultStyle();
+
+
+
+
+ CFX_WideString GetRichTextString();
+
+
+
+ CFX_WideString GetValue();
+
+ CFX_WideString GetDefaultValue();
+
+ FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE);
+
+
+
+
+
+ int GetMaxLen();
+
+
+
+
+ int CountSelectedItems();
+
+ int GetSelectedIndex(int index);
+
+ FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE);
+
+ FX_BOOL IsItemSelected(int index);
+
+ FX_BOOL SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
+
+ FX_BOOL IsItemDefaultSelected(int index);
+
+ int GetDefaultSelectedItem();
+
+
+
+
+ int CountOptions();
+
+ CFX_WideString GetOptionLabel(int index);
+
+ CFX_WideString GetOptionValue(int index);
+
+ int FindOption(CFX_WideString csOptLabel);
+
+ int FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex = 0);
+
+
+
+
+ FX_BOOL CheckControl(int iControlIndex, FX_BOOL bChecked, FX_BOOL bNotify = FALSE);
+
+
+
+
+ int GetTopVisibleIndex();
+
+
+
+
+ int CountSelectedOptions();
+
+ int GetSelectedOptionIndex(int index);
+
+ FX_BOOL IsOptionSelected(int iOptIndex);
+
+ FX_BOOL SelectOption(int iOptIndex, FX_BOOL bSelected, FX_BOOL bNotify = FALSE);
+
+ FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE);
+
+
+
+
+ FX_FLOAT GetFontSize()
+ {
+ return m_FontSize;
+ }
+
+ CPDF_Font* GetFont()
+ {
+ return m_pFont;
+ }
+
+protected:
+
+ CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict);
+
+ ~CPDF_FormField();
+
+ CPDF_FormField::Type m_Type;
+
+ FX_DWORD m_Flags;
+
+ CPDF_InterForm* m_pForm;
+
+ CPDF_Dictionary* m_pDict;
+
+ CFX_PtrArray m_ControlList;
+ friend class CPDF_InterForm;
+ friend class CPDF_FormControl;
+
+
+
+ CFX_WideString GetValue(FX_BOOL bDefault);
+
+ FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
+
+
+ void SyncFieldFlags();
+
+ int FindListSel(CPDF_String* str);
+
+ CFX_WideString GetOptionText(int index, int sub_index);
+
+ void LoadDA();
+
+ void UpdateAP(CPDF_FormControl* pControl);
+
+
+
+ CFX_WideString GetCheckValue(FX_BOOL bDefault);
+
+ FX_BOOL SetCheckValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify);
+
+
+ FX_FLOAT m_FontSize;
+
+ CPDF_Font* m_pFont;
+};
+CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel = 0);
+class CPDF_IconFit : public CFX_Object
+{
+public:
+
+ CPDF_IconFit(CPDF_Dictionary* pDict = NULL)
+ {
+ m_pDict = pDict;
+ }
+
+ operator CPDF_Dictionary*() const
+ {
+ return m_pDict;
+ }
+
+
+
+
+ enum ScaleMethod {
+ Always = 0,
+ Bigger,
+ Smaller,
+ Never
+ };
+
+ ScaleMethod GetScaleMethod();
+
+
+
+
+ FX_BOOL IsProportionalScale();
+
+
+
+
+ void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom);
+
+
+
+
+ FX_BOOL GetFittingBounds();
+
+
+ CPDF_Dictionary* m_pDict;
+};
+
+#define TEXTPOS_CAPTION 0
+#define TEXTPOS_ICON 1
+#define TEXTPOS_BELOW 2
+#define TEXTPOS_ABOVE 3
+#define TEXTPOS_RIGHT 4
+#define TEXTPOS_LEFT 5
+#define TEXTPOS_OVERLAID 6
+class CPDF_FormControl : public CFX_Object
+{
+public:
+
+ CPDF_FormField::Type GetType()
+ {
+ return m_pField->GetType();
+ }
+
+ CPDF_InterForm* GetInterForm() const
+ {
+ return m_pForm;
+ }
+
+ CPDF_FormField* GetField() const
+ {
+ return m_pField;
+ }
+
+ CPDF_Dictionary* GetWidget() const
+ {
+ return m_pWidgetDict;
+ }
+
+ CFX_FloatRect GetRect();
+
+ void DrawControl(CFX_RenderDevice* pDevice, CFX_AffineMatrix* pMatrix,
+ CPDF_Page* pPage, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions = NULL);
+
+
+
+ CFX_ByteString GetCheckedAPState();
+
+ CFX_WideString GetExportValue();
+
+ FX_BOOL IsChecked();
+
+ FX_BOOL IsDefaultChecked();
+
+
+
+
+ enum HighlightingMode {
+ None = 0,
+ Invert,
+ Outline,
+ Push,
+ Toggle
+ };
+
+ HighlightingMode GetHighlightingMode();
+
+
+
+
+ FX_BOOL HasMKEntry(CFX_ByteString csEntry);
+
+
+
+
+ int GetRotation();
+
+
+
+
+ inline FX_ARGB GetBorderColor(int& iColorType)
+ {
+ return GetColor(iColorType, "BC");
+ }
+
+ inline FX_FLOAT GetOriginalBorderColor(int index)
+ {
+ return GetOriginalColor(index, "BC");
+ }
+
+ inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
+ {
+ GetOriginalColor(iColorType, fc, "BC");
+ }
+
+
+
+
+ inline FX_ARGB GetBackgroundColor(int& iColorType)
+ {
+ return GetColor(iColorType, "BG");
+ }
+
+ inline FX_FLOAT GetOriginalBackgroundColor(int index)
+ {
+ return GetOriginalColor(index, "BG");
+ }
+
+ inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
+ {
+ GetOriginalColor(iColorType, fc, "BG");
+ }
+
+
+
+
+ inline CFX_WideString GetNormalCaption()
+ {
+ return GetCaption("CA");
+ }
+
+
+
+
+ inline CFX_WideString GetRolloverCaption()
+ {
+ return GetCaption("RC");
+ }
+
+
+
+
+ inline CFX_WideString GetDownCaption()
+ {
+ return GetCaption("AC");
+ }
+
+
+
+
+ inline CPDF_Stream* GetNormalIcon()
+ {
+ return GetIcon("I");
+ }
+
+
+
+
+ inline CPDF_Stream* GetRolloverIcon()
+ {
+ return GetIcon("RI");
+ }
+
+
+
+
+ inline CPDF_Stream* GetDownIcon()
+ {
+ return GetIcon("IX");
+ }
+
+
+
+
+ CPDF_IconFit GetIconFit();
+
+
+
+
+ int GetTextPosition();
+
+
+
+
+ CPDF_Action GetAction();
+
+
+
+
+ CPDF_AAction GetAdditionalAction();
+
+
+
+
+ CPDF_DefaultAppearance GetDefaultAppearance();
+
+ CPDF_Font* GetDefaultControlFont();
+
+
+
+
+ int GetControlAlignment();
+
+protected:
+
+ CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict);
+
+ CFX_ByteString GetOnStateName();
+
+ void SetOnStateName(const CFX_ByteString& csOn);
+
+ void CheckControl(FX_BOOL bChecked);
+
+ FX_ARGB GetColor(int& iColorType, CFX_ByteString csEntry);
+
+ FX_FLOAT GetOriginalColor(int index, CFX_ByteString csEntry);
+
+ void GetOriginalColor(int& iColorType, FX_FLOAT fc[4], CFX_ByteString csEntry);
+
+ CFX_WideString GetCaption(CFX_ByteString csEntry);
+
+ CPDF_Stream* GetIcon(CFX_ByteString csEntry);
+
+ CPDF_ApSettings GetMK(FX_BOOL bCreate);
+
+ CPDF_InterForm* m_pForm;
+
+ CPDF_FormField* m_pField;
+
+ CPDF_Dictionary* m_pWidgetDict;
+ friend class CPDF_InterForm;
+ friend class CPDF_FormField;
+};
+class CPDF_FormNotify : public CFX_Object
+{
+public:
+
+ virtual ~CPDF_FormNotify() {}
+
+ virtual int BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue)
+ {
+ return 0;
+ }
+
+ virtual int AfterValueChange(const CPDF_FormField* pField)
+ {
+ return 0;
+ }
+
+ virtual int BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue)
+ {
+ return 0;
+ }
+
+ virtual int AfterSelectionChange(const CPDF_FormField* pField)
+ {
+ return 0;
+ }
+
+ virtual int AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray)
+ {
+ return 0;
+ }
+
+ virtual int BeforeFormReset(const CPDF_InterForm* pForm)
+ {
+ return 0;
+ }
+
+ virtual int AfterFormReset(const CPDF_InterForm* pForm)
+ {
+ return 0;
+ }
+
+ virtual int BeforeFormImportData(const CPDF_InterForm* pForm)
+ {
+ return 0;
+ }
+
+ virtual int AfterFormImportData(const CPDF_InterForm* pForm)
+ {
+ return 0;
+ }
+};
+FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
+class CPDF_PageLabel : public CFX_Object
+{
+public:
+
+ CPDF_PageLabel(CPDF_Document* pDocument)
+ {
+ m_pDocument = pDocument;
+ }
+
+
+ CFX_WideString GetLabel(int nPage) const;
+
+ FX_INT32 GetPageByLabel(FX_BSTR bsLabel) const;
+
+
+ FX_INT32 GetPageByLabel(FX_WSTR wsLabel) const;
+
+protected:
+ CPDF_Document* m_pDocument;
+};
+class CPDF_Metadata
+{
+public:
+
+ CPDF_Metadata();
+
+
+ ~CPDF_Metadata();
+
+ void LoadDoc(CPDF_Document *pDoc);
+
+
+ FX_INT32 GetString(FX_BSTR bsItem, CFX_WideString &wsStr);
+
+ CXML_Element* GetRoot() const;
+
+ CXML_Element* GetRDF() const;
+
+protected:
+ FX_LPVOID m_pData;
+};
+class CPDF_ViewerPreferences
+{
+public:
+
+ CPDF_ViewerPreferences(CPDF_Document *pDoc);
+
+
+ ~CPDF_ViewerPreferences();
+
+
+ FX_BOOL IsDirectionR2L() const;
+
+ FX_BOOL PrintScaling() const;
+
+
+protected:
+ CPDF_Document* m_pDoc;
+};
+class CPDF_ApSettings : public CFX_Object
+{
+public:
+
+ CPDF_ApSettings(CPDF_Dictionary* pDict = NULL)
+ {
+ m_pDict = pDict;
+ }
+
+ operator CPDF_Dictionary* () const
+ {
+ return m_pDict;
+ }
+
+ FX_BOOL HasMKEntry(FX_BSTR csEntry);
+
+
+
+ int GetRotation();
+
+
+
+
+ inline FX_ARGB GetBorderColor(int& iColorType)
+ {
+ return GetColor(iColorType, FX_BSTRC("BC"));
+ }
+
+ inline FX_FLOAT GetOriginalBorderColor(int index)
+ {
+ return GetOriginalColor(index, FX_BSTRC("BC"));
+ }
+
+ inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4])
+ {
+ GetOriginalColor(iColorType, fc, FX_BSTRC("BC"));
+ }
+
+
+
+
+ inline FX_ARGB GetBackgroundColor(int& iColorType)
+ {
+ return GetColor(iColorType, FX_BSTRC("BG"));
+ }
+
+ inline FX_FLOAT GetOriginalBackgroundColor(int index)
+ {
+ return GetOriginalColor(index, FX_BSTRC("BG"));
+ }
+
+ inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4])
+ {
+ GetOriginalColor(iColorType, fc, FX_BSTRC("BG"));
+ }
+
+
+
+
+ inline CFX_WideString GetNormalCaption()
+ {
+ return GetCaption(FX_BSTRC("CA"));
+ }
+
+
+
+
+ inline CFX_WideString GetRolloverCaption()
+ {
+ return GetCaption(FX_BSTRC("RC"));
+ }
+
+
+
+
+ inline CFX_WideString GetDownCaption()
+ {
+ return GetCaption(FX_BSTRC("AC"));
+ }
+
+
+
+
+ inline CPDF_Stream* GetNormalIcon()
+ {
+ return GetIcon(FX_BSTRC("I"));
+ }
+
+
+
+
+ inline CPDF_Stream* GetRolloverIcon()
+ {
+ return GetIcon(FX_BSTRC("RI"));
+ }
+
+
+
+
+ inline CPDF_Stream* GetDownIcon()
+ {
+ return GetIcon(FX_BSTRC("IX"));
+ }
+
+
+
+
+ CPDF_IconFit GetIconFit();
+
+
+
+
+ int GetTextPosition();
+
+ CPDF_Dictionary* m_pDict;
+protected:
+
+ FX_ARGB GetColor(int& iColorType, FX_BSTR csEntry);
+
+ FX_FLOAT GetOriginalColor(int index, FX_BSTR csEntry);
+
+ void GetOriginalColor(int& iColorType, FX_FLOAT fc[4], FX_BSTR csEntry);
+
+ CFX_WideString GetCaption(FX_BSTR csEntry);
+
+ CPDF_Stream* GetIcon(FX_BSTR csEntry);
+ friend class CPDF_FormControl;
+};
+#endif
diff --git a/core/include/fpdfdoc/fpdf_tagged.h b/core/include/fpdfdoc/fpdf_tagged.h
index a44c26311b..f3ab01ea28 100644
--- a/core/include/fpdfdoc/fpdf_tagged.h
+++ b/core/include/fpdfdoc/fpdf_tagged.h
@@ -1,99 +1,99 @@
-// 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_TAGGED_H_
-#define _FPDF_TAGGED_H_
-class CPDF_StructTree;
-class CPDF_StructElement;
-struct CPDF_StructKid;
-class CPDF_Document;
-class CPDF_Page;
-class IPDF_ReflowEngine;
-class IPDF_ReflowedPage;
-class CPDF_StructTree : public CFX_Object
-{
-public:
-
- static CPDF_StructTree* LoadDoc(const CPDF_Document* pDoc);
-
- static CPDF_StructTree* LoadPage(const CPDF_Document* pDoc, const CPDF_Dictionary* pPageDict);
-
- virtual ~CPDF_StructTree() {}
-
- virtual int CountTopElements() const = 0;
-
- virtual CPDF_StructElement* GetTopElement(int i) const = 0;
-};
-struct CPDF_StructKid {
- enum {
- Invalid,
- Element,
- PageContent,
- StreamContent,
- Object
- } m_Type;
-
- union {
- struct {
-
- CPDF_StructElement* m_pElement;
-
- CPDF_Dictionary* m_pDict;
- } m_Element;
- struct {
-
- FX_DWORD m_PageObjNum;
-
- FX_DWORD m_ContentId;
- } m_PageContent;
- struct {
-
- FX_DWORD m_PageObjNum;
-
- FX_DWORD m_ContentId;
-
- FX_DWORD m_RefObjNum;
- } m_StreamContent;
- struct {
-
- FX_DWORD m_PageObjNum;
-
- FX_DWORD m_RefObjNum;
- } m_Object;
- };
-};
-class CPDF_StructElement : public CFX_Object
-{
-public:
-
- virtual CPDF_StructTree* GetTree() const = 0;
-
- virtual const CFX_ByteString& GetType() const = 0;
-
- virtual CPDF_StructElement* GetParent() const = 0;
-
- virtual CPDF_Dictionary * GetDict() const = 0;
-
- virtual int CountKids() const = 0;
-
- virtual const CPDF_StructKid& GetKid(int index) const = 0;
-
- virtual CFX_PtrArray* GetObjectArray() = 0;
-
- virtual CPDF_Object* GetAttr(FX_BSTR owner, FX_BSTR name, FX_BOOL bInheritable = FALSE, FX_FLOAT fLevel = 0.0F) = 0;
-
-
-
- virtual CFX_ByteString GetName(FX_BSTR owner, FX_BSTR name, FX_BSTR default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
-
- virtual FX_ARGB GetColor(FX_BSTR owner, FX_BSTR name, FX_ARGB default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
-
- virtual FX_FLOAT GetNumber(FX_BSTR owner, FX_BSTR name, FX_FLOAT default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
-
- virtual int GetInteger(FX_BSTR owner, FX_BSTR name, int default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
-
-};
-#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_TAGGED_H_
+#define _FPDF_TAGGED_H_
+class CPDF_StructTree;
+class CPDF_StructElement;
+struct CPDF_StructKid;
+class CPDF_Document;
+class CPDF_Page;
+class IPDF_ReflowEngine;
+class IPDF_ReflowedPage;
+class CPDF_StructTree : public CFX_Object
+{
+public:
+
+ static CPDF_StructTree* LoadDoc(const CPDF_Document* pDoc);
+
+ static CPDF_StructTree* LoadPage(const CPDF_Document* pDoc, const CPDF_Dictionary* pPageDict);
+
+ virtual ~CPDF_StructTree() {}
+
+ virtual int CountTopElements() const = 0;
+
+ virtual CPDF_StructElement* GetTopElement(int i) const = 0;
+};
+struct CPDF_StructKid {
+ enum {
+ Invalid,
+ Element,
+ PageContent,
+ StreamContent,
+ Object
+ } m_Type;
+
+ union {
+ struct {
+
+ CPDF_StructElement* m_pElement;
+
+ CPDF_Dictionary* m_pDict;
+ } m_Element;
+ struct {
+
+ FX_DWORD m_PageObjNum;
+
+ FX_DWORD m_ContentId;
+ } m_PageContent;
+ struct {
+
+ FX_DWORD m_PageObjNum;
+
+ FX_DWORD m_ContentId;
+
+ FX_DWORD m_RefObjNum;
+ } m_StreamContent;
+ struct {
+
+ FX_DWORD m_PageObjNum;
+
+ FX_DWORD m_RefObjNum;
+ } m_Object;
+ };
+};
+class CPDF_StructElement : public CFX_Object
+{
+public:
+
+ virtual CPDF_StructTree* GetTree() const = 0;
+
+ virtual const CFX_ByteString& GetType() const = 0;
+
+ virtual CPDF_StructElement* GetParent() const = 0;
+
+ virtual CPDF_Dictionary * GetDict() const = 0;
+
+ virtual int CountKids() const = 0;
+
+ virtual const CPDF_StructKid& GetKid(int index) const = 0;
+
+ virtual CFX_PtrArray* GetObjectArray() = 0;
+
+ virtual CPDF_Object* GetAttr(FX_BSTR owner, FX_BSTR name, FX_BOOL bInheritable = FALSE, FX_FLOAT fLevel = 0.0F) = 0;
+
+
+
+ virtual CFX_ByteString GetName(FX_BSTR owner, FX_BSTR name, FX_BSTR default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
+
+ virtual FX_ARGB GetColor(FX_BSTR owner, FX_BSTR name, FX_ARGB default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
+
+ virtual FX_FLOAT GetNumber(FX_BSTR owner, FX_BSTR name, FX_FLOAT default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
+
+ virtual int GetInteger(FX_BSTR owner, FX_BSTR name, int default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0;
+
+};
+#endif
diff --git a/core/include/fpdfdoc/fpdf_vt.h b/core/include/fpdfdoc/fpdf_vt.h
index e2825c123d..41025cbe2e 100644
--- a/core/include/fpdfdoc/fpdf_vt.h
+++ b/core/include/fpdfdoc/fpdf_vt.h
@@ -1,444 +1,444 @@
-// 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_VT_H_
-#define _FPDF_VT_H_
-#include "../fxcrt/fx_basic.h"
-#include "../fpdfapi/fpdf_parser.h"
-struct CPVT_WordPlace;
-struct CPVT_WordRange;
-struct CPVT_Word;
-struct CPVT_Line;
-struct CPVT_Section;
-class IPDF_VariableText_Provider;
-class IPDF_VariableText_Iterator;
-class IPDF_VariableText;
-struct CPVT_WordPlace {
-
- CPVT_WordPlace() : nSecIndex(-1), nLineIndex(-1), nWordIndex(-1)
- {
- }
-
- CPVT_WordPlace(FX_INT32 nSecIndex, FX_INT32 nLineIndex, FX_INT32 nWordIndex)
- {
- this->nSecIndex = nSecIndex;
- this->nLineIndex = nLineIndex;
- this->nWordIndex = nWordIndex;
- }
-
- void Default()
- {
- nSecIndex = nLineIndex = nWordIndex = -1;
- }
-
- FX_BOOL operator == (const CPVT_WordPlace & wp) const
- {
- return wp.nSecIndex == this->nSecIndex && wp.nLineIndex == this->nLineIndex && wp.nWordIndex == this->nWordIndex;
- }
-
- FX_BOOL operator != (const CPVT_WordPlace & wp) const
- {
- return wp.nSecIndex != this->nSecIndex || wp.nLineIndex != this->nLineIndex || wp.nWordIndex != this->nWordIndex;
- }
-
- inline FX_INT32 WordCmp(const CPVT_WordPlace & wp) const
- {
- if (this->nSecIndex > wp.nSecIndex) {
- return 1;
- }
- if (this->nSecIndex < wp.nSecIndex) {
- return -1;
- }
- if (this->nLineIndex > wp.nLineIndex) {
- return 1;
- }
- if (this->nLineIndex < wp.nLineIndex) {
- return -1;
- }
- if (this->nWordIndex > wp.nWordIndex) {
- return 1;
- }
- if (this->nWordIndex < wp.nWordIndex) {
- return -1;
- }
- return 0;
- }
-
- inline FX_INT32 LineCmp(const CPVT_WordPlace & wp) const
- {
- if (this->nSecIndex > wp.nSecIndex) {
- return 1;
- }
- if (this->nSecIndex < wp.nSecIndex) {
- return -1;
- }
- if (this->nLineIndex > wp.nLineIndex) {
- return 1;
- }
- if (this->nLineIndex < wp.nLineIndex) {
- return -1;
- }
- return 0;
- }
-
- inline FX_INT32 SecCmp(const CPVT_WordPlace & wp) const
- {
- if (this->nSecIndex > wp.nSecIndex) {
- return 1;
- }
- if (this->nSecIndex < wp.nSecIndex) {
- return -1;
- }
- return 0;
- }
-
- FX_INT32 nSecIndex;
-
- FX_INT32 nLineIndex;
-
- FX_INT32 nWordIndex;
-};
-struct CPVT_WordRange {
-
- CPVT_WordRange()
- {
- }
-
- CPVT_WordRange(const CPVT_WordPlace & begin, const CPVT_WordPlace & end)
- {
- Set(begin, end);
- }
-
- void Default()
- {
- BeginPos.Default();
- EndPos.Default();
- }
-
- void Set(const CPVT_WordPlace & begin, const CPVT_WordPlace & end)
- {
- this->BeginPos = begin;
- this->EndPos = end;
- SwapWordPlace();
- }
-
- void SetBeginPos(const CPVT_WordPlace & begin)
- {
- this->BeginPos = begin;
- SwapWordPlace();
- }
-
- void SetEndPos(const CPVT_WordPlace & end)
- {
- this->EndPos = end;
- SwapWordPlace();
- }
-
- FX_BOOL IsExist() const
- {
- return this->BeginPos != this->EndPos;
- }
-
- FX_BOOL operator != (const CPVT_WordRange & wr) const
- {
- return wr.BeginPos != this->BeginPos || wr.EndPos != this->EndPos;
- }
-
- void SwapWordPlace()
- {
- if (BeginPos.WordCmp(EndPos) > 0) {
- CPVT_WordPlace place = EndPos;
- EndPos = BeginPos;
- BeginPos = place;
- }
- }
-
- CPVT_WordPlace BeginPos;
-
- CPVT_WordPlace EndPos;
-};
-struct CPVT_SecProps : public CFX_Object {
-
- CPVT_SecProps() : fLineLeading(0.0f), fLineIndent(0.0f), nAlignment(0)
- {
- }
-
- CPVT_SecProps(FX_FLOAT lineLeading, FX_FLOAT lineIndent, FX_INT32 alignment) :
- fLineLeading(lineLeading), fLineIndent(lineIndent), nAlignment(alignment)
- {
- }
-
- CPVT_SecProps(const CPVT_SecProps & other) :
- fLineLeading(other.fLineLeading), fLineIndent(other.fLineIndent), nAlignment(other.nAlignment)
- {
- }
-
- FX_FLOAT fLineLeading;
-
- FX_FLOAT fLineIndent;
-
- FX_INT32 nAlignment;
-};
-struct CPVT_WordProps : public CFX_Object {
-
- CPVT_WordProps() : nFontIndex(-1), fFontSize(0.0f), dwWordColor(0), nScriptType(0), nWordStyle(0),
- fCharSpace(0.0f), nHorzScale(0)
- {
- }
-
- CPVT_WordProps(FX_INT32 fontIndex, FX_FLOAT fontSize, FX_COLORREF wordColor = 0, FX_INT32 scriptType = 0, FX_INT32 wordStyle = 0,
- FX_FLOAT charSpace = 0, FX_INT32 horzScale = 100) :
- nFontIndex(fontIndex), fFontSize(fontSize), dwWordColor(wordColor), nScriptType(scriptType),
- nWordStyle(wordStyle), fCharSpace(charSpace), nHorzScale(horzScale)
- {
- }
-
- CPVT_WordProps(const CPVT_WordProps & other) :
- nFontIndex(other.nFontIndex), fFontSize(other.fFontSize), dwWordColor(other.dwWordColor),
- nScriptType(other.nScriptType), nWordStyle(other.nWordStyle), fCharSpace(other.fCharSpace),
- nHorzScale(other.nHorzScale)
- {
- }
-
- FX_INT32 nFontIndex;
-
- FX_FLOAT fFontSize;
-
- FX_COLORREF dwWordColor;
-
- FX_INT32 nScriptType;
-
- FX_INT32 nWordStyle;
-
- FX_FLOAT fCharSpace;
-
- FX_INT32 nHorzScale;
-};
-struct CPVT_Word {
-
- CPVT_Word() : Word(0), nCharset(0), ptWord(0, 0), fAscent(0.0f), fDescent(0.0f), fWidth(0.0f),
- fFontSize(0), WordProps()
- {
- }
-
- FX_WORD Word;
-
- FX_INT32 nCharset;
-
- CPVT_WordPlace WordPlace;
-
- CPDF_Point ptWord;
-
- FX_FLOAT fAscent;
-
- FX_FLOAT fDescent;
-
- FX_FLOAT fWidth;
-
- FX_INT32 nFontIndex;
-
- FX_FLOAT fFontSize;
-
- CPVT_WordProps WordProps;
-};
-struct CPVT_Line {
-
- CPVT_Line() : ptLine(0, 0), fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f)
- {
- }
-
- CPVT_WordPlace lineplace;
-
- CPVT_WordPlace lineEnd;
-
- CPDF_Point ptLine;
-
- FX_FLOAT fLineWidth;
-
- FX_FLOAT fLineAscent;
-
- FX_FLOAT fLineDescent;
-};
-struct CPVT_Section {
-
- CPVT_WordPlace secplace;
-
- CPDF_Rect rcSection;
-
- CPVT_SecProps SecProps;
-
- CPVT_WordProps WordProps;
-};
-class IPDF_VariableText_Provider
-{
-public:
-
- virtual FX_INT32 GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32 nWordStyle) = 0;
-
- virtual FX_INT32 GetTypeAscent(FX_INT32 nFontIndex) = 0;
-
- virtual FX_INT32 GetTypeDescent(FX_INT32 nFontIndex) = 0;
-
- virtual FX_INT32 GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex) = 0;
-
- virtual FX_BOOL IsLatinWord(FX_WORD word) = 0;
-
- virtual FX_INT32 GetDefaultFontIndex() = 0;
-};
-class IPDF_VariableText_Iterator
-{
-public:
-
- virtual FX_BOOL NextWord() = 0;
-
- virtual FX_BOOL PrevWord() = 0;
-
- virtual FX_BOOL NextLine() = 0;
-
- virtual FX_BOOL PrevLine() = 0;
-
- virtual FX_BOOL NextSection() = 0;
-
- virtual FX_BOOL PrevSection() = 0;
-
- virtual FX_BOOL GetWord(CPVT_Word & word) const = 0;
-
- virtual FX_BOOL SetWord(const CPVT_Word & word) = 0;
-
- virtual FX_BOOL GetLine(CPVT_Line & line) const = 0;
-
- virtual FX_BOOL GetSection(CPVT_Section & section) const = 0;
-
- virtual FX_BOOL SetSection(const CPVT_Section & section) = 0;
-
- virtual void SetAt(FX_INT32 nWordIndex) = 0;
-
- virtual void SetAt(const CPVT_WordPlace & place) = 0;
-
- virtual const CPVT_WordPlace & GetAt() const = 0;
-};
-class IPDF_VariableText
-{
-public:
-
- static IPDF_VariableText* NewVariableText();
-
- static void DelVariableText(IPDF_VariableText* pVT);
-public:
-
- virtual IPDF_VariableText_Provider* SetProvider(IPDF_VariableText_Provider * pProvider) = 0;
-
- virtual IPDF_VariableText_Iterator* GetIterator() = 0;
-
- virtual void SetPlateRect(const CPDF_Rect & rect) = 0;
-
- virtual void SetAlignment(FX_INT32 nFormat = 0) = 0;
-
- virtual void SetPasswordChar(FX_WORD wSubWord = '*') = 0;
-
- virtual void SetLimitChar(FX_INT32 nLimitChar = 0) = 0;
-
- virtual void SetCharArray(FX_INT32 nCharArray = 0) = 0;
-
- virtual void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) = 0;
-
- virtual void SetHorzScale(FX_INT32 nHorzScale = 100) = 0;
-
- virtual void SetMultiLine(FX_BOOL bMultiLine = TRUE) = 0;
-
- virtual void SetAutoReturn(FX_BOOL bAuto = TRUE) = 0;
-
- virtual void SetAutoFontSize(FX_BOOL bAuto = TRUE) = 0;
-
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
-
- virtual void SetLineLeading(FX_FLOAT fLineLeading) = 0;
-
- virtual void SetRichText(FX_BOOL bRichText) = 0;
-
- virtual void Initialize() = 0;
-
- virtual FX_BOOL IsValid() const = 0;
-
- virtual FX_BOOL IsRichText() const = 0;
-
- virtual void RearrangeAll() = 0;
-
- virtual void RearrangePart(const CPVT_WordRange & PlaceRange) = 0;
-
- virtual void ResetAll() = 0;
-
- virtual void SetText(FX_LPCWSTR text, FX_INT32 charset = 1, const CPVT_SecProps * pSecProps = NULL,
- const CPVT_WordProps * pWordProps = NULL) = 0;
-
- virtual CPVT_WordPlace InsertWord(const CPVT_WordPlace & place, FX_WORD word, FX_INT32 charset = 1,
- const CPVT_WordProps * pWordProps = NULL) = 0;
-
- virtual CPVT_WordPlace InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps = NULL,
- const CPVT_WordProps * pWordProps = NULL) = 0;
-
- virtual CPVT_WordPlace InsertText(const CPVT_WordPlace & place, FX_LPCWSTR text, FX_INT32 charset = 1,
- const CPVT_SecProps * pSecProps = NULL, const CPVT_WordProps * pWordProps = NULL) = 0;
-
- virtual CPVT_WordPlace DeleteWords(const CPVT_WordRange & PlaceRange) = 0;
-
- virtual CPVT_WordPlace DeleteWord(const CPVT_WordPlace & place) = 0;
-
- virtual CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace & place) = 0;
-
- virtual const CPDF_Rect & GetPlateRect() const = 0;
-
- virtual CPDF_Rect GetContentRect() const = 0;
-
- virtual FX_INT32 GetTotalWords() const = 0;
-
- virtual FX_FLOAT GetFontSize() const = 0;
-
- virtual FX_INT32 GetAlignment() const = 0;
-
- virtual FX_WORD GetPasswordChar() const = 0;
-
- virtual FX_INT32 GetCharArray() const = 0;
-
- virtual FX_INT32 GetLimitChar() const = 0;
-
- virtual FX_BOOL IsMultiLine() const = 0;
-
- virtual FX_INT32 GetHorzScale() const = 0;
-
- virtual FX_FLOAT GetCharSpace() const = 0;
-
- virtual CPVT_WordPlace GetBeginWordPlace() const = 0;
-
- virtual CPVT_WordPlace GetEndWordPlace() const = 0;
-
- virtual CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace & place) const = 0;
-
- virtual CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace & place) const = 0;
-
- virtual CPVT_WordPlace SearchWordPlace(const CPDF_Point & point) const = 0;
-
- virtual CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const = 0;
-
- virtual CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const = 0;
-
- virtual CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace & place) const = 0;
-
- virtual CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace & place) const = 0;
-
- virtual CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace & place) const = 0;
-
- virtual CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace & place) const = 0;
-
- virtual void UpdateWordPlace(CPVT_WordPlace & place) const = 0;
-
- virtual CPVT_WordPlace AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const = 0;
-
- virtual FX_INT32 WordPlaceToWordIndex(const CPVT_WordPlace & place) const = 0;
-
- virtual CPVT_WordPlace WordIndexToWordPlace(FX_INT32 index) const = 0;
-};
-#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_VT_H_
+#define _FPDF_VT_H_
+#include "../fxcrt/fx_basic.h"
+#include "../fpdfapi/fpdf_parser.h"
+struct CPVT_WordPlace;
+struct CPVT_WordRange;
+struct CPVT_Word;
+struct CPVT_Line;
+struct CPVT_Section;
+class IPDF_VariableText_Provider;
+class IPDF_VariableText_Iterator;
+class IPDF_VariableText;
+struct CPVT_WordPlace {
+
+ CPVT_WordPlace() : nSecIndex(-1), nLineIndex(-1), nWordIndex(-1)
+ {
+ }
+
+ CPVT_WordPlace(FX_INT32 nSecIndex, FX_INT32 nLineIndex, FX_INT32 nWordIndex)
+ {
+ this->nSecIndex = nSecIndex;
+ this->nLineIndex = nLineIndex;
+ this->nWordIndex = nWordIndex;
+ }
+
+ void Default()
+ {
+ nSecIndex = nLineIndex = nWordIndex = -1;
+ }
+
+ FX_BOOL operator == (const CPVT_WordPlace & wp) const
+ {
+ return wp.nSecIndex == this->nSecIndex && wp.nLineIndex == this->nLineIndex && wp.nWordIndex == this->nWordIndex;
+ }
+
+ FX_BOOL operator != (const CPVT_WordPlace & wp) const
+ {
+ return wp.nSecIndex != this->nSecIndex || wp.nLineIndex != this->nLineIndex || wp.nWordIndex != this->nWordIndex;
+ }
+
+ inline FX_INT32 WordCmp(const CPVT_WordPlace & wp) const
+ {
+ if (this->nSecIndex > wp.nSecIndex) {
+ return 1;
+ }
+ if (this->nSecIndex < wp.nSecIndex) {
+ return -1;
+ }
+ if (this->nLineIndex > wp.nLineIndex) {
+ return 1;
+ }
+ if (this->nLineIndex < wp.nLineIndex) {
+ return -1;
+ }
+ if (this->nWordIndex > wp.nWordIndex) {
+ return 1;
+ }
+ if (this->nWordIndex < wp.nWordIndex) {
+ return -1;
+ }
+ return 0;
+ }
+
+ inline FX_INT32 LineCmp(const CPVT_WordPlace & wp) const
+ {
+ if (this->nSecIndex > wp.nSecIndex) {
+ return 1;
+ }
+ if (this->nSecIndex < wp.nSecIndex) {
+ return -1;
+ }
+ if (this->nLineIndex > wp.nLineIndex) {
+ return 1;
+ }
+ if (this->nLineIndex < wp.nLineIndex) {
+ return -1;
+ }
+ return 0;
+ }
+
+ inline FX_INT32 SecCmp(const CPVT_WordPlace & wp) const
+ {
+ if (this->nSecIndex > wp.nSecIndex) {
+ return 1;
+ }
+ if (this->nSecIndex < wp.nSecIndex) {
+ return -1;
+ }
+ return 0;
+ }
+
+ FX_INT32 nSecIndex;
+
+ FX_INT32 nLineIndex;
+
+ FX_INT32 nWordIndex;
+};
+struct CPVT_WordRange {
+
+ CPVT_WordRange()
+ {
+ }
+
+ CPVT_WordRange(const CPVT_WordPlace & begin, const CPVT_WordPlace & end)
+ {
+ Set(begin, end);
+ }
+
+ void Default()
+ {
+ BeginPos.Default();
+ EndPos.Default();
+ }
+
+ void Set(const CPVT_WordPlace & begin, const CPVT_WordPlace & end)
+ {
+ this->BeginPos = begin;
+ this->EndPos = end;
+ SwapWordPlace();
+ }
+
+ void SetBeginPos(const CPVT_WordPlace & begin)
+ {
+ this->BeginPos = begin;
+ SwapWordPlace();
+ }
+
+ void SetEndPos(const CPVT_WordPlace & end)
+ {
+ this->EndPos = end;
+ SwapWordPlace();
+ }
+
+ FX_BOOL IsExist() const
+ {
+ return this->BeginPos != this->EndPos;
+ }
+
+ FX_BOOL operator != (const CPVT_WordRange & wr) const
+ {
+ return wr.BeginPos != this->BeginPos || wr.EndPos != this->EndPos;
+ }
+
+ void SwapWordPlace()
+ {
+ if (BeginPos.WordCmp(EndPos) > 0) {
+ CPVT_WordPlace place = EndPos;
+ EndPos = BeginPos;
+ BeginPos = place;
+ }
+ }
+
+ CPVT_WordPlace BeginPos;
+
+ CPVT_WordPlace EndPos;
+};
+struct CPVT_SecProps : public CFX_Object {
+
+ CPVT_SecProps() : fLineLeading(0.0f), fLineIndent(0.0f), nAlignment(0)
+ {
+ }
+
+ CPVT_SecProps(FX_FLOAT lineLeading, FX_FLOAT lineIndent, FX_INT32 alignment) :
+ fLineLeading(lineLeading), fLineIndent(lineIndent), nAlignment(alignment)
+ {
+ }
+
+ CPVT_SecProps(const CPVT_SecProps & other) :
+ fLineLeading(other.fLineLeading), fLineIndent(other.fLineIndent), nAlignment(other.nAlignment)
+ {
+ }
+
+ FX_FLOAT fLineLeading;
+
+ FX_FLOAT fLineIndent;
+
+ FX_INT32 nAlignment;
+};
+struct CPVT_WordProps : public CFX_Object {
+
+ CPVT_WordProps() : nFontIndex(-1), fFontSize(0.0f), dwWordColor(0), nScriptType(0), nWordStyle(0),
+ fCharSpace(0.0f), nHorzScale(0)
+ {
+ }
+
+ CPVT_WordProps(FX_INT32 fontIndex, FX_FLOAT fontSize, FX_COLORREF wordColor = 0, FX_INT32 scriptType = 0, FX_INT32 wordStyle = 0,
+ FX_FLOAT charSpace = 0, FX_INT32 horzScale = 100) :
+ nFontIndex(fontIndex), fFontSize(fontSize), dwWordColor(wordColor), nScriptType(scriptType),
+ nWordStyle(wordStyle), fCharSpace(charSpace), nHorzScale(horzScale)
+ {
+ }
+
+ CPVT_WordProps(const CPVT_WordProps & other) :
+ nFontIndex(other.nFontIndex), fFontSize(other.fFontSize), dwWordColor(other.dwWordColor),
+ nScriptType(other.nScriptType), nWordStyle(other.nWordStyle), fCharSpace(other.fCharSpace),
+ nHorzScale(other.nHorzScale)
+ {
+ }
+
+ FX_INT32 nFontIndex;
+
+ FX_FLOAT fFontSize;
+
+ FX_COLORREF dwWordColor;
+
+ FX_INT32 nScriptType;
+
+ FX_INT32 nWordStyle;
+
+ FX_FLOAT fCharSpace;
+
+ FX_INT32 nHorzScale;
+};
+struct CPVT_Word {
+
+ CPVT_Word() : Word(0), nCharset(0), ptWord(0, 0), fAscent(0.0f), fDescent(0.0f), fWidth(0.0f),
+ fFontSize(0), WordProps()
+ {
+ }
+
+ FX_WORD Word;
+
+ FX_INT32 nCharset;
+
+ CPVT_WordPlace WordPlace;
+
+ CPDF_Point ptWord;
+
+ FX_FLOAT fAscent;
+
+ FX_FLOAT fDescent;
+
+ FX_FLOAT fWidth;
+
+ FX_INT32 nFontIndex;
+
+ FX_FLOAT fFontSize;
+
+ CPVT_WordProps WordProps;
+};
+struct CPVT_Line {
+
+ CPVT_Line() : ptLine(0, 0), fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f)
+ {
+ }
+
+ CPVT_WordPlace lineplace;
+
+ CPVT_WordPlace lineEnd;
+
+ CPDF_Point ptLine;
+
+ FX_FLOAT fLineWidth;
+
+ FX_FLOAT fLineAscent;
+
+ FX_FLOAT fLineDescent;
+};
+struct CPVT_Section {
+
+ CPVT_WordPlace secplace;
+
+ CPDF_Rect rcSection;
+
+ CPVT_SecProps SecProps;
+
+ CPVT_WordProps WordProps;
+};
+class IPDF_VariableText_Provider
+{
+public:
+
+ virtual FX_INT32 GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32 nWordStyle) = 0;
+
+ virtual FX_INT32 GetTypeAscent(FX_INT32 nFontIndex) = 0;
+
+ virtual FX_INT32 GetTypeDescent(FX_INT32 nFontIndex) = 0;
+
+ virtual FX_INT32 GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex) = 0;
+
+ virtual FX_BOOL IsLatinWord(FX_WORD word) = 0;
+
+ virtual FX_INT32 GetDefaultFontIndex() = 0;
+};
+class IPDF_VariableText_Iterator
+{
+public:
+
+ virtual FX_BOOL NextWord() = 0;
+
+ virtual FX_BOOL PrevWord() = 0;
+
+ virtual FX_BOOL NextLine() = 0;
+
+ virtual FX_BOOL PrevLine() = 0;
+
+ virtual FX_BOOL NextSection() = 0;
+
+ virtual FX_BOOL PrevSection() = 0;
+
+ virtual FX_BOOL GetWord(CPVT_Word & word) const = 0;
+
+ virtual FX_BOOL SetWord(const CPVT_Word & word) = 0;
+
+ virtual FX_BOOL GetLine(CPVT_Line & line) const = 0;
+
+ virtual FX_BOOL GetSection(CPVT_Section & section) const = 0;
+
+ virtual FX_BOOL SetSection(const CPVT_Section & section) = 0;
+
+ virtual void SetAt(FX_INT32 nWordIndex) = 0;
+
+ virtual void SetAt(const CPVT_WordPlace & place) = 0;
+
+ virtual const CPVT_WordPlace & GetAt() const = 0;
+};
+class IPDF_VariableText
+{
+public:
+
+ static IPDF_VariableText* NewVariableText();
+
+ static void DelVariableText(IPDF_VariableText* pVT);
+public:
+
+ virtual IPDF_VariableText_Provider* SetProvider(IPDF_VariableText_Provider * pProvider) = 0;
+
+ virtual IPDF_VariableText_Iterator* GetIterator() = 0;
+
+ virtual void SetPlateRect(const CPDF_Rect & rect) = 0;
+
+ virtual void SetAlignment(FX_INT32 nFormat = 0) = 0;
+
+ virtual void SetPasswordChar(FX_WORD wSubWord = '*') = 0;
+
+ virtual void SetLimitChar(FX_INT32 nLimitChar = 0) = 0;
+
+ virtual void SetCharArray(FX_INT32 nCharArray = 0) = 0;
+
+ virtual void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) = 0;
+
+ virtual void SetHorzScale(FX_INT32 nHorzScale = 100) = 0;
+
+ virtual void SetMultiLine(FX_BOOL bMultiLine = TRUE) = 0;
+
+ virtual void SetAutoReturn(FX_BOOL bAuto = TRUE) = 0;
+
+ virtual void SetAutoFontSize(FX_BOOL bAuto = TRUE) = 0;
+
+ virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
+
+ virtual void SetLineLeading(FX_FLOAT fLineLeading) = 0;
+
+ virtual void SetRichText(FX_BOOL bRichText) = 0;
+
+ virtual void Initialize() = 0;
+
+ virtual FX_BOOL IsValid() const = 0;
+
+ virtual FX_BOOL IsRichText() const = 0;
+
+ virtual void RearrangeAll() = 0;
+
+ virtual void RearrangePart(const CPVT_WordRange & PlaceRange) = 0;
+
+ virtual void ResetAll() = 0;
+
+ virtual void SetText(FX_LPCWSTR text, FX_INT32 charset = 1, const CPVT_SecProps * pSecProps = NULL,
+ const CPVT_WordProps * pWordProps = NULL) = 0;
+
+ virtual CPVT_WordPlace InsertWord(const CPVT_WordPlace & place, FX_WORD word, FX_INT32 charset = 1,
+ const CPVT_WordProps * pWordProps = NULL) = 0;
+
+ virtual CPVT_WordPlace InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps = NULL,
+ const CPVT_WordProps * pWordProps = NULL) = 0;
+
+ virtual CPVT_WordPlace InsertText(const CPVT_WordPlace & place, FX_LPCWSTR text, FX_INT32 charset = 1,
+ const CPVT_SecProps * pSecProps = NULL, const CPVT_WordProps * pWordProps = NULL) = 0;
+
+ virtual CPVT_WordPlace DeleteWords(const CPVT_WordRange & PlaceRange) = 0;
+
+ virtual CPVT_WordPlace DeleteWord(const CPVT_WordPlace & place) = 0;
+
+ virtual CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace & place) = 0;
+
+ virtual const CPDF_Rect & GetPlateRect() const = 0;
+
+ virtual CPDF_Rect GetContentRect() const = 0;
+
+ virtual FX_INT32 GetTotalWords() const = 0;
+
+ virtual FX_FLOAT GetFontSize() const = 0;
+
+ virtual FX_INT32 GetAlignment() const = 0;
+
+ virtual FX_WORD GetPasswordChar() const = 0;
+
+ virtual FX_INT32 GetCharArray() const = 0;
+
+ virtual FX_INT32 GetLimitChar() const = 0;
+
+ virtual FX_BOOL IsMultiLine() const = 0;
+
+ virtual FX_INT32 GetHorzScale() const = 0;
+
+ virtual FX_FLOAT GetCharSpace() const = 0;
+
+ virtual CPVT_WordPlace GetBeginWordPlace() const = 0;
+
+ virtual CPVT_WordPlace GetEndWordPlace() const = 0;
+
+ virtual CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace & place) const = 0;
+
+ virtual CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace & place) const = 0;
+
+ virtual CPVT_WordPlace SearchWordPlace(const CPDF_Point & point) const = 0;
+
+ virtual CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const = 0;
+
+ virtual CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const = 0;
+
+ virtual CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace & place) const = 0;
+
+ virtual CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace & place) const = 0;
+
+ virtual CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace & place) const = 0;
+
+ virtual CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace & place) const = 0;
+
+ virtual void UpdateWordPlace(CPVT_WordPlace & place) const = 0;
+
+ virtual CPVT_WordPlace AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const = 0;
+
+ virtual FX_INT32 WordPlaceToWordIndex(const CPVT_WordPlace & place) const = 0;
+
+ virtual CPVT_WordPlace WordIndexToWordPlace(FX_INT32 index) const = 0;
+};
+#endif
diff --git a/core/include/fpdftext/fpdf_text.h b/core/include/fpdftext/fpdf_text.h
index 8b5edc348f..2a5e4ac4bd 100644
--- a/core/include/fpdftext/fpdf_text.h
+++ b/core/include/fpdftext/fpdf_text.h
@@ -1,173 +1,173 @@
-// 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_TEXT_H_
-#define _FPDF_TEXT_H_
-#ifndef _FPDF_PARSER_
-#include "../fpdfapi/fpdf_parser.h"
-#endif
-#ifndef _FPDF_PAGEOBJ_H_
-#include "../fpdfapi/fpdf_pageobj.h"
-#endif
-#ifndef _FPDF_PAGE_
-#include "../fpdfapi/fpdf_page.h"
-#endif
-class CPDF_PageObjects;
-#define PDF2TXT_AUTO_ROTATE 1
-#define PDF2TXT_AUTO_WIDTH 2
-#define PDF2TXT_KEEP_COLUMN 4
-#define PDF2TXT_USE_OCR 8
-#define PDF2TXT_INCLUDE_INVISIBLE 16
-void PDF_GetPageText(CFX_ByteStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
- int iMinWidth, FX_DWORD flags);
-void PDF_GetPageText_Unicode(CFX_WideStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
- int iMinWidth, FX_DWORD flags);
-void PDF_GetTextStream_Unicode(CFX_WideTextBuf& buffer, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
- FX_DWORD flags);
-CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc, CPDF_Dictionary* pPage);
-class IPDF_TextPage;
-class IPDF_LinkExtract;
-class IPDF_TextPageFind;
-#define CHAR_ERROR -1
-#define CHAR_NORMAL 0
-#define CHAR_GENERATED 1
-#define CHAR_UNUNICODE 2
-typedef struct {
- FX_WCHAR m_Unicode;
- FX_WCHAR m_Charcode;
- FX_INT32 m_Flag;
- FX_FLOAT m_FontSize;
- FX_FLOAT m_OriginX;
- FX_FLOAT m_OriginY;
- CFX_FloatRect m_CharBox;
- CPDF_TextObject* m_pTextObj;
- CFX_AffineMatrix m_Matrix;
-} FPDF_CHAR_INFO;
-typedef CFX_ArrayTemplate<CFX_FloatRect> CFX_RectArray;
-#define FPDFTEXT_LRTB 0
-#define FPDFTEXT_RLTB 1
-#define FPDFTEXT_TBRL 2
-#define FPDFTEXT_LEFT -1
-#define FPDFTEXT_RIGHT 1
-#define FPDFTEXT_UP -2
-#define FPDFTEXT_DOWN 2
-class IPDF_ReflowedPage;
-#define FPDFTEXT_WRITINGMODE_UNKNOW 0
-#define FPDFTEXT_WRITINGMODE_LRTB 1
-#define FPDFTEXT_WRITINGMODE_RLTB 2
-#define FPDFTEXT_WRITINGMODE_TBRL 3
-class CPDFText_ParseOptions : public CFX_Object
-{
-public:
-
- CPDFText_ParseOptions();
- FX_BOOL m_bGetCharCodeOnly;
- FX_BOOL m_bNormalizeObjs;
- FX_BOOL m_bOutputHyphen;
-};
-class IPDF_TextPage : public CFX_Object
-{
-public:
-
- virtual ~IPDF_TextPage() {}
- static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage, CPDFText_ParseOptions ParserOptions);
- static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage, int flags = 0);
- static IPDF_TextPage* CreateTextPage(const CPDF_PageObjects* pObjs, int flags = 0);
- static IPDF_TextPage* CreateReflowTextPage(IPDF_ReflowedPage* pRefPage);
-
- virtual void NormalizeObjects(FX_BOOL bNormalize) = 0;
-
- virtual FX_BOOL ParseTextPage() = 0;
-
-
- virtual FX_BOOL IsParsered() const = 0;
-public:
-
- virtual int CharIndexFromTextIndex(int TextIndex) const = 0;
-
- virtual int TextIndexFromCharIndex(int CharIndex) const = 0;
-
-
- virtual int CountChars() const = 0;
-
- virtual void GetCharInfo(int index, FPDF_CHAR_INFO & info) const = 0;
-
- virtual void GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const = 0;
-
-
-
- virtual int GetIndexAtPos(CPDF_Point point, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const = 0;
-
- virtual int GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const = 0;
-
- virtual int GetOrderByDirection(int index, int direction) const = 0;
-
- virtual CFX_WideString GetTextByRect(CFX_FloatRect rect) const = 0;
-
- virtual void GetRectsArrayByRect(CFX_FloatRect rect, CFX_RectArray& resRectArray) const = 0;
-
-
- virtual int CountRects(int start, int nCount) = 0;
-
- virtual void GetRect(int rectIndex, FX_FLOAT& left, FX_FLOAT& top, FX_FLOAT& right, FX_FLOAT &bottom) const = 0;
-
- virtual FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate) = 0;
-
- virtual FX_BOOL GetBaselineRotate(CFX_FloatRect rect, int& Rotate) = 0;
-
- virtual int CountBoundedSegments(FX_FLOAT left, FX_FLOAT top, FX_FLOAT right, FX_FLOAT bottom, FX_BOOL bContains = FALSE) = 0;
-
- virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
-
-
- virtual int GetWordBreak(int index, int direction) const = 0;
-
- virtual CFX_WideString GetPageText(int start = 0, int nCount = -1 ) const = 0;
-};
-#define FPDFTEXT_MATCHCASE 0x00000001
-#define FPDFTEXT_MATCHWHOLEWORD 0x00000002
-#define FPDFTEXT_CONSECUTIVE 0x00000004
-class IPDF_TextPageFind : public CFX_Object
-{
-public:
-
- virtual ~IPDF_TextPageFind() {}
-
- static IPDF_TextPageFind* CreatePageFind(const IPDF_TextPage* pTextPage);
-public:
-
- virtual FX_BOOL FindFirst(CFX_WideString findwhat, int flags, int startPos = 0) = 0;
-
- virtual FX_BOOL FindNext() = 0;
-
- virtual FX_BOOL FindPrev() = 0;
-
- virtual void GetRectArray(CFX_RectArray& rects) const = 0;
-
- virtual int GetCurOrder() const = 0;
-
- virtual int GetMatchedCount() const = 0;
-};
-class IPDF_LinkExtract : public CFX_Object
-{
-public:
-
- virtual ~IPDF_LinkExtract() {}
-
- static IPDF_LinkExtract* CreateLinkExtract();
-
- virtual FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage) = 0;
-public:
-
- virtual int CountLinks() const = 0;
-
- virtual CFX_WideString GetURL(int index) const = 0;
-
- virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
-
- virtual void GetRects(int index, CFX_RectArray& rects) const = 0;
-};
-#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_TEXT_H_
+#define _FPDF_TEXT_H_
+#ifndef _FPDF_PARSER_
+#include "../fpdfapi/fpdf_parser.h"
+#endif
+#ifndef _FPDF_PAGEOBJ_H_
+#include "../fpdfapi/fpdf_pageobj.h"
+#endif
+#ifndef _FPDF_PAGE_
+#include "../fpdfapi/fpdf_page.h"
+#endif
+class CPDF_PageObjects;
+#define PDF2TXT_AUTO_ROTATE 1
+#define PDF2TXT_AUTO_WIDTH 2
+#define PDF2TXT_KEEP_COLUMN 4
+#define PDF2TXT_USE_OCR 8
+#define PDF2TXT_INCLUDE_INVISIBLE 16
+void PDF_GetPageText(CFX_ByteStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
+ int iMinWidth, FX_DWORD flags);
+void PDF_GetPageText_Unicode(CFX_WideStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
+ int iMinWidth, FX_DWORD flags);
+void PDF_GetTextStream_Unicode(CFX_WideTextBuf& buffer, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
+ FX_DWORD flags);
+CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc, CPDF_Dictionary* pPage);
+class IPDF_TextPage;
+class IPDF_LinkExtract;
+class IPDF_TextPageFind;
+#define CHAR_ERROR -1
+#define CHAR_NORMAL 0
+#define CHAR_GENERATED 1
+#define CHAR_UNUNICODE 2
+typedef struct {
+ FX_WCHAR m_Unicode;
+ FX_WCHAR m_Charcode;
+ FX_INT32 m_Flag;
+ FX_FLOAT m_FontSize;
+ FX_FLOAT m_OriginX;
+ FX_FLOAT m_OriginY;
+ CFX_FloatRect m_CharBox;
+ CPDF_TextObject* m_pTextObj;
+ CFX_AffineMatrix m_Matrix;
+} FPDF_CHAR_INFO;
+typedef CFX_ArrayTemplate<CFX_FloatRect> CFX_RectArray;
+#define FPDFTEXT_LRTB 0
+#define FPDFTEXT_RLTB 1
+#define FPDFTEXT_TBRL 2
+#define FPDFTEXT_LEFT -1
+#define FPDFTEXT_RIGHT 1
+#define FPDFTEXT_UP -2
+#define FPDFTEXT_DOWN 2
+class IPDF_ReflowedPage;
+#define FPDFTEXT_WRITINGMODE_UNKNOW 0
+#define FPDFTEXT_WRITINGMODE_LRTB 1
+#define FPDFTEXT_WRITINGMODE_RLTB 2
+#define FPDFTEXT_WRITINGMODE_TBRL 3
+class CPDFText_ParseOptions : public CFX_Object
+{
+public:
+
+ CPDFText_ParseOptions();
+ FX_BOOL m_bGetCharCodeOnly;
+ FX_BOOL m_bNormalizeObjs;
+ FX_BOOL m_bOutputHyphen;
+};
+class IPDF_TextPage : public CFX_Object
+{
+public:
+
+ virtual ~IPDF_TextPage() {}
+ static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage, CPDFText_ParseOptions ParserOptions);
+ static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage, int flags = 0);
+ static IPDF_TextPage* CreateTextPage(const CPDF_PageObjects* pObjs, int flags = 0);
+ static IPDF_TextPage* CreateReflowTextPage(IPDF_ReflowedPage* pRefPage);
+
+ virtual void NormalizeObjects(FX_BOOL bNormalize) = 0;
+
+ virtual FX_BOOL ParseTextPage() = 0;
+
+
+ virtual FX_BOOL IsParsered() const = 0;
+public:
+
+ virtual int CharIndexFromTextIndex(int TextIndex) const = 0;
+
+ virtual int TextIndexFromCharIndex(int CharIndex) const = 0;
+
+
+ virtual int CountChars() const = 0;
+
+ virtual void GetCharInfo(int index, FPDF_CHAR_INFO & info) const = 0;
+
+ virtual void GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const = 0;
+
+
+
+ virtual int GetIndexAtPos(CPDF_Point point, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const = 0;
+
+ virtual int GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const = 0;
+
+ virtual int GetOrderByDirection(int index, int direction) const = 0;
+
+ virtual CFX_WideString GetTextByRect(CFX_FloatRect rect) const = 0;
+
+ virtual void GetRectsArrayByRect(CFX_FloatRect rect, CFX_RectArray& resRectArray) const = 0;
+
+
+ virtual int CountRects(int start, int nCount) = 0;
+
+ virtual void GetRect(int rectIndex, FX_FLOAT& left, FX_FLOAT& top, FX_FLOAT& right, FX_FLOAT &bottom) const = 0;
+
+ virtual FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate) = 0;
+
+ virtual FX_BOOL GetBaselineRotate(CFX_FloatRect rect, int& Rotate) = 0;
+
+ virtual int CountBoundedSegments(FX_FLOAT left, FX_FLOAT top, FX_FLOAT right, FX_FLOAT bottom, FX_BOOL bContains = FALSE) = 0;
+
+ virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
+
+
+ virtual int GetWordBreak(int index, int direction) const = 0;
+
+ virtual CFX_WideString GetPageText(int start = 0, int nCount = -1 ) const = 0;
+};
+#define FPDFTEXT_MATCHCASE 0x00000001
+#define FPDFTEXT_MATCHWHOLEWORD 0x00000002
+#define FPDFTEXT_CONSECUTIVE 0x00000004
+class IPDF_TextPageFind : public CFX_Object
+{
+public:
+
+ virtual ~IPDF_TextPageFind() {}
+
+ static IPDF_TextPageFind* CreatePageFind(const IPDF_TextPage* pTextPage);
+public:
+
+ virtual FX_BOOL FindFirst(CFX_WideString findwhat, int flags, int startPos = 0) = 0;
+
+ virtual FX_BOOL FindNext() = 0;
+
+ virtual FX_BOOL FindPrev() = 0;
+
+ virtual void GetRectArray(CFX_RectArray& rects) const = 0;
+
+ virtual int GetCurOrder() const = 0;
+
+ virtual int GetMatchedCount() const = 0;
+};
+class IPDF_LinkExtract : public CFX_Object
+{
+public:
+
+ virtual ~IPDF_LinkExtract() {}
+
+ static IPDF_LinkExtract* CreateLinkExtract();
+
+ virtual FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage) = 0;
+public:
+
+ virtual int CountLinks() const = 0;
+
+ virtual CFX_WideString GetURL(int index) const = 0;
+
+ virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
+
+ virtual void GetRects(int index, CFX_RectArray& rects) const = 0;
+};
+#endif
diff --git a/core/include/fxcodec/fx_codec.h b/core/include/fxcodec/fx_codec.h
index bee9702b28..e215bb1d79 100644
--- a/core/include/fxcodec/fx_codec.h
+++ b/core/include/fxcodec/fx_codec.h
@@ -1,288 +1,288 @@
-// 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 _FX_CODEC_H_
-#define _FX_CODEC_H_
-#ifndef _FXCRT_EXTENSION_
-#include "../fxcrt/fx_ext.h"
-#endif
-#include "fx_codec_def.h"
-#include "fx_codec_provider.h"
-class CFX_DIBSource;
-class ICodec_ScanlineDecoder;
-class ICodec_BasicModule;
-class ICodec_FaxModule;
-class ICodec_JpegModule;
-class ICodec_JpxModule;
-class ICodec_Jbig2Module;
-class ICodec_IccModule;
-class ICodec_FlateModule;
-class ICodec_Jbig2Encoder;
-class ICodec_ScanlineDecoder;
-class CCodec_ModuleMgr : public CFX_Object
-{
-public:
-
- static CCodec_ModuleMgr* Create();
-
- void Destroy();
-
- void InitJbig2Decoder();
-
- void InitJpxDecoder();
-
-
- void InitIccDecoder();
-
- ICodec_Jbig2Encoder* CreateJbig2Encoder();
-protected:
- CCodec_ModuleMgr();
- ~CCodec_ModuleMgr();
-public:
- ICodec_BasicModule* GetBasicModule()
- {
- return m_pBasicModule;
- }
- ICodec_FaxModule* GetFaxModule()
- {
- return m_pFaxModule;
- }
- ICodec_JpegModule* GetJpegModule()
- {
- return m_pJpegModule;
- }
- ICodec_JpxModule* GetJpxModule()
- {
- return m_pJpxModule;
- }
- ICodec_Jbig2Module* GetJbig2Module()
- {
- return m_pJbig2Module;
- }
- ICodec_IccModule* GetIccModule()
- {
- return m_pIccModule;
- }
- ICodec_FlateModule* GetFlateModule()
- {
- return m_pFlateModule;
- }
-protected:
- ICodec_BasicModule* m_pBasicModule;
- ICodec_FaxModule* m_pFaxModule;
- ICodec_JpegModule* m_pJpegModule;
- ICodec_JpxModule* m_pJpxModule;
- ICodec_Jbig2Module* m_pJbig2Module;
- ICodec_IccModule* m_pIccModule;
- ICodec_FlateModule* m_pFlateModule;
-
-};
-class ICodec_BasicModule : public CFX_Object
-{
-public:
-
- virtual ~ICodec_BasicModule() {}
- virtual FX_BOOL RunLengthEncode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf,
- FX_DWORD& dest_size) = 0;
- virtual FX_BOOL A85Encode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf,
- FX_DWORD& dest_size) = 0;
- virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
- int nComps, int bpc) = 0;
-};
-class ICodec_ScanlineDecoder : public CFX_Object
-{
-public:
-
- virtual ~ICodec_ScanlineDecoder() {}
-
- virtual FX_DWORD GetSrcOffset() = 0;
-
- virtual void DownScale(int dest_width, int dest_height) = 0;
-
- virtual FX_LPBYTE GetScanline(int line) = 0;
-
- virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) = 0;
-
- virtual int GetWidth() = 0;
-
- virtual int GetHeight() = 0;
-
- virtual int CountComps() = 0;
-
- virtual int GetBPC() = 0;
-
- virtual FX_BOOL IsColorTransformed() = 0;
-
- virtual void ClearImageData() = 0;
-};
-class ICodec_FlateModule : public CFX_Object
-{
-public:
-
- virtual ~ICodec_FlateModule() {}
- virtual ICodec_ScanlineDecoder* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
- int nComps, int bpc, int predictor, int Colors, int BitsPerComponent, int Columns) = 0;
- virtual FX_DWORD FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange,
- int predictor, int Colors, int BitsPerComponent, int Columns,
- FX_DWORD estimated_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
- virtual FX_BOOL Encode(const FX_BYTE* src_buf, FX_DWORD src_size,
- int predictor, int Colors, int BitsPerComponent, int Columns,
- FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
- virtual FX_BOOL Encode(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
-};
-class ICodec_FaxModule : public CFX_Object
-{
-public:
-
- virtual ~ICodec_FaxModule() {}
-
- virtual ICodec_ScanlineDecoder* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
- int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, int Columns, int Rows) = 0;
-
-
- virtual FX_BOOL Encode(FX_LPCBYTE src_buf, int width, int height, int pitch,
- FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
-};
-class ICodec_JpegModule : public CFX_Object
-{
-public:
-
- virtual ~ICodec_JpegModule() {}
-
- virtual void SetPovider(IFX_JpegProvider* pJP) = 0;
-
- virtual ICodec_ScanlineDecoder* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size,
- int width, int height, int nComps, FX_BOOL ColorTransform) = 0;
-
- virtual FX_BOOL LoadInfo(FX_LPCBYTE src_buf, FX_DWORD src_size, int& width, int& height,
- int& num_components, int& bits_per_components, FX_BOOL& color_transform,
- FX_LPBYTE* icc_buf_ptr = NULL, FX_DWORD* icc_length = NULL) = 0;
-
- virtual FX_BOOL Encode(const class CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_STRSIZE& dest_size, int quality = 75,
- FX_LPCBYTE icc_buf = NULL, FX_DWORD icc_length = 0) = 0;
-
- virtual void* Start() = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size) = 0;
-
- virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps) = 0;
-
-
- virtual int StartScanline(void* pContext, int down_scale) = 0;
-
-
- virtual FX_BOOL ReadScanline(void* pContext, FX_LPBYTE dest_buf) = 0;
-
-
- virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr = NULL) = 0;
-};
-class ICodec_JpxModule : public CFX_Object
-{
-public:
-
- virtual ~ICodec_JpxModule() {}
-
- virtual FX_LPVOID CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_BOOL useColorSpace = FALSE) = 0;
-
- virtual void GetImageInfo(FX_LPVOID ctx, FX_DWORD& width, FX_DWORD& height,
- FX_DWORD& codestream_nComps, FX_DWORD& output_nComps) = 0;
-
- virtual FX_BOOL Decode(FX_LPVOID ctx, FX_LPBYTE dest_data, int pitch,
- FX_BOOL bTranslateColor, FX_LPBYTE offsets) = 0;
-
- virtual void DestroyDecoder(FX_LPVOID ctx) = 0;
-};
-class ICodec_Jbig2Module : public CFX_Object
-{
-public:
-
- virtual ~ICodec_Jbig2Module() {}
-
- virtual FX_BOOL Decode(FX_DWORD width, FX_DWORD height, FX_LPCBYTE src_buf, FX_DWORD src_size,
- FX_LPCBYTE global_data, FX_DWORD global_size, FX_LPBYTE dest_buf, FX_DWORD dest_pitch) = 0;
-
- virtual FX_BOOL Decode(IFX_FileRead* file_ptr, FX_DWORD& width, FX_DWORD& height,
- FX_DWORD& pitch, FX_LPBYTE& dest_buf) = 0;
- virtual void* CreateJbig2Context() = 0;
-
- virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, FX_DWORD width, FX_DWORD height, FX_LPCBYTE src_buf, FX_DWORD src_size,
- FX_LPCBYTE global_data, FX_DWORD global_size, FX_LPBYTE dest_buf, FX_DWORD dest_pitch, IFX_Pause* pPause) = 0;
-
- virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, IFX_FileRead* file_ptr,
- FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf, IFX_Pause* pPause) = 0;
- virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content, IFX_Pause* pPause) = 0;
- virtual void DestroyJbig2Context(void* pJbig2Content) = 0;
-};
-class ICodec_Jbig2Encoder : public CFX_Object
-{
-public:
-
- virtual ~ICodec_Jbig2Encoder() {}
-};
-class ICodec_IccModule : public CFX_Object
-{
-public:
- typedef enum {
- IccCS_Unknown = 0,
- IccCS_XYZ,
- IccCS_Lab,
- IccCS_Luv,
- IccCS_YCbCr,
- IccCS_Yxy,
- IccCS_Hsv,
- IccCS_Hls,
- IccCS_Gray,
- IccCS_Rgb,
- IccCS_Cmyk,
- IccCS_Cmy
- } IccCS;
- typedef struct _IccParam {
- FX_DWORD Version;
- IccCS ColorSpace;
- FX_DWORD dwProfileType;
- FX_DWORD dwFormat;
- FX_LPBYTE pProfileData;
- FX_DWORD dwProfileSize;
- double Gamma;
- } IccParam;
-
- virtual ~ICodec_IccModule() {}
-
- virtual IccCS GetProfileCS(FX_LPCBYTE pProfileData, unsigned int dwProfileSize) = 0;
-
- virtual IccCS GetProfileCS(IFX_FileRead* pFile) = 0;
-
- virtual FX_LPVOID CreateTransform(ICodec_IccModule::IccParam* pInputParam,
- ICodec_IccModule::IccParam* pOutputParam,
- ICodec_IccModule::IccParam* pProofParam = NULL,
- FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL,
- FX_DWORD dwFlag = Icc_FLAGS_DEFAULT,
- FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
- FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING
- ) = 0;
-
-
- virtual FX_LPVOID CreateTransform_sRGB(FX_LPCBYTE pProfileData, unsigned int dwProfileSize, int nComponents, int intent = 0,
- FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT) = 0;
-
- virtual FX_LPVOID CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, unsigned int dwSrcProfileSize, int nSrcComponents,
- FX_LPCBYTE pDstProfileData, unsigned int dwDstProfileSize, int intent = 0,
- FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT,
- FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT
- ) = 0;
-
- virtual void DestroyTransform(FX_LPVOID pTransform) = 0;
-
- virtual void Translate(FX_LPVOID pTransform, FX_FLOAT* pSrcValues, FX_FLOAT* pDestValues) = 0;
-
- virtual void TranslateScanline(FX_LPVOID pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, int pixels) = 0;
-};
-void AdobeCMYK_to_sRGB(FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B);
-void AdobeCMYK_to_sRGB1(FX_BYTE c, FX_BYTE m, FX_BYTE y, FX_BYTE k, FX_BYTE& R, FX_BYTE& G, FX_BYTE& B);
-FX_BOOL MD5ComputeID(FX_LPCVOID buf, FX_DWORD dwSize, FX_BYTE ID[16]);
-#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 _FX_CODEC_H_
+#define _FX_CODEC_H_
+#ifndef _FXCRT_EXTENSION_
+#include "../fxcrt/fx_ext.h"
+#endif
+#include "fx_codec_def.h"
+#include "fx_codec_provider.h"
+class CFX_DIBSource;
+class ICodec_ScanlineDecoder;
+class ICodec_BasicModule;
+class ICodec_FaxModule;
+class ICodec_JpegModule;
+class ICodec_JpxModule;
+class ICodec_Jbig2Module;
+class ICodec_IccModule;
+class ICodec_FlateModule;
+class ICodec_Jbig2Encoder;
+class ICodec_ScanlineDecoder;
+class CCodec_ModuleMgr : public CFX_Object
+{
+public:
+
+ static CCodec_ModuleMgr* Create();
+
+ void Destroy();
+
+ void InitJbig2Decoder();
+
+ void InitJpxDecoder();
+
+
+ void InitIccDecoder();
+
+ ICodec_Jbig2Encoder* CreateJbig2Encoder();
+protected:
+ CCodec_ModuleMgr();
+ ~CCodec_ModuleMgr();
+public:
+ ICodec_BasicModule* GetBasicModule()
+ {
+ return m_pBasicModule;
+ }
+ ICodec_FaxModule* GetFaxModule()
+ {
+ return m_pFaxModule;
+ }
+ ICodec_JpegModule* GetJpegModule()
+ {
+ return m_pJpegModule;
+ }
+ ICodec_JpxModule* GetJpxModule()
+ {
+ return m_pJpxModule;
+ }
+ ICodec_Jbig2Module* GetJbig2Module()
+ {
+ return m_pJbig2Module;
+ }
+ ICodec_IccModule* GetIccModule()
+ {
+ return m_pIccModule;
+ }
+ ICodec_FlateModule* GetFlateModule()
+ {
+ return m_pFlateModule;
+ }
+protected:
+ ICodec_BasicModule* m_pBasicModule;
+ ICodec_FaxModule* m_pFaxModule;
+ ICodec_JpegModule* m_pJpegModule;
+ ICodec_JpxModule* m_pJpxModule;
+ ICodec_Jbig2Module* m_pJbig2Module;
+ ICodec_IccModule* m_pIccModule;
+ ICodec_FlateModule* m_pFlateModule;
+
+};
+class ICodec_BasicModule : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_BasicModule() {}
+ virtual FX_BOOL RunLengthEncode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf,
+ FX_DWORD& dest_size) = 0;
+ virtual FX_BOOL A85Encode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf,
+ FX_DWORD& dest_size) = 0;
+ virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
+ int nComps, int bpc) = 0;
+};
+class ICodec_ScanlineDecoder : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_ScanlineDecoder() {}
+
+ virtual FX_DWORD GetSrcOffset() = 0;
+
+ virtual void DownScale(int dest_width, int dest_height) = 0;
+
+ virtual FX_LPBYTE GetScanline(int line) = 0;
+
+ virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) = 0;
+
+ virtual int GetWidth() = 0;
+
+ virtual int GetHeight() = 0;
+
+ virtual int CountComps() = 0;
+
+ virtual int GetBPC() = 0;
+
+ virtual FX_BOOL IsColorTransformed() = 0;
+
+ virtual void ClearImageData() = 0;
+};
+class ICodec_FlateModule : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_FlateModule() {}
+ virtual ICodec_ScanlineDecoder* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
+ int nComps, int bpc, int predictor, int Colors, int BitsPerComponent, int Columns) = 0;
+ virtual FX_DWORD FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_buf, FX_DWORD src_size, FX_BOOL bEarlyChange,
+ int predictor, int Colors, int BitsPerComponent, int Columns,
+ FX_DWORD estimated_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
+ virtual FX_BOOL Encode(const FX_BYTE* src_buf, FX_DWORD src_size,
+ int predictor, int Colors, int BitsPerComponent, int Columns,
+ FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
+ virtual FX_BOOL Encode(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
+};
+class ICodec_FaxModule : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_FaxModule() {}
+
+ virtual ICodec_ScanlineDecoder* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
+ int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, int Columns, int Rows) = 0;
+
+
+ virtual FX_BOOL Encode(FX_LPCBYTE src_buf, int width, int height, int pitch,
+ FX_LPBYTE& dest_buf, FX_DWORD& dest_size) = 0;
+};
+class ICodec_JpegModule : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_JpegModule() {}
+
+ virtual void SetPovider(IFX_JpegProvider* pJP) = 0;
+
+ virtual ICodec_ScanlineDecoder* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size,
+ int width, int height, int nComps, FX_BOOL ColorTransform) = 0;
+
+ virtual FX_BOOL LoadInfo(FX_LPCBYTE src_buf, FX_DWORD src_size, int& width, int& height,
+ int& num_components, int& bits_per_components, FX_BOOL& color_transform,
+ FX_LPBYTE* icc_buf_ptr = NULL, FX_DWORD* icc_length = NULL) = 0;
+
+ virtual FX_BOOL Encode(const class CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_STRSIZE& dest_size, int quality = 75,
+ FX_LPCBYTE icc_buf = NULL, FX_DWORD icc_length = 0) = 0;
+
+ virtual void* Start() = 0;
+
+ virtual void Finish(void* pContext) = 0;
+
+ virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size) = 0;
+
+ virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps) = 0;
+
+
+ virtual int StartScanline(void* pContext, int down_scale) = 0;
+
+
+ virtual FX_BOOL ReadScanline(void* pContext, FX_LPBYTE dest_buf) = 0;
+
+
+ virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr = NULL) = 0;
+};
+class ICodec_JpxModule : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_JpxModule() {}
+
+ virtual FX_LPVOID CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_BOOL useColorSpace = FALSE) = 0;
+
+ virtual void GetImageInfo(FX_LPVOID ctx, FX_DWORD& width, FX_DWORD& height,
+ FX_DWORD& codestream_nComps, FX_DWORD& output_nComps) = 0;
+
+ virtual FX_BOOL Decode(FX_LPVOID ctx, FX_LPBYTE dest_data, int pitch,
+ FX_BOOL bTranslateColor, FX_LPBYTE offsets) = 0;
+
+ virtual void DestroyDecoder(FX_LPVOID ctx) = 0;
+};
+class ICodec_Jbig2Module : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_Jbig2Module() {}
+
+ virtual FX_BOOL Decode(FX_DWORD width, FX_DWORD height, FX_LPCBYTE src_buf, FX_DWORD src_size,
+ FX_LPCBYTE global_data, FX_DWORD global_size, FX_LPBYTE dest_buf, FX_DWORD dest_pitch) = 0;
+
+ virtual FX_BOOL Decode(IFX_FileRead* file_ptr, FX_DWORD& width, FX_DWORD& height,
+ FX_DWORD& pitch, FX_LPBYTE& dest_buf) = 0;
+ virtual void* CreateJbig2Context() = 0;
+
+ virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, FX_DWORD width, FX_DWORD height, FX_LPCBYTE src_buf, FX_DWORD src_size,
+ FX_LPCBYTE global_data, FX_DWORD global_size, FX_LPBYTE dest_buf, FX_DWORD dest_pitch, IFX_Pause* pPause) = 0;
+
+ virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, IFX_FileRead* file_ptr,
+ FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf, IFX_Pause* pPause) = 0;
+ virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content, IFX_Pause* pPause) = 0;
+ virtual void DestroyJbig2Context(void* pJbig2Content) = 0;
+};
+class ICodec_Jbig2Encoder : public CFX_Object
+{
+public:
+
+ virtual ~ICodec_Jbig2Encoder() {}
+};
+class ICodec_IccModule : public CFX_Object
+{
+public:
+ typedef enum {
+ IccCS_Unknown = 0,
+ IccCS_XYZ,
+ IccCS_Lab,
+ IccCS_Luv,
+ IccCS_YCbCr,
+ IccCS_Yxy,
+ IccCS_Hsv,
+ IccCS_Hls,
+ IccCS_Gray,
+ IccCS_Rgb,
+ IccCS_Cmyk,
+ IccCS_Cmy
+ } IccCS;
+ typedef struct _IccParam {
+ FX_DWORD Version;
+ IccCS ColorSpace;
+ FX_DWORD dwProfileType;
+ FX_DWORD dwFormat;
+ FX_LPBYTE pProfileData;
+ FX_DWORD dwProfileSize;
+ double Gamma;
+ } IccParam;
+
+ virtual ~ICodec_IccModule() {}
+
+ virtual IccCS GetProfileCS(FX_LPCBYTE pProfileData, unsigned int dwProfileSize) = 0;
+
+ virtual IccCS GetProfileCS(IFX_FileRead* pFile) = 0;
+
+ virtual FX_LPVOID CreateTransform(ICodec_IccModule::IccParam* pInputParam,
+ ICodec_IccModule::IccParam* pOutputParam,
+ ICodec_IccModule::IccParam* pProofParam = NULL,
+ FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL,
+ FX_DWORD dwFlag = Icc_FLAGS_DEFAULT,
+ FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
+ FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING
+ ) = 0;
+
+
+ virtual FX_LPVOID CreateTransform_sRGB(FX_LPCBYTE pProfileData, unsigned int dwProfileSize, int nComponents, int intent = 0,
+ FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT) = 0;
+
+ virtual FX_LPVOID CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, unsigned int dwSrcProfileSize, int nSrcComponents,
+ FX_LPCBYTE pDstProfileData, unsigned int dwDstProfileSize, int intent = 0,
+ FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT,
+ FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT
+ ) = 0;
+
+ virtual void DestroyTransform(FX_LPVOID pTransform) = 0;
+
+ virtual void Translate(FX_LPVOID pTransform, FX_FLOAT* pSrcValues, FX_FLOAT* pDestValues) = 0;
+
+ virtual void TranslateScanline(FX_LPVOID pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, int pixels) = 0;
+};
+void AdobeCMYK_to_sRGB(FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B);
+void AdobeCMYK_to_sRGB1(FX_BYTE c, FX_BYTE m, FX_BYTE y, FX_BYTE k, FX_BYTE& R, FX_BYTE& G, FX_BYTE& B);
+FX_BOOL MD5ComputeID(FX_LPCVOID buf, FX_DWORD dwSize, FX_BYTE ID[16]);
+#endif
diff --git a/core/include/fxcodec/fx_codec_def.h b/core/include/fxcodec/fx_codec_def.h
index 72b10bd012..0d08da699b 100644
--- a/core/include/fxcodec/fx_codec_def.h
+++ b/core/include/fxcodec/fx_codec_def.h
@@ -1,71 +1,71 @@
-// 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 _FX_CODEC_DEF_H_
-#define _FX_CODEC_DEF_H_
-enum FXCODEC_STATUS {
- FXCODEC_STATUS_ERROR = -1,
- FXCODEC_STATUS_FRAME_READY,
- FXCODEC_STATUS_FRAME_TOBECONTINUE,
- FXCODEC_STATUS_DECODE_READY,
- FXCODEC_STATUS_DECODE_TOBECONTINUE,
- FXCODEC_STATUS_DECODE_FINISH,
- FXCODEC_STATUS_ERR_MEMORY,
- FXCODEC_STATUS_ERR_READ,
- FXCODEC_STATUS_ERR_FLUSH,
- FXCODEC_STATUS_ERR_FORMAT,
- FXCODEC_STATUS_ERR_PARAMS
-};
-#define JP2_SPACE_INVALID -1
-#define JPX_SPACE_INVALID -1
-#define JP2_SPACE_bilevel1 0
-#define JP2_SPACE_YCbCr1 1
-#define JP2_SPACE_YCbCr2 3
-#define JP2_SPACE_YCbCr3 4
-#define JP2_SPACE_PhotoYCC 9
-#define JP2_SPACE_CMY 11
-#define JP2_SPACE_CMYK 12
-#define JP2_SPACE_YCCK 13
-#define JP2_SPACE_CIELab 14
-#define JP2_SPACE_bilevel2 15
-#define JP2_SPACE_sRGB 16
-#define JP2_SPACE_sLUM 17
-#define JP2_SPACE_sYCC 18
-#define JP2_SPACE_CIEJab 19
-#define JP2_SPACE_esRGB 20
-#define JP2_SPACE_ROMMRGB 21
-#define JP2_SPACE_YPbPr60 22
-#define JP2_SPACE_YPbPr50 23
-#define JP2_SPACE_esYCC 24
-#define JP2_SPACE_iccLUM 100
-#define JP2_SPACE_iccRGB 101
-#define Icc_INTENT_PERCEPTUAL 0
-#define Icc_INTENT_RELATIVE_COLORIMETRIC 1
-#define Icc_INTENT_SATURATION 2
-#define Icc_INTENT_ABSOLUTE_COLORIMETRIC 3
-#define Icc_FORMAT_DEFAULT 0
-#define Icc_FORMAT_SWAP (1<<10)
-#define Icc_FLAGS_DEFAULT 0x0000
-#define Icc_FLAGS_BLACKPOINTCOMPENSATION 0x2000
-#define Icc_FLAGS_NOWHITEONWHITEFIXUP 0x0004
-#define Icc_FLAGS_HIGHRESPRECALC 0x0400
-#define Icc_FLAGS_LOWRESPRECALC 0x0800
-#define Icc_FLAGS_GAMUTCHECK 0x1000
-#define Icc_FLAGS_SOFTPROOFING 0x4000
-#define Icc_PARAMTYPE_NONE 0
-#define Icc_PARAMTYPE_BUFFER 1
-#define Icc_PARAMTYPE_PARAM 2
-#define EXIFTAG_USHORT_RESUNIT 296
-#define EXIFTAG_FLOAT_DPIX 282
-#define EXIFTAG_FLOAT_DPIY 283
-#define EXIFTAG_USHORT_ORIENTATION 274
-#define EXIFTAG_STRING_MANUFACTURER 271
-#define EXIFTAG_STRING_MODULE 272
-#define EXIFTAG_STRING_SOFTWARE 305
-#define EXIFTAG_STRING_IAMGEDESCRIPTION 270
-#define EXIFTAG_STRING_DATETIME 306
-#define EXIFTAG_STRING_COPYRIGHT 33432
-#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 _FX_CODEC_DEF_H_
+#define _FX_CODEC_DEF_H_
+enum FXCODEC_STATUS {
+ FXCODEC_STATUS_ERROR = -1,
+ FXCODEC_STATUS_FRAME_READY,
+ FXCODEC_STATUS_FRAME_TOBECONTINUE,
+ FXCODEC_STATUS_DECODE_READY,
+ FXCODEC_STATUS_DECODE_TOBECONTINUE,
+ FXCODEC_STATUS_DECODE_FINISH,
+ FXCODEC_STATUS_ERR_MEMORY,
+ FXCODEC_STATUS_ERR_READ,
+ FXCODEC_STATUS_ERR_FLUSH,
+ FXCODEC_STATUS_ERR_FORMAT,
+ FXCODEC_STATUS_ERR_PARAMS
+};
+#define JP2_SPACE_INVALID -1
+#define JPX_SPACE_INVALID -1
+#define JP2_SPACE_bilevel1 0
+#define JP2_SPACE_YCbCr1 1
+#define JP2_SPACE_YCbCr2 3
+#define JP2_SPACE_YCbCr3 4
+#define JP2_SPACE_PhotoYCC 9
+#define JP2_SPACE_CMY 11
+#define JP2_SPACE_CMYK 12
+#define JP2_SPACE_YCCK 13
+#define JP2_SPACE_CIELab 14
+#define JP2_SPACE_bilevel2 15
+#define JP2_SPACE_sRGB 16
+#define JP2_SPACE_sLUM 17
+#define JP2_SPACE_sYCC 18
+#define JP2_SPACE_CIEJab 19
+#define JP2_SPACE_esRGB 20
+#define JP2_SPACE_ROMMRGB 21
+#define JP2_SPACE_YPbPr60 22
+#define JP2_SPACE_YPbPr50 23
+#define JP2_SPACE_esYCC 24
+#define JP2_SPACE_iccLUM 100
+#define JP2_SPACE_iccRGB 101
+#define Icc_INTENT_PERCEPTUAL 0
+#define Icc_INTENT_RELATIVE_COLORIMETRIC 1
+#define Icc_INTENT_SATURATION 2
+#define Icc_INTENT_ABSOLUTE_COLORIMETRIC 3
+#define Icc_FORMAT_DEFAULT 0
+#define Icc_FORMAT_SWAP (1<<10)
+#define Icc_FLAGS_DEFAULT 0x0000
+#define Icc_FLAGS_BLACKPOINTCOMPENSATION 0x2000
+#define Icc_FLAGS_NOWHITEONWHITEFIXUP 0x0004
+#define Icc_FLAGS_HIGHRESPRECALC 0x0400
+#define Icc_FLAGS_LOWRESPRECALC 0x0800
+#define Icc_FLAGS_GAMUTCHECK 0x1000
+#define Icc_FLAGS_SOFTPROOFING 0x4000
+#define Icc_PARAMTYPE_NONE 0
+#define Icc_PARAMTYPE_BUFFER 1
+#define Icc_PARAMTYPE_PARAM 2
+#define EXIFTAG_USHORT_RESUNIT 296
+#define EXIFTAG_FLOAT_DPIX 282
+#define EXIFTAG_FLOAT_DPIY 283
+#define EXIFTAG_USHORT_ORIENTATION 274
+#define EXIFTAG_STRING_MANUFACTURER 271
+#define EXIFTAG_STRING_MODULE 272
+#define EXIFTAG_STRING_SOFTWARE 305
+#define EXIFTAG_STRING_IAMGEDESCRIPTION 270
+#define EXIFTAG_STRING_DATETIME 306
+#define EXIFTAG_STRING_COPYRIGHT 33432
+#endif
diff --git a/core/include/fxcodec/fx_codec_provider.h b/core/include/fxcodec/fx_codec_provider.h
index 4ef61d8552..a3ef396a27 100644
--- a/core/include/fxcodec/fx_codec_provider.h
+++ b/core/include/fxcodec/fx_codec_provider.h
@@ -1,53 +1,53 @@
-// 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 _FX_CODEC_PROVIDER_H_
-#define _FX_CODEC_PROVIDER_H_
-class IFX_JpegProvider
-{
-public:
-
- virtual void Release() = 0;
-
- virtual void* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, int nComps, FX_BOOL ColorTransform) = 0;
-
-
- virtual void DestroyDecoder(void* pDecoder) = 0;
-
- virtual void DownScale(void* pDecoder, int dest_width, int dest_height) = 0;
-
- virtual FX_BOOL Rewind(void* pDecoder) = 0;
-
- virtual FX_LPBYTE GetNextLine(void* pDecoder) = 0;
-
- virtual FX_DWORD GetSrcOffset(void* pDecoder) = 0;
-
-
- virtual FX_BOOL LoadInfo(FX_LPCBYTE src_buf, FX_DWORD src_size, int& width, int& height,
- int& num_components, int& bits_per_components, FX_BOOL& color_transform,
- FX_LPBYTE* icc_buf_ptr = NULL, FX_DWORD* icc_length = NULL) = 0;
-
- virtual FX_BOOL Encode(const class CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_STRSIZE& dest_size, int quality = 75,
- FX_LPCBYTE icc_buf = NULL, FX_DWORD icc_length = 0) = 0;
-
- virtual void* Start() = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size) = 0;
-
- virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps) = 0;
-
-
- virtual int StartScanline(void* pContext, int down_scale) = 0;
-
-
- virtual FX_BOOL ReadScanline(void* pContext, FX_LPBYTE dest_buf) = 0;
-
-
- virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr = NULL) = 0;
-};
-#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 _FX_CODEC_PROVIDER_H_
+#define _FX_CODEC_PROVIDER_H_
+class IFX_JpegProvider
+{
+public:
+
+ virtual void Release() = 0;
+
+ virtual void* CreateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, int nComps, FX_BOOL ColorTransform) = 0;
+
+
+ virtual void DestroyDecoder(void* pDecoder) = 0;
+
+ virtual void DownScale(void* pDecoder, int dest_width, int dest_height) = 0;
+
+ virtual FX_BOOL Rewind(void* pDecoder) = 0;
+
+ virtual FX_LPBYTE GetNextLine(void* pDecoder) = 0;
+
+ virtual FX_DWORD GetSrcOffset(void* pDecoder) = 0;
+
+
+ virtual FX_BOOL LoadInfo(FX_LPCBYTE src_buf, FX_DWORD src_size, int& width, int& height,
+ int& num_components, int& bits_per_components, FX_BOOL& color_transform,
+ FX_LPBYTE* icc_buf_ptr = NULL, FX_DWORD* icc_length = NULL) = 0;
+
+ virtual FX_BOOL Encode(const class CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_STRSIZE& dest_size, int quality = 75,
+ FX_LPCBYTE icc_buf = NULL, FX_DWORD icc_length = 0) = 0;
+
+ virtual void* Start() = 0;
+
+ virtual void Finish(void* pContext) = 0;
+
+ virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size) = 0;
+
+ virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps) = 0;
+
+
+ virtual int StartScanline(void* pContext, int down_scale) = 0;
+
+
+ virtual FX_BOOL ReadScanline(void* pContext, FX_LPBYTE dest_buf) = 0;
+
+
+ virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr = NULL) = 0;
+};
+#endif
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 29bc221e5b..378d6c30a8 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -1,1642 +1,1642 @@
-// 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 _FX_BASIC_H_
-#define _FX_BASIC_H_
-#ifndef _FX_SYSTEM_H_
-#include "fx_system.h"
-#endif
-#ifndef _FX_MEMORY_H_
-#include "fx_memory.h"
-#endif
-#ifndef _FX_STRING_H_
-#include "fx_string.h"
-#endif
-#ifndef _FX_STREAM_H_
-#include "fx_stream.h"
-#endif
-class CFX_BinaryBuf : public CFX_Object
-{
-public:
-
- CFX_BinaryBuf(IFX_Allocator* pAllocator = NULL);
-
- CFX_BinaryBuf(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
-
- ~CFX_BinaryBuf();
-
- void Clear();
-
- void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0);
-
- void AppendBlock(const void* pBuf, FX_STRSIZE size);
-
- void AppendFill(FX_BYTE byte, FX_STRSIZE count);
-
- void AppendString(FX_BSTR str)
- {
- AppendBlock(str.GetPtr(), str.GetLength());
- }
-
- inline void AppendByte(FX_BYTE byte)
- {
- if (m_AllocSize <= m_DataSize) {
- ExpandBuf(1);
- }
- m_pBuffer[m_DataSize++] = byte;
- }
-
- void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size);
-
- void AttachData(void* pBuf, FX_STRSIZE size);
-
- void CopyData(const void* pBuf, FX_STRSIZE size);
-
- void TakeOver(CFX_BinaryBuf& other);
-
- void Delete(int start_index, int count);
-
- FX_LPBYTE GetBuffer() const
- {
- return m_pBuffer;
- }
-
- FX_STRSIZE GetSize() const
- {
- return m_DataSize;
- }
-
- CFX_ByteStringC GetByteString() const;
- void GetByteStringL(CFX_ByteStringL &str) const;
-
- void DetachBuffer();
-
- IFX_Allocator* m_pAllocator;
-protected:
-
- FX_STRSIZE m_AllocStep;
-
- FX_LPBYTE m_pBuffer;
-
- FX_STRSIZE m_DataSize;
-
- FX_STRSIZE m_AllocSize;
-
- void ExpandBuf(FX_STRSIZE size);
-};
-class CFX_ByteTextBuf : public CFX_BinaryBuf
-{
-public:
-
- CFX_ByteTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
-
- void operator = (FX_BSTR str);
-
- void AppendChar(int ch)
- {
- AppendByte((FX_BYTE)ch);
- }
-
- CFX_ByteTextBuf& operator << (int i);
-
- CFX_ByteTextBuf& operator << (FX_DWORD i);
-
- CFX_ByteTextBuf& operator << (double f);
-
- CFX_ByteTextBuf& operator << (FX_BSTR lpsz);
-
- CFX_ByteTextBuf& operator << (const CFX_ByteTextBuf& buf);
-
- FX_STRSIZE GetLength() const
- {
- return m_DataSize;
- }
-};
-class CFX_WideTextBuf : public CFX_BinaryBuf
-{
-public:
-
- CFX_WideTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
-
- void operator = (FX_LPCWSTR lpsz);
-
- void operator = (FX_WSTR str);
-
- void AppendChar(FX_WCHAR wch);
-
- CFX_WideTextBuf& operator << (int i);
-
- CFX_WideTextBuf& operator << (double f);
-
- CFX_WideTextBuf& operator << (FX_LPCWSTR lpsz);
-
- CFX_WideTextBuf& operator << (FX_WSTR str);
- CFX_WideTextBuf& operator << (const CFX_WideString &str);
-
- CFX_WideTextBuf& operator << (const CFX_WideTextBuf& buf);
-
- FX_STRSIZE GetLength() const
- {
- return m_DataSize / sizeof(FX_WCHAR);
- }
-
- FX_LPWSTR GetBuffer() const
- {
- return (FX_LPWSTR)m_pBuffer;
- }
-
- void Delete(int start_index, int count)
- {
- CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_WCHAR));
- }
-
- CFX_WideStringC GetWideString() const;
- void GetWideStringL(CFX_WideStringL& wideText) const;
-};
-class CFX_ArchiveSaver : public CFX_Object
-{
-public:
-
- CFX_ArchiveSaver(IFX_Allocator* pAllocator = NULL) : m_SavingBuf(pAllocator), m_pStream(NULL) {}
-
- CFX_ArchiveSaver& operator << (FX_BYTE i);
-
- CFX_ArchiveSaver& operator << (int i);
-
- CFX_ArchiveSaver& operator << (FX_DWORD i);
-
- CFX_ArchiveSaver& operator << (FX_FLOAT i);
-
- CFX_ArchiveSaver& operator << (double i);
-
- CFX_ArchiveSaver& operator << (FX_BSTR bstr);
-
- CFX_ArchiveSaver& operator << (FX_LPCWSTR bstr);
-
- CFX_ArchiveSaver& operator << (const CFX_WideString& wstr);
-
- void Write(const void* pData, FX_STRSIZE dwSize);
-
- FX_INTPTR GetLength()
- {
- return m_SavingBuf.GetSize();
- }
-
- FX_LPCBYTE GetBuffer()
- {
- return m_SavingBuf.GetBuffer();
- }
-
- void SetStream(IFX_FileStream* pStream)
- {
- m_pStream = pStream;
- }
-protected:
-
- CFX_BinaryBuf m_SavingBuf;
-
- IFX_FileStream* m_pStream;
-};
-class CFX_ArchiveLoader : public CFX_Object
-{
-public:
-
- CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize);
-
- CFX_ArchiveLoader& operator >> (FX_BYTE& i);
-
- CFX_ArchiveLoader& operator >> (int& i);
-
- CFX_ArchiveLoader& operator >> (FX_DWORD& i);
-
- CFX_ArchiveLoader& operator >> (FX_FLOAT& i);
-
- CFX_ArchiveLoader& operator >> (double& i);
-
- CFX_ArchiveLoader& operator >> (CFX_ByteString& bstr);
-
- CFX_ArchiveLoader& operator >> (CFX_WideString& wstr);
-
- FX_BOOL IsEOF();
-
- FX_BOOL Read(void* pBuf, FX_DWORD dwSize);
-protected:
-
- FX_DWORD m_LoadingPos;
-
- FX_LPCBYTE m_pLoadingBuf;
-
- FX_DWORD m_LoadingSize;
-};
-class IFX_BufferArchive
-{
-public:
-
- IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
-
-
- virtual void Clear();
-
-
- FX_BOOL Flush();
-
-
- FX_INT32 AppendBlock(const void* pBuf, size_t size);
-
- FX_INT32 AppendByte(FX_BYTE byte);
-
- FX_INT32 AppendDWord(FX_DWORD i);
-
-
- FX_INT32 AppendString(FX_BSTR lpsz);
-
-protected:
-
- virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
-
-
- IFX_Allocator* m_pAllocator;
-
- FX_STRSIZE m_BufSize;
-
- FX_LPBYTE m_pBuffer;
-
- FX_STRSIZE m_Length;
-};
-class CFX_FileBufferArchive : public IFX_BufferArchive, public CFX_Object
-{
-public:
- CFX_FileBufferArchive(FX_STRSIZE size = 32768, IFX_Allocator* pAllocator = NULL);
- ~CFX_FileBufferArchive();
- virtual void Clear();
-
- FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = FALSE);
-
- FX_BOOL AttachFile(FX_LPCWSTR filename);
-
- FX_BOOL AttachFile(FX_LPCSTR filename);
-private:
-
- virtual FX_BOOL DoWork(const void* pBuf, size_t size);
-
- IFX_StreamWrite *m_pFile;
-
- FX_BOOL m_bTakeover;
-};
-struct CFX_CharMap {
-
- static CFX_CharMap* GetDefaultMapper(FX_INT32 codepage = 0);
-
-
- CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteString& bstr);
-
- CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideString& wstr);
-
- FX_INT32 (*m_GetCodePage)();
-};
-class CFX_UTF8Decoder
-{
-public:
-
- CFX_UTF8Decoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator)
- {
- m_PendingBytes = 0;
- }
-
- void Clear();
-
- void Input(FX_BYTE byte);
-
- void AppendChar(FX_DWORD ch);
-
- void ClearStatus()
- {
- m_PendingBytes = 0;
- }
-
- CFX_WideStringC GetResult() const
- {
- return m_Buffer.GetWideString();
- }
- void GetResult(CFX_WideStringL &result) const
- {
- m_Buffer.GetWideStringL(result);
- }
-protected:
-
- int m_PendingBytes;
-
- FX_DWORD m_PendingChar;
-
- CFX_WideTextBuf m_Buffer;
-};
-class CFX_UTF8Encoder
-{
-public:
-
- CFX_UTF8Encoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator)
- {
- m_UTF16First = 0;
- }
-
- void Input(FX_WCHAR unicode);
-
- void AppendStr(FX_BSTR str)
- {
- m_UTF16First = 0;
- m_Buffer << str;
- }
-
- CFX_ByteStringC GetResult() const
- {
- return m_Buffer.GetByteString();
- }
- void GetResult(CFX_ByteStringL &result) const
- {
- m_Buffer.GetByteStringL(result);
- }
-protected:
-
- CFX_ByteTextBuf m_Buffer;
-
- FX_DWORD m_UTF16First;
-};
-CFX_ByteString FX_UrlEncode(const CFX_WideString& wsUrl);
-CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl);
-CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI);
-CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI);
-class CFX_BasicArray : public CFX_Object
-{
-public:
-
- IFX_Allocator* m_pAllocator;
-protected:
-
- CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator = NULL);
-
- ~CFX_BasicArray();
-
- FX_BOOL SetSize(int nNewSize, int nGrowBy);
-
- FX_BOOL Append(const CFX_BasicArray& src);
-
- FX_BOOL Copy(const CFX_BasicArray& src);
-
- FX_LPBYTE InsertSpaceAt(int nIndex, int nCount);
-
- FX_BOOL RemoveAt(int nIndex, int nCount);
-
- FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
-
- const void* GetDataPtr(int index) const;
-protected:
-
- FX_LPBYTE m_pData;
-
- int m_nSize;
-
- int m_nMaxSize;
-
- int m_nGrowBy;
-
- int m_nUnitSize;
-};
-template<class TYPE>
-class CFX_ArrayTemplate : public CFX_BasicArray
-{
-public:
-
- CFX_ArrayTemplate(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(TYPE), pAllocator) {}
-
- int GetSize() const
- {
- return m_nSize;
- }
-
- int GetUpperBound() const
- {
- return m_nSize - 1;
- }
-
- FX_BOOL SetSize(int nNewSize, int nGrowBy = -1)
- {
- return CFX_BasicArray::SetSize(nNewSize, nGrowBy);
- }
-
- void RemoveAll()
- {
- SetSize(0, -1);
- }
-
- const TYPE GetAt(int nIndex) const
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- return (const TYPE&)(*(volatile const TYPE*)NULL);
- }
- return ((const TYPE*)m_pData)[nIndex];
- }
-
- FX_BOOL SetAt(int nIndex, TYPE newElement)
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- return FALSE;
- }
- ((TYPE*)m_pData)[nIndex] = newElement;
- return TRUE;
- }
-
- TYPE& ElementAt(int nIndex)
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- return *(TYPE*)NULL;
- }
- return ((TYPE*)m_pData)[nIndex];
- }
-
- const TYPE* GetData() const
- {
- return (const TYPE*)m_pData;
- }
-
- TYPE* GetData()
- {
- return (TYPE*)m_pData;
- }
-
- FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
- {
- if (nIndex < 0) {
- return FALSE;
- }
- if (nIndex >= m_nSize)
- if (!SetSize(nIndex + 1, -1)) {
- return FALSE;
- }
- ((TYPE*)m_pData)[nIndex] = newElement;
- return TRUE;
- }
-
- FX_BOOL Add(TYPE newElement)
- {
- if (m_nSize < m_nMaxSize) {
- m_nSize ++;
- } else if (!SetSize(m_nSize + 1, -1)) {
- return FALSE;
- }
- ((TYPE*)m_pData)[m_nSize - 1] = newElement;
- return TRUE;
- }
-
- FX_BOOL Append(const CFX_ArrayTemplate& src)
- {
- return CFX_BasicArray::Append(src);
- }
-
- FX_BOOL Copy(const CFX_ArrayTemplate& src)
- {
- return CFX_BasicArray::Copy(src);
- }
-
- TYPE* GetDataPtr(int index)
- {
- return (TYPE*)CFX_BasicArray::GetDataPtr(index);
- }
-
- TYPE* AddSpace()
- {
- return (TYPE*)CFX_BasicArray::InsertSpaceAt(m_nSize, 1);
- }
-
- TYPE* InsertSpaceAt(int nIndex, int nCount)
- {
- return (TYPE*)CFX_BasicArray::InsertSpaceAt(nIndex, nCount);
- }
-
- const TYPE operator[](int nIndex) const
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- *(volatile char*)0 = '\0';
- }
- return ((const TYPE*)m_pData)[nIndex];
- }
-
- TYPE& operator[](int nIndex)
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- *(volatile char*)0 = '\0';
- }
- return ((TYPE*)m_pData)[nIndex];
- }
-
- FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1)
- {
- if (!InsertSpaceAt(nIndex, nCount)) {
- return FALSE;
- }
- while (nCount--) {
- ((TYPE*)m_pData)[nIndex++] = newElement;
- }
- return TRUE;
- }
-
- FX_BOOL RemoveAt(int nIndex, int nCount = 1)
- {
- return CFX_BasicArray::RemoveAt(nIndex, nCount);
- }
-
- FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray)
- {
- return CFX_BasicArray::InsertAt(nStartIndex, pNewArray);
- }
-
- int Find(TYPE data, int iStart = 0) const
- {
- if (iStart < 0) {
- return -1;
- }
- for (; iStart < (int)m_nSize; iStart ++)
- if (((TYPE*)m_pData)[iStart] == data) {
- return iStart;
- }
- return -1;
- }
-};
-typedef CFX_ArrayTemplate<FX_BYTE> CFX_ByteArray;
-typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray;
-typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray;
-typedef CFX_ArrayTemplate<void*> CFX_PtrArray;
-typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray;
-typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
-typedef CFX_ArrayTemplate<FX_INT32> CFX_Int32Array;
-template <class ObjectClass>
-class CFX_ObjectArray : public CFX_BasicArray
-{
-public:
-
- CFX_ObjectArray(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(ObjectClass), pAllocator) {}
-
- ~CFX_ObjectArray()
- {
- RemoveAll();
- }
-
- void Add(const ObjectClass& data)
- {
- new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
- }
-
- ObjectClass& Add()
- {
- return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
- }
-
- void* AddSpace()
- {
- return InsertSpaceAt(m_nSize, 1);
- }
-
- FX_INT32 Append(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
- {
- if (nCount == 0) {
- return 0;
- }
- FX_INT32 nSize = src.GetSize();
- if (!nSize) {
- return 0;
- }
- FXSYS_assert(nStart > -1 && nStart < nSize);
- if (nCount < 0) {
- nCount = nSize;
- }
- if (nStart + nCount > nSize) {
- nCount = nSize - nStart;
- }
- if (nCount < 1) {
- return 0;
- }
- nSize = m_nSize;
- InsertSpaceAt(m_nSize, nCount);
- ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
- nSize = nStart + nCount;
- for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) {
- new ((void*)pStartObj) ObjectClass(src[i]);
- }
- return nCount;
- }
-
- FX_INT32 Copy(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
- {
- if (nCount == 0) {
- return 0;
- }
- FX_INT32 nSize = src.GetSize();
- if (!nSize) {
- return 0;
- }
- FXSYS_assert(nStart > -1 && nStart < nSize);
- if (nCount < 0) {
- nCount = nSize;
- }
- if (nStart + nCount > nSize) {
- nCount = nSize - nStart;
- }
- if (nCount < 1) {
- return 0;
- }
- RemoveAll();
- SetSize(nCount, -1);
- ObjectClass* pStartObj = (ObjectClass*)m_pData;
- nSize = nStart + nCount;
- for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) {
- new ((void*)pStartObj) ObjectClass(src[i]);
- }
- return nCount;
- }
-
- int GetSize() const
- {
- return m_nSize;
- }
-
- ObjectClass& operator[] (int index) const
- {
- FXSYS_assert(index < m_nSize);
- return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
- }
-
- ObjectClass* GetDataPtr(int index)
- {
- return (ObjectClass*)CFX_BasicArray::GetDataPtr(index);
- }
-
- void RemoveAt(int index)
- {
- FXSYS_assert(index < m_nSize);
- ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
- CFX_BasicArray::RemoveAt(index, 1);
- }
-
- void RemoveAll()
- {
- for (int i = 0; i < m_nSize; i ++) {
- ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
- }
- CFX_BasicArray::SetSize(0, -1);
- }
-};
-typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray;
-typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
-class CFX_BaseSegmentedArray : public CFX_Object
-{
-public:
-
- CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8, IFX_Allocator* pAllocator = NULL);
-
- ~CFX_BaseSegmentedArray();
-
- void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
-
- void* Add();
-
- void* GetAt(int index) const;
-
- void RemoveAll();
-
- void Delete(int index, int count = 1);
-
- int GetSize() const
- {
- return m_DataSize;
- }
-
- int GetSegmentSize() const
- {
- return m_SegmentSize;
- }
-
- int GetUnitSize() const
- {
- return m_UnitSize;
- }
-
- void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const;
-
- IFX_Allocator* m_pAllocator;
-private:
-
- int m_UnitSize;
-
- short m_SegmentSize;
-
- FX_BYTE m_IndexSize;
-
- FX_BYTE m_IndexDepth;
-
- int m_DataSize;
-
- void* m_pIndex;
- void** GetIndex(int seg_index) const;
- void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
- void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
-};
-template <class ElementType>
-class CFX_SegmentedArray : public CFX_BaseSegmentedArray
-{
-public:
-
- CFX_SegmentedArray(int segment_units, int index_size = 8, IFX_Allocator* pAllocator = NULL)
- : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size, pAllocator)
- {}
-
- void Add(ElementType data)
- {
- *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
- }
-
- ElementType& operator [] (int index)
- {
- return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
- }
-};
-template <class DataType, int FixedSize>
-class CFX_FixedBufGrow : public CFX_Object
-{
-public:
- CFX_FixedBufGrow(IFX_Allocator* pAllocator = NULL)
- : m_pAllocator(pAllocator)
- , m_pData(NULL)
- {}
- CFX_FixedBufGrow(int data_size, IFX_Allocator* pAllocator = NULL)
- : m_pAllocator(pAllocator)
- , m_pData(NULL)
- {
- if (data_size > FixedSize) {
- m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
- } else {
- FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
- }
- }
- void SetDataSize(int data_size)
- {
- if (m_pData) {
- FX_Allocator_Free(m_pAllocator, m_pData);
- }
- m_pData = NULL;
- if (data_size > FixedSize) {
- m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
- } else {
- FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
- }
- }
- ~CFX_FixedBufGrow()
- {
- if (m_pData) {
- FX_Allocator_Free(m_pAllocator, m_pData);
- }
- }
- operator DataType*()
- {
- return m_pData ? m_pData : m_Data;
- }
-private:
- IFX_Allocator* m_pAllocator;
- DataType m_Data[FixedSize];
- DataType* m_pData;
-};
-template <class DataType>
-class CFX_TempBuf
-{
-public:
- CFX_TempBuf(int size, IFX_Allocator* pAllocator = NULL) : m_pAllocator(pAllocator)
- {
- m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, size);
- }
- ~CFX_TempBuf()
- {
- if (m_pData) {
- FX_Allocator_Free(m_pAllocator, m_pData);
- }
- }
- DataType& operator[](int i)
- {
- FXSYS_assert(m_pData != NULL);
- return m_pData[i];
- }
- operator DataType*()
- {
- return m_pData;
- }
-private:
- IFX_Allocator* m_pAllocator;
- DataType* m_pData;
-};
-class CFX_MapPtrToPtr : public CFX_Object
-{
-protected:
-
- struct CAssoc {
-
- CAssoc* pNext;
-
- void* key;
-
- void* value;
- };
-public:
-
- CFX_MapPtrToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
-
- ~CFX_MapPtrToPtr();
-
- int GetCount() const
- {
- return m_nCount;
- }
-
- FX_BOOL IsEmpty() const
- {
- return m_nCount == 0;
- }
-
- FX_BOOL Lookup(void* key, void*& rValue) const;
-
- void* GetValueAt(void* key) const;
-
- void*& operator[](void* key);
-
- void SetAt(void* key, void* newValue)
- {
- (*this)[key] = newValue;
- }
-
- FX_BOOL RemoveKey(void* key);
-
- void RemoveAll();
-
- FX_POSITION GetStartPosition() const
- {
- return (m_nCount == 0) ? NULL : (FX_POSITION) - 1;
- }
-
- void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) const;
-
- FX_DWORD GetHashTableSize() const
- {
- return m_nHashTableSize;
- }
-
- void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
-protected:
-
- IFX_Allocator* m_pAllocator;
-
- CAssoc** m_pHashTable;
-
- FX_DWORD m_nHashTableSize;
-
- int m_nCount;
-
- CAssoc* m_pFreeList;
-
- struct CFX_Plex* m_pBlocks;
-
- int m_nBlockSize;
-
- FX_DWORD HashKey(void* key) const;
-
- CAssoc* NewAssoc();
-
- void FreeAssoc(CAssoc* pAssoc);
-
- CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const;
-};
-template <class KeyType, class ValueType>
-class CFX_MapPtrTemplate : public CFX_MapPtrToPtr
-{
-public:
-
- CFX_MapPtrTemplate(IFX_Allocator* pAllocator = NULL) : CFX_MapPtrToPtr(10, pAllocator) {}
-
- FX_BOOL Lookup(KeyType key, ValueType& rValue) const
- {
- FX_LPVOID pValue = NULL;
- if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue)) {
- return FALSE;
- }
- rValue = (ValueType)(FX_UINTPTR)pValue;
- return TRUE;
- }
-
- ValueType& operator[](KeyType key)
- {
- return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(FX_UINTPTR)key);
- }
-
- void SetAt(KeyType key, ValueType newValue)
- {
- CFX_MapPtrToPtr::SetAt((void*)(FX_UINTPTR)key, (void*)(FX_UINTPTR)newValue);
- }
-
- FX_BOOL RemoveKey(KeyType key)
- {
- return CFX_MapPtrToPtr::RemoveKey((void*)(FX_UINTPTR)key);
- }
-
- void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rValue) const
- {
- void* pKey = NULL;
- void* pValue = NULL;
- CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
- rKey = (KeyType)(FX_UINTPTR)pKey;
- rValue = (ValueType)(FX_UINTPTR)pValue;
- }
-};
-class CFX_CMapDWordToDWord : public CFX_Object
-{
-public:
-
- CFX_CMapDWordToDWord(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) {}
-
- FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
-
- void SetAt(FX_DWORD key, FX_DWORD value);
-
- void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
-
- FX_POSITION GetStartPosition() const;
-
- void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
-protected:
-
- CFX_BinaryBuf m_Buffer;
-};
-class CFX_MapByteStringToPtr : public CFX_Object
-{
-protected:
-
- struct CAssoc {
-
- CAssoc* pNext;
-
- FX_DWORD nHashValue;
-
- CFX_ByteString key;
-
- void* value;
- };
-public:
-
- CFX_MapByteStringToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
-
- int GetCount() const
- {
- return m_nCount;
- }
-
- FX_BOOL IsEmpty() const
- {
- return m_nCount == 0;
- }
-
- FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
-
- void*& operator[](FX_BSTR key);
-
- void SetAt(FX_BSTR key, void* newValue)
- {
- (*this)[key] = newValue;
- }
-
- FX_BOOL RemoveKey(FX_BSTR key);
-
- void RemoveAll();
-
- FX_POSITION GetStartPosition() const
- {
- return (m_nCount == 0) ? NULL : (FX_POSITION) - 1;
- }
-
- void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
-
- FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
-
- FX_DWORD GetHashTableSize() const
- {
- return m_nHashTableSize;
- }
-
- void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
-
- FX_DWORD HashKey(FX_BSTR key) const;
-protected:
-
- IFX_Allocator* m_pAllocator;
-
- CAssoc** m_pHashTable;
-
- FX_DWORD m_nHashTableSize;
-
- int m_nCount;
-
- CAssoc* m_pFreeList;
-
- struct CFX_Plex* m_pBlocks;
-
- int m_nBlockSize;
-
- CAssoc* NewAssoc();
-
- void FreeAssoc(CAssoc* pAssoc);
-
- CAssoc* GetAssocAt(FX_BSTR key, FX_DWORD& hash) const;
-public:
-
- ~CFX_MapByteStringToPtr();
-};
-class CFX_CMapByteStringToPtr : public CFX_Object
-{
-public:
-
- CFX_CMapByteStringToPtr(IFX_Allocator* pAllocator = NULL);
-
- ~CFX_CMapByteStringToPtr();
-
- void RemoveAll();
-
- FX_POSITION GetStartPosition() const;
-
- void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
-
- FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
-
- FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
-
- void SetAt(FX_BSTR key, void* value);
-
- void RemoveKey(FX_BSTR key);
-
- int GetCount() const;
-
- void AddValue(FX_BSTR key, void* pValue);
-private:
-
- CFX_BaseSegmentedArray m_Buffer;
-};
-class CFX_PtrList : public CFX_Object
-{
-protected:
-
- struct CNode {
-
- CNode* pNext;
-
- CNode* pPrev;
-
- void* data;
- };
-public:
-
- CFX_PtrList(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
-
- FX_POSITION GetHeadPosition() const
- {
- return (FX_POSITION)m_pNodeHead;
- }
-
- FX_POSITION GetTailPosition() const
- {
- return (FX_POSITION)m_pNodeTail;
- }
-
- void* GetNext(FX_POSITION& rPosition) const
- {
- CNode* pNode = (CNode*) rPosition;
- rPosition = (FX_POSITION) pNode->pNext;
- return pNode->data;
- }
-
- void* GetPrev(FX_POSITION& rPosition) const
- {
- CNode* pNode = (CNode*) rPosition;
- rPosition = (FX_POSITION) pNode->pPrev;
- return pNode->data;
- }
-
- FX_POSITION GetNextPosition(FX_POSITION pos) const
- {
- return ((CNode*)pos)->pNext;
- }
-
- FX_POSITION GetPrevPosition(FX_POSITION pos) const
- {
- return ((CNode*)pos)->pPrev;
- }
-
- void* GetAt(FX_POSITION rPosition) const
- {
- CNode* pNode = (CNode*) rPosition;
- return pNode->data;
- }
-
- int GetCount() const
- {
- return m_nCount;
- }
-
- FX_POSITION AddTail(void* newElement);
-
- FX_POSITION AddHead(void* newElement);
-
- void SetAt(FX_POSITION pos, void* newElement)
- {
- CNode* pNode = (CNode*) pos;
- pNode->data = newElement;
- }
-
- FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
-
- FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL ) const;
-
- FX_POSITION FindIndex(int index) const;
-
- void RemoveAt(FX_POSITION pos);
-
- void RemoveAll();
-protected:
-
- IFX_Allocator* m_pAllocator;
-
- CNode* m_pNodeHead;
-
- CNode* m_pNodeTail;
-
- int m_nCount;
-
- CNode* m_pNodeFree;
-
- struct CFX_Plex* m_pBlocks;
-
- int m_nBlockSize;
-
- CNode* NewNode(CNode* pPrev, CNode* pNext);
-
- void FreeNode(CNode* pNode);
-public:
-
- ~CFX_PtrList();
-};
-typedef void (*PD_CALLBACK_FREEDATA)(FX_LPVOID pData);
-struct FX_PRIVATEDATA {
-
- void FreeData();
-
- FX_LPVOID m_pModuleId;
-
- FX_LPVOID m_pData;
-
- PD_CALLBACK_FREEDATA m_pCallback;
-
- FX_BOOL m_bSelfDestruct;
-};
-class CFX_PrivateData
-{
-public:
-
- CFX_PrivateData(IFX_Allocator* pAllocator = NULL) : m_DataList(pAllocator) {}
-
- ~CFX_PrivateData();
-
- void ClearAll();
-
- void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
-
- void SetPrivateObj(FX_LPVOID module_id, CFX_DestructObject* pObj);
-
- FX_LPVOID GetPrivateData(FX_LPVOID module_id);
-
- FX_BOOL LookupPrivateData(FX_LPVOID module_id, FX_LPVOID &pData) const
- {
- if (!module_id) {
- return FALSE;
- }
- FX_DWORD nCount = m_DataList.GetSize();
- for (FX_DWORD n = 0; n < nCount; n ++) {
- if (m_DataList[n].m_pModuleId == module_id) {
- pData = m_DataList[n].m_pData;
- return TRUE;
- }
- }
- return FALSE;
- }
-
- FX_BOOL RemovePrivateData(FX_LPVOID module_id);
-protected:
-
- CFX_ArrayTemplate<FX_PRIVATEDATA> m_DataList;
-
- void AddData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct);
-};
-class CFX_BitStream : public CFX_Object
-{
-public:
-
- void Init(FX_LPCBYTE pData, FX_DWORD dwSize);
-
-
- FX_DWORD GetBits(FX_DWORD nBits);
-
- void ByteAlign();
-
- FX_BOOL IsEOF()
- {
- return m_BitPos >= m_BitSize;
- }
-
- void SkipBits(FX_DWORD nBits)
- {
- m_BitPos += nBits;
- }
-
- void Rewind()
- {
- m_BitPos = 0;
- }
-protected:
-
- FX_DWORD m_BitPos;
-
- FX_DWORD m_BitSize;
-
- FX_LPCBYTE m_pData;
-};
-template <class ObjClass> class CFX_CountRef : public CFX_Object
-{
-public:
-
- typedef CFX_CountRef<ObjClass> Ref;
-
- class CountedObj : public ObjClass
- {
- public:
-
- CountedObj() {}
-
- CountedObj(const CountedObj& src) : ObjClass(src) {}
-
- int m_RefCount;
- };
-
- CFX_CountRef()
- {
- m_pObject = NULL;
- }
-
- CFX_CountRef(const Ref& ref)
- {
- m_pObject = ref.m_pObject;
- if (m_pObject) {
- m_pObject->m_RefCount ++;
- }
- }
-
- ~CFX_CountRef()
- {
- if (!m_pObject) {
- return;
- }
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- }
-
- ObjClass* New()
- {
- if (m_pObject) {
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- m_pObject = NULL;
- }
- m_pObject = FX_NEW CountedObj;
- if (!m_pObject) {
- return NULL;
- }
- m_pObject->m_RefCount = 1;
- return m_pObject;
- }
-
- void operator = (const Ref& ref)
- {
- if (ref.m_pObject) {
- ref.m_pObject->m_RefCount ++;
- }
- if (m_pObject) {
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- }
- m_pObject = ref.m_pObject;
- }
-
- void operator = (void* p)
- {
- FXSYS_assert(p == 0);
- if (m_pObject == NULL) {
- return;
- }
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- m_pObject = NULL;
- }
-
- const ObjClass* GetObject() const
- {
- return m_pObject;
- }
-
- operator const ObjClass*() const
- {
- return m_pObject;
- }
-
- FX_BOOL IsNull() const
- {
- return m_pObject == NULL;
- }
-
- FX_BOOL NotNull() const
- {
- return m_pObject != NULL;
- }
-
- ObjClass* GetModify()
- {
- if (m_pObject == NULL) {
- m_pObject = FX_NEW CountedObj;
- if (m_pObject) {
- m_pObject->m_RefCount = 1;
- }
- } else if (m_pObject->m_RefCount > 1) {
- m_pObject->m_RefCount --;
- CountedObj* pOldObject = m_pObject;
- m_pObject = NULL;
- m_pObject = FX_NEW CountedObj(*pOldObject);
- if (m_pObject) {
- m_pObject->m_RefCount = 1;
- }
- }
- return m_pObject;
- }
-
- void SetNull()
- {
- if (m_pObject == NULL) {
- return;
- }
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- m_pObject = NULL;
- }
-
- FX_BOOL operator == (const Ref& ref) const
- {
- return m_pObject == ref.m_pObject;
- }
-protected:
-
- CountedObj* m_pObject;
-};
-class IFX_Pause
-{
-public:
-
- virtual FX_BOOL NeedToPauseNow() = 0;
-};
-class CFX_DataFilter : public CFX_Object
-{
-public:
-
- virtual ~CFX_DataFilter();
-
- void SetDestFilter(CFX_DataFilter* pFilter);
-
- FX_BOOL IsEOF() const
- {
- return m_bEOF;
- }
-
- FX_DWORD GetSrcPos()
- {
- return m_SrcPos;
- }
-
- void FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
-
- void FilterFinish(CFX_BinaryBuf& dest_buf);
-protected:
-
- CFX_DataFilter();
- virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0;
- virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0;
- void ReportEOF(FX_DWORD left_input);
-
- FX_BOOL m_bEOF;
-
- FX_DWORD m_SrcPos;
-
- CFX_DataFilter* m_pDestFilter;
-};
-template <class T>
-class CFX_SmartPointer
-{
-public:
- CFX_SmartPointer(T *pObj) : m_pObj(pObj) {}
- ~CFX_SmartPointer()
- {
- m_pObj->Release();
- }
- operator T*(void)
- {
- return m_pObj;
- }
- T& operator *(void)
- {
- return *m_pObj;
- }
- T* operator ->(void)
- {
- return m_pObj;
- }
-protected:
- T *m_pObj;
-};
-#define FX_DATALIST_LENGTH 1024
-template<size_t unit>
-class CFX_SortListArray : public CFX_Object
-{
-protected:
-
- struct DataList {
-
- FX_INT32 start;
-
- FX_INT32 count;
- FX_LPBYTE data;
- };
-public:
-
- CFX_SortListArray(IFX_Allocator* pAllocator = NULL) : m_CurList(0), m_DataLists(pAllocator) {}
-
- ~CFX_SortListArray()
- {
- Clear();
- }
-
-
- void Clear()
- {
- IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
- for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) {
- DataList list = m_DataLists.ElementAt(i);
- if (list.data) {
- FX_Allocator_Free(pAllocator, list.data);
- }
- }
- m_DataLists.RemoveAll();
- m_CurList = 0;
- }
-
- void Append(FX_INT32 nStart, FX_INT32 nCount)
- {
- if (nStart < 0) {
- return;
- }
- IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
- while (nCount > 0) {
- FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
- DataList list;
- list.data = FX_Allocator_Alloc(pAllocator, FX_BYTE, temp_count * unit);
- if (!list.data) {
- break;
- }
- FXSYS_memset32(list.data, 0, temp_count * unit);
- list.start = nStart;
- list.count = temp_count;
- Append(list);
- nCount -= temp_count;
- nStart += temp_count;
- }
- }
-
- FX_LPBYTE GetAt(FX_INT32 nIndex)
- {
- if (nIndex < 0) {
- return NULL;
- }
- if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) {
- return NULL;
- }
- DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
- if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) {
- pCurList = NULL;
- FX_INT32 iStart = 0;
- FX_INT32 iEnd = m_DataLists.GetUpperBound();
- FX_INT32 iMid = 0;
- while (iStart <= iEnd) {
- iMid = (iStart + iEnd) / 2;
- DataList* list = m_DataLists.GetDataPtr(iMid);
- if (nIndex < list->start) {
- iEnd = iMid - 1;
- } else if (nIndex >= list->start + list->count) {
- iStart = iMid + 1;
- } else {
- pCurList = list;
- m_CurList = iMid;
- break;
- }
- }
- }
- return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL;
- }
-protected:
- void Append(const DataList& list)
- {
- FX_INT32 iStart = 0;
- FX_INT32 iEnd = m_DataLists.GetUpperBound();
- FX_INT32 iFind = 0;
- while (iStart <= iEnd) {
- FX_INT32 iMid = (iStart + iEnd) / 2;
- DataList* cur_list = m_DataLists.GetDataPtr(iMid);
- if (list.start < cur_list->start + cur_list->count) {
- iEnd = iMid - 1;
- } else {
- if (iMid == iEnd) {
- iFind = iMid + 1;
- break;
- }
- DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
- if (list.start < next_list->start) {
- iFind = iMid + 1;
- break;
- } else {
- iStart = iMid + 1;
- }
- }
- }
- m_DataLists.InsertAt(iFind, list);
- }
- FX_INT32 m_CurList;
- CFX_ArrayTemplate<DataList> m_DataLists;
-};
-template<typename T1, typename T2>
-class CFX_ListArrayTemplate : public CFX_Object
-{
-public:
-
- void Clear()
- {
- m_Data.Clear();
- }
-
- void Add(FX_INT32 nStart, FX_INT32 nCount)
- {
- m_Data.Append(nStart, nCount);
- }
-
- T2& operator [] (FX_INT32 nIndex)
- {
- FX_LPBYTE data = m_Data.GetAt(nIndex);
- FXSYS_assert(data != NULL);
- return (T2&)(*(volatile T2*)data);
- }
-
- T2* GetPtrAt(FX_INT32 nIndex)
- {
- return (T2*)m_Data.GetAt(nIndex);
- }
-protected:
- T1 m_Data;
-};
-typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, FX_FILESIZE> CFX_FileSizeListArray;
-typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD> CFX_DWordListArray;
-typedef enum {
- Ready,
- ToBeContinued,
- Found,
- NotFound,
- Failed,
- Done
-} FX_ProgressiveStatus;
-#define ProgressiveStatus FX_ProgressiveStatus
-#define FX_NAMESPACE_DECLARE(namespace, type) namespace::type
-#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 _FX_BASIC_H_
+#define _FX_BASIC_H_
+#ifndef _FX_SYSTEM_H_
+#include "fx_system.h"
+#endif
+#ifndef _FX_MEMORY_H_
+#include "fx_memory.h"
+#endif
+#ifndef _FX_STRING_H_
+#include "fx_string.h"
+#endif
+#ifndef _FX_STREAM_H_
+#include "fx_stream.h"
+#endif
+class CFX_BinaryBuf : public CFX_Object
+{
+public:
+
+ CFX_BinaryBuf(IFX_Allocator* pAllocator = NULL);
+
+ CFX_BinaryBuf(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
+
+ ~CFX_BinaryBuf();
+
+ void Clear();
+
+ void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0);
+
+ void AppendBlock(const void* pBuf, FX_STRSIZE size);
+
+ void AppendFill(FX_BYTE byte, FX_STRSIZE count);
+
+ void AppendString(FX_BSTR str)
+ {
+ AppendBlock(str.GetPtr(), str.GetLength());
+ }
+
+ inline void AppendByte(FX_BYTE byte)
+ {
+ if (m_AllocSize <= m_DataSize) {
+ ExpandBuf(1);
+ }
+ m_pBuffer[m_DataSize++] = byte;
+ }
+
+ void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size);
+
+ void AttachData(void* pBuf, FX_STRSIZE size);
+
+ void CopyData(const void* pBuf, FX_STRSIZE size);
+
+ void TakeOver(CFX_BinaryBuf& other);
+
+ void Delete(int start_index, int count);
+
+ FX_LPBYTE GetBuffer() const
+ {
+ return m_pBuffer;
+ }
+
+ FX_STRSIZE GetSize() const
+ {
+ return m_DataSize;
+ }
+
+ CFX_ByteStringC GetByteString() const;
+ void GetByteStringL(CFX_ByteStringL &str) const;
+
+ void DetachBuffer();
+
+ IFX_Allocator* m_pAllocator;
+protected:
+
+ FX_STRSIZE m_AllocStep;
+
+ FX_LPBYTE m_pBuffer;
+
+ FX_STRSIZE m_DataSize;
+
+ FX_STRSIZE m_AllocSize;
+
+ void ExpandBuf(FX_STRSIZE size);
+};
+class CFX_ByteTextBuf : public CFX_BinaryBuf
+{
+public:
+
+ CFX_ByteTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
+
+ void operator = (FX_BSTR str);
+
+ void AppendChar(int ch)
+ {
+ AppendByte((FX_BYTE)ch);
+ }
+
+ CFX_ByteTextBuf& operator << (int i);
+
+ CFX_ByteTextBuf& operator << (FX_DWORD i);
+
+ CFX_ByteTextBuf& operator << (double f);
+
+ CFX_ByteTextBuf& operator << (FX_BSTR lpsz);
+
+ CFX_ByteTextBuf& operator << (const CFX_ByteTextBuf& buf);
+
+ FX_STRSIZE GetLength() const
+ {
+ return m_DataSize;
+ }
+};
+class CFX_WideTextBuf : public CFX_BinaryBuf
+{
+public:
+
+ CFX_WideTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
+
+ void operator = (FX_LPCWSTR lpsz);
+
+ void operator = (FX_WSTR str);
+
+ void AppendChar(FX_WCHAR wch);
+
+ CFX_WideTextBuf& operator << (int i);
+
+ CFX_WideTextBuf& operator << (double f);
+
+ CFX_WideTextBuf& operator << (FX_LPCWSTR lpsz);
+
+ CFX_WideTextBuf& operator << (FX_WSTR str);
+ CFX_WideTextBuf& operator << (const CFX_WideString &str);
+
+ CFX_WideTextBuf& operator << (const CFX_WideTextBuf& buf);
+
+ FX_STRSIZE GetLength() const
+ {
+ return m_DataSize / sizeof(FX_WCHAR);
+ }
+
+ FX_LPWSTR GetBuffer() const
+ {
+ return (FX_LPWSTR)m_pBuffer;
+ }
+
+ void Delete(int start_index, int count)
+ {
+ CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_WCHAR));
+ }
+
+ CFX_WideStringC GetWideString() const;
+ void GetWideStringL(CFX_WideStringL& wideText) const;
+};
+class CFX_ArchiveSaver : public CFX_Object
+{
+public:
+
+ CFX_ArchiveSaver(IFX_Allocator* pAllocator = NULL) : m_SavingBuf(pAllocator), m_pStream(NULL) {}
+
+ CFX_ArchiveSaver& operator << (FX_BYTE i);
+
+ CFX_ArchiveSaver& operator << (int i);
+
+ CFX_ArchiveSaver& operator << (FX_DWORD i);
+
+ CFX_ArchiveSaver& operator << (FX_FLOAT i);
+
+ CFX_ArchiveSaver& operator << (double i);
+
+ CFX_ArchiveSaver& operator << (FX_BSTR bstr);
+
+ CFX_ArchiveSaver& operator << (FX_LPCWSTR bstr);
+
+ CFX_ArchiveSaver& operator << (const CFX_WideString& wstr);
+
+ void Write(const void* pData, FX_STRSIZE dwSize);
+
+ FX_INTPTR GetLength()
+ {
+ return m_SavingBuf.GetSize();
+ }
+
+ FX_LPCBYTE GetBuffer()
+ {
+ return m_SavingBuf.GetBuffer();
+ }
+
+ void SetStream(IFX_FileStream* pStream)
+ {
+ m_pStream = pStream;
+ }
+protected:
+
+ CFX_BinaryBuf m_SavingBuf;
+
+ IFX_FileStream* m_pStream;
+};
+class CFX_ArchiveLoader : public CFX_Object
+{
+public:
+
+ CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize);
+
+ CFX_ArchiveLoader& operator >> (FX_BYTE& i);
+
+ CFX_ArchiveLoader& operator >> (int& i);
+
+ CFX_ArchiveLoader& operator >> (FX_DWORD& i);
+
+ CFX_ArchiveLoader& operator >> (FX_FLOAT& i);
+
+ CFX_ArchiveLoader& operator >> (double& i);
+
+ CFX_ArchiveLoader& operator >> (CFX_ByteString& bstr);
+
+ CFX_ArchiveLoader& operator >> (CFX_WideString& wstr);
+
+ FX_BOOL IsEOF();
+
+ FX_BOOL Read(void* pBuf, FX_DWORD dwSize);
+protected:
+
+ FX_DWORD m_LoadingPos;
+
+ FX_LPCBYTE m_pLoadingBuf;
+
+ FX_DWORD m_LoadingSize;
+};
+class IFX_BufferArchive
+{
+public:
+
+ IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
+
+
+ virtual void Clear();
+
+
+ FX_BOOL Flush();
+
+
+ FX_INT32 AppendBlock(const void* pBuf, size_t size);
+
+ FX_INT32 AppendByte(FX_BYTE byte);
+
+ FX_INT32 AppendDWord(FX_DWORD i);
+
+
+ FX_INT32 AppendString(FX_BSTR lpsz);
+
+protected:
+
+ virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
+
+
+ IFX_Allocator* m_pAllocator;
+
+ FX_STRSIZE m_BufSize;
+
+ FX_LPBYTE m_pBuffer;
+
+ FX_STRSIZE m_Length;
+};
+class CFX_FileBufferArchive : public IFX_BufferArchive, public CFX_Object
+{
+public:
+ CFX_FileBufferArchive(FX_STRSIZE size = 32768, IFX_Allocator* pAllocator = NULL);
+ ~CFX_FileBufferArchive();
+ virtual void Clear();
+
+ FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = FALSE);
+
+ FX_BOOL AttachFile(FX_LPCWSTR filename);
+
+ FX_BOOL AttachFile(FX_LPCSTR filename);
+private:
+
+ virtual FX_BOOL DoWork(const void* pBuf, size_t size);
+
+ IFX_StreamWrite *m_pFile;
+
+ FX_BOOL m_bTakeover;
+};
+struct CFX_CharMap {
+
+ static CFX_CharMap* GetDefaultMapper(FX_INT32 codepage = 0);
+
+
+ CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteString& bstr);
+
+ CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideString& wstr);
+
+ FX_INT32 (*m_GetCodePage)();
+};
+class CFX_UTF8Decoder
+{
+public:
+
+ CFX_UTF8Decoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator)
+ {
+ m_PendingBytes = 0;
+ }
+
+ void Clear();
+
+ void Input(FX_BYTE byte);
+
+ void AppendChar(FX_DWORD ch);
+
+ void ClearStatus()
+ {
+ m_PendingBytes = 0;
+ }
+
+ CFX_WideStringC GetResult() const
+ {
+ return m_Buffer.GetWideString();
+ }
+ void GetResult(CFX_WideStringL &result) const
+ {
+ m_Buffer.GetWideStringL(result);
+ }
+protected:
+
+ int m_PendingBytes;
+
+ FX_DWORD m_PendingChar;
+
+ CFX_WideTextBuf m_Buffer;
+};
+class CFX_UTF8Encoder
+{
+public:
+
+ CFX_UTF8Encoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator)
+ {
+ m_UTF16First = 0;
+ }
+
+ void Input(FX_WCHAR unicode);
+
+ void AppendStr(FX_BSTR str)
+ {
+ m_UTF16First = 0;
+ m_Buffer << str;
+ }
+
+ CFX_ByteStringC GetResult() const
+ {
+ return m_Buffer.GetByteString();
+ }
+ void GetResult(CFX_ByteStringL &result) const
+ {
+ m_Buffer.GetByteStringL(result);
+ }
+protected:
+
+ CFX_ByteTextBuf m_Buffer;
+
+ FX_DWORD m_UTF16First;
+};
+CFX_ByteString FX_UrlEncode(const CFX_WideString& wsUrl);
+CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl);
+CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI);
+CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI);
+class CFX_BasicArray : public CFX_Object
+{
+public:
+
+ IFX_Allocator* m_pAllocator;
+protected:
+
+ CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator = NULL);
+
+ ~CFX_BasicArray();
+
+ FX_BOOL SetSize(int nNewSize, int nGrowBy);
+
+ FX_BOOL Append(const CFX_BasicArray& src);
+
+ FX_BOOL Copy(const CFX_BasicArray& src);
+
+ FX_LPBYTE InsertSpaceAt(int nIndex, int nCount);
+
+ FX_BOOL RemoveAt(int nIndex, int nCount);
+
+ FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
+
+ const void* GetDataPtr(int index) const;
+protected:
+
+ FX_LPBYTE m_pData;
+
+ int m_nSize;
+
+ int m_nMaxSize;
+
+ int m_nGrowBy;
+
+ int m_nUnitSize;
+};
+template<class TYPE>
+class CFX_ArrayTemplate : public CFX_BasicArray
+{
+public:
+
+ CFX_ArrayTemplate(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(TYPE), pAllocator) {}
+
+ int GetSize() const
+ {
+ return m_nSize;
+ }
+
+ int GetUpperBound() const
+ {
+ return m_nSize - 1;
+ }
+
+ FX_BOOL SetSize(int nNewSize, int nGrowBy = -1)
+ {
+ return CFX_BasicArray::SetSize(nNewSize, nGrowBy);
+ }
+
+ void RemoveAll()
+ {
+ SetSize(0, -1);
+ }
+
+ const TYPE GetAt(int nIndex) const
+ {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ return (const TYPE&)(*(volatile const TYPE*)NULL);
+ }
+ return ((const TYPE*)m_pData)[nIndex];
+ }
+
+ FX_BOOL SetAt(int nIndex, TYPE newElement)
+ {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ return FALSE;
+ }
+ ((TYPE*)m_pData)[nIndex] = newElement;
+ return TRUE;
+ }
+
+ TYPE& ElementAt(int nIndex)
+ {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ return *(TYPE*)NULL;
+ }
+ return ((TYPE*)m_pData)[nIndex];
+ }
+
+ const TYPE* GetData() const
+ {
+ return (const TYPE*)m_pData;
+ }
+
+ TYPE* GetData()
+ {
+ return (TYPE*)m_pData;
+ }
+
+ FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
+ {
+ if (nIndex < 0) {
+ return FALSE;
+ }
+ if (nIndex >= m_nSize)
+ if (!SetSize(nIndex + 1, -1)) {
+ return FALSE;
+ }
+ ((TYPE*)m_pData)[nIndex] = newElement;
+ return TRUE;
+ }
+
+ FX_BOOL Add(TYPE newElement)
+ {
+ if (m_nSize < m_nMaxSize) {
+ m_nSize ++;
+ } else if (!SetSize(m_nSize + 1, -1)) {
+ return FALSE;
+ }
+ ((TYPE*)m_pData)[m_nSize - 1] = newElement;
+ return TRUE;
+ }
+
+ FX_BOOL Append(const CFX_ArrayTemplate& src)
+ {
+ return CFX_BasicArray::Append(src);
+ }
+
+ FX_BOOL Copy(const CFX_ArrayTemplate& src)
+ {
+ return CFX_BasicArray::Copy(src);
+ }
+
+ TYPE* GetDataPtr(int index)
+ {
+ return (TYPE*)CFX_BasicArray::GetDataPtr(index);
+ }
+
+ TYPE* AddSpace()
+ {
+ return (TYPE*)CFX_BasicArray::InsertSpaceAt(m_nSize, 1);
+ }
+
+ TYPE* InsertSpaceAt(int nIndex, int nCount)
+ {
+ return (TYPE*)CFX_BasicArray::InsertSpaceAt(nIndex, nCount);
+ }
+
+ const TYPE operator[](int nIndex) const
+ {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ *(volatile char*)0 = '\0';
+ }
+ return ((const TYPE*)m_pData)[nIndex];
+ }
+
+ TYPE& operator[](int nIndex)
+ {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ *(volatile char*)0 = '\0';
+ }
+ return ((TYPE*)m_pData)[nIndex];
+ }
+
+ FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1)
+ {
+ if (!InsertSpaceAt(nIndex, nCount)) {
+ return FALSE;
+ }
+ while (nCount--) {
+ ((TYPE*)m_pData)[nIndex++] = newElement;
+ }
+ return TRUE;
+ }
+
+ FX_BOOL RemoveAt(int nIndex, int nCount = 1)
+ {
+ return CFX_BasicArray::RemoveAt(nIndex, nCount);
+ }
+
+ FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray)
+ {
+ return CFX_BasicArray::InsertAt(nStartIndex, pNewArray);
+ }
+
+ int Find(TYPE data, int iStart = 0) const
+ {
+ if (iStart < 0) {
+ return -1;
+ }
+ for (; iStart < (int)m_nSize; iStart ++)
+ if (((TYPE*)m_pData)[iStart] == data) {
+ return iStart;
+ }
+ return -1;
+ }
+};
+typedef CFX_ArrayTemplate<FX_BYTE> CFX_ByteArray;
+typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray;
+typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray;
+typedef CFX_ArrayTemplate<void*> CFX_PtrArray;
+typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray;
+typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
+typedef CFX_ArrayTemplate<FX_INT32> CFX_Int32Array;
+template <class ObjectClass>
+class CFX_ObjectArray : public CFX_BasicArray
+{
+public:
+
+ CFX_ObjectArray(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(ObjectClass), pAllocator) {}
+
+ ~CFX_ObjectArray()
+ {
+ RemoveAll();
+ }
+
+ void Add(const ObjectClass& data)
+ {
+ new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
+ }
+
+ ObjectClass& Add()
+ {
+ return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
+ }
+
+ void* AddSpace()
+ {
+ return InsertSpaceAt(m_nSize, 1);
+ }
+
+ FX_INT32 Append(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
+ {
+ if (nCount == 0) {
+ return 0;
+ }
+ FX_INT32 nSize = src.GetSize();
+ if (!nSize) {
+ return 0;
+ }
+ FXSYS_assert(nStart > -1 && nStart < nSize);
+ if (nCount < 0) {
+ nCount = nSize;
+ }
+ if (nStart + nCount > nSize) {
+ nCount = nSize - nStart;
+ }
+ if (nCount < 1) {
+ return 0;
+ }
+ nSize = m_nSize;
+ InsertSpaceAt(m_nSize, nCount);
+ ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
+ nSize = nStart + nCount;
+ for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) {
+ new ((void*)pStartObj) ObjectClass(src[i]);
+ }
+ return nCount;
+ }
+
+ FX_INT32 Copy(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
+ {
+ if (nCount == 0) {
+ return 0;
+ }
+ FX_INT32 nSize = src.GetSize();
+ if (!nSize) {
+ return 0;
+ }
+ FXSYS_assert(nStart > -1 && nStart < nSize);
+ if (nCount < 0) {
+ nCount = nSize;
+ }
+ if (nStart + nCount > nSize) {
+ nCount = nSize - nStart;
+ }
+ if (nCount < 1) {
+ return 0;
+ }
+ RemoveAll();
+ SetSize(nCount, -1);
+ ObjectClass* pStartObj = (ObjectClass*)m_pData;
+ nSize = nStart + nCount;
+ for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) {
+ new ((void*)pStartObj) ObjectClass(src[i]);
+ }
+ return nCount;
+ }
+
+ int GetSize() const
+ {
+ return m_nSize;
+ }
+
+ ObjectClass& operator[] (int index) const
+ {
+ FXSYS_assert(index < m_nSize);
+ return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
+ }
+
+ ObjectClass* GetDataPtr(int index)
+ {
+ return (ObjectClass*)CFX_BasicArray::GetDataPtr(index);
+ }
+
+ void RemoveAt(int index)
+ {
+ FXSYS_assert(index < m_nSize);
+ ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
+ CFX_BasicArray::RemoveAt(index, 1);
+ }
+
+ void RemoveAll()
+ {
+ for (int i = 0; i < m_nSize; i ++) {
+ ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
+ }
+ CFX_BasicArray::SetSize(0, -1);
+ }
+};
+typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray;
+typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
+class CFX_BaseSegmentedArray : public CFX_Object
+{
+public:
+
+ CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8, IFX_Allocator* pAllocator = NULL);
+
+ ~CFX_BaseSegmentedArray();
+
+ void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
+
+ void* Add();
+
+ void* GetAt(int index) const;
+
+ void RemoveAll();
+
+ void Delete(int index, int count = 1);
+
+ int GetSize() const
+ {
+ return m_DataSize;
+ }
+
+ int GetSegmentSize() const
+ {
+ return m_SegmentSize;
+ }
+
+ int GetUnitSize() const
+ {
+ return m_UnitSize;
+ }
+
+ void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const;
+
+ IFX_Allocator* m_pAllocator;
+private:
+
+ int m_UnitSize;
+
+ short m_SegmentSize;
+
+ FX_BYTE m_IndexSize;
+
+ FX_BYTE m_IndexDepth;
+
+ int m_DataSize;
+
+ void* m_pIndex;
+ void** GetIndex(int seg_index) const;
+ void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
+ void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
+};
+template <class ElementType>
+class CFX_SegmentedArray : public CFX_BaseSegmentedArray
+{
+public:
+
+ CFX_SegmentedArray(int segment_units, int index_size = 8, IFX_Allocator* pAllocator = NULL)
+ : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size, pAllocator)
+ {}
+
+ void Add(ElementType data)
+ {
+ *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
+ }
+
+ ElementType& operator [] (int index)
+ {
+ return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
+ }
+};
+template <class DataType, int FixedSize>
+class CFX_FixedBufGrow : public CFX_Object
+{
+public:
+ CFX_FixedBufGrow(IFX_Allocator* pAllocator = NULL)
+ : m_pAllocator(pAllocator)
+ , m_pData(NULL)
+ {}
+ CFX_FixedBufGrow(int data_size, IFX_Allocator* pAllocator = NULL)
+ : m_pAllocator(pAllocator)
+ , m_pData(NULL)
+ {
+ if (data_size > FixedSize) {
+ m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
+ } else {
+ FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
+ }
+ }
+ void SetDataSize(int data_size)
+ {
+ if (m_pData) {
+ FX_Allocator_Free(m_pAllocator, m_pData);
+ }
+ m_pData = NULL;
+ if (data_size > FixedSize) {
+ m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
+ } else {
+ FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
+ }
+ }
+ ~CFX_FixedBufGrow()
+ {
+ if (m_pData) {
+ FX_Allocator_Free(m_pAllocator, m_pData);
+ }
+ }
+ operator DataType*()
+ {
+ return m_pData ? m_pData : m_Data;
+ }
+private:
+ IFX_Allocator* m_pAllocator;
+ DataType m_Data[FixedSize];
+ DataType* m_pData;
+};
+template <class DataType>
+class CFX_TempBuf
+{
+public:
+ CFX_TempBuf(int size, IFX_Allocator* pAllocator = NULL) : m_pAllocator(pAllocator)
+ {
+ m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, size);
+ }
+ ~CFX_TempBuf()
+ {
+ if (m_pData) {
+ FX_Allocator_Free(m_pAllocator, m_pData);
+ }
+ }
+ DataType& operator[](int i)
+ {
+ FXSYS_assert(m_pData != NULL);
+ return m_pData[i];
+ }
+ operator DataType*()
+ {
+ return m_pData;
+ }
+private:
+ IFX_Allocator* m_pAllocator;
+ DataType* m_pData;
+};
+class CFX_MapPtrToPtr : public CFX_Object
+{
+protected:
+
+ struct CAssoc {
+
+ CAssoc* pNext;
+
+ void* key;
+
+ void* value;
+ };
+public:
+
+ CFX_MapPtrToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
+
+ ~CFX_MapPtrToPtr();
+
+ int GetCount() const
+ {
+ return m_nCount;
+ }
+
+ FX_BOOL IsEmpty() const
+ {
+ return m_nCount == 0;
+ }
+
+ FX_BOOL Lookup(void* key, void*& rValue) const;
+
+ void* GetValueAt(void* key) const;
+
+ void*& operator[](void* key);
+
+ void SetAt(void* key, void* newValue)
+ {
+ (*this)[key] = newValue;
+ }
+
+ FX_BOOL RemoveKey(void* key);
+
+ void RemoveAll();
+
+ FX_POSITION GetStartPosition() const
+ {
+ return (m_nCount == 0) ? NULL : (FX_POSITION) - 1;
+ }
+
+ void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) const;
+
+ FX_DWORD GetHashTableSize() const
+ {
+ return m_nHashTableSize;
+ }
+
+ void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
+protected:
+
+ IFX_Allocator* m_pAllocator;
+
+ CAssoc** m_pHashTable;
+
+ FX_DWORD m_nHashTableSize;
+
+ int m_nCount;
+
+ CAssoc* m_pFreeList;
+
+ struct CFX_Plex* m_pBlocks;
+
+ int m_nBlockSize;
+
+ FX_DWORD HashKey(void* key) const;
+
+ CAssoc* NewAssoc();
+
+ void FreeAssoc(CAssoc* pAssoc);
+
+ CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const;
+};
+template <class KeyType, class ValueType>
+class CFX_MapPtrTemplate : public CFX_MapPtrToPtr
+{
+public:
+
+ CFX_MapPtrTemplate(IFX_Allocator* pAllocator = NULL) : CFX_MapPtrToPtr(10, pAllocator) {}
+
+ FX_BOOL Lookup(KeyType key, ValueType& rValue) const
+ {
+ FX_LPVOID pValue = NULL;
+ if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue)) {
+ return FALSE;
+ }
+ rValue = (ValueType)(FX_UINTPTR)pValue;
+ return TRUE;
+ }
+
+ ValueType& operator[](KeyType key)
+ {
+ return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(FX_UINTPTR)key);
+ }
+
+ void SetAt(KeyType key, ValueType newValue)
+ {
+ CFX_MapPtrToPtr::SetAt((void*)(FX_UINTPTR)key, (void*)(FX_UINTPTR)newValue);
+ }
+
+ FX_BOOL RemoveKey(KeyType key)
+ {
+ return CFX_MapPtrToPtr::RemoveKey((void*)(FX_UINTPTR)key);
+ }
+
+ void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rValue) const
+ {
+ void* pKey = NULL;
+ void* pValue = NULL;
+ CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
+ rKey = (KeyType)(FX_UINTPTR)pKey;
+ rValue = (ValueType)(FX_UINTPTR)pValue;
+ }
+};
+class CFX_CMapDWordToDWord : public CFX_Object
+{
+public:
+
+ CFX_CMapDWordToDWord(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) {}
+
+ FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
+
+ void SetAt(FX_DWORD key, FX_DWORD value);
+
+ void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
+
+ FX_POSITION GetStartPosition() const;
+
+ void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
+protected:
+
+ CFX_BinaryBuf m_Buffer;
+};
+class CFX_MapByteStringToPtr : public CFX_Object
+{
+protected:
+
+ struct CAssoc {
+
+ CAssoc* pNext;
+
+ FX_DWORD nHashValue;
+
+ CFX_ByteString key;
+
+ void* value;
+ };
+public:
+
+ CFX_MapByteStringToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
+
+ int GetCount() const
+ {
+ return m_nCount;
+ }
+
+ FX_BOOL IsEmpty() const
+ {
+ return m_nCount == 0;
+ }
+
+ FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
+
+ void*& operator[](FX_BSTR key);
+
+ void SetAt(FX_BSTR key, void* newValue)
+ {
+ (*this)[key] = newValue;
+ }
+
+ FX_BOOL RemoveKey(FX_BSTR key);
+
+ void RemoveAll();
+
+ FX_POSITION GetStartPosition() const
+ {
+ return (m_nCount == 0) ? NULL : (FX_POSITION) - 1;
+ }
+
+ void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
+
+ FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
+
+ FX_DWORD GetHashTableSize() const
+ {
+ return m_nHashTableSize;
+ }
+
+ void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
+
+ FX_DWORD HashKey(FX_BSTR key) const;
+protected:
+
+ IFX_Allocator* m_pAllocator;
+
+ CAssoc** m_pHashTable;
+
+ FX_DWORD m_nHashTableSize;
+
+ int m_nCount;
+
+ CAssoc* m_pFreeList;
+
+ struct CFX_Plex* m_pBlocks;
+
+ int m_nBlockSize;
+
+ CAssoc* NewAssoc();
+
+ void FreeAssoc(CAssoc* pAssoc);
+
+ CAssoc* GetAssocAt(FX_BSTR key, FX_DWORD& hash) const;
+public:
+
+ ~CFX_MapByteStringToPtr();
+};
+class CFX_CMapByteStringToPtr : public CFX_Object
+{
+public:
+
+ CFX_CMapByteStringToPtr(IFX_Allocator* pAllocator = NULL);
+
+ ~CFX_CMapByteStringToPtr();
+
+ void RemoveAll();
+
+ FX_POSITION GetStartPosition() const;
+
+ void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
+
+ FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
+
+ FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
+
+ void SetAt(FX_BSTR key, void* value);
+
+ void RemoveKey(FX_BSTR key);
+
+ int GetCount() const;
+
+ void AddValue(FX_BSTR key, void* pValue);
+private:
+
+ CFX_BaseSegmentedArray m_Buffer;
+};
+class CFX_PtrList : public CFX_Object
+{
+protected:
+
+ struct CNode {
+
+ CNode* pNext;
+
+ CNode* pPrev;
+
+ void* data;
+ };
+public:
+
+ CFX_PtrList(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
+
+ FX_POSITION GetHeadPosition() const
+ {
+ return (FX_POSITION)m_pNodeHead;
+ }
+
+ FX_POSITION GetTailPosition() const
+ {
+ return (FX_POSITION)m_pNodeTail;
+ }
+
+ void* GetNext(FX_POSITION& rPosition) const
+ {
+ CNode* pNode = (CNode*) rPosition;
+ rPosition = (FX_POSITION) pNode->pNext;
+ return pNode->data;
+ }
+
+ void* GetPrev(FX_POSITION& rPosition) const
+ {
+ CNode* pNode = (CNode*) rPosition;
+ rPosition = (FX_POSITION) pNode->pPrev;
+ return pNode->data;
+ }
+
+ FX_POSITION GetNextPosition(FX_POSITION pos) const
+ {
+ return ((CNode*)pos)->pNext;
+ }
+
+ FX_POSITION GetPrevPosition(FX_POSITION pos) const
+ {
+ return ((CNode*)pos)->pPrev;
+ }
+
+ void* GetAt(FX_POSITION rPosition) const
+ {
+ CNode* pNode = (CNode*) rPosition;
+ return pNode->data;
+ }
+
+ int GetCount() const
+ {
+ return m_nCount;
+ }
+
+ FX_POSITION AddTail(void* newElement);
+
+ FX_POSITION AddHead(void* newElement);
+
+ void SetAt(FX_POSITION pos, void* newElement)
+ {
+ CNode* pNode = (CNode*) pos;
+ pNode->data = newElement;
+ }
+
+ FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
+
+ FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL ) const;
+
+ FX_POSITION FindIndex(int index) const;
+
+ void RemoveAt(FX_POSITION pos);
+
+ void RemoveAll();
+protected:
+
+ IFX_Allocator* m_pAllocator;
+
+ CNode* m_pNodeHead;
+
+ CNode* m_pNodeTail;
+
+ int m_nCount;
+
+ CNode* m_pNodeFree;
+
+ struct CFX_Plex* m_pBlocks;
+
+ int m_nBlockSize;
+
+ CNode* NewNode(CNode* pPrev, CNode* pNext);
+
+ void FreeNode(CNode* pNode);
+public:
+
+ ~CFX_PtrList();
+};
+typedef void (*PD_CALLBACK_FREEDATA)(FX_LPVOID pData);
+struct FX_PRIVATEDATA {
+
+ void FreeData();
+
+ FX_LPVOID m_pModuleId;
+
+ FX_LPVOID m_pData;
+
+ PD_CALLBACK_FREEDATA m_pCallback;
+
+ FX_BOOL m_bSelfDestruct;
+};
+class CFX_PrivateData
+{
+public:
+
+ CFX_PrivateData(IFX_Allocator* pAllocator = NULL) : m_DataList(pAllocator) {}
+
+ ~CFX_PrivateData();
+
+ void ClearAll();
+
+ void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
+
+ void SetPrivateObj(FX_LPVOID module_id, CFX_DestructObject* pObj);
+
+ FX_LPVOID GetPrivateData(FX_LPVOID module_id);
+
+ FX_BOOL LookupPrivateData(FX_LPVOID module_id, FX_LPVOID &pData) const
+ {
+ if (!module_id) {
+ return FALSE;
+ }
+ FX_DWORD nCount = m_DataList.GetSize();
+ for (FX_DWORD n = 0; n < nCount; n ++) {
+ if (m_DataList[n].m_pModuleId == module_id) {
+ pData = m_DataList[n].m_pData;
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+
+ FX_BOOL RemovePrivateData(FX_LPVOID module_id);
+protected:
+
+ CFX_ArrayTemplate<FX_PRIVATEDATA> m_DataList;
+
+ void AddData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct);
+};
+class CFX_BitStream : public CFX_Object
+{
+public:
+
+ void Init(FX_LPCBYTE pData, FX_DWORD dwSize);
+
+
+ FX_DWORD GetBits(FX_DWORD nBits);
+
+ void ByteAlign();
+
+ FX_BOOL IsEOF()
+ {
+ return m_BitPos >= m_BitSize;
+ }
+
+ void SkipBits(FX_DWORD nBits)
+ {
+ m_BitPos += nBits;
+ }
+
+ void Rewind()
+ {
+ m_BitPos = 0;
+ }
+protected:
+
+ FX_DWORD m_BitPos;
+
+ FX_DWORD m_BitSize;
+
+ FX_LPCBYTE m_pData;
+};
+template <class ObjClass> class CFX_CountRef : public CFX_Object
+{
+public:
+
+ typedef CFX_CountRef<ObjClass> Ref;
+
+ class CountedObj : public ObjClass
+ {
+ public:
+
+ CountedObj() {}
+
+ CountedObj(const CountedObj& src) : ObjClass(src) {}
+
+ int m_RefCount;
+ };
+
+ CFX_CountRef()
+ {
+ m_pObject = NULL;
+ }
+
+ CFX_CountRef(const Ref& ref)
+ {
+ m_pObject = ref.m_pObject;
+ if (m_pObject) {
+ m_pObject->m_RefCount ++;
+ }
+ }
+
+ ~CFX_CountRef()
+ {
+ if (!m_pObject) {
+ return;
+ }
+ m_pObject->m_RefCount --;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
+ }
+ }
+
+ ObjClass* New()
+ {
+ if (m_pObject) {
+ m_pObject->m_RefCount --;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
+ }
+ m_pObject = NULL;
+ }
+ m_pObject = FX_NEW CountedObj;
+ if (!m_pObject) {
+ return NULL;
+ }
+ m_pObject->m_RefCount = 1;
+ return m_pObject;
+ }
+
+ void operator = (const Ref& ref)
+ {
+ if (ref.m_pObject) {
+ ref.m_pObject->m_RefCount ++;
+ }
+ if (m_pObject) {
+ m_pObject->m_RefCount --;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
+ }
+ }
+ m_pObject = ref.m_pObject;
+ }
+
+ void operator = (void* p)
+ {
+ FXSYS_assert(p == 0);
+ if (m_pObject == NULL) {
+ return;
+ }
+ m_pObject->m_RefCount --;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
+ }
+ m_pObject = NULL;
+ }
+
+ const ObjClass* GetObject() const
+ {
+ return m_pObject;
+ }
+
+ operator const ObjClass*() const
+ {
+ return m_pObject;
+ }
+
+ FX_BOOL IsNull() const
+ {
+ return m_pObject == NULL;
+ }
+
+ FX_BOOL NotNull() const
+ {
+ return m_pObject != NULL;
+ }
+
+ ObjClass* GetModify()
+ {
+ if (m_pObject == NULL) {
+ m_pObject = FX_NEW CountedObj;
+ if (m_pObject) {
+ m_pObject->m_RefCount = 1;
+ }
+ } else if (m_pObject->m_RefCount > 1) {
+ m_pObject->m_RefCount --;
+ CountedObj* pOldObject = m_pObject;
+ m_pObject = NULL;
+ m_pObject = FX_NEW CountedObj(*pOldObject);
+ if (m_pObject) {
+ m_pObject->m_RefCount = 1;
+ }
+ }
+ return m_pObject;
+ }
+
+ void SetNull()
+ {
+ if (m_pObject == NULL) {
+ return;
+ }
+ m_pObject->m_RefCount --;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
+ }
+ m_pObject = NULL;
+ }
+
+ FX_BOOL operator == (const Ref& ref) const
+ {
+ return m_pObject == ref.m_pObject;
+ }
+protected:
+
+ CountedObj* m_pObject;
+};
+class IFX_Pause
+{
+public:
+
+ virtual FX_BOOL NeedToPauseNow() = 0;
+};
+class CFX_DataFilter : public CFX_Object
+{
+public:
+
+ virtual ~CFX_DataFilter();
+
+ void SetDestFilter(CFX_DataFilter* pFilter);
+
+ FX_BOOL IsEOF() const
+ {
+ return m_bEOF;
+ }
+
+ FX_DWORD GetSrcPos()
+ {
+ return m_SrcPos;
+ }
+
+ void FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
+
+ void FilterFinish(CFX_BinaryBuf& dest_buf);
+protected:
+
+ CFX_DataFilter();
+ virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0;
+ virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0;
+ void ReportEOF(FX_DWORD left_input);
+
+ FX_BOOL m_bEOF;
+
+ FX_DWORD m_SrcPos;
+
+ CFX_DataFilter* m_pDestFilter;
+};
+template <class T>
+class CFX_SmartPointer
+{
+public:
+ CFX_SmartPointer(T *pObj) : m_pObj(pObj) {}
+ ~CFX_SmartPointer()
+ {
+ m_pObj->Release();
+ }
+ operator T*(void)
+ {
+ return m_pObj;
+ }
+ T& operator *(void)
+ {
+ return *m_pObj;
+ }
+ T* operator ->(void)
+ {
+ return m_pObj;
+ }
+protected:
+ T *m_pObj;
+};
+#define FX_DATALIST_LENGTH 1024
+template<size_t unit>
+class CFX_SortListArray : public CFX_Object
+{
+protected:
+
+ struct DataList {
+
+ FX_INT32 start;
+
+ FX_INT32 count;
+ FX_LPBYTE data;
+ };
+public:
+
+ CFX_SortListArray(IFX_Allocator* pAllocator = NULL) : m_CurList(0), m_DataLists(pAllocator) {}
+
+ ~CFX_SortListArray()
+ {
+ Clear();
+ }
+
+
+ void Clear()
+ {
+ IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
+ for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) {
+ DataList list = m_DataLists.ElementAt(i);
+ if (list.data) {
+ FX_Allocator_Free(pAllocator, list.data);
+ }
+ }
+ m_DataLists.RemoveAll();
+ m_CurList = 0;
+ }
+
+ void Append(FX_INT32 nStart, FX_INT32 nCount)
+ {
+ if (nStart < 0) {
+ return;
+ }
+ IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
+ while (nCount > 0) {
+ FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
+ DataList list;
+ list.data = FX_Allocator_Alloc(pAllocator, FX_BYTE, temp_count * unit);
+ if (!list.data) {
+ break;
+ }
+ FXSYS_memset32(list.data, 0, temp_count * unit);
+ list.start = nStart;
+ list.count = temp_count;
+ Append(list);
+ nCount -= temp_count;
+ nStart += temp_count;
+ }
+ }
+
+ FX_LPBYTE GetAt(FX_INT32 nIndex)
+ {
+ if (nIndex < 0) {
+ return NULL;
+ }
+ if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) {
+ return NULL;
+ }
+ DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
+ if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) {
+ pCurList = NULL;
+ FX_INT32 iStart = 0;
+ FX_INT32 iEnd = m_DataLists.GetUpperBound();
+ FX_INT32 iMid = 0;
+ while (iStart <= iEnd) {
+ iMid = (iStart + iEnd) / 2;
+ DataList* list = m_DataLists.GetDataPtr(iMid);
+ if (nIndex < list->start) {
+ iEnd = iMid - 1;
+ } else if (nIndex >= list->start + list->count) {
+ iStart = iMid + 1;
+ } else {
+ pCurList = list;
+ m_CurList = iMid;
+ break;
+ }
+ }
+ }
+ return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL;
+ }
+protected:
+ void Append(const DataList& list)
+ {
+ FX_INT32 iStart = 0;
+ FX_INT32 iEnd = m_DataLists.GetUpperBound();
+ FX_INT32 iFind = 0;
+ while (iStart <= iEnd) {
+ FX_INT32 iMid = (iStart + iEnd) / 2;
+ DataList* cur_list = m_DataLists.GetDataPtr(iMid);
+ if (list.start < cur_list->start + cur_list->count) {
+ iEnd = iMid - 1;
+ } else {
+ if (iMid == iEnd) {
+ iFind = iMid + 1;
+ break;
+ }
+ DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
+ if (list.start < next_list->start) {
+ iFind = iMid + 1;
+ break;
+ } else {
+ iStart = iMid + 1;
+ }
+ }
+ }
+ m_DataLists.InsertAt(iFind, list);
+ }
+ FX_INT32 m_CurList;
+ CFX_ArrayTemplate<DataList> m_DataLists;
+};
+template<typename T1, typename T2>
+class CFX_ListArrayTemplate : public CFX_Object
+{
+public:
+
+ void Clear()
+ {
+ m_Data.Clear();
+ }
+
+ void Add(FX_INT32 nStart, FX_INT32 nCount)
+ {
+ m_Data.Append(nStart, nCount);
+ }
+
+ T2& operator [] (FX_INT32 nIndex)
+ {
+ FX_LPBYTE data = m_Data.GetAt(nIndex);
+ FXSYS_assert(data != NULL);
+ return (T2&)(*(volatile T2*)data);
+ }
+
+ T2* GetPtrAt(FX_INT32 nIndex)
+ {
+ return (T2*)m_Data.GetAt(nIndex);
+ }
+protected:
+ T1 m_Data;
+};
+typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, FX_FILESIZE> CFX_FileSizeListArray;
+typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD> CFX_DWordListArray;
+typedef enum {
+ Ready,
+ ToBeContinued,
+ Found,
+ NotFound,
+ Failed,
+ Done
+} FX_ProgressiveStatus;
+#define ProgressiveStatus FX_ProgressiveStatus
+#define FX_NAMESPACE_DECLARE(namespace, type) namespace::type
+#endif
diff --git a/core/include/fxcrt/fx_coordinates.h b/core/include/fxcrt/fx_coordinates.h
index eee0dfb260..9a63e2a4ad 100644
--- a/core/include/fxcrt/fx_coordinates.h
+++ b/core/include/fxcrt/fx_coordinates.h
@@ -1,900 +1,900 @@
-// 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 _FXCRT_COORDINATES_
-#define _FXCRT_COORDINATES_
-template<class baseType> class CFX_PSVTemplate;
-template<class baseType> class CFX_VTemplate;
-template<class baseType> class CFX_PRLTemplate;
-template<class baseType> class CFX_RTemplate;
-template<class baseType> class CFX_ETemplate;
-template<class baseType> class CFX_ATemplate;
-template<class baseType> class CFX_RRTemplate;
-class CFX_Matrix;
-template<class baseType>
-class CFX_PSVTemplate : public CFX_Object
-{
-public:
- typedef CFX_PSVTemplate<baseType> FXT_PSV;
- typedef CFX_PSVTemplate<baseType> FXT_POINT;
- typedef CFX_PSVTemplate<baseType> FXT_SIZE;
- void Set(baseType x, baseType y)
- {
- FXT_PSV::x = x, FXT_PSV::y = y;
- }
- void Set(const FXT_PSV &psv)
- {
- FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;
- }
- void Add(baseType x, baseType y)
- {
- FXT_PSV::x += x, FXT_PSV::y += y;
- }
- void Subtract(baseType x, baseType y)
- {
- FXT_PSV::x -= x, FXT_PSV::y -= y;
- }
- void Reset()
- {
- FXT_PSV::x = FXT_PSV::y = 0;
- }
- FXT_PSV& operator += (const FXT_PSV &obj)
- {
- x += obj.x;
- y += obj.y;
- return *this;
- }
- FXT_PSV& operator -= (const FXT_PSV &obj)
- {
- x -= obj.x;
- y -= obj.y;
- return *this;
- }
- FXT_PSV& operator *= (baseType lamda)
- {
- x *= lamda;
- y *= lamda;
- return *this;
- }
- FXT_PSV& operator /= (baseType lamda)
- {
- x /= lamda;
- y /= lamda;
- return *this;
- }
- friend FX_BOOL operator == (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- return obj1.x == obj2.x && obj1.y == obj2.y;
- }
- friend FX_BOOL operator != (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- return obj1.x != obj2.x || obj1.y != obj2.y;
- }
- friend FXT_PSV operator + (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- CFX_PSVTemplate obj;
- obj.x = obj1.x + obj2.x;
- obj.y = obj1.y + obj2.y;
- return obj;
- }
- friend FXT_PSV operator - (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- CFX_PSVTemplate obj;
- obj.x = obj1.x - obj2.x;
- obj.y = obj1.y - obj2.y;
- return obj;
- }
- friend FXT_PSV operator * (const FXT_PSV &obj, baseType lamda)
- {
- CFX_PSVTemplate t;
- t.x = obj.x * lamda;
- t.y = obj.y * lamda;
- return t;
- }
- friend FXT_PSV operator * (baseType lamda, const FXT_PSV &obj)
- {
- CFX_PSVTemplate t;
- t.x = lamda * obj.x;
- t.y = lamda * obj.y;
- return t;
- }
- friend FXT_PSV operator / (const FXT_PSV &obj, baseType lamda)
- {
- CFX_PSVTemplate t;
- t.x = obj.x / lamda;
- t.y = obj.y / lamda;
- return t;
- }
- baseType x, y;
-};
-typedef CFX_PSVTemplate<FX_INT32> CFX_Point;
-typedef CFX_PSVTemplate<FX_FLOAT> CFX_PointF;
-typedef CFX_PSVTemplate<FX_INT32> CFX_Size;
-typedef CFX_PSVTemplate<FX_FLOAT> CFX_SizeF;
-typedef CFX_ArrayTemplate<CFX_Point> CFX_Points;
-typedef CFX_ArrayTemplate<CFX_PointF> CFX_PointsF;
-typedef CFX_PSVTemplate<FX_INT32> * FX_LPPOINT;
-typedef CFX_PSVTemplate<FX_FLOAT> * FX_LPPOINTF;
-typedef CFX_PSVTemplate<FX_INT32> const * FX_LPCPOINT;
-typedef CFX_PSVTemplate<FX_FLOAT> const * FX_LPCPOINTF;
-#define CFX_FloatPoint CFX_PointF
-template<class baseType>
-class CFX_VTemplate: public CFX_PSVTemplate<baseType>
-{
-public:
- typedef CFX_PSVTemplate<baseType> FXT_PSV;
- typedef CFX_PSVTemplate<baseType> FXT_POINT;
- typedef CFX_PSVTemplate<baseType> FXT_SIZE;
- typedef CFX_VTemplate<baseType> FXT_VECTOR;
- void Set(baseType x, baseType y)
- {
- FXT_PSV::x = x, FXT_PSV::y = y;
- }
- void Set(const FXT_PSV &psv)
- {
- FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;
- }
- void Set(const FXT_POINT &p1, const FXT_POINT &p2)
- {
- FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;
- }
- void Reset()
- {
- FXT_PSV::x = FXT_PSV::y = 0;
- }
- baseType SquareLength() const
- {
- return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;
- }
- baseType Length() const
- {
- return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
- }
- void Normalize()
- {
- FX_FLOAT fLen = FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
- FXSYS_assert(fLen >= 0.0001f);
- FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
- FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
- }
- baseType DotProduct(baseType x, baseType y) const
- {
- return FXT_PSV::x * x + FXT_PSV::y * y;
- }
- baseType DotProduct(const FXT_VECTOR &v) const
- {
- return FXT_PSV::x * v.x + FXT_PSV::y * v.y;
- }
- FX_BOOL IsParallel(baseType x, baseType y) const
- {
- baseType t = FXT_PSV::x * y - FXT_PSV::y * x;
- return FXSYS_fabs(t) < 0x0001f;
- }
- FX_BOOL IsParallel(const FXT_VECTOR &v) const
- {
- return IsParallel(v.x, v.y);
- }
- FX_BOOL IsPerpendicular(baseType x, baseType y) const
- {
- baseType t = DotProduct(x, y);
- return FXSYS_fabs(t) < 0x0001f;
- }
- FX_BOOL IsPerpendicular(const FXT_VECTOR &v) const
- {
- return IsPerpendicular(v.x, v.y);
- }
- void Translate(baseType dx, baseType dy)
- {
- FXT_PSV::x += dx, FXT_PSV::y += dy;
- }
- void Scale(baseType sx, baseType sy)
- {
- FXT_PSV::x *= sx, FXT_PSV::y *= sy;
- }
- void Rotate(FX_FLOAT fRadian)
- {
- FX_FLOAT xx = (FX_FLOAT)FXT_PSV::x;
- FX_FLOAT yy = (FX_FLOAT)FXT_PSV::y;
- FX_FLOAT cosValue = FXSYS_cos(fRadian);
- FX_FLOAT sinValue = FXSYS_sin(fRadian);
- FXT_PSV::x = xx * cosValue - yy * sinValue;
- FXT_PSV::y = xx * sinValue + yy * cosValue;
- }
- friend FX_FLOAT Cosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
- {
- FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
- FX_FLOAT dotProduct = v1.DotProduct(v2);
- return dotProduct / (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
- }
- friend FX_FLOAT ArcCosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
- {
- return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
- }
- friend FX_FLOAT SlopeAngle(const FXT_VECTOR &v)
- {
- CFX_VTemplate vx;
- vx.Set(1, 0);
- FX_FLOAT fSlope = ArcCosine(v, vx);
- return v.y < 0 ? -fSlope : fSlope;
- }
-};
-typedef CFX_VTemplate<FX_INT32> CFX_Vector;
-typedef CFX_VTemplate<FX_FLOAT> CFX_VectorF;
-template<class baseType>
-class CFX_RTemplate: public CFX_Object
-{
-public:
- typedef CFX_PSVTemplate<baseType> FXT_POINT;
- typedef CFX_PSVTemplate<baseType> FXT_SIZE;
- typedef CFX_VTemplate<baseType> FXT_VECTOR;
- typedef CFX_PRLTemplate<baseType> FXT_PARAL;
- typedef CFX_RTemplate<baseType> FXT_RECT;
- void Set(baseType left, baseType top, baseType width, baseType height)
- {
- FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height;
- }
- void Set(baseType left, baseType top, const FXT_SIZE &size)
- {
- FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);
- }
- void Set(const FXT_POINT &p, baseType width, baseType height)
- {
- TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;
- }
- void Set(const FXT_POINT &p1, const FXT_POINT &p2)
- {
- TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RECT::Normalize();
- }
- void Set(const FXT_POINT &p, const FXT_VECTOR &v)
- {
- TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Normalize();
- }
- void Reset()
- {
- FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;
- }
- FXT_RECT& operator += (const FXT_POINT &p)
- {
- left += p.x, top += p.y;
- return *this;
- }
- FXT_RECT& operator -= (const FXT_POINT &p)
- {
- left -= p.x, top -= p.y;
- return *this;
- }
- baseType right() const
- {
- return left + width;
- }
- baseType bottom() const
- {
- return top + height;
- }
- void Normalize()
- {
- if (width < 0) {
- left += width;
- width = -width;
- }
- if (height < 0) {
- top += height;
- height = -height;
- }
- }
- void Offset(baseType dx, baseType dy)
- {
- left += dx;
- top += dy;
- }
- void Inflate(baseType x, baseType y)
- {
- left -= x;
- width += x * 2;
- top -= y;
- height += y * 2;
- }
- void Inflate(const FXT_POINT &p)
- {
- Inflate(p.x, p.y);
- }
- void Inflate(baseType left, baseType top, baseType right, baseType bottom)
- {
- FXT_RECT::left -= left;
- FXT_RECT::top -= top;
- FXT_RECT::width += left + right;
- FXT_RECT::height += top + bottom;
- }
- void Inflate(const FXT_RECT &rt)
- {
- Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);
- }
- void Deflate(baseType x, baseType y)
- {
- left += x;
- width -= x * 2;
- top += y;
- height -= y * 2;
- }
- void Deflate(const FXT_POINT &p)
- {
- Deflate(p.x, p.y);
- }
- void Deflate(baseType left, baseType top, baseType right, baseType bottom)
- {
- FXT_RECT::left += left;
- FXT_RECT::top += top;
- FXT_RECT::width -= left + right;
- FXT_RECT::height -= top + bottom;
- }
- void Deflate(const FXT_RECT &rt)
- {
- Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);
- }
- FX_BOOL IsEmpty() const
- {
- return width <= 0 || height <= 0;
- }
- FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const
- {
- return width <= fEpsilon || height <= fEpsilon;
- }
- void Empty()
- {
- width = height = 0;
- }
- FX_BOOL Contains(baseType x, baseType y) const
- {
- return x >= left && x < left + width && y >= top && y < top + height;
- }
- FX_BOOL Contains(const FXT_POINT &p) const
- {
- return Contains(p.x, p.y);
- }
- FX_BOOL Contains(const FXT_RECT &rt) const
- {
- return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom();
- }
- baseType Width() const
- {
- return width;
- }
- baseType Height() const
- {
- return height;
- }
- FXT_SIZE Size() const
- {
- FXT_SIZE size;
- size.Set(width, height);
- return size;
- }
- void Size(FXT_SIZE s)
- {
- width = s.x, height = s.y;
- }
- FXT_POINT TopLeft() const
- {
- FXT_POINT p;
- p.x = left;
- p.y = top;
- return p;
- }
- FXT_POINT TopRight() const
- {
- FXT_POINT p;
- p.x = left + width;
- p.y = top;
- return p;
- }
- FXT_POINT BottomLeft() const
- {
- FXT_POINT p;
- p.x = left;
- p.y = top + height;
- return p;
- }
- FXT_POINT BottomRight() const
- {
- FXT_POINT p;
- p.x = left + width;
- p.y = top + height;
- return p;
- }
- void TopLeft(FXT_POINT tl)
- {
- left = tl.x;
- top = tl.y;
- }
- void TopRight(FXT_POINT tr)
- {
- width = tr.x - left;
- top = tr.y;
- }
- void BottomLeft(FXT_POINT bl)
- {
- left = bl.x;
- height = bl.y - top;
- }
- void BottomRight(FXT_POINT br)
- {
- width = br.x - left;
- height = br.y - top;
- }
- FXT_POINT Center() const
- {
- FXT_POINT p;
- p.x = left + width / 2;
- p.y = top + height / 2;
- return p;
- }
- void GetParallelogram(FXT_PARAL &pg) const
- {
- pg.x = left, pg.y = top;
- pg.x1 = width, pg.y1 = 0;
- pg.x2 = 0, pg.y2 = height;
- }
- void Union(baseType x, baseType y)
- {
- baseType r = right(), b = bottom();
- if (left > x) {
- left = x;
- }
- if (r < x) {
- r = x;
- }
- if (top > y) {
- top = y;
- }
- if (b < y) {
- b = y;
- }
- width = r - left;
- height = b - top;
- }
- void Union(const FXT_POINT &p)
- {
- Union(p.x, p.y);
- }
- void Union(const FXT_RECT &rt)
- {
- baseType r = right(), b = bottom();
- if (left > rt.left) {
- left = rt.left;
- }
- if (r < rt.right()) {
- r = rt.right();
- }
- if (top > rt.top) {
- top = rt.top;
- }
- if (b < rt.bottom()) {
- b = rt.bottom();
- }
- width = r - left;
- height = b - top;
- }
- void Intersect(const FXT_RECT &rt)
- {
- baseType r = right(), b = bottom();
- if (left < rt.left) {
- left = rt.left;
- }
- if (r > rt.right()) {
- r = rt.right();
- }
- if (top < rt.top) {
- top = rt.top;
- }
- if (b > rt.bottom()) {
- b = rt.bottom();
- }
- width = r - left;
- height = b - top;
- }
- FX_BOOL IntersectWith(const FXT_RECT &rt) const
- {
- FXT_RECT rect = rt;
- rect.Intersect(*this);
- return !rect.IsEmpty();
- }
- FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const
- {
- FXT_RECT rect = rt;
- rect.Intersect(*this);
- return !rect.IsEmpty(fEpsilon);
- }
- friend FX_BOOL operator == (const FXT_RECT &rc1, const FXT_RECT &rc2)
- {
- return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.width && rc1.height == rc2.height;
- }
- friend FX_BOOL operator != (const FXT_RECT &rc1, const FXT_RECT &rc2)
- {
- return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.width || rc1.height != rc2.height;
- }
- baseType left, top;
- baseType width, height;
-};
-typedef CFX_RTemplate<FX_INT32> CFX_Rect;
-typedef CFX_RTemplate<FX_FLOAT> CFX_RectF;
-typedef CFX_RTemplate<FX_INT32> * FX_LPRECT;
-typedef CFX_RTemplate<FX_FLOAT> * FX_LPRECTF;
-typedef CFX_RTemplate<FX_INT32> const * FX_LPCRECT;
-typedef CFX_RTemplate<FX_FLOAT> const * FX_LPCRECTF;
-typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray;
-struct FX_RECT {
-
- int left;
-
- int top;
-
- int right;
-
- int bottom;
-
- FX_RECT() {}
-
- FX_RECT(int left1, int top1, int right1, int bottom1)
- {
- left = left1;
- top = top1;
- right = right1;
- bottom = bottom1;
- }
-
- int Width() const
- {
- return right - left;
- }
-
- int Height() const
- {
- return bottom - top;
- }
-
- FX_BOOL IsEmpty() const
- {
- return right <= left || bottom <= top;
- }
-
- void Normalize();
-
- void Intersect(const FX_RECT& src);
-
- void Intersect(int left1, int top1, int right1, int bottom1)
- {
- Intersect(FX_RECT(left1, top1, right1, bottom1));
- }
-
- void Union(const FX_RECT& other_rect);
-
- FX_BOOL operator == (const FX_RECT& src) const
- {
- return left == src.left && right == src.right && top == src.top && bottom == src.bottom;
- }
-
- void Offset(int dx, int dy)
- {
- left += dx;
- right += dx;
- top += dy;
- bottom += dy;
- }
-
- FX_BOOL Contains(const FX_RECT& other_rect) const
- {
- return other_rect.left >= left && other_rect.right <= right && other_rect.top >= top && other_rect.bottom <= bottom;
- }
-
- FX_BOOL Contains(int x, int y) const
- {
- return x >= left && x < right && y >= top && y < bottom;
- }
-};
-struct FX_SMALL_RECT {
-
- FX_SHORT Left;
-
- FX_SHORT Top;
-
- FX_SHORT Right;
-
- FX_SHORT Bottom;
-};
-class CFX_FloatRect : public CFX_Object
-{
-public:
-
- CFX_FloatRect()
- {
- left = right = bottom = top = 0;
- }
-
- CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
- {
- left = left1;
- bottom = bottom1;
- right = right1;
- top = top1;
- }
-
- CFX_FloatRect(const FX_FLOAT* pArray)
- {
- left = pArray[0];
- bottom = pArray[1];
- right = pArray[2];
- top = pArray[3];
- }
-
- CFX_FloatRect(const FX_RECT& rect);
-
- FX_BOOL IsEmpty() const
- {
- return left >= right || bottom >= top;
- }
-
- void Normalize();
-
- void Reset()
- {
- left = right = bottom = top = 0;
- }
-
- FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
-
- FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
-
- void Transform(const CFX_Matrix* pMatrix);
-
- void Intersect(const CFX_FloatRect& other_rect);
-
- void Union(const CFX_FloatRect& other_rect);
-
- FX_RECT GetInnerRect() const;
-
- FX_RECT GetOutterRect() const;
-
- FX_RECT GetClosestRect() const;
-
- int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
-
- void InitRect(FX_FLOAT x, FX_FLOAT y)
- {
- left = right = x;
- bottom = top = y;
- }
-
- void UpdateRect(FX_FLOAT x, FX_FLOAT y);
-
- FX_FLOAT Width() const
- {
- return right - left;
- }
-
- FX_FLOAT Height() const
- {
- return top - bottom;
- }
-
- void Inflate(FX_FLOAT x, FX_FLOAT y)
- {
- Normalize();
- left -= x;
- right += x;
- bottom -= y;
- top += y;
- }
-
- void Inflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
- {
- Normalize();
- this->left -= left;
- this->bottom -= bottom;
- this->right += right;
- this->top += top;
- }
-
- void Inflate(const CFX_FloatRect &rt)
- {
- Inflate(rt.left, rt.bottom, rt.right, rt.top);
- }
-
- void Deflate(FX_FLOAT x, FX_FLOAT y)
- {
- Normalize();
- left += x;
- right -= x;
- bottom += y;
- top -= y;
- }
-
- void Deflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
- {
- Normalize();
- this->left += left;
- this->bottom += bottom;
- this->right -= right;
- this->top -= top;
- }
-
- void Deflate(const CFX_FloatRect &rt)
- {
- Deflate(rt.left, rt.bottom, rt.right, rt.top);
- }
-
- void Translate(FX_FLOAT e, FX_FLOAT f)
- {
- left += e;
- right += e;
- top += f;
- bottom += f;
- }
-
- static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
-
- FX_FLOAT left;
-
- FX_FLOAT right;
-
- FX_FLOAT bottom;
-
- FX_FLOAT top;
-};
-class CFX_Matrix : public CFX_Object
-{
-public:
-
- CFX_Matrix()
- {
- a = d = 1;
- b = c = e = f = 0;
- }
-
- CFX_Matrix(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1)
- {
- a = a1;
- b = b1;
- c = c1;
- d = d1;
- e = e1;
- f = f1;
- }
-
- void Set(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f);
- void Set(const FX_FLOAT n[6]);
-
- void SetIdentity()
- {
- a = d = 1;
- b = c = e = f = 0;
- }
-
- void SetReverse(const CFX_Matrix &m);
-
- void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = FALSE);
-
- void Concat(const CFX_Matrix &m, FX_BOOL bPrepended = FALSE);
-
- void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
- void Reset()
- {
- SetIdentity();
- }
-
- void Copy(const CFX_Matrix& m)
- {
- *this = m;
- }
-
- FX_BOOL IsIdentity() const
- {
- return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;
- }
- FX_BOOL IsInvertible() const;
-
- FX_BOOL Is90Rotated() const;
-
- FX_BOOL IsScaled() const;
-
- void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
-
- void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended = FALSE)
- {
- Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);
- }
-
- void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE);
-
- void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE);
-
- void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
-
- void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended = FALSE);
-
- void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src);
-
- FX_FLOAT GetXUnit() const;
-
- FX_FLOAT GetYUnit() const;
- void GetUnitRect(CFX_RectF &rect) const;
-
- CFX_FloatRect GetUnitRect() const;
-
- FX_FLOAT GetUnitArea() const;
- FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
- FX_INT32 TransformXDistance(FX_INT32 dx) const;
- FX_FLOAT TransformYDistance(FX_FLOAT dy) const;
- FX_INT32 TransformYDistance(FX_INT32 dy) const;
- FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
- FX_INT32 TransformDistance(FX_INT32 dx, FX_INT32 dy) const;
-
- FX_FLOAT TransformDistance(FX_FLOAT distance) const;
- void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const;
- void TransformPoint(FX_INT32 &x, FX_INT32 &y) const;
- void TransformPoints(CFX_PointF *points, FX_INT32 iCount) const;
- void TransformPoints(CFX_Point *points, FX_INT32 iCount) const;
-
- void Transform(FX_FLOAT& x, FX_FLOAT& y) const
- {
- TransformPoint(x, y);
- }
-
- void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const
- {
- x1 = x, y1 = y;
- TransformPoint(x1, y1);
- }
- void TransformVector(CFX_VectorF &v) const;
- void TransformVector(CFX_Vector &v) const;
- void TransformRect(CFX_RectF &rect) const;
- void TransformRect(CFX_Rect &rect) const;
-
- void TransformRect(FX_FLOAT& left, FX_FLOAT& right, FX_FLOAT& top, FX_FLOAT& bottom) const;
-
- void TransformRect(CFX_FloatRect& rect) const
- {
- TransformRect(rect.left, rect.right, rect.top, rect.bottom);
- }
-
- FX_FLOAT GetA() const
- {
- return a;
- }
-
- FX_FLOAT GetB() const
- {
- return b;
- }
-
- FX_FLOAT GetC() const
- {
- return c;
- }
-
- FX_FLOAT GetD() const
- {
- return d;
- }
-
- FX_FLOAT GetE() const
- {
- return e;
- }
-
- FX_FLOAT GetF() const
- {
- return f;
- }
-public:
- FX_FLOAT a;
- FX_FLOAT b;
- FX_FLOAT c;
- FX_FLOAT d;
- FX_FLOAT e;
- FX_FLOAT f;
-};
-#define CFX_AffineMatrix CFX_Matrix
-#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 _FXCRT_COORDINATES_
+#define _FXCRT_COORDINATES_
+template<class baseType> class CFX_PSVTemplate;
+template<class baseType> class CFX_VTemplate;
+template<class baseType> class CFX_PRLTemplate;
+template<class baseType> class CFX_RTemplate;
+template<class baseType> class CFX_ETemplate;
+template<class baseType> class CFX_ATemplate;
+template<class baseType> class CFX_RRTemplate;
+class CFX_Matrix;
+template<class baseType>
+class CFX_PSVTemplate : public CFX_Object
+{
+public:
+ typedef CFX_PSVTemplate<baseType> FXT_PSV;
+ typedef CFX_PSVTemplate<baseType> FXT_POINT;
+ typedef CFX_PSVTemplate<baseType> FXT_SIZE;
+ void Set(baseType x, baseType y)
+ {
+ FXT_PSV::x = x, FXT_PSV::y = y;
+ }
+ void Set(const FXT_PSV &psv)
+ {
+ FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;
+ }
+ void Add(baseType x, baseType y)
+ {
+ FXT_PSV::x += x, FXT_PSV::y += y;
+ }
+ void Subtract(baseType x, baseType y)
+ {
+ FXT_PSV::x -= x, FXT_PSV::y -= y;
+ }
+ void Reset()
+ {
+ FXT_PSV::x = FXT_PSV::y = 0;
+ }
+ FXT_PSV& operator += (const FXT_PSV &obj)
+ {
+ x += obj.x;
+ y += obj.y;
+ return *this;
+ }
+ FXT_PSV& operator -= (const FXT_PSV &obj)
+ {
+ x -= obj.x;
+ y -= obj.y;
+ return *this;
+ }
+ FXT_PSV& operator *= (baseType lamda)
+ {
+ x *= lamda;
+ y *= lamda;
+ return *this;
+ }
+ FXT_PSV& operator /= (baseType lamda)
+ {
+ x /= lamda;
+ y /= lamda;
+ return *this;
+ }
+ friend FX_BOOL operator == (const FXT_PSV &obj1, const FXT_PSV &obj2)
+ {
+ return obj1.x == obj2.x && obj1.y == obj2.y;
+ }
+ friend FX_BOOL operator != (const FXT_PSV &obj1, const FXT_PSV &obj2)
+ {
+ return obj1.x != obj2.x || obj1.y != obj2.y;
+ }
+ friend FXT_PSV operator + (const FXT_PSV &obj1, const FXT_PSV &obj2)
+ {
+ CFX_PSVTemplate obj;
+ obj.x = obj1.x + obj2.x;
+ obj.y = obj1.y + obj2.y;
+ return obj;
+ }
+ friend FXT_PSV operator - (const FXT_PSV &obj1, const FXT_PSV &obj2)
+ {
+ CFX_PSVTemplate obj;
+ obj.x = obj1.x - obj2.x;
+ obj.y = obj1.y - obj2.y;
+ return obj;
+ }
+ friend FXT_PSV operator * (const FXT_PSV &obj, baseType lamda)
+ {
+ CFX_PSVTemplate t;
+ t.x = obj.x * lamda;
+ t.y = obj.y * lamda;
+ return t;
+ }
+ friend FXT_PSV operator * (baseType lamda, const FXT_PSV &obj)
+ {
+ CFX_PSVTemplate t;
+ t.x = lamda * obj.x;
+ t.y = lamda * obj.y;
+ return t;
+ }
+ friend FXT_PSV operator / (const FXT_PSV &obj, baseType lamda)
+ {
+ CFX_PSVTemplate t;
+ t.x = obj.x / lamda;
+ t.y = obj.y / lamda;
+ return t;
+ }
+ baseType x, y;
+};
+typedef CFX_PSVTemplate<FX_INT32> CFX_Point;
+typedef CFX_PSVTemplate<FX_FLOAT> CFX_PointF;
+typedef CFX_PSVTemplate<FX_INT32> CFX_Size;
+typedef CFX_PSVTemplate<FX_FLOAT> CFX_SizeF;
+typedef CFX_ArrayTemplate<CFX_Point> CFX_Points;
+typedef CFX_ArrayTemplate<CFX_PointF> CFX_PointsF;
+typedef CFX_PSVTemplate<FX_INT32> * FX_LPPOINT;
+typedef CFX_PSVTemplate<FX_FLOAT> * FX_LPPOINTF;
+typedef CFX_PSVTemplate<FX_INT32> const * FX_LPCPOINT;
+typedef CFX_PSVTemplate<FX_FLOAT> const * FX_LPCPOINTF;
+#define CFX_FloatPoint CFX_PointF
+template<class baseType>
+class CFX_VTemplate: public CFX_PSVTemplate<baseType>
+{
+public:
+ typedef CFX_PSVTemplate<baseType> FXT_PSV;
+ typedef CFX_PSVTemplate<baseType> FXT_POINT;
+ typedef CFX_PSVTemplate<baseType> FXT_SIZE;
+ typedef CFX_VTemplate<baseType> FXT_VECTOR;
+ void Set(baseType x, baseType y)
+ {
+ FXT_PSV::x = x, FXT_PSV::y = y;
+ }
+ void Set(const FXT_PSV &psv)
+ {
+ FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;
+ }
+ void Set(const FXT_POINT &p1, const FXT_POINT &p2)
+ {
+ FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;
+ }
+ void Reset()
+ {
+ FXT_PSV::x = FXT_PSV::y = 0;
+ }
+ baseType SquareLength() const
+ {
+ return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;
+ }
+ baseType Length() const
+ {
+ return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
+ }
+ void Normalize()
+ {
+ FX_FLOAT fLen = FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
+ FXSYS_assert(fLen >= 0.0001f);
+ FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
+ FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
+ }
+ baseType DotProduct(baseType x, baseType y) const
+ {
+ return FXT_PSV::x * x + FXT_PSV::y * y;
+ }
+ baseType DotProduct(const FXT_VECTOR &v) const
+ {
+ return FXT_PSV::x * v.x + FXT_PSV::y * v.y;
+ }
+ FX_BOOL IsParallel(baseType x, baseType y) const
+ {
+ baseType t = FXT_PSV::x * y - FXT_PSV::y * x;
+ return FXSYS_fabs(t) < 0x0001f;
+ }
+ FX_BOOL IsParallel(const FXT_VECTOR &v) const
+ {
+ return IsParallel(v.x, v.y);
+ }
+ FX_BOOL IsPerpendicular(baseType x, baseType y) const
+ {
+ baseType t = DotProduct(x, y);
+ return FXSYS_fabs(t) < 0x0001f;
+ }
+ FX_BOOL IsPerpendicular(const FXT_VECTOR &v) const
+ {
+ return IsPerpendicular(v.x, v.y);
+ }
+ void Translate(baseType dx, baseType dy)
+ {
+ FXT_PSV::x += dx, FXT_PSV::y += dy;
+ }
+ void Scale(baseType sx, baseType sy)
+ {
+ FXT_PSV::x *= sx, FXT_PSV::y *= sy;
+ }
+ void Rotate(FX_FLOAT fRadian)
+ {
+ FX_FLOAT xx = (FX_FLOAT)FXT_PSV::x;
+ FX_FLOAT yy = (FX_FLOAT)FXT_PSV::y;
+ FX_FLOAT cosValue = FXSYS_cos(fRadian);
+ FX_FLOAT sinValue = FXSYS_sin(fRadian);
+ FXT_PSV::x = xx * cosValue - yy * sinValue;
+ FXT_PSV::y = xx * sinValue + yy * cosValue;
+ }
+ friend FX_FLOAT Cosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
+ {
+ FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
+ FX_FLOAT dotProduct = v1.DotProduct(v2);
+ return dotProduct / (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
+ }
+ friend FX_FLOAT ArcCosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
+ {
+ return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
+ }
+ friend FX_FLOAT SlopeAngle(const FXT_VECTOR &v)
+ {
+ CFX_VTemplate vx;
+ vx.Set(1, 0);
+ FX_FLOAT fSlope = ArcCosine(v, vx);
+ return v.y < 0 ? -fSlope : fSlope;
+ }
+};
+typedef CFX_VTemplate<FX_INT32> CFX_Vector;
+typedef CFX_VTemplate<FX_FLOAT> CFX_VectorF;
+template<class baseType>
+class CFX_RTemplate: public CFX_Object
+{
+public:
+ typedef CFX_PSVTemplate<baseType> FXT_POINT;
+ typedef CFX_PSVTemplate<baseType> FXT_SIZE;
+ typedef CFX_VTemplate<baseType> FXT_VECTOR;
+ typedef CFX_PRLTemplate<baseType> FXT_PARAL;
+ typedef CFX_RTemplate<baseType> FXT_RECT;
+ void Set(baseType left, baseType top, baseType width, baseType height)
+ {
+ FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height;
+ }
+ void Set(baseType left, baseType top, const FXT_SIZE &size)
+ {
+ FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);
+ }
+ void Set(const FXT_POINT &p, baseType width, baseType height)
+ {
+ TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;
+ }
+ void Set(const FXT_POINT &p1, const FXT_POINT &p2)
+ {
+ TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RECT::Normalize();
+ }
+ void Set(const FXT_POINT &p, const FXT_VECTOR &v)
+ {
+ TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Normalize();
+ }
+ void Reset()
+ {
+ FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;
+ }
+ FXT_RECT& operator += (const FXT_POINT &p)
+ {
+ left += p.x, top += p.y;
+ return *this;
+ }
+ FXT_RECT& operator -= (const FXT_POINT &p)
+ {
+ left -= p.x, top -= p.y;
+ return *this;
+ }
+ baseType right() const
+ {
+ return left + width;
+ }
+ baseType bottom() const
+ {
+ return top + height;
+ }
+ void Normalize()
+ {
+ if (width < 0) {
+ left += width;
+ width = -width;
+ }
+ if (height < 0) {
+ top += height;
+ height = -height;
+ }
+ }
+ void Offset(baseType dx, baseType dy)
+ {
+ left += dx;
+ top += dy;
+ }
+ void Inflate(baseType x, baseType y)
+ {
+ left -= x;
+ width += x * 2;
+ top -= y;
+ height += y * 2;
+ }
+ void Inflate(const FXT_POINT &p)
+ {
+ Inflate(p.x, p.y);
+ }
+ void Inflate(baseType left, baseType top, baseType right, baseType bottom)
+ {
+ FXT_RECT::left -= left;
+ FXT_RECT::top -= top;
+ FXT_RECT::width += left + right;
+ FXT_RECT::height += top + bottom;
+ }
+ void Inflate(const FXT_RECT &rt)
+ {
+ Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);
+ }
+ void Deflate(baseType x, baseType y)
+ {
+ left += x;
+ width -= x * 2;
+ top += y;
+ height -= y * 2;
+ }
+ void Deflate(const FXT_POINT &p)
+ {
+ Deflate(p.x, p.y);
+ }
+ void Deflate(baseType left, baseType top, baseType right, baseType bottom)
+ {
+ FXT_RECT::left += left;
+ FXT_RECT::top += top;
+ FXT_RECT::width -= left + right;
+ FXT_RECT::height -= top + bottom;
+ }
+ void Deflate(const FXT_RECT &rt)
+ {
+ Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);
+ }
+ FX_BOOL IsEmpty() const
+ {
+ return width <= 0 || height <= 0;
+ }
+ FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const
+ {
+ return width <= fEpsilon || height <= fEpsilon;
+ }
+ void Empty()
+ {
+ width = height = 0;
+ }
+ FX_BOOL Contains(baseType x, baseType y) const
+ {
+ return x >= left && x < left + width && y >= top && y < top + height;
+ }
+ FX_BOOL Contains(const FXT_POINT &p) const
+ {
+ return Contains(p.x, p.y);
+ }
+ FX_BOOL Contains(const FXT_RECT &rt) const
+ {
+ return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom();
+ }
+ baseType Width() const
+ {
+ return width;
+ }
+ baseType Height() const
+ {
+ return height;
+ }
+ FXT_SIZE Size() const
+ {
+ FXT_SIZE size;
+ size.Set(width, height);
+ return size;
+ }
+ void Size(FXT_SIZE s)
+ {
+ width = s.x, height = s.y;
+ }
+ FXT_POINT TopLeft() const
+ {
+ FXT_POINT p;
+ p.x = left;
+ p.y = top;
+ return p;
+ }
+ FXT_POINT TopRight() const
+ {
+ FXT_POINT p;
+ p.x = left + width;
+ p.y = top;
+ return p;
+ }
+ FXT_POINT BottomLeft() const
+ {
+ FXT_POINT p;
+ p.x = left;
+ p.y = top + height;
+ return p;
+ }
+ FXT_POINT BottomRight() const
+ {
+ FXT_POINT p;
+ p.x = left + width;
+ p.y = top + height;
+ return p;
+ }
+ void TopLeft(FXT_POINT tl)
+ {
+ left = tl.x;
+ top = tl.y;
+ }
+ void TopRight(FXT_POINT tr)
+ {
+ width = tr.x - left;
+ top = tr.y;
+ }
+ void BottomLeft(FXT_POINT bl)
+ {
+ left = bl.x;
+ height = bl.y - top;
+ }
+ void BottomRight(FXT_POINT br)
+ {
+ width = br.x - left;
+ height = br.y - top;
+ }
+ FXT_POINT Center() const
+ {
+ FXT_POINT p;
+ p.x = left + width / 2;
+ p.y = top + height / 2;
+ return p;
+ }
+ void GetParallelogram(FXT_PARAL &pg) const
+ {
+ pg.x = left, pg.y = top;
+ pg.x1 = width, pg.y1 = 0;
+ pg.x2 = 0, pg.y2 = height;
+ }
+ void Union(baseType x, baseType y)
+ {
+ baseType r = right(), b = bottom();
+ if (left > x) {
+ left = x;
+ }
+ if (r < x) {
+ r = x;
+ }
+ if (top > y) {
+ top = y;
+ }
+ if (b < y) {
+ b = y;
+ }
+ width = r - left;
+ height = b - top;
+ }
+ void Union(const FXT_POINT &p)
+ {
+ Union(p.x, p.y);
+ }
+ void Union(const FXT_RECT &rt)
+ {
+ baseType r = right(), b = bottom();
+ if (left > rt.left) {
+ left = rt.left;
+ }
+ if (r < rt.right()) {
+ r = rt.right();
+ }
+ if (top > rt.top) {
+ top = rt.top;
+ }
+ if (b < rt.bottom()) {
+ b = rt.bottom();
+ }
+ width = r - left;
+ height = b - top;
+ }
+ void Intersect(const FXT_RECT &rt)
+ {
+ baseType r = right(), b = bottom();
+ if (left < rt.left) {
+ left = rt.left;
+ }
+ if (r > rt.right()) {
+ r = rt.right();
+ }
+ if (top < rt.top) {
+ top = rt.top;
+ }
+ if (b > rt.bottom()) {
+ b = rt.bottom();
+ }
+ width = r - left;
+ height = b - top;
+ }
+ FX_BOOL IntersectWith(const FXT_RECT &rt) const
+ {
+ FXT_RECT rect = rt;
+ rect.Intersect(*this);
+ return !rect.IsEmpty();
+ }
+ FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const
+ {
+ FXT_RECT rect = rt;
+ rect.Intersect(*this);
+ return !rect.IsEmpty(fEpsilon);
+ }
+ friend FX_BOOL operator == (const FXT_RECT &rc1, const FXT_RECT &rc2)
+ {
+ return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.width && rc1.height == rc2.height;
+ }
+ friend FX_BOOL operator != (const FXT_RECT &rc1, const FXT_RECT &rc2)
+ {
+ return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.width || rc1.height != rc2.height;
+ }
+ baseType left, top;
+ baseType width, height;
+};
+typedef CFX_RTemplate<FX_INT32> CFX_Rect;
+typedef CFX_RTemplate<FX_FLOAT> CFX_RectF;
+typedef CFX_RTemplate<FX_INT32> * FX_LPRECT;
+typedef CFX_RTemplate<FX_FLOAT> * FX_LPRECTF;
+typedef CFX_RTemplate<FX_INT32> const * FX_LPCRECT;
+typedef CFX_RTemplate<FX_FLOAT> const * FX_LPCRECTF;
+typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray;
+struct FX_RECT {
+
+ int left;
+
+ int top;
+
+ int right;
+
+ int bottom;
+
+ FX_RECT() {}
+
+ FX_RECT(int left1, int top1, int right1, int bottom1)
+ {
+ left = left1;
+ top = top1;
+ right = right1;
+ bottom = bottom1;
+ }
+
+ int Width() const
+ {
+ return right - left;
+ }
+
+ int Height() const
+ {
+ return bottom - top;
+ }
+
+ FX_BOOL IsEmpty() const
+ {
+ return right <= left || bottom <= top;
+ }
+
+ void Normalize();
+
+ void Intersect(const FX_RECT& src);
+
+ void Intersect(int left1, int top1, int right1, int bottom1)
+ {
+ Intersect(FX_RECT(left1, top1, right1, bottom1));
+ }
+
+ void Union(const FX_RECT& other_rect);
+
+ FX_BOOL operator == (const FX_RECT& src) const
+ {
+ return left == src.left && right == src.right && top == src.top && bottom == src.bottom;
+ }
+
+ void Offset(int dx, int dy)
+ {
+ left += dx;
+ right += dx;
+ top += dy;
+ bottom += dy;
+ }
+
+ FX_BOOL Contains(const FX_RECT& other_rect) const
+ {
+ return other_rect.left >= left && other_rect.right <= right && other_rect.top >= top && other_rect.bottom <= bottom;
+ }
+
+ FX_BOOL Contains(int x, int y) const
+ {
+ return x >= left && x < right && y >= top && y < bottom;
+ }
+};
+struct FX_SMALL_RECT {
+
+ FX_SHORT Left;
+
+ FX_SHORT Top;
+
+ FX_SHORT Right;
+
+ FX_SHORT Bottom;
+};
+class CFX_FloatRect : public CFX_Object
+{
+public:
+
+ CFX_FloatRect()
+ {
+ left = right = bottom = top = 0;
+ }
+
+ CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
+ {
+ left = left1;
+ bottom = bottom1;
+ right = right1;
+ top = top1;
+ }
+
+ CFX_FloatRect(const FX_FLOAT* pArray)
+ {
+ left = pArray[0];
+ bottom = pArray[1];
+ right = pArray[2];
+ top = pArray[3];
+ }
+
+ CFX_FloatRect(const FX_RECT& rect);
+
+ FX_BOOL IsEmpty() const
+ {
+ return left >= right || bottom >= top;
+ }
+
+ void Normalize();
+
+ void Reset()
+ {
+ left = right = bottom = top = 0;
+ }
+
+ FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
+
+ FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
+
+ void Transform(const CFX_Matrix* pMatrix);
+
+ void Intersect(const CFX_FloatRect& other_rect);
+
+ void Union(const CFX_FloatRect& other_rect);
+
+ FX_RECT GetInnerRect() const;
+
+ FX_RECT GetOutterRect() const;
+
+ FX_RECT GetClosestRect() const;
+
+ int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
+
+ void InitRect(FX_FLOAT x, FX_FLOAT y)
+ {
+ left = right = x;
+ bottom = top = y;
+ }
+
+ void UpdateRect(FX_FLOAT x, FX_FLOAT y);
+
+ FX_FLOAT Width() const
+ {
+ return right - left;
+ }
+
+ FX_FLOAT Height() const
+ {
+ return top - bottom;
+ }
+
+ void Inflate(FX_FLOAT x, FX_FLOAT y)
+ {
+ Normalize();
+ left -= x;
+ right += x;
+ bottom -= y;
+ top += y;
+ }
+
+ void Inflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
+ {
+ Normalize();
+ this->left -= left;
+ this->bottom -= bottom;
+ this->right += right;
+ this->top += top;
+ }
+
+ void Inflate(const CFX_FloatRect &rt)
+ {
+ Inflate(rt.left, rt.bottom, rt.right, rt.top);
+ }
+
+ void Deflate(FX_FLOAT x, FX_FLOAT y)
+ {
+ Normalize();
+ left += x;
+ right -= x;
+ bottom += y;
+ top -= y;
+ }
+
+ void Deflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
+ {
+ Normalize();
+ this->left += left;
+ this->bottom += bottom;
+ this->right -= right;
+ this->top -= top;
+ }
+
+ void Deflate(const CFX_FloatRect &rt)
+ {
+ Deflate(rt.left, rt.bottom, rt.right, rt.top);
+ }
+
+ void Translate(FX_FLOAT e, FX_FLOAT f)
+ {
+ left += e;
+ right += e;
+ top += f;
+ bottom += f;
+ }
+
+ static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
+
+ FX_FLOAT left;
+
+ FX_FLOAT right;
+
+ FX_FLOAT bottom;
+
+ FX_FLOAT top;
+};
+class CFX_Matrix : public CFX_Object
+{
+public:
+
+ CFX_Matrix()
+ {
+ a = d = 1;
+ b = c = e = f = 0;
+ }
+
+ CFX_Matrix(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1)
+ {
+ a = a1;
+ b = b1;
+ c = c1;
+ d = d1;
+ e = e1;
+ f = f1;
+ }
+
+ void Set(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f);
+ void Set(const FX_FLOAT n[6]);
+
+ void SetIdentity()
+ {
+ a = d = 1;
+ b = c = e = f = 0;
+ }
+
+ void SetReverse(const CFX_Matrix &m);
+
+ void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = FALSE);
+
+ void Concat(const CFX_Matrix &m, FX_BOOL bPrepended = FALSE);
+
+ void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
+ void Reset()
+ {
+ SetIdentity();
+ }
+
+ void Copy(const CFX_Matrix& m)
+ {
+ *this = m;
+ }
+
+ FX_BOOL IsIdentity() const
+ {
+ return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;
+ }
+ FX_BOOL IsInvertible() const;
+
+ FX_BOOL Is90Rotated() const;
+
+ FX_BOOL IsScaled() const;
+
+ void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
+
+ void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended = FALSE)
+ {
+ Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);
+ }
+
+ void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE);
+
+ void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE);
+
+ void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
+
+ void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended = FALSE);
+
+ void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src);
+
+ FX_FLOAT GetXUnit() const;
+
+ FX_FLOAT GetYUnit() const;
+ void GetUnitRect(CFX_RectF &rect) const;
+
+ CFX_FloatRect GetUnitRect() const;
+
+ FX_FLOAT GetUnitArea() const;
+ FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
+ FX_INT32 TransformXDistance(FX_INT32 dx) const;
+ FX_FLOAT TransformYDistance(FX_FLOAT dy) const;
+ FX_INT32 TransformYDistance(FX_INT32 dy) const;
+ FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
+ FX_INT32 TransformDistance(FX_INT32 dx, FX_INT32 dy) const;
+
+ FX_FLOAT TransformDistance(FX_FLOAT distance) const;
+ void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const;
+ void TransformPoint(FX_INT32 &x, FX_INT32 &y) const;
+ void TransformPoints(CFX_PointF *points, FX_INT32 iCount) const;
+ void TransformPoints(CFX_Point *points, FX_INT32 iCount) const;
+
+ void Transform(FX_FLOAT& x, FX_FLOAT& y) const
+ {
+ TransformPoint(x, y);
+ }
+
+ void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const
+ {
+ x1 = x, y1 = y;
+ TransformPoint(x1, y1);
+ }
+ void TransformVector(CFX_VectorF &v) const;
+ void TransformVector(CFX_Vector &v) const;
+ void TransformRect(CFX_RectF &rect) const;
+ void TransformRect(CFX_Rect &rect) const;
+
+ void TransformRect(FX_FLOAT& left, FX_FLOAT& right, FX_FLOAT& top, FX_FLOAT& bottom) const;
+
+ void TransformRect(CFX_FloatRect& rect) const
+ {
+ TransformRect(rect.left, rect.right, rect.top, rect.bottom);
+ }
+
+ FX_FLOAT GetA() const
+ {
+ return a;
+ }
+
+ FX_FLOAT GetB() const
+ {
+ return b;
+ }
+
+ FX_FLOAT GetC() const
+ {
+ return c;
+ }
+
+ FX_FLOAT GetD() const
+ {
+ return d;
+ }
+
+ FX_FLOAT GetE() const
+ {
+ return e;
+ }
+
+ FX_FLOAT GetF() const
+ {
+ return f;
+ }
+public:
+ FX_FLOAT a;
+ FX_FLOAT b;
+ FX_FLOAT c;
+ FX_FLOAT d;
+ FX_FLOAT e;
+ FX_FLOAT f;
+};
+#define CFX_AffineMatrix CFX_Matrix
+#endif
diff --git a/core/include/fxcrt/fx_ext.h b/core/include/fxcrt/fx_ext.h
index 7fdbfcd0af..03ec488135 100644
--- a/core/include/fxcrt/fx_ext.h
+++ b/core/include/fxcrt/fx_ext.h
@@ -1,103 +1,103 @@
-// 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 _FXCRT_EXTENSION_
-#define _FXCRT_EXTENSION_
-#ifndef _FX_BASIC_H_
-#include "fx_basic.h"
-#endif
-#ifndef _FXCRT_COORDINATES_
-#include "fx_coordinates.h"
-#endif
-#ifndef _FX_XML_H_
-#include "fx_xml.h"
-#endif
-#ifndef _FX_UNICODE_
-#include "fx_ucd.h"
-#endif
-#ifndef _FX_ARABIC_
-#include "fx_arb.h"
-#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-FX_FLOAT FXSYS_tan(FX_FLOAT a);
-FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x);
-FX_FLOAT FXSYS_strtof(FX_LPCSTR pcsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
-FX_FLOAT FXSYS_wcstof(FX_LPCWSTR pwsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
-FX_LPWSTR FXSYS_wcsncpy(FX_LPWSTR dstStr, FX_LPCWSTR srcStr, size_t count);
-FX_INT32 FXSYS_wcsnicmp(FX_LPCWSTR s1, FX_LPCWSTR s2, size_t count);
-FX_INT32 FXSYS_strnicmp(FX_LPCSTR s1, FX_LPCSTR s2, size_t count);
-inline FX_BOOL FXSYS_islower(FX_INT32 ch)
-{
- return ch >= 'a' && ch <= 'z';
-}
-inline FX_BOOL FXSYS_isupper(FX_INT32 ch)
-{
- return ch >= 'A' && ch <= 'Z';
-}
-inline FX_INT32 FXSYS_tolower(FX_INT32 ch)
-{
- return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20);
-}
-inline FX_INT32 FXSYS_toupper(FX_INT32 ch)
-{
- return ch < 'a' || ch > 'z' ? ch : (ch - 0x20);
-}
-
-
-
-FX_DWORD FX_HashCode_String_GetA(FX_LPCSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE);
-FX_DWORD FX_HashCode_String_GetW(FX_LPCWSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE);
-
-#ifdef __cplusplus
-}
-#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed);
-
-FX_DWORD FX_Random_MT_Generate(FX_LPVOID pContext);
-
-void FX_Random_MT_Close(FX_LPVOID pContext);
-
-void FX_Random_GenerateBase(FX_LPDWORD pBuffer, FX_INT32 iCount);
-
-void FX_Random_GenerateMT(FX_LPDWORD pBuffer, FX_INT32 iCount);
-
-void FX_Random_GenerateCrypto(FX_LPDWORD pBuffer, FX_INT32 iCount);
-#ifdef __cplusplus
-}
-#endif
-template<class baseType>
-class CFX_SSortTemplate
-{
-public:
- void ShellSort(baseType *pArray, FX_INT32 iCount)
- {
- FXSYS_assert(pArray != NULL && iCount > 0);
- FX_INT32 i, j, gap;
- baseType v1, v2;
- gap = iCount >> 1;
- while (gap > 0) {
- for (i = gap; i < iCount; i ++) {
- j = i - gap;
- v1 = pArray[i];
- while (j > -1 && (v2 = pArray[j]) > v1) {
- pArray[j + gap] = v2;
- j -= gap;
- }
- pArray[j + gap] = v1;
- }
- gap >>= 1;
- }
- }
-};
-#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 _FXCRT_EXTENSION_
+#define _FXCRT_EXTENSION_
+#ifndef _FX_BASIC_H_
+#include "fx_basic.h"
+#endif
+#ifndef _FXCRT_COORDINATES_
+#include "fx_coordinates.h"
+#endif
+#ifndef _FX_XML_H_
+#include "fx_xml.h"
+#endif
+#ifndef _FX_UNICODE_
+#include "fx_ucd.h"
+#endif
+#ifndef _FX_ARABIC_
+#include "fx_arb.h"
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+FX_FLOAT FXSYS_tan(FX_FLOAT a);
+FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x);
+FX_FLOAT FXSYS_strtof(FX_LPCSTR pcsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
+FX_FLOAT FXSYS_wcstof(FX_LPCWSTR pwsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
+FX_LPWSTR FXSYS_wcsncpy(FX_LPWSTR dstStr, FX_LPCWSTR srcStr, size_t count);
+FX_INT32 FXSYS_wcsnicmp(FX_LPCWSTR s1, FX_LPCWSTR s2, size_t count);
+FX_INT32 FXSYS_strnicmp(FX_LPCSTR s1, FX_LPCSTR s2, size_t count);
+inline FX_BOOL FXSYS_islower(FX_INT32 ch)
+{
+ return ch >= 'a' && ch <= 'z';
+}
+inline FX_BOOL FXSYS_isupper(FX_INT32 ch)
+{
+ return ch >= 'A' && ch <= 'Z';
+}
+inline FX_INT32 FXSYS_tolower(FX_INT32 ch)
+{
+ return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20);
+}
+inline FX_INT32 FXSYS_toupper(FX_INT32 ch)
+{
+ return ch < 'a' || ch > 'z' ? ch : (ch - 0x20);
+}
+
+
+
+FX_DWORD FX_HashCode_String_GetA(FX_LPCSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE);
+FX_DWORD FX_HashCode_String_GetW(FX_LPCWSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE);
+
+#ifdef __cplusplus
+}
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed);
+
+FX_DWORD FX_Random_MT_Generate(FX_LPVOID pContext);
+
+void FX_Random_MT_Close(FX_LPVOID pContext);
+
+void FX_Random_GenerateBase(FX_LPDWORD pBuffer, FX_INT32 iCount);
+
+void FX_Random_GenerateMT(FX_LPDWORD pBuffer, FX_INT32 iCount);
+
+void FX_Random_GenerateCrypto(FX_LPDWORD pBuffer, FX_INT32 iCount);
+#ifdef __cplusplus
+}
+#endif
+template<class baseType>
+class CFX_SSortTemplate
+{
+public:
+ void ShellSort(baseType *pArray, FX_INT32 iCount)
+ {
+ FXSYS_assert(pArray != NULL && iCount > 0);
+ FX_INT32 i, j, gap;
+ baseType v1, v2;
+ gap = iCount >> 1;
+ while (gap > 0) {
+ for (i = gap; i < iCount; i ++) {
+ j = i - gap;
+ v1 = pArray[i];
+ while (j > -1 && (v2 = pArray[j]) > v1) {
+ pArray[j + gap] = v2;
+ j -= gap;
+ }
+ pArray[j + gap] = v1;
+ }
+ gap >>= 1;
+ }
+ }
+};
+#endif
diff --git a/core/include/fxcrt/fx_memory.h b/core/include/fxcrt/fx_memory.h
index b0c94c4c73..cf795fa869 100644
--- a/core/include/fxcrt/fx_memory.h
+++ b/core/include/fxcrt/fx_memory.h
@@ -1,300 +1,300 @@
-// 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 _FX_MEMORY_H_
-#define _FX_MEMORY_H_
-#ifndef _FX_SYSTEM_H_
-#include "fx_system.h"
-#endif
-#define FXMEM_NONLEAVE 1
-#define FXMEM_MOVABLE 2
-#define FXMEM_DISCARDABLE 4
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef struct _FXMEM_SystemMgr {
-
- void* (*Alloc)(struct _FXMEM_SystemMgr* pMgr, size_t size, int flags);
-
- void* (*AllocDebug)(struct _FXMEM_SystemMgr* pMgr, size_t size, int flags, FX_LPCSTR file, int line);
-
- void* (*Realloc)(struct _FXMEM_SystemMgr* pMgr, void* pointer, size_t size, int flags);
-
- void* (*ReallocDebug)(struct _FXMEM_SystemMgr* pMgr, void* pointer, size_t size, int flags, FX_LPCSTR file, int line);
-
- void* (*Lock)(struct _FXMEM_SystemMgr* pMgr, void* handle);
-
- void (*Unlock)(struct _FXMEM_SystemMgr* pMgr, void* handle);
-
- void (*Free)(struct _FXMEM_SystemMgr* pMgr, void* pointer, int flags);
-
- void (*Purge)(struct _FXMEM_SystemMgr* pMgr);
-
- void (*CollectAll)(struct _FXMEM_SystemMgr* pMgr);
-
-
- void* user;
-} FXMEM_SystemMgr;
-FX_DEFINEHANDLE(FXMEM_FoxitMgr)
-typedef struct _FXMEM_SystemMgr2 {
-
- FX_BOOL (*More)(struct _FXMEM_SystemMgr2* pMgr, size_t alloc_size, void** new_memory, size_t* new_size);
-
- void (*Free)(struct _FXMEM_SystemMgr2* pMgr, void* memory);
-} FXMEM_SystemMgr2;
-FXMEM_FoxitMgr* FXMEM_CreateMemoryMgr(size_t size, FX_BOOL extensible);
-void FXMEM_DestroyFoxitMgr(FXMEM_FoxitMgr* pFoxitMgr);
-void* FXMEM_DefaultAlloc(size_t byte_size, int flags);
-void* FXMEM_DefaultAlloc2(size_t units, size_t unit_size, int flags);
-void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags);
-void* FXMEM_DefaultRealloc2(void* pointer, size_t units, size_t unit_size, int flags);
-void FXMEM_DefaultFree(void* pointer, int flags);
-#define FX_Alloc(type, size) (type*)FXMEM_DefaultAlloc2(size, sizeof(type), 0)
-#define FX_Realloc(type, ptr, size) (type*)FXMEM_DefaultRealloc2(ptr, size, sizeof(type), 0)
-#define FX_AllocNL(type, size) (type*)FXMEM_DefaultAlloc2(size, sizeof(type), FXMEM_NONLEAVE)
-#define FX_ReallocNL(type, ptr, size) (type*)FXMEM_DefaultRealloc2(ptr, size, sizeof(type), FXMEM_NONLEAVE)
-#define FX_Free(pointer) FXMEM_DefaultFree(pointer, 0)
-#ifdef __cplusplus
-}
-#endif
-#ifdef __cplusplus
-#if defined(_DEBUG)
-#define FX_NEW new(__FILE__, __LINE__)
-#else
-
-#define FX_NEW new
-#endif
-class CFX_Object
-{
-public:
-
- void* operator new (size_t size, FX_LPCSTR file, int line);
-
- void operator delete (void* p, FX_LPCSTR file, int line);
-
- void* operator new (size_t size);
-
- void operator delete (void* p);
-
- void* operator new[] (size_t size, FX_LPCSTR file, int line);
-
- void operator delete[] (void* p, FX_LPCSTR file, int line);
-
- void* operator new[] (size_t size);
-
- void operator delete[] (void* p);
-
- void* operator new (size_t, void* buf)
- {
- return buf;
- }
-
- void operator delete (void*, void*) {}
-};
-#define FX_NEW_VECTOR(Pointer, Class, Count) \
- { \
- Pointer = FX_Alloc(Class, Count); \
- if (Pointer) { \
- for (int i = 0; i < (Count); i ++) new (Pointer + i) Class; \
- } \
- }
-#define FX_DELETE_VECTOR(Pointer, Class, Count) \
- { \
- for (int i = 0; i < (Count); i ++) Pointer[i].~Class(); \
- FX_Free(Pointer); \
- }
-class CFX_DestructObject : public CFX_Object
-{
-public:
-
- virtual ~CFX_DestructObject() {}
-};
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef struct _IFX_Allocator {
-
- void* (*m_AllocDebug)(struct _IFX_Allocator* pAllocator, size_t size, FX_LPCSTR file, int line);
-
- void* (*m_Alloc)(struct _IFX_Allocator* pAllocator, size_t size);
-
- void* (*m_ReallocDebug)(struct _IFX_Allocator* pAllocator, void* p, size_t size, FX_LPCSTR file, int line);
-
- void* (*m_Realloc)(struct _IFX_Allocator* pAllocator, void* p, size_t size);
-
- void (*m_Free)(struct _IFX_Allocator* pAllocator, void* p);
-} IFX_Allocator;
-IFX_Allocator* FXMEM_GetDefAllocator();
-#ifdef __cplusplus
-}
-#endif
-#ifdef _DEBUG
-
-#define FX_Allocator_Alloc(fxAllocator, type, size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_AllocDebug((fxAllocator), (size) * sizeof(type), __FILE__, __LINE__) : (FX_Alloc(type, size)))
-
-#define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_ReallocDebug((fxAllocator), (ptr), (new_size) * sizeof(type), __FILE__, __LINE__) : (FX_Realloc(type, ptr, new_size)))
-#else
-
-#define FX_Allocator_Alloc(fxAllocator, type, size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_Alloc((fxAllocator), (size) * sizeof(type)) : (FX_Alloc(type, size)))
-
-#define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_Realloc((fxAllocator), (ptr), (new_size) * sizeof(type)) : (FX_Realloc(type, ptr, new_size)))
-#endif
-#define FX_Allocator_Free(fxAllocator, ptr) \
- ((fxAllocator) ? (fxAllocator)->m_Free((fxAllocator), (ptr)) : (FX_Free(ptr)))
-inline void* operator new(size_t size, IFX_Allocator* fxAllocator)
-{
- return (void*)FX_Allocator_Alloc(fxAllocator, FX_BYTE, size);
-}
-inline void operator delete(void* ptr, IFX_Allocator* fxAllocator)
-{
-}
-#define FX_NewAtAllocator(fxAllocator) \
- ::new(fxAllocator)
-#define FX_DeleteAtAllocator(pointer, fxAllocator, __class__) \
- (pointer)->~__class__(); \
- FX_Allocator_Free(fxAllocator, pointer)
-class CFX_AllocObject
-{
-public:
-
- void* operator new (size_t size, IFX_Allocator* pAllocator, FX_LPCSTR file, int line);
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete (void* p, IFX_Allocator* pAllocator, FX_LPCSTR file, int line);
-#endif
-
- void* operator new (size_t size, IFX_Allocator* pAllocator);
-
- void operator delete (void* p);
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete (void* p, IFX_Allocator* pAllocator);
-#endif
-
- void* operator new (size_t, void* buf)
- {
- return buf;
- }
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete (void*, void*) {}
-#endif
-
- IFX_Allocator* GetAllocator() const
- {
- return m_pAllocator;
- }
-private:
-
- void* operator new[] (size_t size, IFX_Allocator* pAllocator, FX_LPCSTR file, int line)
- {
- return operator new(size, pAllocator, file, line);
- }
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete[] (void* p, IFX_Allocator* pAllocator, FX_LPCSTR file, int line) {}
-#endif
-
- void* operator new[] (size_t size, IFX_Allocator* pAllocator)
- {
- return operator new(size, pAllocator);
- }
-
- void operator delete[] (void* p) {}
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete[] (void* p, IFX_Allocator* pAllocator) {}
-#endif
-protected:
-
- IFX_Allocator* m_pAllocator;
-};
-#if defined(_DEBUG)
-#define FX_NEWAT(pAllocator) new(pAllocator, __FILE__, __LINE__)
-#else
-
-#define FX_NEWAT(pAllocator) new(pAllocator)
-#endif
-class CFX_GrowOnlyPool : public IFX_Allocator, public CFX_Object
-{
-public:
-
- CFX_GrowOnlyPool(IFX_Allocator* pAllocator = NULL, size_t trunk_size = 16384);
-
- ~CFX_GrowOnlyPool();
-
- void SetAllocator(IFX_Allocator* pAllocator);
-
- void SetTrunkSize(size_t trunk_size)
- {
- m_TrunkSize = trunk_size;
- }
-
- void* AllocDebug(size_t size, FX_LPCSTR file, int line)
- {
- return Alloc(size);
- }
-
- void* Alloc(size_t size);
-
- void* ReallocDebug(void* p, size_t new_size, FX_LPCSTR file, int line)
- {
- return NULL;
- }
-
- void* Realloc(void* p, size_t new_size)
- {
- return NULL;
- }
-
- void Free(void*) {}
-
- void FreeAll();
-private:
-
- size_t m_TrunkSize;
-
- void* m_pFirstTrunk;
-
- IFX_Allocator* m_pAllocator;
-};
-#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define FX_FIXEDMEM_PAGESIZE (4096 * 16)
-#define FX_FIXEDMEM_MIDBLOCKSIZE (4096)
-typedef struct _FX_MEMCONFIG {
-
- size_t nPageNum_Init8;
-
- size_t nPageNum_Init16;
-
- size_t nPageNum_Init32;
-
- size_t nPageNum_More16;
-
- size_t nPageNum_More32;
-
- size_t nPageSize_Mid;
-
- size_t nPageNum_InitMid;
-
- size_t nPageNum_MoreMid;
-
- size_t nPageSize_Large;
-
- size_t nPageSize_Alone;
-} FX_MEMCONFIG;
-void FXMEM_SetConfig(const FX_MEMCONFIG* memConfig);
-#ifdef __cplusplus
-}
-#endif
-#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 _FX_MEMORY_H_
+#define _FX_MEMORY_H_
+#ifndef _FX_SYSTEM_H_
+#include "fx_system.h"
+#endif
+#define FXMEM_NONLEAVE 1
+#define FXMEM_MOVABLE 2
+#define FXMEM_DISCARDABLE 4
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef struct _FXMEM_SystemMgr {
+
+ void* (*Alloc)(struct _FXMEM_SystemMgr* pMgr, size_t size, int flags);
+
+ void* (*AllocDebug)(struct _FXMEM_SystemMgr* pMgr, size_t size, int flags, FX_LPCSTR file, int line);
+
+ void* (*Realloc)(struct _FXMEM_SystemMgr* pMgr, void* pointer, size_t size, int flags);
+
+ void* (*ReallocDebug)(struct _FXMEM_SystemMgr* pMgr, void* pointer, size_t size, int flags, FX_LPCSTR file, int line);
+
+ void* (*Lock)(struct _FXMEM_SystemMgr* pMgr, void* handle);
+
+ void (*Unlock)(struct _FXMEM_SystemMgr* pMgr, void* handle);
+
+ void (*Free)(struct _FXMEM_SystemMgr* pMgr, void* pointer, int flags);
+
+ void (*Purge)(struct _FXMEM_SystemMgr* pMgr);
+
+ void (*CollectAll)(struct _FXMEM_SystemMgr* pMgr);
+
+
+ void* user;
+} FXMEM_SystemMgr;
+FX_DEFINEHANDLE(FXMEM_FoxitMgr)
+typedef struct _FXMEM_SystemMgr2 {
+
+ FX_BOOL (*More)(struct _FXMEM_SystemMgr2* pMgr, size_t alloc_size, void** new_memory, size_t* new_size);
+
+ void (*Free)(struct _FXMEM_SystemMgr2* pMgr, void* memory);
+} FXMEM_SystemMgr2;
+FXMEM_FoxitMgr* FXMEM_CreateMemoryMgr(size_t size, FX_BOOL extensible);
+void FXMEM_DestroyFoxitMgr(FXMEM_FoxitMgr* pFoxitMgr);
+void* FXMEM_DefaultAlloc(size_t byte_size, int flags);
+void* FXMEM_DefaultAlloc2(size_t units, size_t unit_size, int flags);
+void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags);
+void* FXMEM_DefaultRealloc2(void* pointer, size_t units, size_t unit_size, int flags);
+void FXMEM_DefaultFree(void* pointer, int flags);
+#define FX_Alloc(type, size) (type*)FXMEM_DefaultAlloc2(size, sizeof(type), 0)
+#define FX_Realloc(type, ptr, size) (type*)FXMEM_DefaultRealloc2(ptr, size, sizeof(type), 0)
+#define FX_AllocNL(type, size) (type*)FXMEM_DefaultAlloc2(size, sizeof(type), FXMEM_NONLEAVE)
+#define FX_ReallocNL(type, ptr, size) (type*)FXMEM_DefaultRealloc2(ptr, size, sizeof(type), FXMEM_NONLEAVE)
+#define FX_Free(pointer) FXMEM_DefaultFree(pointer, 0)
+#ifdef __cplusplus
+}
+#endif
+#ifdef __cplusplus
+#if defined(_DEBUG)
+#define FX_NEW new(__FILE__, __LINE__)
+#else
+
+#define FX_NEW new
+#endif
+class CFX_Object
+{
+public:
+
+ void* operator new (size_t size, FX_LPCSTR file, int line);
+
+ void operator delete (void* p, FX_LPCSTR file, int line);
+
+ void* operator new (size_t size);
+
+ void operator delete (void* p);
+
+ void* operator new[] (size_t size, FX_LPCSTR file, int line);
+
+ void operator delete[] (void* p, FX_LPCSTR file, int line);
+
+ void* operator new[] (size_t size);
+
+ void operator delete[] (void* p);
+
+ void* operator new (size_t, void* buf)
+ {
+ return buf;
+ }
+
+ void operator delete (void*, void*) {}
+};
+#define FX_NEW_VECTOR(Pointer, Class, Count) \
+ { \
+ Pointer = FX_Alloc(Class, Count); \
+ if (Pointer) { \
+ for (int i = 0; i < (Count); i ++) new (Pointer + i) Class; \
+ } \
+ }
+#define FX_DELETE_VECTOR(Pointer, Class, Count) \
+ { \
+ for (int i = 0; i < (Count); i ++) Pointer[i].~Class(); \
+ FX_Free(Pointer); \
+ }
+class CFX_DestructObject : public CFX_Object
+{
+public:
+
+ virtual ~CFX_DestructObject() {}
+};
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef struct _IFX_Allocator {
+
+ void* (*m_AllocDebug)(struct _IFX_Allocator* pAllocator, size_t size, FX_LPCSTR file, int line);
+
+ void* (*m_Alloc)(struct _IFX_Allocator* pAllocator, size_t size);
+
+ void* (*m_ReallocDebug)(struct _IFX_Allocator* pAllocator, void* p, size_t size, FX_LPCSTR file, int line);
+
+ void* (*m_Realloc)(struct _IFX_Allocator* pAllocator, void* p, size_t size);
+
+ void (*m_Free)(struct _IFX_Allocator* pAllocator, void* p);
+} IFX_Allocator;
+IFX_Allocator* FXMEM_GetDefAllocator();
+#ifdef __cplusplus
+}
+#endif
+#ifdef _DEBUG
+
+#define FX_Allocator_Alloc(fxAllocator, type, size) \
+ ((fxAllocator) ? (type*)(fxAllocator)->m_AllocDebug((fxAllocator), (size) * sizeof(type), __FILE__, __LINE__) : (FX_Alloc(type, size)))
+
+#define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \
+ ((fxAllocator) ? (type*)(fxAllocator)->m_ReallocDebug((fxAllocator), (ptr), (new_size) * sizeof(type), __FILE__, __LINE__) : (FX_Realloc(type, ptr, new_size)))
+#else
+
+#define FX_Allocator_Alloc(fxAllocator, type, size) \
+ ((fxAllocator) ? (type*)(fxAllocator)->m_Alloc((fxAllocator), (size) * sizeof(type)) : (FX_Alloc(type, size)))
+
+#define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \
+ ((fxAllocator) ? (type*)(fxAllocator)->m_Realloc((fxAllocator), (ptr), (new_size) * sizeof(type)) : (FX_Realloc(type, ptr, new_size)))
+#endif
+#define FX_Allocator_Free(fxAllocator, ptr) \
+ ((fxAllocator) ? (fxAllocator)->m_Free((fxAllocator), (ptr)) : (FX_Free(ptr)))
+inline void* operator new(size_t size, IFX_Allocator* fxAllocator)
+{
+ return (void*)FX_Allocator_Alloc(fxAllocator, FX_BYTE, size);
+}
+inline void operator delete(void* ptr, IFX_Allocator* fxAllocator)
+{
+}
+#define FX_NewAtAllocator(fxAllocator) \
+ ::new(fxAllocator)
+#define FX_DeleteAtAllocator(pointer, fxAllocator, __class__) \
+ (pointer)->~__class__(); \
+ FX_Allocator_Free(fxAllocator, pointer)
+class CFX_AllocObject
+{
+public:
+
+ void* operator new (size_t size, IFX_Allocator* pAllocator, FX_LPCSTR file, int line);
+#ifndef _FX_NO_EXCEPTION_
+
+ void operator delete (void* p, IFX_Allocator* pAllocator, FX_LPCSTR file, int line);
+#endif
+
+ void* operator new (size_t size, IFX_Allocator* pAllocator);
+
+ void operator delete (void* p);
+#ifndef _FX_NO_EXCEPTION_
+
+ void operator delete (void* p, IFX_Allocator* pAllocator);
+#endif
+
+ void* operator new (size_t, void* buf)
+ {
+ return buf;
+ }
+#ifndef _FX_NO_EXCEPTION_
+
+ void operator delete (void*, void*) {}
+#endif
+
+ IFX_Allocator* GetAllocator() const
+ {
+ return m_pAllocator;
+ }
+private:
+
+ void* operator new[] (size_t size, IFX_Allocator* pAllocator, FX_LPCSTR file, int line)
+ {
+ return operator new(size, pAllocator, file, line);
+ }
+#ifndef _FX_NO_EXCEPTION_
+
+ void operator delete[] (void* p, IFX_Allocator* pAllocator, FX_LPCSTR file, int line) {}
+#endif
+
+ void* operator new[] (size_t size, IFX_Allocator* pAllocator)
+ {
+ return operator new(size, pAllocator);
+ }
+
+ void operator delete[] (void* p) {}
+#ifndef _FX_NO_EXCEPTION_
+
+ void operator delete[] (void* p, IFX_Allocator* pAllocator) {}
+#endif
+protected:
+
+ IFX_Allocator* m_pAllocator;
+};
+#if defined(_DEBUG)
+#define FX_NEWAT(pAllocator) new(pAllocator, __FILE__, __LINE__)
+#else
+
+#define FX_NEWAT(pAllocator) new(pAllocator)
+#endif
+class CFX_GrowOnlyPool : public IFX_Allocator, public CFX_Object
+{
+public:
+
+ CFX_GrowOnlyPool(IFX_Allocator* pAllocator = NULL, size_t trunk_size = 16384);
+
+ ~CFX_GrowOnlyPool();
+
+ void SetAllocator(IFX_Allocator* pAllocator);
+
+ void SetTrunkSize(size_t trunk_size)
+ {
+ m_TrunkSize = trunk_size;
+ }
+
+ void* AllocDebug(size_t size, FX_LPCSTR file, int line)
+ {
+ return Alloc(size);
+ }
+
+ void* Alloc(size_t size);
+
+ void* ReallocDebug(void* p, size_t new_size, FX_LPCSTR file, int line)
+ {
+ return NULL;
+ }
+
+ void* Realloc(void* p, size_t new_size)
+ {
+ return NULL;
+ }
+
+ void Free(void*) {}
+
+ void FreeAll();
+private:
+
+ size_t m_TrunkSize;
+
+ void* m_pFirstTrunk;
+
+ IFX_Allocator* m_pAllocator;
+};
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define FX_FIXEDMEM_PAGESIZE (4096 * 16)
+#define FX_FIXEDMEM_MIDBLOCKSIZE (4096)
+typedef struct _FX_MEMCONFIG {
+
+ size_t nPageNum_Init8;
+
+ size_t nPageNum_Init16;
+
+ size_t nPageNum_Init32;
+
+ size_t nPageNum_More16;
+
+ size_t nPageNum_More32;
+
+ size_t nPageSize_Mid;
+
+ size_t nPageNum_InitMid;
+
+ size_t nPageNum_MoreMid;
+
+ size_t nPageSize_Large;
+
+ size_t nPageSize_Alone;
+} FX_MEMCONFIG;
+void FXMEM_SetConfig(const FX_MEMCONFIG* memConfig);
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/core/include/fxcrt/fx_stream.h b/core/include/fxcrt/fx_stream.h
index cda5253365..869797f7e9 100644
--- a/core/include/fxcrt/fx_stream.h
+++ b/core/include/fxcrt/fx_stream.h
@@ -1,200 +1,200 @@
-// 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 _FX_STREAM_H_
-#define _FX_STREAM_H_
-#ifndef _FX_MEMORY_H_
-#include "fx_memory.h"
-#endif
-void* FX_OpenFolder(FX_LPCSTR path);
-void* FX_OpenFolder(FX_LPCWSTR path);
-FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder);
-FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder);
-void FX_CloseFolder(void* handle);
-FX_WCHAR FX_GetFolderSeparator();
-FX_DEFINEHANDLE(FX_HFILE)
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define FX_FILESIZE FX_INT32
-#else
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-#ifndef O_LARGEFILE
-#define O_LARGEFILE 0
-#endif
-#define FX_FILESIZE off_t
-#endif
-#define FX_GETBYTEOFFSET32(a) 0
-#define FX_GETBYTEOFFSET40(a) 0
-#define FX_GETBYTEOFFSET48(a) 0
-#define FX_GETBYTEOFFSET56(a) 0
-#define FX_GETBYTEOFFSET24(a) ((FX_BYTE)(a>>24))
-#define FX_GETBYTEOFFSET16(a) ((FX_BYTE)(a>>16))
-#define FX_GETBYTEOFFSET8(a) ((FX_BYTE)(a>>8))
-#define FX_GETBYTEOFFSET0(a) ((FX_BYTE)(a))
-#define FX_FILEMODE_Write 0
-#define FX_FILEMODE_ReadOnly 1
-#define FX_FILEMODE_Truncate 2
-FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
-FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
-void FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator = NULL);
-FX_FILESIZE FX_File_GetSize(FX_HFILE hFile);
-FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile);
-FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos);
-size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer);
-size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
-size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuffer);
-size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
-FX_BOOL FX_File_Flush(FX_HFILE hFile);
-FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile);
-FX_BOOL FX_File_Exist(FX_BSTR fileName);
-FX_BOOL FX_File_Exist(FX_WSTR fileName);
-FX_BOOL FX_File_Delete(FX_BSTR fileName);
-FX_BOOL FX_File_Delete(FX_WSTR fileName);
-FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
-FX_BOOL FX_File_Copy(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
-FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
-FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
-class IFX_StreamWrite
-{
-public:
-
- virtual void Release() = 0;
-
- virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
-};
-class IFX_FileWrite : public IFX_StreamWrite
-{
-public:
-
- virtual void Release() = 0;
-
- virtual FX_FILESIZE GetSize() = 0;
-
- virtual FX_BOOL Flush() = 0;
-
- virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0;
- virtual FX_BOOL WriteBlock(const void* pData, size_t size)
- {
- return WriteBlock(pData, GetSize(), size);
- }
-};
-IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
-IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
-class IFX_StreamRead
-{
-public:
-
- virtual void Release() = 0;
-
- virtual FX_BOOL IsEOF() = 0;
-
- virtual FX_FILESIZE GetPosition() = 0;
-
- virtual size_t ReadBlock(void* buffer, size_t size) = 0;
-};
-class IFX_FileRead : IFX_StreamRead
-{
-public:
-
- virtual void Release() = 0;
-
- virtual FX_FILESIZE GetSize() = 0;
-
- virtual FX_BOOL IsEOF()
- {
- return FALSE;
- }
-
- virtual FX_FILESIZE GetPosition()
- {
- return 0;
- }
-
- virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size)
- {
- return FALSE;
- }
-
- virtual void ClearRange() {}
-
- virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
-
- virtual size_t ReadBlock(void* buffer, size_t size)
- {
- return 0;
- }
-};
-IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
-IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
-class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite
-{
-public:
-
- virtual IFX_FileStream* Retain() = 0;
-
- virtual void Release() = 0;
-
- virtual FX_FILESIZE GetSize() = 0;
-
- virtual FX_BOOL IsEOF() = 0;
-
- virtual FX_FILESIZE GetPosition() = 0;
-
- virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
-
- virtual size_t ReadBlock(void* buffer, size_t size) = 0;
-
- virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0;
- virtual FX_BOOL WriteBlock(const void* buffer, size_t size)
- {
- return WriteBlock(buffer, GetSize(), size);
- }
-
- virtual FX_BOOL Flush() = 0;
-};
-IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
-IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
-class IFX_MemoryStream : public IFX_FileStream
-{
-public:
-
- virtual FX_BOOL IsConsecutive() const = 0;
-
- virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
-
- virtual FX_LPBYTE GetBuffer() const = 0;
-
- virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) = 0;
-
- virtual void DetachBuffer() = 0;
-};
-IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE, IFX_Allocator* pAllocator = NULL);
-IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE, IFX_Allocator* pAllocator = NULL);
-class IFX_BufferRead : public IFX_StreamRead
-{
-public:
-
- virtual void Release() = 0;
-
- virtual FX_BOOL IsEOF() = 0;
-
- virtual FX_FILESIZE GetPosition() = 0;
-
- virtual size_t ReadBlock(void* buffer, size_t size) = 0;
-
- virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
-
- virtual FX_LPCBYTE GetBlockBuffer() = 0;
-
- virtual size_t GetBlockSize() = 0;
-
- virtual FX_FILESIZE GetBlockOffset() = 0;
-};
-#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 _FX_STREAM_H_
+#define _FX_STREAM_H_
+#ifndef _FX_MEMORY_H_
+#include "fx_memory.h"
+#endif
+void* FX_OpenFolder(FX_LPCSTR path);
+void* FX_OpenFolder(FX_LPCWSTR path);
+FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder);
+FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder);
+void FX_CloseFolder(void* handle);
+FX_WCHAR FX_GetFolderSeparator();
+FX_DEFINEHANDLE(FX_HFILE)
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#define FX_FILESIZE FX_INT32
+#else
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+#define FX_FILESIZE off_t
+#endif
+#define FX_GETBYTEOFFSET32(a) 0
+#define FX_GETBYTEOFFSET40(a) 0
+#define FX_GETBYTEOFFSET48(a) 0
+#define FX_GETBYTEOFFSET56(a) 0
+#define FX_GETBYTEOFFSET24(a) ((FX_BYTE)(a>>24))
+#define FX_GETBYTEOFFSET16(a) ((FX_BYTE)(a>>16))
+#define FX_GETBYTEOFFSET8(a) ((FX_BYTE)(a>>8))
+#define FX_GETBYTEOFFSET0(a) ((FX_BYTE)(a))
+#define FX_FILEMODE_Write 0
+#define FX_FILEMODE_ReadOnly 1
+#define FX_FILEMODE_Truncate 2
+FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
+FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
+void FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator = NULL);
+FX_FILESIZE FX_File_GetSize(FX_HFILE hFile);
+FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile);
+FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos);
+size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer);
+size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
+size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuffer);
+size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
+FX_BOOL FX_File_Flush(FX_HFILE hFile);
+FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile);
+FX_BOOL FX_File_Exist(FX_BSTR fileName);
+FX_BOOL FX_File_Exist(FX_WSTR fileName);
+FX_BOOL FX_File_Delete(FX_BSTR fileName);
+FX_BOOL FX_File_Delete(FX_WSTR fileName);
+FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
+FX_BOOL FX_File_Copy(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
+FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
+FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
+class IFX_StreamWrite
+{
+public:
+
+ virtual void Release() = 0;
+
+ virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
+};
+class IFX_FileWrite : public IFX_StreamWrite
+{
+public:
+
+ virtual void Release() = 0;
+
+ virtual FX_FILESIZE GetSize() = 0;
+
+ virtual FX_BOOL Flush() = 0;
+
+ virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0;
+ virtual FX_BOOL WriteBlock(const void* pData, size_t size)
+ {
+ return WriteBlock(pData, GetSize(), size);
+ }
+};
+IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
+IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
+class IFX_StreamRead
+{
+public:
+
+ virtual void Release() = 0;
+
+ virtual FX_BOOL IsEOF() = 0;
+
+ virtual FX_FILESIZE GetPosition() = 0;
+
+ virtual size_t ReadBlock(void* buffer, size_t size) = 0;
+};
+class IFX_FileRead : IFX_StreamRead
+{
+public:
+
+ virtual void Release() = 0;
+
+ virtual FX_FILESIZE GetSize() = 0;
+
+ virtual FX_BOOL IsEOF()
+ {
+ return FALSE;
+ }
+
+ virtual FX_FILESIZE GetPosition()
+ {
+ return 0;
+ }
+
+ virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size)
+ {
+ return FALSE;
+ }
+
+ virtual void ClearRange() {}
+
+ virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
+
+ virtual size_t ReadBlock(void* buffer, size_t size)
+ {
+ return 0;
+ }
+};
+IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
+IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
+class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite
+{
+public:
+
+ virtual IFX_FileStream* Retain() = 0;
+
+ virtual void Release() = 0;
+
+ virtual FX_FILESIZE GetSize() = 0;
+
+ virtual FX_BOOL IsEOF() = 0;
+
+ virtual FX_FILESIZE GetPosition() = 0;
+
+ virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
+
+ virtual size_t ReadBlock(void* buffer, size_t size) = 0;
+
+ virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0;
+ virtual FX_BOOL WriteBlock(const void* buffer, size_t size)
+ {
+ return WriteBlock(buffer, GetSize(), size);
+ }
+
+ virtual FX_BOOL Flush() = 0;
+};
+IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
+IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
+class IFX_MemoryStream : public IFX_FileStream
+{
+public:
+
+ virtual FX_BOOL IsConsecutive() const = 0;
+
+ virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
+
+ virtual FX_LPBYTE GetBuffer() const = 0;
+
+ virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) = 0;
+
+ virtual void DetachBuffer() = 0;
+};
+IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE, IFX_Allocator* pAllocator = NULL);
+IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE, IFX_Allocator* pAllocator = NULL);
+class IFX_BufferRead : public IFX_StreamRead
+{
+public:
+
+ virtual void Release() = 0;
+
+ virtual FX_BOOL IsEOF() = 0;
+
+ virtual FX_FILESIZE GetPosition() = 0;
+
+ virtual size_t ReadBlock(void* buffer, size_t size) = 0;
+
+ virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
+
+ virtual FX_LPCBYTE GetBlockBuffer() = 0;
+
+ virtual size_t GetBlockSize() = 0;
+
+ virtual FX_FILESIZE GetBlockOffset() = 0;
+};
+#endif
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index 563964cdf7..08fb83cfd7 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -1,870 +1,870 @@
-// 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 _FX_STRING_H_
-#define _FX_STRING_H_
-class CFX_ByteStringC;
-class CFX_ByteString;
-class CFX_WideStringC;
-class CFX_WideString;
-struct CFX_CharMap;
-class CFX_BinaryBuf;
-typedef int FX_STRSIZE;
-class CFX_ByteStringL;
-class CFX_WideStringL;
-class CFX_ByteStringC : public CFX_Object
-{
-public:
-
- CFX_ByteStringC()
- {
- m_Ptr = NULL;
- m_Length = 0;
- }
-
- CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
- {
- m_Ptr = ptr;
- m_Length = size;
- }
-
- CFX_ByteStringC(FX_LPCSTR ptr)
- {
- m_Ptr = (FX_LPCBYTE)ptr;
- m_Length = ptr ? (FX_STRSIZE)FXSYS_strlen(ptr) : 0;
- }
-
- CFX_ByteStringC(FX_CHAR& ch)
- {
- m_Ptr = (FX_LPCBYTE)&ch;
- m_Length = 1;
- }
-
- CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
- {
- m_Ptr = (FX_LPCBYTE)ptr;
- if (len == -1) {
- m_Length = (FX_STRSIZE)FXSYS_strlen(ptr);
- } else {
- m_Length = len;
- }
- }
-
- CFX_ByteStringC(const CFX_ByteStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- }
-
- CFX_ByteStringC(const CFX_ByteString& src);
-
- CFX_ByteStringC& operator = (FX_LPCSTR src)
- {
- m_Ptr = (FX_LPCBYTE)src;
- m_Length = (FX_STRSIZE)FXSYS_strlen(src);
- return *this;
- }
-
- CFX_ByteStringC& operator = (const CFX_ByteStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- return *this;
- }
-
- CFX_ByteStringC& operator = (const CFX_ByteString& src);
-
- bool operator == (const CFX_ByteStringC& str) const
- {
- return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) == 0;
- }
-
- bool operator != (const CFX_ByteStringC& str) const
- {
- return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) != 0;
- }
-#define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
-
- FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
-
- FX_LPCBYTE GetPtr() const
- {
- return m_Ptr;
- }
-
- FX_LPCSTR GetCStr() const
- {
- return (FX_LPCSTR)m_Ptr;
- }
-
- FX_STRSIZE GetLength() const
- {
- return m_Length;
- }
-
- bool IsEmpty() const
- {
- return m_Length == 0;
- }
-
- operator FX_LPCBYTE() const
- {
- return m_Ptr;
- }
-
- FX_BYTE GetAt(FX_STRSIZE index) const
- {
- return m_Ptr[index];
- }
-
- CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
- {
- if (index < 0) {
- index = 0;
- }
- if (index > m_Length) {
- return CFX_ByteStringC();
- }
- if (count < 0 || count > m_Length - index) {
- count = m_Length - index;
- }
- return CFX_ByteStringC(m_Ptr + index, count);
- }
-protected:
-
- FX_LPCBYTE m_Ptr;
-
- FX_STRSIZE m_Length;
-private:
-
- void* operator new (size_t) throw()
- {
- return NULL;
- }
-};
-typedef const CFX_ByteStringC& FX_BSTR;
-#define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1)
-struct CFX_StringData {
-
- long m_nRefs;
-
- FX_STRSIZE m_nDataLength;
-
- FX_STRSIZE m_nAllocLength;
-
- FX_CHAR m_String[1];
-};
-class CFX_ByteString : public CFX_Object
-{
-public:
-
- CFX_ByteString()
- {
- m_pData = NULL;
- }
-
- CFX_ByteString(const CFX_ByteString& str);
-
- CFX_ByteString(char ch);
-
- CFX_ByteString(FX_LPCSTR ptr, FX_STRSIZE len = -1);
-
- CFX_ByteString(FX_LPCBYTE ptr, FX_STRSIZE len);
-
- CFX_ByteString(FX_BSTR bstrc);
-
- CFX_ByteString(FX_BSTR bstrc1, FX_BSTR bstrc2);
-
- ~CFX_ByteString();
-
- static CFX_ByteString FromUnicode(FX_LPCWSTR ptr, FX_STRSIZE len = -1);
-
- static CFX_ByteString FromUnicode(const CFX_WideString& str);
-
- operator FX_LPCSTR() const
- {
- return m_pData ? m_pData->m_String : "";
- }
-
- operator FX_LPCBYTE() const
- {
- return m_pData ? (FX_LPCBYTE)m_pData->m_String : NULL;
- }
-
- FX_STRSIZE GetLength() const
- {
- return m_pData ? m_pData->m_nDataLength : 0;
- }
-
- bool IsEmpty() const
- {
- return !GetLength();
- }
-
- int Compare(FX_BSTR str) const;
-
-
- bool Equal(FX_BSTR str) const;
-
-
- bool EqualNoCase(FX_BSTR str) const;
-
- bool operator == (FX_LPCSTR str) const
- {
- return Equal(str);
- }
-
- bool operator == (FX_BSTR str) const
- {
- return Equal(str);
- }
-
- bool operator == (const CFX_ByteString& str) const;
-
- bool operator != (FX_LPCSTR str) const
- {
- return !Equal(str);
- }
-
- bool operator != (FX_BSTR str) const
- {
- return !Equal(str);
- }
-
- bool operator != (const CFX_ByteString& str) const
- {
- return !operator==(str);
- }
-
- void Empty();
-
- const CFX_ByteString& operator = (FX_LPCSTR str);
-
- const CFX_ByteString& operator = (FX_BSTR bstrc);
-
- const CFX_ByteString& operator = (const CFX_ByteString& stringSrc);
-
- const CFX_ByteString& operator = (const CFX_BinaryBuf& buf);
-
- void Load(FX_LPCBYTE str, FX_STRSIZE len);
-
- const CFX_ByteString& operator += (FX_CHAR ch);
-
- const CFX_ByteString& operator += (FX_LPCSTR str);
-
- const CFX_ByteString& operator += (const CFX_ByteString& str);
-
- const CFX_ByteString& operator += (FX_BSTR bstrc);
-
- FX_BYTE GetAt(FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
-
- FX_BYTE operator[](FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
-
- void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
-
- FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
-
- FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
-
-
- void Format(FX_LPCSTR lpszFormat, ... );
-
- void FormatV(FX_LPCSTR lpszFormat, va_list argList);
-
-
- void Reserve(FX_STRSIZE len);
-
- FX_LPSTR GetBuffer(FX_STRSIZE len);
-
- FX_LPSTR LockBuffer();
-
- void ReleaseBuffer(FX_STRSIZE len = -1);
-
- CFX_ByteString Mid(FX_STRSIZE first) const;
-
- CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
-
- CFX_ByteString Left(FX_STRSIZE count) const;
-
- CFX_ByteString Right(FX_STRSIZE count) const;
-
- FX_STRSIZE Find(FX_BSTR lpszSub, FX_STRSIZE start = 0) const;
-
- FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const;
-
- FX_STRSIZE ReverseFind(FX_CHAR ch) const;
-
- void MakeLower();
-
- void MakeUpper();
-
- void TrimRight();
-
- void TrimRight(FX_CHAR chTarget);
-
- void TrimRight(FX_BSTR lpszTargets);
-
- void TrimLeft();
-
- void TrimLeft(FX_CHAR chTarget);
-
- void TrimLeft(FX_BSTR lpszTargets);
-
- FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew);
-
- FX_STRSIZE Remove(FX_CHAR ch);
-
- CFX_WideString UTF8Decode() const;
-
- void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
-
- FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
-
- static CFX_ByteString LoadFromFile(FX_BSTR file_path);
-#define FXFORMAT_SIGNED 1
-#define FXFORMAT_HEX 2
-#define FXFORMAT_CAPITAL 4
-
- static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0);
-
- static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
-protected:
-
- struct CFX_StringData* m_pData;
- void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
- void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
- void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCSTR lpszSrc2Data);
- void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
- void CopyBeforeWrite();
- void AllocBeforeWrite(FX_STRSIZE nLen);
-};
-inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src)
-{
- m_Ptr = (FX_LPCBYTE)src;
- m_Length = src.GetLength();
-}
-inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src)
-{
- m_Ptr = (FX_LPCBYTE)src;
- m_Length = src.GetLength();
- return *this;
-}
-
-inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2)
-{
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator + (FX_BSTR str1, FX_LPCSTR str2)
-{
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator + (FX_LPCSTR str1, FX_BSTR str2)
-{
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator + (FX_BSTR str1, FX_CHAR ch)
-{
- return CFX_ByteString(str1, CFX_ByteStringC(ch));
-}
-inline CFX_ByteString operator + (FX_CHAR ch, FX_BSTR str2)
-{
- return CFX_ByteString(ch, str2);
-}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2)
-{
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch)
-{
- return CFX_ByteString(str1, CFX_ByteStringC(ch));
-}
-inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2)
-{
- return CFX_ByteString(ch, str2);
-}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_LPCSTR str2)
-{
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator + (FX_LPCSTR str1, const CFX_ByteString& str2)
-{
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2)
-{
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2)
-{
- return CFX_ByteString(str1, str2);
-}
-class CFX_StringBufBase : public CFX_Object
-{
-public:
-
- CFX_StringBufBase(FX_STRSIZE limit)
- {
- m_Size = 0;
- m_Limit = limit;
- }
-
- FX_CHAR* GetPtr() const
- {
- return (FX_CHAR*)(this + 1);
- }
-
- FX_STRSIZE GetSize() const
- {
- return m_Size;
- }
-
- void Empty()
- {
- m_Size = 0;
- }
-
- void Copy(FX_BSTR str);
-
- void Append(FX_BSTR str);
-
- void Append(int i, FX_DWORD flags = 0);
-
- CFX_ByteStringC GetStringC() const
- {
- return CFX_ByteStringC((FX_CHAR*)(this + 1), m_Size);
- }
-
- CFX_ByteString GetString() const
- {
- return CFX_ByteString((FX_CHAR*)(this + 1), m_Size);
- }
-protected:
-
- FX_STRSIZE m_Limit;
-
- FX_STRSIZE m_Size;
-};
-template<FX_STRSIZE limit>
-class CFX_StringBufTemplate : public CFX_StringBufBase
-{
-public:
-
- CFX_StringBufTemplate() : CFX_StringBufBase(limit) {}
-
- FX_CHAR m_Buffer[limit];
-};
-typedef CFX_StringBufTemplate<256> CFX_StringBuf256;
-class CFX_WideStringC : public CFX_Object
-{
-public:
-
- CFX_WideStringC()
- {
- m_Ptr = NULL;
- m_Length = 0;
- }
-
- CFX_WideStringC(FX_LPCWSTR ptr)
- {
- m_Ptr = ptr;
- m_Length = ptr ? (FX_STRSIZE)FXSYS_wcslen(ptr) : 0;
- }
-
- CFX_WideStringC(FX_WCHAR& ch)
- {
- m_Ptr = &ch;
- m_Length = 1;
- }
-
- CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
- {
- m_Ptr = ptr;
- if (len == -1) {
- m_Length = (FX_STRSIZE)FXSYS_wcslen(ptr);
- } else {
- m_Length = len;
- }
- }
-
- CFX_WideStringC(const CFX_WideStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- }
-
- CFX_WideStringC(const CFX_WideString& src);
-
- CFX_WideStringC& operator = (FX_LPCWSTR src)
- {
- m_Ptr = src;
- m_Length = (FX_STRSIZE)FXSYS_wcslen(src);
- return *this;
- }
-
- CFX_WideStringC& operator = (const CFX_WideStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- return *this;
- }
-
- CFX_WideStringC& operator = (const CFX_WideString& src);
-
- bool operator == (const CFX_WideStringC& str) const
- {
- return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length * sizeof(FX_WCHAR)) == 0;
- }
-
- bool operator != (const CFX_WideStringC& str) const
- {
- return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length * sizeof(FX_WCHAR)) != 0;
- }
-
- FX_LPCWSTR GetPtr() const
- {
- return m_Ptr;
- }
-
- FX_STRSIZE GetLength() const
- {
- return m_Length;
- }
-
- bool IsEmpty() const
- {
- return m_Length == 0;
- }
-
- FX_WCHAR GetAt(FX_STRSIZE index) const
- {
- return m_Ptr[index];
- }
-
- CFX_WideStringC Left(FX_STRSIZE count) const
- {
- if (count < 1) {
- return CFX_WideStringC();
- }
- if (count > m_Length) {
- count = m_Length;
- }
- return CFX_WideStringC(m_Ptr, count);
- }
-
- CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
- {
- if (index < 0) {
- index = 0;
- }
- if (index > m_Length) {
- return CFX_WideStringC();
- }
- if (count < 0 || count > m_Length - index) {
- count = m_Length - index;
- }
- return CFX_WideStringC(m_Ptr + index, count);
- }
-
- CFX_WideStringC Right(FX_STRSIZE count) const
- {
- if (count < 1) {
- return CFX_WideStringC();
- }
- if (count > m_Length) {
- count = m_Length;
- }
- return CFX_WideStringC(m_Ptr + m_Length - count, count);
- }
-protected:
-
- FX_LPCWSTR m_Ptr;
-
- FX_STRSIZE m_Length;
-private:
-
- void* operator new (size_t) throw()
- {
- return NULL;
- }
-};
-typedef const CFX_WideStringC& FX_WSTR;
-#define FX_WSTRC(wstr) CFX_WideStringC((FX_LPCWSTR)wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
-struct CFX_StringDataW {
-
- long m_nRefs;
-
- FX_STRSIZE m_nDataLength;
-
- FX_STRSIZE m_nAllocLength;
-
- FX_WCHAR m_String[1];
-};
-class CFX_WideString : public CFX_Object
-{
-public:
-
- CFX_WideString()
- {
- m_pData = NULL;
- }
-
- CFX_WideString(const CFX_WideString& str);
-
- CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len = -1)
- {
- InitStr(ptr, len);
- }
-
- CFX_WideString(FX_WCHAR ch);
-
- CFX_WideString(const CFX_WideStringC& str);
-
- CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
-
- ~CFX_WideString();
-
- static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
-
- static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len = -1);
-
- static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len = -1);
-
- operator FX_LPCWSTR() const
- {
- return m_pData ? m_pData->m_String : (FX_WCHAR*)L"";
- }
-
- void Empty();
-
-
- FX_BOOL IsEmpty() const
- {
- return !GetLength();
- }
-
- FX_STRSIZE GetLength() const
- {
- return m_pData ? m_pData->m_nDataLength : 0;
- }
-
- const CFX_WideString& operator = (FX_LPCWSTR str);
-
- const CFX_WideString& operator =(const CFX_WideString& stringSrc);
-
- const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
-
- const CFX_WideString& operator += (FX_LPCWSTR str);
-
- const CFX_WideString& operator += (FX_WCHAR ch);
-
- const CFX_WideString& operator += (const CFX_WideString& str);
-
- const CFX_WideString& operator += (const CFX_WideStringC& str);
-
- FX_WCHAR GetAt(FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
-
- FX_WCHAR operator[](FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
-
- void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
-
- int Compare(FX_LPCWSTR str) const;
-
- int Compare(const CFX_WideString& str) const;
-
- int CompareNoCase(FX_LPCWSTR str) const;
-
- bool Equal(const CFX_WideStringC& str) const;
-
- CFX_WideString Mid(FX_STRSIZE first) const;
-
- CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
-
- CFX_WideString Left(FX_STRSIZE count) const;
-
- CFX_WideString Right(FX_STRSIZE count) const;
-
- FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
-
- FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
-
- void Format(FX_LPCWSTR lpszFormat, ... );
-
- void FormatV(FX_LPCWSTR lpszFormat, va_list argList);
-
- void MakeLower();
-
- void MakeUpper();
-
- void TrimRight();
-
- void TrimRight(FX_WCHAR chTarget);
-
- void TrimRight(FX_LPCWSTR lpszTargets);
-
- void TrimLeft();
-
- void TrimLeft(FX_WCHAR chTarget);
-
- void TrimLeft(FX_LPCWSTR lpszTargets);
-
- void Reserve(FX_STRSIZE len);
-
- FX_LPWSTR GetBuffer(FX_STRSIZE len);
-
- FX_LPWSTR LockBuffer();
-
- void ReleaseBuffer(FX_STRSIZE len = -1);
-
- int GetInteger() const;
-
- FX_FLOAT GetFloat() const;
-
- FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start = 0) const;
-
- FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
-
- FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew);
-
- FX_STRSIZE Remove(FX_WCHAR ch);
-
- CFX_ByteString UTF8Encode() const;
-
- CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate = TRUE) const;
-
- void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
-protected:
- void InitStr(FX_LPCWSTR ptr, int len);
-
- CFX_StringDataW* m_pData;
- void CopyBeforeWrite();
- void AllocBeforeWrite(FX_STRSIZE nLen);
- void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
- void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data);
- void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
- void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
-};
-inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
-{
- m_Ptr = (FX_LPCWSTR)src;
- m_Length = src.GetLength();
-}
-inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src)
-{
- m_Ptr = (FX_LPCWSTR)src;
- m_Length = src.GetLength();
- return *this;
-}
-
-inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2)
-{
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2)
-{
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideStringC& str2)
-{
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch)
-{
- return CFX_WideString(str1, CFX_WideStringC(ch));
-}
-inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2)
-{
- return CFX_WideString(ch, str2);
-}
-inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2)
-{
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch)
-{
- return CFX_WideString(str1, CFX_WideStringC(ch));
-}
-inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2)
-{
- return CFX_WideString(ch, str2);
-}
-inline CFX_WideString operator + (const CFX_WideString& str1, FX_LPCWSTR str2)
-{
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideString& str2)
-{
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2)
-{
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2)
-{
- return CFX_WideString(str1, str2);
-}
-
-bool operator==(const CFX_WideString& s1, const CFX_WideString& s2);
-bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2);
-bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2);
-bool operator== (const CFX_WideString& s1, FX_LPCWSTR s2);
-bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2);
-bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2);
-bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2);
-bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2);
-bool operator!= (const CFX_WideString& s1, FX_LPCWSTR s2);
-bool operator!=(FX_LPCWSTR s1, const CFX_WideString& s2);
-FX_FLOAT FX_atof(FX_BSTR str);
-void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData);
-FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf);
-CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len);
-inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr)
-{
- return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
-}
-inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr)
-{
- return FX_UTF8Encode((FX_LPCWSTR)wsStr, wsStr.GetLength());
-}
-class CFX_ByteStringL : public CFX_ByteStringC
-{
-public:
- CFX_ByteStringL() : CFX_ByteStringC() {}
- ~CFX_ByteStringL() {}
-
- void Empty(IFX_Allocator* pAllocator);
- FX_LPSTR AllocBuffer(FX_STRSIZE length, IFX_Allocator* pAllocator);
-
- void Set(FX_BSTR src, IFX_Allocator* pAllocator);
-};
-class CFX_WideStringL : public CFX_WideStringC
-{
-public:
- CFX_WideStringL() : CFX_WideStringC() {}
- ~CFX_WideStringL() {}
-
- void Empty(IFX_Allocator* pAllocator);
- void Set(FX_WSTR src, IFX_Allocator* pAllocator);
-
- int GetInteger() const;
- FX_FLOAT GetFloat() const;
-
- void TrimRight(FX_LPCWSTR lpszTargets);
-};
-void FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len, CFX_ByteStringL &utf8Str, IFX_Allocator* pAllocator = 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 _FX_STRING_H_
+#define _FX_STRING_H_
+class CFX_ByteStringC;
+class CFX_ByteString;
+class CFX_WideStringC;
+class CFX_WideString;
+struct CFX_CharMap;
+class CFX_BinaryBuf;
+typedef int FX_STRSIZE;
+class CFX_ByteStringL;
+class CFX_WideStringL;
+class CFX_ByteStringC : public CFX_Object
+{
+public:
+
+ CFX_ByteStringC()
+ {
+ m_Ptr = NULL;
+ m_Length = 0;
+ }
+
+ CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
+ {
+ m_Ptr = ptr;
+ m_Length = size;
+ }
+
+ CFX_ByteStringC(FX_LPCSTR ptr)
+ {
+ m_Ptr = (FX_LPCBYTE)ptr;
+ m_Length = ptr ? (FX_STRSIZE)FXSYS_strlen(ptr) : 0;
+ }
+
+ CFX_ByteStringC(FX_CHAR& ch)
+ {
+ m_Ptr = (FX_LPCBYTE)&ch;
+ m_Length = 1;
+ }
+
+ CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
+ {
+ m_Ptr = (FX_LPCBYTE)ptr;
+ if (len == -1) {
+ m_Length = (FX_STRSIZE)FXSYS_strlen(ptr);
+ } else {
+ m_Length = len;
+ }
+ }
+
+ CFX_ByteStringC(const CFX_ByteStringC& src)
+ {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ }
+
+ CFX_ByteStringC(const CFX_ByteString& src);
+
+ CFX_ByteStringC& operator = (FX_LPCSTR src)
+ {
+ m_Ptr = (FX_LPCBYTE)src;
+ m_Length = (FX_STRSIZE)FXSYS_strlen(src);
+ return *this;
+ }
+
+ CFX_ByteStringC& operator = (const CFX_ByteStringC& src)
+ {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ return *this;
+ }
+
+ CFX_ByteStringC& operator = (const CFX_ByteString& src);
+
+ bool operator == (const CFX_ByteStringC& str) const
+ {
+ return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) == 0;
+ }
+
+ bool operator != (const CFX_ByteStringC& str) const
+ {
+ return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) != 0;
+ }
+#define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
+
+ FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
+
+ FX_LPCBYTE GetPtr() const
+ {
+ return m_Ptr;
+ }
+
+ FX_LPCSTR GetCStr() const
+ {
+ return (FX_LPCSTR)m_Ptr;
+ }
+
+ FX_STRSIZE GetLength() const
+ {
+ return m_Length;
+ }
+
+ bool IsEmpty() const
+ {
+ return m_Length == 0;
+ }
+
+ operator FX_LPCBYTE() const
+ {
+ return m_Ptr;
+ }
+
+ FX_BYTE GetAt(FX_STRSIZE index) const
+ {
+ return m_Ptr[index];
+ }
+
+ CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
+ {
+ if (index < 0) {
+ index = 0;
+ }
+ if (index > m_Length) {
+ return CFX_ByteStringC();
+ }
+ if (count < 0 || count > m_Length - index) {
+ count = m_Length - index;
+ }
+ return CFX_ByteStringC(m_Ptr + index, count);
+ }
+protected:
+
+ FX_LPCBYTE m_Ptr;
+
+ FX_STRSIZE m_Length;
+private:
+
+ void* operator new (size_t) throw()
+ {
+ return NULL;
+ }
+};
+typedef const CFX_ByteStringC& FX_BSTR;
+#define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1)
+struct CFX_StringData {
+
+ long m_nRefs;
+
+ FX_STRSIZE m_nDataLength;
+
+ FX_STRSIZE m_nAllocLength;
+
+ FX_CHAR m_String[1];
+};
+class CFX_ByteString : public CFX_Object
+{
+public:
+
+ CFX_ByteString()
+ {
+ m_pData = NULL;
+ }
+
+ CFX_ByteString(const CFX_ByteString& str);
+
+ CFX_ByteString(char ch);
+
+ CFX_ByteString(FX_LPCSTR ptr, FX_STRSIZE len = -1);
+
+ CFX_ByteString(FX_LPCBYTE ptr, FX_STRSIZE len);
+
+ CFX_ByteString(FX_BSTR bstrc);
+
+ CFX_ByteString(FX_BSTR bstrc1, FX_BSTR bstrc2);
+
+ ~CFX_ByteString();
+
+ static CFX_ByteString FromUnicode(FX_LPCWSTR ptr, FX_STRSIZE len = -1);
+
+ static CFX_ByteString FromUnicode(const CFX_WideString& str);
+
+ operator FX_LPCSTR() const
+ {
+ return m_pData ? m_pData->m_String : "";
+ }
+
+ operator FX_LPCBYTE() const
+ {
+ return m_pData ? (FX_LPCBYTE)m_pData->m_String : NULL;
+ }
+
+ FX_STRSIZE GetLength() const
+ {
+ return m_pData ? m_pData->m_nDataLength : 0;
+ }
+
+ bool IsEmpty() const
+ {
+ return !GetLength();
+ }
+
+ int Compare(FX_BSTR str) const;
+
+
+ bool Equal(FX_BSTR str) const;
+
+
+ bool EqualNoCase(FX_BSTR str) const;
+
+ bool operator == (FX_LPCSTR str) const
+ {
+ return Equal(str);
+ }
+
+ bool operator == (FX_BSTR str) const
+ {
+ return Equal(str);
+ }
+
+ bool operator == (const CFX_ByteString& str) const;
+
+ bool operator != (FX_LPCSTR str) const
+ {
+ return !Equal(str);
+ }
+
+ bool operator != (FX_BSTR str) const
+ {
+ return !Equal(str);
+ }
+
+ bool operator != (const CFX_ByteString& str) const
+ {
+ return !operator==(str);
+ }
+
+ void Empty();
+
+ const CFX_ByteString& operator = (FX_LPCSTR str);
+
+ const CFX_ByteString& operator = (FX_BSTR bstrc);
+
+ const CFX_ByteString& operator = (const CFX_ByteString& stringSrc);
+
+ const CFX_ByteString& operator = (const CFX_BinaryBuf& buf);
+
+ void Load(FX_LPCBYTE str, FX_STRSIZE len);
+
+ const CFX_ByteString& operator += (FX_CHAR ch);
+
+ const CFX_ByteString& operator += (FX_LPCSTR str);
+
+ const CFX_ByteString& operator += (const CFX_ByteString& str);
+
+ const CFX_ByteString& operator += (FX_BSTR bstrc);
+
+ FX_BYTE GetAt(FX_STRSIZE nIndex) const
+ {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
+
+ FX_BYTE operator[](FX_STRSIZE nIndex) const
+ {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
+
+ void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
+
+ FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
+
+ FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
+
+
+ void Format(FX_LPCSTR lpszFormat, ... );
+
+ void FormatV(FX_LPCSTR lpszFormat, va_list argList);
+
+
+ void Reserve(FX_STRSIZE len);
+
+ FX_LPSTR GetBuffer(FX_STRSIZE len);
+
+ FX_LPSTR LockBuffer();
+
+ void ReleaseBuffer(FX_STRSIZE len = -1);
+
+ CFX_ByteString Mid(FX_STRSIZE first) const;
+
+ CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
+
+ CFX_ByteString Left(FX_STRSIZE count) const;
+
+ CFX_ByteString Right(FX_STRSIZE count) const;
+
+ FX_STRSIZE Find(FX_BSTR lpszSub, FX_STRSIZE start = 0) const;
+
+ FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const;
+
+ FX_STRSIZE ReverseFind(FX_CHAR ch) const;
+
+ void MakeLower();
+
+ void MakeUpper();
+
+ void TrimRight();
+
+ void TrimRight(FX_CHAR chTarget);
+
+ void TrimRight(FX_BSTR lpszTargets);
+
+ void TrimLeft();
+
+ void TrimLeft(FX_CHAR chTarget);
+
+ void TrimLeft(FX_BSTR lpszTargets);
+
+ FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew);
+
+ FX_STRSIZE Remove(FX_CHAR ch);
+
+ CFX_WideString UTF8Decode() const;
+
+ void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
+
+ FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
+
+ static CFX_ByteString LoadFromFile(FX_BSTR file_path);
+#define FXFORMAT_SIGNED 1
+#define FXFORMAT_HEX 2
+#define FXFORMAT_CAPITAL 4
+
+ static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0);
+
+ static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
+protected:
+
+ struct CFX_StringData* m_pData;
+ void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
+ void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
+ void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCSTR lpszSrc2Data);
+ void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
+ void CopyBeforeWrite();
+ void AllocBeforeWrite(FX_STRSIZE nLen);
+};
+inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src)
+{
+ m_Ptr = (FX_LPCBYTE)src;
+ m_Length = src.GetLength();
+}
+inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src)
+{
+ m_Ptr = (FX_LPCBYTE)src;
+ m_Length = src.GetLength();
+ return *this;
+}
+
+inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+inline CFX_ByteString operator + (FX_BSTR str1, FX_LPCSTR str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+inline CFX_ByteString operator + (FX_LPCSTR str1, FX_BSTR str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+inline CFX_ByteString operator + (FX_BSTR str1, FX_CHAR ch)
+{
+ return CFX_ByteString(str1, CFX_ByteStringC(ch));
+}
+inline CFX_ByteString operator + (FX_CHAR ch, FX_BSTR str2)
+{
+ return CFX_ByteString(ch, str2);
+}
+inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch)
+{
+ return CFX_ByteString(str1, CFX_ByteStringC(ch));
+}
+inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2)
+{
+ return CFX_ByteString(ch, str2);
+}
+inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_LPCSTR str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+inline CFX_ByteString operator + (FX_LPCSTR str1, const CFX_ByteString& str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2)
+{
+ return CFX_ByteString(str1, str2);
+}
+class CFX_StringBufBase : public CFX_Object
+{
+public:
+
+ CFX_StringBufBase(FX_STRSIZE limit)
+ {
+ m_Size = 0;
+ m_Limit = limit;
+ }
+
+ FX_CHAR* GetPtr() const
+ {
+ return (FX_CHAR*)(this + 1);
+ }
+
+ FX_STRSIZE GetSize() const
+ {
+ return m_Size;
+ }
+
+ void Empty()
+ {
+ m_Size = 0;
+ }
+
+ void Copy(FX_BSTR str);
+
+ void Append(FX_BSTR str);
+
+ void Append(int i, FX_DWORD flags = 0);
+
+ CFX_ByteStringC GetStringC() const
+ {
+ return CFX_ByteStringC((FX_CHAR*)(this + 1), m_Size);
+ }
+
+ CFX_ByteString GetString() const
+ {
+ return CFX_ByteString((FX_CHAR*)(this + 1), m_Size);
+ }
+protected:
+
+ FX_STRSIZE m_Limit;
+
+ FX_STRSIZE m_Size;
+};
+template<FX_STRSIZE limit>
+class CFX_StringBufTemplate : public CFX_StringBufBase
+{
+public:
+
+ CFX_StringBufTemplate() : CFX_StringBufBase(limit) {}
+
+ FX_CHAR m_Buffer[limit];
+};
+typedef CFX_StringBufTemplate<256> CFX_StringBuf256;
+class CFX_WideStringC : public CFX_Object
+{
+public:
+
+ CFX_WideStringC()
+ {
+ m_Ptr = NULL;
+ m_Length = 0;
+ }
+
+ CFX_WideStringC(FX_LPCWSTR ptr)
+ {
+ m_Ptr = ptr;
+ m_Length = ptr ? (FX_STRSIZE)FXSYS_wcslen(ptr) : 0;
+ }
+
+ CFX_WideStringC(FX_WCHAR& ch)
+ {
+ m_Ptr = &ch;
+ m_Length = 1;
+ }
+
+ CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
+ {
+ m_Ptr = ptr;
+ if (len == -1) {
+ m_Length = (FX_STRSIZE)FXSYS_wcslen(ptr);
+ } else {
+ m_Length = len;
+ }
+ }
+
+ CFX_WideStringC(const CFX_WideStringC& src)
+ {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ }
+
+ CFX_WideStringC(const CFX_WideString& src);
+
+ CFX_WideStringC& operator = (FX_LPCWSTR src)
+ {
+ m_Ptr = src;
+ m_Length = (FX_STRSIZE)FXSYS_wcslen(src);
+ return *this;
+ }
+
+ CFX_WideStringC& operator = (const CFX_WideStringC& src)
+ {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ return *this;
+ }
+
+ CFX_WideStringC& operator = (const CFX_WideString& src);
+
+ bool operator == (const CFX_WideStringC& str) const
+ {
+ return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length * sizeof(FX_WCHAR)) == 0;
+ }
+
+ bool operator != (const CFX_WideStringC& str) const
+ {
+ return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length * sizeof(FX_WCHAR)) != 0;
+ }
+
+ FX_LPCWSTR GetPtr() const
+ {
+ return m_Ptr;
+ }
+
+ FX_STRSIZE GetLength() const
+ {
+ return m_Length;
+ }
+
+ bool IsEmpty() const
+ {
+ return m_Length == 0;
+ }
+
+ FX_WCHAR GetAt(FX_STRSIZE index) const
+ {
+ return m_Ptr[index];
+ }
+
+ CFX_WideStringC Left(FX_STRSIZE count) const
+ {
+ if (count < 1) {
+ return CFX_WideStringC();
+ }
+ if (count > m_Length) {
+ count = m_Length;
+ }
+ return CFX_WideStringC(m_Ptr, count);
+ }
+
+ CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
+ {
+ if (index < 0) {
+ index = 0;
+ }
+ if (index > m_Length) {
+ return CFX_WideStringC();
+ }
+ if (count < 0 || count > m_Length - index) {
+ count = m_Length - index;
+ }
+ return CFX_WideStringC(m_Ptr + index, count);
+ }
+
+ CFX_WideStringC Right(FX_STRSIZE count) const
+ {
+ if (count < 1) {
+ return CFX_WideStringC();
+ }
+ if (count > m_Length) {
+ count = m_Length;
+ }
+ return CFX_WideStringC(m_Ptr + m_Length - count, count);
+ }
+protected:
+
+ FX_LPCWSTR m_Ptr;
+
+ FX_STRSIZE m_Length;
+private:
+
+ void* operator new (size_t) throw()
+ {
+ return NULL;
+ }
+};
+typedef const CFX_WideStringC& FX_WSTR;
+#define FX_WSTRC(wstr) CFX_WideStringC((FX_LPCWSTR)wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
+struct CFX_StringDataW {
+
+ long m_nRefs;
+
+ FX_STRSIZE m_nDataLength;
+
+ FX_STRSIZE m_nAllocLength;
+
+ FX_WCHAR m_String[1];
+};
+class CFX_WideString : public CFX_Object
+{
+public:
+
+ CFX_WideString()
+ {
+ m_pData = NULL;
+ }
+
+ CFX_WideString(const CFX_WideString& str);
+
+ CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len = -1)
+ {
+ InitStr(ptr, len);
+ }
+
+ CFX_WideString(FX_WCHAR ch);
+
+ CFX_WideString(const CFX_WideStringC& str);
+
+ CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
+
+ ~CFX_WideString();
+
+ static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
+
+ static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len = -1);
+
+ static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len = -1);
+
+ operator FX_LPCWSTR() const
+ {
+ return m_pData ? m_pData->m_String : (FX_WCHAR*)L"";
+ }
+
+ void Empty();
+
+
+ FX_BOOL IsEmpty() const
+ {
+ return !GetLength();
+ }
+
+ FX_STRSIZE GetLength() const
+ {
+ return m_pData ? m_pData->m_nDataLength : 0;
+ }
+
+ const CFX_WideString& operator = (FX_LPCWSTR str);
+
+ const CFX_WideString& operator =(const CFX_WideString& stringSrc);
+
+ const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
+
+ const CFX_WideString& operator += (FX_LPCWSTR str);
+
+ const CFX_WideString& operator += (FX_WCHAR ch);
+
+ const CFX_WideString& operator += (const CFX_WideString& str);
+
+ const CFX_WideString& operator += (const CFX_WideStringC& str);
+
+ FX_WCHAR GetAt(FX_STRSIZE nIndex) const
+ {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
+
+ FX_WCHAR operator[](FX_STRSIZE nIndex) const
+ {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
+
+ void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
+
+ int Compare(FX_LPCWSTR str) const;
+
+ int Compare(const CFX_WideString& str) const;
+
+ int CompareNoCase(FX_LPCWSTR str) const;
+
+ bool Equal(const CFX_WideStringC& str) const;
+
+ CFX_WideString Mid(FX_STRSIZE first) const;
+
+ CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
+
+ CFX_WideString Left(FX_STRSIZE count) const;
+
+ CFX_WideString Right(FX_STRSIZE count) const;
+
+ FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
+
+ FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
+
+ void Format(FX_LPCWSTR lpszFormat, ... );
+
+ void FormatV(FX_LPCWSTR lpszFormat, va_list argList);
+
+ void MakeLower();
+
+ void MakeUpper();
+
+ void TrimRight();
+
+ void TrimRight(FX_WCHAR chTarget);
+
+ void TrimRight(FX_LPCWSTR lpszTargets);
+
+ void TrimLeft();
+
+ void TrimLeft(FX_WCHAR chTarget);
+
+ void TrimLeft(FX_LPCWSTR lpszTargets);
+
+ void Reserve(FX_STRSIZE len);
+
+ FX_LPWSTR GetBuffer(FX_STRSIZE len);
+
+ FX_LPWSTR LockBuffer();
+
+ void ReleaseBuffer(FX_STRSIZE len = -1);
+
+ int GetInteger() const;
+
+ FX_FLOAT GetFloat() const;
+
+ FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start = 0) const;
+
+ FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
+
+ FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew);
+
+ FX_STRSIZE Remove(FX_WCHAR ch);
+
+ CFX_ByteString UTF8Encode() const;
+
+ CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate = TRUE) const;
+
+ void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
+protected:
+ void InitStr(FX_LPCWSTR ptr, int len);
+
+ CFX_StringDataW* m_pData;
+ void CopyBeforeWrite();
+ void AllocBeforeWrite(FX_STRSIZE nLen);
+ void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
+ void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data);
+ void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
+ void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
+};
+inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
+{
+ m_Ptr = (FX_LPCWSTR)src;
+ m_Length = src.GetLength();
+}
+inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src)
+{
+ m_Ptr = (FX_LPCWSTR)src;
+ m_Length = src.GetLength();
+ return *this;
+}
+
+inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2)
+{
+ return CFX_WideString(str1, str2);
+}
+inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2)
+{
+ return CFX_WideString(str1, str2);
+}
+inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideStringC& str2)
+{
+ return CFX_WideString(str1, str2);
+}
+inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch)
+{
+ return CFX_WideString(str1, CFX_WideStringC(ch));
+}
+inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2)
+{
+ return CFX_WideString(ch, str2);
+}
+inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2)
+{
+ return CFX_WideString(str1, str2);
+}
+inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch)
+{
+ return CFX_WideString(str1, CFX_WideStringC(ch));
+}
+inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2)
+{
+ return CFX_WideString(ch, str2);
+}
+inline CFX_WideString operator + (const CFX_WideString& str1, FX_LPCWSTR str2)
+{
+ return CFX_WideString(str1, str2);
+}
+inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideString& str2)
+{
+ return CFX_WideString(str1, str2);
+}
+inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2)
+{
+ return CFX_WideString(str1, str2);
+}
+inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2)
+{
+ return CFX_WideString(str1, str2);
+}
+
+bool operator==(const CFX_WideString& s1, const CFX_WideString& s2);
+bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2);
+bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2);
+bool operator== (const CFX_WideString& s1, FX_LPCWSTR s2);
+bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2);
+bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2);
+bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2);
+bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2);
+bool operator!= (const CFX_WideString& s1, FX_LPCWSTR s2);
+bool operator!=(FX_LPCWSTR s1, const CFX_WideString& s2);
+FX_FLOAT FX_atof(FX_BSTR str);
+void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData);
+FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf);
+CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len);
+inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr)
+{
+ return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
+}
+inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr)
+{
+ return FX_UTF8Encode((FX_LPCWSTR)wsStr, wsStr.GetLength());
+}
+class CFX_ByteStringL : public CFX_ByteStringC
+{
+public:
+ CFX_ByteStringL() : CFX_ByteStringC() {}
+ ~CFX_ByteStringL() {}
+
+ void Empty(IFX_Allocator* pAllocator);
+ FX_LPSTR AllocBuffer(FX_STRSIZE length, IFX_Allocator* pAllocator);
+
+ void Set(FX_BSTR src, IFX_Allocator* pAllocator);
+};
+class CFX_WideStringL : public CFX_WideStringC
+{
+public:
+ CFX_WideStringL() : CFX_WideStringC() {}
+ ~CFX_WideStringL() {}
+
+ void Empty(IFX_Allocator* pAllocator);
+ void Set(FX_WSTR src, IFX_Allocator* pAllocator);
+
+ int GetInteger() const;
+ FX_FLOAT GetFloat() const;
+
+ void TrimRight(FX_LPCWSTR lpszTargets);
+};
+void FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len, CFX_ByteStringL &utf8Str, IFX_Allocator* pAllocator = NULL);
+#endif
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index f72be0ffcb..0021c1437d 100644
--- a/core/include/fxcrt/fx_system.h
+++ b/core/include/fxcrt/fx_system.h
@@ -1,279 +1,279 @@
-// 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 _FX_SYSTEM_H_
-#define _FX_SYSTEM_H_
-#define _FX_WIN32_DESKTOP_ 1
-#define _FX_LINUX_DESKTOP_ 4
-#define _FX_MACOSX_ 7
-#define _FX_ANDROID_ 12
-#define _FXM_PLATFORM_WINDOWS_ 1
-#define _FXM_PLATFORM_LINUX_ 2
-#define _FXM_PLATFORM_APPLE_ 3
-#define _FXM_PLATFORM_ANDROID_ 4
-#ifndef _FX_OS_
-#if defined(__ANDROID__)
-#define _FX_OS_ _FX_ANDROID_
-#define _FXM_PLATFORM_ _FXM_PLATFORM_ANDROID_
-#elif defined(_WIN32) || defined(_WIN64)
-#define _FX_OS_ _FX_WIN32_DESKTOP_
-#define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
-#elif defined(__linux__)
-#define _FX_OS_ _FX_LINUX_DESKTOP_
-#define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
-#elif defined(__APPLE__)
-#define _FX_OS_ _FX_MACOSX_
-#define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_
-#endif
-#endif
-#if !defined(_FX_OS_) || _FX_OS_ == 0
-#error Sorry, can not figure out what OS you are targeting to. Please specify _FX_OS_ macro.
-#endif
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define _CRT_SECURE_NO_WARNINGS
-#include <windows.h>
-#endif
-#define _FX_W32_ 1
-#define _FX_W64_ 2
-#ifndef _FX_WORDSIZE_
-#if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(__x86_64__) || __WORDSIZE == 64
-#define _FX_WORDSIZE_ _FX_W64_
-#else
-#define _FX_WORDSIZE_ _FX_W32_
-#endif
-#endif
-#include <stddef.h>
-#include <stdarg.h>
-#include <setjmp.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <wchar.h>
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-#include <libkern/OSAtomic.h>
-#if _FX_OS_ == _FX_MACOSX_
-#include <Carbon/Carbon.h>
-#elif _FX_OS_ == _FX_IOS_
-#include <CoreText/CoreText.h>
-#include <CoreGraphics/CoreGraphics.h>
-#endif
-#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef void* FX_LPVOID;
-typedef void const* FX_LPCVOID;
-typedef void* FX_POSITION;
-typedef signed char FX_INT8;
-typedef unsigned char FX_UINT8;
-typedef unsigned char FX_BYTE;
-typedef unsigned char* FX_LPBYTE;
-typedef unsigned char const* FX_LPCBYTE;
-typedef short FX_INT16;
-typedef unsigned short FX_UINT16;
-typedef short FX_SHORT;
-typedef unsigned short FX_WORD;
-typedef unsigned short* FX_LPWORD;
-typedef unsigned short const* FX_LPCWORD;
-typedef int FX_INT32;
-typedef float FX_FLOAT;
-typedef int FX_BOOL;
-typedef int FX_ERR;
-#define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0)
-#define FX_FAILED(Status) ((FX_ERR)(Status) < 0)
-typedef char FX_CHAR;
-typedef char* FX_LPSTR;
-typedef char const* FX_LPCSTR;
-typedef unsigned int FX_DWORD;
-typedef unsigned int* FX_LPDWORD;
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-typedef __int64 FX_INT64;
-typedef unsigned __int64 FX_UINT64;
-#else
-typedef long long int FX_INT64;
-typedef unsigned long long FX_UINT64;
-#endif
-#if _FX_WORDSIZE_ == _FX_W64_
-typedef FX_INT64 FX_INTPTR;
-typedef FX_UINT64 FX_UINTPTR;
-#else
-typedef int FX_INTPTR;
-typedef unsigned int FX_UINTPTR;
-#endif
-typedef wchar_t FX_WCHAR;
-typedef wchar_t* FX_LPWSTR;
-typedef wchar_t const* FX_LPCWSTR;
-typedef FX_DWORD FX_UINT32;
-typedef FX_UINT64 FX_QWORD;
-#define FX_DEFINEHANDLE(name) typedef struct _##name {FX_LPVOID pData;} * name;
-#if defined(DEBUG) && !defined(_DEBUG)
-#define _DEBUG
-#endif
-#ifndef TRUE
-
-#define TRUE 1
-#endif
-#ifndef FALSE
-
-#define FALSE 0
-#endif
-#ifndef NULL
-
-#define NULL 0
-#endif
-#define FXSYS_assert assert
-#ifndef ASSERT
-#ifdef _DEBUG
-#define ASSERT FXSYS_assert
-#else
-
-#define ASSERT(a)
-#endif
-#endif
-#define FX_MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define FX_MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define FX_PI 3.1415926535897932384626433832795f
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define FXSYS_snprintf _snprintf
-#else
-#define FXSYS_snprintf snprintf
-#endif
-#define FXSYS_sprintf sprintf
-#define FXSYS_vsprintf vsprintf
-#define FXSYS_strchr strchr
-#define FXSYS_strlen strlen
-#define FXSYS_strncmp strncmp
-#define FXSYS_strcmp strcmp
-#define FXSYS_strcpy strcpy
-#define FXSYS_strncpy strncpy
-#define FXSYS_strstr strstr
-#define FXSYS_FILE FILE
-#define FXSYS_fopen fopen
-#define FXSYS_fclose fclose
-#define FXSYS_SEEK_END SEEK_END
-#define FXSYS_SEEK_SET SEEK_SET
-#define FXSYS_fseek fseek
-#define FXSYS_ftell ftell
-#define FXSYS_fread fread
-#define FXSYS_fwrite fwrite
-#define FXSYS_fprintf fprintf
-#define FXSYS_fflush fflush
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#ifdef _NATIVE_WCHAR_T_DEFINED
-#define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m))
-#else
-#define FXSYS_wfopen _wfopen
-#endif
-#else
-FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode);
-#endif
-
-#define FXSYS_wcslen wcslen
-#define FXSYS_wcscmp wcscmp
-#define FXSYS_wcschr wcschr
-#define FXSYS_wcsstr wcsstr
-#define FXSYS_wcsncmp wcsncmp
-#define FXSYS_vswprintf vswprintf
-#define FXSYS_mbstowcs mbstowcs
-#define FXSYS_wcstombs wcstombs
-#define FXSYS_memcmp memcmp
-#define FXSYS_memcpy memcpy
-#define FXSYS_memmove memmove
-#define FXSYS_memset memset
-#define FXSYS_memchr memchr
-#define FXSYS_qsort qsort
-#define FXSYS_bsearch bsearch
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define FXSYS_GetACP GetACP
-#define FXSYS_itoa _itoa
-#define FXSYS_strlwr _strlwr
-#define FXSYS_strupr _strupr
-#define FXSYS_stricmp _stricmp
-#ifdef _NATIVE_WCHAR_T_DEFINED
-#define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2))
-#define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8)
-#define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6)
-#define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str))
-#define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str))
-#else
-#define FXSYS_wcsicmp _wcsicmp
-#define FXSYS_WideCharToMultiByte WideCharToMultiByte
-#define FXSYS_MultiByteToWideChar MultiByteToWideChar
-#define FXSYS_wcslwr _wcslwr
-#define FXSYS_wcsupr _wcsupr
-#endif
-#define FXSYS_GetFullPathName GetFullPathName
-#define FXSYS_GetModuleFileName GetModuleFileName
-#else
-int FXSYS_GetACP(void);
-char* FXSYS_itoa(int value, char* string, int radix);
-int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const wchar_t* wstr, int wlen,
- char* buf, int buflen, const char* default_str, int* pUseDefault);
-int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const char* bstr, int blen,
- wchar_t* buf, int buflen);
-FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
-FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
-char* FXSYS_strlwr(char* str);
-char* FXSYS_strupr(char* str);
-int FXSYS_stricmp(const char*, const char*);
-int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2);
-wchar_t* FXSYS_wcslwr(wchar_t* str);
-wchar_t* FXSYS_wcsupr(wchar_t* str);
-#endif
-#define FXSYS_memcpy32 FXSYS_memcpy
-#define FXSYS_memcmp32 FXSYS_memcmp
-#define FXSYS_memset32 FXSYS_memset
-#define FXSYS_memset8 FXSYS_memset
-#define FXSYS_memmove32 FXSYS_memmove
-#ifdef __cplusplus
-}
-#endif
-#include <math.h>
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define FXSYS_pow(a, b) (FX_FLOAT)powf(a, b)
-#else
-#define FXSYS_pow(a, b) (FX_FLOAT)pow(a, b)
-#endif
-#define FXSYS_sqrt(a) (FX_FLOAT)sqrt(a)
-#define FXSYS_fabs(a) (FX_FLOAT)fabs(a)
-#define FXSYS_atan2(a, b) (FX_FLOAT)atan2(a, b)
-#define FXSYS_ceil(a) (FX_FLOAT)ceil(a)
-#define FXSYS_floor(a) (FX_FLOAT)floor(a)
-#define FXSYS_cos(a) (FX_FLOAT)cos(a)
-#define FXSYS_acos(a) (FX_FLOAT)acos(a)
-#define FXSYS_sin(a) (FX_FLOAT)sin(a)
-#define FXSYS_log(a) (FX_FLOAT)log(a)
-#define FXSYS_log10(a) (FX_FLOAT)log10(a)
-#define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b)
-#define FXSYS_abs abs
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define _FX_LSB_FIRST_
-#define FXDWORD_FROM_LSBFIRST(i) (i)
-#define FXDWORD_FROM_MSBFIRST(i) (((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24))
-#define FXDWORD_GET_LSBFIRST(p) ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0]))
-#define FXDWORD_GET_MSBFIRST(p) ((((FX_LPBYTE)(p))[0] << 24) | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | (((FX_LPBYTE)(p))[3]))
-#define FXSYS_HIBYTE(word) ((FX_BYTE)((word) >> 8))
-#define FXSYS_LOBYTE(word) ((FX_BYTE)(word))
-#define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16))
-#define FXSYS_LOWORD(dword) ((FX_WORD)(dword))
-FX_INT32 FXSYS_atoi(FX_LPCSTR str);
-FX_INT32 FXSYS_wtoi(FX_LPCWSTR str);
-FX_INT64 FXSYS_atoi64(FX_LPCSTR str);
-FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str);
-FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix);
-FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix);
-int FXSYS_round(FX_FLOAT f);
-#define FXSYS_Mul(a, b) ((a) * (b))
-#define FXSYS_Div(a, b) ((a) / (b))
-#define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c))
-#define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b))
-#ifdef __cplusplus
-};
-#endif
-#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 _FX_SYSTEM_H_
+#define _FX_SYSTEM_H_
+#define _FX_WIN32_DESKTOP_ 1
+#define _FX_LINUX_DESKTOP_ 4
+#define _FX_MACOSX_ 7
+#define _FX_ANDROID_ 12
+#define _FXM_PLATFORM_WINDOWS_ 1
+#define _FXM_PLATFORM_LINUX_ 2
+#define _FXM_PLATFORM_APPLE_ 3
+#define _FXM_PLATFORM_ANDROID_ 4
+#ifndef _FX_OS_
+#if defined(__ANDROID__)
+#define _FX_OS_ _FX_ANDROID_
+#define _FXM_PLATFORM_ _FXM_PLATFORM_ANDROID_
+#elif defined(_WIN32) || defined(_WIN64)
+#define _FX_OS_ _FX_WIN32_DESKTOP_
+#define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
+#elif defined(__linux__)
+#define _FX_OS_ _FX_LINUX_DESKTOP_
+#define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
+#elif defined(__APPLE__)
+#define _FX_OS_ _FX_MACOSX_
+#define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_
+#endif
+#endif
+#if !defined(_FX_OS_) || _FX_OS_ == 0
+#error Sorry, can not figure out what OS you are targeting to. Please specify _FX_OS_ macro.
+#endif
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#define _CRT_SECURE_NO_WARNINGS
+#include <windows.h>
+#endif
+#define _FX_W32_ 1
+#define _FX_W64_ 2
+#ifndef _FX_WORDSIZE_
+#if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(__x86_64__) || __WORDSIZE == 64
+#define _FX_WORDSIZE_ _FX_W64_
+#else
+#define _FX_WORDSIZE_ _FX_W32_
+#endif
+#endif
+#include <stddef.h>
+#include <stdarg.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <wchar.h>
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+#include <libkern/OSAtomic.h>
+#if _FX_OS_ == _FX_MACOSX_
+#include <Carbon/Carbon.h>
+#elif _FX_OS_ == _FX_IOS_
+#include <CoreText/CoreText.h>
+#include <CoreGraphics/CoreGraphics.h>
+#endif
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef void* FX_LPVOID;
+typedef void const* FX_LPCVOID;
+typedef void* FX_POSITION;
+typedef signed char FX_INT8;
+typedef unsigned char FX_UINT8;
+typedef unsigned char FX_BYTE;
+typedef unsigned char* FX_LPBYTE;
+typedef unsigned char const* FX_LPCBYTE;
+typedef short FX_INT16;
+typedef unsigned short FX_UINT16;
+typedef short FX_SHORT;
+typedef unsigned short FX_WORD;
+typedef unsigned short* FX_LPWORD;
+typedef unsigned short const* FX_LPCWORD;
+typedef int FX_INT32;
+typedef float FX_FLOAT;
+typedef int FX_BOOL;
+typedef int FX_ERR;
+#define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0)
+#define FX_FAILED(Status) ((FX_ERR)(Status) < 0)
+typedef char FX_CHAR;
+typedef char* FX_LPSTR;
+typedef char const* FX_LPCSTR;
+typedef unsigned int FX_DWORD;
+typedef unsigned int* FX_LPDWORD;
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+typedef __int64 FX_INT64;
+typedef unsigned __int64 FX_UINT64;
+#else
+typedef long long int FX_INT64;
+typedef unsigned long long FX_UINT64;
+#endif
+#if _FX_WORDSIZE_ == _FX_W64_
+typedef FX_INT64 FX_INTPTR;
+typedef FX_UINT64 FX_UINTPTR;
+#else
+typedef int FX_INTPTR;
+typedef unsigned int FX_UINTPTR;
+#endif
+typedef wchar_t FX_WCHAR;
+typedef wchar_t* FX_LPWSTR;
+typedef wchar_t const* FX_LPCWSTR;
+typedef FX_DWORD FX_UINT32;
+typedef FX_UINT64 FX_QWORD;
+#define FX_DEFINEHANDLE(name) typedef struct _##name {FX_LPVOID pData;} * name;
+#if defined(DEBUG) && !defined(_DEBUG)
+#define _DEBUG
+#endif
+#ifndef TRUE
+
+#define TRUE 1
+#endif
+#ifndef FALSE
+
+#define FALSE 0
+#endif
+#ifndef NULL
+
+#define NULL 0
+#endif
+#define FXSYS_assert assert
+#ifndef ASSERT
+#ifdef _DEBUG
+#define ASSERT FXSYS_assert
+#else
+
+#define ASSERT(a)
+#endif
+#endif
+#define FX_MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define FX_MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define FX_PI 3.1415926535897932384626433832795f
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#define FXSYS_snprintf _snprintf
+#else
+#define FXSYS_snprintf snprintf
+#endif
+#define FXSYS_sprintf sprintf
+#define FXSYS_vsprintf vsprintf
+#define FXSYS_strchr strchr
+#define FXSYS_strlen strlen
+#define FXSYS_strncmp strncmp
+#define FXSYS_strcmp strcmp
+#define FXSYS_strcpy strcpy
+#define FXSYS_strncpy strncpy
+#define FXSYS_strstr strstr
+#define FXSYS_FILE FILE
+#define FXSYS_fopen fopen
+#define FXSYS_fclose fclose
+#define FXSYS_SEEK_END SEEK_END
+#define FXSYS_SEEK_SET SEEK_SET
+#define FXSYS_fseek fseek
+#define FXSYS_ftell ftell
+#define FXSYS_fread fread
+#define FXSYS_fwrite fwrite
+#define FXSYS_fprintf fprintf
+#define FXSYS_fflush fflush
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#ifdef _NATIVE_WCHAR_T_DEFINED
+#define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m))
+#else
+#define FXSYS_wfopen _wfopen
+#endif
+#else
+FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode);
+#endif
+
+#define FXSYS_wcslen wcslen
+#define FXSYS_wcscmp wcscmp
+#define FXSYS_wcschr wcschr
+#define FXSYS_wcsstr wcsstr
+#define FXSYS_wcsncmp wcsncmp
+#define FXSYS_vswprintf vswprintf
+#define FXSYS_mbstowcs mbstowcs
+#define FXSYS_wcstombs wcstombs
+#define FXSYS_memcmp memcmp
+#define FXSYS_memcpy memcpy
+#define FXSYS_memmove memmove
+#define FXSYS_memset memset
+#define FXSYS_memchr memchr
+#define FXSYS_qsort qsort
+#define FXSYS_bsearch bsearch
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#define FXSYS_GetACP GetACP
+#define FXSYS_itoa _itoa
+#define FXSYS_strlwr _strlwr
+#define FXSYS_strupr _strupr
+#define FXSYS_stricmp _stricmp
+#ifdef _NATIVE_WCHAR_T_DEFINED
+#define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2))
+#define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8)
+#define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6)
+#define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str))
+#define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str))
+#else
+#define FXSYS_wcsicmp _wcsicmp
+#define FXSYS_WideCharToMultiByte WideCharToMultiByte
+#define FXSYS_MultiByteToWideChar MultiByteToWideChar
+#define FXSYS_wcslwr _wcslwr
+#define FXSYS_wcsupr _wcsupr
+#endif
+#define FXSYS_GetFullPathName GetFullPathName
+#define FXSYS_GetModuleFileName GetModuleFileName
+#else
+int FXSYS_GetACP(void);
+char* FXSYS_itoa(int value, char* string, int radix);
+int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const wchar_t* wstr, int wlen,
+ char* buf, int buflen, const char* default_str, int* pUseDefault);
+int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const char* bstr, int blen,
+ wchar_t* buf, int buflen);
+FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
+FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
+char* FXSYS_strlwr(char* str);
+char* FXSYS_strupr(char* str);
+int FXSYS_stricmp(const char*, const char*);
+int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2);
+wchar_t* FXSYS_wcslwr(wchar_t* str);
+wchar_t* FXSYS_wcsupr(wchar_t* str);
+#endif
+#define FXSYS_memcpy32 FXSYS_memcpy
+#define FXSYS_memcmp32 FXSYS_memcmp
+#define FXSYS_memset32 FXSYS_memset
+#define FXSYS_memset8 FXSYS_memset
+#define FXSYS_memmove32 FXSYS_memmove
+#ifdef __cplusplus
+}
+#endif
+#include <math.h>
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#define FXSYS_pow(a, b) (FX_FLOAT)powf(a, b)
+#else
+#define FXSYS_pow(a, b) (FX_FLOAT)pow(a, b)
+#endif
+#define FXSYS_sqrt(a) (FX_FLOAT)sqrt(a)
+#define FXSYS_fabs(a) (FX_FLOAT)fabs(a)
+#define FXSYS_atan2(a, b) (FX_FLOAT)atan2(a, b)
+#define FXSYS_ceil(a) (FX_FLOAT)ceil(a)
+#define FXSYS_floor(a) (FX_FLOAT)floor(a)
+#define FXSYS_cos(a) (FX_FLOAT)cos(a)
+#define FXSYS_acos(a) (FX_FLOAT)acos(a)
+#define FXSYS_sin(a) (FX_FLOAT)sin(a)
+#define FXSYS_log(a) (FX_FLOAT)log(a)
+#define FXSYS_log10(a) (FX_FLOAT)log10(a)
+#define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b)
+#define FXSYS_abs abs
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define _FX_LSB_FIRST_
+#define FXDWORD_FROM_LSBFIRST(i) (i)
+#define FXDWORD_FROM_MSBFIRST(i) (((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24))
+#define FXDWORD_GET_LSBFIRST(p) ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0]))
+#define FXDWORD_GET_MSBFIRST(p) ((((FX_LPBYTE)(p))[0] << 24) | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | (((FX_LPBYTE)(p))[3]))
+#define FXSYS_HIBYTE(word) ((FX_BYTE)((word) >> 8))
+#define FXSYS_LOBYTE(word) ((FX_BYTE)(word))
+#define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16))
+#define FXSYS_LOWORD(dword) ((FX_WORD)(dword))
+FX_INT32 FXSYS_atoi(FX_LPCSTR str);
+FX_INT32 FXSYS_wtoi(FX_LPCWSTR str);
+FX_INT64 FXSYS_atoi64(FX_LPCSTR str);
+FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str);
+FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix);
+FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix);
+int FXSYS_round(FX_FLOAT f);
+#define FXSYS_Mul(a, b) ((a) * (b))
+#define FXSYS_Div(a, b) ((a) / (b))
+#define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c))
+#define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b))
+#ifdef __cplusplus
+};
+#endif
+#endif
diff --git a/core/include/fxcrt/fx_xml.h b/core/include/fxcrt/fx_xml.h
index 1217677740..19a49cde12 100644
--- a/core/include/fxcrt/fx_xml.h
+++ b/core/include/fxcrt/fx_xml.h
@@ -1,209 +1,209 @@
-// 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 _FX_XML_H_
-#define _FX_XML_H_
-#ifndef _FX_BASIC_H_
-#include "fx_basic.h"
-#endif
-class CXML_AttrItem : public CFX_Object
-{
-public:
- CFX_ByteStringL m_QSpaceName;
- CFX_ByteStringL m_AttrName;
- CFX_WideStringL m_Value;
-
- void Empty(IFX_Allocator* pAllocator = NULL)
- {
- m_QSpaceName.Empty(pAllocator);
- m_AttrName.Empty(pAllocator);
- m_Value.Empty(pAllocator);
- }
-};
-class CXML_AttrMap : public CFX_Object
-{
-public:
- CXML_AttrMap()
- {
- m_pMap = NULL;
- }
- ~CXML_AttrMap()
- {
- RemoveAll(NULL);
- }
- const CFX_WideStringL* Lookup(FX_BSTR space, FX_BSTR name) const;
- void SetAt(FX_BSTR space, FX_BSTR name, FX_WSTR value, IFX_Allocator* pAllocator = NULL);
- void RemoveAt(FX_BSTR space, FX_BSTR name, IFX_Allocator* pAllocator = NULL);
- void RemoveAll(IFX_Allocator* pAllocator = NULL);
- int GetSize() const;
- CXML_AttrItem& GetAt(int index) const;
- CFX_ObjectArray<CXML_AttrItem>* m_pMap;
-};
-class CXML_Content : public CFX_Object
-{
-public:
- CXML_Content() : m_bCDATA(FALSE), m_Content() {}
- ~CXML_Content()
- {
- Empty(NULL);
- }
- void Empty(IFX_Allocator* pAllocator = NULL)
- {
- m_Content.Empty(pAllocator);
- }
- void Set(FX_BOOL bCDATA, FX_WSTR content, IFX_Allocator* pAllocator = NULL)
- {
- m_bCDATA = bCDATA;
- m_Content.Set(content, pAllocator);
- }
- FX_BOOL m_bCDATA;
- CFX_WideStringL m_Content;
-};
-class CXML_Element : public CFX_Object
-{
-public:
-
- static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
-
- static CXML_Element* Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
-
- static CXML_Element* Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
-
- CXML_Element(FX_BSTR qSpace, FX_BSTR tagName, IFX_Allocator* pAllocator = NULL);
-
- CXML_Element(FX_BSTR qTagName, IFX_Allocator* pAllocator = NULL);
-
- CXML_Element(IFX_Allocator* pAllocator = NULL);
-
- ~CXML_Element();
-
- void Empty();
-
-
-
- CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
- void GetTagName(CFX_ByteStringL &tagName, FX_BOOL bQualified = FALSE) const;
-
- CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
- void GetNamespace(CFX_ByteStringL &nameSpace, FX_BOOL bQualified = FALSE) const;
-
- CFX_ByteString GetNamespaceURI(FX_BSTR qName) const;
- void GetNamespaceURI(FX_BSTR qName, CFX_ByteStringL &uri) const;
-
- CXML_Element* GetParent() const
- {
- return m_pParent;
- }
-
- FX_DWORD CountAttrs() const
- {
- return m_AttrMap.GetSize();
- }
-
- void GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const;
- void GetAttrByIndex(int index, CFX_ByteStringL &space, CFX_ByteStringL &name, CFX_WideStringL &value) const;
-
- FX_BOOL HasAttr(FX_BSTR qName) const;
-
- FX_BOOL GetAttrValue(FX_BSTR name, CFX_WideString& attribute) const;
- CFX_WideString GetAttrValue(FX_BSTR name) const
- {
- CFX_WideString attr;
- GetAttrValue(name, attr);
- return attr;
- }
- const CFX_WideStringL* GetAttrValuePtr(FX_BSTR name) const;
-
- FX_BOOL GetAttrValue(FX_BSTR space, FX_BSTR name, CFX_WideString& attribute) const;
- CFX_WideString GetAttrValue(FX_BSTR space, FX_BSTR name) const
- {
- CFX_WideString attr;
- GetAttrValue(space, name, attr);
- return attr;
- }
- const CFX_WideStringL* GetAttrValuePtr(FX_BSTR space, FX_BSTR name) const;
-
- FX_BOOL GetAttrInteger(FX_BSTR name, int& attribute) const;
- int GetAttrInteger(FX_BSTR name) const
- {
- int attr = 0;
- GetAttrInteger(name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrInteger(FX_BSTR space, FX_BSTR name, int& attribute) const;
- int GetAttrInteger(FX_BSTR space, FX_BSTR name) const
- {
- int attr = 0;
- GetAttrInteger(space, name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrFloat(FX_BSTR name, FX_FLOAT& attribute) const;
- FX_FLOAT GetAttrFloat(FX_BSTR name) const
- {
- FX_FLOAT attr = 0;
- GetAttrFloat(name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrFloat(FX_BSTR space, FX_BSTR name, FX_FLOAT& attribute) const;
- FX_FLOAT GetAttrFloat(FX_BSTR space, FX_BSTR name) const
- {
- FX_FLOAT attr = 0;
- GetAttrFloat(space, name, attr);
- return attr;
- }
-
- FX_DWORD CountChildren() const;
-
- enum ChildType { Invalid, Element, Content};
-
- ChildType GetChildType(FX_DWORD index) const;
-
- CFX_WideString GetContent(FX_DWORD index) const;
- const CFX_WideStringL* GetContentPtr(FX_DWORD index) const;
-
- CXML_Element* GetElement(FX_DWORD index) const;
-
- CXML_Element* GetElement(FX_BSTR space, FX_BSTR tag) const
- {
- return GetElement(space, tag, 0);
- }
-
- FX_DWORD CountElements(FX_BSTR space, FX_BSTR tag) const;
-
- CXML_Element* GetElement(FX_BSTR space, FX_BSTR tag, int index) const;
-
- FX_DWORD FindElement(CXML_Element *pChild) const;
-
-
-
-
- void SetTag(FX_BSTR qSpace, FX_BSTR tagname);
-
- void SetTag(FX_BSTR qTagName);
-
- void RemoveChildren();
-
- void RemoveChild(FX_DWORD index);
-
-
-protected:
-
- CXML_Element* m_pParent;
-
- CFX_ByteStringL m_QSpaceName;
-
- CFX_ByteStringL m_TagName;
-
- CXML_AttrMap m_AttrMap;
-
- CFX_PtrArray m_Children;
- friend class CXML_Parser;
- friend class CXML_Composer;
-};
-#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 _FX_XML_H_
+#define _FX_XML_H_
+#ifndef _FX_BASIC_H_
+#include "fx_basic.h"
+#endif
+class CXML_AttrItem : public CFX_Object
+{
+public:
+ CFX_ByteStringL m_QSpaceName;
+ CFX_ByteStringL m_AttrName;
+ CFX_WideStringL m_Value;
+
+ void Empty(IFX_Allocator* pAllocator = NULL)
+ {
+ m_QSpaceName.Empty(pAllocator);
+ m_AttrName.Empty(pAllocator);
+ m_Value.Empty(pAllocator);
+ }
+};
+class CXML_AttrMap : public CFX_Object
+{
+public:
+ CXML_AttrMap()
+ {
+ m_pMap = NULL;
+ }
+ ~CXML_AttrMap()
+ {
+ RemoveAll(NULL);
+ }
+ const CFX_WideStringL* Lookup(FX_BSTR space, FX_BSTR name) const;
+ void SetAt(FX_BSTR space, FX_BSTR name, FX_WSTR value, IFX_Allocator* pAllocator = NULL);
+ void RemoveAt(FX_BSTR space, FX_BSTR name, IFX_Allocator* pAllocator = NULL);
+ void RemoveAll(IFX_Allocator* pAllocator = NULL);
+ int GetSize() const;
+ CXML_AttrItem& GetAt(int index) const;
+ CFX_ObjectArray<CXML_AttrItem>* m_pMap;
+};
+class CXML_Content : public CFX_Object
+{
+public:
+ CXML_Content() : m_bCDATA(FALSE), m_Content() {}
+ ~CXML_Content()
+ {
+ Empty(NULL);
+ }
+ void Empty(IFX_Allocator* pAllocator = NULL)
+ {
+ m_Content.Empty(pAllocator);
+ }
+ void Set(FX_BOOL bCDATA, FX_WSTR content, IFX_Allocator* pAllocator = NULL)
+ {
+ m_bCDATA = bCDATA;
+ m_Content.Set(content, pAllocator);
+ }
+ FX_BOOL m_bCDATA;
+ CFX_WideStringL m_Content;
+};
+class CXML_Element : public CFX_Object
+{
+public:
+
+ static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
+
+ static CXML_Element* Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
+
+ static CXML_Element* Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
+
+ CXML_Element(FX_BSTR qSpace, FX_BSTR tagName, IFX_Allocator* pAllocator = NULL);
+
+ CXML_Element(FX_BSTR qTagName, IFX_Allocator* pAllocator = NULL);
+
+ CXML_Element(IFX_Allocator* pAllocator = NULL);
+
+ ~CXML_Element();
+
+ void Empty();
+
+
+
+ CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
+ void GetTagName(CFX_ByteStringL &tagName, FX_BOOL bQualified = FALSE) const;
+
+ CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
+ void GetNamespace(CFX_ByteStringL &nameSpace, FX_BOOL bQualified = FALSE) const;
+
+ CFX_ByteString GetNamespaceURI(FX_BSTR qName) const;
+ void GetNamespaceURI(FX_BSTR qName, CFX_ByteStringL &uri) const;
+
+ CXML_Element* GetParent() const
+ {
+ return m_pParent;
+ }
+
+ FX_DWORD CountAttrs() const
+ {
+ return m_AttrMap.GetSize();
+ }
+
+ void GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const;
+ void GetAttrByIndex(int index, CFX_ByteStringL &space, CFX_ByteStringL &name, CFX_WideStringL &value) const;
+
+ FX_BOOL HasAttr(FX_BSTR qName) const;
+
+ FX_BOOL GetAttrValue(FX_BSTR name, CFX_WideString& attribute) const;
+ CFX_WideString GetAttrValue(FX_BSTR name) const
+ {
+ CFX_WideString attr;
+ GetAttrValue(name, attr);
+ return attr;
+ }
+ const CFX_WideStringL* GetAttrValuePtr(FX_BSTR name) const;
+
+ FX_BOOL GetAttrValue(FX_BSTR space, FX_BSTR name, CFX_WideString& attribute) const;
+ CFX_WideString GetAttrValue(FX_BSTR space, FX_BSTR name) const
+ {
+ CFX_WideString attr;
+ GetAttrValue(space, name, attr);
+ return attr;
+ }
+ const CFX_WideStringL* GetAttrValuePtr(FX_BSTR space, FX_BSTR name) const;
+
+ FX_BOOL GetAttrInteger(FX_BSTR name, int& attribute) const;
+ int GetAttrInteger(FX_BSTR name) const
+ {
+ int attr = 0;
+ GetAttrInteger(name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrInteger(FX_BSTR space, FX_BSTR name, int& attribute) const;
+ int GetAttrInteger(FX_BSTR space, FX_BSTR name) const
+ {
+ int attr = 0;
+ GetAttrInteger(space, name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrFloat(FX_BSTR name, FX_FLOAT& attribute) const;
+ FX_FLOAT GetAttrFloat(FX_BSTR name) const
+ {
+ FX_FLOAT attr = 0;
+ GetAttrFloat(name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrFloat(FX_BSTR space, FX_BSTR name, FX_FLOAT& attribute) const;
+ FX_FLOAT GetAttrFloat(FX_BSTR space, FX_BSTR name) const
+ {
+ FX_FLOAT attr = 0;
+ GetAttrFloat(space, name, attr);
+ return attr;
+ }
+
+ FX_DWORD CountChildren() const;
+
+ enum ChildType { Invalid, Element, Content};
+
+ ChildType GetChildType(FX_DWORD index) const;
+
+ CFX_WideString GetContent(FX_DWORD index) const;
+ const CFX_WideStringL* GetContentPtr(FX_DWORD index) const;
+
+ CXML_Element* GetElement(FX_DWORD index) const;
+
+ CXML_Element* GetElement(FX_BSTR space, FX_BSTR tag) const
+ {
+ return GetElement(space, tag, 0);
+ }
+
+ FX_DWORD CountElements(FX_BSTR space, FX_BSTR tag) const;
+
+ CXML_Element* GetElement(FX_BSTR space, FX_BSTR tag, int index) const;
+
+ FX_DWORD FindElement(CXML_Element *pChild) const;
+
+
+
+
+ void SetTag(FX_BSTR qSpace, FX_BSTR tagname);
+
+ void SetTag(FX_BSTR qTagName);
+
+ void RemoveChildren();
+
+ void RemoveChild(FX_DWORD index);
+
+
+protected:
+
+ CXML_Element* m_pParent;
+
+ CFX_ByteStringL m_QSpaceName;
+
+ CFX_ByteStringL m_TagName;
+
+ CXML_AttrMap m_AttrMap;
+
+ CFX_PtrArray m_Children;
+ friend class CXML_Parser;
+ friend class CXML_Composer;
+};
+#endif
diff --git a/core/include/fxge/fx_dib.h b/core/include/fxge/fx_dib.h
index 7aa3bf8d10..957a957043 100644
--- a/core/include/fxge/fx_dib.h
+++ b/core/include/fxge/fx_dib.h
@@ -1,606 +1,606 @@
-// 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_DIB_H_
-#define _FPDF_DIB_H_
-#ifndef _FXCRT_EXTENSION_
-#include "../fxcrt/fx_ext.h"
-#endif
-enum FXDIB_Format {
- FXDIB_Invalid = 0,
- FXDIB_1bppMask = 0x101,
- FXDIB_1bppRgb = 0x001,
- FXDIB_1bppCmyk = 0x401,
- FXDIB_8bppMask = 0x108,
- FXDIB_8bppRgb = 0x008,
- FXDIB_8bppRgba = 0x208,
- FXDIB_8bppCmyk = 0x408,
- FXDIB_8bppCmyka = 0x608,
- FXDIB_Rgb = 0x018,
- FXDIB_Rgba = 0x218,
- FXDIB_Rgb32 = 0x020,
- FXDIB_Argb = 0x220,
- FXDIB_Cmyk = 0x420,
- FXDIB_Cmyka = 0x620,
-};
-enum FXDIB_Channel {
- FXDIB_Red = 1,
- FXDIB_Green,
- FXDIB_Blue,
- FXDIB_Cyan,
- FXDIB_Magenta,
- FXDIB_Yellow,
- FXDIB_Black,
- FXDIB_Alpha
-};
-#define FXDIB_DOWNSAMPLE 0x04
-#define FXDIB_INTERPOL 0x20
-#define FXDIB_BICUBIC_INTERPOL 0x80
-#define FXDIB_NOSMOOTH 0x100
-#define FXDIB_PALETTE_LOC 0x01
-#define FXDIB_PALETTE_WIN 0x02
-#define FXDIB_PALETTE_MAC 0x04
-#define FXDIB_BLEND_NORMAL 0
-#define FXDIB_BLEND_MULTIPLY 1
-#define FXDIB_BLEND_SCREEN 2
-#define FXDIB_BLEND_OVERLAY 3
-#define FXDIB_BLEND_DARKEN 4
-#define FXDIB_BLEND_LIGHTEN 5
-
-#define FXDIB_BLEND_COLORDODGE 6
-#define FXDIB_BLEND_COLORBURN 7
-#define FXDIB_BLEND_HARDLIGHT 8
-#define FXDIB_BLEND_SOFTLIGHT 9
-#define FXDIB_BLEND_DIFFERENCE 10
-#define FXDIB_BLEND_EXCLUSION 11
-#define FXDIB_BLEND_NONSEPARABLE 21
-#define FXDIB_BLEND_HUE 21
-#define FXDIB_BLEND_SATURATION 22
-#define FXDIB_BLEND_COLOR 23
-#define FXDIB_BLEND_LUMINOSITY 24
-#define FXDIB_BLEND_UNSUPPORTED -1
-typedef FX_DWORD FX_ARGB;
-typedef FX_DWORD FX_COLORREF;
-typedef FX_DWORD FX_CMYK;
-class CFX_ClipRgn;
-class CFX_DIBSource;
-class CFX_DIBitmap;
-#define FXSYS_RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
-#define FXSYS_GetRValue(rgb) ((rgb) & 0xff)
-#define FXSYS_GetGValue(rgb) (((rgb) >> 8) & 0xff)
-#define FXSYS_GetBValue(rgb) (((rgb) >> 16) & 0xff)
-#define FX_CCOLOR(val) (255-(val))
-#define FXSYS_CMYK(c, m, y, k) (((c) << 24) | ((m) << 16) | ((y) << 8) | (k))
-#define FXSYS_GetCValue(cmyk) ((FX_BYTE)((cmyk) >> 24) & 0xff)
-#define FXSYS_GetMValue(cmyk) ((FX_BYTE)((cmyk) >> 16) & 0xff)
-#define FXSYS_GetYValue(cmyk) ((FX_BYTE)((cmyk) >> 8) & 0xff)
-#define FXSYS_GetKValue(cmyk) ((FX_BYTE)(cmyk) & 0xff)
-void CmykDecode(FX_CMYK cmyk, int& c, int& m, int& y, int& k);
-inline FX_CMYK CmykEncode(int c, int m, int y, int k)
-{
- return (c << 24) | (m << 16) | (y << 8) | k;
-}
-void ArgbDecode(FX_ARGB argb, int& a, int& r, int&g, int& b);
-void ArgbDecode(FX_ARGB argb, int& a, FX_COLORREF& rgb);
-inline FX_ARGB ArgbEncode(int a, int r, int g, int b)
-{
- return (a << 24) | (r << 16) | (g << 8) | b;
-}
-FX_ARGB ArgbEncode(int a, FX_COLORREF rgb);
-#define FXARGB_A(argb) ((FX_BYTE)((argb) >> 24))
-#define FXARGB_R(argb) ((FX_BYTE)((argb) >> 16))
-#define FXARGB_G(argb) ((FX_BYTE)((argb) >> 8))
-#define FXARGB_B(argb) ((FX_BYTE)(argb))
-#define FXARGB_MAKE(a,r,g,b) (((FX_DWORD)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-#define FXARGB_MUL_ALPHA(argb, alpha) (((((argb) >> 24) * (alpha) / 255) << 24) | ((argb) & 0xffffff))
-#define FXRGB2GRAY(r,g,b) (((b) * 11 + (g) * 59 + (r) * 30) / 100)
-#define FXCMYK2GRAY(c,m,y,k) (((255-(c)) * (255-(k)) * 30 + (255-(m)) * (255-(k)) * 59 + (255-(y)) * (255-(k)) * 11) / 25500)
-#define FXDIB_ALPHA_MERGE(backdrop, source, source_alpha) (((backdrop) * (255-(source_alpha)) + (source)*(source_alpha))/255)
-#define FXDIB_ALPHA_UNION(dest, src) ((dest) + (src) - (dest)*(src)/255)
-#define FXCMYK_GETDIB(p) ((((FX_LPBYTE)(p))[0] << 24 | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | ((FX_LPBYTE)(p))[3]))
-#define FXCMYK_SETDIB(p, cmyk) ((FX_LPBYTE)(p))[0] = (FX_BYTE)((cmyk) >> 24), \
- ((FX_LPBYTE)(p))[1] = (FX_BYTE)((cmyk) >> 16), \
- ((FX_LPBYTE)(p))[2] = (FX_BYTE)((cmyk) >> 8), \
- ((FX_LPBYTE)(p))[3] = (FX_BYTE)(cmyk))
-#define FXARGB_GETDIB(p) (((FX_LPBYTE)(p))[0]) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[3] << 24)
-#define FXARGB_SETDIB(p, argb) ((FX_LPBYTE)(p))[0] = (FX_BYTE)(argb), \
- ((FX_LPBYTE)(p))[1] = (FX_BYTE)((argb) >> 8), \
- ((FX_LPBYTE)(p))[2] = (FX_BYTE)((argb) >> 16), \
- ((FX_LPBYTE)(p))[3] = (FX_BYTE)((argb) >> 24)
-#define FXARGB_COPY(dest, src) *(FX_LPBYTE)(dest) = *(FX_LPBYTE)(src), \
- *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
- *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src)+2), \
- *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3)
-#define FXCMYK_COPY(dest, src) *(FX_LPBYTE)(dest) = *(FX_LPBYTE)(src), \
- *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
- *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src)+2), \
- *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3)
-#define FXARGB_SETRGBORDERDIB(p, argb) ((FX_LPBYTE)(p))[3] = (FX_BYTE)(argb>>24), \
- ((FX_LPBYTE)(p))[0] = (FX_BYTE)((argb) >> 16), \
- ((FX_LPBYTE)(p))[1] = (FX_BYTE)((argb) >> 8), \
- ((FX_LPBYTE)(p))[2] = (FX_BYTE)(argb)
-#define FXARGB_GETRGBORDERDIB(p) (((FX_LPBYTE)(p))[2]) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0] << 16) | (((FX_LPBYTE)(p))[3] << 24)
-#define FXARGB_RGBORDERCOPY(dest, src) *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3), \
- *(FX_LPBYTE)(dest) = *((FX_LPBYTE)(src)+2), \
- *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
- *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src))
-#define FXARGB_TODIB(argb) (argb)
-#define FXCMYK_TODIB(cmyk) ((FX_BYTE)((cmyk) >> 24) | ((FX_BYTE)((cmyk) >> 16)) << 8 | ((FX_BYTE)((cmyk) >> 8)) << 16 | ((FX_BYTE)(cmyk) << 24))
-#define FXARGB_TOBGRORDERDIB(argb) ((FX_BYTE)(argb>>16) | ((FX_BYTE)(argb>>8)) << 8 | ((FX_BYTE)(argb)) << 16 | ((FX_BYTE)(argb>>24) << 24))
-#define FXGETFLAG_COLORTYPE(flag) (FX_BYTE)((flag)>>8)
-#define FXGETFLAG_ALPHA_FILL(flag) (FX_BYTE)(flag)
-#define FXGETFLAG_ALPHA_STROKE(flag) (FX_BYTE)((flag)>>16)
-#define FXSETFLAG_COLORTYPE(flag, val) flag = (((val)<<8)|(flag&0xffff00ff))
-#define FXSETFLAG_ALPHA_FILL(flag, val) flag = ((val)|(flag&0xffffff00))
-#define FXSETFLAG_ALPHA_STROKE(flag, val) flag = (((val)<<16)|(flag&0xff00ffff))
-class CFX_DIBSource : public CFX_Object
-{
-public:
-
- virtual ~CFX_DIBSource();
-
-
-
- int GetWidth() const
- {
- return m_Width;
- }
-
- int GetHeight() const
- {
- return m_Height;
- }
-
- FXDIB_Format GetFormat() const
- {
- return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp);
- }
-
- FX_DWORD GetPitch() const
- {
- return m_Pitch;
- }
-
- FX_DWORD* GetPalette() const
- {
- return m_pPalette;
- }
-
-
-
- virtual FX_LPBYTE GetBuffer() const
- {
- return NULL;
- }
-
- virtual FX_LPCBYTE GetScanline(int line) const = 0;
-
- virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const
- {
- return FALSE;
- }
-
- virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
- int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const = 0;
-
- virtual void SetDownSampleSize(int width, int height) const {}
-
- int GetBPP() const
- {
- return m_bpp;
- }
-
- FX_BOOL IsAlphaMask() const
- {
- return m_AlphaFlag == 1;
- }
-
- FX_BOOL HasAlpha() const
- {
- return m_AlphaFlag & 2 ? TRUE : FALSE;
- }
-
- FX_BOOL IsOpaqueImage() const
- {
- return !(m_AlphaFlag & 3);
- }
-
- FX_BOOL IsCmykImage() const
- {
- return m_AlphaFlag & 4 ? TRUE : FALSE;
- }
-
-
-
- int GetPaletteSize() const
- {
- return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0));
- }
-
- FX_DWORD GetPaletteEntry(int index) const;
-
- void SetPaletteEntry(int index, FX_DWORD color);
- FX_DWORD GetPaletteArgb(int index) const
- {
- return GetPaletteEntry(index);
- }
- void SetPaletteArgb(int index, FX_DWORD color)
- {
- SetPaletteEntry(index, color);
- }
-
- void CopyPalette(const FX_DWORD* pSrcPal, FX_DWORD size = 256);
-
-
- CFX_DIBitmap* Clone(const FX_RECT* pClip = NULL) const;
-
- CFX_DIBitmap* CloneConvert(FXDIB_Format format, const FX_RECT* pClip = NULL, void* pIccTransform = NULL) const;
-
- CFX_DIBitmap* StretchTo(int dest_width, int dest_height, FX_DWORD flags = 0, const FX_RECT* pClip = NULL) const;
-
-
- CFX_DIBitmap* TransformTo(const CFX_AffineMatrix* pMatrix, int& left, int &top,
- FX_DWORD flags = 0, const FX_RECT* pClip = NULL) const;
-
- CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = NULL) const;
-
- FX_BOOL CopyAlphaMask(const CFX_DIBSource* pAlphaMask, const FX_RECT* pClip = NULL);
-
- CFX_DIBitmap* SwapXY(FX_BOOL bXFlip, FX_BOOL bYFlip, const FX_RECT* pClip = NULL) const;
-
- CFX_DIBitmap* FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const;
-
- void GetOverlapRect(int& dest_left, int& dest_top, int& width, int& height, int src_width,
- int src_height, int& src_left, int& src_top, const CFX_ClipRgn* pClipRgn);
-
- CFX_DIBitmap* m_pAlphaMask;
-protected:
-
- CFX_DIBSource();
-
- int m_Width;
-
- int m_Height;
-
- int m_bpp;
-
- FX_DWORD m_AlphaFlag;
-
- FX_DWORD m_Pitch;
-
- FX_DWORD* m_pPalette;
-
- void BuildPalette();
-
- FX_BOOL BuildAlphaMask();
-
- int FindPalette(FX_DWORD color) const;
-
- void GetPalette(FX_DWORD* pal, int alpha) const;
-};
-class CFX_DIBitmap : public CFX_DIBSource
-{
-public:
-
- virtual ~CFX_DIBitmap();
-
- CFX_DIBitmap();
-
- CFX_DIBitmap(const CFX_DIBitmap& src);
-
- FX_BOOL Create(int width, int height, FXDIB_Format format, FX_LPBYTE pBuffer = NULL, int pitch = 0);
-
- FX_BOOL Copy(const CFX_DIBSource* pSrc);
-
- virtual FX_LPBYTE GetBuffer() const
- {
- return m_pBuffer;
- }
-
- virtual FX_LPCBYTE GetScanline(int line) const
- {
- return m_pBuffer ? m_pBuffer + line * m_Pitch : NULL;
- }
-
- virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
- int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const;
-
- void TakeOver(CFX_DIBitmap* pSrcBitmap);
-
- FX_BOOL ConvertFormat(FXDIB_Format format, void* pIccTransform = NULL);
-
- void Clear(FX_DWORD color);
-
- FX_DWORD GetPixel(int x, int y) const;
-
- void SetPixel(int x, int y, FX_DWORD color);
-
- FX_BOOL LoadChannel(FXDIB_Channel destChannel, const CFX_DIBSource* pSrcBitmap, FXDIB_Channel srcChannel);
-
- FX_BOOL LoadChannel(FXDIB_Channel destChannel, int value);
-
- FX_BOOL MultiplyAlpha(int alpha);
-
- FX_BOOL MultiplyAlpha(const CFX_DIBSource* pAlphaMask);
-
- FX_BOOL TransferBitmap(int dest_left, int dest_top, int width, int height,
- const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, void* pIccTransform = NULL);
-
- FX_BOOL CompositeBitmap(int dest_left, int dest_top, int width, int height,
- const CFX_DIBSource* pSrcBitmap, int src_left, int src_top,
- int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = NULL, FX_BOOL bRgbByteOrder = FALSE, void* pIccTransform = NULL);
-
- FX_BOOL TransferMask(int dest_left, int dest_top, int width, int height,
- const CFX_DIBSource* pMask, FX_DWORD color, int src_left, int src_top, int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL CompositeMask(int dest_left, int dest_top, int width, int height,
- const CFX_DIBSource* pMask, FX_DWORD color, int src_left, int src_top,
- int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = NULL, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL CompositeRect(int dest_left, int dest_top, int width, int height, FX_DWORD color, int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor);
-
- FX_BOOL DitherFS(const FX_DWORD* pPalette, int pal_size, const FX_RECT* pRect = NULL);
-protected:
-
- FX_LPBYTE m_pBuffer;
-
- FX_BOOL m_bExtBuf;
-
- FX_BOOL GetGrayData(void* pIccTransform = NULL);
-};
-class CFX_DIBExtractor : public CFX_Object
-{
-public:
-
- CFX_DIBExtractor(const CFX_DIBSource* pSrc);
-
- ~CFX_DIBExtractor();
-
- operator CFX_DIBitmap*()
- {
- return m_pBitmap;
- }
-private:
-
- CFX_DIBitmap* m_pBitmap;
-};
-typedef CFX_CountRef<CFX_DIBitmap> CFX_DIBitmapRef;
-class CFX_FilteredDIB : public CFX_DIBSource
-{
-public:
-
- CFX_FilteredDIB();
-
- ~CFX_FilteredDIB();
-
- void LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc = FALSE);
-
- virtual FXDIB_Format GetDestFormat() = 0;
-
- virtual FX_DWORD* GetDestPalette() = 0;
-
-
- virtual void TranslateScanline(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf) const = 0;
-
- virtual void TranslateDownSamples(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels, int Bpp) const = 0;
-protected:
- virtual FX_LPCBYTE GetScanline(int line) const;
- virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
- int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const;
-
- const CFX_DIBSource* m_pSrc;
-
- FX_BOOL m_bAutoDropSrc;
-
- FX_LPBYTE m_pScanline;
-};
-class IFX_ScanlineComposer
-{
-public:
-
- virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha = NULL) = 0;
-
-
- virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette) = 0;
-};
-class CFX_ScanlineCompositor : public CFX_Object
-{
-public:
-
- CFX_ScanlineCompositor();
-
- ~CFX_ScanlineCompositor();
-
- FX_BOOL Init(FXDIB_Format dest_format, FXDIB_Format src_format, FX_INT32 width, FX_DWORD* pSrcPalette,
- FX_DWORD mask_color, int blend_type, FX_BOOL bClip, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL);
-
-
- void CompositeRgbBitmapLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int width, FX_LPCBYTE clip_scan,
- FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
-
-
- void CompositePalBitmapLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int src_left, int width, FX_LPCBYTE clip_scan,
- FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
-
-
- void CompositeByteMaskLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int width, FX_LPCBYTE clip_scan,
- FX_LPBYTE dst_extra_alpha = NULL);
-
-
- void CompositeBitMaskLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int src_left, int width, FX_LPCBYTE clip_scan,
- FX_LPBYTE dst_extra_alpha = NULL);
-protected:
- int m_Transparency;
- FXDIB_Format m_SrcFormat,
- m_DestFormat;
- FX_DWORD* m_pSrcPalette;
-
- int m_MaskAlpha,
- m_MaskRed,
- m_MaskGreen,
- m_MaskBlue,
- m_MaskBlack;
- int m_BlendType;
- void* m_pIccTransform;
- FX_LPBYTE m_pCacheScanline;
- int m_CacheSize;
- FX_BOOL m_bRgbByteOrder;
-};
-class CFX_BitmapComposer : public IFX_ScanlineComposer, public CFX_Object
-{
-public:
-
- CFX_BitmapComposer();
-
- ~CFX_BitmapComposer();
-
-
- void Compose(CFX_DIBitmap* pDest, const CFX_ClipRgn* pClipRgn, int bitmap_alpha,
- FX_DWORD mask_color, FX_RECT& dest_rect, FX_BOOL bVertical,
- FX_BOOL bFlipX, FX_BOOL bFlipY, FX_BOOL bRgbByteOrder = FALSE,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
-
- virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette);
-
-
- virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha);
-protected:
-
- void DoCompose(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int dest_width, FX_LPCBYTE clip_scan,
- FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
- CFX_DIBitmap* m_pBitmap;
- const CFX_ClipRgn* m_pClipRgn;
- FXDIB_Format m_SrcFormat;
- int m_DestLeft, m_DestTop, m_DestWidth, m_DestHeight, m_BitmapAlpha;
- FX_DWORD m_MaskColor;
- const CFX_DIBitmap* m_pClipMask;
- CFX_ScanlineCompositor m_Compositor;
- FX_BOOL m_bVertical, m_bFlipX, m_bFlipY;
- int m_AlphaFlag;
- void* m_pIccTransform;
- FX_BOOL m_bRgbByteOrder;
- int m_BlendType;
- void ComposeScanlineV(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha = NULL);
- FX_LPBYTE m_pScanlineV, m_pClipScanV, m_pAddClipScan, m_pScanlineAlphaV;
-};
-class CFX_BitmapStorer : public IFX_ScanlineComposer, public CFX_Object
-{
-public:
-
- CFX_BitmapStorer();
-
- ~CFX_BitmapStorer();
-
- virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha);
-
- virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette);
-
- CFX_DIBitmap* GetBitmap()
- {
- return m_pBitmap;
- }
-
- CFX_DIBitmap* Detach();
-
- void Replace(CFX_DIBitmap* pBitmap);
-private:
- CFX_DIBitmap* m_pBitmap;
-};
-class CStretchEngine;
-class CFX_ImageStretcher : public CFX_Object
-{
-public:
-
- CFX_ImageStretcher();
-
- ~CFX_ImageStretcher();
-
- FX_INT32 Start(IFX_ScanlineComposer* pDest, const CFX_DIBSource* pBitmap,
- int dest_width, int dest_height, const FX_RECT& bitmap_rect, FX_DWORD flags);
-
-
- FX_INT32 Continue(IFX_Pause* pPause);
- IFX_ScanlineComposer* m_pDest;
- const CFX_DIBSource* m_pSource;
- CStretchEngine* m_pStretchEngine;
- FX_DWORD m_Flags;
- FX_BOOL m_bFlipX,
- m_bFlipY;
- int m_DestWidth,
- m_DestHeight;
- FX_RECT m_ClipRect;
- int m_LineIndex;
- int m_DestBPP;
- FX_LPBYTE m_pScanline;
- FX_LPBYTE m_pMaskScanline;
- FXDIB_Format m_DestFormat;
- FX_INT32 m_Status;
-
- FX_INT32 StartQuickStretch();
-
- FX_INT32 StartStretch();
-
- FX_INT32 ContinueQuickStretch(IFX_Pause* pPause);
-
- FX_INT32 ContinueStretch(IFX_Pause* pPause);
-};
-class CFX_ImageTransformer : public CFX_Object
-{
-public:
-
- CFX_ImageTransformer();
-
- ~CFX_ImageTransformer();
-
- FX_INT32 Start(const CFX_DIBSource* pSrc, const CFX_AffineMatrix* pMatrix, int flags, const FX_RECT* pClip);
-
-
- FX_INT32 Continue(IFX_Pause* pPause);
- CFX_AffineMatrix* m_pMatrix;
- FX_RECT m_StretchClip;
- int m_ResultLeft, m_ResultTop, m_ResultWidth, m_ResultHeight;
- CFX_AffineMatrix m_dest2stretch;
- CFX_ImageStretcher m_Stretcher;
- CFX_BitmapStorer m_Storer;
- FX_DWORD m_Flags;
- int m_Status;
-};
-class CFX_ImageRenderer : public CFX_Object
-{
-public:
-
- CFX_ImageRenderer();
-
- ~CFX_ImageRenderer();
-
- FX_INT32 Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClipRgn,
- const CFX_DIBSource* pSource, int bitmap_alpha,
- FX_DWORD mask_color, const CFX_AffineMatrix* pMatrix, FX_DWORD dib_flags,
- FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL);
-
- FX_INT32 Continue(IFX_Pause* pPause);
-protected:
- CFX_DIBitmap* m_pDevice;
- const CFX_ClipRgn* m_pClipRgn;
- int m_BitmapAlpha;
- FX_DWORD m_MaskColor;
- CFX_AffineMatrix m_Matrix;
- CFX_ImageTransformer* m_pTransformer;
- CFX_ImageStretcher m_Stretcher;
- CFX_BitmapComposer m_Composer;
- int m_Status;
- int m_DestLeft, m_DestTop;
- FX_RECT m_ClipBox;
- FX_DWORD m_Flags;
- int m_AlphaFlag;
- void* m_pIccTransform;
- FX_BOOL m_bRgbByteOrder;
- int m_BlendType;
-};
-#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_DIB_H_
+#define _FPDF_DIB_H_
+#ifndef _FXCRT_EXTENSION_
+#include "../fxcrt/fx_ext.h"
+#endif
+enum FXDIB_Format {
+ FXDIB_Invalid = 0,
+ FXDIB_1bppMask = 0x101,
+ FXDIB_1bppRgb = 0x001,
+ FXDIB_1bppCmyk = 0x401,
+ FXDIB_8bppMask = 0x108,
+ FXDIB_8bppRgb = 0x008,
+ FXDIB_8bppRgba = 0x208,
+ FXDIB_8bppCmyk = 0x408,
+ FXDIB_8bppCmyka = 0x608,
+ FXDIB_Rgb = 0x018,
+ FXDIB_Rgba = 0x218,
+ FXDIB_Rgb32 = 0x020,
+ FXDIB_Argb = 0x220,
+ FXDIB_Cmyk = 0x420,
+ FXDIB_Cmyka = 0x620,
+};
+enum FXDIB_Channel {
+ FXDIB_Red = 1,
+ FXDIB_Green,
+ FXDIB_Blue,
+ FXDIB_Cyan,
+ FXDIB_Magenta,
+ FXDIB_Yellow,
+ FXDIB_Black,
+ FXDIB_Alpha
+};
+#define FXDIB_DOWNSAMPLE 0x04
+#define FXDIB_INTERPOL 0x20
+#define FXDIB_BICUBIC_INTERPOL 0x80
+#define FXDIB_NOSMOOTH 0x100
+#define FXDIB_PALETTE_LOC 0x01
+#define FXDIB_PALETTE_WIN 0x02
+#define FXDIB_PALETTE_MAC 0x04
+#define FXDIB_BLEND_NORMAL 0
+#define FXDIB_BLEND_MULTIPLY 1
+#define FXDIB_BLEND_SCREEN 2
+#define FXDIB_BLEND_OVERLAY 3
+#define FXDIB_BLEND_DARKEN 4
+#define FXDIB_BLEND_LIGHTEN 5
+
+#define FXDIB_BLEND_COLORDODGE 6
+#define FXDIB_BLEND_COLORBURN 7
+#define FXDIB_BLEND_HARDLIGHT 8
+#define FXDIB_BLEND_SOFTLIGHT 9
+#define FXDIB_BLEND_DIFFERENCE 10
+#define FXDIB_BLEND_EXCLUSION 11
+#define FXDIB_BLEND_NONSEPARABLE 21
+#define FXDIB_BLEND_HUE 21
+#define FXDIB_BLEND_SATURATION 22
+#define FXDIB_BLEND_COLOR 23
+#define FXDIB_BLEND_LUMINOSITY 24
+#define FXDIB_BLEND_UNSUPPORTED -1
+typedef FX_DWORD FX_ARGB;
+typedef FX_DWORD FX_COLORREF;
+typedef FX_DWORD FX_CMYK;
+class CFX_ClipRgn;
+class CFX_DIBSource;
+class CFX_DIBitmap;
+#define FXSYS_RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
+#define FXSYS_GetRValue(rgb) ((rgb) & 0xff)
+#define FXSYS_GetGValue(rgb) (((rgb) >> 8) & 0xff)
+#define FXSYS_GetBValue(rgb) (((rgb) >> 16) & 0xff)
+#define FX_CCOLOR(val) (255-(val))
+#define FXSYS_CMYK(c, m, y, k) (((c) << 24) | ((m) << 16) | ((y) << 8) | (k))
+#define FXSYS_GetCValue(cmyk) ((FX_BYTE)((cmyk) >> 24) & 0xff)
+#define FXSYS_GetMValue(cmyk) ((FX_BYTE)((cmyk) >> 16) & 0xff)
+#define FXSYS_GetYValue(cmyk) ((FX_BYTE)((cmyk) >> 8) & 0xff)
+#define FXSYS_GetKValue(cmyk) ((FX_BYTE)(cmyk) & 0xff)
+void CmykDecode(FX_CMYK cmyk, int& c, int& m, int& y, int& k);
+inline FX_CMYK CmykEncode(int c, int m, int y, int k)
+{
+ return (c << 24) | (m << 16) | (y << 8) | k;
+}
+void ArgbDecode(FX_ARGB argb, int& a, int& r, int&g, int& b);
+void ArgbDecode(FX_ARGB argb, int& a, FX_COLORREF& rgb);
+inline FX_ARGB ArgbEncode(int a, int r, int g, int b)
+{
+ return (a << 24) | (r << 16) | (g << 8) | b;
+}
+FX_ARGB ArgbEncode(int a, FX_COLORREF rgb);
+#define FXARGB_A(argb) ((FX_BYTE)((argb) >> 24))
+#define FXARGB_R(argb) ((FX_BYTE)((argb) >> 16))
+#define FXARGB_G(argb) ((FX_BYTE)((argb) >> 8))
+#define FXARGB_B(argb) ((FX_BYTE)(argb))
+#define FXARGB_MAKE(a,r,g,b) (((FX_DWORD)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+#define FXARGB_MUL_ALPHA(argb, alpha) (((((argb) >> 24) * (alpha) / 255) << 24) | ((argb) & 0xffffff))
+#define FXRGB2GRAY(r,g,b) (((b) * 11 + (g) * 59 + (r) * 30) / 100)
+#define FXCMYK2GRAY(c,m,y,k) (((255-(c)) * (255-(k)) * 30 + (255-(m)) * (255-(k)) * 59 + (255-(y)) * (255-(k)) * 11) / 25500)
+#define FXDIB_ALPHA_MERGE(backdrop, source, source_alpha) (((backdrop) * (255-(source_alpha)) + (source)*(source_alpha))/255)
+#define FXDIB_ALPHA_UNION(dest, src) ((dest) + (src) - (dest)*(src)/255)
+#define FXCMYK_GETDIB(p) ((((FX_LPBYTE)(p))[0] << 24 | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | ((FX_LPBYTE)(p))[3]))
+#define FXCMYK_SETDIB(p, cmyk) ((FX_LPBYTE)(p))[0] = (FX_BYTE)((cmyk) >> 24), \
+ ((FX_LPBYTE)(p))[1] = (FX_BYTE)((cmyk) >> 16), \
+ ((FX_LPBYTE)(p))[2] = (FX_BYTE)((cmyk) >> 8), \
+ ((FX_LPBYTE)(p))[3] = (FX_BYTE)(cmyk))
+#define FXARGB_GETDIB(p) (((FX_LPBYTE)(p))[0]) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[3] << 24)
+#define FXARGB_SETDIB(p, argb) ((FX_LPBYTE)(p))[0] = (FX_BYTE)(argb), \
+ ((FX_LPBYTE)(p))[1] = (FX_BYTE)((argb) >> 8), \
+ ((FX_LPBYTE)(p))[2] = (FX_BYTE)((argb) >> 16), \
+ ((FX_LPBYTE)(p))[3] = (FX_BYTE)((argb) >> 24)
+#define FXARGB_COPY(dest, src) *(FX_LPBYTE)(dest) = *(FX_LPBYTE)(src), \
+ *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
+ *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src)+2), \
+ *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3)
+#define FXCMYK_COPY(dest, src) *(FX_LPBYTE)(dest) = *(FX_LPBYTE)(src), \
+ *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
+ *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src)+2), \
+ *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3)
+#define FXARGB_SETRGBORDERDIB(p, argb) ((FX_LPBYTE)(p))[3] = (FX_BYTE)(argb>>24), \
+ ((FX_LPBYTE)(p))[0] = (FX_BYTE)((argb) >> 16), \
+ ((FX_LPBYTE)(p))[1] = (FX_BYTE)((argb) >> 8), \
+ ((FX_LPBYTE)(p))[2] = (FX_BYTE)(argb)
+#define FXARGB_GETRGBORDERDIB(p) (((FX_LPBYTE)(p))[2]) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0] << 16) | (((FX_LPBYTE)(p))[3] << 24)
+#define FXARGB_RGBORDERCOPY(dest, src) *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3), \
+ *(FX_LPBYTE)(dest) = *((FX_LPBYTE)(src)+2), \
+ *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
+ *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src))
+#define FXARGB_TODIB(argb) (argb)
+#define FXCMYK_TODIB(cmyk) ((FX_BYTE)((cmyk) >> 24) | ((FX_BYTE)((cmyk) >> 16)) << 8 | ((FX_BYTE)((cmyk) >> 8)) << 16 | ((FX_BYTE)(cmyk) << 24))
+#define FXARGB_TOBGRORDERDIB(argb) ((FX_BYTE)(argb>>16) | ((FX_BYTE)(argb>>8)) << 8 | ((FX_BYTE)(argb)) << 16 | ((FX_BYTE)(argb>>24) << 24))
+#define FXGETFLAG_COLORTYPE(flag) (FX_BYTE)((flag)>>8)
+#define FXGETFLAG_ALPHA_FILL(flag) (FX_BYTE)(flag)
+#define FXGETFLAG_ALPHA_STROKE(flag) (FX_BYTE)((flag)>>16)
+#define FXSETFLAG_COLORTYPE(flag, val) flag = (((val)<<8)|(flag&0xffff00ff))
+#define FXSETFLAG_ALPHA_FILL(flag, val) flag = ((val)|(flag&0xffffff00))
+#define FXSETFLAG_ALPHA_STROKE(flag, val) flag = (((val)<<16)|(flag&0xff00ffff))
+class CFX_DIBSource : public CFX_Object
+{
+public:
+
+ virtual ~CFX_DIBSource();
+
+
+
+ int GetWidth() const
+ {
+ return m_Width;
+ }
+
+ int GetHeight() const
+ {
+ return m_Height;
+ }
+
+ FXDIB_Format GetFormat() const
+ {
+ return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp);
+ }
+
+ FX_DWORD GetPitch() const
+ {
+ return m_Pitch;
+ }
+
+ FX_DWORD* GetPalette() const
+ {
+ return m_pPalette;
+ }
+
+
+
+ virtual FX_LPBYTE GetBuffer() const
+ {
+ return NULL;
+ }
+
+ virtual FX_LPCBYTE GetScanline(int line) const = 0;
+
+ virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const
+ {
+ return FALSE;
+ }
+
+ virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
+ int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const = 0;
+
+ virtual void SetDownSampleSize(int width, int height) const {}
+
+ int GetBPP() const
+ {
+ return m_bpp;
+ }
+
+ FX_BOOL IsAlphaMask() const
+ {
+ return m_AlphaFlag == 1;
+ }
+
+ FX_BOOL HasAlpha() const
+ {
+ return m_AlphaFlag & 2 ? TRUE : FALSE;
+ }
+
+ FX_BOOL IsOpaqueImage() const
+ {
+ return !(m_AlphaFlag & 3);
+ }
+
+ FX_BOOL IsCmykImage() const
+ {
+ return m_AlphaFlag & 4 ? TRUE : FALSE;
+ }
+
+
+
+ int GetPaletteSize() const
+ {
+ return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0));
+ }
+
+ FX_DWORD GetPaletteEntry(int index) const;
+
+ void SetPaletteEntry(int index, FX_DWORD color);
+ FX_DWORD GetPaletteArgb(int index) const
+ {
+ return GetPaletteEntry(index);
+ }
+ void SetPaletteArgb(int index, FX_DWORD color)
+ {
+ SetPaletteEntry(index, color);
+ }
+
+ void CopyPalette(const FX_DWORD* pSrcPal, FX_DWORD size = 256);
+
+
+ CFX_DIBitmap* Clone(const FX_RECT* pClip = NULL) const;
+
+ CFX_DIBitmap* CloneConvert(FXDIB_Format format, const FX_RECT* pClip = NULL, void* pIccTransform = NULL) const;
+
+ CFX_DIBitmap* StretchTo(int dest_width, int dest_height, FX_DWORD flags = 0, const FX_RECT* pClip = NULL) const;
+
+
+ CFX_DIBitmap* TransformTo(const CFX_AffineMatrix* pMatrix, int& left, int &top,
+ FX_DWORD flags = 0, const FX_RECT* pClip = NULL) const;
+
+ CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = NULL) const;
+
+ FX_BOOL CopyAlphaMask(const CFX_DIBSource* pAlphaMask, const FX_RECT* pClip = NULL);
+
+ CFX_DIBitmap* SwapXY(FX_BOOL bXFlip, FX_BOOL bYFlip, const FX_RECT* pClip = NULL) const;
+
+ CFX_DIBitmap* FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const;
+
+ void GetOverlapRect(int& dest_left, int& dest_top, int& width, int& height, int src_width,
+ int src_height, int& src_left, int& src_top, const CFX_ClipRgn* pClipRgn);
+
+ CFX_DIBitmap* m_pAlphaMask;
+protected:
+
+ CFX_DIBSource();
+
+ int m_Width;
+
+ int m_Height;
+
+ int m_bpp;
+
+ FX_DWORD m_AlphaFlag;
+
+ FX_DWORD m_Pitch;
+
+ FX_DWORD* m_pPalette;
+
+ void BuildPalette();
+
+ FX_BOOL BuildAlphaMask();
+
+ int FindPalette(FX_DWORD color) const;
+
+ void GetPalette(FX_DWORD* pal, int alpha) const;
+};
+class CFX_DIBitmap : public CFX_DIBSource
+{
+public:
+
+ virtual ~CFX_DIBitmap();
+
+ CFX_DIBitmap();
+
+ CFX_DIBitmap(const CFX_DIBitmap& src);
+
+ FX_BOOL Create(int width, int height, FXDIB_Format format, FX_LPBYTE pBuffer = NULL, int pitch = 0);
+
+ FX_BOOL Copy(const CFX_DIBSource* pSrc);
+
+ virtual FX_LPBYTE GetBuffer() const
+ {
+ return m_pBuffer;
+ }
+
+ virtual FX_LPCBYTE GetScanline(int line) const
+ {
+ return m_pBuffer ? m_pBuffer + line * m_Pitch : NULL;
+ }
+
+ virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
+ int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const;
+
+ void TakeOver(CFX_DIBitmap* pSrcBitmap);
+
+ FX_BOOL ConvertFormat(FXDIB_Format format, void* pIccTransform = NULL);
+
+ void Clear(FX_DWORD color);
+
+ FX_DWORD GetPixel(int x, int y) const;
+
+ void SetPixel(int x, int y, FX_DWORD color);
+
+ FX_BOOL LoadChannel(FXDIB_Channel destChannel, const CFX_DIBSource* pSrcBitmap, FXDIB_Channel srcChannel);
+
+ FX_BOOL LoadChannel(FXDIB_Channel destChannel, int value);
+
+ FX_BOOL MultiplyAlpha(int alpha);
+
+ FX_BOOL MultiplyAlpha(const CFX_DIBSource* pAlphaMask);
+
+ FX_BOOL TransferBitmap(int dest_left, int dest_top, int width, int height,
+ const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, void* pIccTransform = NULL);
+
+ FX_BOOL CompositeBitmap(int dest_left, int dest_top, int width, int height,
+ const CFX_DIBSource* pSrcBitmap, int src_left, int src_top,
+ int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = NULL, FX_BOOL bRgbByteOrder = FALSE, void* pIccTransform = NULL);
+
+ FX_BOOL TransferMask(int dest_left, int dest_top, int width, int height,
+ const CFX_DIBSource* pMask, FX_DWORD color, int src_left, int src_top, int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL CompositeMask(int dest_left, int dest_top, int width, int height,
+ const CFX_DIBSource* pMask, FX_DWORD color, int src_left, int src_top,
+ int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = NULL, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL CompositeRect(int dest_left, int dest_top, int width, int height, FX_DWORD color, int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor);
+
+ FX_BOOL DitherFS(const FX_DWORD* pPalette, int pal_size, const FX_RECT* pRect = NULL);
+protected:
+
+ FX_LPBYTE m_pBuffer;
+
+ FX_BOOL m_bExtBuf;
+
+ FX_BOOL GetGrayData(void* pIccTransform = NULL);
+};
+class CFX_DIBExtractor : public CFX_Object
+{
+public:
+
+ CFX_DIBExtractor(const CFX_DIBSource* pSrc);
+
+ ~CFX_DIBExtractor();
+
+ operator CFX_DIBitmap*()
+ {
+ return m_pBitmap;
+ }
+private:
+
+ CFX_DIBitmap* m_pBitmap;
+};
+typedef CFX_CountRef<CFX_DIBitmap> CFX_DIBitmapRef;
+class CFX_FilteredDIB : public CFX_DIBSource
+{
+public:
+
+ CFX_FilteredDIB();
+
+ ~CFX_FilteredDIB();
+
+ void LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc = FALSE);
+
+ virtual FXDIB_Format GetDestFormat() = 0;
+
+ virtual FX_DWORD* GetDestPalette() = 0;
+
+
+ virtual void TranslateScanline(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf) const = 0;
+
+ virtual void TranslateDownSamples(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels, int Bpp) const = 0;
+protected:
+ virtual FX_LPCBYTE GetScanline(int line) const;
+ virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
+ int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const;
+
+ const CFX_DIBSource* m_pSrc;
+
+ FX_BOOL m_bAutoDropSrc;
+
+ FX_LPBYTE m_pScanline;
+};
+class IFX_ScanlineComposer
+{
+public:
+
+ virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha = NULL) = 0;
+
+
+ virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette) = 0;
+};
+class CFX_ScanlineCompositor : public CFX_Object
+{
+public:
+
+ CFX_ScanlineCompositor();
+
+ ~CFX_ScanlineCompositor();
+
+ FX_BOOL Init(FXDIB_Format dest_format, FXDIB_Format src_format, FX_INT32 width, FX_DWORD* pSrcPalette,
+ FX_DWORD mask_color, int blend_type, FX_BOOL bClip, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL);
+
+
+ void CompositeRgbBitmapLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int width, FX_LPCBYTE clip_scan,
+ FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
+
+
+ void CompositePalBitmapLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int src_left, int width, FX_LPCBYTE clip_scan,
+ FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
+
+
+ void CompositeByteMaskLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int width, FX_LPCBYTE clip_scan,
+ FX_LPBYTE dst_extra_alpha = NULL);
+
+
+ void CompositeBitMaskLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int src_left, int width, FX_LPCBYTE clip_scan,
+ FX_LPBYTE dst_extra_alpha = NULL);
+protected:
+ int m_Transparency;
+ FXDIB_Format m_SrcFormat,
+ m_DestFormat;
+ FX_DWORD* m_pSrcPalette;
+
+ int m_MaskAlpha,
+ m_MaskRed,
+ m_MaskGreen,
+ m_MaskBlue,
+ m_MaskBlack;
+ int m_BlendType;
+ void* m_pIccTransform;
+ FX_LPBYTE m_pCacheScanline;
+ int m_CacheSize;
+ FX_BOOL m_bRgbByteOrder;
+};
+class CFX_BitmapComposer : public IFX_ScanlineComposer, public CFX_Object
+{
+public:
+
+ CFX_BitmapComposer();
+
+ ~CFX_BitmapComposer();
+
+
+ void Compose(CFX_DIBitmap* pDest, const CFX_ClipRgn* pClipRgn, int bitmap_alpha,
+ FX_DWORD mask_color, FX_RECT& dest_rect, FX_BOOL bVertical,
+ FX_BOOL bFlipX, FX_BOOL bFlipY, FX_BOOL bRgbByteOrder = FALSE,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
+
+ virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette);
+
+
+ virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha);
+protected:
+
+ void DoCompose(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int dest_width, FX_LPCBYTE clip_scan,
+ FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
+ CFX_DIBitmap* m_pBitmap;
+ const CFX_ClipRgn* m_pClipRgn;
+ FXDIB_Format m_SrcFormat;
+ int m_DestLeft, m_DestTop, m_DestWidth, m_DestHeight, m_BitmapAlpha;
+ FX_DWORD m_MaskColor;
+ const CFX_DIBitmap* m_pClipMask;
+ CFX_ScanlineCompositor m_Compositor;
+ FX_BOOL m_bVertical, m_bFlipX, m_bFlipY;
+ int m_AlphaFlag;
+ void* m_pIccTransform;
+ FX_BOOL m_bRgbByteOrder;
+ int m_BlendType;
+ void ComposeScanlineV(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha = NULL);
+ FX_LPBYTE m_pScanlineV, m_pClipScanV, m_pAddClipScan, m_pScanlineAlphaV;
+};
+class CFX_BitmapStorer : public IFX_ScanlineComposer, public CFX_Object
+{
+public:
+
+ CFX_BitmapStorer();
+
+ ~CFX_BitmapStorer();
+
+ virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha);
+
+ virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette);
+
+ CFX_DIBitmap* GetBitmap()
+ {
+ return m_pBitmap;
+ }
+
+ CFX_DIBitmap* Detach();
+
+ void Replace(CFX_DIBitmap* pBitmap);
+private:
+ CFX_DIBitmap* m_pBitmap;
+};
+class CStretchEngine;
+class CFX_ImageStretcher : public CFX_Object
+{
+public:
+
+ CFX_ImageStretcher();
+
+ ~CFX_ImageStretcher();
+
+ FX_INT32 Start(IFX_ScanlineComposer* pDest, const CFX_DIBSource* pBitmap,
+ int dest_width, int dest_height, const FX_RECT& bitmap_rect, FX_DWORD flags);
+
+
+ FX_INT32 Continue(IFX_Pause* pPause);
+ IFX_ScanlineComposer* m_pDest;
+ const CFX_DIBSource* m_pSource;
+ CStretchEngine* m_pStretchEngine;
+ FX_DWORD m_Flags;
+ FX_BOOL m_bFlipX,
+ m_bFlipY;
+ int m_DestWidth,
+ m_DestHeight;
+ FX_RECT m_ClipRect;
+ int m_LineIndex;
+ int m_DestBPP;
+ FX_LPBYTE m_pScanline;
+ FX_LPBYTE m_pMaskScanline;
+ FXDIB_Format m_DestFormat;
+ FX_INT32 m_Status;
+
+ FX_INT32 StartQuickStretch();
+
+ FX_INT32 StartStretch();
+
+ FX_INT32 ContinueQuickStretch(IFX_Pause* pPause);
+
+ FX_INT32 ContinueStretch(IFX_Pause* pPause);
+};
+class CFX_ImageTransformer : public CFX_Object
+{
+public:
+
+ CFX_ImageTransformer();
+
+ ~CFX_ImageTransformer();
+
+ FX_INT32 Start(const CFX_DIBSource* pSrc, const CFX_AffineMatrix* pMatrix, int flags, const FX_RECT* pClip);
+
+
+ FX_INT32 Continue(IFX_Pause* pPause);
+ CFX_AffineMatrix* m_pMatrix;
+ FX_RECT m_StretchClip;
+ int m_ResultLeft, m_ResultTop, m_ResultWidth, m_ResultHeight;
+ CFX_AffineMatrix m_dest2stretch;
+ CFX_ImageStretcher m_Stretcher;
+ CFX_BitmapStorer m_Storer;
+ FX_DWORD m_Flags;
+ int m_Status;
+};
+class CFX_ImageRenderer : public CFX_Object
+{
+public:
+
+ CFX_ImageRenderer();
+
+ ~CFX_ImageRenderer();
+
+ FX_INT32 Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClipRgn,
+ const CFX_DIBSource* pSource, int bitmap_alpha,
+ FX_DWORD mask_color, const CFX_AffineMatrix* pMatrix, FX_DWORD dib_flags,
+ FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL);
+
+ FX_INT32 Continue(IFX_Pause* pPause);
+protected:
+ CFX_DIBitmap* m_pDevice;
+ const CFX_ClipRgn* m_pClipRgn;
+ int m_BitmapAlpha;
+ FX_DWORD m_MaskColor;
+ CFX_AffineMatrix m_Matrix;
+ CFX_ImageTransformer* m_pTransformer;
+ CFX_ImageStretcher m_Stretcher;
+ CFX_BitmapComposer m_Composer;
+ int m_Status;
+ int m_DestLeft, m_DestTop;
+ FX_RECT m_ClipBox;
+ FX_DWORD m_Flags;
+ int m_AlphaFlag;
+ void* m_pIccTransform;
+ FX_BOOL m_bRgbByteOrder;
+ int m_BlendType;
+};
+#endif
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h
index abfa9b8b5d..dc96debeb6 100644
--- a/core/include/fxge/fx_font.h
+++ b/core/include/fxge/fx_font.h
@@ -1,428 +1,428 @@
-// 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 _FX_FONT_H_
-#define _FX_FONT_H_
-#ifndef _FXCRT_EXTENSION_
-#include "../../include/fxcrt/fx_ext.h"
-#endif
-#ifndef _FX_DIB_H_
-#include "fx_dib.h"
-#endif
-typedef struct FT_FaceRec_* FXFT_Face;
-typedef void* FXFT_Library;
-class IFX_FontEncoding;
-class CFX_PathData;
-class CFX_SubstFont;
-class CFX_FaceCache;
-class IFX_FontMapper;
-class CFX_FontMapper;
-class IFX_SystemFontInfo;
-class CFontFileFaceInfo;
-#define FXFONT_FIXED_PITCH 0x01
-#define FXFONT_SERIF 0x02
-#define FXFONT_SYMBOLIC 0x04
-#define FXFONT_SCRIPT 0x08
-#define FXFONT_ITALIC 0x40
-#define FXFONT_BOLD 0x40000
-#define FXFONT_USEEXTERNATTR 0x80000
-#define FXFONT_CIDFONT 0x100000
-#define FXFONT_ANSI_CHARSET 0
-#define FXFONT_DEFAULT_CHARSET 1
-#define FXFONT_SYMBOL_CHARSET 2
-#define FXFONT_SHIFTJIS_CHARSET 128
-#define FXFONT_HANGEUL_CHARSET 129
-#define FXFONT_GB2312_CHARSET 134
-#define FXFONT_CHINESEBIG5_CHARSET 136
-#define FXFONT_THAI_CHARSET 222
-#define FXFONT_EASTEUROPE_CHARSET 238
-#define FXFONT_RUSSIAN_CHARSET 204
-#define FXFONT_GREEK_CHARSET 161
-#define FXFONT_TURKISH_CHARSET 162
-#define FXFONT_HEBREW_CHARSET 177
-#define FXFONT_ARABIC_CHARSET 178
-#define FXFONT_BALTIC_CHARSET 186
-#define FXFONT_FF_FIXEDPITCH 1
-#define FXFONT_FF_ROMAN (1<<4)
-#define FXFONT_FF_SCRIPT (4<<4)
-#define FXFONT_FW_NORMAL 400
-#define FXFONT_FW_BOLD 700
-class CFX_Font : public CFX_Object
-{
-public:
- CFX_Font();
- ~CFX_Font();
-
- FX_BOOL LoadSubst(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
- int weight, int italic_angle, int CharsetCP, FX_BOOL bVertical = FALSE);
-
- FX_BOOL LoadEmbedded(FX_LPCBYTE data, FX_DWORD size);
-
- FX_BOOL LoadFile(IFX_FileRead* pFile);
-
- FXFT_Face GetFace() const
- {
- return m_Face;
- }
-
-
- const CFX_SubstFont* GetSubstFont() const
- {
- return m_pSubstFont;
- }
-
- CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0);
-
- int GetGlyphWidth(FX_DWORD glyph_index);
-
- int GetAscent() const;
-
- int GetDescent() const;
-
- FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT &bbox);
-
- FX_BOOL IsItalic();
-
- FX_BOOL IsBold();
-
- FX_BOOL IsFixedWidth();
-
- FX_BOOL IsVertical() const
- {
- return m_bVertical;
- }
-
- CFX_WideString GetPsName() const;
-
-
- CFX_ByteString GetFamilyName() const;
-
- CFX_ByteString GetFaceName() const;
-
-
- FX_BOOL IsTTFont();
-
- FX_BOOL GetBBox(FX_RECT &bbox);
-
- int GetHeight();
-
- int GetULPos();
-
- int GetULthickness();
-
- int GetMaxAdvanceWidth();
-
- FXFT_Face m_Face;
-
- CFX_SubstFont* m_pSubstFont;
- FX_BOOL IsEmbedded()
- {
- return m_bEmbedded;
- }
-
- void AdjustMMParams(int glyph_index, int width, int weight);
- FX_LPBYTE m_pFontDataAllocation;
- FX_LPBYTE m_pFontData;
- FX_LPBYTE m_pGsubData;
- FX_DWORD m_dwSize;
- CFX_BinaryBuf m_OtfFontData;
- void* m_hHandle;
- void* m_pPlatformFont;
- void* m_pPlatformFontCollection;
- void* m_pDwFont;
- FX_BOOL m_bDwLoaded;
- void ReleasePlatformResource();
-
- void DeleteFace();
-protected:
-
- FX_BOOL m_bEmbedded;
- FX_BOOL m_bVertical;
- void* m_pOwnedStream;
-};
-#define ENCODING_INTERNAL 0
-#define ENCODING_UNICODE 1
-class IFX_FontEncoding : public CFX_Object
-{
-public:
- virtual ~IFX_FontEncoding() {}
-
- virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode) = 0;
-
- virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const = 0;
-
- virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const = 0;
-};
-IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont);
-#define FXFONT_SUBST_MM 0x01
-#define FXFONT_SUBST_GLYPHPATH 0x04
-#define FXFONT_SUBST_CLEARTYPE 0x08
-#define FXFONT_SUBST_TRANSFORM 0x10
-#define FXFONT_SUBST_NONSYMBOL 0x20
-#define FXFONT_SUBST_EXACT 0x40
-#define FXFONT_SUBST_STANDARD 0x80
-class CFX_SubstFont : public CFX_Object
-{
-public:
-
- CFX_SubstFont();
-
- FX_LPVOID m_ExtHandle;
-
- CFX_ByteString m_Family;
-
- int m_Charset;
-
- FX_DWORD m_SubstFlags;
-
- int m_Weight;
-
- int m_ItalicAngle;
-
- FX_BOOL m_bSubstOfCJK;
-
- int m_WeightCJK;
-
- FX_BOOL m_bItlicCJK;
-};
-#define FX_FONT_FLAG_SERIF 0x01
-#define FX_FONT_FLAG_FIXEDPITCH 0x02
-#define FX_FONT_FLAG_ITALIC 0x04
-#define FX_FONT_FLAG_BOLD 0x08
-#define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10
-#define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20
-#define FX_FONT_FLAG_MULTIPLEMASTER 0x40
-typedef struct {
- FX_LPCBYTE m_pFontData;
- FX_DWORD m_dwSize;
-} FoxitFonts;
-class CFX_FontMgr : public CFX_Object
-{
-public:
- CFX_FontMgr();
- ~CFX_FontMgr();
- void InitFTLibrary();
- FXFT_Face GetCachedFace(const CFX_ByteString& face_name,
- int weight, FX_BOOL bItalic, FX_LPBYTE& pFontData);
- FXFT_Face AddCachedFace(const CFX_ByteString& face_name,
- int weight, FX_BOOL bItalic, FX_LPBYTE pData, FX_DWORD size, int face_index);
- FXFT_Face GetCachedTTCFace(int ttc_size, FX_DWORD checksum,
- int font_offset, FX_LPBYTE& pFontData);
- FXFT_Face AddCachedTTCFace(int ttc_size, FX_DWORD checksum,
- FX_LPBYTE pData, FX_DWORD size, int font_offset);
- FXFT_Face GetFileFace(FX_LPCSTR filename, int face_index);
- FXFT_Face GetFixedFace(FX_LPCBYTE pData, FX_DWORD size, int face_index);
- void ReleaseFace(FXFT_Face face);
- void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo);
- FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
- int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont);
-
- void FreeCache();
-
- FX_BOOL GetStandardFont(FX_LPCBYTE& pFontData, FX_DWORD& size, int index);
- CFX_FontMapper* m_pBuiltinMapper;
- IFX_FontMapper* m_pExtMapper;
- CFX_MapByteStringToPtr m_FaceMap;
- FXFT_Library m_FTLibrary;
- FoxitFonts m_ExternalFonts[16];
-};
-class IFX_FontMapper : public CFX_Object
-{
-public:
-
- virtual ~IFX_FontMapper() {}
-
- virtual FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
- int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont) = 0;
-
- CFX_FontMgr* m_pFontMgr;
-};
-class IFX_FontEnumerator
-{
-public:
-
- virtual void HitFont() = 0;
-
- virtual void Finish() = 0;
-};
-class IFX_AdditionalFontEnum
-{
-public:
- virtual int CountFiles() = 0;
- virtual IFX_FileStream* GetFontFile(int index) = 0;
-};
-class CFX_FontMapper : public IFX_FontMapper
-{
-public:
- CFX_FontMapper();
- virtual ~CFX_FontMapper();
- void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo);
- IFX_SystemFontInfo* GetSystemFontInfo()
- {
- return m_pFontInfo;
- }
- void AddInstalledFont(const CFX_ByteString& name, int charset);
- void LoadInstalledFonts();
- CFX_ByteStringArray m_InstalledTTFonts;
- void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator)
- {
- m_pFontEnumerator = pFontEnumerator;
- }
- IFX_FontEnumerator* GetFontEnumerator() const
- {
- return m_pFontEnumerator;
- }
- virtual FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
- int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont);
-private:
- CFX_ByteString GetPSNameFromTT(void* hFont);
- CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name);
- FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, int iBaseFont, int italic_angle, int weight, int picthfamily);
-
- FX_BOOL m_bListLoaded;
- FXFT_Face m_MMFaces[2];
- CFX_ByteString m_LastFamily;
- CFX_DWordArray m_CharsetArray;
- CFX_ByteStringArray m_FaceArray;
- IFX_SystemFontInfo* m_pFontInfo;
- FXFT_Face m_FoxitFaces[14];
- IFX_FontEnumerator* m_pFontEnumerator;
-};
-class IFX_SystemFontInfo : public CFX_Object
-{
-public:
- static IFX_SystemFontInfo* CreateDefault();
- virtual void Release() = 0;
- virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0;
- virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR face, FX_BOOL& bExact) = 0;
- virtual void* GetFont(FX_LPCSTR face) = 0;
- virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, FX_LPBYTE buffer, FX_DWORD size) = 0;
- virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0;
- virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0;
- virtual int GetFaceIndex(void* hFont)
- {
- return 0;
- }
- virtual void DeleteFont(void* hFont) = 0;
- virtual void* RetainFont(void* hFont)
- {
- return NULL;
- }
-};
-class CFX_FolderFontInfo : public IFX_SystemFontInfo
-{
-public:
- CFX_FolderFontInfo();
- ~CFX_FolderFontInfo();
- void AddPath(FX_BSTR path);
- virtual void Release();
- virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper);
- virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR face, FX_BOOL& bExact);
- virtual void* GetFont(FX_LPCSTR face);
- virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, FX_LPBYTE buffer, FX_DWORD size);
- virtual void DeleteFont(void* hFont);
- virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name);
- virtual FX_BOOL GetFontCharset(void* hFont, int& charset);
-protected:
- CFX_MapByteStringToPtr m_FontList;
- CFX_ByteStringArray m_PathList;
- CFX_FontMapper* m_pMapper;
- void ScanPath(CFX_ByteString& path);
- void ScanFile(CFX_ByteString& path);
- void ReportFace(CFX_ByteString& path, FXSYS_FILE* pFile, FX_DWORD filesize, FX_DWORD offset);
-};
-class CFX_CountedFaceCache : public CFX_Object
-{
-public:
- CFX_FaceCache* m_Obj;
- FX_DWORD m_nCount;
-};
-typedef CFX_MapPtrTemplate<FXFT_Face, CFX_CountedFaceCache*> CFX_FTCacheMap;
-class CFX_FontCache : public CFX_Object
-{
-public:
- ~CFX_FontCache();
- CFX_FaceCache* GetCachedFace(CFX_Font* pFont);
- void ReleaseCachedFace(CFX_Font* pFont);
- void FreeCache(FX_BOOL bRelease = FALSE);
-
-private:
- CFX_FTCacheMap m_FTFaceMap;
- CFX_FTCacheMap m_ExtFaceMap;
-};
-class CFX_AutoFontCache
-{
-public:
- CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont)
- : m_pFontCache(pFontCache)
- , m_pFont(pFont)
- {
- }
- ~CFX_AutoFontCache()
- {
- m_pFontCache->ReleaseCachedFace(m_pFont);
- }
- CFX_FontCache* m_pFontCache;
- CFX_Font* m_pFont;
-};
-#define FX_FONTCACHE_DEFINE(pFontCache, pFont) CFX_AutoFontCache autoFontCache((pFontCache), (pFont))
-class CFX_GlyphBitmap : public CFX_Object
-{
-public:
- int m_Top;
- int m_Left;
- CFX_DIBitmap m_Bitmap;
-};
-class CFX_FaceCache : public CFX_Object
-{
-public:
- ~CFX_FaceCache();
- const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix,
- int dest_width, int anti_alias, int& text_flags);
- const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph_index, int dest_width);
-
-
- CFX_FaceCache(FXFT_Face face);
-private:
- FXFT_Face m_Face;
- CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_index, FX_BOOL bFontStyle,
- const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias);
- CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, FX_DWORD glyph_index,
- const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias);
- CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, const CFX_AffineMatrix* pMatrix, CFX_ByteStringC& FaceGlyphsKey,
- FX_DWORD glyph_index, FX_BOOL bFontStyle, int dest_width, int anti_alias);
- CFX_MapByteStringToPtr m_SizeMap;
- CFX_MapPtrToPtr m_PathMap;
- CFX_DIBitmap* m_pBitmap;
- void* m_pPlatformGraphics;
- void* m_pPlatformBitmap;
- void* m_hDC;
- void* m_hBitmap;
- void* m_hOldBitmap;
- void* m_hGdiFont;
- void* m_hOldGdiFont;
-
- void InitPlatform();
- void DestroyPlatform();
-};
-typedef struct {
- const CFX_GlyphBitmap* m_pGlyph;
- int m_OriginX, m_OriginY;
- FX_FLOAT m_fOriginX, m_fOriginY;
-} FXTEXT_GLYPHPOS;
-FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, int nChars, int anti_alias, FX_FLOAT retinaScaleX = 1.0f, FX_FLOAT retinaScaleY = 1.0f);
-FX_BOOL OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size,
- CFX_AffineMatrix* pMatrix, unsigned long glyph_index, unsigned long argb);
-FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size,
- CFX_AffineMatrix* pText_matrix, unsigned short const* text, unsigned long argb);
-class IFX_GSUBTable
-{
-public:
- virtual void Release() = 0;
- virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0;
-};
-IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont);
-#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 _FX_FONT_H_
+#define _FX_FONT_H_
+#ifndef _FXCRT_EXTENSION_
+#include "../../include/fxcrt/fx_ext.h"
+#endif
+#ifndef _FX_DIB_H_
+#include "fx_dib.h"
+#endif
+typedef struct FT_FaceRec_* FXFT_Face;
+typedef void* FXFT_Library;
+class IFX_FontEncoding;
+class CFX_PathData;
+class CFX_SubstFont;
+class CFX_FaceCache;
+class IFX_FontMapper;
+class CFX_FontMapper;
+class IFX_SystemFontInfo;
+class CFontFileFaceInfo;
+#define FXFONT_FIXED_PITCH 0x01
+#define FXFONT_SERIF 0x02
+#define FXFONT_SYMBOLIC 0x04
+#define FXFONT_SCRIPT 0x08
+#define FXFONT_ITALIC 0x40
+#define FXFONT_BOLD 0x40000
+#define FXFONT_USEEXTERNATTR 0x80000
+#define FXFONT_CIDFONT 0x100000
+#define FXFONT_ANSI_CHARSET 0
+#define FXFONT_DEFAULT_CHARSET 1
+#define FXFONT_SYMBOL_CHARSET 2
+#define FXFONT_SHIFTJIS_CHARSET 128
+#define FXFONT_HANGEUL_CHARSET 129
+#define FXFONT_GB2312_CHARSET 134
+#define FXFONT_CHINESEBIG5_CHARSET 136
+#define FXFONT_THAI_CHARSET 222
+#define FXFONT_EASTEUROPE_CHARSET 238
+#define FXFONT_RUSSIAN_CHARSET 204
+#define FXFONT_GREEK_CHARSET 161
+#define FXFONT_TURKISH_CHARSET 162
+#define FXFONT_HEBREW_CHARSET 177
+#define FXFONT_ARABIC_CHARSET 178
+#define FXFONT_BALTIC_CHARSET 186
+#define FXFONT_FF_FIXEDPITCH 1
+#define FXFONT_FF_ROMAN (1<<4)
+#define FXFONT_FF_SCRIPT (4<<4)
+#define FXFONT_FW_NORMAL 400
+#define FXFONT_FW_BOLD 700
+class CFX_Font : public CFX_Object
+{
+public:
+ CFX_Font();
+ ~CFX_Font();
+
+ FX_BOOL LoadSubst(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
+ int weight, int italic_angle, int CharsetCP, FX_BOOL bVertical = FALSE);
+
+ FX_BOOL LoadEmbedded(FX_LPCBYTE data, FX_DWORD size);
+
+ FX_BOOL LoadFile(IFX_FileRead* pFile);
+
+ FXFT_Face GetFace() const
+ {
+ return m_Face;
+ }
+
+
+ const CFX_SubstFont* GetSubstFont() const
+ {
+ return m_pSubstFont;
+ }
+
+ CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0);
+
+ int GetGlyphWidth(FX_DWORD glyph_index);
+
+ int GetAscent() const;
+
+ int GetDescent() const;
+
+ FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT &bbox);
+
+ FX_BOOL IsItalic();
+
+ FX_BOOL IsBold();
+
+ FX_BOOL IsFixedWidth();
+
+ FX_BOOL IsVertical() const
+ {
+ return m_bVertical;
+ }
+
+ CFX_WideString GetPsName() const;
+
+
+ CFX_ByteString GetFamilyName() const;
+
+ CFX_ByteString GetFaceName() const;
+
+
+ FX_BOOL IsTTFont();
+
+ FX_BOOL GetBBox(FX_RECT &bbox);
+
+ int GetHeight();
+
+ int GetULPos();
+
+ int GetULthickness();
+
+ int GetMaxAdvanceWidth();
+
+ FXFT_Face m_Face;
+
+ CFX_SubstFont* m_pSubstFont;
+ FX_BOOL IsEmbedded()
+ {
+ return m_bEmbedded;
+ }
+
+ void AdjustMMParams(int glyph_index, int width, int weight);
+ FX_LPBYTE m_pFontDataAllocation;
+ FX_LPBYTE m_pFontData;
+ FX_LPBYTE m_pGsubData;
+ FX_DWORD m_dwSize;
+ CFX_BinaryBuf m_OtfFontData;
+ void* m_hHandle;
+ void* m_pPlatformFont;
+ void* m_pPlatformFontCollection;
+ void* m_pDwFont;
+ FX_BOOL m_bDwLoaded;
+ void ReleasePlatformResource();
+
+ void DeleteFace();
+protected:
+
+ FX_BOOL m_bEmbedded;
+ FX_BOOL m_bVertical;
+ void* m_pOwnedStream;
+};
+#define ENCODING_INTERNAL 0
+#define ENCODING_UNICODE 1
+class IFX_FontEncoding : public CFX_Object
+{
+public:
+ virtual ~IFX_FontEncoding() {}
+
+ virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode) = 0;
+
+ virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const = 0;
+
+ virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const = 0;
+};
+IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont);
+#define FXFONT_SUBST_MM 0x01
+#define FXFONT_SUBST_GLYPHPATH 0x04
+#define FXFONT_SUBST_CLEARTYPE 0x08
+#define FXFONT_SUBST_TRANSFORM 0x10
+#define FXFONT_SUBST_NONSYMBOL 0x20
+#define FXFONT_SUBST_EXACT 0x40
+#define FXFONT_SUBST_STANDARD 0x80
+class CFX_SubstFont : public CFX_Object
+{
+public:
+
+ CFX_SubstFont();
+
+ FX_LPVOID m_ExtHandle;
+
+ CFX_ByteString m_Family;
+
+ int m_Charset;
+
+ FX_DWORD m_SubstFlags;
+
+ int m_Weight;
+
+ int m_ItalicAngle;
+
+ FX_BOOL m_bSubstOfCJK;
+
+ int m_WeightCJK;
+
+ FX_BOOL m_bItlicCJK;
+};
+#define FX_FONT_FLAG_SERIF 0x01
+#define FX_FONT_FLAG_FIXEDPITCH 0x02
+#define FX_FONT_FLAG_ITALIC 0x04
+#define FX_FONT_FLAG_BOLD 0x08
+#define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10
+#define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20
+#define FX_FONT_FLAG_MULTIPLEMASTER 0x40
+typedef struct {
+ FX_LPCBYTE m_pFontData;
+ FX_DWORD m_dwSize;
+} FoxitFonts;
+class CFX_FontMgr : public CFX_Object
+{
+public:
+ CFX_FontMgr();
+ ~CFX_FontMgr();
+ void InitFTLibrary();
+ FXFT_Face GetCachedFace(const CFX_ByteString& face_name,
+ int weight, FX_BOOL bItalic, FX_LPBYTE& pFontData);
+ FXFT_Face AddCachedFace(const CFX_ByteString& face_name,
+ int weight, FX_BOOL bItalic, FX_LPBYTE pData, FX_DWORD size, int face_index);
+ FXFT_Face GetCachedTTCFace(int ttc_size, FX_DWORD checksum,
+ int font_offset, FX_LPBYTE& pFontData);
+ FXFT_Face AddCachedTTCFace(int ttc_size, FX_DWORD checksum,
+ FX_LPBYTE pData, FX_DWORD size, int font_offset);
+ FXFT_Face GetFileFace(FX_LPCSTR filename, int face_index);
+ FXFT_Face GetFixedFace(FX_LPCBYTE pData, FX_DWORD size, int face_index);
+ void ReleaseFace(FXFT_Face face);
+ void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo);
+ FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
+ int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont);
+
+ void FreeCache();
+
+ FX_BOOL GetStandardFont(FX_LPCBYTE& pFontData, FX_DWORD& size, int index);
+ CFX_FontMapper* m_pBuiltinMapper;
+ IFX_FontMapper* m_pExtMapper;
+ CFX_MapByteStringToPtr m_FaceMap;
+ FXFT_Library m_FTLibrary;
+ FoxitFonts m_ExternalFonts[16];
+};
+class IFX_FontMapper : public CFX_Object
+{
+public:
+
+ virtual ~IFX_FontMapper() {}
+
+ virtual FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
+ int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont) = 0;
+
+ CFX_FontMgr* m_pFontMgr;
+};
+class IFX_FontEnumerator
+{
+public:
+
+ virtual void HitFont() = 0;
+
+ virtual void Finish() = 0;
+};
+class IFX_AdditionalFontEnum
+{
+public:
+ virtual int CountFiles() = 0;
+ virtual IFX_FileStream* GetFontFile(int index) = 0;
+};
+class CFX_FontMapper : public IFX_FontMapper
+{
+public:
+ CFX_FontMapper();
+ virtual ~CFX_FontMapper();
+ void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo);
+ IFX_SystemFontInfo* GetSystemFontInfo()
+ {
+ return m_pFontInfo;
+ }
+ void AddInstalledFont(const CFX_ByteString& name, int charset);
+ void LoadInstalledFonts();
+ CFX_ByteStringArray m_InstalledTTFonts;
+ void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator)
+ {
+ m_pFontEnumerator = pFontEnumerator;
+ }
+ IFX_FontEnumerator* GetFontEnumerator() const
+ {
+ return m_pFontEnumerator;
+ }
+ virtual FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
+ int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont);
+private:
+ CFX_ByteString GetPSNameFromTT(void* hFont);
+ CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name);
+ FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, int iBaseFont, int italic_angle, int weight, int picthfamily);
+
+ FX_BOOL m_bListLoaded;
+ FXFT_Face m_MMFaces[2];
+ CFX_ByteString m_LastFamily;
+ CFX_DWordArray m_CharsetArray;
+ CFX_ByteStringArray m_FaceArray;
+ IFX_SystemFontInfo* m_pFontInfo;
+ FXFT_Face m_FoxitFaces[14];
+ IFX_FontEnumerator* m_pFontEnumerator;
+};
+class IFX_SystemFontInfo : public CFX_Object
+{
+public:
+ static IFX_SystemFontInfo* CreateDefault();
+ virtual void Release() = 0;
+ virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0;
+ virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR face, FX_BOOL& bExact) = 0;
+ virtual void* GetFont(FX_LPCSTR face) = 0;
+ virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, FX_LPBYTE buffer, FX_DWORD size) = 0;
+ virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0;
+ virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0;
+ virtual int GetFaceIndex(void* hFont)
+ {
+ return 0;
+ }
+ virtual void DeleteFont(void* hFont) = 0;
+ virtual void* RetainFont(void* hFont)
+ {
+ return NULL;
+ }
+};
+class CFX_FolderFontInfo : public IFX_SystemFontInfo
+{
+public:
+ CFX_FolderFontInfo();
+ ~CFX_FolderFontInfo();
+ void AddPath(FX_BSTR path);
+ virtual void Release();
+ virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper);
+ virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR face, FX_BOOL& bExact);
+ virtual void* GetFont(FX_LPCSTR face);
+ virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, FX_LPBYTE buffer, FX_DWORD size);
+ virtual void DeleteFont(void* hFont);
+ virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name);
+ virtual FX_BOOL GetFontCharset(void* hFont, int& charset);
+protected:
+ CFX_MapByteStringToPtr m_FontList;
+ CFX_ByteStringArray m_PathList;
+ CFX_FontMapper* m_pMapper;
+ void ScanPath(CFX_ByteString& path);
+ void ScanFile(CFX_ByteString& path);
+ void ReportFace(CFX_ByteString& path, FXSYS_FILE* pFile, FX_DWORD filesize, FX_DWORD offset);
+};
+class CFX_CountedFaceCache : public CFX_Object
+{
+public:
+ CFX_FaceCache* m_Obj;
+ FX_DWORD m_nCount;
+};
+typedef CFX_MapPtrTemplate<FXFT_Face, CFX_CountedFaceCache*> CFX_FTCacheMap;
+class CFX_FontCache : public CFX_Object
+{
+public:
+ ~CFX_FontCache();
+ CFX_FaceCache* GetCachedFace(CFX_Font* pFont);
+ void ReleaseCachedFace(CFX_Font* pFont);
+ void FreeCache(FX_BOOL bRelease = FALSE);
+
+private:
+ CFX_FTCacheMap m_FTFaceMap;
+ CFX_FTCacheMap m_ExtFaceMap;
+};
+class CFX_AutoFontCache
+{
+public:
+ CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont)
+ : m_pFontCache(pFontCache)
+ , m_pFont(pFont)
+ {
+ }
+ ~CFX_AutoFontCache()
+ {
+ m_pFontCache->ReleaseCachedFace(m_pFont);
+ }
+ CFX_FontCache* m_pFontCache;
+ CFX_Font* m_pFont;
+};
+#define FX_FONTCACHE_DEFINE(pFontCache, pFont) CFX_AutoFontCache autoFontCache((pFontCache), (pFont))
+class CFX_GlyphBitmap : public CFX_Object
+{
+public:
+ int m_Top;
+ int m_Left;
+ CFX_DIBitmap m_Bitmap;
+};
+class CFX_FaceCache : public CFX_Object
+{
+public:
+ ~CFX_FaceCache();
+ const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix,
+ int dest_width, int anti_alias, int& text_flags);
+ const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph_index, int dest_width);
+
+
+ CFX_FaceCache(FXFT_Face face);
+private:
+ FXFT_Face m_Face;
+ CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_index, FX_BOOL bFontStyle,
+ const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias);
+ CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, FX_DWORD glyph_index,
+ const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias);
+ CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, const CFX_AffineMatrix* pMatrix, CFX_ByteStringC& FaceGlyphsKey,
+ FX_DWORD glyph_index, FX_BOOL bFontStyle, int dest_width, int anti_alias);
+ CFX_MapByteStringToPtr m_SizeMap;
+ CFX_MapPtrToPtr m_PathMap;
+ CFX_DIBitmap* m_pBitmap;
+ void* m_pPlatformGraphics;
+ void* m_pPlatformBitmap;
+ void* m_hDC;
+ void* m_hBitmap;
+ void* m_hOldBitmap;
+ void* m_hGdiFont;
+ void* m_hOldGdiFont;
+
+ void InitPlatform();
+ void DestroyPlatform();
+};
+typedef struct {
+ const CFX_GlyphBitmap* m_pGlyph;
+ int m_OriginX, m_OriginY;
+ FX_FLOAT m_fOriginX, m_fOriginY;
+} FXTEXT_GLYPHPOS;
+FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, int nChars, int anti_alias, FX_FLOAT retinaScaleX = 1.0f, FX_FLOAT retinaScaleY = 1.0f);
+FX_BOOL OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size,
+ CFX_AffineMatrix* pMatrix, unsigned long glyph_index, unsigned long argb);
+FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size,
+ CFX_AffineMatrix* pText_matrix, unsigned short const* text, unsigned long argb);
+class IFX_GSUBTable
+{
+public:
+ virtual void Release() = 0;
+ virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0;
+};
+IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont);
+#endif
diff --git a/core/include/fxge/fx_freetype.h b/core/include/fxge/fx_freetype.h
index 397c3eea9b..6a2190b2fc 100644
--- a/core/include/fxge/fx_freetype.h
+++ b/core/include/fxge/fx_freetype.h
@@ -1,144 +1,144 @@
-// 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
-
-#include "../thirdparties/freetype/ft2build.h"
-#include "../thirdparties/freetype/freetype/freetype.h"
-#include "../thirdparties/freetype/freetype/ftoutln.h"
-#include "../thirdparties/freetype/freetype/ftmm.h"
-#include "../thirdparties/freetype/freetype/internal/ftobjs.h"
-#include "../thirdparties/freetype/freetype/tttables.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define FXFT_ENCODING_UNICODE FT_ENCODING_UNICODE
-#define FXFT_ENCODING_ADOBE_STANDARD FT_ENCODING_ADOBE_STANDARD
-#define FXFT_ENCODING_ADOBE_EXPERT FT_ENCODING_ADOBE_EXPERT
-#define FXFT_ENCODING_ADOBE_LATIN_1 FT_ENCODING_ADOBE_LATIN_1
-#define FXFT_ENCODING_APPLE_ROMAN FT_ENCODING_APPLE_ROMAN
-#define FXFT_ENCODING_ADOBE_CUSTOM FT_ENCODING_ADOBE_CUSTOM
-#define FXFT_ENCODING_MS_SYMBOL FT_ENCODING_MS_SYMBOL
-#define FXFT_ENCODING_GB2312 FT_ENCODING_GB2312
-#define FXFT_ENCODING_BIG5 FT_ENCODING_BIG5
-#define FXFT_ENCODING_SJIS FT_ENCODING_SJIS
-#define FXFT_ENCODING_JOHAB FT_ENCODING_JOHAB
-#define FXFT_ENCODING_WANSUNG FT_ENCODING_WANSUNG
-#define FXFT_LOAD_NO_SCALE FT_LOAD_NO_SCALE
-#define FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
-#define FXFT_RENDER_MODE_LCD FT_RENDER_MODE_LCD
-#define FXFT_RENDER_MODE_MONO FT_RENDER_MODE_MONO
-#define FXFT_RENDER_MODE_NORMAL FT_RENDER_MODE_NORMAL
-#define FXFT_LOAD_IGNORE_TRANSFORM FT_LOAD_IGNORE_TRANSFORM
-#define FXFT_LOAD_NO_BITMAP FT_LOAD_NO_BITMAP
-#define FXFT_LOAD_NO_HINTING FT_LOAD_NO_HINTING
-#define FXFT_PIXEL_MODE_MONO FT_PIXEL_MODE_MONO
-#define FXFT_STYLE_FLAG_ITALIC FT_STYLE_FLAG_ITALIC
-#define FXFT_STYLE_FLAG_BOLD FT_STYLE_FLAG_BOLD
-#define FXFT_FACE_FLAG_SFNT FT_FACE_FLAG_SFNT
-#define FXFT_FACE_FLAG_TRICKY ( 1L << 13 )
-typedef FT_MM_Var* FXFT_MM_Var;
-typedef FT_Bitmap* FXFT_Bitmap;
-#define FXFT_Matrix FT_Matrix
-#define FXFT_Vector FT_Vector
-#define FXFT_Outline_Funcs FT_Outline_Funcs
-typedef FT_Open_Args FXFT_Open_Args;
-typedef FT_StreamRec FXFT_StreamRec;
-typedef FT_StreamRec* FXFT_Stream;
-typedef FT_BBox FXFT_BBox;
-typedef FT_Glyph FXFT_Glyph;
-typedef FT_CharMap FXFT_CharMap;
-#define FXFT_GLYPH_BBOX_PIXELS FT_GLYPH_BBOX_PIXELS
-#define FXFT_Open_Face(library, args, index, face) \
- FT_Open_Face((FT_Library)(library), args, index, (FT_Face*)(face))
-#define FXFT_Done_Face(face) FT_Done_Face((FT_Face)(face))
-#define FXFT_Done_FreeType(library) FT_Done_FreeType((FT_Library)(library))
-#define FXFT_Init_FreeType(library) FT_Init_FreeType((FT_Library*)(library))
-#define FXFT_New_Memory_Face(library, base, size, index, face) \
- FT_New_Memory_Face((FT_Library)(library), base, size, index, (FT_Face*)(face))
-#define FXFT_New_Face(library, filename, index, face) \
- FT_New_Face((FT_Library)(library), filename, index, (FT_Face*)(face))
-#define FXFT_Get_Face_FreeType(face) ((FT_Face)face)->driver->root.library
-#define FXFT_Select_Charmap(face, encoding) FT_Select_Charmap((FT_Face)face, (FT_Encoding)encoding)
-#define FXFT_Set_Charmap(face, charmap) FT_Set_Charmap((FT_Face)face, (FT_CharMap)charmap)
-#define FXFT_Load_Glyph(face, glyph_index, flags) FT_Load_Glyph((FT_Face)face, glyph_index, flags)
-#define FXFT_Get_Char_Index(face, code) FT_Get_Char_Index((FT_Face)face, code)
-#define FXFT_Get_Glyph_Name(face, index, buffer, size) FT_Get_Glyph_Name((FT_Face)face, index, buffer, size)
-#define FXFT_Get_Name_Index(face, name) FT_Get_Name_Index((FT_Face)face, name)
-#define FXFT_Has_Glyph_Names(face) (((FT_Face)face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES)
-#define FXFT_Get_Postscript_Name(face) FT_Get_Postscript_Name((FT_Face)face)
-#define FXFT_Load_Sfnt_Table(face, tag, offset, buffer, length) \
- FT_Load_Sfnt_Table((FT_Face)face, tag, offset, buffer, length)
-#define FXFT_Get_First_Char(face, glyph_index) FT_Get_First_Char((FT_Face)face, glyph_index)
-#define FXFT_Get_Next_Char(face, code, glyph_index) FT_Get_Next_Char((FT_Face)face, code, glyph_index)
-#define FXFT_Clear_Face_External_Stream(face) (((FT_Face)face)->face_flags&=~FT_FACE_FLAG_EXTERNAL_STREAM)
-#define FXFT_Get_Face_External_Stream(face) (((FT_Face)face)->face_flags&FT_FACE_FLAG_EXTERNAL_STREAM)
-#define FXFT_Is_Face_TT_OT(face) (((FT_Face)face)->face_flags&FT_FACE_FLAG_SFNT)
-#define FXFT_Is_Face_Tricky(face) (((FT_Face)face)->face_flags&FXFT_FACE_FLAG_TRICKY)
-#define FXFT_Is_Face_fixedwidth(face) (((FT_Face)face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
-#define FXFT_Get_Face_Stream_Base(face) ((FT_Face)face)->stream->base
-#define FXFT_Get_Face_Stream_Size(face) ((FT_Face)face)->stream->size
-#define FXFT_Get_Face_Family_Name(face) ((FT_Face)face)->family_name
-#define FXFT_Get_Face_Style_Name(face) ((FT_Face)face)->style_name
-#define FXFT_Get_Face_Numfaces(face) ((FT_Face)face)->num_faces
-#define FXFT_Get_Face_Faceindex(face) ((FT_Face)face)->face_index
-#define FXFT_Is_Face_Italic(face) (((FT_Face)face)->style_flags&FT_STYLE_FLAG_ITALIC)
-#define FXFT_Is_Face_Bold(face) (((FT_Face)face)->style_flags&FT_STYLE_FLAG_BOLD)
-#define FXFT_Get_Face_Charmaps(face) ((FT_Face)face)->charmaps
-#define FXFT_Get_Glyph_HoriBearingX(face) ((FT_Face)face)->glyph->metrics.horiBearingX
-#define FXFT_Get_Glyph_HoriBearingY(face) ((FT_Face)face)->glyph->metrics.horiBearingY
-#define FXFT_Get_Glyph_Width(face) ((FT_Face)face)->glyph->metrics.width
-#define FXFT_Get_Glyph_Height(face) ((FT_Face)face)->glyph->metrics.height
-#define FXFT_Get_Face_CharmapCount(face) ((FT_Face)face)->num_charmaps
-#define FXFT_Get_Charmap_Encoding(charmap) ((FT_CharMap)charmap)->encoding
-#define FXFT_Get_Face_Charmap(face) ((FT_Face)face)->charmap
-#define FXFT_Get_Charmap_PlatformID(charmap) ((FT_CharMap)charmap)->platform_id
-#define FXFT_Get_Charmap_EncodingID(charmap) ((FT_CharMap)charmap)->encoding_id
-#define FXFT_Get_Face_UnitsPerEM(face) ((FT_Face)face)->units_per_EM
-#define FXFT_Get_Face_xMin(face) ((FT_Face)face)->bbox.xMin
-#define FXFT_Get_Face_xMax(face) ((FT_Face)face)->bbox.xMax
-#define FXFT_Get_Face_yMin(face) ((FT_Face)face)->bbox.yMin
-#define FXFT_Get_Face_yMax(face) ((FT_Face)face)->bbox.yMax
-#define FXFT_Get_Face_Height(face) ((FT_Face)face)->height
-#define FXFT_Get_Face_UnderLineThickness(face) ((FT_Face)face)->underline_thickness
-#define FXFT_Get_Face_UnderLinePosition(face) ((FT_Face)face)->underline_position
-#define FXFT_Get_Face_MaxAdvanceWidth(face) ((FT_Face)face)->max_advance_width
-#define FXFT_Get_Face_Ascender(face) ((FT_Face)face)->ascender
-#define FXFT_Get_Face_Descender(face) ((FT_Face)face)->descender
-#define FXFT_Get_Glyph_HoriAdvance(face) ((FT_Face)face)->glyph->metrics.horiAdvance
-#define FXFT_Get_MM_Axis(var, index) &((FT_MM_Var*)var)->axis[index]
-#define FXFT_Get_MM_Axis_Min(axis) ((FT_Var_Axis*)axis)->minimum
-#define FXFT_Get_MM_Axis_Max(axis) ((FT_Var_Axis*)axis)->maximum
-#define FXFT_Get_MM_Axis_Def(axis) ((FT_Var_Axis*)axis)->def
-#define FXFT_Get_Face_Internal_Flag(face) ((FT_Face)face)->internal->transform_flags
-#define FXFT_Set_Face_Internal_Flag(face, flag) (((FT_Face)face)->internal->transform_flags = flag)
-#define FXFT_Alloc(library, size) ((FT_Library)library)->memory->alloc(((FT_Library)library)->memory, size)
-#define FXFT_Free(face, p) ((FT_Face)face)->memory->free(((FT_Face)face)->memory, p)
-#define FXFT_Get_Glyph_Outline(face) &((FT_Face)face)->glyph->outline
-#define FXFT_Get_Outline_Bbox(outline, cbox) FT_Outline_Get_CBox(outline, cbox)
-#define FXFT_Render_Glyph(face, mode) FT_Render_Glyph(((FT_Face)face)->glyph, (enum FT_Render_Mode_)mode)
-#define FXFT_Get_MM_Var(face, p) FT_Get_MM_Var((FT_Face)face, p)
-#define FXFT_Set_MM_Design_Coordinates(face, n, p) FT_Set_MM_Design_Coordinates((FT_Face)face, n, p)
-#define FXFT_Set_Pixel_Sizes(face, w, h) FT_Set_Pixel_Sizes((FT_Face)face, w, h)
-#define FXFT_Set_Transform(face, m, d) FT_Set_Transform((FT_Face)face, m, d)
-#define FXFT_Outline_Embolden(outline, s) FT_Outline_Embolden(outline, s)
-#define FXFT_Get_Glyph_Bitmap(face) &((FT_Face)face)->glyph->bitmap
-#define FXFT_Get_Bitmap_Width(bitmap) ((FT_Bitmap*)bitmap)->width
-#define FXFT_Get_Bitmap_Rows(bitmap) ((FT_Bitmap*)bitmap)->rows
-#define FXFT_Get_Bitmap_PixelMode(bitmap) ((FT_Bitmap*)bitmap)->pixel_mode
-#define FXFT_Get_Bitmap_Pitch(bitmap) ((FT_Bitmap*)bitmap)->pitch
-#define FXFT_Get_Bitmap_Buffer(bitmap) ((FT_Bitmap*)bitmap)->buffer
-#define FXFT_Get_Glyph_BitmapLeft(face) ((FT_Face)face)->glyph->bitmap_left
-#define FXFT_Get_Glyph_BitmapTop(face) ((FT_Face)face)->glyph->bitmap_top
-#define FXFT_Outline_Decompose(outline, funcs, params) FT_Outline_Decompose(outline, funcs, params)
-#define FXFT_Set_Char_Size(face, char_width, char_height, horz_resolution, vert_resolution) FT_Set_Char_Size(face, char_width, char_height, horz_resolution, vert_resolution)
-#define FXFT_Get_Glyph(slot, aglyph) FT_Get_Glyph(slot, aglyph)
-#define FXFT_Glyph_Get_CBox(glyph, bbox_mode, acbox) FT_Glyph_Get_CBox(glyph, bbox_mode, acbox)
-#define FXFT_Done_Glyph(glyph) FT_Done_Glyph(glyph)
-#define FXFT_Library_SetLcdFilter(library, filter) FT_Library_SetLcdFilter((FT_Library)(library), filter)
-int FXFT_unicode_from_adobe_name(const char* name);
-void FXFT_adobe_name_from_unicode(char* name, unsigned int unicode);
-#ifdef __cplusplus
-};
-#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
+
+#include "../thirdparties/freetype/ft2build.h"
+#include "../thirdparties/freetype/freetype/freetype.h"
+#include "../thirdparties/freetype/freetype/ftoutln.h"
+#include "../thirdparties/freetype/freetype/ftmm.h"
+#include "../thirdparties/freetype/freetype/internal/ftobjs.h"
+#include "../thirdparties/freetype/freetype/tttables.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define FXFT_ENCODING_UNICODE FT_ENCODING_UNICODE
+#define FXFT_ENCODING_ADOBE_STANDARD FT_ENCODING_ADOBE_STANDARD
+#define FXFT_ENCODING_ADOBE_EXPERT FT_ENCODING_ADOBE_EXPERT
+#define FXFT_ENCODING_ADOBE_LATIN_1 FT_ENCODING_ADOBE_LATIN_1
+#define FXFT_ENCODING_APPLE_ROMAN FT_ENCODING_APPLE_ROMAN
+#define FXFT_ENCODING_ADOBE_CUSTOM FT_ENCODING_ADOBE_CUSTOM
+#define FXFT_ENCODING_MS_SYMBOL FT_ENCODING_MS_SYMBOL
+#define FXFT_ENCODING_GB2312 FT_ENCODING_GB2312
+#define FXFT_ENCODING_BIG5 FT_ENCODING_BIG5
+#define FXFT_ENCODING_SJIS FT_ENCODING_SJIS
+#define FXFT_ENCODING_JOHAB FT_ENCODING_JOHAB
+#define FXFT_ENCODING_WANSUNG FT_ENCODING_WANSUNG
+#define FXFT_LOAD_NO_SCALE FT_LOAD_NO_SCALE
+#define FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
+#define FXFT_RENDER_MODE_LCD FT_RENDER_MODE_LCD
+#define FXFT_RENDER_MODE_MONO FT_RENDER_MODE_MONO
+#define FXFT_RENDER_MODE_NORMAL FT_RENDER_MODE_NORMAL
+#define FXFT_LOAD_IGNORE_TRANSFORM FT_LOAD_IGNORE_TRANSFORM
+#define FXFT_LOAD_NO_BITMAP FT_LOAD_NO_BITMAP
+#define FXFT_LOAD_NO_HINTING FT_LOAD_NO_HINTING
+#define FXFT_PIXEL_MODE_MONO FT_PIXEL_MODE_MONO
+#define FXFT_STYLE_FLAG_ITALIC FT_STYLE_FLAG_ITALIC
+#define FXFT_STYLE_FLAG_BOLD FT_STYLE_FLAG_BOLD
+#define FXFT_FACE_FLAG_SFNT FT_FACE_FLAG_SFNT
+#define FXFT_FACE_FLAG_TRICKY ( 1L << 13 )
+typedef FT_MM_Var* FXFT_MM_Var;
+typedef FT_Bitmap* FXFT_Bitmap;
+#define FXFT_Matrix FT_Matrix
+#define FXFT_Vector FT_Vector
+#define FXFT_Outline_Funcs FT_Outline_Funcs
+typedef FT_Open_Args FXFT_Open_Args;
+typedef FT_StreamRec FXFT_StreamRec;
+typedef FT_StreamRec* FXFT_Stream;
+typedef FT_BBox FXFT_BBox;
+typedef FT_Glyph FXFT_Glyph;
+typedef FT_CharMap FXFT_CharMap;
+#define FXFT_GLYPH_BBOX_PIXELS FT_GLYPH_BBOX_PIXELS
+#define FXFT_Open_Face(library, args, index, face) \
+ FT_Open_Face((FT_Library)(library), args, index, (FT_Face*)(face))
+#define FXFT_Done_Face(face) FT_Done_Face((FT_Face)(face))
+#define FXFT_Done_FreeType(library) FT_Done_FreeType((FT_Library)(library))
+#define FXFT_Init_FreeType(library) FT_Init_FreeType((FT_Library*)(library))
+#define FXFT_New_Memory_Face(library, base, size, index, face) \
+ FT_New_Memory_Face((FT_Library)(library), base, size, index, (FT_Face*)(face))
+#define FXFT_New_Face(library, filename, index, face) \
+ FT_New_Face((FT_Library)(library), filename, index, (FT_Face*)(face))
+#define FXFT_Get_Face_FreeType(face) ((FT_Face)face)->driver->root.library
+#define FXFT_Select_Charmap(face, encoding) FT_Select_Charmap((FT_Face)face, (FT_Encoding)encoding)
+#define FXFT_Set_Charmap(face, charmap) FT_Set_Charmap((FT_Face)face, (FT_CharMap)charmap)
+#define FXFT_Load_Glyph(face, glyph_index, flags) FT_Load_Glyph((FT_Face)face, glyph_index, flags)
+#define FXFT_Get_Char_Index(face, code) FT_Get_Char_Index((FT_Face)face, code)
+#define FXFT_Get_Glyph_Name(face, index, buffer, size) FT_Get_Glyph_Name((FT_Face)face, index, buffer, size)
+#define FXFT_Get_Name_Index(face, name) FT_Get_Name_Index((FT_Face)face, name)
+#define FXFT_Has_Glyph_Names(face) (((FT_Face)face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES)
+#define FXFT_Get_Postscript_Name(face) FT_Get_Postscript_Name((FT_Face)face)
+#define FXFT_Load_Sfnt_Table(face, tag, offset, buffer, length) \
+ FT_Load_Sfnt_Table((FT_Face)face, tag, offset, buffer, length)
+#define FXFT_Get_First_Char(face, glyph_index) FT_Get_First_Char((FT_Face)face, glyph_index)
+#define FXFT_Get_Next_Char(face, code, glyph_index) FT_Get_Next_Char((FT_Face)face, code, glyph_index)
+#define FXFT_Clear_Face_External_Stream(face) (((FT_Face)face)->face_flags&=~FT_FACE_FLAG_EXTERNAL_STREAM)
+#define FXFT_Get_Face_External_Stream(face) (((FT_Face)face)->face_flags&FT_FACE_FLAG_EXTERNAL_STREAM)
+#define FXFT_Is_Face_TT_OT(face) (((FT_Face)face)->face_flags&FT_FACE_FLAG_SFNT)
+#define FXFT_Is_Face_Tricky(face) (((FT_Face)face)->face_flags&FXFT_FACE_FLAG_TRICKY)
+#define FXFT_Is_Face_fixedwidth(face) (((FT_Face)face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
+#define FXFT_Get_Face_Stream_Base(face) ((FT_Face)face)->stream->base
+#define FXFT_Get_Face_Stream_Size(face) ((FT_Face)face)->stream->size
+#define FXFT_Get_Face_Family_Name(face) ((FT_Face)face)->family_name
+#define FXFT_Get_Face_Style_Name(face) ((FT_Face)face)->style_name
+#define FXFT_Get_Face_Numfaces(face) ((FT_Face)face)->num_faces
+#define FXFT_Get_Face_Faceindex(face) ((FT_Face)face)->face_index
+#define FXFT_Is_Face_Italic(face) (((FT_Face)face)->style_flags&FT_STYLE_FLAG_ITALIC)
+#define FXFT_Is_Face_Bold(face) (((FT_Face)face)->style_flags&FT_STYLE_FLAG_BOLD)
+#define FXFT_Get_Face_Charmaps(face) ((FT_Face)face)->charmaps
+#define FXFT_Get_Glyph_HoriBearingX(face) ((FT_Face)face)->glyph->metrics.horiBearingX
+#define FXFT_Get_Glyph_HoriBearingY(face) ((FT_Face)face)->glyph->metrics.horiBearingY
+#define FXFT_Get_Glyph_Width(face) ((FT_Face)face)->glyph->metrics.width
+#define FXFT_Get_Glyph_Height(face) ((FT_Face)face)->glyph->metrics.height
+#define FXFT_Get_Face_CharmapCount(face) ((FT_Face)face)->num_charmaps
+#define FXFT_Get_Charmap_Encoding(charmap) ((FT_CharMap)charmap)->encoding
+#define FXFT_Get_Face_Charmap(face) ((FT_Face)face)->charmap
+#define FXFT_Get_Charmap_PlatformID(charmap) ((FT_CharMap)charmap)->platform_id
+#define FXFT_Get_Charmap_EncodingID(charmap) ((FT_CharMap)charmap)->encoding_id
+#define FXFT_Get_Face_UnitsPerEM(face) ((FT_Face)face)->units_per_EM
+#define FXFT_Get_Face_xMin(face) ((FT_Face)face)->bbox.xMin
+#define FXFT_Get_Face_xMax(face) ((FT_Face)face)->bbox.xMax
+#define FXFT_Get_Face_yMin(face) ((FT_Face)face)->bbox.yMin
+#define FXFT_Get_Face_yMax(face) ((FT_Face)face)->bbox.yMax
+#define FXFT_Get_Face_Height(face) ((FT_Face)face)->height
+#define FXFT_Get_Face_UnderLineThickness(face) ((FT_Face)face)->underline_thickness
+#define FXFT_Get_Face_UnderLinePosition(face) ((FT_Face)face)->underline_position
+#define FXFT_Get_Face_MaxAdvanceWidth(face) ((FT_Face)face)->max_advance_width
+#define FXFT_Get_Face_Ascender(face) ((FT_Face)face)->ascender
+#define FXFT_Get_Face_Descender(face) ((FT_Face)face)->descender
+#define FXFT_Get_Glyph_HoriAdvance(face) ((FT_Face)face)->glyph->metrics.horiAdvance
+#define FXFT_Get_MM_Axis(var, index) &((FT_MM_Var*)var)->axis[index]
+#define FXFT_Get_MM_Axis_Min(axis) ((FT_Var_Axis*)axis)->minimum
+#define FXFT_Get_MM_Axis_Max(axis) ((FT_Var_Axis*)axis)->maximum
+#define FXFT_Get_MM_Axis_Def(axis) ((FT_Var_Axis*)axis)->def
+#define FXFT_Get_Face_Internal_Flag(face) ((FT_Face)face)->internal->transform_flags
+#define FXFT_Set_Face_Internal_Flag(face, flag) (((FT_Face)face)->internal->transform_flags = flag)
+#define FXFT_Alloc(library, size) ((FT_Library)library)->memory->alloc(((FT_Library)library)->memory, size)
+#define FXFT_Free(face, p) ((FT_Face)face)->memory->free(((FT_Face)face)->memory, p)
+#define FXFT_Get_Glyph_Outline(face) &((FT_Face)face)->glyph->outline
+#define FXFT_Get_Outline_Bbox(outline, cbox) FT_Outline_Get_CBox(outline, cbox)
+#define FXFT_Render_Glyph(face, mode) FT_Render_Glyph(((FT_Face)face)->glyph, (enum FT_Render_Mode_)mode)
+#define FXFT_Get_MM_Var(face, p) FT_Get_MM_Var((FT_Face)face, p)
+#define FXFT_Set_MM_Design_Coordinates(face, n, p) FT_Set_MM_Design_Coordinates((FT_Face)face, n, p)
+#define FXFT_Set_Pixel_Sizes(face, w, h) FT_Set_Pixel_Sizes((FT_Face)face, w, h)
+#define FXFT_Set_Transform(face, m, d) FT_Set_Transform((FT_Face)face, m, d)
+#define FXFT_Outline_Embolden(outline, s) FT_Outline_Embolden(outline, s)
+#define FXFT_Get_Glyph_Bitmap(face) &((FT_Face)face)->glyph->bitmap
+#define FXFT_Get_Bitmap_Width(bitmap) ((FT_Bitmap*)bitmap)->width
+#define FXFT_Get_Bitmap_Rows(bitmap) ((FT_Bitmap*)bitmap)->rows
+#define FXFT_Get_Bitmap_PixelMode(bitmap) ((FT_Bitmap*)bitmap)->pixel_mode
+#define FXFT_Get_Bitmap_Pitch(bitmap) ((FT_Bitmap*)bitmap)->pitch
+#define FXFT_Get_Bitmap_Buffer(bitmap) ((FT_Bitmap*)bitmap)->buffer
+#define FXFT_Get_Glyph_BitmapLeft(face) ((FT_Face)face)->glyph->bitmap_left
+#define FXFT_Get_Glyph_BitmapTop(face) ((FT_Face)face)->glyph->bitmap_top
+#define FXFT_Outline_Decompose(outline, funcs, params) FT_Outline_Decompose(outline, funcs, params)
+#define FXFT_Set_Char_Size(face, char_width, char_height, horz_resolution, vert_resolution) FT_Set_Char_Size(face, char_width, char_height, horz_resolution, vert_resolution)
+#define FXFT_Get_Glyph(slot, aglyph) FT_Get_Glyph(slot, aglyph)
+#define FXFT_Glyph_Get_CBox(glyph, bbox_mode, acbox) FT_Glyph_Get_CBox(glyph, bbox_mode, acbox)
+#define FXFT_Done_Glyph(glyph) FT_Done_Glyph(glyph)
+#define FXFT_Library_SetLcdFilter(library, filter) FT_Library_SetLcdFilter((FT_Library)(library), filter)
+int FXFT_unicode_from_adobe_name(const char* name);
+void FXFT_adobe_name_from_unicode(char* name, unsigned int unicode);
+#ifdef __cplusplus
+};
+#endif
diff --git a/core/include/fxge/fx_ge.h b/core/include/fxge/fx_ge.h
index ab0bf3572a..82719ffda6 100644
--- a/core/include/fxge/fx_ge.h
+++ b/core/include/fxge/fx_ge.h
@@ -1,733 +1,733 @@
-// 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 _FX_GE_H_
-#define _FX_GE_H_
-#ifndef _FX_DIB_H_
-#include "fx_dib.h"
-#endif
-#ifndef _FX_FONT_H_
-#include "fx_font.h"
-#endif
-class CFX_ClipRgn;
-class CFX_PathData;
-class CFX_GraphStateData;
-class CFX_Font;
-class CFX_FontMgr;
-class CFX_FontCache;
-class CFX_FaceCache;
-class CFX_RenderDevice;
-class IFX_RenderDeviceDriver;
-class CCodec_ModuleMgr;
-class IFXG_PaintModuleMgr;
-class CFX_GEModule : public CFX_Object
-{
-public:
-
- static void Create();
-
- static void Use(CFX_GEModule* pMgr);
-
- static CFX_GEModule* Get();
-
- static void Destroy();
-public:
-
- CFX_FontCache* GetFontCache();
- CFX_FontMgr* GetFontMgr()
- {
- return m_pFontMgr;
- }
- void SetTextGamma(FX_FLOAT gammaValue);
- FX_LPCBYTE GetTextGammaTable();
- void SetExtFontMapper(IFX_FontMapper* pFontMapper);
-
- void SetCodecModule(CCodec_ModuleMgr* pCodecModule)
- {
- m_pCodecModule = pCodecModule;
- }
- CCodec_ModuleMgr* GetCodecModule()
- {
- return m_pCodecModule;
- }
- FXFT_Library m_FTLibrary;
- void* GetPlatformData()
- {
- return m_pPlatformData;
- }
-protected:
-
- CFX_GEModule();
-
- ~CFX_GEModule();
- void InitPlatform();
- void DestroyPlatform();
-private:
- FX_BYTE m_GammaValue[256];
- CFX_FontCache* m_pFontCache;
- CFX_FontMgr* m_pFontMgr;
- CCodec_ModuleMgr* m_pCodecModule;
- void* m_pPlatformData;
-};
-typedef struct {
-
- FX_FLOAT m_PointX;
-
- FX_FLOAT m_PointY;
-
- int m_Flag;
-} FX_PATHPOINT;
-#define FXPT_CLOSEFIGURE 0x01
-#define FXPT_LINETO 0x02
-#define FXPT_BEZIERTO 0x04
-#define FXPT_MOVETO 0x06
-#define FXPT_TYPE 0x06
-#define FXFILL_ALTERNATE 1
-#define FXFILL_WINDING 2
-class CFX_ClipRgn : public CFX_Object
-{
-public:
-
- CFX_ClipRgn(int device_width, int device_height);
-
- CFX_ClipRgn(const FX_RECT& rect);
-
- CFX_ClipRgn(const CFX_ClipRgn& src);
-
- ~CFX_ClipRgn();
-
- typedef enum {
- RectI,
- MaskF
- } ClipType;
-
- void Reset(const FX_RECT& rect);
-
- ClipType GetType() const
- {
- return m_Type;
- }
-
- const FX_RECT& GetBox() const
- {
- return m_Box;
- }
-
- CFX_DIBitmapRef GetMask() const
- {
- return m_Mask;
- }
-
- void IntersectRect(const FX_RECT& rect);
-
- void IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask);
-protected:
-
- ClipType m_Type;
-
- FX_RECT m_Box;
-
- CFX_DIBitmapRef m_Mask;
-
- void IntersectMaskRect(FX_RECT rect, FX_RECT mask_box, CFX_DIBitmapRef Mask);
-};
-extern const FX_BYTE g_GammaRamp[256];
-extern const FX_BYTE g_GammaInverse[256];
-#define FX_GAMMA(value) (value)
-#define FX_GAMMA_INVERSE(value) (value)
-inline FX_ARGB ArgbGamma(FX_ARGB argb)
-{
- return argb;
-}
-inline FX_ARGB ArgbGammaInverse(FX_ARGB argb)
-{
- return argb;
-}
-class CFX_PathData : public CFX_Object
-{
-public:
-
- CFX_PathData();
-
- CFX_PathData(const CFX_PathData& src);
-
- ~CFX_PathData();
-
-
-
-
- int GetPointCount() const
- {
- return m_PointCount;
- }
-
- int GetFlag(int index) const
- {
- return m_pPoints[index].m_Flag;
- }
-
- FX_FLOAT GetPointX(int index) const
- {
- return m_pPoints[index].m_PointX;
- }
-
- FX_FLOAT GetPointY(int index) const
- {
- return m_pPoints[index].m_PointY;
- }
-
-
-
- FX_PATHPOINT* GetPoints() const
- {
- return m_pPoints;
- }
-
- FX_BOOL SetPointCount(int nPoints);
-
- FX_BOOL AllocPointCount(int nPoints);
-
- FX_BOOL AddPointCount(int addPoints);
-
- CFX_FloatRect GetBoundingBox() const;
-
- CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const;
-
- void Transform(const CFX_AffineMatrix* pMatrix);
-
- FX_BOOL IsRect() const;
-
- FX_BOOL GetZeroAreaPath(CFX_PathData& NewPath, CFX_AffineMatrix* pMatrix, FX_BOOL&bThin, FX_BOOL bAdjust) const;
-
- FX_BOOL IsRect(const CFX_AffineMatrix* pMatrix, CFX_FloatRect* rect) const;
-
- FX_BOOL Append(const CFX_PathData* pSrc, const CFX_AffineMatrix* pMatrix);
-
- FX_BOOL AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top);
-
- void SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag);
-
- void TrimPoints(int nPoints);
-
- FX_BOOL Copy(const CFX_PathData &src);
-protected:
- friend class CPDF_Path;
-
- int m_PointCount;
-
- FX_PATHPOINT* m_pPoints;
-
- int m_AllocCount;
-};
-class CFX_GraphStateData : public CFX_Object
-{
-public:
-
- CFX_GraphStateData();
-
- CFX_GraphStateData(const CFX_GraphStateData& src);
-
- ~CFX_GraphStateData();
-
- void Copy(const CFX_GraphStateData& src);
-
- void SetDashCount(int count);
-
-
-
- typedef enum {
- LineCapButt = 0,
- LineCapRound = 1,
- LineCapSquare = 2
- } LineCap;
- LineCap m_LineCap;
- int m_DashCount;
- FX_FLOAT* m_DashArray;
- FX_FLOAT m_DashPhase;
-
- typedef enum {
- LineJoinMiter = 0,
- LineJoinRound = 1,
- LineJoinBevel = 2,
- } LineJoin;
- LineJoin m_LineJoin;
- FX_FLOAT m_MiterLimit;
- FX_FLOAT m_LineWidth;
-
-};
-#define FXDC_DEVICE_CLASS 1
-#define FXDC_PIXEL_WIDTH 2
-#define FXDC_PIXEL_HEIGHT 3
-#define FXDC_BITS_PIXEL 4
-#define FXDC_HORZ_SIZE 5
-#define FXDC_VERT_SIZE 6
-#define FXDC_RENDER_CAPS 7
-#define FXDC_DITHER_BITS 8
-#define FXDC_DISPLAY 1
-#define FXDC_PRINTER 2
-#define FXRC_GET_BITS 0x01
-#define FXRC_BIT_MASK 0x02
-#define FXRC_ALPHA_MASK 0x04
-#define FXRC_ALPHA_PATH 0x10
-#define FXRC_ALPHA_IMAGE 0x20
-#define FXRC_ALPHA_OUTPUT 0x40
-#define FXRC_BLEND_MODE 0x80
-#define FXRC_SOFT_CLIP 0x100
-#define FXRC_CMYK_OUTPUT 0x200
-#define FXRC_BITMASK_OUTPUT 0x400
-#define FXRC_BYTEMASK_OUTPUT 0x800
-#define FXRENDER_IMAGE_LOSSY 0x1000
-#define FXFILL_ALTERNATE 1
-#define FXFILL_WINDING 2
-#define FXFILL_FULLCOVER 4
-#define FXFILL_RECT_AA 8
-#define FX_FILL_STROKE 16
-#define FX_STROKE_ADJUST 32
-#define FX_STROKE_TEXT_MODE 64
-#define FX_FILL_TEXT_MODE 128
-#define FX_ZEROAREA_FILL 256
-#define FXFILL_NOPATHSMOOTH 512
-#define FXTEXT_CLEARTYPE 0x01
-#define FXTEXT_BGR_STRIPE 0x02
-#define FXTEXT_PRINTGRAPHICTEXT 0x04
-#define FXTEXT_NO_NATIVETEXT 0x08
-#define FXTEXT_PRINTIMAGETEXT 0x10
-#define FXTEXT_NOSMOOTH 0x20
-typedef struct {
- FX_DWORD m_GlyphIndex;
- FX_FLOAT m_OriginX, m_OriginY;
- int m_FontCharWidth;
- FX_BOOL m_bGlyphAdjust;
- FX_FLOAT m_AdjustMatrix[4];
- FX_DWORD m_ExtGID;
- FX_BOOL m_bFontStyle;
-} FXTEXT_CHARPOS;
-class CFX_RenderDevice : public CFX_Object
-{
-public:
- CFX_RenderDevice();
-
- virtual ~CFX_RenderDevice();
-
- void SetDeviceDriver(IFX_RenderDeviceDriver* pDriver);
-
- IFX_RenderDeviceDriver* GetDeviceDriver() const
- {
- return m_pDeviceDriver;
- }
-
- FX_BOOL StartRendering();
-
- void EndRendering();
-
-
-
- void SaveState();
-
- void RestoreState(FX_BOOL bKeepSaved = FALSE);
-
-
-
-
- int GetWidth() const
- {
- return m_Width;
- }
-
- int GetHeight() const
- {
- return m_Height;
- }
-
- int GetDeviceClass() const
- {
- return m_DeviceClass;
- }
-
- int GetBPP() const
- {
- return m_bpp;
- }
-
- int GetRenderCaps() const
- {
- return m_RenderCaps;
- }
-
- int GetDeviceCaps(int id) const;
-
- CFX_Matrix GetCTM() const;
-
-
- CFX_DIBitmap* GetBitmap() const
- {
- return m_pBitmap;
- }
- void SetBitmap(CFX_DIBitmap* pBitmap)
- {
- m_pBitmap = pBitmap;
- }
-
- FX_BOOL CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, int height) const;
-
- const FX_RECT& GetClipBox() const
- {
- return m_ClipBox;
- }
-
- FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- int fill_mode
- );
-
- FX_BOOL SetClip_Rect(const FX_RECT* pRect);
-
- FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- const CFX_GraphStateData* pGraphState
- );
-
- FX_BOOL DrawPath(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- const CFX_GraphStateData* pGraphState,
- FX_DWORD fill_color,
- FX_DWORD stroke_color,
- int fill_mode,
- int alpha_flag = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL
- );
-
- FX_BOOL SetPixel(int x, int y, FX_DWORD color,
- int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL FillRect(const FX_RECT* pRect, FX_DWORD color,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
-
- FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color,
- int fill_mode = 0, int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
-
- FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL);
-
- CFX_DIBitmap* GetBackDrop();
-
- FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, int left, int top, int blend_type = FXDIB_BLEND_NORMAL,
- void* pIccTransform = NULL);
-
- FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, int left, int top, int dest_width, int dest_height,
- FX_DWORD flags = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
-
- FX_BOOL SetBitMask(const CFX_DIBSource* pBitmap, int left, int top, FX_DWORD color,
- int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL StretchBitMask(const CFX_DIBSource* pBitmap, int left, int top, int dest_width, int dest_height,
- FX_DWORD color, FX_DWORD flags = 0, int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,
- const CFX_AffineMatrix* pMatrix, FX_DWORD flags, FX_LPVOID& handle,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
-
- FX_BOOL ContinueDIBits(FX_LPVOID handle, IFX_Pause* pPause);
-
- void CancelDIBits(FX_LPVOID handle);
-
- FX_BOOL DrawNormalText(int nChars, const FXTEXT_CHARPOS* pCharPos,
- CFX_Font* pFont, CFX_FontCache* pCache,
- FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device,
- FX_DWORD fill_color, FX_DWORD text_flags,
- int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPos,
- CFX_Font* pFont, CFX_FontCache* pCache,
- FX_FLOAT font_size, const CFX_AffineMatrix* pText2User,
- const CFX_AffineMatrix* pUser2Device, const CFX_GraphStateData* pGraphState,
- FX_DWORD fill_color, FX_DWORD stroke_color, CFX_PathData* pClippingPath, int nFlag = 0,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
- virtual void Begin() {}
- virtual void End() {}
-private:
-
- CFX_DIBitmap* m_pBitmap;
-
-
-
- int m_Width;
-
- int m_Height;
-
- int m_bpp;
-
- int m_RenderCaps;
-
- int m_DeviceClass;
-
- FX_RECT m_ClipBox;
-
-protected:
-
- IFX_RenderDeviceDriver* m_pDeviceDriver;
-private:
-
- void InitDeviceInfo();
-
- void UpdateClipBox();
-};
-class CFX_FxgeDevice : public CFX_RenderDevice
-{
-public:
-
- CFX_FxgeDevice();
-
- ~CFX_FxgeDevice();
-
- FX_BOOL Attach(CFX_DIBitmap* pBitmap, int dither_bits = 0, FX_BOOL bRgbByteOrder = FALSE, CFX_DIBitmap* pOriDevice = NULL, FX_BOOL bGroupKnockout = FALSE);
-
- FX_BOOL Create(int width, int height, FXDIB_Format format, int dither_bits = 0, CFX_DIBitmap* pOriDevice = NULL);
-protected:
-
- FX_BOOL m_bOwnedBitmap;
-};
-class CFX_SkiaDevice : public CFX_RenderDevice
-{
-public:
-
- CFX_SkiaDevice();
-
- ~CFX_SkiaDevice();
-
- FX_BOOL Attach(CFX_DIBitmap* pBitmap, int dither_bits = 0, FX_BOOL bRgbByteOrder = FALSE, CFX_DIBitmap* pOriDevice = NULL, FX_BOOL bGroupKnockout = FALSE);
-
- FX_BOOL Create(int width, int height, FXDIB_Format format, int dither_bits = 0, CFX_DIBitmap* pOriDevice = NULL);
-protected:
-
- FX_BOOL m_bOwnedBitmap;
-};
-class IFX_RenderDeviceDriver : public CFX_Object
-{
-public:
-
- static IFX_RenderDeviceDriver* CreateFxgeDriver(CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder = FALSE,
- CFX_DIBitmap* pOriDevice = NULL, FX_BOOL bGroupKnockout = FALSE);
-
- virtual ~IFX_RenderDeviceDriver() {}
- virtual void Begin() { }
- virtual void End() { }
-
- virtual int GetDeviceCaps(int caps_id) = 0;
-
- virtual CFX_Matrix GetCTM() const
- {
- return CFX_Matrix();
- }
-
- virtual FX_BOOL IsPSPrintDriver()
- {
- return FALSE;
- }
-
- virtual FX_BOOL StartRendering()
- {
- return TRUE;
- }
-
- virtual void EndRendering() {}
-
-
-
-
- virtual void SaveState() = 0;
-
- virtual void RestoreState(FX_BOOL bKeepSaved = FALSE) = 0;
-
-
- virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- int fill_mode
- ) = 0;
-
- virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- const CFX_GraphStateData* pGraphState
- )
- {
- return FALSE;
- }
-
- virtual FX_BOOL DrawPath(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- const CFX_GraphStateData* pGraphState,
- FX_DWORD fill_color,
- FX_DWORD stroke_color,
- int fill_mode,
- int alpha_flag = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL
- ) = 0;
-
- virtual FX_BOOL SetPixel(int x, int y, FX_DWORD color,
- int alpha_flag = 0, void* pIccTransform = NULL)
- {
- return FALSE;
- }
-
- virtual FX_BOOL FillRect(const FX_RECT* pRect, FX_DWORD fill_color,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL)
- {
- return FALSE;
- }
-
- virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL)
- {
- return FALSE;
- }
-
- virtual FX_BOOL GetClipBox(FX_RECT* pRect) = 0;
-
- virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL, FX_BOOL bDEdge = FALSE)
- {
- return FALSE;
- }
- virtual CFX_DIBitmap* GetBackDrop()
- {
- return NULL;
- }
-
- virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect,
- int dest_left, int dest_top, int blend_type,
- int alpha_flag = 0, void* pIccTransform = NULL) = 0;
-
- virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
- int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL) = 0;
-
- virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,
- const CFX_AffineMatrix* pMatrix, FX_DWORD flags, FX_LPVOID& handle,
- int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL) = 0;
-
- virtual FX_BOOL ContinueDIBits(FX_LPVOID handle, IFX_Pause* pPause)
- {
- return FALSE;
- }
-
- virtual void CancelDIBits(FX_LPVOID handle) {}
-
- virtual FX_BOOL DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
- CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color,
- int alpha_flag = 0, void* pIccTransform = NULL)
- {
- return FALSE;
- }
-
- virtual void* GetPlatformSurface()
- {
- return NULL;
- }
-
- virtual int GetDriverType()
- {
- return 0;
- }
-
- virtual void ClearDriver() {}
-};
-class IFX_PSOutput
-{
-public:
-
- virtual void OutputPS(FX_LPCSTR string, int len) = 0;
- virtual void Release() = 0;
-};
-class CPSFont;
-class CFX_PSRenderer : public CFX_Object
-{
-public:
-
- CFX_PSRenderer();
-
- ~CFX_PSRenderer();
-
- void Init(IFX_PSOutput* pOutput, int ps_level, int width, int height, FX_BOOL bCmykOutput);
- FX_BOOL StartRendering();
- void EndRendering();
-
- void SaveState();
-
- void RestoreState(FX_BOOL bKeepSaved = FALSE);
-
- void SetClip_PathFill(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- int fill_mode
- );
-
- void SetClip_PathStroke(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- const CFX_GraphStateData* pGraphState
- );
-
- FX_RECT GetClipBox()
- {
- return m_ClipBox;
- }
-
- FX_BOOL DrawPath(const CFX_PathData* pPathData,
- const CFX_AffineMatrix* pObject2Device,
- const CFX_GraphStateData* pGraphState,
- FX_DWORD fill_color,
- FX_DWORD stroke_color,
- int fill_mode,
- int alpha_flag = 0,
- void* pIccTransform = NULL
- );
-
- FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
- int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
- int dest_width, int dest_height, FX_DWORD flags,
- int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL DrawDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color,
- const CFX_AffineMatrix* pMatrix, FX_DWORD flags,
- int alpha_flag = 0, void* pIccTransform = NULL);
-
- FX_BOOL DrawText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, CFX_FontCache* pCache,
- const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color,
- int alpha_flag = 0, void* pIccTransform = NULL);
-private:
-
- IFX_PSOutput* m_pOutput;
-
- int m_PSLevel;
-
- CFX_GraphStateData m_CurGraphState;
-
- FX_BOOL m_bGraphStateSet;
-
- FX_BOOL m_bCmykOutput;
-
- FX_BOOL m_bColorSet;
-
- FX_DWORD m_LastColor;
-
- FX_RECT m_ClipBox;
-
- CFX_ArrayTemplate<CPSFont*> m_PSFontList;
-
- CFX_ArrayTemplate<FX_RECT> m_ClipBoxStack;
- FX_BOOL m_bInited;
-
- void OutputPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device);
-
- void SetGraphState(const CFX_GraphStateData* pGraphState);
-
- void SetColor(FX_DWORD color, int alpha_flag, void* pIccTransform);
-
- void FindPSFontGlyph(CFX_FaceCache* pFaceCache, CFX_Font* pFont, const FXTEXT_CHARPOS& charpos, int& ps_fontnum, int &ps_glyphindex);
-
- void WritePSBinary(FX_LPCBYTE data, int len);
-};
-#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 _FX_GE_H_
+#define _FX_GE_H_
+#ifndef _FX_DIB_H_
+#include "fx_dib.h"
+#endif
+#ifndef _FX_FONT_H_
+#include "fx_font.h"
+#endif
+class CFX_ClipRgn;
+class CFX_PathData;
+class CFX_GraphStateData;
+class CFX_Font;
+class CFX_FontMgr;
+class CFX_FontCache;
+class CFX_FaceCache;
+class CFX_RenderDevice;
+class IFX_RenderDeviceDriver;
+class CCodec_ModuleMgr;
+class IFXG_PaintModuleMgr;
+class CFX_GEModule : public CFX_Object
+{
+public:
+
+ static void Create();
+
+ static void Use(CFX_GEModule* pMgr);
+
+ static CFX_GEModule* Get();
+
+ static void Destroy();
+public:
+
+ CFX_FontCache* GetFontCache();
+ CFX_FontMgr* GetFontMgr()
+ {
+ return m_pFontMgr;
+ }
+ void SetTextGamma(FX_FLOAT gammaValue);
+ FX_LPCBYTE GetTextGammaTable();
+ void SetExtFontMapper(IFX_FontMapper* pFontMapper);
+
+ void SetCodecModule(CCodec_ModuleMgr* pCodecModule)
+ {
+ m_pCodecModule = pCodecModule;
+ }
+ CCodec_ModuleMgr* GetCodecModule()
+ {
+ return m_pCodecModule;
+ }
+ FXFT_Library m_FTLibrary;
+ void* GetPlatformData()
+ {
+ return m_pPlatformData;
+ }
+protected:
+
+ CFX_GEModule();
+
+ ~CFX_GEModule();
+ void InitPlatform();
+ void DestroyPlatform();
+private:
+ FX_BYTE m_GammaValue[256];
+ CFX_FontCache* m_pFontCache;
+ CFX_FontMgr* m_pFontMgr;
+ CCodec_ModuleMgr* m_pCodecModule;
+ void* m_pPlatformData;
+};
+typedef struct {
+
+ FX_FLOAT m_PointX;
+
+ FX_FLOAT m_PointY;
+
+ int m_Flag;
+} FX_PATHPOINT;
+#define FXPT_CLOSEFIGURE 0x01
+#define FXPT_LINETO 0x02
+#define FXPT_BEZIERTO 0x04
+#define FXPT_MOVETO 0x06
+#define FXPT_TYPE 0x06
+#define FXFILL_ALTERNATE 1
+#define FXFILL_WINDING 2
+class CFX_ClipRgn : public CFX_Object
+{
+public:
+
+ CFX_ClipRgn(int device_width, int device_height);
+
+ CFX_ClipRgn(const FX_RECT& rect);
+
+ CFX_ClipRgn(const CFX_ClipRgn& src);
+
+ ~CFX_ClipRgn();
+
+ typedef enum {
+ RectI,
+ MaskF
+ } ClipType;
+
+ void Reset(const FX_RECT& rect);
+
+ ClipType GetType() const
+ {
+ return m_Type;
+ }
+
+ const FX_RECT& GetBox() const
+ {
+ return m_Box;
+ }
+
+ CFX_DIBitmapRef GetMask() const
+ {
+ return m_Mask;
+ }
+
+ void IntersectRect(const FX_RECT& rect);
+
+ void IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask);
+protected:
+
+ ClipType m_Type;
+
+ FX_RECT m_Box;
+
+ CFX_DIBitmapRef m_Mask;
+
+ void IntersectMaskRect(FX_RECT rect, FX_RECT mask_box, CFX_DIBitmapRef Mask);
+};
+extern const FX_BYTE g_GammaRamp[256];
+extern const FX_BYTE g_GammaInverse[256];
+#define FX_GAMMA(value) (value)
+#define FX_GAMMA_INVERSE(value) (value)
+inline FX_ARGB ArgbGamma(FX_ARGB argb)
+{
+ return argb;
+}
+inline FX_ARGB ArgbGammaInverse(FX_ARGB argb)
+{
+ return argb;
+}
+class CFX_PathData : public CFX_Object
+{
+public:
+
+ CFX_PathData();
+
+ CFX_PathData(const CFX_PathData& src);
+
+ ~CFX_PathData();
+
+
+
+
+ int GetPointCount() const
+ {
+ return m_PointCount;
+ }
+
+ int GetFlag(int index) const
+ {
+ return m_pPoints[index].m_Flag;
+ }
+
+ FX_FLOAT GetPointX(int index) const
+ {
+ return m_pPoints[index].m_PointX;
+ }
+
+ FX_FLOAT GetPointY(int index) const
+ {
+ return m_pPoints[index].m_PointY;
+ }
+
+
+
+ FX_PATHPOINT* GetPoints() const
+ {
+ return m_pPoints;
+ }
+
+ FX_BOOL SetPointCount(int nPoints);
+
+ FX_BOOL AllocPointCount(int nPoints);
+
+ FX_BOOL AddPointCount(int addPoints);
+
+ CFX_FloatRect GetBoundingBox() const;
+
+ CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const;
+
+ void Transform(const CFX_AffineMatrix* pMatrix);
+
+ FX_BOOL IsRect() const;
+
+ FX_BOOL GetZeroAreaPath(CFX_PathData& NewPath, CFX_AffineMatrix* pMatrix, FX_BOOL&bThin, FX_BOOL bAdjust) const;
+
+ FX_BOOL IsRect(const CFX_AffineMatrix* pMatrix, CFX_FloatRect* rect) const;
+
+ FX_BOOL Append(const CFX_PathData* pSrc, const CFX_AffineMatrix* pMatrix);
+
+ FX_BOOL AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top);
+
+ void SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag);
+
+ void TrimPoints(int nPoints);
+
+ FX_BOOL Copy(const CFX_PathData &src);
+protected:
+ friend class CPDF_Path;
+
+ int m_PointCount;
+
+ FX_PATHPOINT* m_pPoints;
+
+ int m_AllocCount;
+};
+class CFX_GraphStateData : public CFX_Object
+{
+public:
+
+ CFX_GraphStateData();
+
+ CFX_GraphStateData(const CFX_GraphStateData& src);
+
+ ~CFX_GraphStateData();
+
+ void Copy(const CFX_GraphStateData& src);
+
+ void SetDashCount(int count);
+
+
+
+ typedef enum {
+ LineCapButt = 0,
+ LineCapRound = 1,
+ LineCapSquare = 2
+ } LineCap;
+ LineCap m_LineCap;
+ int m_DashCount;
+ FX_FLOAT* m_DashArray;
+ FX_FLOAT m_DashPhase;
+
+ typedef enum {
+ LineJoinMiter = 0,
+ LineJoinRound = 1,
+ LineJoinBevel = 2,
+ } LineJoin;
+ LineJoin m_LineJoin;
+ FX_FLOAT m_MiterLimit;
+ FX_FLOAT m_LineWidth;
+
+};
+#define FXDC_DEVICE_CLASS 1
+#define FXDC_PIXEL_WIDTH 2
+#define FXDC_PIXEL_HEIGHT 3
+#define FXDC_BITS_PIXEL 4
+#define FXDC_HORZ_SIZE 5
+#define FXDC_VERT_SIZE 6
+#define FXDC_RENDER_CAPS 7
+#define FXDC_DITHER_BITS 8
+#define FXDC_DISPLAY 1
+#define FXDC_PRINTER 2
+#define FXRC_GET_BITS 0x01
+#define FXRC_BIT_MASK 0x02
+#define FXRC_ALPHA_MASK 0x04
+#define FXRC_ALPHA_PATH 0x10
+#define FXRC_ALPHA_IMAGE 0x20
+#define FXRC_ALPHA_OUTPUT 0x40
+#define FXRC_BLEND_MODE 0x80
+#define FXRC_SOFT_CLIP 0x100
+#define FXRC_CMYK_OUTPUT 0x200
+#define FXRC_BITMASK_OUTPUT 0x400
+#define FXRC_BYTEMASK_OUTPUT 0x800
+#define FXRENDER_IMAGE_LOSSY 0x1000
+#define FXFILL_ALTERNATE 1
+#define FXFILL_WINDING 2
+#define FXFILL_FULLCOVER 4
+#define FXFILL_RECT_AA 8
+#define FX_FILL_STROKE 16
+#define FX_STROKE_ADJUST 32
+#define FX_STROKE_TEXT_MODE 64
+#define FX_FILL_TEXT_MODE 128
+#define FX_ZEROAREA_FILL 256
+#define FXFILL_NOPATHSMOOTH 512
+#define FXTEXT_CLEARTYPE 0x01
+#define FXTEXT_BGR_STRIPE 0x02
+#define FXTEXT_PRINTGRAPHICTEXT 0x04
+#define FXTEXT_NO_NATIVETEXT 0x08
+#define FXTEXT_PRINTIMAGETEXT 0x10
+#define FXTEXT_NOSMOOTH 0x20
+typedef struct {
+ FX_DWORD m_GlyphIndex;
+ FX_FLOAT m_OriginX, m_OriginY;
+ int m_FontCharWidth;
+ FX_BOOL m_bGlyphAdjust;
+ FX_FLOAT m_AdjustMatrix[4];
+ FX_DWORD m_ExtGID;
+ FX_BOOL m_bFontStyle;
+} FXTEXT_CHARPOS;
+class CFX_RenderDevice : public CFX_Object
+{
+public:
+ CFX_RenderDevice();
+
+ virtual ~CFX_RenderDevice();
+
+ void SetDeviceDriver(IFX_RenderDeviceDriver* pDriver);
+
+ IFX_RenderDeviceDriver* GetDeviceDriver() const
+ {
+ return m_pDeviceDriver;
+ }
+
+ FX_BOOL StartRendering();
+
+ void EndRendering();
+
+
+
+ void SaveState();
+
+ void RestoreState(FX_BOOL bKeepSaved = FALSE);
+
+
+
+
+ int GetWidth() const
+ {
+ return m_Width;
+ }
+
+ int GetHeight() const
+ {
+ return m_Height;
+ }
+
+ int GetDeviceClass() const
+ {
+ return m_DeviceClass;
+ }
+
+ int GetBPP() const
+ {
+ return m_bpp;
+ }
+
+ int GetRenderCaps() const
+ {
+ return m_RenderCaps;
+ }
+
+ int GetDeviceCaps(int id) const;
+
+ CFX_Matrix GetCTM() const;
+
+
+ CFX_DIBitmap* GetBitmap() const
+ {
+ return m_pBitmap;
+ }
+ void SetBitmap(CFX_DIBitmap* pBitmap)
+ {
+ m_pBitmap = pBitmap;
+ }
+
+ FX_BOOL CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, int height) const;
+
+ const FX_RECT& GetClipBox() const
+ {
+ return m_ClipBox;
+ }
+
+ FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ int fill_mode
+ );
+
+ FX_BOOL SetClip_Rect(const FX_RECT* pRect);
+
+ FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState
+ );
+
+ FX_BOOL DrawPath(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState,
+ FX_DWORD fill_color,
+ FX_DWORD stroke_color,
+ int fill_mode,
+ int alpha_flag = 0,
+ void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL
+ );
+
+ FX_BOOL SetPixel(int x, int y, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL FillRect(const FX_RECT* pRect, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
+
+ FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color,
+ int fill_mode = 0, int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
+
+ FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL);
+
+ CFX_DIBitmap* GetBackDrop();
+
+ FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, int left, int top, int blend_type = FXDIB_BLEND_NORMAL,
+ void* pIccTransform = NULL);
+
+ FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, int left, int top, int dest_width, int dest_height,
+ FX_DWORD flags = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
+
+ FX_BOOL SetBitMask(const CFX_DIBSource* pBitmap, int left, int top, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL StretchBitMask(const CFX_DIBSource* pBitmap, int left, int top, int dest_width, int dest_height,
+ FX_DWORD color, FX_DWORD flags = 0, int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,
+ const CFX_AffineMatrix* pMatrix, FX_DWORD flags, FX_LPVOID& handle,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
+
+ FX_BOOL ContinueDIBits(FX_LPVOID handle, IFX_Pause* pPause);
+
+ void CancelDIBits(FX_LPVOID handle);
+
+ FX_BOOL DrawNormalText(int nChars, const FXTEXT_CHARPOS* pCharPos,
+ CFX_Font* pFont, CFX_FontCache* pCache,
+ FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device,
+ FX_DWORD fill_color, FX_DWORD text_flags,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPos,
+ CFX_Font* pFont, CFX_FontCache* pCache,
+ FX_FLOAT font_size, const CFX_AffineMatrix* pText2User,
+ const CFX_AffineMatrix* pUser2Device, const CFX_GraphStateData* pGraphState,
+ FX_DWORD fill_color, FX_DWORD stroke_color, CFX_PathData* pClippingPath, int nFlag = 0,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
+ virtual void Begin() {}
+ virtual void End() {}
+private:
+
+ CFX_DIBitmap* m_pBitmap;
+
+
+
+ int m_Width;
+
+ int m_Height;
+
+ int m_bpp;
+
+ int m_RenderCaps;
+
+ int m_DeviceClass;
+
+ FX_RECT m_ClipBox;
+
+protected:
+
+ IFX_RenderDeviceDriver* m_pDeviceDriver;
+private:
+
+ void InitDeviceInfo();
+
+ void UpdateClipBox();
+};
+class CFX_FxgeDevice : public CFX_RenderDevice
+{
+public:
+
+ CFX_FxgeDevice();
+
+ ~CFX_FxgeDevice();
+
+ FX_BOOL Attach(CFX_DIBitmap* pBitmap, int dither_bits = 0, FX_BOOL bRgbByteOrder = FALSE, CFX_DIBitmap* pOriDevice = NULL, FX_BOOL bGroupKnockout = FALSE);
+
+ FX_BOOL Create(int width, int height, FXDIB_Format format, int dither_bits = 0, CFX_DIBitmap* pOriDevice = NULL);
+protected:
+
+ FX_BOOL m_bOwnedBitmap;
+};
+class CFX_SkiaDevice : public CFX_RenderDevice
+{
+public:
+
+ CFX_SkiaDevice();
+
+ ~CFX_SkiaDevice();
+
+ FX_BOOL Attach(CFX_DIBitmap* pBitmap, int dither_bits = 0, FX_BOOL bRgbByteOrder = FALSE, CFX_DIBitmap* pOriDevice = NULL, FX_BOOL bGroupKnockout = FALSE);
+
+ FX_BOOL Create(int width, int height, FXDIB_Format format, int dither_bits = 0, CFX_DIBitmap* pOriDevice = NULL);
+protected:
+
+ FX_BOOL m_bOwnedBitmap;
+};
+class IFX_RenderDeviceDriver : public CFX_Object
+{
+public:
+
+ static IFX_RenderDeviceDriver* CreateFxgeDriver(CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder = FALSE,
+ CFX_DIBitmap* pOriDevice = NULL, FX_BOOL bGroupKnockout = FALSE);
+
+ virtual ~IFX_RenderDeviceDriver() {}
+ virtual void Begin() { }
+ virtual void End() { }
+
+ virtual int GetDeviceCaps(int caps_id) = 0;
+
+ virtual CFX_Matrix GetCTM() const
+ {
+ return CFX_Matrix();
+ }
+
+ virtual FX_BOOL IsPSPrintDriver()
+ {
+ return FALSE;
+ }
+
+ virtual FX_BOOL StartRendering()
+ {
+ return TRUE;
+ }
+
+ virtual void EndRendering() {}
+
+
+
+
+ virtual void SaveState() = 0;
+
+ virtual void RestoreState(FX_BOOL bKeepSaved = FALSE) = 0;
+
+
+ virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ int fill_mode
+ ) = 0;
+
+ virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState
+ )
+ {
+ return FALSE;
+ }
+
+ virtual FX_BOOL DrawPath(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState,
+ FX_DWORD fill_color,
+ FX_DWORD stroke_color,
+ int fill_mode,
+ int alpha_flag = 0,
+ void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL
+ ) = 0;
+
+ virtual FX_BOOL SetPixel(int x, int y, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL)
+ {
+ return FALSE;
+ }
+
+ virtual FX_BOOL FillRect(const FX_RECT* pRect, FX_DWORD fill_color,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL)
+ {
+ return FALSE;
+ }
+
+ virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL)
+ {
+ return FALSE;
+ }
+
+ virtual FX_BOOL GetClipBox(FX_RECT* pRect) = 0;
+
+ virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL, FX_BOOL bDEdge = FALSE)
+ {
+ return FALSE;
+ }
+ virtual CFX_DIBitmap* GetBackDrop()
+ {
+ return NULL;
+ }
+
+ virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect,
+ int dest_left, int dest_top, int blend_type,
+ int alpha_flag = 0, void* pIccTransform = NULL) = 0;
+
+ virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
+ int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL) = 0;
+
+ virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,
+ const CFX_AffineMatrix* pMatrix, FX_DWORD flags, FX_LPVOID& handle,
+ int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL) = 0;
+
+ virtual FX_BOOL ContinueDIBits(FX_LPVOID handle, IFX_Pause* pPause)
+ {
+ return FALSE;
+ }
+
+ virtual void CancelDIBits(FX_LPVOID handle) {}
+
+ virtual FX_BOOL DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
+ CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL)
+ {
+ return FALSE;
+ }
+
+ virtual void* GetPlatformSurface()
+ {
+ return NULL;
+ }
+
+ virtual int GetDriverType()
+ {
+ return 0;
+ }
+
+ virtual void ClearDriver() {}
+};
+class IFX_PSOutput
+{
+public:
+
+ virtual void OutputPS(FX_LPCSTR string, int len) = 0;
+ virtual void Release() = 0;
+};
+class CPSFont;
+class CFX_PSRenderer : public CFX_Object
+{
+public:
+
+ CFX_PSRenderer();
+
+ ~CFX_PSRenderer();
+
+ void Init(IFX_PSOutput* pOutput, int ps_level, int width, int height, FX_BOOL bCmykOutput);
+ FX_BOOL StartRendering();
+ void EndRendering();
+
+ void SaveState();
+
+ void RestoreState(FX_BOOL bKeepSaved = FALSE);
+
+ void SetClip_PathFill(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ int fill_mode
+ );
+
+ void SetClip_PathStroke(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState
+ );
+
+ FX_RECT GetClipBox()
+ {
+ return m_ClipBox;
+ }
+
+ FX_BOOL DrawPath(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState,
+ FX_DWORD fill_color,
+ FX_DWORD stroke_color,
+ int fill_mode,
+ int alpha_flag = 0,
+ void* pIccTransform = NULL
+ );
+
+ FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
+ int dest_width, int dest_height, FX_DWORD flags,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL DrawDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color,
+ const CFX_AffineMatrix* pMatrix, FX_DWORD flags,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ FX_BOOL DrawText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, CFX_FontCache* pCache,
+ const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+private:
+
+ IFX_PSOutput* m_pOutput;
+
+ int m_PSLevel;
+
+ CFX_GraphStateData m_CurGraphState;
+
+ FX_BOOL m_bGraphStateSet;
+
+ FX_BOOL m_bCmykOutput;
+
+ FX_BOOL m_bColorSet;
+
+ FX_DWORD m_LastColor;
+
+ FX_RECT m_ClipBox;
+
+ CFX_ArrayTemplate<CPSFont*> m_PSFontList;
+
+ CFX_ArrayTemplate<FX_RECT> m_ClipBoxStack;
+ FX_BOOL m_bInited;
+
+ void OutputPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device);
+
+ void SetGraphState(const CFX_GraphStateData* pGraphState);
+
+ void SetColor(FX_DWORD color, int alpha_flag, void* pIccTransform);
+
+ void FindPSFontGlyph(CFX_FaceCache* pFaceCache, CFX_Font* pFont, const FXTEXT_CHARPOS& charpos, int& ps_fontnum, int &ps_glyphindex);
+
+ void WritePSBinary(FX_LPCBYTE data, int len);
+};
+#endif
diff --git a/core/include/fxge/fx_ge_apple.h b/core/include/fxge/fx_ge_apple.h
index f13a1b38be..44bf2a028a 100644
--- a/core/include/fxge/fx_ge_apple.h
+++ b/core/include/fxge/fx_ge_apple.h
@@ -1,26 +1,26 @@
-// 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 _FX_GE_APPLE_H_
-#define _FX_GE_APPLE_H_
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-class CFX_QuartzDevice : public CFX_RenderDevice
-{
-public:
- CFX_QuartzDevice();
- ~CFX_QuartzDevice();
- FX_BOOL Attach(CGContextRef context, FX_INT32 nDeviceClass = FXDC_DISPLAY);
- FX_BOOL Attach(CFX_DIBitmap* pBitmap);
- FX_BOOL Create(FX_INT32 width, FX_INT32 height, FXDIB_Format format);
-
- CGContextRef GetContext();
-
-protected:
- CGContextRef m_pContext;
- FX_BOOL m_bOwnedBitmap;
-};
-#endif
-#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 _FX_GE_APPLE_H_
+#define _FX_GE_APPLE_H_
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+class CFX_QuartzDevice : public CFX_RenderDevice
+{
+public:
+ CFX_QuartzDevice();
+ ~CFX_QuartzDevice();
+ FX_BOOL Attach(CGContextRef context, FX_INT32 nDeviceClass = FXDC_DISPLAY);
+ FX_BOOL Attach(CFX_DIBitmap* pBitmap);
+ FX_BOOL Create(FX_INT32 width, FX_INT32 height, FXDIB_Format format);
+
+ CGContextRef GetContext();
+
+protected:
+ CGContextRef m_pContext;
+ FX_BOOL m_bOwnedBitmap;
+};
+#endif
+#endif
diff --git a/core/include/fxge/fx_ge_win32.h b/core/include/fxge/fx_ge_win32.h
index 0b421db788..311d355ef7 100644
--- a/core/include/fxge/fx_ge_win32.h
+++ b/core/include/fxge/fx_ge_win32.h
@@ -1,105 +1,105 @@
-// 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 _FX_GE_WIN32_H_
-#define _FX_GE_WIN32_H_
-#ifdef _WIN32
-#ifndef _WINDOWS_
-#include <windows.h>
-#endif
-#define WINDIB_OPEN_MEMORY 0x1
-#define WINDIB_OPEN_PATHNAME 0x2
-typedef struct WINDIB_Open_Args_ {
-
- int flags;
-
- const FX_BYTE* memory_base;
-
- size_t memory_size;
-
- FX_LPCWSTR path_name;
-} WINDIB_Open_Args_;
-class CFX_WindowsDIB : public CFX_DIBitmap
-{
-public:
-
- static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap);
-
- static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData);
-
- static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC);
-
- static CFX_DIBitmap* LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pPalette = NULL, FX_DWORD size = 256);
-
- static CFX_DIBitmap* LoadFromFile(FX_LPCWSTR filename);
-
- static CFX_DIBitmap* LoadFromFile(FX_LPCSTR filename)
- {
- return LoadFromFile(CFX_WideString::FromLocal(filename));
- }
-
- static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args);
-
- CFX_WindowsDIB(HDC hDC, int width, int height);
-
- ~CFX_WindowsDIB();
-
- HDC GetDC() const
- {
- return m_hMemDC;
- }
-
- HBITMAP GetWindowsBitmap() const
- {
- return m_hBitmap;
- }
-
- void LoadFromDevice(HDC hDC, int left, int top);
-
- void SetToDevice(HDC hDC, int left, int top);
-protected:
-
- HDC m_hMemDC;
-
- HBITMAP m_hBitmap;
-
- HBITMAP m_hOldBitmap;
-};
-class CFX_WindowsDevice : public CFX_RenderDevice
-{
-public:
- static IFX_RenderDeviceDriver* CreateDriver(HDC hDC, FX_BOOL bCmykOutput = FALSE);
-
- CFX_WindowsDevice(HDC hDC, FX_BOOL bCmykOutput = FALSE, FX_BOOL bForcePSOutput = FALSE, int psLevel = 2);
-
- HDC GetDC() const;
-
- FX_BOOL m_bForcePSOutput;
-
- static int m_psLevel;
-};
-class CFX_WinBitmapDevice : public CFX_RenderDevice
-{
-public:
-
- CFX_WinBitmapDevice(int width, int height, FXDIB_Format format);
-
- ~CFX_WinBitmapDevice();
-
- HDC GetDC()
- {
- return m_hDC;
- }
-protected:
-
- HBITMAP m_hBitmap;
-
- HBITMAP m_hOldBitmap;
-
- HDC m_hDC;
-};
-#endif
-#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 _FX_GE_WIN32_H_
+#define _FX_GE_WIN32_H_
+#ifdef _WIN32
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+#define WINDIB_OPEN_MEMORY 0x1
+#define WINDIB_OPEN_PATHNAME 0x2
+typedef struct WINDIB_Open_Args_ {
+
+ int flags;
+
+ const FX_BYTE* memory_base;
+
+ size_t memory_size;
+
+ FX_LPCWSTR path_name;
+} WINDIB_Open_Args_;
+class CFX_WindowsDIB : public CFX_DIBitmap
+{
+public:
+
+ static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap);
+
+ static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData);
+
+ static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC);
+
+ static CFX_DIBitmap* LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pPalette = NULL, FX_DWORD size = 256);
+
+ static CFX_DIBitmap* LoadFromFile(FX_LPCWSTR filename);
+
+ static CFX_DIBitmap* LoadFromFile(FX_LPCSTR filename)
+ {
+ return LoadFromFile(CFX_WideString::FromLocal(filename));
+ }
+
+ static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args);
+
+ CFX_WindowsDIB(HDC hDC, int width, int height);
+
+ ~CFX_WindowsDIB();
+
+ HDC GetDC() const
+ {
+ return m_hMemDC;
+ }
+
+ HBITMAP GetWindowsBitmap() const
+ {
+ return m_hBitmap;
+ }
+
+ void LoadFromDevice(HDC hDC, int left, int top);
+
+ void SetToDevice(HDC hDC, int left, int top);
+protected:
+
+ HDC m_hMemDC;
+
+ HBITMAP m_hBitmap;
+
+ HBITMAP m_hOldBitmap;
+};
+class CFX_WindowsDevice : public CFX_RenderDevice
+{
+public:
+ static IFX_RenderDeviceDriver* CreateDriver(HDC hDC, FX_BOOL bCmykOutput = FALSE);
+
+ CFX_WindowsDevice(HDC hDC, FX_BOOL bCmykOutput = FALSE, FX_BOOL bForcePSOutput = FALSE, int psLevel = 2);
+
+ HDC GetDC() const;
+
+ FX_BOOL m_bForcePSOutput;
+
+ static int m_psLevel;
+};
+class CFX_WinBitmapDevice : public CFX_RenderDevice
+{
+public:
+
+ CFX_WinBitmapDevice(int width, int height, FXDIB_Format format);
+
+ ~CFX_WinBitmapDevice();
+
+ HDC GetDC()
+ {
+ return m_hDC;
+ }
+protected:
+
+ HBITMAP m_hBitmap;
+
+ HBITMAP m_hOldBitmap;
+
+ HDC m_hDC;
+};
+#endif
+#endif
diff --git a/core/include/thirdparties/freetype/foxitnames.h b/core/include/thirdparties/freetype/foxitnames.h
index 5749f9b6b3..e163fb86f0 100644
--- a/core/include/thirdparties/freetype/foxitnames.h
+++ b/core/include/thirdparties/freetype/foxitnames.h
@@ -1,283 +1,283 @@
-#ifndef _FX_FREETYPE_DONT_RENAME_
-// To avoid any possible linking confliction, we rename all FreeType exported names
-
-#define FT_Init_FreeType FPDFAPI_FT_Init_FreeType
-#define FT_Done_FreeType FPDFAPI_FT_Done_FreeType
-#define FT_New_Face FPDFAPI_FT_New_Face
-#define FT_Select_Charmap FPDFAPI_FT_Select_Charmap
-#define FT_Done_Face FPDFAPI_FT_Done_Face
-#define FT_Get_Charmap_Index FPDFAPI_FT_Get_Charmap_Index
-#define FT_New_Memory_Face FPDFAPI_FT_New_Memory_Face
-#define FT_MulDiv FPDFAPI_FT_MulDiv
-#define FT_Vector_Transform FPDFAPI_FT_Vector_Transform
-#define FT_Cos FPDFAPI_FT_Cos
-#define FT_Sin FPDFAPI_FT_Sin
-#define FT_Load_Glyph FPDFAPI_FT_Load_Glyph
-#define FT_DivFix FPDFAPI_FT_DivFix
-#define FT_Realloc FPDFAPI_FT_Realloc
-#define FT_Alloc FPDFAPI_FT_Alloc
-#define FT_Get_Char_Index FPDFAPI_FT_Get_Char_Index
-#define FT_GlyphLoader_CheckPoints FPDFAPI_FT_GlyphLoader_CheckPoints
-#define FT_GlyphLoader_Add FPDFAPI_FT_GlyphLoader_Add
-#define FT_GlyphLoader_CheckSubGlyphs FPDFAPI_FT_GlyphLoader_CheckSubGlyphs
-#define FT_Outline_Translate FPDFAPI_FT_Outline_Translate
-#define FT_Outline_Transform FPDFAPI_FT_Outline_Transform
-#define FT_Outline_Get_CBox FPDFAPI_FT_Outline_Get_CBox
-#define FT_GlyphLoader_Rewind FPDFAPI_FT_GlyphLoader_Rewind
-#define FT_GlyphLoader_CopyPoints FPDFAPI_FT_GlyphLoader_CopyPoints
-#define FT_GlyphLoader_New FPDFAPI_FT_GlyphLoader_New
-#define FT_GlyphLoader_CreateExtra FPDFAPI_FT_GlyphLoader_CreateExtra
-#define FT_Free FPDFAPI_FT_Free
-#define FT_Set_Charmap FPDFAPI_FT_Set_Charmap
-#define FT_GlyphLoader_Done FPDFAPI_FT_GlyphLoader_Done
-#define _debug_mem_dummy FPDFAPI__debug_mem_dummy
-#define _debug_mem_dummy FPDFAPI__debug_mem_dummy
-#define FT_QAlloc FPDFAPI_FT_QAlloc
-#define FT_QRealloc FPDFAPI_FT_QRealloc
-#define FT_List_Find FPDFAPI_FT_List_Find
-#define FT_List_Add FPDFAPI_FT_List_Add
-#define FT_List_Insert FPDFAPI_FT_List_Insert
-#define FT_List_Remove FPDFAPI_FT_List_Remove
-#define FT_List_Up FPDFAPI_FT_List_Up
-#define FT_List_Iterate FPDFAPI_FT_List_Iterate
-#define FT_List_Finalize FPDFAPI_FT_List_Finalize
-#define ft_highpow2 FPDFAPI_ft_highpow2
-#define FT_Stream_OpenMemory FPDFAPI_FT_Stream_OpenMemory
-#define FT_Stream_Close FPDFAPI_FT_Stream_Close
-#define FT_Stream_Seek FPDFAPI_FT_Stream_Seek
-#define FT_Stream_Skip FPDFAPI_FT_Stream_Skip
-#define FT_Stream_Pos FPDFAPI_FT_Stream_Pos
-#define FT_Stream_ReadAt FPDFAPI_FT_Stream_ReadAt
-#define FT_Stream_Read FPDFAPI_FT_Stream_Read
-#define FT_Stream_TryRead FPDFAPI_FT_Stream_TryRead
-#define FT_Stream_EnterFrame FPDFAPI_FT_Stream_EnterFrame
-#define FT_Stream_ExtractFrame FPDFAPI_FT_Stream_ExtractFrame
-#define FT_Stream_ReleaseFrame FPDFAPI_FT_Stream_ReleaseFrame
-#define FT_Stream_ExitFrame FPDFAPI_FT_Stream_ExitFrame
-#define FT_Stream_GetChar FPDFAPI_FT_Stream_GetChar
-#define FT_Stream_GetShort FPDFAPI_FT_Stream_GetShort
-#define FT_Stream_GetShortLE FPDFAPI_FT_Stream_GetShortLE
-#define FT_Stream_GetOffset FPDFAPI_FT_Stream_GetOffset
-#define FT_Stream_GetLong FPDFAPI_FT_Stream_GetLong
-#define FT_Stream_GetLongLE FPDFAPI_FT_Stream_GetLongLE
-#define FT_Stream_ReadChar FPDFAPI_FT_Stream_ReadChar
-#define FT_Stream_ReadShort FPDFAPI_FT_Stream_ReadShort
-#define FT_Stream_ReadShortLE FPDFAPI_FT_Stream_ReadShortLE
-#define FT_Stream_ReadOffset FPDFAPI_FT_Stream_ReadOffset
-#define FT_Stream_ReadLong FPDFAPI_FT_Stream_ReadLong
-#define FT_Stream_ReadLongLE FPDFAPI_FT_Stream_ReadLongLE
-#define FT_Stream_ReadFields FPDFAPI_FT_Stream_ReadFields
-#define FT_RoundFix FPDFAPI_FT_RoundFix
-#define FT_CeilFix FPDFAPI_FT_CeilFix
-#define FT_FloorFix FPDFAPI_FT_FloorFix
-#define FT_Sqrt32 FPDFAPI_FT_Sqrt32
-#define FT_SqrtFixed FPDFAPI_FT_SqrtFixed
-#define FT_Tan FPDFAPI_FT_Tan
-#define FT_Atan2 FPDFAPI_FT_Atan2
-#define FT_Vector_Unit FPDFAPI_FT_Vector_Unit
-#define FT_Vector_Rotate FPDFAPI_FT_Vector_Rotate
-#define FT_Vector_Length FPDFAPI_FT_Vector_Length
-#define FT_Vector_Polarize FPDFAPI_FT_Vector_Polarize
-#define FT_Vector_From_Polar FPDFAPI_FT_Vector_From_Polar
-#define FT_Angle_Diff FPDFAPI_FT_Angle_Diff
-#define FT_Outline_Decompose FPDFAPI_FT_Outline_Decompose
-#define FT_Outline_Done_Internal FPDFAPI_FT_Outline_Done_Internal
-#define FT_Outline_New_Internal FPDFAPI_FT_Outline_New_Internal
-#define FT_Outline_New FPDFAPI_FT_Outline_New
-#define FT_Outline_Check FPDFAPI_FT_Outline_Check
-#define FT_Outline_Copy FPDFAPI_FT_Outline_Copy
-#define FT_Outline_Done FPDFAPI_FT_Outline_Done
-#define FT_Outline_Reverse FPDFAPI_FT_Outline_Reverse
-#define FT_Set_Renderer FPDFAPI_FT_Set_Renderer
-#define FT_Lookup_Renderer FPDFAPI_FT_Lookup_Renderer
-#define FT_Outline_Render FPDFAPI_FT_Outline_Render
-#define FT_Outline_Get_Bitmap FPDFAPI_FT_Outline_Get_Bitmap
-#define FT_Outline_Get_Orientation FPDFAPI_FT_Outline_Get_Orientation
-#define FT_Outline_Embolden FPDFAPI_FT_Outline_Embolden
-#define FT_GlyphLoader_Reset FPDFAPI_FT_GlyphLoader_Reset
-#define FT_GlyphLoader_Prepare FPDFAPI_FT_GlyphLoader_Prepare
-#define ft_service_list_lookup FPDFAPI_ft_service_list_lookup
-#define ft_validator_init FPDFAPI_ft_validator_init
-#define ft_validator_run FPDFAPI_ft_validator_run
-#define ft_validator_error FPDFAPI_ft_validator_error
-#define FT_Stream_New FPDFAPI_FT_Stream_New
-#define FT_Stream_Free FPDFAPI_FT_Stream_Free
-#define ft_glyphslot_free_bitmap FPDFAPI_ft_glyphslot_free_bitmap
-#define ft_glyphslot_set_bitmap FPDFAPI_ft_glyphslot_set_bitmap
-#define FT_GlyphSlot_Own_Bitmap FPDFAPI_FT_GlyphSlot_Own_Bitmap
-#define ft_glyphslot_alloc_bitmap FPDFAPI_ft_glyphslot_alloc_bitmap
-#define FT_New_GlyphSlot FPDFAPI_FT_New_GlyphSlot
-#define FT_Done_GlyphSlot FPDFAPI_FT_Done_GlyphSlot
-#define FT_Set_Transform FPDFAPI_FT_Set_Transform
-#define FT_Render_Glyph_Internal FPDFAPI_FT_Render_Glyph_Internal
-#define FT_Render_Glyph FPDFAPI_FT_Render_Glyph
-#define FT_Load_Char FPDFAPI_FT_Load_Char
-#define FT_New_Size FPDFAPI_FT_New_Size
-#define FT_Open_Face FPDFAPI_FT_Open_Face
-#define FT_Attach_Stream FPDFAPI_FT_Attach_Stream
-#define FT_Attach_File FPDFAPI_FT_Attach_File
-#define FT_Done_Size FPDFAPI_FT_Done_Size
-#define FT_Set_Char_Size FPDFAPI_FT_Set_Char_Size
-#define FT_Set_Pixel_Sizes FPDFAPI_FT_Set_Pixel_Sizes
-#define FT_Get_Kerning FPDFAPI_FT_Get_Kerning
-#define FT_CMap_Done FPDFAPI_FT_CMap_Done
-#define FT_CMap_New FPDFAPI_FT_CMap_New
-#define FT_Get_Next_Char FPDFAPI_FT_Get_Next_Char
-#define FT_Get_First_Char FPDFAPI_FT_Get_First_Char
-#define FT_Get_Name_Index FPDFAPI_FT_Get_Name_Index
-#define FT_Get_Glyph_Name FPDFAPI_FT_Get_Glyph_Name
-#define FT_Get_Postscript_Name FPDFAPI_FT_Get_Postscript_Name
-#define FT_Get_Sfnt_Table FPDFAPI_FT_Get_Sfnt_Table
-#define FT_Load_Sfnt_Table FPDFAPI_FT_Load_Sfnt_Table
-#define FT_Sfnt_Table_Info FPDFAPI_FT_Sfnt_Table_Info
-#define FT_Get_CMap_Language_ID FPDFAPI_FT_Get_CMap_Language_ID
-#define FT_Activate_Size FPDFAPI_FT_Activate_Size
-#define FT_Get_Renderer FPDFAPI_FT_Get_Renderer
-#define FT_Remove_Module FPDFAPI_FT_Remove_Module
-#define FT_Add_Module FPDFAPI_FT_Add_Module
-#define FT_Get_Module FPDFAPI_FT_Get_Module
-#define FT_Get_Module_Interface FPDFAPI_FT_Get_Module_Interface
-#define ft_module_get_service FPDFAPI_ft_module_get_service
-#define FT_New_Library FPDFAPI_FT_New_Library
-#define FT_Library_Version FPDFAPI_FT_Library_Version
-#define FT_Done_Library FPDFAPI_FT_Done_Library
-#define FT_Set_Debug_Hook FPDFAPI_FT_Set_Debug_Hook
-#define FT_Raccess_Get_HeaderInfo FPDFAPI_FT_Raccess_Get_HeaderInfo
-#define FT_Raccess_Get_DataOffsets FPDFAPI_FT_Raccess_Get_DataOffsets
-#define FT_Raccess_Guess FPDFAPI_FT_Raccess_Guess
-#define af_dummy_script_class FPDFAPI_af_dummy_script_class
-#define af_latin_script_class FPDFAPI_af_latin_script_class
-#define af_cjk_script_class FPDFAPI_af_cjk_script_class
-#define af_autofitter_service FPDFAPI_af_autofitter_service
-#define autofit_module_class FPDFAPI_autofit_module_class
-#define cff_cmap_encoding_class_rec FPDFAPI_cff_cmap_encoding_class_rec
-#define cff_cmap_unicode_class_rec FPDFAPI_cff_cmap_unicode_class_rec
-#define cff_driver_class FPDFAPI_cff_driver_class
-#define FT_Stream_Open FPDFAPI_FT_Stream_Open
-#define FT_New_Memory FPDFAPI_FT_New_Memory
-#define FT_Done_Memory FPDFAPI_FT_Done_Memory
-#define ft_mem_qalloc FPDFAPI_ft_mem_qalloc
-#define ft_mem_alloc FPDFAPI_ft_mem_alloc
-#define ft_mem_free FPDFAPI_ft_mem_free
-#define ft_mem_qrealloc FPDFAPI_ft_mem_qrealloc
-#define ft_mem_realloc FPDFAPI_ft_mem_realloc
-#define FT_Get_TrueType_Engine_Type FPDFAPI_FT_Get_TrueType_Engine_Type
-#define ft_stub_set_char_sizes FPDFAPI_ft_stub_set_char_sizes
-#define ft_stub_set_pixel_sizes FPDFAPI_ft_stub_set_pixel_sizes
-#define FT_Get_SubGlyph_Info FPDFAPI_FT_Get_SubGlyph_Info
-#define FT_Get_Sfnt_Name_Count FPDFAPI_FT_Get_Sfnt_Name_Count
-#define FT_Get_Sfnt_Name FPDFAPI_FT_Get_Sfnt_Name
-#define FT_Bitmap_New FPDFAPI_FT_Bitmap_New
-#define FT_Bitmap_Copy FPDFAPI_FT_Bitmap_Copy
-#define FT_Bitmap_Done FPDFAPI_FT_Bitmap_Done
-#define FT_Bitmap_Convert FPDFAPI_FT_Bitmap_Convert
-#define FT_Bitmap_Embolden FPDFAPI_FT_Bitmap_Embolden
-#define ft_bitmap_glyph_class FPDFAPI_ft_bitmap_glyph_class
-#define ft_outline_glyph_class FPDFAPI_ft_outline_glyph_class
-#define FT_Matrix_Multiply FPDFAPI_FT_Matrix_Multiply
-#define FT_Matrix_Invert FPDFAPI_FT_Matrix_Invert
-#define FT_Done_Glyph FPDFAPI_FT_Done_Glyph
-#define FT_Glyph_Copy FPDFAPI_FT_Glyph_Copy
-#define FT_Get_Glyph FPDFAPI_FT_Get_Glyph
-#define FT_Glyph_Transform FPDFAPI_FT_Glyph_Transform
-#define FT_Glyph_Get_CBox FPDFAPI_FT_Glyph_Get_CBox
-#define FT_Glyph_To_Bitmap FPDFAPI_FT_Glyph_To_Bitmap
-#define FT_Add_Default_Modules FPDFAPI_FT_Add_Default_Modules
-#define FT_Get_Multi_Master FPDFAPI_FT_Get_Multi_Master
-#define FT_Get_MM_Var FPDFAPI_FT_Get_MM_Var
-#define FT_Set_MM_Design_Coordinates FPDFAPI_FT_Set_MM_Design_Coordinates
-#define FT_Set_Var_Design_Coordinates FPDFAPI_FT_Set_Var_Design_Coordinates
-#define FT_Set_MM_Blend_Coordinates FPDFAPI_FT_Set_MM_Blend_Coordinates
-#define FT_Set_Var_Blend_Coordinates FPDFAPI_FT_Set_Var_Blend_Coordinates
-#define ps_table_funcs FPDFAPI_ps_table_funcs
-#define ps_parser_funcs FPDFAPI_ps_parser_funcs
-#define t1_builder_funcs FPDFAPI_t1_builder_funcs
-#define t1_decoder_funcs FPDFAPI_t1_decoder_funcs
-#define afm_parser_funcs FPDFAPI_afm_parser_funcs
-#define t1_cmap_classes FPDFAPI_t1_cmap_classes
-#define t1_cmap_standard_class_rec FPDFAPI_t1_cmap_standard_class_rec
-#define t1_cmap_expert_class_rec FPDFAPI_t1_cmap_expert_class_rec
-#define t1_cmap_custom_class_rec FPDFAPI_t1_cmap_custom_class_rec
-#define t1_cmap_unicode_class_rec FPDFAPI_t1_cmap_unicode_class_rec
-#define psaux_module_class FPDFAPI_psaux_module_class
-#define pshinter_module_class FPDFAPI_pshinter_module_class
-#define ps_hints_apply FPDFAPI_ps_hints_apply
-#define psnames_module_class FPDFAPI_psnames_module_class
-#define ft_raster1_renderer_class FPDFAPI_ft_raster1_renderer_class
-#define ft_standard_raster FPDFAPI_ft_standard_raster
-#define ft_raster5_renderer_class FPDFAPI_ft_raster5_renderer_class
-#define tt_cmap0_class_rec FPDFAPI_tt_cmap0_class_rec
-#define tt_cmap2_class_rec FPDFAPI_tt_cmap2_class_rec
-#define tt_cmap4_class_rec FPDFAPI_tt_cmap4_class_rec
-#define tt_cmap6_class_rec FPDFAPI_tt_cmap6_class_rec
-#define tt_cmap8_class_rec FPDFAPI_tt_cmap8_class_rec
-#define tt_cmap10_class_rec FPDFAPI_tt_cmap10_class_rec
-#define tt_cmap12_class_rec FPDFAPI_tt_cmap12_class_rec
-#define tt_cmap13_class_rec FPDFAPI_tt_cmap13_class_rec
-#define tt_cmap14_class_rec FPDFAPI_tt_cmap14_class_rec
-#define sfnt_module_class FPDFAPI_sfnt_module_class
-#define ft_grays_raster FPDFAPI_ft_grays_raster
-#define ft_smooth_renderer_class FPDFAPI_ft_smooth_renderer_class
-#define ft_smooth_lcd_renderer_class FPDFAPI_ft_smooth_lcd_renderer_class
-#define ft_smooth_lcdv_renderer_class FPDFAPI_ft_smooth_lcdv_renderer_class
-#define tt_default_graphics_state FPDFAPI_tt_default_graphics_state
-#define tt_driver_class FPDFAPI_tt_driver_class
-#define TT_RunIns FPDFAPI_TT_RunIns
-#define TT_New_Context FPDFAPI_TT_New_Context
-#define t1_driver_class FPDFAPI_t1_driver_class
-#define t1cid_driver_class FPDFAPI_t1cid_driver_class
-#define FT_Get_Track_Kerning FPDFAPI_FT_Get_Track_Kerning
-#define FT_Match_Size FPDFAPI_FT_Match_Size
-#define FT_MulDiv_No_Round FPDFAPI_FT_MulDiv_No_Round
-#define FT_Request_Metrics FPDFAPI_FT_Request_Metrics
-#define FT_Request_Size FPDFAPI_FT_Request_Size
-#define FT_Select_Metrics FPDFAPI_FT_Select_Metrics
-#define FT_Select_Size FPDFAPI_FT_Select_Size
-#define ft_synthesize_vertical_metrics FPDFAPI_ft_synthesize_vertical_metrics
-#define New_Profile FPDFAPI_New_Profile
-#define End_Profile FPDFAPI_End_Profile
-#define Insert_Y_Turn FPDFAPI_Insert_Y_Turn
-#define Split_Conic FPDFAPI_Split_Conic
-#define Split_Cubic FPDFAPI_Split_Cubic
-#define Line_Up FPDFAPI_Line_Up
-#define Bezier_Up FPDFAPI_Bezier_Up
-#define Bezier_Down FPDFAPI_Bezier_Down
-#define Line_To FPDFAPI_Line_To
-#define Conic_To FPDFAPI_Conic_To
-#define Cubic_To FPDFAPI_Cubic_To
-#define Decompose_Curve FPDFAPI_Decompose_Curve
-#define Convert_Glyph FPDFAPI_Convert_Glyph
-#define Sort FPDFAPI_Sort
-#define Vertical_Sweep_Init FPDFAPI_Vertical_Sweep_Init
-#define Vertical_Sweep_Span FPDFAPI_Vertical_Sweep_Span
-#define Vertical_Sweep_Drop FPDFAPI_Vertical_Sweep_Drop
-#define Vertical_Sweep_Step FPDFAPI_Vertical_Sweep_Step
-#define Horizontal_Sweep_Init FPDFAPI_Horizontal_Sweep_Init
-#define Horizontal_Sweep_Span FPDFAPI_Horizontal_Sweep_Span
-#define Horizontal_Sweep_Drop FPDFAPI_Horizontal_Sweep_Drop
-#define Horizontal_Sweep_Step FPDFAPI_Horizontal_Sweep_Step
-#define Draw_Sweep FPDFAPI_Draw_Sweep
-#define Render_Single_Pass FPDFAPI_Render_Single_Pass
-#define Render_Glyph FPDFAPI_Render_Glyph
-#define Finalize_Profile_Table FPDFAPI_Finalize_Profile_Table
-#define InsNew FPDFAPI_InsNew
-#define DelOld FPDFAPI_DelOld
-#define FT_MulFix FPDFAPI_FT_MulFix
-#define FT_Matrix_Multiply_Scaled FPDFAPI_FT_Matrix_Multiply_Scaled
-#define FT_Vector_Transform_Scaled FPDFAPI_FT_Vector_Transform_Scaled
-#define ft_corner_orientation FPDFAPI_ft_corner_orientation
-#define ft_corner_is_flat FPDFAPI_ft_corner_is_flat
-#define FT_Get_CMap_Format FPDFAPI_FT_Get_CMap_Format
-#define ft_mem_strcpyn FPDFAPI_ft_mem_strcpyn
-#define ft_mem_dup FPDFAPI_ft_mem_dup
-#define ft_mem_strdup FPDFAPI_ft_mem_strdup
-#define FT_Face_GetCharVariantIsDefault FPDFAPI_FT_Face_GetCharVariantIsDefault
-#define FT_Face_GetCharsOfVariant FPDFAPI_FT_Face_GetCharsOfVariant
-#define FT_Face_GetVariantsOfChar FPDFAPI_FT_Face_GetVariantsOfChar
-#define FT_Face_GetVariantSelectors FPDFAPI_FT_Face_GetVariantSelectors
-#define FT_Face_GetCharVariantIndex FPDFAPI_FT_Face_GetCharVariantIndex
-#define FT_Get_Advances FPDFAPI_FT_Get_Advances
-#define FT_Get_Advance FPDFAPI_FT_Get_Advance
-#define FT_Library_SetLcdFilter FPDFAPI_FT_Library_SetLcdFilter
-
-#endif // !_FX_FREETYPE_DONT_RENAME_
+#ifndef _FX_FREETYPE_DONT_RENAME_
+// To avoid any possible linking confliction, we rename all FreeType exported names
+
+#define FT_Init_FreeType FPDFAPI_FT_Init_FreeType
+#define FT_Done_FreeType FPDFAPI_FT_Done_FreeType
+#define FT_New_Face FPDFAPI_FT_New_Face
+#define FT_Select_Charmap FPDFAPI_FT_Select_Charmap
+#define FT_Done_Face FPDFAPI_FT_Done_Face
+#define FT_Get_Charmap_Index FPDFAPI_FT_Get_Charmap_Index
+#define FT_New_Memory_Face FPDFAPI_FT_New_Memory_Face
+#define FT_MulDiv FPDFAPI_FT_MulDiv
+#define FT_Vector_Transform FPDFAPI_FT_Vector_Transform
+#define FT_Cos FPDFAPI_FT_Cos
+#define FT_Sin FPDFAPI_FT_Sin
+#define FT_Load_Glyph FPDFAPI_FT_Load_Glyph
+#define FT_DivFix FPDFAPI_FT_DivFix
+#define FT_Realloc FPDFAPI_FT_Realloc
+#define FT_Alloc FPDFAPI_FT_Alloc
+#define FT_Get_Char_Index FPDFAPI_FT_Get_Char_Index
+#define FT_GlyphLoader_CheckPoints FPDFAPI_FT_GlyphLoader_CheckPoints
+#define FT_GlyphLoader_Add FPDFAPI_FT_GlyphLoader_Add
+#define FT_GlyphLoader_CheckSubGlyphs FPDFAPI_FT_GlyphLoader_CheckSubGlyphs
+#define FT_Outline_Translate FPDFAPI_FT_Outline_Translate
+#define FT_Outline_Transform FPDFAPI_FT_Outline_Transform
+#define FT_Outline_Get_CBox FPDFAPI_FT_Outline_Get_CBox
+#define FT_GlyphLoader_Rewind FPDFAPI_FT_GlyphLoader_Rewind
+#define FT_GlyphLoader_CopyPoints FPDFAPI_FT_GlyphLoader_CopyPoints
+#define FT_GlyphLoader_New FPDFAPI_FT_GlyphLoader_New
+#define FT_GlyphLoader_CreateExtra FPDFAPI_FT_GlyphLoader_CreateExtra
+#define FT_Free FPDFAPI_FT_Free
+#define FT_Set_Charmap FPDFAPI_FT_Set_Charmap
+#define FT_GlyphLoader_Done FPDFAPI_FT_GlyphLoader_Done
+#define _debug_mem_dummy FPDFAPI__debug_mem_dummy
+#define _debug_mem_dummy FPDFAPI__debug_mem_dummy
+#define FT_QAlloc FPDFAPI_FT_QAlloc
+#define FT_QRealloc FPDFAPI_FT_QRealloc
+#define FT_List_Find FPDFAPI_FT_List_Find
+#define FT_List_Add FPDFAPI_FT_List_Add
+#define FT_List_Insert FPDFAPI_FT_List_Insert
+#define FT_List_Remove FPDFAPI_FT_List_Remove
+#define FT_List_Up FPDFAPI_FT_List_Up
+#define FT_List_Iterate FPDFAPI_FT_List_Iterate
+#define FT_List_Finalize FPDFAPI_FT_List_Finalize
+#define ft_highpow2 FPDFAPI_ft_highpow2
+#define FT_Stream_OpenMemory FPDFAPI_FT_Stream_OpenMemory
+#define FT_Stream_Close FPDFAPI_FT_Stream_Close
+#define FT_Stream_Seek FPDFAPI_FT_Stream_Seek
+#define FT_Stream_Skip FPDFAPI_FT_Stream_Skip
+#define FT_Stream_Pos FPDFAPI_FT_Stream_Pos
+#define FT_Stream_ReadAt FPDFAPI_FT_Stream_ReadAt
+#define FT_Stream_Read FPDFAPI_FT_Stream_Read
+#define FT_Stream_TryRead FPDFAPI_FT_Stream_TryRead
+#define FT_Stream_EnterFrame FPDFAPI_FT_Stream_EnterFrame
+#define FT_Stream_ExtractFrame FPDFAPI_FT_Stream_ExtractFrame
+#define FT_Stream_ReleaseFrame FPDFAPI_FT_Stream_ReleaseFrame
+#define FT_Stream_ExitFrame FPDFAPI_FT_Stream_ExitFrame
+#define FT_Stream_GetChar FPDFAPI_FT_Stream_GetChar
+#define FT_Stream_GetShort FPDFAPI_FT_Stream_GetShort
+#define FT_Stream_GetShortLE FPDFAPI_FT_Stream_GetShortLE
+#define FT_Stream_GetOffset FPDFAPI_FT_Stream_GetOffset
+#define FT_Stream_GetLong FPDFAPI_FT_Stream_GetLong
+#define FT_Stream_GetLongLE FPDFAPI_FT_Stream_GetLongLE
+#define FT_Stream_ReadChar FPDFAPI_FT_Stream_ReadChar
+#define FT_Stream_ReadShort FPDFAPI_FT_Stream_ReadShort
+#define FT_Stream_ReadShortLE FPDFAPI_FT_Stream_ReadShortLE
+#define FT_Stream_ReadOffset FPDFAPI_FT_Stream_ReadOffset
+#define FT_Stream_ReadLong FPDFAPI_FT_Stream_ReadLong
+#define FT_Stream_ReadLongLE FPDFAPI_FT_Stream_ReadLongLE
+#define FT_Stream_ReadFields FPDFAPI_FT_Stream_ReadFields
+#define FT_RoundFix FPDFAPI_FT_RoundFix
+#define FT_CeilFix FPDFAPI_FT_CeilFix
+#define FT_FloorFix FPDFAPI_FT_FloorFix
+#define FT_Sqrt32 FPDFAPI_FT_Sqrt32
+#define FT_SqrtFixed FPDFAPI_FT_SqrtFixed
+#define FT_Tan FPDFAPI_FT_Tan
+#define FT_Atan2 FPDFAPI_FT_Atan2
+#define FT_Vector_Unit FPDFAPI_FT_Vector_Unit
+#define FT_Vector_Rotate FPDFAPI_FT_Vector_Rotate
+#define FT_Vector_Length FPDFAPI_FT_Vector_Length
+#define FT_Vector_Polarize FPDFAPI_FT_Vector_Polarize
+#define FT_Vector_From_Polar FPDFAPI_FT_Vector_From_Polar
+#define FT_Angle_Diff FPDFAPI_FT_Angle_Diff
+#define FT_Outline_Decompose FPDFAPI_FT_Outline_Decompose
+#define FT_Outline_Done_Internal FPDFAPI_FT_Outline_Done_Internal
+#define FT_Outline_New_Internal FPDFAPI_FT_Outline_New_Internal
+#define FT_Outline_New FPDFAPI_FT_Outline_New
+#define FT_Outline_Check FPDFAPI_FT_Outline_Check
+#define FT_Outline_Copy FPDFAPI_FT_Outline_Copy
+#define FT_Outline_Done FPDFAPI_FT_Outline_Done
+#define FT_Outline_Reverse FPDFAPI_FT_Outline_Reverse
+#define FT_Set_Renderer FPDFAPI_FT_Set_Renderer
+#define FT_Lookup_Renderer FPDFAPI_FT_Lookup_Renderer
+#define FT_Outline_Render FPDFAPI_FT_Outline_Render
+#define FT_Outline_Get_Bitmap FPDFAPI_FT_Outline_Get_Bitmap
+#define FT_Outline_Get_Orientation FPDFAPI_FT_Outline_Get_Orientation
+#define FT_Outline_Embolden FPDFAPI_FT_Outline_Embolden
+#define FT_GlyphLoader_Reset FPDFAPI_FT_GlyphLoader_Reset
+#define FT_GlyphLoader_Prepare FPDFAPI_FT_GlyphLoader_Prepare
+#define ft_service_list_lookup FPDFAPI_ft_service_list_lookup
+#define ft_validator_init FPDFAPI_ft_validator_init
+#define ft_validator_run FPDFAPI_ft_validator_run
+#define ft_validator_error FPDFAPI_ft_validator_error
+#define FT_Stream_New FPDFAPI_FT_Stream_New
+#define FT_Stream_Free FPDFAPI_FT_Stream_Free
+#define ft_glyphslot_free_bitmap FPDFAPI_ft_glyphslot_free_bitmap
+#define ft_glyphslot_set_bitmap FPDFAPI_ft_glyphslot_set_bitmap
+#define FT_GlyphSlot_Own_Bitmap FPDFAPI_FT_GlyphSlot_Own_Bitmap
+#define ft_glyphslot_alloc_bitmap FPDFAPI_ft_glyphslot_alloc_bitmap
+#define FT_New_GlyphSlot FPDFAPI_FT_New_GlyphSlot
+#define FT_Done_GlyphSlot FPDFAPI_FT_Done_GlyphSlot
+#define FT_Set_Transform FPDFAPI_FT_Set_Transform
+#define FT_Render_Glyph_Internal FPDFAPI_FT_Render_Glyph_Internal
+#define FT_Render_Glyph FPDFAPI_FT_Render_Glyph
+#define FT_Load_Char FPDFAPI_FT_Load_Char
+#define FT_New_Size FPDFAPI_FT_New_Size
+#define FT_Open_Face FPDFAPI_FT_Open_Face
+#define FT_Attach_Stream FPDFAPI_FT_Attach_Stream
+#define FT_Attach_File FPDFAPI_FT_Attach_File
+#define FT_Done_Size FPDFAPI_FT_Done_Size
+#define FT_Set_Char_Size FPDFAPI_FT_Set_Char_Size
+#define FT_Set_Pixel_Sizes FPDFAPI_FT_Set_Pixel_Sizes
+#define FT_Get_Kerning FPDFAPI_FT_Get_Kerning
+#define FT_CMap_Done FPDFAPI_FT_CMap_Done
+#define FT_CMap_New FPDFAPI_FT_CMap_New
+#define FT_Get_Next_Char FPDFAPI_FT_Get_Next_Char
+#define FT_Get_First_Char FPDFAPI_FT_Get_First_Char
+#define FT_Get_Name_Index FPDFAPI_FT_Get_Name_Index
+#define FT_Get_Glyph_Name FPDFAPI_FT_Get_Glyph_Name
+#define FT_Get_Postscript_Name FPDFAPI_FT_Get_Postscript_Name
+#define FT_Get_Sfnt_Table FPDFAPI_FT_Get_Sfnt_Table
+#define FT_Load_Sfnt_Table FPDFAPI_FT_Load_Sfnt_Table
+#define FT_Sfnt_Table_Info FPDFAPI_FT_Sfnt_Table_Info
+#define FT_Get_CMap_Language_ID FPDFAPI_FT_Get_CMap_Language_ID
+#define FT_Activate_Size FPDFAPI_FT_Activate_Size
+#define FT_Get_Renderer FPDFAPI_FT_Get_Renderer
+#define FT_Remove_Module FPDFAPI_FT_Remove_Module
+#define FT_Add_Module FPDFAPI_FT_Add_Module
+#define FT_Get_Module FPDFAPI_FT_Get_Module
+#define FT_Get_Module_Interface FPDFAPI_FT_Get_Module_Interface
+#define ft_module_get_service FPDFAPI_ft_module_get_service
+#define FT_New_Library FPDFAPI_FT_New_Library
+#define FT_Library_Version FPDFAPI_FT_Library_Version
+#define FT_Done_Library FPDFAPI_FT_Done_Library
+#define FT_Set_Debug_Hook FPDFAPI_FT_Set_Debug_Hook
+#define FT_Raccess_Get_HeaderInfo FPDFAPI_FT_Raccess_Get_HeaderInfo
+#define FT_Raccess_Get_DataOffsets FPDFAPI_FT_Raccess_Get_DataOffsets
+#define FT_Raccess_Guess FPDFAPI_FT_Raccess_Guess
+#define af_dummy_script_class FPDFAPI_af_dummy_script_class
+#define af_latin_script_class FPDFAPI_af_latin_script_class
+#define af_cjk_script_class FPDFAPI_af_cjk_script_class
+#define af_autofitter_service FPDFAPI_af_autofitter_service
+#define autofit_module_class FPDFAPI_autofit_module_class
+#define cff_cmap_encoding_class_rec FPDFAPI_cff_cmap_encoding_class_rec
+#define cff_cmap_unicode_class_rec FPDFAPI_cff_cmap_unicode_class_rec
+#define cff_driver_class FPDFAPI_cff_driver_class
+#define FT_Stream_Open FPDFAPI_FT_Stream_Open
+#define FT_New_Memory FPDFAPI_FT_New_Memory
+#define FT_Done_Memory FPDFAPI_FT_Done_Memory
+#define ft_mem_qalloc FPDFAPI_ft_mem_qalloc
+#define ft_mem_alloc FPDFAPI_ft_mem_alloc
+#define ft_mem_free FPDFAPI_ft_mem_free
+#define ft_mem_qrealloc FPDFAPI_ft_mem_qrealloc
+#define ft_mem_realloc FPDFAPI_ft_mem_realloc
+#define FT_Get_TrueType_Engine_Type FPDFAPI_FT_Get_TrueType_Engine_Type
+#define ft_stub_set_char_sizes FPDFAPI_ft_stub_set_char_sizes
+#define ft_stub_set_pixel_sizes FPDFAPI_ft_stub_set_pixel_sizes
+#define FT_Get_SubGlyph_Info FPDFAPI_FT_Get_SubGlyph_Info
+#define FT_Get_Sfnt_Name_Count FPDFAPI_FT_Get_Sfnt_Name_Count
+#define FT_Get_Sfnt_Name FPDFAPI_FT_Get_Sfnt_Name
+#define FT_Bitmap_New FPDFAPI_FT_Bitmap_New
+#define FT_Bitmap_Copy FPDFAPI_FT_Bitmap_Copy
+#define FT_Bitmap_Done FPDFAPI_FT_Bitmap_Done
+#define FT_Bitmap_Convert FPDFAPI_FT_Bitmap_Convert
+#define FT_Bitmap_Embolden FPDFAPI_FT_Bitmap_Embolden
+#define ft_bitmap_glyph_class FPDFAPI_ft_bitmap_glyph_class
+#define ft_outline_glyph_class FPDFAPI_ft_outline_glyph_class
+#define FT_Matrix_Multiply FPDFAPI_FT_Matrix_Multiply
+#define FT_Matrix_Invert FPDFAPI_FT_Matrix_Invert
+#define FT_Done_Glyph FPDFAPI_FT_Done_Glyph
+#define FT_Glyph_Copy FPDFAPI_FT_Glyph_Copy
+#define FT_Get_Glyph FPDFAPI_FT_Get_Glyph
+#define FT_Glyph_Transform FPDFAPI_FT_Glyph_Transform
+#define FT_Glyph_Get_CBox FPDFAPI_FT_Glyph_Get_CBox
+#define FT_Glyph_To_Bitmap FPDFAPI_FT_Glyph_To_Bitmap
+#define FT_Add_Default_Modules FPDFAPI_FT_Add_Default_Modules
+#define FT_Get_Multi_Master FPDFAPI_FT_Get_Multi_Master
+#define FT_Get_MM_Var FPDFAPI_FT_Get_MM_Var
+#define FT_Set_MM_Design_Coordinates FPDFAPI_FT_Set_MM_Design_Coordinates
+#define FT_Set_Var_Design_Coordinates FPDFAPI_FT_Set_Var_Design_Coordinates
+#define FT_Set_MM_Blend_Coordinates FPDFAPI_FT_Set_MM_Blend_Coordinates
+#define FT_Set_Var_Blend_Coordinates FPDFAPI_FT_Set_Var_Blend_Coordinates
+#define ps_table_funcs FPDFAPI_ps_table_funcs
+#define ps_parser_funcs FPDFAPI_ps_parser_funcs
+#define t1_builder_funcs FPDFAPI_t1_builder_funcs
+#define t1_decoder_funcs FPDFAPI_t1_decoder_funcs
+#define afm_parser_funcs FPDFAPI_afm_parser_funcs
+#define t1_cmap_classes FPDFAPI_t1_cmap_classes
+#define t1_cmap_standard_class_rec FPDFAPI_t1_cmap_standard_class_rec
+#define t1_cmap_expert_class_rec FPDFAPI_t1_cmap_expert_class_rec
+#define t1_cmap_custom_class_rec FPDFAPI_t1_cmap_custom_class_rec
+#define t1_cmap_unicode_class_rec FPDFAPI_t1_cmap_unicode_class_rec
+#define psaux_module_class FPDFAPI_psaux_module_class
+#define pshinter_module_class FPDFAPI_pshinter_module_class
+#define ps_hints_apply FPDFAPI_ps_hints_apply
+#define psnames_module_class FPDFAPI_psnames_module_class
+#define ft_raster1_renderer_class FPDFAPI_ft_raster1_renderer_class
+#define ft_standard_raster FPDFAPI_ft_standard_raster
+#define ft_raster5_renderer_class FPDFAPI_ft_raster5_renderer_class
+#define tt_cmap0_class_rec FPDFAPI_tt_cmap0_class_rec
+#define tt_cmap2_class_rec FPDFAPI_tt_cmap2_class_rec
+#define tt_cmap4_class_rec FPDFAPI_tt_cmap4_class_rec
+#define tt_cmap6_class_rec FPDFAPI_tt_cmap6_class_rec
+#define tt_cmap8_class_rec FPDFAPI_tt_cmap8_class_rec
+#define tt_cmap10_class_rec FPDFAPI_tt_cmap10_class_rec
+#define tt_cmap12_class_rec FPDFAPI_tt_cmap12_class_rec
+#define tt_cmap13_class_rec FPDFAPI_tt_cmap13_class_rec
+#define tt_cmap14_class_rec FPDFAPI_tt_cmap14_class_rec
+#define sfnt_module_class FPDFAPI_sfnt_module_class
+#define ft_grays_raster FPDFAPI_ft_grays_raster
+#define ft_smooth_renderer_class FPDFAPI_ft_smooth_renderer_class
+#define ft_smooth_lcd_renderer_class FPDFAPI_ft_smooth_lcd_renderer_class
+#define ft_smooth_lcdv_renderer_class FPDFAPI_ft_smooth_lcdv_renderer_class
+#define tt_default_graphics_state FPDFAPI_tt_default_graphics_state
+#define tt_driver_class FPDFAPI_tt_driver_class
+#define TT_RunIns FPDFAPI_TT_RunIns
+#define TT_New_Context FPDFAPI_TT_New_Context
+#define t1_driver_class FPDFAPI_t1_driver_class
+#define t1cid_driver_class FPDFAPI_t1cid_driver_class
+#define FT_Get_Track_Kerning FPDFAPI_FT_Get_Track_Kerning
+#define FT_Match_Size FPDFAPI_FT_Match_Size
+#define FT_MulDiv_No_Round FPDFAPI_FT_MulDiv_No_Round
+#define FT_Request_Metrics FPDFAPI_FT_Request_Metrics
+#define FT_Request_Size FPDFAPI_FT_Request_Size
+#define FT_Select_Metrics FPDFAPI_FT_Select_Metrics
+#define FT_Select_Size FPDFAPI_FT_Select_Size
+#define ft_synthesize_vertical_metrics FPDFAPI_ft_synthesize_vertical_metrics
+#define New_Profile FPDFAPI_New_Profile
+#define End_Profile FPDFAPI_End_Profile
+#define Insert_Y_Turn FPDFAPI_Insert_Y_Turn
+#define Split_Conic FPDFAPI_Split_Conic
+#define Split_Cubic FPDFAPI_Split_Cubic
+#define Line_Up FPDFAPI_Line_Up
+#define Bezier_Up FPDFAPI_Bezier_Up
+#define Bezier_Down FPDFAPI_Bezier_Down
+#define Line_To FPDFAPI_Line_To
+#define Conic_To FPDFAPI_Conic_To
+#define Cubic_To FPDFAPI_Cubic_To
+#define Decompose_Curve FPDFAPI_Decompose_Curve
+#define Convert_Glyph FPDFAPI_Convert_Glyph
+#define Sort FPDFAPI_Sort
+#define Vertical_Sweep_Init FPDFAPI_Vertical_Sweep_Init
+#define Vertical_Sweep_Span FPDFAPI_Vertical_Sweep_Span
+#define Vertical_Sweep_Drop FPDFAPI_Vertical_Sweep_Drop
+#define Vertical_Sweep_Step FPDFAPI_Vertical_Sweep_Step
+#define Horizontal_Sweep_Init FPDFAPI_Horizontal_Sweep_Init
+#define Horizontal_Sweep_Span FPDFAPI_Horizontal_Sweep_Span
+#define Horizontal_Sweep_Drop FPDFAPI_Horizontal_Sweep_Drop
+#define Horizontal_Sweep_Step FPDFAPI_Horizontal_Sweep_Step
+#define Draw_Sweep FPDFAPI_Draw_Sweep
+#define Render_Single_Pass FPDFAPI_Render_Single_Pass
+#define Render_Glyph FPDFAPI_Render_Glyph
+#define Finalize_Profile_Table FPDFAPI_Finalize_Profile_Table
+#define InsNew FPDFAPI_InsNew
+#define DelOld FPDFAPI_DelOld
+#define FT_MulFix FPDFAPI_FT_MulFix
+#define FT_Matrix_Multiply_Scaled FPDFAPI_FT_Matrix_Multiply_Scaled
+#define FT_Vector_Transform_Scaled FPDFAPI_FT_Vector_Transform_Scaled
+#define ft_corner_orientation FPDFAPI_ft_corner_orientation
+#define ft_corner_is_flat FPDFAPI_ft_corner_is_flat
+#define FT_Get_CMap_Format FPDFAPI_FT_Get_CMap_Format
+#define ft_mem_strcpyn FPDFAPI_ft_mem_strcpyn
+#define ft_mem_dup FPDFAPI_ft_mem_dup
+#define ft_mem_strdup FPDFAPI_ft_mem_strdup
+#define FT_Face_GetCharVariantIsDefault FPDFAPI_FT_Face_GetCharVariantIsDefault
+#define FT_Face_GetCharsOfVariant FPDFAPI_FT_Face_GetCharsOfVariant
+#define FT_Face_GetVariantsOfChar FPDFAPI_FT_Face_GetVariantsOfChar
+#define FT_Face_GetVariantSelectors FPDFAPI_FT_Face_GetVariantSelectors
+#define FT_Face_GetCharVariantIndex FPDFAPI_FT_Face_GetCharVariantIndex
+#define FT_Get_Advances FPDFAPI_FT_Get_Advances
+#define FT_Get_Advance FPDFAPI_FT_Get_Advance
+#define FT_Library_SetLcdFilter FPDFAPI_FT_Library_SetLcdFilter
+
+#endif // !_FX_FREETYPE_DONT_RENAME_
diff --git a/core/include/thirdparties/freetype/freetype/config/ftconfig.h b/core/include/thirdparties/freetype/freetype/config/ftconfig.h
index e4eb4dcba2..b971d146ed 100644
--- a/core/include/thirdparties/freetype/freetype/config/ftconfig.h
+++ b/core/include/thirdparties/freetype/freetype/config/ftconfig.h
@@ -337,7 +337,7 @@ FT_BEGIN_HEADER
/* Provide assembler fragments for performance-critical functions. */
/* These must be defined `static __inline__' with GCC. */
- /**Johnson add !defined( __thumb__ )*/
+ /**Johnson add !defined( __thumb__ )*/
#if (defined( __CC_ARM ) || defined( __ARMCC__ ))&& !defined( __thumb__ ) /* RVCT */
#define FT_MULFIX_ASSEMBLER FT_MulFix_arm
diff --git a/core/include/thirdparties/freetype/freetype/freetype.h b/core/include/thirdparties/freetype/freetype/freetype.h
index 7a31923dd3..b6c77153a9 100644
--- a/core/include/thirdparties/freetype/freetype/freetype.h
+++ b/core/include/thirdparties/freetype/freetype/freetype.h
@@ -1,4016 +1,4016 @@
-/***************************************************************************/
-/* */
-/* freetype.h */
-/* */
-/* FreeType high-level API and common types (specification only). */
-/* */
-/* Copyright 1996-2013 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef __FREETYPE_H__
-#define __FREETYPE_H__
-
-
-#ifndef FT_FREETYPE_H
-#error "`ft2build.h' hasn't been included yet!"
-#error "Please always use macros to include FreeType header files."
-#error "Example:"
-#error " #include <ft2build.h>"
-#error " #include FT_FREETYPE_H"
-#endif
-
-
-#include "../ft2build.h"
-#include "config/ftconfig.h"
-#include "fttypes.h"
-#include "fterrors.h"
-
-
-FT_BEGIN_HEADER
-
-
-
- /*************************************************************************/
- /* */
- /* <Section> */
- /* user_allocation */
- /* */
- /* <Title> */
- /* User allocation */
- /* */
- /* <Abstract> */
- /* How client applications should allocate FreeType data structures. */
- /* */
- /* <Description> */
- /* FreeType assumes that structures allocated by the user and passed */
- /* as arguments are zeroed out except for the actual data. In other */
- /* words, it is recommended to use `calloc' (or variants of it) */
- /* instead of `malloc' for allocation. */
- /* */
- /*************************************************************************/
-
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* B A S I C T Y P E S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Section> */
- /* base_interface */
- /* */
- /* <Title> */
- /* Base Interface */
- /* */
- /* <Abstract> */
- /* The FreeType~2 base font interface. */
- /* */
- /* <Description> */
- /* This section describes the public high-level API of FreeType~2. */
- /* */
- /* <Order> */
- /* FT_Library */
- /* FT_Face */
- /* FT_Size */
- /* FT_GlyphSlot */
- /* FT_CharMap */
- /* FT_Encoding */
- /* */
- /* FT_FaceRec */
- /* */
- /* FT_FACE_FLAG_SCALABLE */
- /* FT_FACE_FLAG_FIXED_SIZES */
- /* FT_FACE_FLAG_FIXED_WIDTH */
- /* FT_FACE_FLAG_HORIZONTAL */
- /* FT_FACE_FLAG_VERTICAL */
- /* FT_FACE_FLAG_SFNT */
- /* FT_FACE_FLAG_KERNING */
- /* FT_FACE_FLAG_MULTIPLE_MASTERS */
- /* FT_FACE_FLAG_GLYPH_NAMES */
- /* FT_FACE_FLAG_EXTERNAL_STREAM */
- /* FT_FACE_FLAG_FAST_GLYPHS */
- /* FT_FACE_FLAG_HINTER */
- /* */
- /* FT_STYLE_FLAG_BOLD */
- /* FT_STYLE_FLAG_ITALIC */
- /* */
- /* FT_SizeRec */
- /* FT_Size_Metrics */
- /* */
- /* FT_GlyphSlotRec */
- /* FT_Glyph_Metrics */
- /* FT_SubGlyph */
- /* */
- /* FT_Bitmap_Size */
- /* */
- /* FT_Init_FreeType */
- /* FT_Done_FreeType */
- /* */
- /* FT_New_Face */
- /* FT_Done_Face */
- /* FT_New_Memory_Face */
- /* FT_Open_Face */
- /* FT_Open_Args */
- /* FT_Parameter */
- /* FT_Attach_File */
- /* FT_Attach_Stream */
- /* */
- /* FT_Set_Char_Size */
- /* FT_Set_Pixel_Sizes */
- /* FT_Request_Size */
- /* FT_Select_Size */
- /* FT_Size_Request_Type */
- /* FT_Size_Request */
- /* FT_Set_Transform */
- /* FT_Load_Glyph */
- /* FT_Get_Char_Index */
- /* FT_Get_Name_Index */
- /* FT_Load_Char */
- /* */
- /* FT_OPEN_MEMORY */
- /* FT_OPEN_STREAM */
- /* FT_OPEN_PATHNAME */
- /* FT_OPEN_DRIVER */
- /* FT_OPEN_PARAMS */
- /* */
- /* FT_LOAD_DEFAULT */
- /* FT_LOAD_RENDER */
- /* FT_LOAD_MONOCHROME */
- /* FT_LOAD_LINEAR_DESIGN */
- /* FT_LOAD_NO_SCALE */
- /* FT_LOAD_NO_HINTING */
- /* FT_LOAD_NO_BITMAP */
- /* FT_LOAD_CROP_BITMAP */
- /* */
- /* FT_LOAD_VERTICAL_LAYOUT */
- /* FT_LOAD_IGNORE_TRANSFORM */
- /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
- /* FT_LOAD_FORCE_AUTOHINT */
- /* FT_LOAD_NO_RECURSE */
- /* FT_LOAD_PEDANTIC */
- /* */
- /* FT_LOAD_TARGET_NORMAL */
- /* FT_LOAD_TARGET_LIGHT */
- /* FT_LOAD_TARGET_MONO */
- /* FT_LOAD_TARGET_LCD */
- /* FT_LOAD_TARGET_LCD_V */
- /* */
- /* FT_Render_Glyph */
- /* FT_Render_Mode */
- /* FT_Get_Kerning */
- /* FT_Kerning_Mode */
- /* FT_Get_Track_Kerning */
- /* FT_Get_Glyph_Name */
- /* FT_Get_Postscript_Name */
- /* */
- /* FT_CharMapRec */
- /* FT_Select_Charmap */
- /* FT_Set_Charmap */
- /* FT_Get_Charmap_Index */
- /* */
- /* FT_FSTYPE_INSTALLABLE_EMBEDDING */
- /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING */
- /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING */
- /* FT_FSTYPE_EDITABLE_EMBEDDING */
- /* FT_FSTYPE_NO_SUBSETTING */
- /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY */
- /* */
- /* FT_Get_FSType_Flags */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Glyph_Metrics */
- /* */
- /* <Description> */
- /* A structure used to model the metrics of a single glyph. The */
- /* values are expressed in 26.6 fractional pixel format; if the flag */
- /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */
- /* are expressed in font units instead. */
- /* */
- /* <Fields> */
- /* width :: */
- /* The glyph's width. */
- /* */
- /* height :: */
- /* The glyph's height. */
- /* */
- /* horiBearingX :: */
- /* Left side bearing for horizontal layout. */
- /* */
- /* horiBearingY :: */
- /* Top side bearing for horizontal layout. */
- /* */
- /* horiAdvance :: */
- /* Advance width for horizontal layout. */
- /* */
- /* vertBearingX :: */
- /* Left side bearing for vertical layout. */
- /* */
- /* vertBearingY :: */
- /* Top side bearing for vertical layout. Larger positive values */
- /* mean further below the vertical glyph origin. */
- /* */
- /* vertAdvance :: */
- /* Advance height for vertical layout. Positive values mean the */
- /* glyph has a positive advance downward. */
- /* */
- /* <Note> */
- /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */
- /* dimensions of the hinted glyph (in case hinting is applicable). */
- /* */
- /* Stroking a glyph with an outside border does not increase */
- /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */
- /* values to account for the added width and height. */
- /* */
- typedef struct FT_Glyph_Metrics_
- {
- FT_Pos width;
- FT_Pos height;
-
- FT_Pos horiBearingX;
- FT_Pos horiBearingY;
- FT_Pos horiAdvance;
-
- FT_Pos vertBearingX;
- FT_Pos vertBearingY;
- FT_Pos vertAdvance;
-
- } FT_Glyph_Metrics;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Bitmap_Size */
- /* */
- /* <Description> */
- /* This structure models the metrics of a bitmap strike (i.e., a set */
- /* of glyphs for a given point size and resolution) in a bitmap font. */
- /* It is used for the `available_sizes' field of @FT_Face. */
- /* */
- /* <Fields> */
- /* height :: The vertical distance, in pixels, between two */
- /* consecutive baselines. It is always positive. */
- /* */
- /* width :: The average width, in pixels, of all glyphs in the */
- /* strike. */
- /* */
- /* size :: The nominal size of the strike in 26.6 fractional */
- /* points. This field is not very useful. */
- /* */
- /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */
- /* pixels. */
- /* */
- /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */
- /* pixels. */
- /* */
- /* <Note> */
- /* Windows FNT: */
- /* The nominal size given in a FNT font is not reliable. Thus when */
- /* the driver finds it incorrect, it sets `size' to some calculated */
- /* values and sets `x_ppem' and `y_ppem' to the pixel width and */
- /* height given in the font, respectively. */
- /* */
- /* TrueType embedded bitmaps: */
- /* `size', `width', and `height' values are not contained in the */
- /* bitmap strike itself. They are computed from the global font */
- /* parameters. */
- /* */
- typedef struct FT_Bitmap_Size_
- {
- FT_Short height;
- FT_Short width;
-
- FT_Pos size;
-
- FT_Pos x_ppem;
- FT_Pos y_ppem;
-
- } FT_Bitmap_Size;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* O B J E C T C L A S S E S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Library */
- /* */
- /* <Description> */
- /* A handle to a FreeType library instance. Each `library' is */
- /* completely independent from the others; it is the `root' of a set */
- /* of objects like fonts, faces, sizes, etc. */
- /* */
- /* It also embeds a memory manager (see @FT_Memory), as well as a */
- /* scan-line converter object (see @FT_Raster). */
- /* */
- /* In multi-threaded applications, make sure that the same FT_Library */
- /* object or any of its children doesn't get accessed in parallel. */
- /* */
- /* <Note> */
- /* Library objects are normally created by @FT_Init_FreeType, and */
- /* destroyed with @FT_Done_FreeType. If you need reference-counting */
- /* (cf. @FT_Reference_Library), use @FT_New_Library and */
- /* @FT_Done_Library. */
- /* */
- typedef struct FT_LibraryRec_ *FT_Library;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Module */
- /* */
- /* <Description> */
- /* A handle to a given FreeType module object. Each module can be a */
- /* font driver, a renderer, or anything else that provides services */
- /* to the formers. */
- /* */
- typedef struct FT_ModuleRec_* FT_Module;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Driver */
- /* */
- /* <Description> */
- /* A handle to a given FreeType font driver object. Each font driver */
- /* is a special module capable of creating faces from font files. */
- /* */
- typedef struct FT_DriverRec_* FT_Driver;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Renderer */
- /* */
- /* <Description> */
- /* A handle to a given FreeType renderer. A renderer is a special */
- /* module in charge of converting a glyph image to a bitmap, when */
- /* necessary. Each renderer supports a given glyph image format, and */
- /* one or more target surface depths. */
- /* */
- typedef struct FT_RendererRec_* FT_Renderer;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Face */
- /* */
- /* <Description> */
- /* A handle to a given typographic face object. A face object models */
- /* a given typeface, in a given style. */
- /* */
- /* <Note> */
- /* Each face object also owns a single @FT_GlyphSlot object, as well */
- /* as one or more @FT_Size objects. */
- /* */
- /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */
- /* a given filepathname or a custom input stream. */
- /* */
- /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
- /* */
- /* <Also> */
- /* See @FT_FaceRec for the publicly accessible fields of a given face */
- /* object. */
- /* */
- typedef struct FT_FaceRec_* FT_Face;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Size */
- /* */
- /* <Description> */
- /* A handle to an object used to model a face scaled to a given */
- /* character size. */
- /* */
- /* <Note> */
- /* Each @FT_Face has an _active_ @FT_Size object that is used by */
- /* functions like @FT_Load_Glyph to determine the scaling */
- /* transformation which is used to load and hint glyphs and metrics. */
- /* */
- /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */
- /* @FT_Request_Size or even @FT_Select_Size to change the content */
- /* (i.e., the scaling values) of the active @FT_Size. */
- /* */
- /* You can use @FT_New_Size to create additional size objects for a */
- /* given @FT_Face, but they won't be used by other functions until */
- /* you activate it through @FT_Activate_Size. Only one size can be */
- /* activated at any given time per face. */
- /* */
- /* <Also> */
- /* See @FT_SizeRec for the publicly accessible fields of a given size */
- /* object. */
- /* */
- typedef struct FT_SizeRec_* FT_Size;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_GlyphSlot */
- /* */
- /* <Description> */
- /* A handle to a given `glyph slot'. A slot is a container where it */
- /* is possible to load any of the glyphs contained in its parent */
- /* face. */
- /* */
- /* In other words, each time you call @FT_Load_Glyph or */
- /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
- /* i.e., the glyph's metrics, its image (bitmap or outline), and */
- /* other control information. */
- /* */
- /* <Also> */
- /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */
- /* */
- typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_CharMap */
- /* */
- /* <Description> */
- /* A handle to a given character map. A charmap is used to translate */
- /* character codes in a given encoding into glyph indexes for its */
- /* parent's face. Some font formats may provide several charmaps per */
- /* font. */
- /* */
- /* Each face object owns zero or more charmaps, but only one of them */
- /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */
- /* */
- /* The list of available charmaps in a face is available through the */
- /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */
- /* */
- /* The currently active charmap is available as `face->charmap'. */
- /* You should call @FT_Set_Charmap to change it. */
- /* */
- /* <Note> */
- /* When a new face is created (either through @FT_New_Face or */
- /* @FT_Open_Face), the library looks for a Unicode charmap within */
- /* the list and automatically activates it. */
- /* */
- /* <Also> */
- /* See @FT_CharMapRec for the publicly accessible fields of a given */
- /* character map. */
- /* */
- typedef struct FT_CharMapRec_* FT_CharMap;
-
-
- /*************************************************************************/
- /* */
- /* <Macro> */
- /* FT_ENC_TAG */
- /* */
- /* <Description> */
- /* This macro converts four-letter tags into an unsigned long. It is */
- /* used to define `encoding' identifiers (see @FT_Encoding). */
- /* */
- /* <Note> */
- /* Since many 16-bit compilers don't like 32-bit enumerations, you */
- /* should redefine this macro in case of problems to something like */
- /* this: */
- /* */
- /* { */
- /* #define FT_ENC_TAG( value, a, b, c, d ) value */
- /* } */
- /* */
- /* to get a simple enumeration without assigning special numbers. */
- /* */
-
-#ifndef FT_ENC_TAG
-#define FT_ENC_TAG( value, a, b, c, d ) \
- value = ( ( (FT_UInt32)(a) << 24 ) | \
- ( (FT_UInt32)(b) << 16 ) | \
- ( (FT_UInt32)(c) << 8 ) | \
- (FT_UInt32)(d) )
-
-#endif /* FT_ENC_TAG */
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* FT_Encoding */
- /* */
- /* <Description> */
- /* An enumeration used to specify character sets supported by */
- /* charmaps. Used in the @FT_Select_Charmap API function. */
- /* */
- /* <Note> */
- /* Despite the name, this enumeration lists specific character */
- /* repertories (i.e., charsets), and not text encoding methods (e.g., */
- /* UTF-8, UTF-16, etc.). */
- /* */
- /* Other encodings might be defined in the future. */
- /* */
- /* <Values> */
- /* FT_ENCODING_NONE :: */
- /* The encoding value~0 is reserved. */
- /* */
- /* FT_ENCODING_UNICODE :: */
- /* Corresponds to the Unicode character set. This value covers */
- /* all versions of the Unicode repertoire, including ASCII and */
- /* Latin-1. Most fonts include a Unicode charmap, but not all */
- /* of them. */
- /* */
- /* For example, if you want to access Unicode value U+1F028 (and */
- /* the font contains it), use value 0x1F028 as the input value for */
- /* @FT_Get_Char_Index. */
- /* */
- /* FT_ENCODING_MS_SYMBOL :: */
- /* Corresponds to the Microsoft Symbol encoding, used to encode */
- /* mathematical symbols in the 32..255 character code range. For */
- /* more information, see `http://www.ceviz.net/symbol.htm'. */
- /* */
- /* FT_ENCODING_SJIS :: */
- /* Corresponds to Japanese SJIS encoding. More info at */
- /* at `http://langsupport.japanreference.com/encoding.shtml'. */
- /* See note on multi-byte encodings below. */
- /* */
- /* FT_ENCODING_GB2312 :: */
- /* Corresponds to an encoding system for Simplified Chinese as used */
- /* used in mainland China. */
- /* */
- /* FT_ENCODING_BIG5 :: */
- /* Corresponds to an encoding system for Traditional Chinese as */
- /* used in Taiwan and Hong Kong. */
- /* */
- /* FT_ENCODING_WANSUNG :: */
- /* Corresponds to the Korean encoding system known as Wansung. */
- /* For more information see */
- /* `http://www.microsoft.com/typography/unicode/949.txt'. */
- /* */
- /* FT_ENCODING_JOHAB :: */
- /* The Korean standard character set (KS~C 5601-1992), which */
- /* corresponds to MS Windows code page 1361. This character set */
- /* includes all possible Hangeul character combinations. */
- /* */
- /* FT_ENCODING_ADOBE_LATIN_1 :: */
- /* Corresponds to a Latin-1 encoding as defined in a Type~1 */
- /* PostScript font. It is limited to 256 character codes. */
- /* */
- /* FT_ENCODING_ADOBE_STANDARD :: */
- /* Corresponds to the Adobe Standard encoding, as found in Type~1, */
- /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
- /* codes. */
- /* */
- /* FT_ENCODING_ADOBE_EXPERT :: */
- /* Corresponds to the Adobe Expert encoding, as found in Type~1, */
- /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
- /* codes. */
- /* */
- /* FT_ENCODING_ADOBE_CUSTOM :: */
- /* Corresponds to a custom encoding, as found in Type~1, CFF, and */
- /* OpenType/CFF fonts. It is limited to 256 character codes. */
- /* */
- /* FT_ENCODING_APPLE_ROMAN :: */
- /* Corresponds to the 8-bit Apple roman encoding. Many TrueType */
- /* and OpenType fonts contain a charmap for this encoding, since */
- /* older versions of Mac OS are able to use it. */
- /* */
- /* FT_ENCODING_OLD_LATIN_2 :: */
- /* This value is deprecated and was never used nor reported by */
- /* FreeType. Don't use or test for it. */
- /* */
- /* FT_ENCODING_MS_SJIS :: */
- /* Same as FT_ENCODING_SJIS. Deprecated. */
- /* */
- /* FT_ENCODING_MS_GB2312 :: */
- /* Same as FT_ENCODING_GB2312. Deprecated. */
- /* */
- /* FT_ENCODING_MS_BIG5 :: */
- /* Same as FT_ENCODING_BIG5. Deprecated. */
- /* */
- /* FT_ENCODING_MS_WANSUNG :: */
- /* Same as FT_ENCODING_WANSUNG. Deprecated. */
- /* */
- /* FT_ENCODING_MS_JOHAB :: */
- /* Same as FT_ENCODING_JOHAB. Deprecated. */
- /* */
- /* <Note> */
- /* By default, FreeType automatically synthesizes a Unicode charmap */
- /* for PostScript fonts, using their glyph names dictionaries. */
- /* However, it also reports the encodings defined explicitly in the */
- /* font file, for the cases when they are needed, with the Adobe */
- /* values as well. */
- /* */
- /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */
- /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */
- /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */
- /* which encoding is really present. If, for example, the */
- /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */
- /* the font is encoded in KOI8-R. */
- /* */
- /* FT_ENCODING_NONE is always set (with a single exception) by the */
- /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */
- /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */
- /* which encoding is really present. For example, */
- /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */
- /* Russian). */
- /* */
- /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */
- /* and `encoding_id' is not @TT_MAC_ID_ROMAN (otherwise it is set to */
- /* FT_ENCODING_APPLE_ROMAN). */
- /* */
- /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */
- /* @FT_Get_CMap_Language_ID to query the Mac language ID which may */
- /* be needed to be able to distinguish Apple encoding variants. See */
- /* */
- /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/README.TXT */
- /* */
- /* to get an idea how to do that. Basically, if the language ID */
- /* is~0, don't use it, otherwise subtract 1 from the language ID. */
- /* Then examine `encoding_id'. If, for example, `encoding_id' is */
- /* @TT_MAC_ID_ROMAN and the language ID (minus~1) is */
- /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
- /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */
- /* variant the Arabic encoding. */
- /* */
- typedef enum FT_Encoding_
- {
- FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
-
- FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
- FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
-
- FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
- FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ),
- FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
- FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
- FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
-
- /* for backwards compatibility */
- FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
- FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312,
- FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
- FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
- FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
-
- FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
-
- FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
-
- FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
-
- } FT_Encoding;
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* ft_encoding_xxx */
- /* */
- /* <Description> */
- /* These constants are deprecated; use the corresponding @FT_Encoding */
- /* values instead. */
- /* */
-#define ft_encoding_none FT_ENCODING_NONE
-#define ft_encoding_unicode FT_ENCODING_UNICODE
-#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
-#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
-#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
-#define ft_encoding_sjis FT_ENCODING_SJIS
-#define ft_encoding_gb2312 FT_ENCODING_GB2312
-#define ft_encoding_big5 FT_ENCODING_BIG5
-#define ft_encoding_wansung FT_ENCODING_WANSUNG
-#define ft_encoding_johab FT_ENCODING_JOHAB
-
-#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
-#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
-#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
-#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_CharMapRec */
- /* */
- /* <Description> */
- /* The base charmap structure. */
- /* */
- /* <Fields> */
- /* face :: A handle to the parent face object. */
- /* */
- /* encoding :: An @FT_Encoding tag identifying the charmap. Use */
- /* this with @FT_Select_Charmap. */
- /* */
- /* platform_id :: An ID number describing the platform for the */
- /* following encoding ID. This comes directly from */
- /* the TrueType specification and should be emulated */
- /* for other formats. */
- /* */
- /* encoding_id :: A platform specific encoding number. This also */
- /* comes from the TrueType specification and should be */
- /* emulated similarly. */
- /* */
- typedef struct FT_CharMapRec_
- {
- FT_Face face;
- FT_Encoding encoding;
- FT_UShort platform_id;
- FT_UShort encoding_id;
-
- } FT_CharMapRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* B A S E O B J E C T C L A S S E S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Face_Internal */
- /* */
- /* <Description> */
- /* An opaque handle to an `FT_Face_InternalRec' structure, used to */
- /* model private data of a given @FT_Face object. */
- /* */
- /* This structure might change between releases of FreeType~2 and is */
- /* not generally available to client applications. */
- /* */
- typedef struct FT_Face_InternalRec_* FT_Face_Internal;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_FaceRec */
- /* */
- /* <Description> */
- /* FreeType root face class structure. A face object models a */
- /* typeface in a font file. */
- /* */
- /* <Fields> */
- /* num_faces :: The number of faces in the font file. Some */
- /* font formats can have multiple faces in */
- /* a font file. */
- /* */
- /* face_index :: The index of the face in the font file. It */
- /* is set to~0 if there is only one face in */
- /* the font file. */
- /* */
- /* face_flags :: A set of bit flags that give important */
- /* information about the face; see */
- /* @FT_FACE_FLAG_XXX for the details. */
- /* */
- /* style_flags :: A set of bit flags indicating the style of */
- /* the face; see @FT_STYLE_FLAG_XXX for the */
- /* details. */
- /* */
- /* num_glyphs :: The number of glyphs in the face. If the */
- /* face is scalable and has sbits (see */
- /* `num_fixed_sizes'), it is set to the number */
- /* of outline glyphs. */
- /* */
- /* For CID-keyed fonts, this value gives the */
- /* highest CID used in the font. */
- /* */
- /* family_name :: The face's family name. This is an ASCII */
- /* string, usually in English, which describes */
- /* the typeface's family (like `Times New */
- /* Roman', `Bodoni', `Garamond', etc). This */
- /* is a least common denominator used to list */
- /* fonts. Some formats (TrueType & OpenType) */
- /* provide localized and Unicode versions of */
- /* this string. Applications should use the */
- /* format specific interface to access them. */
- /* Can be NULL (e.g., in fonts embedded in a */
- /* PDF file). */
- /* */
- /* style_name :: The face's style name. This is an ASCII */
- /* string, usually in English, which describes */
- /* the typeface's style (like `Italic', */
- /* `Bold', `Condensed', etc). Not all font */
- /* formats provide a style name, so this field */
- /* is optional, and can be set to NULL. As */
- /* for `family_name', some formats provide */
- /* localized and Unicode versions of this */
- /* string. Applications should use the format */
- /* specific interface to access them. */
- /* */
- /* num_fixed_sizes :: The number of bitmap strikes in the face. */
- /* Even if the face is scalable, there might */
- /* still be bitmap strikes, which are called */
- /* `sbits' in that case. */
- /* */
- /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */
- /* strikes in the face. It is set to NULL if */
- /* there is no bitmap strike. */
- /* */
- /* num_charmaps :: The number of charmaps in the face. */
- /* */
- /* charmaps :: An array of the charmaps of the face. */
- /* */
- /* generic :: A field reserved for client uses. See the */
- /* @FT_Generic type description. */
- /* */
- /* bbox :: The font bounding box. Coordinates are */
- /* expressed in font units (see */
- /* `units_per_EM'). The box is large enough */
- /* to contain any glyph from the font. Thus, */
- /* `bbox.yMax' can be seen as the `maximum */
- /* ascender', and `bbox.yMin' as the `minimum */
- /* descender'. Only relevant for scalable */
- /* formats. */
- /* */
- /* Note that the bounding box might be off by */
- /* (at least) one pixel for hinted fonts. See */
- /* @FT_Size_Metrics for further discussion. */
- /* */
- /* units_per_EM :: The number of font units per EM square for */
- /* this face. This is typically 2048 for */
- /* TrueType fonts, and 1000 for Type~1 fonts. */
- /* Only relevant for scalable formats. */
- /* */
- /* ascender :: The typographic ascender of the face, */
- /* expressed in font units. For font formats */
- /* not having this information, it is set to */
- /* `bbox.yMax'. Only relevant for scalable */
- /* formats. */
- /* */
- /* descender :: The typographic descender of the face, */
- /* expressed in font units. For font formats */
- /* not having this information, it is set to */
- /* `bbox.yMin'. Note that this field is */
- /* usually negative. Only relevant for */
- /* scalable formats. */
- /* */
- /* height :: This value is the vertical distance */
- /* between two consecutive baselines, */
- /* expressed in font units. It is always */
- /* positive. Only relevant for scalable */
- /* formats. */
- /* */
- /* If you want the global glyph height, use */
- /* `ascender - descender'. */
- /* */
- /* max_advance_width :: The maximum advance width, in font units, */
- /* for all glyphs in this face. This can be */
- /* used to make word wrapping computations */
- /* faster. Only relevant for scalable */
- /* formats. */
- /* */
- /* max_advance_height :: The maximum advance height, in font units, */
- /* for all glyphs in this face. This is only */
- /* relevant for vertical layouts, and is set */
- /* to `height' for fonts that do not provide */
- /* vertical metrics. Only relevant for */
- /* scalable formats. */
- /* */
- /* underline_position :: The position, in font units, of the */
- /* underline line for this face. It is the */
- /* center of the underlining stem. Only */
- /* relevant for scalable formats. */
- /* */
- /* underline_thickness :: The thickness, in font units, of the */
- /* underline for this face. Only relevant for */
- /* scalable formats. */
- /* */
- /* glyph :: The face's associated glyph slot(s). */
- /* */
- /* size :: The current active size for this face. */
- /* */
- /* charmap :: The current active charmap for this face. */
- /* */
- /* <Note> */
- /* Fields may be changed after a call to @FT_Attach_File or */
- /* @FT_Attach_Stream. */
- /* */
- typedef struct FT_FaceRec_
- {
- FT_Long num_faces;
- FT_Long face_index;
-
- FT_Long face_flags;
- FT_Long style_flags;
-
- FT_Long num_glyphs;
-
- FT_String* family_name;
- FT_String* style_name;
-
- FT_Int num_fixed_sizes;
- FT_Bitmap_Size* available_sizes;
-
- FT_Int num_charmaps;
- FT_CharMap* charmaps;
-
-#ifdef _FX_MANAGED_CODE_
-#define generic generic_data
-#endif
-
- FT_Generic generic;
-
- /*# The following member variables (down to `underline_thickness') */
- /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
- /*# for bitmap fonts. */
- FT_BBox bbox;
-
- FT_UShort units_per_EM;
- FT_Short ascender;
- FT_Short descender;
- FT_Short height;
-
- FT_Short max_advance_width;
- FT_Short max_advance_height;
-
- FT_Short underline_position;
- FT_Short underline_thickness;
-
- FT_GlyphSlot glyph;
- FT_Size size;
- FT_CharMap charmap;
-
- /*@private begin */
-
- FT_Driver driver;
- FT_Memory memory;
- FT_Stream stream;
-
- FT_ListRec sizes_list;
-
- FT_Generic autohint; /* face-specific auto-hinter data */
- void* extensions; /* unused */
-
- FT_Face_Internal internal;
-
- /*@private end */
-
- } FT_FaceRec;
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* FT_FACE_FLAG_XXX */
- /* */
- /* <Description> */
- /* A list of bit flags used in the `face_flags' field of the */
- /* @FT_FaceRec structure. They inform client applications of */
- /* properties of the corresponding face. */
- /* */
- /* <Values> */
- /* FT_FACE_FLAG_SCALABLE :: */
- /* Indicates that the face contains outline glyphs. This doesn't */
- /* prevent bitmap strikes, i.e., a face can have both this and */
- /* and @FT_FACE_FLAG_FIXED_SIZES set. */
- /* */
- /* FT_FACE_FLAG_FIXED_SIZES :: */
- /* Indicates that the face contains bitmap strikes. See also the */
- /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */
- /* */
- /* FT_FACE_FLAG_FIXED_WIDTH :: */
- /* Indicates that the face contains fixed-width characters (like */
- /* Courier, Lucido, MonoType, etc.). */
- /* */
- /* FT_FACE_FLAG_SFNT :: */
- /* Indicates that the face uses the `sfnt' storage scheme. For */
- /* now, this means TrueType and OpenType. */
- /* */
- /* FT_FACE_FLAG_HORIZONTAL :: */
- /* Indicates that the face contains horizontal glyph metrics. This */
- /* should be set for all common formats. */
- /* */
- /* FT_FACE_FLAG_VERTICAL :: */
- /* Indicates that the face contains vertical glyph metrics. This */
- /* is only available in some formats, not all of them. */
- /* */
- /* FT_FACE_FLAG_KERNING :: */
- /* Indicates that the face contains kerning information. If set, */
- /* the kerning distance can be retrieved through the function */
- /* @FT_Get_Kerning. Otherwise the function always return the */
- /* vector (0,0). Note that FreeType doesn't handle kerning data */
- /* from the `GPOS' table (as present in some OpenType fonts). */
- /* */
- /* FT_FACE_FLAG_FAST_GLYPHS :: */
- /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */
- /* */
- /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */
- /* Indicates that the font contains multiple masters and is capable */
- /* of interpolating between them. See the multiple-masters */
- /* specific API for details. */
- /* */
- /* FT_FACE_FLAG_GLYPH_NAMES :: */
- /* Indicates that the font contains glyph names that can be */
- /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */
- /* fonts contain broken glyph name tables. Use the function */
- /* @FT_Has_PS_Glyph_Names when needed. */
- /* */
- /* FT_FACE_FLAG_EXTERNAL_STREAM :: */
- /* Used internally by FreeType to indicate that a face's stream was */
- /* provided by the client application and should not be destroyed */
- /* when @FT_Done_Face is called. Don't read or test this flag. */
- /* */
- /* FT_FACE_FLAG_HINTER :: */
- /* Set if the font driver has a hinting machine of its own. For */
- /* example, with TrueType fonts, it makes sense to use data from */
- /* the SFNT `gasp' table only if the native TrueType hinting engine */
- /* (with the bytecode interpreter) is available and active. */
- /* */
- /* FT_FACE_FLAG_CID_KEYED :: */
- /* Set if the font is CID-keyed. In that case, the font is not */
- /* accessed by glyph indices but by CID values. For subsetted */
- /* CID-keyed fonts this has the consequence that not all index */
- /* values are a valid argument to FT_Load_Glyph. Only the CID */
- /* values for which corresponding glyphs in the subsetted font */
- /* exist make FT_Load_Glyph return successfully; in all other cases */
- /* you get an `FT_Err_Invalid_Argument' error. */
- /* */
- /* Note that CID-keyed fonts which are in an SFNT wrapper don't */
- /* have this flag set since the glyphs are accessed in the normal */
- /* way (using contiguous indices); the `CID-ness' isn't visible to */
- /* the application. */
- /* */
- /* FT_FACE_FLAG_TRICKY :: */
- /* Set if the font is `tricky', this is, it always needs the */
- /* font format's native hinting engine to get a reasonable result. */
- /* A typical example is the Chinese font `mingli.ttf' which uses */
- /* TrueType bytecode instructions to move and scale all of its */
- /* subglyphs. */
- /* */
- /* It is not possible to autohint such fonts using */
- /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */
- /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */
- /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */
- /* probably never want this except for demonstration purposes. */
- /* */
- /* Currently, there are about a dozen TrueType fonts in the list of */
- /* tricky fonts; they are hard-coded in file `ttobjs.c'. */
- /* */
-#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
-#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
-#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
-#define FT_FACE_FLAG_SFNT ( 1L << 3 )
-#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
-#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
-#define FT_FACE_FLAG_KERNING ( 1L << 6 )
-#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
-#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
-#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
-#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
-#define FT_FACE_FLAG_HINTER ( 1L << 11 )
-#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
-#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_HAS_HORIZONTAL( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains
- * horizontal metrics (this is true for all font formats though).
- *
- * @also:
- * @FT_HAS_VERTICAL can be used to check for vertical metrics.
- *
- */
-#define FT_HAS_HORIZONTAL( face ) \
- ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_HAS_VERTICAL( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains real
- * vertical metrics (and not only synthesized ones).
- *
- */
-#define FT_HAS_VERTICAL( face ) \
- ( face->face_flags & FT_FACE_FLAG_VERTICAL )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_HAS_KERNING( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains kerning
- * data that can be accessed with @FT_Get_Kerning.
- *
- */
-#define FT_HAS_KERNING( face ) \
- ( face->face_flags & FT_FACE_FLAG_KERNING )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_IS_SCALABLE( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains a scalable
- * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF,
- * and PFR font formats.
- *
- */
-#define FT_IS_SCALABLE( face ) \
- ( face->face_flags & FT_FACE_FLAG_SCALABLE )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_IS_SFNT( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains a font
- * whose format is based on the SFNT storage scheme. This usually
- * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded
- * bitmap fonts.
- *
- * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
- * @FT_TRUETYPE_TABLES_H are available.
- *
- */
-#define FT_IS_SFNT( face ) \
- ( face->face_flags & FT_FACE_FLAG_SFNT )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_IS_FIXED_WIDTH( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains a font face
- * that contains fixed-width (or `monospace', `fixed-pitch', etc.)
- * glyphs.
- *
- */
-#define FT_IS_FIXED_WIDTH( face ) \
- ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_HAS_FIXED_SIZES( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains some
- * embedded bitmaps. See the `available_sizes' field of the
- * @FT_FaceRec structure.
- *
- */
-#define FT_HAS_FIXED_SIZES( face ) \
- ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_HAS_FAST_GLYPHS( face )
- *
- * @description:
- * Deprecated.
- *
- */
-#define FT_HAS_FAST_GLYPHS( face ) 0
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_HAS_GLYPH_NAMES( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains some glyph
- * names that can be accessed through @FT_Get_Glyph_Name.
- *
- */
-#define FT_HAS_GLYPH_NAMES( face ) \
- ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_HAS_MULTIPLE_MASTERS( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains some
- * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
- * are then available to choose the exact design you want.
- *
- */
-#define FT_HAS_MULTIPLE_MASTERS( face ) \
- ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_IS_CID_KEYED( face )
- *
- * @description:
- * A macro that returns true whenever a face object contains a CID-keyed
- * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more
- * details.
- *
- * If this macro is true, all functions defined in @FT_CID_H are
- * available.
- *
- */
-#define FT_IS_CID_KEYED( face ) \
- ( face->face_flags & FT_FACE_FLAG_CID_KEYED )
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_IS_TRICKY( face )
- *
- * @description:
- * A macro that returns true whenever a face represents a `tricky' font.
- * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
- *
- */
-#define FT_IS_TRICKY( face ) \
- ( face->face_flags & FT_FACE_FLAG_TRICKY )
-
-
- /*************************************************************************/
- /* */
- /* <Const> */
- /* FT_STYLE_FLAG_XXX */
- /* */
- /* <Description> */
- /* A list of bit-flags used to indicate the style of a given face. */
- /* These are used in the `style_flags' field of @FT_FaceRec. */
- /* */
- /* <Values> */
- /* FT_STYLE_FLAG_ITALIC :: */
- /* Indicates that a given face style is italic or oblique. */
- /* */
- /* FT_STYLE_FLAG_BOLD :: */
- /* Indicates that a given face is bold. */
- /* */
- /* <Note> */
- /* The style information as provided by FreeType is very basic. More */
- /* details are beyond the scope and should be done on a higher level */
- /* (for example, by analyzing various fields of the `OS/2' table in */
- /* SFNT based fonts). */
- /* */
-#define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
-#define FT_STYLE_FLAG_BOLD ( 1 << 1 )
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Size_Internal */
- /* */
- /* <Description> */
- /* An opaque handle to an `FT_Size_InternalRec' structure, used to */
- /* model private data of a given @FT_Size object. */
- /* */
- typedef struct FT_Size_InternalRec_* FT_Size_Internal;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Size_Metrics */
- /* */
- /* <Description> */
- /* The size metrics structure gives the metrics of a size object. */
- /* */
- /* <Fields> */
- /* x_ppem :: The width of the scaled EM square in pixels, hence */
- /* the term `ppem' (pixels per EM). It is also */
- /* referred to as `nominal width'. */
- /* */
- /* y_ppem :: The height of the scaled EM square in pixels, */
- /* hence the term `ppem' (pixels per EM). It is also */
- /* referred to as `nominal height'. */
- /* */
- /* x_scale :: A 16.16 fractional scaling value used to convert */
- /* horizontal metrics from font units to 26.6 */
- /* fractional pixels. Only relevant for scalable */
- /* font formats. */
- /* */
- /* y_scale :: A 16.16 fractional scaling value used to convert */
- /* vertical metrics from font units to 26.6 */
- /* fractional pixels. Only relevant for scalable */
- /* font formats. */
- /* */
- /* ascender :: The ascender in 26.6 fractional pixels. See */
- /* @FT_FaceRec for the details. */
- /* */
- /* descender :: The descender in 26.6 fractional pixels. See */
- /* @FT_FaceRec for the details. */
- /* */
- /* height :: The height in 26.6 fractional pixels. See */
- /* @FT_FaceRec for the details. */
- /* */
- /* max_advance :: The maximum advance width in 26.6 fractional */
- /* pixels. See @FT_FaceRec for the details. */
- /* */
- /* <Note> */
- /* The scaling values, if relevant, are determined first during a */
- /* size changing operation. The remaining fields are then set by the */
- /* driver. For scalable formats, they are usually set to scaled */
- /* values of the corresponding fields in @FT_FaceRec. */
- /* */
- /* Note that due to glyph hinting, these values might not be exact */
- /* for certain fonts. Thus they must be treated as unreliable */
- /* with an error margin of at least one pixel! */
- /* */
- /* Indeed, the only way to get the exact metrics is to render _all_ */
- /* glyphs. As this would be a definite performance hit, it is up to */
- /* client applications to perform such computations. */
- /* */
- /* The FT_Size_Metrics structure is valid for bitmap fonts also. */
- /* */
- typedef struct FT_Size_Metrics_
- {
- FT_UShort x_ppem; /* horizontal pixels per EM */
- FT_UShort y_ppem; /* vertical pixels per EM */
-
- FT_Fixed x_scale; /* scaling values used to convert font */
- FT_Fixed y_scale; /* units to 26.6 fractional pixels */
-
- FT_Pos ascender; /* ascender in 26.6 frac. pixels */
- FT_Pos descender; /* descender in 26.6 frac. pixels */
- FT_Pos height; /* text height in 26.6 frac. pixels */
- FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
-
- } FT_Size_Metrics;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_SizeRec */
- /* */
- /* <Description> */
- /* FreeType root size class structure. A size object models a face */
- /* object at a given size. */
- /* */
- /* <Fields> */
- /* face :: Handle to the parent face object. */
- /* */
- /* generic :: A typeless pointer, which is unused by the FreeType */
- /* library or any of its drivers. It can be used by */
- /* client applications to link their own data to each size */
- /* object. */
- /* */
- /* metrics :: Metrics for this size object. This field is read-only. */
- /* */
- typedef struct FT_SizeRec_
- {
- FT_Face face; /* parent face object */
- FT_Generic generic; /* generic pointer for client uses */
- FT_Size_Metrics metrics; /* size metrics */
- FT_Size_Internal internal;
-
- } FT_SizeRec;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_SubGlyph */
- /* */
- /* <Description> */
- /* The subglyph structure is an internal object used to describe */
- /* subglyphs (for example, in the case of composites). */
- /* */
- /* <Note> */
- /* The subglyph implementation is not part of the high-level API, */
- /* hence the forward structure declaration. */
- /* */
- /* You can however retrieve subglyph information with */
- /* @FT_Get_SubGlyph_Info. */
- /* */
- typedef struct FT_SubGlyphRec_* FT_SubGlyph;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Slot_Internal */
- /* */
- /* <Description> */
- /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */
- /* model private data of a given @FT_GlyphSlot object. */
- /* */
- typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_GlyphSlotRec */
- /* */
- /* <Description> */
- /* FreeType root glyph slot class structure. A glyph slot is a */
- /* container where individual glyphs can be loaded, be they in */
- /* outline or bitmap format. */
- /* */
- /* <Fields> */
- /* library :: A handle to the FreeType library instance */
- /* this slot belongs to. */
- /* */
- /* face :: A handle to the parent face object. */
- /* */
- /* next :: In some cases (like some font tools), several */
- /* glyph slots per face object can be a good */
- /* thing. As this is rare, the glyph slots are */
- /* listed through a direct, single-linked list */
- /* using its `next' field. */
- /* */
- /* generic :: A typeless pointer which is unused by the */
- /* FreeType library or any of its drivers. It */
- /* can be used by client applications to link */
- /* their own data to each glyph slot object. */
- /* */
- /* metrics :: The metrics of the last loaded glyph in the */
- /* slot. The returned values depend on the last */
- /* load flags (see the @FT_Load_Glyph API */
- /* function) and can be expressed either in 26.6 */
- /* fractional pixels or font units. */
- /* */
- /* Note that even when the glyph image is */
- /* transformed, the metrics are not. */
- /* */
- /* linearHoriAdvance :: The advance width of the unhinted glyph. */
- /* Its value is expressed in 16.16 fractional */
- /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
- /* when loading the glyph. This field can be */
- /* important to perform correct WYSIWYG layout. */
- /* Only relevant for outline glyphs. */
- /* */
- /* linearVertAdvance :: The advance height of the unhinted glyph. */
- /* Its value is expressed in 16.16 fractional */
- /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
- /* when loading the glyph. This field can be */
- /* important to perform correct WYSIWYG layout. */
- /* Only relevant for outline glyphs. */
- /* */
- /* advance :: This shorthand is, depending on */
- /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */
- /* advance width for the glyph (in 26.6 */
- /* fractional pixel format). As specified with */
- /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */
- /* `horiAdvance' or the `vertAdvance' value of */
- /* `metrics' field. */
- /* */
- /* format :: This field indicates the format of the image */
- /* contained in the glyph slot. Typically */
- /* @FT_GLYPH_FORMAT_BITMAP, */
- /* @FT_GLYPH_FORMAT_OUTLINE, or */
- /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */
- /* possible. */
- /* */
- /* bitmap :: This field is used as a bitmap descriptor */
- /* when the slot format is */
- /* @FT_GLYPH_FORMAT_BITMAP. Note that the */
- /* address and content of the bitmap buffer can */
- /* change between calls of @FT_Load_Glyph and a */
- /* few other functions. */
- /* */
- /* bitmap_left :: This is the bitmap's left bearing expressed */
- /* in integer pixels. Of course, this is only */
- /* valid if the format is */
- /* @FT_GLYPH_FORMAT_BITMAP. */
- /* */
- /* bitmap_top :: This is the bitmap's top bearing expressed in */
- /* integer pixels. Remember that this is the */
- /* distance from the baseline to the top-most */
- /* glyph scanline, upwards y~coordinates being */
- /* *positive*. */
- /* */
- /* outline :: The outline descriptor for the current glyph */
- /* image if its format is */
- /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */
- /* loaded, `outline' can be transformed, */
- /* distorted, embolded, etc. However, it must */
- /* not be freed. */
- /* */
- /* num_subglyphs :: The number of subglyphs in a composite glyph. */
- /* This field is only valid for the composite */
- /* glyph format that should normally only be */
- /* loaded with the @FT_LOAD_NO_RECURSE flag. */
- /* For now this is internal to FreeType. */
- /* */
- /* subglyphs :: An array of subglyph descriptors for */
- /* composite glyphs. There are `num_subglyphs' */
- /* elements in there. Currently internal to */
- /* FreeType. */
- /* */
- /* control_data :: Certain font drivers can also return the */
- /* control data for a given glyph image (e.g. */
- /* TrueType bytecode, Type~1 charstrings, etc.). */
- /* This field is a pointer to such data. */
- /* */
- /* control_len :: This is the length in bytes of the control */
- /* data. */
- /* */
- /* other :: Really wicked formats can use this pointer to */
- /* present their own glyph image to client */
- /* applications. Note that the application */
- /* needs to know about the image format. */
- /* */
- /* lsb_delta :: The difference between hinted and unhinted */
- /* left side bearing while autohinting is */
- /* active. Zero otherwise. */
- /* */
- /* rsb_delta :: The difference between hinted and unhinted */
- /* right side bearing while autohinting is */
- /* active. Zero otherwise. */
- /* */
- /* <Note> */
- /* If @FT_Load_Glyph is called with default flags (see */
- /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
- /* its native format (e.g., an outline glyph for TrueType and Type~1 */
- /* formats). */
- /* */
- /* This image can later be converted into a bitmap by calling */
- /* @FT_Render_Glyph. This function finds the current renderer for */
- /* the native image's format, then invokes it. */
- /* */
- /* The renderer is in charge of transforming the native image through */
- /* the slot's face transformation fields, then converting it into a */
- /* bitmap that is returned in `slot->bitmap'. */
- /* */
- /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
- /* to specify the position of the bitmap relative to the current pen */
- /* position (e.g., coordinates (0,0) on the baseline). Of course, */
- /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */
- /* */
- /* <Note> */
- /* Here a small pseudo code fragment which shows how to use */
- /* `lsb_delta' and `rsb_delta': */
- /* */
- /* { */
- /* FT_Pos origin_x = 0; */
- /* FT_Pos prev_rsb_delta = 0; */
- /* */
- /* */
- /* for all glyphs do */
- /* <compute kern between current and previous glyph and add it to */
- /* `origin_x'> */
- /* */
- /* <load glyph with `FT_Load_Glyph'> */
- /* */
- /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */
- /* origin_x -= 64; */
- /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */
- /* origin_x += 64; */
- /* */
- /* prev_rsb_delta = face->glyph->rsb_delta; */
- /* */
- /* <save glyph image, or render glyph, or ...> */
- /* */
- /* origin_x += face->glyph->advance.x; */
- /* endfor */
- /* } */
- /* */
- typedef struct FT_GlyphSlotRec_
- {
- FT_Library library;
- FT_Face face;
- FT_GlyphSlot next;
- FT_UInt reserved; /* retained for binary compatibility */
- FT_Generic generic;
-
- FT_Glyph_Metrics metrics;
- FT_Fixed linearHoriAdvance;
- FT_Fixed linearVertAdvance;
- FT_Vector advance;
-
- FT_Glyph_Format format;
-
- FT_Bitmap bitmap;
- FT_Int bitmap_left;
- FT_Int bitmap_top;
-
- FT_Outline outline;
-
- FT_UInt num_subglyphs;
- FT_SubGlyph subglyphs;
-
- void* control_data;
- long control_len;
-
- FT_Pos lsb_delta;
- FT_Pos rsb_delta;
-
- void* other;
-
- FT_Slot_Internal internal;
-
- } FT_GlyphSlotRec;
-
-
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* F U N C T I O N S */
- /* */
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Init_FreeType */
- /* */
- /* <Description> */
- /* Initialize a new FreeType library object. The set of modules */
- /* that are registered by this function is determined at build time. */
- /* */
- /* <Output> */
- /* alibrary :: A handle to a new library object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* In case you want to provide your own memory allocating routines, */
- /* use @FT_New_Library instead, followed by a call to */
- /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */
- /* */
- /* For multi-threading applications each thread should have its own */
- /* FT_Library object. */
- /* */
- /* If you need reference-counting (cf. @FT_Reference_Library), use */
- /* @FT_New_Library and @FT_Done_Library. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Init_FreeType( FT_Library *alibrary );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Done_FreeType */
- /* */
- /* <Description> */
- /* Destroy a given FreeType library object and all of its children, */
- /* including resources, drivers, faces, sizes, etc. */
- /* */
- /* <Input> */
- /* library :: A handle to the target library object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Done_FreeType( FT_Library library );
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* FT_OPEN_XXX */
- /* */
- /* <Description> */
- /* A list of bit-field constants used within the `flags' field of the */
- /* @FT_Open_Args structure. */
- /* */
- /* <Values> */
- /* FT_OPEN_MEMORY :: This is a memory-based stream. */
- /* */
- /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */
- /* */
- /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */
- /* name. */
- /* */
- /* FT_OPEN_DRIVER :: Use the `driver' field. */
- /* */
- /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */
- /* */
- /* ft_open_memory :: Deprecated; use @FT_OPEN_MEMORY instead. */
- /* */
- /* ft_open_stream :: Deprecated; use @FT_OPEN_STREAM instead. */
- /* */
- /* ft_open_pathname :: Deprecated; use @FT_OPEN_PATHNAME instead. */
- /* */
- /* ft_open_driver :: Deprecated; use @FT_OPEN_DRIVER instead. */
- /* */
- /* ft_open_params :: Deprecated; use @FT_OPEN_PARAMS instead. */
- /* */
- /* <Note> */
- /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */
- /* flags are mutually exclusive. */
- /* */
-#define FT_OPEN_MEMORY 0x1
-#define FT_OPEN_STREAM 0x2
-#define FT_OPEN_PATHNAME 0x4
-#define FT_OPEN_DRIVER 0x8
-#define FT_OPEN_PARAMS 0x10
-
-#define ft_open_memory FT_OPEN_MEMORY /* deprecated */
-#define ft_open_stream FT_OPEN_STREAM /* deprecated */
-#define ft_open_pathname FT_OPEN_PATHNAME /* deprecated */
-#define ft_open_driver FT_OPEN_DRIVER /* deprecated */
-#define ft_open_params FT_OPEN_PARAMS /* deprecated */
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Parameter */
- /* */
- /* <Description> */
- /* A simple structure used to pass more or less generic parameters to */
- /* @FT_Open_Face. */
- /* */
- /* <Fields> */
- /* tag :: A four-byte identification tag. */
- /* */
- /* data :: A pointer to the parameter data. */
- /* */
- /* <Note> */
- /* The ID and function of parameters are driver-specific. See the */
- /* various FT_PARAM_TAG_XXX flags for more information. */
- /* */
- typedef struct FT_Parameter_
- {
- FT_ULong tag;
- FT_Pointer data;
-
- } FT_Parameter;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Open_Args */
- /* */
- /* <Description> */
- /* A structure used to indicate how to open a new font file or */
- /* stream. A pointer to such a structure can be used as a parameter */
- /* for the functions @FT_Open_Face and @FT_Attach_Stream. */
- /* */
- /* <Fields> */
- /* flags :: A set of bit flags indicating how to use the */
- /* structure. */
- /* */
- /* memory_base :: The first byte of the file in memory. */
- /* */
- /* memory_size :: The size in bytes of the file in memory. */
- /* */
- /* pathname :: A pointer to an 8-bit file pathname. */
- /* */
- /* stream :: A handle to a source stream object. */
- /* */
- /* driver :: This field is exclusively used by @FT_Open_Face; */
- /* it simply specifies the font driver to use to open */
- /* the face. If set to~0, FreeType tries to load the */
- /* face with each one of the drivers in its list. */
- /* */
- /* num_params :: The number of extra parameters. */
- /* */
- /* params :: Extra parameters passed to the font driver when */
- /* opening a new face. */
- /* */
- /* <Note> */
- /* The stream type is determined by the contents of `flags' which */
- /* are tested in the following order by @FT_Open_Face: */
- /* */
- /* If the `FT_OPEN_MEMORY' bit is set, assume that this is a */
- /* memory file of `memory_size' bytes, located at `memory_address'. */
- /* The data are are not copied, and the client is responsible for */
- /* releasing and destroying them _after_ the corresponding call to */
- /* @FT_Done_Face. */
- /* */
- /* Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a */
- /* custom input stream `stream' is used. */
- /* */
- /* Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this */
- /* is a normal file and use `pathname' to open it. */
- /* */
- /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face only tries to */
- /* open the file with the driver whose handler is in `driver'. */
- /* */
- /* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */
- /* `num_params' and `params' is used. They are ignored otherwise. */
- /* */
- /* Ideally, both the `pathname' and `params' fields should be tagged */
- /* as `const'; this is missing for API backwards compatibility. In */
- /* other words, applications should treat them as read-only. */
- /* */
- typedef struct FT_Open_Args_
- {
- FT_UInt flags;
- const FT_Byte* memory_base;
- FT_Long memory_size;
- FT_String* pathname;
- FT_Stream stream;
- FT_Module driver;
- FT_Int num_params;
- FT_Parameter* params;
-
- } FT_Open_Args;
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_New_Face */
- /* */
- /* <Description> */
- /* This function calls @FT_Open_Face to open a font by its pathname. */
- /* */
- /* <InOut> */
- /* library :: A handle to the library resource. */
- /* */
- /* <Input> */
- /* pathname :: A path to the font file. */
- /* */
- /* face_index :: The index of the face within the font. The first */
- /* face has index~0. */
- /* */
- /* <Output> */
- /* aface :: A handle to a new face object. If `face_index' is */
- /* greater than or equal to zero, it must be non-NULL. */
- /* See @FT_Open_Face for more details. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* Use @FT_Done_Face to destroy the created @FT_Face object (along */
- /* with its slot and sizes). */
- /* */
- FT_EXPORT( FT_Error )
- FT_New_Face( FT_Library library,
- const char* filepathname,
- FT_Long face_index,
- FT_Face *aface );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_New_Memory_Face */
- /* */
- /* <Description> */
- /* This function calls @FT_Open_Face to open a font which has been */
- /* loaded into memory. */
- /* */
- /* <InOut> */
- /* library :: A handle to the library resource. */
- /* */
- /* <Input> */
- /* file_base :: A pointer to the beginning of the font data. */
- /* */
- /* file_size :: The size of the memory chunk used by the font data. */
- /* */
- /* face_index :: The index of the face within the font. The first */
- /* face has index~0. */
- /* */
- /* <Output> */
- /* aface :: A handle to a new face object. If `face_index' is */
- /* greater than or equal to zero, it must be non-NULL. */
- /* See @FT_Open_Face for more details. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* You must not deallocate the memory before calling @FT_Done_Face. */
- /* */
- FT_EXPORT( FT_Error )
- FT_New_Memory_Face( FT_Library library,
- const FT_Byte* file_base,
- FT_Long file_size,
- FT_Long face_index,
- FT_Face *aface );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Open_Face */
- /* */
- /* <Description> */
- /* Create a face object from a given resource described by */
- /* @FT_Open_Args. */
- /* */
- /* <InOut> */
- /* library :: A handle to the library resource. */
- /* */
- /* <Input> */
- /* args :: A pointer to an `FT_Open_Args' structure which must */
- /* be filled by the caller. */
- /* */
- /* face_index :: The index of the face within the font. The first */
- /* face has index~0. */
- /* */
- /* <Output> */
- /* aface :: A handle to a new face object. If `face_index' is */
- /* greater than or equal to zero, it must be non-NULL. */
- /* See note below. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* Unlike FreeType 1.x, this function automatically creates a glyph */
- /* slot for the face object which can be accessed directly through */
- /* `face->glyph'. */
- /* */
- /* FT_Open_Face can be used to quickly check whether the font */
- /* format of a given font resource is supported by FreeType. If the */
- /* `face_index' field is negative, the function's return value is~0 */
- /* if the font format is recognized, or non-zero otherwise; */
- /* the function returns a more or less empty face handle in `*aface' */
- /* (if `aface' isn't NULL). The only useful field in this special */
- /* case is `face->num_faces' which gives the number of faces within */
- /* the font file. After examination, the returned @FT_Face structure */
- /* should be deallocated with a call to @FT_Done_Face. */
- /* */
- /* Each new face object created with this function also owns a */
- /* default @FT_Size object, accessible as `face->size'. */
- /* */
- /* One @FT_Library instance can have multiple face objects, this is, */
- /* @FT_Open_Face and its siblings can be called multiple times using */
- /* the same `library' argument. */
- /* */
- /* See the discussion of reference counters in the description of */
- /* @FT_Reference_Face. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Open_Face( FT_Library library,
- const FT_Open_Args* args,
- FT_Long face_index,
- FT_Face *aface );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Attach_File */
- /* */
- /* <Description> */
- /* This function calls @FT_Attach_Stream to attach a file. */
- /* */
- /* <InOut> */
- /* face :: The target face object. */
- /* */
- /* <Input> */
- /* filepathname :: The pathname. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Attach_File( FT_Face face,
- const char* filepathname );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Attach_Stream */
- /* */
- /* <Description> */
- /* `Attach' data to a face object. Normally, this is used to read */
- /* additional information for the face object. For example, you can */
- /* attach an AFM file that comes with a Type~1 font to get the */
- /* kerning values and other metrics. */
- /* */
- /* <InOut> */
- /* face :: The target face object. */
- /* */
- /* <Input> */
- /* parameters :: A pointer to @FT_Open_Args which must be filled by */
- /* the caller. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* The meaning of the `attach' (i.e., what really happens when the */
- /* new file is read) is not fixed by FreeType itself. It really */
- /* depends on the font format (and thus the font driver). */
- /* */
- /* Client applications are expected to know what they are doing */
- /* when invoking this function. Most drivers simply do not implement */
- /* file attachments. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Attach_Stream( FT_Face face,
- FT_Open_Args* parameters );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Reference_Face */
- /* */
- /* <Description> */
- /* A counter gets initialized to~1 at the time an @FT_Face structure */
- /* is created. This function increments the counter. @FT_Done_Face */
- /* then only destroys a face if the counter is~1, otherwise it simply */
- /* decrements the counter. */
- /* */
- /* This function helps in managing life-cycles of structures which */
- /* reference @FT_Face objects. */
- /* */
- /* <Input> */
- /* face :: A handle to a target face object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Since> */
- /* 2.4.2 */
- /* */
- FT_EXPORT( FT_Error )
- FT_Reference_Face( FT_Face face );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Done_Face */
- /* */
- /* <Description> */
- /* Discard a given face object, as well as all of its child slots and */
- /* sizes. */
- /* */
- /* <Input> */
- /* face :: A handle to a target face object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* See the discussion of reference counters in the description of */
- /* @FT_Reference_Face. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Done_Face( FT_Face face );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Select_Size */
- /* */
- /* <Description> */
- /* Select a bitmap strike. */
- /* */
- /* <InOut> */
- /* face :: A handle to a target face object. */
- /* */
- /* <Input> */
- /* strike_index :: The index of the bitmap strike in the */
- /* `available_sizes' field of @FT_FaceRec structure. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Select_Size( FT_Face face,
- FT_Int strike_index );
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* FT_Size_Request_Type */
- /* */
- /* <Description> */
- /* An enumeration type that lists the supported size request types. */
- /* */
- /* <Values> */
- /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */
- /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */
- /* used to determine both scaling values. */
- /* */
- /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */
- /* The real dimension. The sum of the the `ascender' and (minus */
- /* of) the `descender' fields of @FT_FaceRec are used to determine */
- /* both scaling values. */
- /* */
- /* FT_SIZE_REQUEST_TYPE_BBOX :: */
- /* The font bounding box. The width and height of the `bbox' field */
- /* of @FT_FaceRec are used to determine the horizontal and vertical */
- /* scaling value, respectively. */
- /* */
- /* FT_SIZE_REQUEST_TYPE_CELL :: */
- /* The `max_advance_width' field of @FT_FaceRec is used to */
- /* determine the horizontal scaling value; the vertical scaling */
- /* value is determined the same way as */
- /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */
- /* values are set to the smaller one. This type is useful if you */
- /* want to specify the font size for, say, a window of a given */
- /* dimension and 80x24 cells. */
- /* */
- /* FT_SIZE_REQUEST_TYPE_SCALES :: */
- /* Specify the scaling values directly. */
- /* */
- /* <Note> */
- /* The above descriptions only apply to scalable formats. For bitmap */
- /* formats, the behaviour is up to the driver. */
- /* */
- /* See the note section of @FT_Size_Metrics if you wonder how size */
- /* requesting relates to scaling values. */
- /* */
- typedef enum FT_Size_Request_Type_
- {
- FT_SIZE_REQUEST_TYPE_NOMINAL,
- FT_SIZE_REQUEST_TYPE_REAL_DIM,
- FT_SIZE_REQUEST_TYPE_BBOX,
- FT_SIZE_REQUEST_TYPE_CELL,
- FT_SIZE_REQUEST_TYPE_SCALES,
-
- FT_SIZE_REQUEST_TYPE_MAX
-
- } FT_Size_Request_Type;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Size_RequestRec */
- /* */
- /* <Description> */
- /* A structure used to model a size request. */
- /* */
- /* <Fields> */
- /* type :: See @FT_Size_Request_Type. */
- /* */
- /* width :: The desired width. */
- /* */
- /* height :: The desired height. */
- /* */
- /* horiResolution :: The horizontal resolution. If set to zero, */
- /* `width' is treated as a 26.6 fractional pixel */
- /* value. */
- /* */
- /* vertResolution :: The vertical resolution. If set to zero, */
- /* `height' is treated as a 26.6 fractional pixel */
- /* value. */
- /* */
- /* <Note> */
- /* If `width' is zero, then the horizontal scaling value is set equal */
- /* to the vertical scaling value, and vice versa. */
- /* */
- typedef struct FT_Size_RequestRec_
- {
- FT_Size_Request_Type type;
- FT_Long width;
- FT_Long height;
- FT_UInt horiResolution;
- FT_UInt vertResolution;
-
- } FT_Size_RequestRec;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Size_Request */
- /* */
- /* <Description> */
- /* A handle to a size request structure. */
- /* */
- typedef struct FT_Size_RequestRec_ *FT_Size_Request;
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Request_Size */
- /* */
- /* <Description> */
- /* Resize the scale of the active @FT_Size object in a face. */
- /* */
- /* <InOut> */
- /* face :: A handle to a target face object. */
- /* */
- /* <Input> */
- /* req :: A pointer to a @FT_Size_RequestRec. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* Although drivers may select the bitmap strike matching the */
- /* request, you should not rely on this if you intend to select a */
- /* particular bitmap strike. Use @FT_Select_Size instead in that */
- /* case. */
- /* */
- /* The relation between the requested size and the resulting glyph */
- /* size is dependent entirely on how the size is defined in the */
- /* source face. The font designer chooses the final size of each */
- /* glyph relative to this size. For more information refer to */
- /* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */
- /* */
- FT_EXPORT( FT_Error )
- FT_Request_Size( FT_Face face,
- FT_Size_Request req );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Set_Char_Size */
- /* */
- /* <Description> */
- /* This function calls @FT_Request_Size to request the nominal size */
- /* (in points). */
- /* */
- /* <InOut> */
- /* face :: A handle to a target face object. */
- /* */
- /* <Input> */
- /* char_width :: The nominal width, in 26.6 fractional points. */
- /* */
- /* char_height :: The nominal height, in 26.6 fractional points. */
- /* */
- /* horz_resolution :: The horizontal resolution in dpi. */
- /* */
- /* vert_resolution :: The vertical resolution in dpi. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* If either the character width or height is zero, it is set equal */
- /* to the other value. */
- /* */
- /* If either the horizontal or vertical resolution is zero, it is set */
- /* equal to the other value. */
- /* */
- /* A character width or height smaller than 1pt is set to 1pt; if */
- /* both resolution values are zero, they are set to 72dpi. */
- /* */
- /* Don't use this function if you are using the FreeType cache API. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Set_Char_Size( FT_Face face,
- FT_F26Dot6 char_width,
- FT_F26Dot6 char_height,
- FT_UInt horz_resolution,
- FT_UInt vert_resolution );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Set_Pixel_Sizes */
- /* */
- /* <Description> */
- /* This function calls @FT_Request_Size to request the nominal size */
- /* (in pixels). */
- /* */
- /* <InOut> */
- /* face :: A handle to the target face object. */
- /* */
- /* <Input> */
- /* pixel_width :: The nominal width, in pixels. */
- /* */
- /* pixel_height :: The nominal height, in pixels. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* You should not rely on the resulting glyphs matching, or being */
- /* constrained, to this pixel size. Refer to @FT_Request_Size to */
- /* understand how requested sizes relate to actual sizes. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Set_Pixel_Sizes( FT_Face face,
- FT_UInt pixel_width,
- FT_UInt pixel_height );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Load_Glyph */
- /* */
- /* <Description> */
- /* A function used to load a single glyph into the glyph slot of a */
- /* face object. */
- /* */
- /* <InOut> */
- /* face :: A handle to the target face object where the glyph */
- /* is loaded. */
- /* */
- /* <Input> */
- /* glyph_index :: The index of the glyph in the font file. For */
- /* CID-keyed fonts (either in PS or in CFF format) */
- /* this argument specifies the CID value. */
- /* */
- /* load_flags :: A flag indicating what to load for this glyph. The */
- /* @FT_LOAD_XXX constants can be used to control the */
- /* glyph loading process (e.g., whether the outline */
- /* should be scaled, whether to load bitmaps or not, */
- /* whether to hint the outline, etc). */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* The loaded glyph may be transformed. See @FT_Set_Transform for */
- /* the details. */
- /* */
- /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */
- /* returned for invalid CID values (this is, for CID values which */
- /* don't have a corresponding glyph in the font). See the discussion */
- /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Load_Glyph( FT_Face face,
- FT_UInt glyph_index,
- FT_Int32 load_flags );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Load_Char */
- /* */
- /* <Description> */
- /* A function used to load a single glyph into the glyph slot of a */
- /* face object, according to its character code. */
- /* */
- /* <InOut> */
- /* face :: A handle to a target face object where the glyph */
- /* is loaded. */
- /* */
- /* <Input> */
- /* char_code :: The glyph's character code, according to the */
- /* current charmap used in the face. */
- /* */
- /* load_flags :: A flag indicating what to load for this glyph. The */
- /* @FT_LOAD_XXX constants can be used to control the */
- /* glyph loading process (e.g., whether the outline */
- /* should be scaled, whether to load bitmaps or not, */
- /* whether to hint the outline, etc). */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Load_Char( FT_Face face,
- FT_ULong char_code,
- FT_Int32 load_flags );
-
-
- /*************************************************************************
- *
- * @enum:
- * FT_LOAD_XXX
- *
- * @description:
- * A list of bit-field constants used with @FT_Load_Glyph to indicate
- * what kind of operations to perform during glyph loading.
- *
- * @values:
- * FT_LOAD_DEFAULT ::
- * Corresponding to~0, this value is used as the default glyph load
- * operation. In this case, the following happens:
- *
- * 1. FreeType looks for a bitmap for the glyph corresponding to the
- * face's current size. If one is found, the function returns.
- * The bitmap data can be accessed from the glyph slot (see note
- * below).
- *
- * 2. If no embedded bitmap is searched or found, FreeType looks for a
- * scalable outline. If one is found, it is loaded from the font
- * file, scaled to device pixels, then `hinted' to the pixel grid
- * in order to optimize it. The outline data can be accessed from
- * the glyph slot (see note below).
- *
- * Note that by default, the glyph loader doesn't render outlines into
- * bitmaps. The following flags are used to modify this default
- * behaviour to more specific and useful cases.
- *
- * FT_LOAD_NO_SCALE ::
- * Don't scale the loaded outline glyph but keep it in font units.
- *
- * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
- * unsets @FT_LOAD_RENDER.
- *
- * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using
- * FT_LOAD_NO_SCALE usually yields meaningless outlines because the
- * subglyphs must be scaled and positioned with hinting instructions.
- * This can be solved by loading the font without FT_LOAD_NO_SCALE and
- * setting the character size to `font->units_per_EM'.
- *
- * FT_LOAD_NO_HINTING ::
- * Disable hinting. This generally generates `blurrier' bitmap glyphs
- * when the glyph are rendered in any of the anti-aliased modes. See
- * also the note below.
- *
- * This flag is implied by @FT_LOAD_NO_SCALE.
- *
- * FT_LOAD_RENDER ::
- * Call @FT_Render_Glyph after the glyph is loaded. By default, the
- * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
- * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
- *
- * This flag is unset by @FT_LOAD_NO_SCALE.
- *
- * FT_LOAD_NO_BITMAP ::
- * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
- * flag.
- *
- * @FT_LOAD_NO_SCALE always sets this flag.
- *
- * FT_LOAD_VERTICAL_LAYOUT ::
- * Load the glyph for vertical text layout. In particular, the
- * `advance' value in the @FT_GlyphSlotRec structure is set to the
- * `vertAdvance' value of the `metrics' field.
- *
- * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use
- * this flag currently. Reason is that in this case vertical metrics
- * get synthesized, and those values are not always consistent across
- * various font formats.
- *
- * FT_LOAD_FORCE_AUTOHINT ::
- * Indicates that the auto-hinter is preferred over the font's native
- * hinter. See also the note below.
- *
- * FT_LOAD_CROP_BITMAP ::
- * Indicates that the font driver should crop the loaded bitmap glyph
- * (i.e., remove all space around its black bits). Not all drivers
- * implement this.
- *
- * FT_LOAD_PEDANTIC ::
- * Indicates that the font driver should perform pedantic verifications
- * during glyph loading. This is mostly used to detect broken glyphs
- * in fonts. By default, FreeType tries to handle broken fonts also.
- *
- * In particular, errors from the TrueType bytecode engine are not
- * passed to the application if this flag is not set; this might
- * result in partially hinted or distorted glyphs in case a glyph's
- * bytecode is buggy.
- *
- * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
- * Ignored. Deprecated.
- *
- * FT_LOAD_NO_RECURSE ::
- * This flag is only used internally. It merely indicates that the
- * font driver should not load composite glyphs recursively. Instead,
- * it should set the `num_subglyph' and `subglyphs' values of the
- * glyph slot accordingly, and set `glyph->format' to
- * @FT_GLYPH_FORMAT_COMPOSITE.
- *
- * The description of sub-glyphs is not available to client
- * applications for now.
- *
- * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
- *
- * FT_LOAD_IGNORE_TRANSFORM ::
- * Indicates that the transform matrix set by @FT_Set_Transform should
- * be ignored.
- *
- * FT_LOAD_MONOCHROME ::
- * This flag is used with @FT_LOAD_RENDER to indicate that you want to
- * render an outline glyph to a 1-bit monochrome bitmap glyph, with
- * 8~pixels packed into each byte of the bitmap data.
- *
- * Note that this has no effect on the hinting algorithm used. You
- * should rather use @FT_LOAD_TARGET_MONO so that the
- * monochrome-optimized hinting algorithm is used.
- *
- * FT_LOAD_LINEAR_DESIGN ::
- * Indicates that the `linearHoriAdvance' and `linearVertAdvance'
- * fields of @FT_GlyphSlotRec should be kept in font units. See
- * @FT_GlyphSlotRec for details.
- *
- * FT_LOAD_NO_AUTOHINT ::
- * Disable auto-hinter. See also the note below.
- *
- * FT_LOAD_COLOR ::
- * This flag is used to request loading of color embedded-bitmap
- * images. The resulting color bitmaps, if available, will have the
- * @FT_PIXEL_MODE_BGRA format. When the flag is not used and color
- * bitmaps are found, they will be converted to 256-level gray
- * bitmaps transparently. Those bitmaps will be in the
- * @FT_PIXEL_MODE_GRAY format.
- *
- * @note:
- * By default, hinting is enabled and the font's native hinter (see
- * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
- * disable hinting by setting @FT_LOAD_NO_HINTING or change the
- * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
- * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be
- * used at all.
- *
- * See the description of @FT_FACE_FLAG_TRICKY for a special exception
- * (affecting only a handful of Asian fonts).
- *
- * Besides deciding which hinter to use, you can also decide which
- * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
- *
- * Note that the auto-hinter needs a valid Unicode cmap (either a native
- * one or synthesized by FreeType) for producing correct results. If a
- * font provides an incorrect mapping (for example, assigning the
- * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a
- * mathematical integral sign), the auto-hinter might produce useless
- * results.
- *
- */
-#define FT_LOAD_DEFAULT 0x0
-#define FT_LOAD_NO_SCALE ( 1L << 0 )
-#define FT_LOAD_NO_HINTING ( 1L << 1 )
-#define FT_LOAD_RENDER ( 1L << 2 )
-#define FT_LOAD_NO_BITMAP ( 1L << 3 )
-#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
-#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
-#define FT_LOAD_CROP_BITMAP ( 1L << 6 )
-#define FT_LOAD_PEDANTIC ( 1L << 7 )
-#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
-#define FT_LOAD_NO_RECURSE ( 1L << 10 )
-#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
-#define FT_LOAD_MONOCHROME ( 1L << 12 )
-#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
-#define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
- /* Bits 16..19 are used by `FT_LOAD_TARGET_' */
-#define FT_LOAD_COLOR ( 1L << 20 )
-
- /* */
-
- /* used internally only by certain font drivers! */
-#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
-#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
-
-
- /**************************************************************************
- *
- * @enum:
- * FT_LOAD_TARGET_XXX
- *
- * @description:
- * A list of values that are used to select a specific hinting algorithm
- * to use by the hinter. You should OR one of these values to your
- * `load_flags' when calling @FT_Load_Glyph.
- *
- * Note that font's native hinters may ignore the hinting algorithm you
- * have specified (e.g., the TrueType bytecode interpreter). You can set
- * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used.
- *
- * Also note that @FT_LOAD_TARGET_LIGHT is an exception, in that it
- * always implies @FT_LOAD_FORCE_AUTOHINT.
- *
- * @values:
- * FT_LOAD_TARGET_NORMAL ::
- * This corresponds to the default hinting algorithm, optimized for
- * standard gray-level rendering. For monochrome output, use
- * @FT_LOAD_TARGET_MONO instead.
- *
- * FT_LOAD_TARGET_LIGHT ::
- * A lighter hinting algorithm for non-monochrome modes. Many
- * generated glyphs are more fuzzy but better resemble its original
- * shape. A bit like rendering on Mac OS~X.
- *
- * As a special exception, this target implies @FT_LOAD_FORCE_AUTOHINT.
- *
- * FT_LOAD_TARGET_MONO ::
- * Strong hinting algorithm that should only be used for monochrome
- * output. The result is probably unpleasant if the glyph is rendered
- * in non-monochrome modes.
- *
- * FT_LOAD_TARGET_LCD ::
- * A variant of @FT_LOAD_TARGET_NORMAL optimized for horizontally
- * decimated LCD displays.
- *
- * FT_LOAD_TARGET_LCD_V ::
- * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
- * decimated LCD displays.
- *
- * @note:
- * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your
- * `load_flags'. They can't be ORed.
- *
- * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
- * corresponding mode (i.e., the mode which matches the used algorithm
- * best). An exeption is FT_LOAD_TARGET_MONO since it implies
- * @FT_LOAD_MONOCHROME.
- *
- * You can use a hinting algorithm that doesn't correspond to the same
- * rendering mode. As an example, it is possible to use the `light'
- * hinting algorithm and have the results rendered in horizontal LCD
- * pixel mode, with code like
- *
- * {
- * FT_Load_Glyph( face, glyph_index,
- * load_flags | FT_LOAD_TARGET_LIGHT );
- *
- * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
- * }
- *
- */
-#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
-
-#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
-#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
-#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
-#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
-#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
-
-
- /**************************************************************************
- *
- * @macro:
- * FT_LOAD_TARGET_MODE
- *
- * @description:
- * Return the @FT_Render_Mode corresponding to a given
- * @FT_LOAD_TARGET_XXX value.
- *
- */
-#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Set_Transform */
- /* */
- /* <Description> */
- /* A function used to set the transformation that is applied to glyph */
- /* images when they are loaded into a glyph slot through */
- /* @FT_Load_Glyph. */
- /* */
- /* <InOut> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Input> */
- /* matrix :: A pointer to the transformation's 2x2 matrix. Use~0 for */
- /* the identity matrix. */
- /* delta :: A pointer to the translation vector. Use~0 for the null */
- /* vector. */
- /* */
- /* <Note> */
- /* The transformation is only applied to scalable image formats after */
- /* the glyph has been loaded. It means that hinting is unaltered by */
- /* the transformation and is performed on the character size given in */
- /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */
- /* */
- /* Note that this also transforms the `face.glyph.advance' field, but */
- /* *not* the values in `face.glyph.metrics'. */
- /* */
- FT_EXPORT( void )
- FT_Set_Transform( FT_Face face,
- FT_Matrix* matrix,
- FT_Vector* delta );
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* FT_Render_Mode */
- /* */
- /* <Description> */
- /* An enumeration type that lists the render modes supported by */
- /* FreeType~2. Each mode corresponds to a specific type of scanline */
- /* conversion performed on the outline. */
- /* */
- /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */
- /* field in the @FT_GlyphSlotRec structure gives the format of the */
- /* returned bitmap. */
- /* */
- /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity. */
- /* */
- /* <Values> */
- /* FT_RENDER_MODE_NORMAL :: */
- /* This is the default render mode; it corresponds to 8-bit */
- /* anti-aliased bitmaps. */
- /* */
- /* FT_RENDER_MODE_LIGHT :: */
- /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */
- /* defined as a separate value because render modes are also used */
- /* indirectly to define hinting algorithm selectors. See */
- /* @FT_LOAD_TARGET_XXX for details. */
- /* */
- /* FT_RENDER_MODE_MONO :: */
- /* This mode corresponds to 1-bit bitmaps (with 2~levels of */
- /* opacity). */
- /* */
- /* FT_RENDER_MODE_LCD :: */
- /* This mode corresponds to horizontal RGB and BGR sub-pixel */
- /* displays like LCD screens. It produces 8-bit bitmaps that are */
- /* 3~times the width of the original glyph outline in pixels, and */
- /* which use the @FT_PIXEL_MODE_LCD mode. */
- /* */
- /* FT_RENDER_MODE_LCD_V :: */
- /* This mode corresponds to vertical RGB and BGR sub-pixel displays */
- /* (like PDA screens, rotated LCD displays, etc.). It produces */
- /* 8-bit bitmaps that are 3~times the height of the original */
- /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */
- /* */
- /* <Note> */
- /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph can be */
- /* filtered to reduce color-fringes by using @FT_Library_SetLcdFilter */
- /* (not active in the default builds). It is up to the caller to */
- /* either call @FT_Library_SetLcdFilter (if available) or do the */
- /* filtering itself. */
- /* */
- /* The selected render mode only affects vector glyphs of a font. */
- /* Embedded bitmaps often have a different pixel mode like */
- /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */
- /* them into 8-bit pixmaps. */
- /* */
- typedef enum FT_Render_Mode_
- {
- FT_RENDER_MODE_NORMAL = 0,
- FT_RENDER_MODE_LIGHT,
- FT_RENDER_MODE_MONO,
- FT_RENDER_MODE_LCD,
- FT_RENDER_MODE_LCD_V,
-
- FT_RENDER_MODE_MAX
-
- } FT_Render_Mode;
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* ft_render_mode_xxx */
- /* */
- /* <Description> */
- /* These constants are deprecated. Use the corresponding */
- /* @FT_Render_Mode values instead. */
- /* */
- /* <Values> */
- /* ft_render_mode_normal :: see @FT_RENDER_MODE_NORMAL */
- /* ft_render_mode_mono :: see @FT_RENDER_MODE_MONO */
- /* */
-#define ft_render_mode_normal FT_RENDER_MODE_NORMAL
-#define ft_render_mode_mono FT_RENDER_MODE_MONO
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Render_Glyph */
- /* */
- /* <Description> */
- /* Convert a given glyph image to a bitmap. It does so by inspecting */
- /* the glyph image format, finding the relevant renderer, and */
- /* invoking it. */
- /* */
- /* <InOut> */
- /* slot :: A handle to the glyph slot containing the image to */
- /* convert. */
- /* */
- /* <Input> */
- /* render_mode :: This is the render mode used to render the glyph */
- /* image into a bitmap. See @FT_Render_Mode for a */
- /* list of possible values. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Render_Glyph( FT_GlyphSlot slot,
- FT_Render_Mode render_mode );
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* FT_Kerning_Mode */
- /* */
- /* <Description> */
- /* An enumeration used to specify which kerning values to return in */
- /* @FT_Get_Kerning. */
- /* */
- /* <Values> */
- /* FT_KERNING_DEFAULT :: Return scaled and grid-fitted kerning */
- /* distances (value is~0). */
- /* */
- /* FT_KERNING_UNFITTED :: Return scaled but un-grid-fitted kerning */
- /* distances. */
- /* */
- /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */
- /* units. */
- /* */
- typedef enum FT_Kerning_Mode_
- {
- FT_KERNING_DEFAULT = 0,
- FT_KERNING_UNFITTED,
- FT_KERNING_UNSCALED
-
- } FT_Kerning_Mode;
-
-
- /*************************************************************************/
- /* */
- /* <Const> */
- /* ft_kerning_default */
- /* */
- /* <Description> */
- /* This constant is deprecated. Please use @FT_KERNING_DEFAULT */
- /* instead. */
- /* */
-#define ft_kerning_default FT_KERNING_DEFAULT
-
-
- /*************************************************************************/
- /* */
- /* <Const> */
- /* ft_kerning_unfitted */
- /* */
- /* <Description> */
- /* This constant is deprecated. Please use @FT_KERNING_UNFITTED */
- /* instead. */
- /* */
-#define ft_kerning_unfitted FT_KERNING_UNFITTED
-
-
- /*************************************************************************/
- /* */
- /* <Const> */
- /* ft_kerning_unscaled */
- /* */
- /* <Description> */
- /* This constant is deprecated. Please use @FT_KERNING_UNSCALED */
- /* instead. */
- /* */
-#define ft_kerning_unscaled FT_KERNING_UNSCALED
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Kerning */
- /* */
- /* <Description> */
- /* Return the kerning vector between two glyphs of a same face. */
- /* */
- /* <Input> */
- /* face :: A handle to a source face object. */
- /* */
- /* left_glyph :: The index of the left glyph in the kern pair. */
- /* */
- /* right_glyph :: The index of the right glyph in the kern pair. */
- /* */
- /* kern_mode :: See @FT_Kerning_Mode for more information. */
- /* Determines the scale and dimension of the returned */
- /* kerning vector. */
- /* */
- /* <Output> */
- /* akerning :: The kerning vector. This is either in font units */
- /* or in pixels (26.6 format) for scalable formats, */
- /* and in pixels for fixed-sizes formats. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* Only horizontal layouts (left-to-right & right-to-left) are */
- /* supported by this method. Other layouts, or more sophisticated */
- /* kernings, are out of the scope of this API function -- they can be */
- /* implemented through format-specific interfaces. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Get_Kerning( FT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_UInt kern_mode,
- FT_Vector *akerning );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Track_Kerning */
- /* */
- /* <Description> */
- /* Return the track kerning for a given face object at a given size. */
- /* */
- /* <Input> */
- /* face :: A handle to a source face object. */
- /* */
- /* point_size :: The point size in 16.16 fractional points. */
- /* */
- /* degree :: The degree of tightness. Increasingly negative */
- /* values represent tighter track kerning, while */
- /* increasingly positive values represent looser track */
- /* kerning. Value zero means no track kerning. */
- /* */
- /* <Output> */
- /* akerning :: The kerning in 16.16 fractional points, to be */
- /* uniformly applied between all glyphs. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* Currently, only the Type~1 font driver supports track kerning, */
- /* using data from AFM files (if attached with @FT_Attach_File or */
- /* @FT_Attach_Stream). */
- /* */
- /* Only very few AFM files come with track kerning data; please refer */
- /* to the Adobe's AFM specification for more details. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Get_Track_Kerning( FT_Face face,
- FT_Fixed point_size,
- FT_Int degree,
- FT_Fixed* akerning );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Glyph_Name */
- /* */
- /* <Description> */
- /* Retrieve the ASCII name of a given glyph in a face. This only */
- /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */
- /* */
- /* <Input> */
- /* face :: A handle to a source face object. */
- /* */
- /* glyph_index :: The glyph index. */
- /* */
- /* buffer_max :: The maximum number of bytes available in the */
- /* buffer. */
- /* */
- /* <Output> */
- /* buffer :: A pointer to a target buffer where the name is */
- /* copied to. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* An error is returned if the face doesn't provide glyph names or if */
- /* the glyph index is invalid. In all cases of failure, the first */
- /* byte of `buffer' is set to~0 to indicate an empty name. */
- /* */
- /* The glyph name is truncated to fit within the buffer if it is too */
- /* long. The returned string is always zero-terminated. */
- /* */
- /* Be aware that FreeType reorders glyph indices internally so that */
- /* glyph index~0 always corresponds to the `missing glyph' (called */
- /* `.notdef'). */
- /* */
- /* This function is not compiled within the library if the config */
- /* macro `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is defined in */
- /* `include/freetype/config/ftoptions.h'. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Get_Glyph_Name( FT_Face face,
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Postscript_Name */
- /* */
- /* <Description> */
- /* Retrieve the ASCII PostScript name of a given face, if available. */
- /* This only works with PostScript and TrueType fonts. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Return> */
- /* A pointer to the face's PostScript name. NULL if unavailable. */
- /* */
- /* <Note> */
- /* The returned pointer is owned by the face and is destroyed with */
- /* it. */
- /* */
- FT_EXPORT( const char* )
- FT_Get_Postscript_Name( FT_Face face );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Select_Charmap */
- /* */
- /* <Description> */
- /* Select a given charmap by its encoding tag (as listed in */
- /* `freetype.h'). */
- /* */
- /* <InOut> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Input> */
- /* encoding :: A handle to the selected encoding. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* This function returns an error if no charmap in the face */
- /* corresponds to the encoding queried here. */
- /* */
- /* Because many fonts contain more than a single cmap for Unicode */
- /* encoding, this function has some special code to select the one */
- /* which covers Unicode best (`best' in the sense that a UCS-4 cmap */
- /* is preferred to a UCS-2 cmap). It is thus preferable to */
- /* @FT_Set_Charmap in this case. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Select_Charmap( FT_Face face,
- FT_Encoding encoding );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Set_Charmap */
- /* */
- /* <Description> */
- /* Select a given charmap for character code to glyph index mapping. */
- /* */
- /* <InOut> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Input> */
- /* charmap :: A handle to the selected charmap. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
- /* <Note> */
- /* This function returns an error if the charmap is not part of */
- /* the face (i.e., if it is not listed in the `face->charmaps' */
- /* table). */
- /* */
- /* It also fails if a type~14 charmap is selected. */
- /* */
- FT_EXPORT( FT_Error )
- FT_Set_Charmap( FT_Face face,
- FT_CharMap charmap );
-
-
- /*************************************************************************
- *
- * @function:
- * FT_Get_Charmap_Index
- *
- * @description:
- * Retrieve index of a given charmap.
- *
- * @input:
- * charmap ::
- * A handle to a charmap.
- *
- * @return:
- * The index into the array of character maps within the face to which
- * `charmap' belongs. If an error occurs, -1 is returned.
- *
- */
- FT_EXPORT( FT_Int )
- FT_Get_Charmap_Index( FT_CharMap charmap );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Char_Index */
- /* */
- /* <Description> */
- /* Return the glyph index of a given character code. This function */
- /* uses a charmap object to do the mapping. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* charcode :: The character code. */
- /* */
- /* <Return> */
- /* The glyph index. 0~means `undefined character code'. */
- /* */
- /* <Note> */
- /* If you use FreeType to manipulate the contents of font files */
- /* directly, be aware that the glyph index returned by this function */
- /* doesn't always correspond to the internal indices used within the */
- /* file. This is done to ensure that value~0 always corresponds to */
- /* the `missing glyph'. If the first glyph is not named `.notdef', */
- /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */
- /* the glyph ID~0 position, and whatever was there will be moved to */
- /* the position `.notdef' had. For Type~1 fonts, if there is no */
- /* `.notdef' glyph at all, then one will be created at index~0 and */
- /* whatever was there will be moved to the last index -- Type~42 */
- /* fonts are considered invalid under this condition. */
- /* */
- FT_EXPORT( FT_UInt )
- FT_Get_Char_Index( FT_Face face,
- FT_ULong charcode );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_First_Char */
- /* */
- /* <Description> */
- /* This function is used to return the first character code in the */
- /* current charmap of a given face. It also returns the */
- /* corresponding glyph index. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Output> */
- /* agindex :: Glyph index of first character code. 0~if charmap is */
- /* empty. */
- /* */
- /* <Return> */
- /* The charmap's first character code. */
- /* */
- /* <Note> */
- /* You should use this function with @FT_Get_Next_Char to be able to */
- /* parse all character codes available in a given charmap. The code */
- /* should look like this: */
- /* */
- /* { */
- /* FT_ULong charcode; */
- /* FT_UInt gindex; */
- /* */
- /* */
- /* charcode = FT_Get_First_Char( face, &gindex ); */
- /* while ( gindex != 0 ) */
- /* { */
- /* ... do something with (charcode,gindex) pair ... */
- /* */
- /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
- /* } */
- /* } */
- /* */
- /* Note that `*agindex' is set to~0 if the charmap is empty. The */
- /* result itself can be~0 in two cases: if the charmap is empty or */
- /* if the value~0 is the first valid character code. */
- /* */
- FT_EXPORT( FT_ULong )
- FT_Get_First_Char( FT_Face face,
- FT_UInt *agindex );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Next_Char */
- /* */
- /* <Description> */
- /* This function is used to return the next character code in the */
- /* current charmap of a given face following the value `char_code', */
- /* as well as the corresponding glyph index. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* char_code :: The starting character code. */
- /* */
- /* <Output> */
- /* agindex :: Glyph index of next character code. 0~if charmap */
- /* is empty. */
- /* */
- /* <Return> */
- /* The charmap's next character code. */
- /* */
- /* <Note> */
- /* You should use this function with @FT_Get_First_Char to walk */
- /* over all character codes available in a given charmap. See the */
- /* note for this function for a simple code example. */
- /* */
- /* Note that `*agindex' is set to~0 when there are no more codes in */
- /* the charmap. */
- /* */
- FT_EXPORT( FT_ULong )
- FT_Get_Next_Char( FT_Face face,
- FT_ULong char_code,
- FT_UInt *agindex );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Name_Index */
- /* */
- /* <Description> */
- /* Return the glyph index of a given glyph name. This function uses */
- /* driver specific objects to do the translation. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* glyph_name :: The glyph name. */
- /* */
- /* <Return> */
- /* The glyph index. 0~means `undefined character code'. */
- /* */
- FT_EXPORT( FT_UInt )
- FT_Get_Name_Index( FT_Face face,
- FT_String* glyph_name );
-
-
- /*************************************************************************
- *
- * @macro:
- * FT_SUBGLYPH_FLAG_XXX
- *
- * @description:
- * A list of constants used to describe subglyphs. Please refer to the
- * TrueType specification for the meaning of the various flags.
- *
- * @values:
- * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
- * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
- * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
- * FT_SUBGLYPH_FLAG_SCALE ::
- * FT_SUBGLYPH_FLAG_XY_SCALE ::
- * FT_SUBGLYPH_FLAG_2X2 ::
- * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
- *
- */
-#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
-#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
-#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
-#define FT_SUBGLYPH_FLAG_SCALE 8
-#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
-#define FT_SUBGLYPH_FLAG_2X2 0x80
-#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
-
-
- /*************************************************************************
- *
- * @func:
- * FT_Get_SubGlyph_Info
- *
- * @description:
- * Retrieve a description of a given subglyph. Only use it if
- * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is
- * returned otherwise.
- *
- * @input:
- * glyph ::
- * The source glyph slot.
- *
- * sub_index ::
- * The index of the subglyph. Must be less than
- * `glyph->num_subglyphs'.
- *
- * @output:
- * p_index ::
- * The glyph index of the subglyph.
- *
- * p_flags ::
- * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
- *
- * p_arg1 ::
- * The subglyph's first argument (if any).
- *
- * p_arg2 ::
- * The subglyph's second argument (if any).
- *
- * p_transform ::
- * The subglyph transformation (if any).
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be
- * interpreted depending on the flags returned in `*p_flags'. See the
- * TrueType specification for details.
- *
- */
- FT_EXPORT( FT_Error )
- FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
- FT_UInt sub_index,
- FT_Int *p_index,
- FT_UInt *p_flags,
- FT_Int *p_arg1,
- FT_Int *p_arg2,
- FT_Matrix *p_transform );
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* FT_FSTYPE_XXX */
- /* */
- /* <Description> */
- /* A list of bit flags used in the `fsType' field of the OS/2 table */
- /* in a TrueType or OpenType font and the `FSType' entry in a */
- /* PostScript font. These bit flags are returned by */
- /* @FT_Get_FSType_Flags; they inform client applications of embedding */
- /* and subsetting restrictions associated with a font. */
- /* */
- /* See http://www.adobe.com/devnet/acrobat/pdfs/FontPolicies.pdf for */
- /* more details. */
- /* */
- /* <Values> */
- /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */
- /* Fonts with no fsType bit set may be embedded and permanently */
- /* installed on the remote system by an application. */
- /* */
- /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */
- /* Fonts that have only this bit set must not be modified, embedded */
- /* or exchanged in any manner without first obtaining permission of */
- /* the font software copyright owner. */
- /* */
- /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */
- /* If this bit is set, the font may be embedded and temporarily */
- /* loaded on the remote system. Documents containing Preview & */
- /* Print fonts must be opened `read-only'; no edits can be applied */
- /* to the document. */
- /* */
- /* FT_FSTYPE_EDITABLE_EMBEDDING :: */
- /* If this bit is set, the font may be embedded but must only be */
- /* installed temporarily on other systems. In contrast to Preview */
- /* & Print fonts, documents containing editable fonts may be opened */
- /* for reading, editing is permitted, and changes may be saved. */
- /* */
- /* FT_FSTYPE_NO_SUBSETTING :: */
- /* If this bit is set, the font may not be subsetted prior to */
- /* embedding. */
- /* */
- /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */
- /* If this bit is set, only bitmaps contained in the font may be */
- /* embedded; no outline data may be embedded. If there are no */
- /* bitmaps available in the font, then the font is unembeddable. */
- /* */
- /* <Note> */
- /* While the fsType flags can indicate that a font may be embedded, a */
- /* license with the font vendor may be separately required to use the */
- /* font in this way. */
- /* */
-#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
-#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
-#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
-#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
-#define FT_FSTYPE_NO_SUBSETTING 0x0100
-#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_FSType_Flags */
- /* */
- /* <Description> */
- /* Return the fsType flags for a font. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Return> */
- /* The fsType flags, @FT_FSTYPE_XXX. */
- /* */
- /* <Note> */
- /* Use this function rather than directly reading the `fs_type' field */
- /* in the @PS_FontInfoRec structure which is only guaranteed to */
- /* return the correct results for Type~1 fonts. */
- /* */
- /* <Since> */
- /* 2.3.8 */
- /* */
- FT_EXPORT( FT_UShort )
- FT_Get_FSType_Flags( FT_Face face );
-
-
- /*************************************************************************/
- /* */
- /* <Section> */
- /* glyph_variants */
- /* */
- /* <Title> */
- /* Glyph Variants */
- /* */
- /* <Abstract> */
- /* The FreeType~2 interface to Unicode Ideographic Variation */
- /* Sequences (IVS), using the SFNT cmap format~14. */
- /* */
- /* <Description> */
- /* Many CJK characters have variant forms. They are a sort of grey */
- /* area somewhere between being totally irrelevant and semantically */
- /* distinct; for this reason, the Unicode consortium decided to */
- /* introduce Ideographic Variation Sequences (IVS), consisting of a */
- /* Unicode base character and one of 240 variant selectors */
- /* (U+E0100-U+E01EF), instead of further extending the already huge */
- /* code range for CJK characters. */
- /* */
- /* An IVS is registered and unique; for further details please refer */
- /* to Unicode Technical Standard #37, the Ideographic Variation */
- /* Database: */
- /* */
- /* http://www.unicode.org/reports/tr37/ */
- /* */
- /* To date (November 2012), the character with the most variants is */
- /* U+9089, having 31 such IVS. */
- /* */
- /* Adobe and MS decided to support IVS with a new cmap subtable */
- /* (format~14). It is an odd subtable because it is not a mapping of */
- /* input code points to glyphs, but contains lists of all variants */
- /* supported by the font. */
- /* */
- /* A variant may be either `default' or `non-default'. A default */
- /* variant is the one you will get for that code point if you look it */
- /* up in the standard Unicode cmap. A non-default variant is a */
- /* different glyph. */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Face_GetCharVariantIndex */
- /* */
- /* <Description> */
- /* Return the glyph index of a given character code as modified by */
- /* the variation selector. */
- /* */
- /* <Input> */
- /* face :: */
- /* A handle to the source face object. */
- /* */
- /* charcode :: */
- /* The character code point in Unicode. */
- /* */
- /* variantSelector :: */
- /* The Unicode code point of the variation selector. */
- /* */
- /* <Return> */
- /* The glyph index. 0~means either `undefined character code', or */
- /* `undefined selector code', or `no variation selector cmap */
- /* subtable', or `current CharMap is not Unicode'. */
- /* */
- /* <Note> */
- /* If you use FreeType to manipulate the contents of font files */
- /* directly, be aware that the glyph index returned by this function */
- /* doesn't always correspond to the internal indices used within */
- /* the file. This is done to ensure that value~0 always corresponds */
- /* to the `missing glyph'. */
- /* */
- /* This function is only meaningful if */
- /* a) the font has a variation selector cmap sub table, */
- /* and */
- /* b) the current charmap has a Unicode encoding. */
- /* */
- /* <Since> */
- /* 2.3.6 */
- /* */
- FT_EXPORT( FT_UInt )
- FT_Face_GetCharVariantIndex( FT_Face face,
- FT_ULong charcode,
- FT_ULong variantSelector );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Face_GetCharVariantIsDefault */
- /* */
- /* <Description> */
- /* Check whether this variant of this Unicode character is the one to */
- /* be found in the `cmap'. */
- /* */
- /* <Input> */
- /* face :: */
- /* A handle to the source face object. */
- /* */
- /* charcode :: */
- /* The character codepoint in Unicode. */
- /* */
- /* variantSelector :: */
- /* The Unicode codepoint of the variation selector. */
- /* */
- /* <Return> */
- /* 1~if found in the standard (Unicode) cmap, 0~if found in the */
- /* variation selector cmap, or -1 if it is not a variant. */
- /* */
- /* <Note> */
- /* This function is only meaningful if the font has a variation */
- /* selector cmap subtable. */
- /* */
- /* <Since> */
- /* 2.3.6 */
- /* */
- FT_EXPORT( FT_Int )
- FT_Face_GetCharVariantIsDefault( FT_Face face,
- FT_ULong charcode,
- FT_ULong variantSelector );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Face_GetVariantSelectors */
- /* */
- /* <Description> */
- /* Return a zero-terminated list of Unicode variant selectors found */
- /* in the font. */
- /* */
- /* <Input> */
- /* face :: */
- /* A handle to the source face object. */
- /* */
- /* <Return> */
- /* A pointer to an array of selector code points, or NULL if there is */
- /* no valid variant selector cmap subtable. */
- /* */
- /* <Note> */
- /* The last item in the array is~0; the array is owned by the */
- /* @FT_Face object but can be overwritten or released on the next */
- /* call to a FreeType function. */
- /* */
- /* <Since> */
- /* 2.3.6 */
- /* */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetVariantSelectors( FT_Face face );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Face_GetVariantsOfChar */
- /* */
- /* <Description> */
- /* Return a zero-terminated list of Unicode variant selectors found */
- /* for the specified character code. */
- /* */
- /* <Input> */
- /* face :: */
- /* A handle to the source face object. */
- /* */
- /* charcode :: */
- /* The character codepoint in Unicode. */
- /* */
- /* <Return> */
- /* A pointer to an array of variant selector code points which are */
- /* active for the given character, or NULL if the corresponding list */
- /* is empty. */
- /* */
- /* <Note> */
- /* The last item in the array is~0; the array is owned by the */
- /* @FT_Face object but can be overwritten or released on the next */
- /* call to a FreeType function. */
- /* */
- /* <Since> */
- /* 2.3.6 */
- /* */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetVariantsOfChar( FT_Face face,
- FT_ULong charcode );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Face_GetCharsOfVariant */
- /* */
- /* <Description> */
- /* Return a zero-terminated list of Unicode character codes found for */
- /* the specified variant selector. */
- /* */
- /* <Input> */
- /* face :: */
- /* A handle to the source face object. */
- /* */
- /* variantSelector :: */
- /* The variant selector code point in Unicode. */
- /* */
- /* <Return> */
- /* A list of all the code points which are specified by this selector */
- /* (both default and non-default codes are returned) or NULL if there */
- /* is no valid cmap or the variant selector is invalid. */
- /* */
- /* <Note> */
- /* The last item in the array is~0; the array is owned by the */
- /* @FT_Face object but can be overwritten or released on the next */
- /* call to a FreeType function. */
- /* */
- /* <Since> */
- /* 2.3.6 */
- /* */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetCharsOfVariant( FT_Face face,
- FT_ULong variantSelector );
-
-
- /*************************************************************************/
- /* */
- /* <Section> */
- /* computations */
- /* */
- /* <Title> */
- /* Computations */
- /* */
- /* <Abstract> */
- /* Crunching fixed numbers and vectors. */
- /* */
- /* <Description> */
- /* This section contains various functions used to perform */
- /* computations on 16.16 fixed-float numbers or 2d vectors. */
- /* */
- /* <Order> */
- /* FT_MulDiv */
- /* FT_MulFix */
- /* FT_DivFix */
- /* FT_RoundFix */
- /* FT_CeilFix */
- /* FT_FloorFix */
- /* FT_Vector_Transform */
- /* FT_Matrix_Multiply */
- /* FT_Matrix_Invert */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_MulDiv */
- /* */
- /* <Description> */
- /* A very simple function used to perform the computation `(a*b)/c' */
- /* with maximum accuracy (it uses a 64-bit intermediate integer */
- /* whenever necessary). */
- /* */
- /* This function isn't necessarily as fast as some processor specific */
- /* operations, but is at least completely portable. */
- /* */
- /* <Input> */
- /* a :: The first multiplier. */
- /* b :: The second multiplier. */
- /* c :: The divisor. */
- /* */
- /* <Return> */
- /* The result of `(a*b)/c'. This function never traps when trying to */
- /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
- /* on the signs of `a' and `b'. */
- /* */
- FT_EXPORT( FT_Long )
- FT_MulDiv( FT_Long a,
- FT_Long b,
- FT_Long c );
-
-
- /* */
-
- /* The following #if 0 ... #endif is for the documentation formatter, */
- /* hiding the internal `FT_MULFIX_INLINED' macro. */
-
-#if 0
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_MulFix */
- /* */
- /* <Description> */
- /* A very simple function used to perform the computation */
- /* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */
- /* used to multiply a given value by a 16.16 fixed-point factor. */
- /* */
- /* <Input> */
- /* a :: The first multiplier. */
- /* b :: The second multiplier. Use a 16.16 factor here whenever */
- /* possible (see note below). */
- /* */
- /* <Return> */
- /* The result of `(a*b)/0x10000'. */
- /* */
- /* <Note> */
- /* This function has been optimized for the case where the absolute */
- /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
- /* As this happens mainly when scaling from notional units to */
- /* fractional pixels in FreeType, it resulted in noticeable speed */
- /* improvements between versions 2.x and 1.x. */
- /* */
- /* As a conclusion, always try to place a 16.16 factor as the */
- /* _second_ argument of this function; this can make a great */
- /* difference. */
- /* */
- FT_EXPORT( FT_Long )
- FT_MulFix( FT_Long a,
- FT_Long b );
-
- /* */
-#endif
-
-#ifdef FT_MULFIX_INLINED
-#define FPDFAPI_FT_MulFix( a, b ) FT_MULFIX_INLINED( a, b )
-#else
- FT_EXPORT( FT_Long )
- FT_MulFix( FT_Long a,
- FT_Long b );
-#endif
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_DivFix */
- /* */
- /* <Description> */
- /* A very simple function used to perform the computation */
- /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */
- /* used to divide a given value by a 16.16 fixed-point factor. */
- /* */
- /* <Input> */
- /* a :: The first multiplier. */
- /* b :: The second multiplier. Use a 16.16 factor here whenever */
- /* possible (see note below). */
- /* */
- /* <Return> */
- /* The result of `(a*0x10000)/b'. */
- /* */
- /* <Note> */
- /* The optimization for FT_DivFix() is simple: If (a~<<~16) fits in */
- /* 32~bits, then the division is computed directly. Otherwise, we */
- /* use a specialized version of @FT_MulDiv. */
- /* */
- FT_EXPORT( FT_Long )
- FT_DivFix( FT_Long a,
- FT_Long b );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_RoundFix */
- /* */
- /* <Description> */
- /* A very simple function used to round a 16.16 fixed number. */
- /* */
- /* <Input> */
- /* a :: The number to be rounded. */
- /* */
- /* <Return> */
- /* The result of `(a + 0x8000) & -0x10000'. */
- /* */
- FT_EXPORT( FT_Fixed )
- FT_RoundFix( FT_Fixed a );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_CeilFix */
- /* */
- /* <Description> */
- /* A very simple function used to compute the ceiling function of a */
- /* 16.16 fixed number. */
- /* */
- /* <Input> */
- /* a :: The number for which the ceiling function is to be computed. */
- /* */
- /* <Return> */
- /* The result of `(a + 0x10000 - 1) & -0x10000'. */
- /* */
- FT_EXPORT( FT_Fixed )
- FT_CeilFix( FT_Fixed a );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_FloorFix */
- /* */
- /* <Description> */
- /* A very simple function used to compute the floor function of a */
- /* 16.16 fixed number. */
- /* */
- /* <Input> */
- /* a :: The number for which the floor function is to be computed. */
- /* */
- /* <Return> */
- /* The result of `a & -0x10000'. */
- /* */
- FT_EXPORT( FT_Fixed )
- FT_FloorFix( FT_Fixed a );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Vector_Transform */
- /* */
- /* <Description> */
- /* Transform a single vector through a 2x2 matrix. */
- /* */
- /* <InOut> */
- /* vector :: The target vector to transform. */
- /* */
- /* <Input> */
- /* matrix :: A pointer to the source 2x2 matrix. */
- /* */
- /* <Note> */
- /* The result is undefined if either `vector' or `matrix' is invalid. */
- /* */
- FT_EXPORT( void )
- FT_Vector_Transform( FT_Vector* vec,
- const FT_Matrix* matrix );
-
-
- /*************************************************************************/
- /* */
- /* <Section> */
- /* version */
- /* */
- /* <Title> */
- /* FreeType Version */
- /* */
- /* <Abstract> */
- /* Functions and macros related to FreeType versions. */
- /* */
- /* <Description> */
- /* Note that those functions and macros are of limited use because */
- /* even a new release of FreeType with only documentation changes */
- /* increases the version number. */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************
- *
- * @enum:
- * FREETYPE_XXX
- *
- * @description:
- * These three macros identify the FreeType source code version.
- * Use @FT_Library_Version to access them at runtime.
- *
- * @values:
- * FREETYPE_MAJOR :: The major version number.
- * FREETYPE_MINOR :: The minor version number.
- * FREETYPE_PATCH :: The patch level.
- *
- * @note:
- * The version number of FreeType if built as a dynamic link library
- * with the `libtool' package is _not_ controlled by these three
- * macros.
- *
- */
-#define FREETYPE_MAJOR 2
-#define FREETYPE_MINOR 5
-#define FREETYPE_PATCH 0
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Library_Version */
- /* */
- /* <Description> */
- /* Return the version of the FreeType library being used. This is */
- /* useful when dynamically linking to the library, since one cannot */
- /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */
- /* @FREETYPE_PATCH. */
- /* */
- /* <Input> */
- /* library :: A source library handle. */
- /* */
- /* <Output> */
- /* amajor :: The major version number. */
- /* */
- /* aminor :: The minor version number. */
- /* */
- /* apatch :: The patch version number. */
- /* */
- /* <Note> */
- /* The reason why this function takes a `library' argument is because */
- /* certain programs implement library initialization in a custom way */
- /* that doesn't use @FT_Init_FreeType. */
- /* */
- /* In such cases, the library version might not be available before */
- /* the library object has been created. */
- /* */
- FT_EXPORT( void )
- FT_Library_Version( FT_Library library,
- FT_Int *amajor,
- FT_Int *aminor,
- FT_Int *apatch );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Face_CheckTrueTypePatents */
- /* */
- /* <Description> */
- /* Parse all bytecode instructions of a TrueType font file to check */
- /* whether any of the patented opcodes are used. This is only useful */
- /* if you want to be able to use the unpatented hinter with */
- /* fonts that do *not* use these opcodes. */
- /* */
- /* Note that this function parses *all* glyph instructions in the */
- /* font file, which may be slow. */
- /* */
- /* <Input> */
- /* face :: A face handle. */
- /* */
- /* <Return> */
- /* 1~if this is a TrueType font that uses one of the patented */
- /* opcodes, 0~otherwise. */
- /* */
- /* <Note> */
- /* Since May 2010, TrueType hinting is no longer patented. */
- /* */
- /* <Since> */
- /* 2.3.5 */
- /* */
- FT_EXPORT( FT_Bool )
- FT_Face_CheckTrueTypePatents( FT_Face face );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Face_SetUnpatentedHinting */
- /* */
- /* <Description> */
- /* Enable or disable the unpatented hinter for a given face. */
- /* Only enable it if you have determined that the face doesn't */
- /* use any patented opcodes (see @FT_Face_CheckTrueTypePatents). */
- /* */
- /* <Input> */
- /* face :: A face handle. */
- /* */
- /* value :: New boolean setting. */
- /* */
- /* <Return> */
- /* The old setting value. This will always be false if this is not */
- /* an SFNT font, or if the unpatented hinter is not compiled in this */
- /* instance of the library. */
- /* */
- /* <Note> */
- /* Since May 2010, TrueType hinting is no longer patented. */
- /* */
- /* <Since> */
- /* 2.3.5 */
- /* */
- FT_EXPORT( FT_Bool )
- FT_Face_SetUnpatentedHinting( FT_Face face,
- FT_Bool value );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* __FREETYPE_H__ */
-
-
-/* END */
+/***************************************************************************/
+/* */
+/* freetype.h */
+/* */
+/* FreeType high-level API and common types (specification only). */
+/* */
+/* Copyright 1996-2013 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __FREETYPE_H__
+#define __FREETYPE_H__
+
+
+#ifndef FT_FREETYPE_H
+#error "`ft2build.h' hasn't been included yet!"
+#error "Please always use macros to include FreeType header files."
+#error "Example:"
+#error " #include <ft2build.h>"
+#error " #include FT_FREETYPE_H"
+#endif
+
+
+#include "../ft2build.h"
+#include "config/ftconfig.h"
+#include "fttypes.h"
+#include "fterrors.h"
+
+
+FT_BEGIN_HEADER
+
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* user_allocation */
+ /* */
+ /* <Title> */
+ /* User allocation */
+ /* */
+ /* <Abstract> */
+ /* How client applications should allocate FreeType data structures. */
+ /* */
+ /* <Description> */
+ /* FreeType assumes that structures allocated by the user and passed */
+ /* as arguments are zeroed out except for the actual data. In other */
+ /* words, it is recommended to use `calloc' (or variants of it) */
+ /* instead of `malloc' for allocation. */
+ /* */
+ /*************************************************************************/
+
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* B A S I C T Y P E S */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* base_interface */
+ /* */
+ /* <Title> */
+ /* Base Interface */
+ /* */
+ /* <Abstract> */
+ /* The FreeType~2 base font interface. */
+ /* */
+ /* <Description> */
+ /* This section describes the public high-level API of FreeType~2. */
+ /* */
+ /* <Order> */
+ /* FT_Library */
+ /* FT_Face */
+ /* FT_Size */
+ /* FT_GlyphSlot */
+ /* FT_CharMap */
+ /* FT_Encoding */
+ /* */
+ /* FT_FaceRec */
+ /* */
+ /* FT_FACE_FLAG_SCALABLE */
+ /* FT_FACE_FLAG_FIXED_SIZES */
+ /* FT_FACE_FLAG_FIXED_WIDTH */
+ /* FT_FACE_FLAG_HORIZONTAL */
+ /* FT_FACE_FLAG_VERTICAL */
+ /* FT_FACE_FLAG_SFNT */
+ /* FT_FACE_FLAG_KERNING */
+ /* FT_FACE_FLAG_MULTIPLE_MASTERS */
+ /* FT_FACE_FLAG_GLYPH_NAMES */
+ /* FT_FACE_FLAG_EXTERNAL_STREAM */
+ /* FT_FACE_FLAG_FAST_GLYPHS */
+ /* FT_FACE_FLAG_HINTER */
+ /* */
+ /* FT_STYLE_FLAG_BOLD */
+ /* FT_STYLE_FLAG_ITALIC */
+ /* */
+ /* FT_SizeRec */
+ /* FT_Size_Metrics */
+ /* */
+ /* FT_GlyphSlotRec */
+ /* FT_Glyph_Metrics */
+ /* FT_SubGlyph */
+ /* */
+ /* FT_Bitmap_Size */
+ /* */
+ /* FT_Init_FreeType */
+ /* FT_Done_FreeType */
+ /* */
+ /* FT_New_Face */
+ /* FT_Done_Face */
+ /* FT_New_Memory_Face */
+ /* FT_Open_Face */
+ /* FT_Open_Args */
+ /* FT_Parameter */
+ /* FT_Attach_File */
+ /* FT_Attach_Stream */
+ /* */
+ /* FT_Set_Char_Size */
+ /* FT_Set_Pixel_Sizes */
+ /* FT_Request_Size */
+ /* FT_Select_Size */
+ /* FT_Size_Request_Type */
+ /* FT_Size_Request */
+ /* FT_Set_Transform */
+ /* FT_Load_Glyph */
+ /* FT_Get_Char_Index */
+ /* FT_Get_Name_Index */
+ /* FT_Load_Char */
+ /* */
+ /* FT_OPEN_MEMORY */
+ /* FT_OPEN_STREAM */
+ /* FT_OPEN_PATHNAME */
+ /* FT_OPEN_DRIVER */
+ /* FT_OPEN_PARAMS */
+ /* */
+ /* FT_LOAD_DEFAULT */
+ /* FT_LOAD_RENDER */
+ /* FT_LOAD_MONOCHROME */
+ /* FT_LOAD_LINEAR_DESIGN */
+ /* FT_LOAD_NO_SCALE */
+ /* FT_LOAD_NO_HINTING */
+ /* FT_LOAD_NO_BITMAP */
+ /* FT_LOAD_CROP_BITMAP */
+ /* */
+ /* FT_LOAD_VERTICAL_LAYOUT */
+ /* FT_LOAD_IGNORE_TRANSFORM */
+ /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
+ /* FT_LOAD_FORCE_AUTOHINT */
+ /* FT_LOAD_NO_RECURSE */
+ /* FT_LOAD_PEDANTIC */
+ /* */
+ /* FT_LOAD_TARGET_NORMAL */
+ /* FT_LOAD_TARGET_LIGHT */
+ /* FT_LOAD_TARGET_MONO */
+ /* FT_LOAD_TARGET_LCD */
+ /* FT_LOAD_TARGET_LCD_V */
+ /* */
+ /* FT_Render_Glyph */
+ /* FT_Render_Mode */
+ /* FT_Get_Kerning */
+ /* FT_Kerning_Mode */
+ /* FT_Get_Track_Kerning */
+ /* FT_Get_Glyph_Name */
+ /* FT_Get_Postscript_Name */
+ /* */
+ /* FT_CharMapRec */
+ /* FT_Select_Charmap */
+ /* FT_Set_Charmap */
+ /* FT_Get_Charmap_Index */
+ /* */
+ /* FT_FSTYPE_INSTALLABLE_EMBEDDING */
+ /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING */
+ /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING */
+ /* FT_FSTYPE_EDITABLE_EMBEDDING */
+ /* FT_FSTYPE_NO_SUBSETTING */
+ /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY */
+ /* */
+ /* FT_Get_FSType_Flags */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Glyph_Metrics */
+ /* */
+ /* <Description> */
+ /* A structure used to model the metrics of a single glyph. The */
+ /* values are expressed in 26.6 fractional pixel format; if the flag */
+ /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */
+ /* are expressed in font units instead. */
+ /* */
+ /* <Fields> */
+ /* width :: */
+ /* The glyph's width. */
+ /* */
+ /* height :: */
+ /* The glyph's height. */
+ /* */
+ /* horiBearingX :: */
+ /* Left side bearing for horizontal layout. */
+ /* */
+ /* horiBearingY :: */
+ /* Top side bearing for horizontal layout. */
+ /* */
+ /* horiAdvance :: */
+ /* Advance width for horizontal layout. */
+ /* */
+ /* vertBearingX :: */
+ /* Left side bearing for vertical layout. */
+ /* */
+ /* vertBearingY :: */
+ /* Top side bearing for vertical layout. Larger positive values */
+ /* mean further below the vertical glyph origin. */
+ /* */
+ /* vertAdvance :: */
+ /* Advance height for vertical layout. Positive values mean the */
+ /* glyph has a positive advance downward. */
+ /* */
+ /* <Note> */
+ /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */
+ /* dimensions of the hinted glyph (in case hinting is applicable). */
+ /* */
+ /* Stroking a glyph with an outside border does not increase */
+ /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */
+ /* values to account for the added width and height. */
+ /* */
+ typedef struct FT_Glyph_Metrics_
+ {
+ FT_Pos width;
+ FT_Pos height;
+
+ FT_Pos horiBearingX;
+ FT_Pos horiBearingY;
+ FT_Pos horiAdvance;
+
+ FT_Pos vertBearingX;
+ FT_Pos vertBearingY;
+ FT_Pos vertAdvance;
+
+ } FT_Glyph_Metrics;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Bitmap_Size */
+ /* */
+ /* <Description> */
+ /* This structure models the metrics of a bitmap strike (i.e., a set */
+ /* of glyphs for a given point size and resolution) in a bitmap font. */
+ /* It is used for the `available_sizes' field of @FT_Face. */
+ /* */
+ /* <Fields> */
+ /* height :: The vertical distance, in pixels, between two */
+ /* consecutive baselines. It is always positive. */
+ /* */
+ /* width :: The average width, in pixels, of all glyphs in the */
+ /* strike. */
+ /* */
+ /* size :: The nominal size of the strike in 26.6 fractional */
+ /* points. This field is not very useful. */
+ /* */
+ /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */
+ /* pixels. */
+ /* */
+ /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */
+ /* pixels. */
+ /* */
+ /* <Note> */
+ /* Windows FNT: */
+ /* The nominal size given in a FNT font is not reliable. Thus when */
+ /* the driver finds it incorrect, it sets `size' to some calculated */
+ /* values and sets `x_ppem' and `y_ppem' to the pixel width and */
+ /* height given in the font, respectively. */
+ /* */
+ /* TrueType embedded bitmaps: */
+ /* `size', `width', and `height' values are not contained in the */
+ /* bitmap strike itself. They are computed from the global font */
+ /* parameters. */
+ /* */
+ typedef struct FT_Bitmap_Size_
+ {
+ FT_Short height;
+ FT_Short width;
+
+ FT_Pos size;
+
+ FT_Pos x_ppem;
+ FT_Pos y_ppem;
+
+ } FT_Bitmap_Size;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* O B J E C T C L A S S E S */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Library */
+ /* */
+ /* <Description> */
+ /* A handle to a FreeType library instance. Each `library' is */
+ /* completely independent from the others; it is the `root' of a set */
+ /* of objects like fonts, faces, sizes, etc. */
+ /* */
+ /* It also embeds a memory manager (see @FT_Memory), as well as a */
+ /* scan-line converter object (see @FT_Raster). */
+ /* */
+ /* In multi-threaded applications, make sure that the same FT_Library */
+ /* object or any of its children doesn't get accessed in parallel. */
+ /* */
+ /* <Note> */
+ /* Library objects are normally created by @FT_Init_FreeType, and */
+ /* destroyed with @FT_Done_FreeType. If you need reference-counting */
+ /* (cf. @FT_Reference_Library), use @FT_New_Library and */
+ /* @FT_Done_Library. */
+ /* */
+ typedef struct FT_LibraryRec_ *FT_Library;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Module */
+ /* */
+ /* <Description> */
+ /* A handle to a given FreeType module object. Each module can be a */
+ /* font driver, a renderer, or anything else that provides services */
+ /* to the formers. */
+ /* */
+ typedef struct FT_ModuleRec_* FT_Module;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Driver */
+ /* */
+ /* <Description> */
+ /* A handle to a given FreeType font driver object. Each font driver */
+ /* is a special module capable of creating faces from font files. */
+ /* */
+ typedef struct FT_DriverRec_* FT_Driver;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Renderer */
+ /* */
+ /* <Description> */
+ /* A handle to a given FreeType renderer. A renderer is a special */
+ /* module in charge of converting a glyph image to a bitmap, when */
+ /* necessary. Each renderer supports a given glyph image format, and */
+ /* one or more target surface depths. */
+ /* */
+ typedef struct FT_RendererRec_* FT_Renderer;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Face */
+ /* */
+ /* <Description> */
+ /* A handle to a given typographic face object. A face object models */
+ /* a given typeface, in a given style. */
+ /* */
+ /* <Note> */
+ /* Each face object also owns a single @FT_GlyphSlot object, as well */
+ /* as one or more @FT_Size objects. */
+ /* */
+ /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */
+ /* a given filepathname or a custom input stream. */
+ /* */
+ /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
+ /* */
+ /* <Also> */
+ /* See @FT_FaceRec for the publicly accessible fields of a given face */
+ /* object. */
+ /* */
+ typedef struct FT_FaceRec_* FT_Face;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Size */
+ /* */
+ /* <Description> */
+ /* A handle to an object used to model a face scaled to a given */
+ /* character size. */
+ /* */
+ /* <Note> */
+ /* Each @FT_Face has an _active_ @FT_Size object that is used by */
+ /* functions like @FT_Load_Glyph to determine the scaling */
+ /* transformation which is used to load and hint glyphs and metrics. */
+ /* */
+ /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */
+ /* @FT_Request_Size or even @FT_Select_Size to change the content */
+ /* (i.e., the scaling values) of the active @FT_Size. */
+ /* */
+ /* You can use @FT_New_Size to create additional size objects for a */
+ /* given @FT_Face, but they won't be used by other functions until */
+ /* you activate it through @FT_Activate_Size. Only one size can be */
+ /* activated at any given time per face. */
+ /* */
+ /* <Also> */
+ /* See @FT_SizeRec for the publicly accessible fields of a given size */
+ /* object. */
+ /* */
+ typedef struct FT_SizeRec_* FT_Size;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_GlyphSlot */
+ /* */
+ /* <Description> */
+ /* A handle to a given `glyph slot'. A slot is a container where it */
+ /* is possible to load any of the glyphs contained in its parent */
+ /* face. */
+ /* */
+ /* In other words, each time you call @FT_Load_Glyph or */
+ /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
+ /* i.e., the glyph's metrics, its image (bitmap or outline), and */
+ /* other control information. */
+ /* */
+ /* <Also> */
+ /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */
+ /* */
+ typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_CharMap */
+ /* */
+ /* <Description> */
+ /* A handle to a given character map. A charmap is used to translate */
+ /* character codes in a given encoding into glyph indexes for its */
+ /* parent's face. Some font formats may provide several charmaps per */
+ /* font. */
+ /* */
+ /* Each face object owns zero or more charmaps, but only one of them */
+ /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */
+ /* */
+ /* The list of available charmaps in a face is available through the */
+ /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */
+ /* */
+ /* The currently active charmap is available as `face->charmap'. */
+ /* You should call @FT_Set_Charmap to change it. */
+ /* */
+ /* <Note> */
+ /* When a new face is created (either through @FT_New_Face or */
+ /* @FT_Open_Face), the library looks for a Unicode charmap within */
+ /* the list and automatically activates it. */
+ /* */
+ /* <Also> */
+ /* See @FT_CharMapRec for the publicly accessible fields of a given */
+ /* character map. */
+ /* */
+ typedef struct FT_CharMapRec_* FT_CharMap;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Macro> */
+ /* FT_ENC_TAG */
+ /* */
+ /* <Description> */
+ /* This macro converts four-letter tags into an unsigned long. It is */
+ /* used to define `encoding' identifiers (see @FT_Encoding). */
+ /* */
+ /* <Note> */
+ /* Since many 16-bit compilers don't like 32-bit enumerations, you */
+ /* should redefine this macro in case of problems to something like */
+ /* this: */
+ /* */
+ /* { */
+ /* #define FT_ENC_TAG( value, a, b, c, d ) value */
+ /* } */
+ /* */
+ /* to get a simple enumeration without assigning special numbers. */
+ /* */
+
+#ifndef FT_ENC_TAG
+#define FT_ENC_TAG( value, a, b, c, d ) \
+ value = ( ( (FT_UInt32)(a) << 24 ) | \
+ ( (FT_UInt32)(b) << 16 ) | \
+ ( (FT_UInt32)(c) << 8 ) | \
+ (FT_UInt32)(d) )
+
+#endif /* FT_ENC_TAG */
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_Encoding */
+ /* */
+ /* <Description> */
+ /* An enumeration used to specify character sets supported by */
+ /* charmaps. Used in the @FT_Select_Charmap API function. */
+ /* */
+ /* <Note> */
+ /* Despite the name, this enumeration lists specific character */
+ /* repertories (i.e., charsets), and not text encoding methods (e.g., */
+ /* UTF-8, UTF-16, etc.). */
+ /* */
+ /* Other encodings might be defined in the future. */
+ /* */
+ /* <Values> */
+ /* FT_ENCODING_NONE :: */
+ /* The encoding value~0 is reserved. */
+ /* */
+ /* FT_ENCODING_UNICODE :: */
+ /* Corresponds to the Unicode character set. This value covers */
+ /* all versions of the Unicode repertoire, including ASCII and */
+ /* Latin-1. Most fonts include a Unicode charmap, but not all */
+ /* of them. */
+ /* */
+ /* For example, if you want to access Unicode value U+1F028 (and */
+ /* the font contains it), use value 0x1F028 as the input value for */
+ /* @FT_Get_Char_Index. */
+ /* */
+ /* FT_ENCODING_MS_SYMBOL :: */
+ /* Corresponds to the Microsoft Symbol encoding, used to encode */
+ /* mathematical symbols in the 32..255 character code range. For */
+ /* more information, see `http://www.ceviz.net/symbol.htm'. */
+ /* */
+ /* FT_ENCODING_SJIS :: */
+ /* Corresponds to Japanese SJIS encoding. More info at */
+ /* at `http://langsupport.japanreference.com/encoding.shtml'. */
+ /* See note on multi-byte encodings below. */
+ /* */
+ /* FT_ENCODING_GB2312 :: */
+ /* Corresponds to an encoding system for Simplified Chinese as used */
+ /* used in mainland China. */
+ /* */
+ /* FT_ENCODING_BIG5 :: */
+ /* Corresponds to an encoding system for Traditional Chinese as */
+ /* used in Taiwan and Hong Kong. */
+ /* */
+ /* FT_ENCODING_WANSUNG :: */
+ /* Corresponds to the Korean encoding system known as Wansung. */
+ /* For more information see */
+ /* `http://www.microsoft.com/typography/unicode/949.txt'. */
+ /* */
+ /* FT_ENCODING_JOHAB :: */
+ /* The Korean standard character set (KS~C 5601-1992), which */
+ /* corresponds to MS Windows code page 1361. This character set */
+ /* includes all possible Hangeul character combinations. */
+ /* */
+ /* FT_ENCODING_ADOBE_LATIN_1 :: */
+ /* Corresponds to a Latin-1 encoding as defined in a Type~1 */
+ /* PostScript font. It is limited to 256 character codes. */
+ /* */
+ /* FT_ENCODING_ADOBE_STANDARD :: */
+ /* Corresponds to the Adobe Standard encoding, as found in Type~1, */
+ /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
+ /* codes. */
+ /* */
+ /* FT_ENCODING_ADOBE_EXPERT :: */
+ /* Corresponds to the Adobe Expert encoding, as found in Type~1, */
+ /* CFF, and OpenType/CFF fonts. It is limited to 256 character */
+ /* codes. */
+ /* */
+ /* FT_ENCODING_ADOBE_CUSTOM :: */
+ /* Corresponds to a custom encoding, as found in Type~1, CFF, and */
+ /* OpenType/CFF fonts. It is limited to 256 character codes. */
+ /* */
+ /* FT_ENCODING_APPLE_ROMAN :: */
+ /* Corresponds to the 8-bit Apple roman encoding. Many TrueType */
+ /* and OpenType fonts contain a charmap for this encoding, since */
+ /* older versions of Mac OS are able to use it. */
+ /* */
+ /* FT_ENCODING_OLD_LATIN_2 :: */
+ /* This value is deprecated and was never used nor reported by */
+ /* FreeType. Don't use or test for it. */
+ /* */
+ /* FT_ENCODING_MS_SJIS :: */
+ /* Same as FT_ENCODING_SJIS. Deprecated. */
+ /* */
+ /* FT_ENCODING_MS_GB2312 :: */
+ /* Same as FT_ENCODING_GB2312. Deprecated. */
+ /* */
+ /* FT_ENCODING_MS_BIG5 :: */
+ /* Same as FT_ENCODING_BIG5. Deprecated. */
+ /* */
+ /* FT_ENCODING_MS_WANSUNG :: */
+ /* Same as FT_ENCODING_WANSUNG. Deprecated. */
+ /* */
+ /* FT_ENCODING_MS_JOHAB :: */
+ /* Same as FT_ENCODING_JOHAB. Deprecated. */
+ /* */
+ /* <Note> */
+ /* By default, FreeType automatically synthesizes a Unicode charmap */
+ /* for PostScript fonts, using their glyph names dictionaries. */
+ /* However, it also reports the encodings defined explicitly in the */
+ /* font file, for the cases when they are needed, with the Adobe */
+ /* values as well. */
+ /* */
+ /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */
+ /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */
+ /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */
+ /* which encoding is really present. If, for example, the */
+ /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */
+ /* the font is encoded in KOI8-R. */
+ /* */
+ /* FT_ENCODING_NONE is always set (with a single exception) by the */
+ /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */
+ /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */
+ /* which encoding is really present. For example, */
+ /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */
+ /* Russian). */
+ /* */
+ /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */
+ /* and `encoding_id' is not @TT_MAC_ID_ROMAN (otherwise it is set to */
+ /* FT_ENCODING_APPLE_ROMAN). */
+ /* */
+ /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */
+ /* @FT_Get_CMap_Language_ID to query the Mac language ID which may */
+ /* be needed to be able to distinguish Apple encoding variants. See */
+ /* */
+ /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/README.TXT */
+ /* */
+ /* to get an idea how to do that. Basically, if the language ID */
+ /* is~0, don't use it, otherwise subtract 1 from the language ID. */
+ /* Then examine `encoding_id'. If, for example, `encoding_id' is */
+ /* @TT_MAC_ID_ROMAN and the language ID (minus~1) is */
+ /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
+ /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */
+ /* variant the Arabic encoding. */
+ /* */
+ typedef enum FT_Encoding_
+ {
+ FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
+
+ FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
+ FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
+
+ FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
+ FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ),
+ FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
+ FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
+ FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
+
+ /* for backwards compatibility */
+ FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
+ FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312,
+ FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
+ FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
+ FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
+
+ FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
+ FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
+ FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
+ FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
+
+ FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
+
+ FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
+
+ } FT_Encoding;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* ft_encoding_xxx */
+ /* */
+ /* <Description> */
+ /* These constants are deprecated; use the corresponding @FT_Encoding */
+ /* values instead. */
+ /* */
+#define ft_encoding_none FT_ENCODING_NONE
+#define ft_encoding_unicode FT_ENCODING_UNICODE
+#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
+#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
+#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
+#define ft_encoding_sjis FT_ENCODING_SJIS
+#define ft_encoding_gb2312 FT_ENCODING_GB2312
+#define ft_encoding_big5 FT_ENCODING_BIG5
+#define ft_encoding_wansung FT_ENCODING_WANSUNG
+#define ft_encoding_johab FT_ENCODING_JOHAB
+
+#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
+#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
+#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
+#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_CharMapRec */
+ /* */
+ /* <Description> */
+ /* The base charmap structure. */
+ /* */
+ /* <Fields> */
+ /* face :: A handle to the parent face object. */
+ /* */
+ /* encoding :: An @FT_Encoding tag identifying the charmap. Use */
+ /* this with @FT_Select_Charmap. */
+ /* */
+ /* platform_id :: An ID number describing the platform for the */
+ /* following encoding ID. This comes directly from */
+ /* the TrueType specification and should be emulated */
+ /* for other formats. */
+ /* */
+ /* encoding_id :: A platform specific encoding number. This also */
+ /* comes from the TrueType specification and should be */
+ /* emulated similarly. */
+ /* */
+ typedef struct FT_CharMapRec_
+ {
+ FT_Face face;
+ FT_Encoding encoding;
+ FT_UShort platform_id;
+ FT_UShort encoding_id;
+
+ } FT_CharMapRec;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* B A S E O B J E C T C L A S S E S */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Face_Internal */
+ /* */
+ /* <Description> */
+ /* An opaque handle to an `FT_Face_InternalRec' structure, used to */
+ /* model private data of a given @FT_Face object. */
+ /* */
+ /* This structure might change between releases of FreeType~2 and is */
+ /* not generally available to client applications. */
+ /* */
+ typedef struct FT_Face_InternalRec_* FT_Face_Internal;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_FaceRec */
+ /* */
+ /* <Description> */
+ /* FreeType root face class structure. A face object models a */
+ /* typeface in a font file. */
+ /* */
+ /* <Fields> */
+ /* num_faces :: The number of faces in the font file. Some */
+ /* font formats can have multiple faces in */
+ /* a font file. */
+ /* */
+ /* face_index :: The index of the face in the font file. It */
+ /* is set to~0 if there is only one face in */
+ /* the font file. */
+ /* */
+ /* face_flags :: A set of bit flags that give important */
+ /* information about the face; see */
+ /* @FT_FACE_FLAG_XXX for the details. */
+ /* */
+ /* style_flags :: A set of bit flags indicating the style of */
+ /* the face; see @FT_STYLE_FLAG_XXX for the */
+ /* details. */
+ /* */
+ /* num_glyphs :: The number of glyphs in the face. If the */
+ /* face is scalable and has sbits (see */
+ /* `num_fixed_sizes'), it is set to the number */
+ /* of outline glyphs. */
+ /* */
+ /* For CID-keyed fonts, this value gives the */
+ /* highest CID used in the font. */
+ /* */
+ /* family_name :: The face's family name. This is an ASCII */
+ /* string, usually in English, which describes */
+ /* the typeface's family (like `Times New */
+ /* Roman', `Bodoni', `Garamond', etc). This */
+ /* is a least common denominator used to list */
+ /* fonts. Some formats (TrueType & OpenType) */
+ /* provide localized and Unicode versions of */
+ /* this string. Applications should use the */
+ /* format specific interface to access them. */
+ /* Can be NULL (e.g., in fonts embedded in a */
+ /* PDF file). */
+ /* */
+ /* style_name :: The face's style name. This is an ASCII */
+ /* string, usually in English, which describes */
+ /* the typeface's style (like `Italic', */
+ /* `Bold', `Condensed', etc). Not all font */
+ /* formats provide a style name, so this field */
+ /* is optional, and can be set to NULL. As */
+ /* for `family_name', some formats provide */
+ /* localized and Unicode versions of this */
+ /* string. Applications should use the format */
+ /* specific interface to access them. */
+ /* */
+ /* num_fixed_sizes :: The number of bitmap strikes in the face. */
+ /* Even if the face is scalable, there might */
+ /* still be bitmap strikes, which are called */
+ /* `sbits' in that case. */
+ /* */
+ /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */
+ /* strikes in the face. It is set to NULL if */
+ /* there is no bitmap strike. */
+ /* */
+ /* num_charmaps :: The number of charmaps in the face. */
+ /* */
+ /* charmaps :: An array of the charmaps of the face. */
+ /* */
+ /* generic :: A field reserved for client uses. See the */
+ /* @FT_Generic type description. */
+ /* */
+ /* bbox :: The font bounding box. Coordinates are */
+ /* expressed in font units (see */
+ /* `units_per_EM'). The box is large enough */
+ /* to contain any glyph from the font. Thus, */
+ /* `bbox.yMax' can be seen as the `maximum */
+ /* ascender', and `bbox.yMin' as the `minimum */
+ /* descender'. Only relevant for scalable */
+ /* formats. */
+ /* */
+ /* Note that the bounding box might be off by */
+ /* (at least) one pixel for hinted fonts. See */
+ /* @FT_Size_Metrics for further discussion. */
+ /* */
+ /* units_per_EM :: The number of font units per EM square for */
+ /* this face. This is typically 2048 for */
+ /* TrueType fonts, and 1000 for Type~1 fonts. */
+ /* Only relevant for scalable formats. */
+ /* */
+ /* ascender :: The typographic ascender of the face, */
+ /* expressed in font units. For font formats */
+ /* not having this information, it is set to */
+ /* `bbox.yMax'. Only relevant for scalable */
+ /* formats. */
+ /* */
+ /* descender :: The typographic descender of the face, */
+ /* expressed in font units. For font formats */
+ /* not having this information, it is set to */
+ /* `bbox.yMin'. Note that this field is */
+ /* usually negative. Only relevant for */
+ /* scalable formats. */
+ /* */
+ /* height :: This value is the vertical distance */
+ /* between two consecutive baselines, */
+ /* expressed in font units. It is always */
+ /* positive. Only relevant for scalable */
+ /* formats. */
+ /* */
+ /* If you want the global glyph height, use */
+ /* `ascender - descender'. */
+ /* */
+ /* max_advance_width :: The maximum advance width, in font units, */
+ /* for all glyphs in this face. This can be */
+ /* used to make word wrapping computations */
+ /* faster. Only relevant for scalable */
+ /* formats. */
+ /* */
+ /* max_advance_height :: The maximum advance height, in font units, */
+ /* for all glyphs in this face. This is only */
+ /* relevant for vertical layouts, and is set */
+ /* to `height' for fonts that do not provide */
+ /* vertical metrics. Only relevant for */
+ /* scalable formats. */
+ /* */
+ /* underline_position :: The position, in font units, of the */
+ /* underline line for this face. It is the */
+ /* center of the underlining stem. Only */
+ /* relevant for scalable formats. */
+ /* */
+ /* underline_thickness :: The thickness, in font units, of the */
+ /* underline for this face. Only relevant for */
+ /* scalable formats. */
+ /* */
+ /* glyph :: The face's associated glyph slot(s). */
+ /* */
+ /* size :: The current active size for this face. */
+ /* */
+ /* charmap :: The current active charmap for this face. */
+ /* */
+ /* <Note> */
+ /* Fields may be changed after a call to @FT_Attach_File or */
+ /* @FT_Attach_Stream. */
+ /* */
+ typedef struct FT_FaceRec_
+ {
+ FT_Long num_faces;
+ FT_Long face_index;
+
+ FT_Long face_flags;
+ FT_Long style_flags;
+
+ FT_Long num_glyphs;
+
+ FT_String* family_name;
+ FT_String* style_name;
+
+ FT_Int num_fixed_sizes;
+ FT_Bitmap_Size* available_sizes;
+
+ FT_Int num_charmaps;
+ FT_CharMap* charmaps;
+
+#ifdef _FX_MANAGED_CODE_
+#define generic generic_data
+#endif
+
+ FT_Generic generic;
+
+ /*# The following member variables (down to `underline_thickness') */
+ /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
+ /*# for bitmap fonts. */
+ FT_BBox bbox;
+
+ FT_UShort units_per_EM;
+ FT_Short ascender;
+ FT_Short descender;
+ FT_Short height;
+
+ FT_Short max_advance_width;
+ FT_Short max_advance_height;
+
+ FT_Short underline_position;
+ FT_Short underline_thickness;
+
+ FT_GlyphSlot glyph;
+ FT_Size size;
+ FT_CharMap charmap;
+
+ /*@private begin */
+
+ FT_Driver driver;
+ FT_Memory memory;
+ FT_Stream stream;
+
+ FT_ListRec sizes_list;
+
+ FT_Generic autohint; /* face-specific auto-hinter data */
+ void* extensions; /* unused */
+
+ FT_Face_Internal internal;
+
+ /*@private end */
+
+ } FT_FaceRec;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_FACE_FLAG_XXX */
+ /* */
+ /* <Description> */
+ /* A list of bit flags used in the `face_flags' field of the */
+ /* @FT_FaceRec structure. They inform client applications of */
+ /* properties of the corresponding face. */
+ /* */
+ /* <Values> */
+ /* FT_FACE_FLAG_SCALABLE :: */
+ /* Indicates that the face contains outline glyphs. This doesn't */
+ /* prevent bitmap strikes, i.e., a face can have both this and */
+ /* and @FT_FACE_FLAG_FIXED_SIZES set. */
+ /* */
+ /* FT_FACE_FLAG_FIXED_SIZES :: */
+ /* Indicates that the face contains bitmap strikes. See also the */
+ /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */
+ /* */
+ /* FT_FACE_FLAG_FIXED_WIDTH :: */
+ /* Indicates that the face contains fixed-width characters (like */
+ /* Courier, Lucido, MonoType, etc.). */
+ /* */
+ /* FT_FACE_FLAG_SFNT :: */
+ /* Indicates that the face uses the `sfnt' storage scheme. For */
+ /* now, this means TrueType and OpenType. */
+ /* */
+ /* FT_FACE_FLAG_HORIZONTAL :: */
+ /* Indicates that the face contains horizontal glyph metrics. This */
+ /* should be set for all common formats. */
+ /* */
+ /* FT_FACE_FLAG_VERTICAL :: */
+ /* Indicates that the face contains vertical glyph metrics. This */
+ /* is only available in some formats, not all of them. */
+ /* */
+ /* FT_FACE_FLAG_KERNING :: */
+ /* Indicates that the face contains kerning information. If set, */
+ /* the kerning distance can be retrieved through the function */
+ /* @FT_Get_Kerning. Otherwise the function always return the */
+ /* vector (0,0). Note that FreeType doesn't handle kerning data */
+ /* from the `GPOS' table (as present in some OpenType fonts). */
+ /* */
+ /* FT_FACE_FLAG_FAST_GLYPHS :: */
+ /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */
+ /* */
+ /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */
+ /* Indicates that the font contains multiple masters and is capable */
+ /* of interpolating between them. See the multiple-masters */
+ /* specific API for details. */
+ /* */
+ /* FT_FACE_FLAG_GLYPH_NAMES :: */
+ /* Indicates that the font contains glyph names that can be */
+ /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */
+ /* fonts contain broken glyph name tables. Use the function */
+ /* @FT_Has_PS_Glyph_Names when needed. */
+ /* */
+ /* FT_FACE_FLAG_EXTERNAL_STREAM :: */
+ /* Used internally by FreeType to indicate that a face's stream was */
+ /* provided by the client application and should not be destroyed */
+ /* when @FT_Done_Face is called. Don't read or test this flag. */
+ /* */
+ /* FT_FACE_FLAG_HINTER :: */
+ /* Set if the font driver has a hinting machine of its own. For */
+ /* example, with TrueType fonts, it makes sense to use data from */
+ /* the SFNT `gasp' table only if the native TrueType hinting engine */
+ /* (with the bytecode interpreter) is available and active. */
+ /* */
+ /* FT_FACE_FLAG_CID_KEYED :: */
+ /* Set if the font is CID-keyed. In that case, the font is not */
+ /* accessed by glyph indices but by CID values. For subsetted */
+ /* CID-keyed fonts this has the consequence that not all index */
+ /* values are a valid argument to FT_Load_Glyph. Only the CID */
+ /* values for which corresponding glyphs in the subsetted font */
+ /* exist make FT_Load_Glyph return successfully; in all other cases */
+ /* you get an `FT_Err_Invalid_Argument' error. */
+ /* */
+ /* Note that CID-keyed fonts which are in an SFNT wrapper don't */
+ /* have this flag set since the glyphs are accessed in the normal */
+ /* way (using contiguous indices); the `CID-ness' isn't visible to */
+ /* the application. */
+ /* */
+ /* FT_FACE_FLAG_TRICKY :: */
+ /* Set if the font is `tricky', this is, it always needs the */
+ /* font format's native hinting engine to get a reasonable result. */
+ /* A typical example is the Chinese font `mingli.ttf' which uses */
+ /* TrueType bytecode instructions to move and scale all of its */
+ /* subglyphs. */
+ /* */
+ /* It is not possible to autohint such fonts using */
+ /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */
+ /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */
+ /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */
+ /* probably never want this except for demonstration purposes. */
+ /* */
+ /* Currently, there are about a dozen TrueType fonts in the list of */
+ /* tricky fonts; they are hard-coded in file `ttobjs.c'. */
+ /* */
+#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
+#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
+#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
+#define FT_FACE_FLAG_SFNT ( 1L << 3 )
+#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
+#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
+#define FT_FACE_FLAG_KERNING ( 1L << 6 )
+#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
+#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
+#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
+#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
+#define FT_FACE_FLAG_HINTER ( 1L << 11 )
+#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
+#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_HAS_HORIZONTAL( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains
+ * horizontal metrics (this is true for all font formats though).
+ *
+ * @also:
+ * @FT_HAS_VERTICAL can be used to check for vertical metrics.
+ *
+ */
+#define FT_HAS_HORIZONTAL( face ) \
+ ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_HAS_VERTICAL( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains real
+ * vertical metrics (and not only synthesized ones).
+ *
+ */
+#define FT_HAS_VERTICAL( face ) \
+ ( face->face_flags & FT_FACE_FLAG_VERTICAL )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_HAS_KERNING( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains kerning
+ * data that can be accessed with @FT_Get_Kerning.
+ *
+ */
+#define FT_HAS_KERNING( face ) \
+ ( face->face_flags & FT_FACE_FLAG_KERNING )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_IS_SCALABLE( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a scalable
+ * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF,
+ * and PFR font formats.
+ *
+ */
+#define FT_IS_SCALABLE( face ) \
+ ( face->face_flags & FT_FACE_FLAG_SCALABLE )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_IS_SFNT( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a font
+ * whose format is based on the SFNT storage scheme. This usually
+ * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded
+ * bitmap fonts.
+ *
+ * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
+ * @FT_TRUETYPE_TABLES_H are available.
+ *
+ */
+#define FT_IS_SFNT( face ) \
+ ( face->face_flags & FT_FACE_FLAG_SFNT )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_IS_FIXED_WIDTH( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a font face
+ * that contains fixed-width (or `monospace', `fixed-pitch', etc.)
+ * glyphs.
+ *
+ */
+#define FT_IS_FIXED_WIDTH( face ) \
+ ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_HAS_FIXED_SIZES( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains some
+ * embedded bitmaps. See the `available_sizes' field of the
+ * @FT_FaceRec structure.
+ *
+ */
+#define FT_HAS_FIXED_SIZES( face ) \
+ ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_HAS_FAST_GLYPHS( face )
+ *
+ * @description:
+ * Deprecated.
+ *
+ */
+#define FT_HAS_FAST_GLYPHS( face ) 0
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_HAS_GLYPH_NAMES( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains some glyph
+ * names that can be accessed through @FT_Get_Glyph_Name.
+ *
+ */
+#define FT_HAS_GLYPH_NAMES( face ) \
+ ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_HAS_MULTIPLE_MASTERS( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains some
+ * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
+ * are then available to choose the exact design you want.
+ *
+ */
+#define FT_HAS_MULTIPLE_MASTERS( face ) \
+ ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_IS_CID_KEYED( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face object contains a CID-keyed
+ * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more
+ * details.
+ *
+ * If this macro is true, all functions defined in @FT_CID_H are
+ * available.
+ *
+ */
+#define FT_IS_CID_KEYED( face ) \
+ ( face->face_flags & FT_FACE_FLAG_CID_KEYED )
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_IS_TRICKY( face )
+ *
+ * @description:
+ * A macro that returns true whenever a face represents a `tricky' font.
+ * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
+ *
+ */
+#define FT_IS_TRICKY( face ) \
+ ( face->face_flags & FT_FACE_FLAG_TRICKY )
+
+
+ /*************************************************************************/
+ /* */
+ /* <Const> */
+ /* FT_STYLE_FLAG_XXX */
+ /* */
+ /* <Description> */
+ /* A list of bit-flags used to indicate the style of a given face. */
+ /* These are used in the `style_flags' field of @FT_FaceRec. */
+ /* */
+ /* <Values> */
+ /* FT_STYLE_FLAG_ITALIC :: */
+ /* Indicates that a given face style is italic or oblique. */
+ /* */
+ /* FT_STYLE_FLAG_BOLD :: */
+ /* Indicates that a given face is bold. */
+ /* */
+ /* <Note> */
+ /* The style information as provided by FreeType is very basic. More */
+ /* details are beyond the scope and should be done on a higher level */
+ /* (for example, by analyzing various fields of the `OS/2' table in */
+ /* SFNT based fonts). */
+ /* */
+#define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
+#define FT_STYLE_FLAG_BOLD ( 1 << 1 )
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Size_Internal */
+ /* */
+ /* <Description> */
+ /* An opaque handle to an `FT_Size_InternalRec' structure, used to */
+ /* model private data of a given @FT_Size object. */
+ /* */
+ typedef struct FT_Size_InternalRec_* FT_Size_Internal;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Size_Metrics */
+ /* */
+ /* <Description> */
+ /* The size metrics structure gives the metrics of a size object. */
+ /* */
+ /* <Fields> */
+ /* x_ppem :: The width of the scaled EM square in pixels, hence */
+ /* the term `ppem' (pixels per EM). It is also */
+ /* referred to as `nominal width'. */
+ /* */
+ /* y_ppem :: The height of the scaled EM square in pixels, */
+ /* hence the term `ppem' (pixels per EM). It is also */
+ /* referred to as `nominal height'. */
+ /* */
+ /* x_scale :: A 16.16 fractional scaling value used to convert */
+ /* horizontal metrics from font units to 26.6 */
+ /* fractional pixels. Only relevant for scalable */
+ /* font formats. */
+ /* */
+ /* y_scale :: A 16.16 fractional scaling value used to convert */
+ /* vertical metrics from font units to 26.6 */
+ /* fractional pixels. Only relevant for scalable */
+ /* font formats. */
+ /* */
+ /* ascender :: The ascender in 26.6 fractional pixels. See */
+ /* @FT_FaceRec for the details. */
+ /* */
+ /* descender :: The descender in 26.6 fractional pixels. See */
+ /* @FT_FaceRec for the details. */
+ /* */
+ /* height :: The height in 26.6 fractional pixels. See */
+ /* @FT_FaceRec for the details. */
+ /* */
+ /* max_advance :: The maximum advance width in 26.6 fractional */
+ /* pixels. See @FT_FaceRec for the details. */
+ /* */
+ /* <Note> */
+ /* The scaling values, if relevant, are determined first during a */
+ /* size changing operation. The remaining fields are then set by the */
+ /* driver. For scalable formats, they are usually set to scaled */
+ /* values of the corresponding fields in @FT_FaceRec. */
+ /* */
+ /* Note that due to glyph hinting, these values might not be exact */
+ /* for certain fonts. Thus they must be treated as unreliable */
+ /* with an error margin of at least one pixel! */
+ /* */
+ /* Indeed, the only way to get the exact metrics is to render _all_ */
+ /* glyphs. As this would be a definite performance hit, it is up to */
+ /* client applications to perform such computations. */
+ /* */
+ /* The FT_Size_Metrics structure is valid for bitmap fonts also. */
+ /* */
+ typedef struct FT_Size_Metrics_
+ {
+ FT_UShort x_ppem; /* horizontal pixels per EM */
+ FT_UShort y_ppem; /* vertical pixels per EM */
+
+ FT_Fixed x_scale; /* scaling values used to convert font */
+ FT_Fixed y_scale; /* units to 26.6 fractional pixels */
+
+ FT_Pos ascender; /* ascender in 26.6 frac. pixels */
+ FT_Pos descender; /* descender in 26.6 frac. pixels */
+ FT_Pos height; /* text height in 26.6 frac. pixels */
+ FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
+
+ } FT_Size_Metrics;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_SizeRec */
+ /* */
+ /* <Description> */
+ /* FreeType root size class structure. A size object models a face */
+ /* object at a given size. */
+ /* */
+ /* <Fields> */
+ /* face :: Handle to the parent face object. */
+ /* */
+ /* generic :: A typeless pointer, which is unused by the FreeType */
+ /* library or any of its drivers. It can be used by */
+ /* client applications to link their own data to each size */
+ /* object. */
+ /* */
+ /* metrics :: Metrics for this size object. This field is read-only. */
+ /* */
+ typedef struct FT_SizeRec_
+ {
+ FT_Face face; /* parent face object */
+ FT_Generic generic; /* generic pointer for client uses */
+ FT_Size_Metrics metrics; /* size metrics */
+ FT_Size_Internal internal;
+
+ } FT_SizeRec;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_SubGlyph */
+ /* */
+ /* <Description> */
+ /* The subglyph structure is an internal object used to describe */
+ /* subglyphs (for example, in the case of composites). */
+ /* */
+ /* <Note> */
+ /* The subglyph implementation is not part of the high-level API, */
+ /* hence the forward structure declaration. */
+ /* */
+ /* You can however retrieve subglyph information with */
+ /* @FT_Get_SubGlyph_Info. */
+ /* */
+ typedef struct FT_SubGlyphRec_* FT_SubGlyph;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FT_Slot_Internal */
+ /* */
+ /* <Description> */
+ /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */
+ /* model private data of a given @FT_GlyphSlot object. */
+ /* */
+ typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_GlyphSlotRec */
+ /* */
+ /* <Description> */
+ /* FreeType root glyph slot class structure. A glyph slot is a */
+ /* container where individual glyphs can be loaded, be they in */
+ /* outline or bitmap format. */
+ /* */
+ /* <Fields> */
+ /* library :: A handle to the FreeType library instance */
+ /* this slot belongs to. */
+ /* */
+ /* face :: A handle to the parent face object. */
+ /* */
+ /* next :: In some cases (like some font tools), several */
+ /* glyph slots per face object can be a good */
+ /* thing. As this is rare, the glyph slots are */
+ /* listed through a direct, single-linked list */
+ /* using its `next' field. */
+ /* */
+ /* generic :: A typeless pointer which is unused by the */
+ /* FreeType library or any of its drivers. It */
+ /* can be used by client applications to link */
+ /* their own data to each glyph slot object. */
+ /* */
+ /* metrics :: The metrics of the last loaded glyph in the */
+ /* slot. The returned values depend on the last */
+ /* load flags (see the @FT_Load_Glyph API */
+ /* function) and can be expressed either in 26.6 */
+ /* fractional pixels or font units. */
+ /* */
+ /* Note that even when the glyph image is */
+ /* transformed, the metrics are not. */
+ /* */
+ /* linearHoriAdvance :: The advance width of the unhinted glyph. */
+ /* Its value is expressed in 16.16 fractional */
+ /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
+ /* when loading the glyph. This field can be */
+ /* important to perform correct WYSIWYG layout. */
+ /* Only relevant for outline glyphs. */
+ /* */
+ /* linearVertAdvance :: The advance height of the unhinted glyph. */
+ /* Its value is expressed in 16.16 fractional */
+ /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
+ /* when loading the glyph. This field can be */
+ /* important to perform correct WYSIWYG layout. */
+ /* Only relevant for outline glyphs. */
+ /* */
+ /* advance :: This shorthand is, depending on */
+ /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */
+ /* advance width for the glyph (in 26.6 */
+ /* fractional pixel format). As specified with */
+ /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */
+ /* `horiAdvance' or the `vertAdvance' value of */
+ /* `metrics' field. */
+ /* */
+ /* format :: This field indicates the format of the image */
+ /* contained in the glyph slot. Typically */
+ /* @FT_GLYPH_FORMAT_BITMAP, */
+ /* @FT_GLYPH_FORMAT_OUTLINE, or */
+ /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */
+ /* possible. */
+ /* */
+ /* bitmap :: This field is used as a bitmap descriptor */
+ /* when the slot format is */
+ /* @FT_GLYPH_FORMAT_BITMAP. Note that the */
+ /* address and content of the bitmap buffer can */
+ /* change between calls of @FT_Load_Glyph and a */
+ /* few other functions. */
+ /* */
+ /* bitmap_left :: This is the bitmap's left bearing expressed */
+ /* in integer pixels. Of course, this is only */
+ /* valid if the format is */
+ /* @FT_GLYPH_FORMAT_BITMAP. */
+ /* */
+ /* bitmap_top :: This is the bitmap's top bearing expressed in */
+ /* integer pixels. Remember that this is the */
+ /* distance from the baseline to the top-most */
+ /* glyph scanline, upwards y~coordinates being */
+ /* *positive*. */
+ /* */
+ /* outline :: The outline descriptor for the current glyph */
+ /* image if its format is */
+ /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */
+ /* loaded, `outline' can be transformed, */
+ /* distorted, embolded, etc. However, it must */
+ /* not be freed. */
+ /* */
+ /* num_subglyphs :: The number of subglyphs in a composite glyph. */
+ /* This field is only valid for the composite */
+ /* glyph format that should normally only be */
+ /* loaded with the @FT_LOAD_NO_RECURSE flag. */
+ /* For now this is internal to FreeType. */
+ /* */
+ /* subglyphs :: An array of subglyph descriptors for */
+ /* composite glyphs. There are `num_subglyphs' */
+ /* elements in there. Currently internal to */
+ /* FreeType. */
+ /* */
+ /* control_data :: Certain font drivers can also return the */
+ /* control data for a given glyph image (e.g. */
+ /* TrueType bytecode, Type~1 charstrings, etc.). */
+ /* This field is a pointer to such data. */
+ /* */
+ /* control_len :: This is the length in bytes of the control */
+ /* data. */
+ /* */
+ /* other :: Really wicked formats can use this pointer to */
+ /* present their own glyph image to client */
+ /* applications. Note that the application */
+ /* needs to know about the image format. */
+ /* */
+ /* lsb_delta :: The difference between hinted and unhinted */
+ /* left side bearing while autohinting is */
+ /* active. Zero otherwise. */
+ /* */
+ /* rsb_delta :: The difference between hinted and unhinted */
+ /* right side bearing while autohinting is */
+ /* active. Zero otherwise. */
+ /* */
+ /* <Note> */
+ /* If @FT_Load_Glyph is called with default flags (see */
+ /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
+ /* its native format (e.g., an outline glyph for TrueType and Type~1 */
+ /* formats). */
+ /* */
+ /* This image can later be converted into a bitmap by calling */
+ /* @FT_Render_Glyph. This function finds the current renderer for */
+ /* the native image's format, then invokes it. */
+ /* */
+ /* The renderer is in charge of transforming the native image through */
+ /* the slot's face transformation fields, then converting it into a */
+ /* bitmap that is returned in `slot->bitmap'. */
+ /* */
+ /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
+ /* to specify the position of the bitmap relative to the current pen */
+ /* position (e.g., coordinates (0,0) on the baseline). Of course, */
+ /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */
+ /* */
+ /* <Note> */
+ /* Here a small pseudo code fragment which shows how to use */
+ /* `lsb_delta' and `rsb_delta': */
+ /* */
+ /* { */
+ /* FT_Pos origin_x = 0; */
+ /* FT_Pos prev_rsb_delta = 0; */
+ /* */
+ /* */
+ /* for all glyphs do */
+ /* <compute kern between current and previous glyph and add it to */
+ /* `origin_x'> */
+ /* */
+ /* <load glyph with `FT_Load_Glyph'> */
+ /* */
+ /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */
+ /* origin_x -= 64; */
+ /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */
+ /* origin_x += 64; */
+ /* */
+ /* prev_rsb_delta = face->glyph->rsb_delta; */
+ /* */
+ /* <save glyph image, or render glyph, or ...> */
+ /* */
+ /* origin_x += face->glyph->advance.x; */
+ /* endfor */
+ /* } */
+ /* */
+ typedef struct FT_GlyphSlotRec_
+ {
+ FT_Library library;
+ FT_Face face;
+ FT_GlyphSlot next;
+ FT_UInt reserved; /* retained for binary compatibility */
+ FT_Generic generic;
+
+ FT_Glyph_Metrics metrics;
+ FT_Fixed linearHoriAdvance;
+ FT_Fixed linearVertAdvance;
+ FT_Vector advance;
+
+ FT_Glyph_Format format;
+
+ FT_Bitmap bitmap;
+ FT_Int bitmap_left;
+ FT_Int bitmap_top;
+
+ FT_Outline outline;
+
+ FT_UInt num_subglyphs;
+ FT_SubGlyph subglyphs;
+
+ void* control_data;
+ long control_len;
+
+ FT_Pos lsb_delta;
+ FT_Pos rsb_delta;
+
+ void* other;
+
+ FT_Slot_Internal internal;
+
+ } FT_GlyphSlotRec;
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* F U N C T I O N S */
+ /* */
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Init_FreeType */
+ /* */
+ /* <Description> */
+ /* Initialize a new FreeType library object. The set of modules */
+ /* that are registered by this function is determined at build time. */
+ /* */
+ /* <Output> */
+ /* alibrary :: A handle to a new library object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* In case you want to provide your own memory allocating routines, */
+ /* use @FT_New_Library instead, followed by a call to */
+ /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */
+ /* */
+ /* For multi-threading applications each thread should have its own */
+ /* FT_Library object. */
+ /* */
+ /* If you need reference-counting (cf. @FT_Reference_Library), use */
+ /* @FT_New_Library and @FT_Done_Library. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Init_FreeType( FT_Library *alibrary );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Done_FreeType */
+ /* */
+ /* <Description> */
+ /* Destroy a given FreeType library object and all of its children, */
+ /* including resources, drivers, faces, sizes, etc. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to the target library object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Done_FreeType( FT_Library library );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_OPEN_XXX */
+ /* */
+ /* <Description> */
+ /* A list of bit-field constants used within the `flags' field of the */
+ /* @FT_Open_Args structure. */
+ /* */
+ /* <Values> */
+ /* FT_OPEN_MEMORY :: This is a memory-based stream. */
+ /* */
+ /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */
+ /* */
+ /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */
+ /* name. */
+ /* */
+ /* FT_OPEN_DRIVER :: Use the `driver' field. */
+ /* */
+ /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */
+ /* */
+ /* ft_open_memory :: Deprecated; use @FT_OPEN_MEMORY instead. */
+ /* */
+ /* ft_open_stream :: Deprecated; use @FT_OPEN_STREAM instead. */
+ /* */
+ /* ft_open_pathname :: Deprecated; use @FT_OPEN_PATHNAME instead. */
+ /* */
+ /* ft_open_driver :: Deprecated; use @FT_OPEN_DRIVER instead. */
+ /* */
+ /* ft_open_params :: Deprecated; use @FT_OPEN_PARAMS instead. */
+ /* */
+ /* <Note> */
+ /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */
+ /* flags are mutually exclusive. */
+ /* */
+#define FT_OPEN_MEMORY 0x1
+#define FT_OPEN_STREAM 0x2
+#define FT_OPEN_PATHNAME 0x4
+#define FT_OPEN_DRIVER 0x8
+#define FT_OPEN_PARAMS 0x10
+
+#define ft_open_memory FT_OPEN_MEMORY /* deprecated */
+#define ft_open_stream FT_OPEN_STREAM /* deprecated */
+#define ft_open_pathname FT_OPEN_PATHNAME /* deprecated */
+#define ft_open_driver FT_OPEN_DRIVER /* deprecated */
+#define ft_open_params FT_OPEN_PARAMS /* deprecated */
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Parameter */
+ /* */
+ /* <Description> */
+ /* A simple structure used to pass more or less generic parameters to */
+ /* @FT_Open_Face. */
+ /* */
+ /* <Fields> */
+ /* tag :: A four-byte identification tag. */
+ /* */
+ /* data :: A pointer to the parameter data. */
+ /* */
+ /* <Note> */
+ /* The ID and function of parameters are driver-specific. See the */
+ /* various FT_PARAM_TAG_XXX flags for more information. */
+ /* */
+ typedef struct FT_Parameter_
+ {
+ FT_ULong tag;
+ FT_Pointer data;
+
+ } FT_Parameter;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Open_Args */
+ /* */
+ /* <Description> */
+ /* A structure used to indicate how to open a new font file or */
+ /* stream. A pointer to such a structure can be used as a parameter */
+ /* for the functions @FT_Open_Face and @FT_Attach_Stream. */
+ /* */
+ /* <Fields> */
+ /* flags :: A set of bit flags indicating how to use the */
+ /* structure. */
+ /* */
+ /* memory_base :: The first byte of the file in memory. */
+ /* */
+ /* memory_size :: The size in bytes of the file in memory. */
+ /* */
+ /* pathname :: A pointer to an 8-bit file pathname. */
+ /* */
+ /* stream :: A handle to a source stream object. */
+ /* */
+ /* driver :: This field is exclusively used by @FT_Open_Face; */
+ /* it simply specifies the font driver to use to open */
+ /* the face. If set to~0, FreeType tries to load the */
+ /* face with each one of the drivers in its list. */
+ /* */
+ /* num_params :: The number of extra parameters. */
+ /* */
+ /* params :: Extra parameters passed to the font driver when */
+ /* opening a new face. */
+ /* */
+ /* <Note> */
+ /* The stream type is determined by the contents of `flags' which */
+ /* are tested in the following order by @FT_Open_Face: */
+ /* */
+ /* If the `FT_OPEN_MEMORY' bit is set, assume that this is a */
+ /* memory file of `memory_size' bytes, located at `memory_address'. */
+ /* The data are are not copied, and the client is responsible for */
+ /* releasing and destroying them _after_ the corresponding call to */
+ /* @FT_Done_Face. */
+ /* */
+ /* Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a */
+ /* custom input stream `stream' is used. */
+ /* */
+ /* Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this */
+ /* is a normal file and use `pathname' to open it. */
+ /* */
+ /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face only tries to */
+ /* open the file with the driver whose handler is in `driver'. */
+ /* */
+ /* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */
+ /* `num_params' and `params' is used. They are ignored otherwise. */
+ /* */
+ /* Ideally, both the `pathname' and `params' fields should be tagged */
+ /* as `const'; this is missing for API backwards compatibility. In */
+ /* other words, applications should treat them as read-only. */
+ /* */
+ typedef struct FT_Open_Args_
+ {
+ FT_UInt flags;
+ const FT_Byte* memory_base;
+ FT_Long memory_size;
+ FT_String* pathname;
+ FT_Stream stream;
+ FT_Module driver;
+ FT_Int num_params;
+ FT_Parameter* params;
+
+ } FT_Open_Args;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_New_Face */
+ /* */
+ /* <Description> */
+ /* This function calls @FT_Open_Face to open a font by its pathname. */
+ /* */
+ /* <InOut> */
+ /* library :: A handle to the library resource. */
+ /* */
+ /* <Input> */
+ /* pathname :: A path to the font file. */
+ /* */
+ /* face_index :: The index of the face within the font. The first */
+ /* face has index~0. */
+ /* */
+ /* <Output> */
+ /* aface :: A handle to a new face object. If `face_index' is */
+ /* greater than or equal to zero, it must be non-NULL. */
+ /* See @FT_Open_Face for more details. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* Use @FT_Done_Face to destroy the created @FT_Face object (along */
+ /* with its slot and sizes). */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_New_Face( FT_Library library,
+ const char* filepathname,
+ FT_Long face_index,
+ FT_Face *aface );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_New_Memory_Face */
+ /* */
+ /* <Description> */
+ /* This function calls @FT_Open_Face to open a font which has been */
+ /* loaded into memory. */
+ /* */
+ /* <InOut> */
+ /* library :: A handle to the library resource. */
+ /* */
+ /* <Input> */
+ /* file_base :: A pointer to the beginning of the font data. */
+ /* */
+ /* file_size :: The size of the memory chunk used by the font data. */
+ /* */
+ /* face_index :: The index of the face within the font. The first */
+ /* face has index~0. */
+ /* */
+ /* <Output> */
+ /* aface :: A handle to a new face object. If `face_index' is */
+ /* greater than or equal to zero, it must be non-NULL. */
+ /* See @FT_Open_Face for more details. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* You must not deallocate the memory before calling @FT_Done_Face. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_New_Memory_Face( FT_Library library,
+ const FT_Byte* file_base,
+ FT_Long file_size,
+ FT_Long face_index,
+ FT_Face *aface );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Open_Face */
+ /* */
+ /* <Description> */
+ /* Create a face object from a given resource described by */
+ /* @FT_Open_Args. */
+ /* */
+ /* <InOut> */
+ /* library :: A handle to the library resource. */
+ /* */
+ /* <Input> */
+ /* args :: A pointer to an `FT_Open_Args' structure which must */
+ /* be filled by the caller. */
+ /* */
+ /* face_index :: The index of the face within the font. The first */
+ /* face has index~0. */
+ /* */
+ /* <Output> */
+ /* aface :: A handle to a new face object. If `face_index' is */
+ /* greater than or equal to zero, it must be non-NULL. */
+ /* See note below. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* Unlike FreeType 1.x, this function automatically creates a glyph */
+ /* slot for the face object which can be accessed directly through */
+ /* `face->glyph'. */
+ /* */
+ /* FT_Open_Face can be used to quickly check whether the font */
+ /* format of a given font resource is supported by FreeType. If the */
+ /* `face_index' field is negative, the function's return value is~0 */
+ /* if the font format is recognized, or non-zero otherwise; */
+ /* the function returns a more or less empty face handle in `*aface' */
+ /* (if `aface' isn't NULL). The only useful field in this special */
+ /* case is `face->num_faces' which gives the number of faces within */
+ /* the font file. After examination, the returned @FT_Face structure */
+ /* should be deallocated with a call to @FT_Done_Face. */
+ /* */
+ /* Each new face object created with this function also owns a */
+ /* default @FT_Size object, accessible as `face->size'. */
+ /* */
+ /* One @FT_Library instance can have multiple face objects, this is, */
+ /* @FT_Open_Face and its siblings can be called multiple times using */
+ /* the same `library' argument. */
+ /* */
+ /* See the discussion of reference counters in the description of */
+ /* @FT_Reference_Face. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Open_Face( FT_Library library,
+ const FT_Open_Args* args,
+ FT_Long face_index,
+ FT_Face *aface );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Attach_File */
+ /* */
+ /* <Description> */
+ /* This function calls @FT_Attach_Stream to attach a file. */
+ /* */
+ /* <InOut> */
+ /* face :: The target face object. */
+ /* */
+ /* <Input> */
+ /* filepathname :: The pathname. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Attach_File( FT_Face face,
+ const char* filepathname );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Attach_Stream */
+ /* */
+ /* <Description> */
+ /* `Attach' data to a face object. Normally, this is used to read */
+ /* additional information for the face object. For example, you can */
+ /* attach an AFM file that comes with a Type~1 font to get the */
+ /* kerning values and other metrics. */
+ /* */
+ /* <InOut> */
+ /* face :: The target face object. */
+ /* */
+ /* <Input> */
+ /* parameters :: A pointer to @FT_Open_Args which must be filled by */
+ /* the caller. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* The meaning of the `attach' (i.e., what really happens when the */
+ /* new file is read) is not fixed by FreeType itself. It really */
+ /* depends on the font format (and thus the font driver). */
+ /* */
+ /* Client applications are expected to know what they are doing */
+ /* when invoking this function. Most drivers simply do not implement */
+ /* file attachments. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Attach_Stream( FT_Face face,
+ FT_Open_Args* parameters );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Reference_Face */
+ /* */
+ /* <Description> */
+ /* A counter gets initialized to~1 at the time an @FT_Face structure */
+ /* is created. This function increments the counter. @FT_Done_Face */
+ /* then only destroys a face if the counter is~1, otherwise it simply */
+ /* decrements the counter. */
+ /* */
+ /* This function helps in managing life-cycles of structures which */
+ /* reference @FT_Face objects. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to a target face object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Since> */
+ /* 2.4.2 */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Reference_Face( FT_Face face );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Done_Face */
+ /* */
+ /* <Description> */
+ /* Discard a given face object, as well as all of its child slots and */
+ /* sizes. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to a target face object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* See the discussion of reference counters in the description of */
+ /* @FT_Reference_Face. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Done_Face( FT_Face face );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Select_Size */
+ /* */
+ /* <Description> */
+ /* Select a bitmap strike. */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to a target face object. */
+ /* */
+ /* <Input> */
+ /* strike_index :: The index of the bitmap strike in the */
+ /* `available_sizes' field of @FT_FaceRec structure. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Select_Size( FT_Face face,
+ FT_Int strike_index );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_Size_Request_Type */
+ /* */
+ /* <Description> */
+ /* An enumeration type that lists the supported size request types. */
+ /* */
+ /* <Values> */
+ /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */
+ /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */
+ /* used to determine both scaling values. */
+ /* */
+ /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */
+ /* The real dimension. The sum of the the `ascender' and (minus */
+ /* of) the `descender' fields of @FT_FaceRec are used to determine */
+ /* both scaling values. */
+ /* */
+ /* FT_SIZE_REQUEST_TYPE_BBOX :: */
+ /* The font bounding box. The width and height of the `bbox' field */
+ /* of @FT_FaceRec are used to determine the horizontal and vertical */
+ /* scaling value, respectively. */
+ /* */
+ /* FT_SIZE_REQUEST_TYPE_CELL :: */
+ /* The `max_advance_width' field of @FT_FaceRec is used to */
+ /* determine the horizontal scaling value; the vertical scaling */
+ /* value is determined the same way as */
+ /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */
+ /* values are set to the smaller one. This type is useful if you */
+ /* want to specify the font size for, say, a window of a given */
+ /* dimension and 80x24 cells. */
+ /* */
+ /* FT_SIZE_REQUEST_TYPE_SCALES :: */
+ /* Specify the scaling values directly. */
+ /* */
+ /* <Note> */
+ /* The above descriptions only apply to scalable formats. For bitmap */
+ /* formats, the behaviour is up to the driver. */
+ /* */
+ /* See the note section of @FT_Size_Metrics if you wonder how size */
+ /* requesting relates to scaling values. */
+ /* */
+ typedef enum FT_Size_Request_Type_
+ {
+ FT_SIZE_REQUEST_TYPE_NOMINAL,
+ FT_SIZE_REQUEST_TYPE_REAL_DIM,
+ FT_SIZE_REQUEST_TYPE_BBOX,
+ FT_SIZE_REQUEST_TYPE_CELL,
+ FT_SIZE_REQUEST_TYPE_SCALES,
+
+ FT_SIZE_REQUEST_TYPE_MAX
+
+ } FT_Size_Request_Type;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Size_RequestRec */
+ /* */
+ /* <Description> */
+ /* A structure used to model a size request. */
+ /* */
+ /* <Fields> */
+ /* type :: See @FT_Size_Request_Type. */
+ /* */
+ /* width :: The desired width. */
+ /* */
+ /* height :: The desired height. */
+ /* */
+ /* horiResolution :: The horizontal resolution. If set to zero, */
+ /* `width' is treated as a 26.6 fractional pixel */
+ /* value. */
+ /* */
+ /* vertResolution :: The vertical resolution. If set to zero, */
+ /* `height' is treated as a 26.6 fractional pixel */
+ /* value. */
+ /* */
+ /* <Note> */
+ /* If `width' is zero, then the horizontal scaling value is set equal */
+ /* to the vertical scaling value, and vice versa. */
+ /* */
+ typedef struct FT_Size_RequestRec_
+ {
+ FT_Size_Request_Type type;
+ FT_Long width;
+ FT_Long height;
+ FT_UInt horiResolution;
+ FT_UInt vertResolution;
+
+ } FT_Size_RequestRec;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Size_Request */
+ /* */
+ /* <Description> */
+ /* A handle to a size request structure. */
+ /* */
+ typedef struct FT_Size_RequestRec_ *FT_Size_Request;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Request_Size */
+ /* */
+ /* <Description> */
+ /* Resize the scale of the active @FT_Size object in a face. */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to a target face object. */
+ /* */
+ /* <Input> */
+ /* req :: A pointer to a @FT_Size_RequestRec. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* Although drivers may select the bitmap strike matching the */
+ /* request, you should not rely on this if you intend to select a */
+ /* particular bitmap strike. Use @FT_Select_Size instead in that */
+ /* case. */
+ /* */
+ /* The relation between the requested size and the resulting glyph */
+ /* size is dependent entirely on how the size is defined in the */
+ /* source face. The font designer chooses the final size of each */
+ /* glyph relative to this size. For more information refer to */
+ /* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Request_Size( FT_Face face,
+ FT_Size_Request req );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Set_Char_Size */
+ /* */
+ /* <Description> */
+ /* This function calls @FT_Request_Size to request the nominal size */
+ /* (in points). */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to a target face object. */
+ /* */
+ /* <Input> */
+ /* char_width :: The nominal width, in 26.6 fractional points. */
+ /* */
+ /* char_height :: The nominal height, in 26.6 fractional points. */
+ /* */
+ /* horz_resolution :: The horizontal resolution in dpi. */
+ /* */
+ /* vert_resolution :: The vertical resolution in dpi. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* If either the character width or height is zero, it is set equal */
+ /* to the other value. */
+ /* */
+ /* If either the horizontal or vertical resolution is zero, it is set */
+ /* equal to the other value. */
+ /* */
+ /* A character width or height smaller than 1pt is set to 1pt; if */
+ /* both resolution values are zero, they are set to 72dpi. */
+ /* */
+ /* Don't use this function if you are using the FreeType cache API. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Set_Char_Size( FT_Face face,
+ FT_F26Dot6 char_width,
+ FT_F26Dot6 char_height,
+ FT_UInt horz_resolution,
+ FT_UInt vert_resolution );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Set_Pixel_Sizes */
+ /* */
+ /* <Description> */
+ /* This function calls @FT_Request_Size to request the nominal size */
+ /* (in pixels). */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to the target face object. */
+ /* */
+ /* <Input> */
+ /* pixel_width :: The nominal width, in pixels. */
+ /* */
+ /* pixel_height :: The nominal height, in pixels. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* You should not rely on the resulting glyphs matching, or being */
+ /* constrained, to this pixel size. Refer to @FT_Request_Size to */
+ /* understand how requested sizes relate to actual sizes. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Set_Pixel_Sizes( FT_Face face,
+ FT_UInt pixel_width,
+ FT_UInt pixel_height );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Load_Glyph */
+ /* */
+ /* <Description> */
+ /* A function used to load a single glyph into the glyph slot of a */
+ /* face object. */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to the target face object where the glyph */
+ /* is loaded. */
+ /* */
+ /* <Input> */
+ /* glyph_index :: The index of the glyph in the font file. For */
+ /* CID-keyed fonts (either in PS or in CFF format) */
+ /* this argument specifies the CID value. */
+ /* */
+ /* load_flags :: A flag indicating what to load for this glyph. The */
+ /* @FT_LOAD_XXX constants can be used to control the */
+ /* glyph loading process (e.g., whether the outline */
+ /* should be scaled, whether to load bitmaps or not, */
+ /* whether to hint the outline, etc). */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* The loaded glyph may be transformed. See @FT_Set_Transform for */
+ /* the details. */
+ /* */
+ /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */
+ /* returned for invalid CID values (this is, for CID values which */
+ /* don't have a corresponding glyph in the font). See the discussion */
+ /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Load_Glyph( FT_Face face,
+ FT_UInt glyph_index,
+ FT_Int32 load_flags );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Load_Char */
+ /* */
+ /* <Description> */
+ /* A function used to load a single glyph into the glyph slot of a */
+ /* face object, according to its character code. */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to a target face object where the glyph */
+ /* is loaded. */
+ /* */
+ /* <Input> */
+ /* char_code :: The glyph's character code, according to the */
+ /* current charmap used in the face. */
+ /* */
+ /* load_flags :: A flag indicating what to load for this glyph. The */
+ /* @FT_LOAD_XXX constants can be used to control the */
+ /* glyph loading process (e.g., whether the outline */
+ /* should be scaled, whether to load bitmaps or not, */
+ /* whether to hint the outline, etc). */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Load_Char( FT_Face face,
+ FT_ULong char_code,
+ FT_Int32 load_flags );
+
+
+ /*************************************************************************
+ *
+ * @enum:
+ * FT_LOAD_XXX
+ *
+ * @description:
+ * A list of bit-field constants used with @FT_Load_Glyph to indicate
+ * what kind of operations to perform during glyph loading.
+ *
+ * @values:
+ * FT_LOAD_DEFAULT ::
+ * Corresponding to~0, this value is used as the default glyph load
+ * operation. In this case, the following happens:
+ *
+ * 1. FreeType looks for a bitmap for the glyph corresponding to the
+ * face's current size. If one is found, the function returns.
+ * The bitmap data can be accessed from the glyph slot (see note
+ * below).
+ *
+ * 2. If no embedded bitmap is searched or found, FreeType looks for a
+ * scalable outline. If one is found, it is loaded from the font
+ * file, scaled to device pixels, then `hinted' to the pixel grid
+ * in order to optimize it. The outline data can be accessed from
+ * the glyph slot (see note below).
+ *
+ * Note that by default, the glyph loader doesn't render outlines into
+ * bitmaps. The following flags are used to modify this default
+ * behaviour to more specific and useful cases.
+ *
+ * FT_LOAD_NO_SCALE ::
+ * Don't scale the loaded outline glyph but keep it in font units.
+ *
+ * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
+ * unsets @FT_LOAD_RENDER.
+ *
+ * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using
+ * FT_LOAD_NO_SCALE usually yields meaningless outlines because the
+ * subglyphs must be scaled and positioned with hinting instructions.
+ * This can be solved by loading the font without FT_LOAD_NO_SCALE and
+ * setting the character size to `font->units_per_EM'.
+ *
+ * FT_LOAD_NO_HINTING ::
+ * Disable hinting. This generally generates `blurrier' bitmap glyphs
+ * when the glyph are rendered in any of the anti-aliased modes. See
+ * also the note below.
+ *
+ * This flag is implied by @FT_LOAD_NO_SCALE.
+ *
+ * FT_LOAD_RENDER ::
+ * Call @FT_Render_Glyph after the glyph is loaded. By default, the
+ * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
+ * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
+ *
+ * This flag is unset by @FT_LOAD_NO_SCALE.
+ *
+ * FT_LOAD_NO_BITMAP ::
+ * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
+ * flag.
+ *
+ * @FT_LOAD_NO_SCALE always sets this flag.
+ *
+ * FT_LOAD_VERTICAL_LAYOUT ::
+ * Load the glyph for vertical text layout. In particular, the
+ * `advance' value in the @FT_GlyphSlotRec structure is set to the
+ * `vertAdvance' value of the `metrics' field.
+ *
+ * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use
+ * this flag currently. Reason is that in this case vertical metrics
+ * get synthesized, and those values are not always consistent across
+ * various font formats.
+ *
+ * FT_LOAD_FORCE_AUTOHINT ::
+ * Indicates that the auto-hinter is preferred over the font's native
+ * hinter. See also the note below.
+ *
+ * FT_LOAD_CROP_BITMAP ::
+ * Indicates that the font driver should crop the loaded bitmap glyph
+ * (i.e., remove all space around its black bits). Not all drivers
+ * implement this.
+ *
+ * FT_LOAD_PEDANTIC ::
+ * Indicates that the font driver should perform pedantic verifications
+ * during glyph loading. This is mostly used to detect broken glyphs
+ * in fonts. By default, FreeType tries to handle broken fonts also.
+ *
+ * In particular, errors from the TrueType bytecode engine are not
+ * passed to the application if this flag is not set; this might
+ * result in partially hinted or distorted glyphs in case a glyph's
+ * bytecode is buggy.
+ *
+ * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
+ * Ignored. Deprecated.
+ *
+ * FT_LOAD_NO_RECURSE ::
+ * This flag is only used internally. It merely indicates that the
+ * font driver should not load composite glyphs recursively. Instead,
+ * it should set the `num_subglyph' and `subglyphs' values of the
+ * glyph slot accordingly, and set `glyph->format' to
+ * @FT_GLYPH_FORMAT_COMPOSITE.
+ *
+ * The description of sub-glyphs is not available to client
+ * applications for now.
+ *
+ * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
+ *
+ * FT_LOAD_IGNORE_TRANSFORM ::
+ * Indicates that the transform matrix set by @FT_Set_Transform should
+ * be ignored.
+ *
+ * FT_LOAD_MONOCHROME ::
+ * This flag is used with @FT_LOAD_RENDER to indicate that you want to
+ * render an outline glyph to a 1-bit monochrome bitmap glyph, with
+ * 8~pixels packed into each byte of the bitmap data.
+ *
+ * Note that this has no effect on the hinting algorithm used. You
+ * should rather use @FT_LOAD_TARGET_MONO so that the
+ * monochrome-optimized hinting algorithm is used.
+ *
+ * FT_LOAD_LINEAR_DESIGN ::
+ * Indicates that the `linearHoriAdvance' and `linearVertAdvance'
+ * fields of @FT_GlyphSlotRec should be kept in font units. See
+ * @FT_GlyphSlotRec for details.
+ *
+ * FT_LOAD_NO_AUTOHINT ::
+ * Disable auto-hinter. See also the note below.
+ *
+ * FT_LOAD_COLOR ::
+ * This flag is used to request loading of color embedded-bitmap
+ * images. The resulting color bitmaps, if available, will have the
+ * @FT_PIXEL_MODE_BGRA format. When the flag is not used and color
+ * bitmaps are found, they will be converted to 256-level gray
+ * bitmaps transparently. Those bitmaps will be in the
+ * @FT_PIXEL_MODE_GRAY format.
+ *
+ * @note:
+ * By default, hinting is enabled and the font's native hinter (see
+ * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
+ * disable hinting by setting @FT_LOAD_NO_HINTING or change the
+ * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
+ * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be
+ * used at all.
+ *
+ * See the description of @FT_FACE_FLAG_TRICKY for a special exception
+ * (affecting only a handful of Asian fonts).
+ *
+ * Besides deciding which hinter to use, you can also decide which
+ * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
+ *
+ * Note that the auto-hinter needs a valid Unicode cmap (either a native
+ * one or synthesized by FreeType) for producing correct results. If a
+ * font provides an incorrect mapping (for example, assigning the
+ * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a
+ * mathematical integral sign), the auto-hinter might produce useless
+ * results.
+ *
+ */
+#define FT_LOAD_DEFAULT 0x0
+#define FT_LOAD_NO_SCALE ( 1L << 0 )
+#define FT_LOAD_NO_HINTING ( 1L << 1 )
+#define FT_LOAD_RENDER ( 1L << 2 )
+#define FT_LOAD_NO_BITMAP ( 1L << 3 )
+#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
+#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
+#define FT_LOAD_CROP_BITMAP ( 1L << 6 )
+#define FT_LOAD_PEDANTIC ( 1L << 7 )
+#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
+#define FT_LOAD_NO_RECURSE ( 1L << 10 )
+#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
+#define FT_LOAD_MONOCHROME ( 1L << 12 )
+#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
+#define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
+ /* Bits 16..19 are used by `FT_LOAD_TARGET_' */
+#define FT_LOAD_COLOR ( 1L << 20 )
+
+ /* */
+
+ /* used internally only by certain font drivers! */
+#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
+#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
+
+
+ /**************************************************************************
+ *
+ * @enum:
+ * FT_LOAD_TARGET_XXX
+ *
+ * @description:
+ * A list of values that are used to select a specific hinting algorithm
+ * to use by the hinter. You should OR one of these values to your
+ * `load_flags' when calling @FT_Load_Glyph.
+ *
+ * Note that font's native hinters may ignore the hinting algorithm you
+ * have specified (e.g., the TrueType bytecode interpreter). You can set
+ * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used.
+ *
+ * Also note that @FT_LOAD_TARGET_LIGHT is an exception, in that it
+ * always implies @FT_LOAD_FORCE_AUTOHINT.
+ *
+ * @values:
+ * FT_LOAD_TARGET_NORMAL ::
+ * This corresponds to the default hinting algorithm, optimized for
+ * standard gray-level rendering. For monochrome output, use
+ * @FT_LOAD_TARGET_MONO instead.
+ *
+ * FT_LOAD_TARGET_LIGHT ::
+ * A lighter hinting algorithm for non-monochrome modes. Many
+ * generated glyphs are more fuzzy but better resemble its original
+ * shape. A bit like rendering on Mac OS~X.
+ *
+ * As a special exception, this target implies @FT_LOAD_FORCE_AUTOHINT.
+ *
+ * FT_LOAD_TARGET_MONO ::
+ * Strong hinting algorithm that should only be used for monochrome
+ * output. The result is probably unpleasant if the glyph is rendered
+ * in non-monochrome modes.
+ *
+ * FT_LOAD_TARGET_LCD ::
+ * A variant of @FT_LOAD_TARGET_NORMAL optimized for horizontally
+ * decimated LCD displays.
+ *
+ * FT_LOAD_TARGET_LCD_V ::
+ * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
+ * decimated LCD displays.
+ *
+ * @note:
+ * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your
+ * `load_flags'. They can't be ORed.
+ *
+ * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
+ * corresponding mode (i.e., the mode which matches the used algorithm
+ * best). An exeption is FT_LOAD_TARGET_MONO since it implies
+ * @FT_LOAD_MONOCHROME.
+ *
+ * You can use a hinting algorithm that doesn't correspond to the same
+ * rendering mode. As an example, it is possible to use the `light'
+ * hinting algorithm and have the results rendered in horizontal LCD
+ * pixel mode, with code like
+ *
+ * {
+ * FT_Load_Glyph( face, glyph_index,
+ * load_flags | FT_LOAD_TARGET_LIGHT );
+ *
+ * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
+ * }
+ *
+ */
+#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
+
+#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
+#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
+#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
+#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
+#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
+
+
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_LOAD_TARGET_MODE
+ *
+ * @description:
+ * Return the @FT_Render_Mode corresponding to a given
+ * @FT_LOAD_TARGET_XXX value.
+ *
+ */
+#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Set_Transform */
+ /* */
+ /* <Description> */
+ /* A function used to set the transformation that is applied to glyph */
+ /* images when they are loaded into a glyph slot through */
+ /* @FT_Load_Glyph. */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* <Input> */
+ /* matrix :: A pointer to the transformation's 2x2 matrix. Use~0 for */
+ /* the identity matrix. */
+ /* delta :: A pointer to the translation vector. Use~0 for the null */
+ /* vector. */
+ /* */
+ /* <Note> */
+ /* The transformation is only applied to scalable image formats after */
+ /* the glyph has been loaded. It means that hinting is unaltered by */
+ /* the transformation and is performed on the character size given in */
+ /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */
+ /* */
+ /* Note that this also transforms the `face.glyph.advance' field, but */
+ /* *not* the values in `face.glyph.metrics'. */
+ /* */
+ FT_EXPORT( void )
+ FT_Set_Transform( FT_Face face,
+ FT_Matrix* matrix,
+ FT_Vector* delta );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_Render_Mode */
+ /* */
+ /* <Description> */
+ /* An enumeration type that lists the render modes supported by */
+ /* FreeType~2. Each mode corresponds to a specific type of scanline */
+ /* conversion performed on the outline. */
+ /* */
+ /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */
+ /* field in the @FT_GlyphSlotRec structure gives the format of the */
+ /* returned bitmap. */
+ /* */
+ /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity. */
+ /* */
+ /* <Values> */
+ /* FT_RENDER_MODE_NORMAL :: */
+ /* This is the default render mode; it corresponds to 8-bit */
+ /* anti-aliased bitmaps. */
+ /* */
+ /* FT_RENDER_MODE_LIGHT :: */
+ /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */
+ /* defined as a separate value because render modes are also used */
+ /* indirectly to define hinting algorithm selectors. See */
+ /* @FT_LOAD_TARGET_XXX for details. */
+ /* */
+ /* FT_RENDER_MODE_MONO :: */
+ /* This mode corresponds to 1-bit bitmaps (with 2~levels of */
+ /* opacity). */
+ /* */
+ /* FT_RENDER_MODE_LCD :: */
+ /* This mode corresponds to horizontal RGB and BGR sub-pixel */
+ /* displays like LCD screens. It produces 8-bit bitmaps that are */
+ /* 3~times the width of the original glyph outline in pixels, and */
+ /* which use the @FT_PIXEL_MODE_LCD mode. */
+ /* */
+ /* FT_RENDER_MODE_LCD_V :: */
+ /* This mode corresponds to vertical RGB and BGR sub-pixel displays */
+ /* (like PDA screens, rotated LCD displays, etc.). It produces */
+ /* 8-bit bitmaps that are 3~times the height of the original */
+ /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */
+ /* */
+ /* <Note> */
+ /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph can be */
+ /* filtered to reduce color-fringes by using @FT_Library_SetLcdFilter */
+ /* (not active in the default builds). It is up to the caller to */
+ /* either call @FT_Library_SetLcdFilter (if available) or do the */
+ /* filtering itself. */
+ /* */
+ /* The selected render mode only affects vector glyphs of a font. */
+ /* Embedded bitmaps often have a different pixel mode like */
+ /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */
+ /* them into 8-bit pixmaps. */
+ /* */
+ typedef enum FT_Render_Mode_
+ {
+ FT_RENDER_MODE_NORMAL = 0,
+ FT_RENDER_MODE_LIGHT,
+ FT_RENDER_MODE_MONO,
+ FT_RENDER_MODE_LCD,
+ FT_RENDER_MODE_LCD_V,
+
+ FT_RENDER_MODE_MAX
+
+ } FT_Render_Mode;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* ft_render_mode_xxx */
+ /* */
+ /* <Description> */
+ /* These constants are deprecated. Use the corresponding */
+ /* @FT_Render_Mode values instead. */
+ /* */
+ /* <Values> */
+ /* ft_render_mode_normal :: see @FT_RENDER_MODE_NORMAL */
+ /* ft_render_mode_mono :: see @FT_RENDER_MODE_MONO */
+ /* */
+#define ft_render_mode_normal FT_RENDER_MODE_NORMAL
+#define ft_render_mode_mono FT_RENDER_MODE_MONO
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Render_Glyph */
+ /* */
+ /* <Description> */
+ /* Convert a given glyph image to a bitmap. It does so by inspecting */
+ /* the glyph image format, finding the relevant renderer, and */
+ /* invoking it. */
+ /* */
+ /* <InOut> */
+ /* slot :: A handle to the glyph slot containing the image to */
+ /* convert. */
+ /* */
+ /* <Input> */
+ /* render_mode :: This is the render mode used to render the glyph */
+ /* image into a bitmap. See @FT_Render_Mode for a */
+ /* list of possible values. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Render_Glyph( FT_GlyphSlot slot,
+ FT_Render_Mode render_mode );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_Kerning_Mode */
+ /* */
+ /* <Description> */
+ /* An enumeration used to specify which kerning values to return in */
+ /* @FT_Get_Kerning. */
+ /* */
+ /* <Values> */
+ /* FT_KERNING_DEFAULT :: Return scaled and grid-fitted kerning */
+ /* distances (value is~0). */
+ /* */
+ /* FT_KERNING_UNFITTED :: Return scaled but un-grid-fitted kerning */
+ /* distances. */
+ /* */
+ /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */
+ /* units. */
+ /* */
+ typedef enum FT_Kerning_Mode_
+ {
+ FT_KERNING_DEFAULT = 0,
+ FT_KERNING_UNFITTED,
+ FT_KERNING_UNSCALED
+
+ } FT_Kerning_Mode;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Const> */
+ /* ft_kerning_default */
+ /* */
+ /* <Description> */
+ /* This constant is deprecated. Please use @FT_KERNING_DEFAULT */
+ /* instead. */
+ /* */
+#define ft_kerning_default FT_KERNING_DEFAULT
+
+
+ /*************************************************************************/
+ /* */
+ /* <Const> */
+ /* ft_kerning_unfitted */
+ /* */
+ /* <Description> */
+ /* This constant is deprecated. Please use @FT_KERNING_UNFITTED */
+ /* instead. */
+ /* */
+#define ft_kerning_unfitted FT_KERNING_UNFITTED
+
+
+ /*************************************************************************/
+ /* */
+ /* <Const> */
+ /* ft_kerning_unscaled */
+ /* */
+ /* <Description> */
+ /* This constant is deprecated. Please use @FT_KERNING_UNSCALED */
+ /* instead. */
+ /* */
+#define ft_kerning_unscaled FT_KERNING_UNSCALED
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Kerning */
+ /* */
+ /* <Description> */
+ /* Return the kerning vector between two glyphs of a same face. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to a source face object. */
+ /* */
+ /* left_glyph :: The index of the left glyph in the kern pair. */
+ /* */
+ /* right_glyph :: The index of the right glyph in the kern pair. */
+ /* */
+ /* kern_mode :: See @FT_Kerning_Mode for more information. */
+ /* Determines the scale and dimension of the returned */
+ /* kerning vector. */
+ /* */
+ /* <Output> */
+ /* akerning :: The kerning vector. This is either in font units */
+ /* or in pixels (26.6 format) for scalable formats, */
+ /* and in pixels for fixed-sizes formats. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* Only horizontal layouts (left-to-right & right-to-left) are */
+ /* supported by this method. Other layouts, or more sophisticated */
+ /* kernings, are out of the scope of this API function -- they can be */
+ /* implemented through format-specific interfaces. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Get_Kerning( FT_Face face,
+ FT_UInt left_glyph,
+ FT_UInt right_glyph,
+ FT_UInt kern_mode,
+ FT_Vector *akerning );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Track_Kerning */
+ /* */
+ /* <Description> */
+ /* Return the track kerning for a given face object at a given size. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to a source face object. */
+ /* */
+ /* point_size :: The point size in 16.16 fractional points. */
+ /* */
+ /* degree :: The degree of tightness. Increasingly negative */
+ /* values represent tighter track kerning, while */
+ /* increasingly positive values represent looser track */
+ /* kerning. Value zero means no track kerning. */
+ /* */
+ /* <Output> */
+ /* akerning :: The kerning in 16.16 fractional points, to be */
+ /* uniformly applied between all glyphs. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* Currently, only the Type~1 font driver supports track kerning, */
+ /* using data from AFM files (if attached with @FT_Attach_File or */
+ /* @FT_Attach_Stream). */
+ /* */
+ /* Only very few AFM files come with track kerning data; please refer */
+ /* to the Adobe's AFM specification for more details. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Get_Track_Kerning( FT_Face face,
+ FT_Fixed point_size,
+ FT_Int degree,
+ FT_Fixed* akerning );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Glyph_Name */
+ /* */
+ /* <Description> */
+ /* Retrieve the ASCII name of a given glyph in a face. This only */
+ /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to a source face object. */
+ /* */
+ /* glyph_index :: The glyph index. */
+ /* */
+ /* buffer_max :: The maximum number of bytes available in the */
+ /* buffer. */
+ /* */
+ /* <Output> */
+ /* buffer :: A pointer to a target buffer where the name is */
+ /* copied to. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* An error is returned if the face doesn't provide glyph names or if */
+ /* the glyph index is invalid. In all cases of failure, the first */
+ /* byte of `buffer' is set to~0 to indicate an empty name. */
+ /* */
+ /* The glyph name is truncated to fit within the buffer if it is too */
+ /* long. The returned string is always zero-terminated. */
+ /* */
+ /* Be aware that FreeType reorders glyph indices internally so that */
+ /* glyph index~0 always corresponds to the `missing glyph' (called */
+ /* `.notdef'). */
+ /* */
+ /* This function is not compiled within the library if the config */
+ /* macro `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is defined in */
+ /* `include/freetype/config/ftoptions.h'. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Get_Glyph_Name( FT_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Postscript_Name */
+ /* */
+ /* <Description> */
+ /* Retrieve the ASCII PostScript name of a given face, if available. */
+ /* This only works with PostScript and TrueType fonts. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* <Return> */
+ /* A pointer to the face's PostScript name. NULL if unavailable. */
+ /* */
+ /* <Note> */
+ /* The returned pointer is owned by the face and is destroyed with */
+ /* it. */
+ /* */
+ FT_EXPORT( const char* )
+ FT_Get_Postscript_Name( FT_Face face );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Select_Charmap */
+ /* */
+ /* <Description> */
+ /* Select a given charmap by its encoding tag (as listed in */
+ /* `freetype.h'). */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* <Input> */
+ /* encoding :: A handle to the selected encoding. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* This function returns an error if no charmap in the face */
+ /* corresponds to the encoding queried here. */
+ /* */
+ /* Because many fonts contain more than a single cmap for Unicode */
+ /* encoding, this function has some special code to select the one */
+ /* which covers Unicode best (`best' in the sense that a UCS-4 cmap */
+ /* is preferred to a UCS-2 cmap). It is thus preferable to */
+ /* @FT_Set_Charmap in this case. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Select_Charmap( FT_Face face,
+ FT_Encoding encoding );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Set_Charmap */
+ /* */
+ /* <Description> */
+ /* Select a given charmap for character code to glyph index mapping. */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* <Input> */
+ /* charmap :: A handle to the selected charmap. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ /* <Note> */
+ /* This function returns an error if the charmap is not part of */
+ /* the face (i.e., if it is not listed in the `face->charmaps' */
+ /* table). */
+ /* */
+ /* It also fails if a type~14 charmap is selected. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Set_Charmap( FT_Face face,
+ FT_CharMap charmap );
+
+
+ /*************************************************************************
+ *
+ * @function:
+ * FT_Get_Charmap_Index
+ *
+ * @description:
+ * Retrieve index of a given charmap.
+ *
+ * @input:
+ * charmap ::
+ * A handle to a charmap.
+ *
+ * @return:
+ * The index into the array of character maps within the face to which
+ * `charmap' belongs. If an error occurs, -1 is returned.
+ *
+ */
+ FT_EXPORT( FT_Int )
+ FT_Get_Charmap_Index( FT_CharMap charmap );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Char_Index */
+ /* */
+ /* <Description> */
+ /* Return the glyph index of a given character code. This function */
+ /* uses a charmap object to do the mapping. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* charcode :: The character code. */
+ /* */
+ /* <Return> */
+ /* The glyph index. 0~means `undefined character code'. */
+ /* */
+ /* <Note> */
+ /* If you use FreeType to manipulate the contents of font files */
+ /* directly, be aware that the glyph index returned by this function */
+ /* doesn't always correspond to the internal indices used within the */
+ /* file. This is done to ensure that value~0 always corresponds to */
+ /* the `missing glyph'. If the first glyph is not named `.notdef', */
+ /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */
+ /* the glyph ID~0 position, and whatever was there will be moved to */
+ /* the position `.notdef' had. For Type~1 fonts, if there is no */
+ /* `.notdef' glyph at all, then one will be created at index~0 and */
+ /* whatever was there will be moved to the last index -- Type~42 */
+ /* fonts are considered invalid under this condition. */
+ /* */
+ FT_EXPORT( FT_UInt )
+ FT_Get_Char_Index( FT_Face face,
+ FT_ULong charcode );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_First_Char */
+ /* */
+ /* <Description> */
+ /* This function is used to return the first character code in the */
+ /* current charmap of a given face. It also returns the */
+ /* corresponding glyph index. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* <Output> */
+ /* agindex :: Glyph index of first character code. 0~if charmap is */
+ /* empty. */
+ /* */
+ /* <Return> */
+ /* The charmap's first character code. */
+ /* */
+ /* <Note> */
+ /* You should use this function with @FT_Get_Next_Char to be able to */
+ /* parse all character codes available in a given charmap. The code */
+ /* should look like this: */
+ /* */
+ /* { */
+ /* FT_ULong charcode; */
+ /* FT_UInt gindex; */
+ /* */
+ /* */
+ /* charcode = FT_Get_First_Char( face, &gindex ); */
+ /* while ( gindex != 0 ) */
+ /* { */
+ /* ... do something with (charcode,gindex) pair ... */
+ /* */
+ /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
+ /* } */
+ /* } */
+ /* */
+ /* Note that `*agindex' is set to~0 if the charmap is empty. The */
+ /* result itself can be~0 in two cases: if the charmap is empty or */
+ /* if the value~0 is the first valid character code. */
+ /* */
+ FT_EXPORT( FT_ULong )
+ FT_Get_First_Char( FT_Face face,
+ FT_UInt *agindex );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Next_Char */
+ /* */
+ /* <Description> */
+ /* This function is used to return the next character code in the */
+ /* current charmap of a given face following the value `char_code', */
+ /* as well as the corresponding glyph index. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* char_code :: The starting character code. */
+ /* */
+ /* <Output> */
+ /* agindex :: Glyph index of next character code. 0~if charmap */
+ /* is empty. */
+ /* */
+ /* <Return> */
+ /* The charmap's next character code. */
+ /* */
+ /* <Note> */
+ /* You should use this function with @FT_Get_First_Char to walk */
+ /* over all character codes available in a given charmap. See the */
+ /* note for this function for a simple code example. */
+ /* */
+ /* Note that `*agindex' is set to~0 when there are no more codes in */
+ /* the charmap. */
+ /* */
+ FT_EXPORT( FT_ULong )
+ FT_Get_Next_Char( FT_Face face,
+ FT_ULong char_code,
+ FT_UInt *agindex );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Name_Index */
+ /* */
+ /* <Description> */
+ /* Return the glyph index of a given glyph name. This function uses */
+ /* driver specific objects to do the translation. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* glyph_name :: The glyph name. */
+ /* */
+ /* <Return> */
+ /* The glyph index. 0~means `undefined character code'. */
+ /* */
+ FT_EXPORT( FT_UInt )
+ FT_Get_Name_Index( FT_Face face,
+ FT_String* glyph_name );
+
+
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_SUBGLYPH_FLAG_XXX
+ *
+ * @description:
+ * A list of constants used to describe subglyphs. Please refer to the
+ * TrueType specification for the meaning of the various flags.
+ *
+ * @values:
+ * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
+ * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
+ * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
+ * FT_SUBGLYPH_FLAG_SCALE ::
+ * FT_SUBGLYPH_FLAG_XY_SCALE ::
+ * FT_SUBGLYPH_FLAG_2X2 ::
+ * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
+ *
+ */
+#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
+#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
+#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
+#define FT_SUBGLYPH_FLAG_SCALE 8
+#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
+#define FT_SUBGLYPH_FLAG_2X2 0x80
+#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
+
+
+ /*************************************************************************
+ *
+ * @func:
+ * FT_Get_SubGlyph_Info
+ *
+ * @description:
+ * Retrieve a description of a given subglyph. Only use it if
+ * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is
+ * returned otherwise.
+ *
+ * @input:
+ * glyph ::
+ * The source glyph slot.
+ *
+ * sub_index ::
+ * The index of the subglyph. Must be less than
+ * `glyph->num_subglyphs'.
+ *
+ * @output:
+ * p_index ::
+ * The glyph index of the subglyph.
+ *
+ * p_flags ::
+ * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
+ *
+ * p_arg1 ::
+ * The subglyph's first argument (if any).
+ *
+ * p_arg2 ::
+ * The subglyph's second argument (if any).
+ *
+ * p_transform ::
+ * The subglyph transformation (if any).
+ *
+ * @return:
+ * FreeType error code. 0~means success.
+ *
+ * @note:
+ * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be
+ * interpreted depending on the flags returned in `*p_flags'. See the
+ * TrueType specification for details.
+ *
+ */
+ FT_EXPORT( FT_Error )
+ FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
+ FT_UInt sub_index,
+ FT_Int *p_index,
+ FT_UInt *p_flags,
+ FT_Int *p_arg1,
+ FT_Int *p_arg2,
+ FT_Matrix *p_transform );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_FSTYPE_XXX */
+ /* */
+ /* <Description> */
+ /* A list of bit flags used in the `fsType' field of the OS/2 table */
+ /* in a TrueType or OpenType font and the `FSType' entry in a */
+ /* PostScript font. These bit flags are returned by */
+ /* @FT_Get_FSType_Flags; they inform client applications of embedding */
+ /* and subsetting restrictions associated with a font. */
+ /* */
+ /* See http://www.adobe.com/devnet/acrobat/pdfs/FontPolicies.pdf for */
+ /* more details. */
+ /* */
+ /* <Values> */
+ /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */
+ /* Fonts with no fsType bit set may be embedded and permanently */
+ /* installed on the remote system by an application. */
+ /* */
+ /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */
+ /* Fonts that have only this bit set must not be modified, embedded */
+ /* or exchanged in any manner without first obtaining permission of */
+ /* the font software copyright owner. */
+ /* */
+ /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */
+ /* If this bit is set, the font may be embedded and temporarily */
+ /* loaded on the remote system. Documents containing Preview & */
+ /* Print fonts must be opened `read-only'; no edits can be applied */
+ /* to the document. */
+ /* */
+ /* FT_FSTYPE_EDITABLE_EMBEDDING :: */
+ /* If this bit is set, the font may be embedded but must only be */
+ /* installed temporarily on other systems. In contrast to Preview */
+ /* & Print fonts, documents containing editable fonts may be opened */
+ /* for reading, editing is permitted, and changes may be saved. */
+ /* */
+ /* FT_FSTYPE_NO_SUBSETTING :: */
+ /* If this bit is set, the font may not be subsetted prior to */
+ /* embedding. */
+ /* */
+ /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */
+ /* If this bit is set, only bitmaps contained in the font may be */
+ /* embedded; no outline data may be embedded. If there are no */
+ /* bitmaps available in the font, then the font is unembeddable. */
+ /* */
+ /* <Note> */
+ /* While the fsType flags can indicate that a font may be embedded, a */
+ /* license with the font vendor may be separately required to use the */
+ /* font in this way. */
+ /* */
+#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
+#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
+#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
+#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
+#define FT_FSTYPE_NO_SUBSETTING 0x0100
+#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_FSType_Flags */
+ /* */
+ /* <Description> */
+ /* Return the fsType flags for a font. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* */
+ /* <Return> */
+ /* The fsType flags, @FT_FSTYPE_XXX. */
+ /* */
+ /* <Note> */
+ /* Use this function rather than directly reading the `fs_type' field */
+ /* in the @PS_FontInfoRec structure which is only guaranteed to */
+ /* return the correct results for Type~1 fonts. */
+ /* */
+ /* <Since> */
+ /* 2.3.8 */
+ /* */
+ FT_EXPORT( FT_UShort )
+ FT_Get_FSType_Flags( FT_Face face );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* glyph_variants */
+ /* */
+ /* <Title> */
+ /* Glyph Variants */
+ /* */
+ /* <Abstract> */
+ /* The FreeType~2 interface to Unicode Ideographic Variation */
+ /* Sequences (IVS), using the SFNT cmap format~14. */
+ /* */
+ /* <Description> */
+ /* Many CJK characters have variant forms. They are a sort of grey */
+ /* area somewhere between being totally irrelevant and semantically */
+ /* distinct; for this reason, the Unicode consortium decided to */
+ /* introduce Ideographic Variation Sequences (IVS), consisting of a */
+ /* Unicode base character and one of 240 variant selectors */
+ /* (U+E0100-U+E01EF), instead of further extending the already huge */
+ /* code range for CJK characters. */
+ /* */
+ /* An IVS is registered and unique; for further details please refer */
+ /* to Unicode Technical Standard #37, the Ideographic Variation */
+ /* Database: */
+ /* */
+ /* http://www.unicode.org/reports/tr37/ */
+ /* */
+ /* To date (November 2012), the character with the most variants is */
+ /* U+9089, having 31 such IVS. */
+ /* */
+ /* Adobe and MS decided to support IVS with a new cmap subtable */
+ /* (format~14). It is an odd subtable because it is not a mapping of */
+ /* input code points to glyphs, but contains lists of all variants */
+ /* supported by the font. */
+ /* */
+ /* A variant may be either `default' or `non-default'. A default */
+ /* variant is the one you will get for that code point if you look it */
+ /* up in the standard Unicode cmap. A non-default variant is a */
+ /* different glyph. */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Face_GetCharVariantIndex */
+ /* */
+ /* <Description> */
+ /* Return the glyph index of a given character code as modified by */
+ /* the variation selector. */
+ /* */
+ /* <Input> */
+ /* face :: */
+ /* A handle to the source face object. */
+ /* */
+ /* charcode :: */
+ /* The character code point in Unicode. */
+ /* */
+ /* variantSelector :: */
+ /* The Unicode code point of the variation selector. */
+ /* */
+ /* <Return> */
+ /* The glyph index. 0~means either `undefined character code', or */
+ /* `undefined selector code', or `no variation selector cmap */
+ /* subtable', or `current CharMap is not Unicode'. */
+ /* */
+ /* <Note> */
+ /* If you use FreeType to manipulate the contents of font files */
+ /* directly, be aware that the glyph index returned by this function */
+ /* doesn't always correspond to the internal indices used within */
+ /* the file. This is done to ensure that value~0 always corresponds */
+ /* to the `missing glyph'. */
+ /* */
+ /* This function is only meaningful if */
+ /* a) the font has a variation selector cmap sub table, */
+ /* and */
+ /* b) the current charmap has a Unicode encoding. */
+ /* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
+ FT_EXPORT( FT_UInt )
+ FT_Face_GetCharVariantIndex( FT_Face face,
+ FT_ULong charcode,
+ FT_ULong variantSelector );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Face_GetCharVariantIsDefault */
+ /* */
+ /* <Description> */
+ /* Check whether this variant of this Unicode character is the one to */
+ /* be found in the `cmap'. */
+ /* */
+ /* <Input> */
+ /* face :: */
+ /* A handle to the source face object. */
+ /* */
+ /* charcode :: */
+ /* The character codepoint in Unicode. */
+ /* */
+ /* variantSelector :: */
+ /* The Unicode codepoint of the variation selector. */
+ /* */
+ /* <Return> */
+ /* 1~if found in the standard (Unicode) cmap, 0~if found in the */
+ /* variation selector cmap, or -1 if it is not a variant. */
+ /* */
+ /* <Note> */
+ /* This function is only meaningful if the font has a variation */
+ /* selector cmap subtable. */
+ /* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
+ FT_EXPORT( FT_Int )
+ FT_Face_GetCharVariantIsDefault( FT_Face face,
+ FT_ULong charcode,
+ FT_ULong variantSelector );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Face_GetVariantSelectors */
+ /* */
+ /* <Description> */
+ /* Return a zero-terminated list of Unicode variant selectors found */
+ /* in the font. */
+ /* */
+ /* <Input> */
+ /* face :: */
+ /* A handle to the source face object. */
+ /* */
+ /* <Return> */
+ /* A pointer to an array of selector code points, or NULL if there is */
+ /* no valid variant selector cmap subtable. */
+ /* */
+ /* <Note> */
+ /* The last item in the array is~0; the array is owned by the */
+ /* @FT_Face object but can be overwritten or released on the next */
+ /* call to a FreeType function. */
+ /* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
+ FT_EXPORT( FT_UInt32* )
+ FT_Face_GetVariantSelectors( FT_Face face );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Face_GetVariantsOfChar */
+ /* */
+ /* <Description> */
+ /* Return a zero-terminated list of Unicode variant selectors found */
+ /* for the specified character code. */
+ /* */
+ /* <Input> */
+ /* face :: */
+ /* A handle to the source face object. */
+ /* */
+ /* charcode :: */
+ /* The character codepoint in Unicode. */
+ /* */
+ /* <Return> */
+ /* A pointer to an array of variant selector code points which are */
+ /* active for the given character, or NULL if the corresponding list */
+ /* is empty. */
+ /* */
+ /* <Note> */
+ /* The last item in the array is~0; the array is owned by the */
+ /* @FT_Face object but can be overwritten or released on the next */
+ /* call to a FreeType function. */
+ /* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
+ FT_EXPORT( FT_UInt32* )
+ FT_Face_GetVariantsOfChar( FT_Face face,
+ FT_ULong charcode );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Face_GetCharsOfVariant */
+ /* */
+ /* <Description> */
+ /* Return a zero-terminated list of Unicode character codes found for */
+ /* the specified variant selector. */
+ /* */
+ /* <Input> */
+ /* face :: */
+ /* A handle to the source face object. */
+ /* */
+ /* variantSelector :: */
+ /* The variant selector code point in Unicode. */
+ /* */
+ /* <Return> */
+ /* A list of all the code points which are specified by this selector */
+ /* (both default and non-default codes are returned) or NULL if there */
+ /* is no valid cmap or the variant selector is invalid. */
+ /* */
+ /* <Note> */
+ /* The last item in the array is~0; the array is owned by the */
+ /* @FT_Face object but can be overwritten or released on the next */
+ /* call to a FreeType function. */
+ /* */
+ /* <Since> */
+ /* 2.3.6 */
+ /* */
+ FT_EXPORT( FT_UInt32* )
+ FT_Face_GetCharsOfVariant( FT_Face face,
+ FT_ULong variantSelector );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* computations */
+ /* */
+ /* <Title> */
+ /* Computations */
+ /* */
+ /* <Abstract> */
+ /* Crunching fixed numbers and vectors. */
+ /* */
+ /* <Description> */
+ /* This section contains various functions used to perform */
+ /* computations on 16.16 fixed-float numbers or 2d vectors. */
+ /* */
+ /* <Order> */
+ /* FT_MulDiv */
+ /* FT_MulFix */
+ /* FT_DivFix */
+ /* FT_RoundFix */
+ /* FT_CeilFix */
+ /* FT_FloorFix */
+ /* FT_Vector_Transform */
+ /* FT_Matrix_Multiply */
+ /* FT_Matrix_Invert */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_MulDiv */
+ /* */
+ /* <Description> */
+ /* A very simple function used to perform the computation `(a*b)/c' */
+ /* with maximum accuracy (it uses a 64-bit intermediate integer */
+ /* whenever necessary). */
+ /* */
+ /* This function isn't necessarily as fast as some processor specific */
+ /* operations, but is at least completely portable. */
+ /* */
+ /* <Input> */
+ /* a :: The first multiplier. */
+ /* b :: The second multiplier. */
+ /* c :: The divisor. */
+ /* */
+ /* <Return> */
+ /* The result of `(a*b)/c'. This function never traps when trying to */
+ /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
+ /* on the signs of `a' and `b'. */
+ /* */
+ FT_EXPORT( FT_Long )
+ FT_MulDiv( FT_Long a,
+ FT_Long b,
+ FT_Long c );
+
+
+ /* */
+
+ /* The following #if 0 ... #endif is for the documentation formatter, */
+ /* hiding the internal `FT_MULFIX_INLINED' macro. */
+
+#if 0
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_MulFix */
+ /* */
+ /* <Description> */
+ /* A very simple function used to perform the computation */
+ /* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */
+ /* used to multiply a given value by a 16.16 fixed-point factor. */
+ /* */
+ /* <Input> */
+ /* a :: The first multiplier. */
+ /* b :: The second multiplier. Use a 16.16 factor here whenever */
+ /* possible (see note below). */
+ /* */
+ /* <Return> */
+ /* The result of `(a*b)/0x10000'. */
+ /* */
+ /* <Note> */
+ /* This function has been optimized for the case where the absolute */
+ /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
+ /* As this happens mainly when scaling from notional units to */
+ /* fractional pixels in FreeType, it resulted in noticeable speed */
+ /* improvements between versions 2.x and 1.x. */
+ /* */
+ /* As a conclusion, always try to place a 16.16 factor as the */
+ /* _second_ argument of this function; this can make a great */
+ /* difference. */
+ /* */
+ FT_EXPORT( FT_Long )
+ FT_MulFix( FT_Long a,
+ FT_Long b );
+
+ /* */
+#endif
+
+#ifdef FT_MULFIX_INLINED
+#define FPDFAPI_FT_MulFix( a, b ) FT_MULFIX_INLINED( a, b )
+#else
+ FT_EXPORT( FT_Long )
+ FT_MulFix( FT_Long a,
+ FT_Long b );
+#endif
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_DivFix */
+ /* */
+ /* <Description> */
+ /* A very simple function used to perform the computation */
+ /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */
+ /* used to divide a given value by a 16.16 fixed-point factor. */
+ /* */
+ /* <Input> */
+ /* a :: The first multiplier. */
+ /* b :: The second multiplier. Use a 16.16 factor here whenever */
+ /* possible (see note below). */
+ /* */
+ /* <Return> */
+ /* The result of `(a*0x10000)/b'. */
+ /* */
+ /* <Note> */
+ /* The optimization for FT_DivFix() is simple: If (a~<<~16) fits in */
+ /* 32~bits, then the division is computed directly. Otherwise, we */
+ /* use a specialized version of @FT_MulDiv. */
+ /* */
+ FT_EXPORT( FT_Long )
+ FT_DivFix( FT_Long a,
+ FT_Long b );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_RoundFix */
+ /* */
+ /* <Description> */
+ /* A very simple function used to round a 16.16 fixed number. */
+ /* */
+ /* <Input> */
+ /* a :: The number to be rounded. */
+ /* */
+ /* <Return> */
+ /* The result of `(a + 0x8000) & -0x10000'. */
+ /* */
+ FT_EXPORT( FT_Fixed )
+ FT_RoundFix( FT_Fixed a );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_CeilFix */
+ /* */
+ /* <Description> */
+ /* A very simple function used to compute the ceiling function of a */
+ /* 16.16 fixed number. */
+ /* */
+ /* <Input> */
+ /* a :: The number for which the ceiling function is to be computed. */
+ /* */
+ /* <Return> */
+ /* The result of `(a + 0x10000 - 1) & -0x10000'. */
+ /* */
+ FT_EXPORT( FT_Fixed )
+ FT_CeilFix( FT_Fixed a );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_FloorFix */
+ /* */
+ /* <Description> */
+ /* A very simple function used to compute the floor function of a */
+ /* 16.16 fixed number. */
+ /* */
+ /* <Input> */
+ /* a :: The number for which the floor function is to be computed. */
+ /* */
+ /* <Return> */
+ /* The result of `a & -0x10000'. */
+ /* */
+ FT_EXPORT( FT_Fixed )
+ FT_FloorFix( FT_Fixed a );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Vector_Transform */
+ /* */
+ /* <Description> */
+ /* Transform a single vector through a 2x2 matrix. */
+ /* */
+ /* <InOut> */
+ /* vector :: The target vector to transform. */
+ /* */
+ /* <Input> */
+ /* matrix :: A pointer to the source 2x2 matrix. */
+ /* */
+ /* <Note> */
+ /* The result is undefined if either `vector' or `matrix' is invalid. */
+ /* */
+ FT_EXPORT( void )
+ FT_Vector_Transform( FT_Vector* vec,
+ const FT_Matrix* matrix );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* version */
+ /* */
+ /* <Title> */
+ /* FreeType Version */
+ /* */
+ /* <Abstract> */
+ /* Functions and macros related to FreeType versions. */
+ /* */
+ /* <Description> */
+ /* Note that those functions and macros are of limited use because */
+ /* even a new release of FreeType with only documentation changes */
+ /* increases the version number. */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************
+ *
+ * @enum:
+ * FREETYPE_XXX
+ *
+ * @description:
+ * These three macros identify the FreeType source code version.
+ * Use @FT_Library_Version to access them at runtime.
+ *
+ * @values:
+ * FREETYPE_MAJOR :: The major version number.
+ * FREETYPE_MINOR :: The minor version number.
+ * FREETYPE_PATCH :: The patch level.
+ *
+ * @note:
+ * The version number of FreeType if built as a dynamic link library
+ * with the `libtool' package is _not_ controlled by these three
+ * macros.
+ *
+ */
+#define FREETYPE_MAJOR 2
+#define FREETYPE_MINOR 5
+#define FREETYPE_PATCH 0
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Library_Version */
+ /* */
+ /* <Description> */
+ /* Return the version of the FreeType library being used. This is */
+ /* useful when dynamically linking to the library, since one cannot */
+ /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */
+ /* @FREETYPE_PATCH. */
+ /* */
+ /* <Input> */
+ /* library :: A source library handle. */
+ /* */
+ /* <Output> */
+ /* amajor :: The major version number. */
+ /* */
+ /* aminor :: The minor version number. */
+ /* */
+ /* apatch :: The patch version number. */
+ /* */
+ /* <Note> */
+ /* The reason why this function takes a `library' argument is because */
+ /* certain programs implement library initialization in a custom way */
+ /* that doesn't use @FT_Init_FreeType. */
+ /* */
+ /* In such cases, the library version might not be available before */
+ /* the library object has been created. */
+ /* */
+ FT_EXPORT( void )
+ FT_Library_Version( FT_Library library,
+ FT_Int *amajor,
+ FT_Int *aminor,
+ FT_Int *apatch );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Face_CheckTrueTypePatents */
+ /* */
+ /* <Description> */
+ /* Parse all bytecode instructions of a TrueType font file to check */
+ /* whether any of the patented opcodes are used. This is only useful */
+ /* if you want to be able to use the unpatented hinter with */
+ /* fonts that do *not* use these opcodes. */
+ /* */
+ /* Note that this function parses *all* glyph instructions in the */
+ /* font file, which may be slow. */
+ /* */
+ /* <Input> */
+ /* face :: A face handle. */
+ /* */
+ /* <Return> */
+ /* 1~if this is a TrueType font that uses one of the patented */
+ /* opcodes, 0~otherwise. */
+ /* */
+ /* <Note> */
+ /* Since May 2010, TrueType hinting is no longer patented. */
+ /* */
+ /* <Since> */
+ /* 2.3.5 */
+ /* */
+ FT_EXPORT( FT_Bool )
+ FT_Face_CheckTrueTypePatents( FT_Face face );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Face_SetUnpatentedHinting */
+ /* */
+ /* <Description> */
+ /* Enable or disable the unpatented hinter for a given face. */
+ /* Only enable it if you have determined that the face doesn't */
+ /* use any patented opcodes (see @FT_Face_CheckTrueTypePatents). */
+ /* */
+ /* <Input> */
+ /* face :: A face handle. */
+ /* */
+ /* value :: New boolean setting. */
+ /* */
+ /* <Return> */
+ /* The old setting value. This will always be false if this is not */
+ /* an SFNT font, or if the unpatented hinter is not compiled in this */
+ /* instance of the library. */
+ /* */
+ /* <Note> */
+ /* Since May 2010, TrueType hinting is no longer patented. */
+ /* */
+ /* <Since> */
+ /* 2.3.5 */
+ /* */
+ FT_EXPORT( FT_Bool )
+ FT_Face_SetUnpatentedHinting( FT_Face face,
+ FT_Bool value );
+
+ /* */
+
+
+FT_END_HEADER
+
+#endif /* __FREETYPE_H__ */
+
+
+/* END */
diff --git a/core/include/thirdparties/freetype/freetype/ftsystem.h b/core/include/thirdparties/freetype/freetype/ftsystem.h
index 6b41320aa8..1e92390aca 100644
--- a/core/include/thirdparties/freetype/freetype/ftsystem.h
+++ b/core/include/thirdparties/freetype/freetype/ftsystem.h
@@ -89,10 +89,10 @@ FT_BEGIN_HEADER
(*FT_Alloc_Func)( FT_Memory memory,
long size );
- /* Sunliang.Liu 20100915 sync 221's revison. */
- typedef void*
- (*FT_AllocDebug_Func)( FT_Memory memory,
- long size, const char* filename, int line);
+ /* Sunliang.Liu 20100915 sync 221's revison. */
+ typedef void*
+ (*FT_AllocDebug_Func)( FT_Memory memory,
+ long size, const char* filename, int line);
diff --git a/core/include/thirdparties/freetype/freetype/internal/ftmemory.h b/core/include/thirdparties/freetype/freetype/internal/ftmemory.h
index 67cbf43308..432a9ba6d8 100644
--- a/core/include/thirdparties/freetype/freetype/internal/ftmemory.h
+++ b/core/include/thirdparties/freetype/freetype/internal/ftmemory.h
@@ -135,37 +135,37 @@ FT_BEGIN_HEADER
FT_Long new_count,
void* block,
FT_Error *p_error );
-#ifdef _DEBUG
-//#define _XYQ_MEM_DEBUG
-#endif
-
-#ifdef _XYQ_MEM_DEBUG /* XYQ */
- FT_BASE( FT_Pointer )
- ft_mem_allocdebug( FT_Memory memory,
- FT_Long size, const char* filename, int line,
- FT_Error *p_error );
-
- FT_BASE( FT_Pointer )
- ft_mem_qallocdebug( FT_Memory memory,
- FT_Long size, const char* filename, int line,
- FT_Error *p_error );
-
- FT_BASE( FT_Pointer )
- ft_mem_reallocdebug( FT_Memory memory,
- FT_Long item_size,
- FT_Long cur_count,
- FT_Long new_count,
- void* block, const char* filename, int line,
- FT_Error *p_error );
-
- FT_BASE( FT_Pointer )
- ft_mem_qreallocdebug( FT_Memory memory,
- FT_Long item_size,
- FT_Long cur_count,
- FT_Long new_count,
- void* block, const char* filename, int line,
- FT_Error *p_error );
-#endif
+#ifdef _DEBUG
+//#define _XYQ_MEM_DEBUG
+#endif
+
+#ifdef _XYQ_MEM_DEBUG /* XYQ */
+ FT_BASE( FT_Pointer )
+ ft_mem_allocdebug( FT_Memory memory,
+ FT_Long size, const char* filename, int line,
+ FT_Error *p_error );
+
+ FT_BASE( FT_Pointer )
+ ft_mem_qallocdebug( FT_Memory memory,
+ FT_Long size, const char* filename, int line,
+ FT_Error *p_error );
+
+ FT_BASE( FT_Pointer )
+ ft_mem_reallocdebug( FT_Memory memory,
+ FT_Long item_size,
+ FT_Long cur_count,
+ FT_Long new_count,
+ void* block, const char* filename, int line,
+ FT_Error *p_error );
+
+ FT_BASE( FT_Pointer )
+ ft_mem_qreallocdebug( FT_Memory memory,
+ FT_Long item_size,
+ FT_Long cur_count,
+ FT_Long new_count,
+ void* block, const char* filename, int line,
+ FT_Error *p_error );
+#endif
FT_BASE( void )
@@ -178,8 +178,8 @@ FT_BEGIN_HEADER
ft_mem_free( memory, (ptr) ); \
(ptr) = NULL; \
FT_END_STMNT
-#ifndef _XYQ_MEM_DEBUG
-#define FT_MEM_ALLOC( ptr, size ) \
+#ifndef _XYQ_MEM_DEBUG
+#define FT_MEM_ALLOC( ptr, size ) \
FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) )
@@ -235,94 +235,94 @@ FT_BEGIN_HEADER
(FT_Long)(newcnt), \
(ptr), \
&error ) )
-#define FT_MEM_NEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, &error ) )
-
-#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
-
-#define FT_MEM_QNEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, &error ) )
-
-#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
-
-#else
-#define FT_MEM_ALLOC( ptr, size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_allocdebug( memory, (size), __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_REALLOC( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, 1, \
- (cursz), (newsz), \
- (ptr), __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_QALLOC( ptr, size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qallocdebug( memory, (size), __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, 1, \
- (cursz), (newsz), \
- (ptr), __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, (item_size), \
- 0, (count), \
- NULL, __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, (itmsz), \
- (oldcnt), (newcnt), \
+#define FT_MEM_NEW_ARRAY( ptr, count ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
+ 0, (count), \
+ NULL, &error ) )
+
+#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
+ (cursz), (newsz), \
+ (ptr), &error ) )
+
+#define FT_MEM_QNEW_ARRAY( ptr, count ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
+ 0, (count), \
+ NULL, &error ) )
+
+#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
+ (cursz), (newsz), \
+ (ptr), &error ) )
+
+#else
+#define FT_MEM_ALLOC( ptr, size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_allocdebug( memory, (size), __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_REALLOC( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, 1, \
+ (cursz), (newsz), \
+ (ptr), __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_QALLOC( ptr, size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qallocdebug( memory, (size), __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, 1, \
+ (cursz), (newsz), \
+ (ptr), __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, (item_size), \
+ 0, (count), \
+ NULL, __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, (itmsz), \
+ (oldcnt), (newcnt), \
+ (ptr), __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, (item_size), \
+ 0, (count), \
+ NULL, __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, (itmsz), \
+ (oldcnt), (newcnt), \
+ (ptr), __FILE__, __LINE__, &error ) )
+ /*************************************************************************/
+ /* */
+ /* The following functions macros expect that their pointer argument is */
+ /* _typed_ in order to automatically compute array element sizes. */
+ /* */
+
+#define FT_MEM_NEW_ARRAY( ptr, count ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, sizeof ( *(ptr) ), \
+ 0, (count), \
+ NULL, __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, sizeof ( *(ptr) ), \
+ (cursz), (newsz), \
(ptr), __FILE__, __LINE__, &error ) )
-#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, (item_size), \
- 0, (count), \
- NULL, __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, (itmsz), \
- (oldcnt), (newcnt), \
- (ptr), __FILE__, __LINE__, &error ) )
- /*************************************************************************/
- /* */
- /* The following functions macros expect that their pointer argument is */
- /* _typed_ in order to automatically compute array element sizes. */
- /* */
-
-#define FT_MEM_NEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_QNEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, __FILE__, __LINE__, &error ) )
-
-#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), __FILE__, __LINE__, &error ) )
-
-#endif
-
-#define FT_MEM_NEW( ptr ) \
- FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) )
-
-#define FT_MEM_QNEW( ptr ) \
+#define FT_MEM_QNEW_ARRAY( ptr, count ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, sizeof ( *(ptr) ), \
+ 0, (count), \
+ NULL, __FILE__, __LINE__, &error ) )
+
+#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, sizeof ( *(ptr) ), \
+ (cursz), (newsz), \
+ (ptr), __FILE__, __LINE__, &error ) )
+
+#endif
+
+#define FT_MEM_NEW( ptr ) \
+ FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) )
+
+#define FT_MEM_QNEW( ptr ) \
FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) )
#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 )
diff --git a/core/include/thirdparties/freetype/ft2build.h b/core/include/thirdparties/freetype/ft2build.h
index 134007d86f..1fc812153f 100644
--- a/core/include/thirdparties/freetype/ft2build.h
+++ b/core/include/thirdparties/freetype/ft2build.h
@@ -31,7 +31,7 @@
#ifndef __FT2_BUILD_GENERIC_H__
#define __FT2_BUILD_GENERIC_H__
-#include "foxitnames.h"
+#include "foxitnames.h"
#include "freetype/config/ftheader.h"
#endif /* __FT2_BUILD_GENERIC_H__ */
diff --git a/core/include/thirdparties/libjpeg/jconfig.h b/core/include/thirdparties/libjpeg/jconfig.h
index 2f4da14c54..7e291c75bd 100644
--- a/core/include/thirdparties/libjpeg/jconfig.h
+++ b/core/include/thirdparties/libjpeg/jconfig.h
@@ -1,45 +1,45 @@
-/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */
-/* see jconfig.doc for explanations */
-
-#define HAVE_PROTOTYPES
-#define HAVE_UNSIGNED_CHAR
-#define HAVE_UNSIGNED_SHORT
-/* #define void char */
-/* #define const */
-#undef CHAR_IS_UNSIGNED
-#define HAVE_STDDEF_H
-#define HAVE_STDLIB_H
-#undef NEED_BSD_STRINGS
-#undef NEED_SYS_TYPES_H
-#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */
-#undef NEED_SHORT_EXTERNAL_NAMES
-#undef INCOMPLETE_TYPES_BROKEN
-
-/* Define "boolean" as unsigned char, not int, per Windows custom */
-#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
-typedef unsigned char boolean;
-#endif
-#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
-
-
-#ifdef JPEG_INTERNALS
-
-#undef RIGHT_SHIFT_IS_UNSIGNED
-
-#endif /* JPEG_INTERNALS */
-
-#ifdef JPEG_CJPEG_DJPEG
-
-#define BMP_SUPPORTED /* BMP image file format */
-#define GIF_SUPPORTED /* GIF image file format */
-#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
-#undef RLE_SUPPORTED /* Utah RLE image file format */
-#define TARGA_SUPPORTED /* Targa image file format */
-
-#define TWO_FILE_COMMANDLINE /* optional */
-#define USE_SETMODE /* Microsoft has setmode() */
-#undef NEED_SIGNAL_CATCHER
-#undef DONT_USE_B_MODE
-#undef PROGRESS_REPORT /* optional */
-
-#endif /* JPEG_CJPEG_DJPEG */
+/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */
+/* see jconfig.doc for explanations */
+
+#define HAVE_PROTOTYPES
+#define HAVE_UNSIGNED_CHAR
+#define HAVE_UNSIGNED_SHORT
+/* #define void char */
+/* #define const */
+#undef CHAR_IS_UNSIGNED
+#define HAVE_STDDEF_H
+#define HAVE_STDLIB_H
+#undef NEED_BSD_STRINGS
+#undef NEED_SYS_TYPES_H
+#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */
+#undef NEED_SHORT_EXTERNAL_NAMES
+#undef INCOMPLETE_TYPES_BROKEN
+
+/* Define "boolean" as unsigned char, not int, per Windows custom */
+#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
+typedef unsigned char boolean;
+#endif
+#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
+
+
+#ifdef JPEG_INTERNALS
+
+#undef RIGHT_SHIFT_IS_UNSIGNED
+
+#endif /* JPEG_INTERNALS */
+
+#ifdef JPEG_CJPEG_DJPEG
+
+#define BMP_SUPPORTED /* BMP image file format */
+#define GIF_SUPPORTED /* GIF image file format */
+#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
+#undef RLE_SUPPORTED /* Utah RLE image file format */
+#define TARGA_SUPPORTED /* Targa image file format */
+
+#define TWO_FILE_COMMANDLINE /* optional */
+#define USE_SETMODE /* Microsoft has setmode() */
+#undef NEED_SIGNAL_CATCHER
+#undef DONT_USE_B_MODE
+#undef PROGRESS_REPORT /* optional */
+
+#endif /* JPEG_CJPEG_DJPEG */
diff --git a/core/include/thirdparties/libjpeg/jerror.h b/core/include/thirdparties/libjpeg/jerror.h
index a2b8f96f8f..06d344067a 100644
--- a/core/include/thirdparties/libjpeg/jerror.h
+++ b/core/include/thirdparties/libjpeg/jerror.h
@@ -1,291 +1,291 @@
-/*
- * jerror.h
- *
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file defines the error and message codes for the JPEG library.
- * Edit this file to add new codes, or to translate the message strings to
- * some other language.
- * A set of error-reporting macros are defined too. Some applications using
- * the JPEG library may wish to include this file to get the error codes
- * and/or the macros.
- */
-
-/*
- * To define the enum list of message codes, include this file without
- * defining macro JMESSAGE. To create a message string table, include it
- * again with a suitable JMESSAGE definition (see jerror.c for an example).
- */
-#ifndef JMESSAGE
-#ifndef JERROR_H
-/* First time through, define the enum list */
-#define JMAKE_ENUM_LIST
-#else
-/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
-#define JMESSAGE(code,string)
-#endif /* JERROR_H */
-#endif /* JMESSAGE */
-
-#ifdef JMAKE_ENUM_LIST
-
-typedef enum {
-
-#define JMESSAGE(code,string) code ,
-
-#endif /* JMAKE_ENUM_LIST */
-
-JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
-
-/* For maintenance convenience, list is alphabetical by message code name */
-JMESSAGE(JERR_ARITH_NOTIMPL,
- "Sorry, there are legal restrictions on arithmetic coding")
-JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
-JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
-JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
-JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
-JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
-JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported")
-JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
-JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
-JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
-JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
-JMESSAGE(JERR_BAD_LIB_VERSION,
- "Wrong JPEG library version: library is %d, caller expects %d")
-JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
-JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
-JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
-JMESSAGE(JERR_BAD_PROGRESSION,
- "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d")
-JMESSAGE(JERR_BAD_PROG_SCRIPT,
- "Invalid progressive parameters at scan script entry %d")
-JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
-JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
-JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
-JMESSAGE(JERR_BAD_STRUCT_SIZE,
- "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
-JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
-JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
-JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
-JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
-JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
-JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
-JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
-JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
-JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
-JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
-JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
-JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
-JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
-JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
-JMESSAGE(JERR_FILE_READ, "Input file read error")
-JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
-JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
-JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
-JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
-JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
-JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
-JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
-JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
- "Cannot transcode due to multiple use of quantization table %d")
-JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
-JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
-JMESSAGE(JERR_NOTIMPL, "Not implemented yet")
-JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
-JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
-JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
-JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
-JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
-JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
-JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
-JMESSAGE(JERR_QUANT_COMPONENTS,
- "Cannot quantize more than %d color components")
-JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
-JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
-JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
-JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
-JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
-JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
-JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
-JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
-JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
-JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
-JMESSAGE(JERR_TFILE_WRITE,
- "Write failed on temporary file --- out of disk space?")
-JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
-JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
-JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
-JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
-JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
-JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
-JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)
-JMESSAGE(JMSG_VERSION, JVERSION)
-JMESSAGE(JTRC_16BIT_TABLES,
- "Caution: quantization tables are too coarse for baseline JPEG")
-JMESSAGE(JTRC_ADOBE,
- "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
-JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
-JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
-JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
-JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
-JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d")
-JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
-JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
-JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
-JMESSAGE(JTRC_EOI, "End Of Image")
-JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
-JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
-JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
- "Warning: thumbnail image size does not match data length %u")
-JMESSAGE(JTRC_JFIF_EXTENSION,
- "JFIF extension marker: type 0x%02x, length %u")
-JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
-JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
-JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
-JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u")
-JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
-JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
-JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
-JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
-JMESSAGE(JTRC_RST, "RST%d")
-JMESSAGE(JTRC_SMOOTH_NOTIMPL,
- "Smoothing not supported with nonstandard sampling ratios")
-JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
-JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d")
-JMESSAGE(JTRC_SOI, "Start of Image")
-JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
-JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d")
-JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d")
-JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
-JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
-JMESSAGE(JTRC_THUMB_JPEG,
- "JFIF extension marker: JPEG-compressed thumbnail image, length %u")
-JMESSAGE(JTRC_THUMB_PALETTE,
- "JFIF extension marker: palette thumbnail image, length %u")
-JMESSAGE(JTRC_THUMB_RGB,
- "JFIF extension marker: RGB thumbnail image, length %u")
-JMESSAGE(JTRC_UNKNOWN_IDS,
- "Unrecognized component IDs %d %d %d, assuming YCbCr")
-JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
-JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
-JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
-JMESSAGE(JWRN_BOGUS_PROGRESSION,
- "Inconsistent progression sequence for component %d coefficient %d")
-JMESSAGE(JWRN_EXTRANEOUS_DATA,
- "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
-JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
-JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
-JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
-JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
-JMESSAGE(JWRN_MUST_RESYNC,
- "Corrupt JPEG data: found marker 0x%02x instead of RST%d")
-JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
-JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
-
-#ifdef JMAKE_ENUM_LIST
-
- JMSG_LASTMSGCODE
-} J_MESSAGE_CODE;
-
-#undef JMAKE_ENUM_LIST
-#endif /* JMAKE_ENUM_LIST */
-
-/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
-#undef JMESSAGE
-
-
-#ifndef JERROR_H
-#define JERROR_H
-
-/* Macros to simplify using the error and trace message stuff */
-/* The first parameter is either type of cinfo pointer */
-
-/* Fatal errors (print message and exit) */
-#define ERREXIT(cinfo,code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
-#define ERREXIT1(cinfo,code,p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
-#define ERREXIT2(cinfo,code,p1,p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
-#define ERREXIT3(cinfo,code,p1,p2,p3) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
-#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (cinfo)->err->msg_parm.i[3] = (p4), \
- (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
-#define ERREXITS(cinfo,code,str) \
- ((cinfo)->err->msg_code = (code), \
- FXSYS_strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
- (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
-
-#define MAKESTMT(stuff) do { stuff } while (0)
-
-/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
-#define WARNMS(cinfo,code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
-#define WARNMS1(cinfo,code,p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
-#define WARNMS2(cinfo,code,p1,p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
-
-/* Informational/debugging messages */
-#define TRACEMS(cinfo,lvl,code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
-#define TRACEMS1(cinfo,lvl,code,p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
-#define TRACEMS2(cinfo,lvl,code,p1,p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
-#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \
- MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
-#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \
- MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
-#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \
- MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- _mp[4] = (p5); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
-#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \
- MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
-#define TRACEMSS(cinfo,lvl,code,str) \
- ((cinfo)->err->msg_code = (code), \
- FXSYS_strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
- (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
-
-#endif /* JERROR_H */
+/*
+ * jerror.h
+ *
+ * Copyright (C) 1994-1997, Thomas G. Lane.
+ * This file is part of the Independent JPEG Group's software.
+ * For conditions of distribution and use, see the accompanying README file.
+ *
+ * This file defines the error and message codes for the JPEG library.
+ * Edit this file to add new codes, or to translate the message strings to
+ * some other language.
+ * A set of error-reporting macros are defined too. Some applications using
+ * the JPEG library may wish to include this file to get the error codes
+ * and/or the macros.
+ */
+
+/*
+ * To define the enum list of message codes, include this file without
+ * defining macro JMESSAGE. To create a message string table, include it
+ * again with a suitable JMESSAGE definition (see jerror.c for an example).
+ */
+#ifndef JMESSAGE
+#ifndef JERROR_H
+/* First time through, define the enum list */
+#define JMAKE_ENUM_LIST
+#else
+/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
+#define JMESSAGE(code,string)
+#endif /* JERROR_H */
+#endif /* JMESSAGE */
+
+#ifdef JMAKE_ENUM_LIST
+
+typedef enum {
+
+#define JMESSAGE(code,string) code ,
+
+#endif /* JMAKE_ENUM_LIST */
+
+JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
+
+/* For maintenance convenience, list is alphabetical by message code name */
+JMESSAGE(JERR_ARITH_NOTIMPL,
+ "Sorry, there are legal restrictions on arithmetic coding")
+JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
+JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
+JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
+JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
+JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
+JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported")
+JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
+JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
+JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
+JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
+JMESSAGE(JERR_BAD_LIB_VERSION,
+ "Wrong JPEG library version: library is %d, caller expects %d")
+JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
+JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
+JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
+JMESSAGE(JERR_BAD_PROGRESSION,
+ "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d")
+JMESSAGE(JERR_BAD_PROG_SCRIPT,
+ "Invalid progressive parameters at scan script entry %d")
+JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
+JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
+JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
+JMESSAGE(JERR_BAD_STRUCT_SIZE,
+ "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
+JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
+JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
+JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
+JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
+JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
+JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
+JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
+JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
+JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
+JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
+JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
+JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
+JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
+JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
+JMESSAGE(JERR_FILE_READ, "Input file read error")
+JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
+JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
+JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
+JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
+JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
+JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
+JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
+JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
+ "Cannot transcode due to multiple use of quantization table %d")
+JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
+JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
+JMESSAGE(JERR_NOTIMPL, "Not implemented yet")
+JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
+JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
+JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
+JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
+JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
+JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
+JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
+JMESSAGE(JERR_QUANT_COMPONENTS,
+ "Cannot quantize more than %d color components")
+JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
+JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
+JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
+JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
+JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
+JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
+JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
+JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
+JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
+JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
+JMESSAGE(JERR_TFILE_WRITE,
+ "Write failed on temporary file --- out of disk space?")
+JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
+JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
+JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
+JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
+JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
+JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
+JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)
+JMESSAGE(JMSG_VERSION, JVERSION)
+JMESSAGE(JTRC_16BIT_TABLES,
+ "Caution: quantization tables are too coarse for baseline JPEG")
+JMESSAGE(JTRC_ADOBE,
+ "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
+JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
+JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
+JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
+JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
+JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d")
+JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
+JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
+JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
+JMESSAGE(JTRC_EOI, "End Of Image")
+JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
+JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
+JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
+ "Warning: thumbnail image size does not match data length %u")
+JMESSAGE(JTRC_JFIF_EXTENSION,
+ "JFIF extension marker: type 0x%02x, length %u")
+JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
+JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
+JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
+JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u")
+JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
+JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
+JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
+JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
+JMESSAGE(JTRC_RST, "RST%d")
+JMESSAGE(JTRC_SMOOTH_NOTIMPL,
+ "Smoothing not supported with nonstandard sampling ratios")
+JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
+JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d")
+JMESSAGE(JTRC_SOI, "Start of Image")
+JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
+JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d")
+JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d")
+JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
+JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
+JMESSAGE(JTRC_THUMB_JPEG,
+ "JFIF extension marker: JPEG-compressed thumbnail image, length %u")
+JMESSAGE(JTRC_THUMB_PALETTE,
+ "JFIF extension marker: palette thumbnail image, length %u")
+JMESSAGE(JTRC_THUMB_RGB,
+ "JFIF extension marker: RGB thumbnail image, length %u")
+JMESSAGE(JTRC_UNKNOWN_IDS,
+ "Unrecognized component IDs %d %d %d, assuming YCbCr")
+JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
+JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
+JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
+JMESSAGE(JWRN_BOGUS_PROGRESSION,
+ "Inconsistent progression sequence for component %d coefficient %d")
+JMESSAGE(JWRN_EXTRANEOUS_DATA,
+ "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
+JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
+JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
+JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
+JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
+JMESSAGE(JWRN_MUST_RESYNC,
+ "Corrupt JPEG data: found marker 0x%02x instead of RST%d")
+JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
+JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
+
+#ifdef JMAKE_ENUM_LIST
+
+ JMSG_LASTMSGCODE
+} J_MESSAGE_CODE;
+
+#undef JMAKE_ENUM_LIST
+#endif /* JMAKE_ENUM_LIST */
+
+/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
+#undef JMESSAGE
+
+
+#ifndef JERROR_H
+#define JERROR_H
+
+/* Macros to simplify using the error and trace message stuff */
+/* The first parameter is either type of cinfo pointer */
+
+/* Fatal errors (print message and exit) */
+#define ERREXIT(cinfo,code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT1(cinfo,code,p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT2(cinfo,code,p1,p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT3(cinfo,code,p1,p2,p3) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (cinfo)->err->msg_parm.i[3] = (p4), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXITS(cinfo,code,str) \
+ ((cinfo)->err->msg_code = (code), \
+ FXSYS_strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+
+#define MAKESTMT(stuff) do { stuff } while (0)
+
+/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
+#define WARNMS(cinfo,code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
+#define WARNMS1(cinfo,code,p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
+#define WARNMS2(cinfo,code,p1,p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
+
+/* Informational/debugging messages */
+#define TRACEMS(cinfo,lvl,code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+#define TRACEMS1(cinfo,lvl,code,p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+#define TRACEMS2(cinfo,lvl,code,p1,p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ _mp[4] = (p5); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMSS(cinfo,lvl,code,str) \
+ ((cinfo)->err->msg_code = (code), \
+ FXSYS_strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+
+#endif /* JERROR_H */
diff --git a/core/include/thirdparties/libjpeg/jmorecfg.h b/core/include/thirdparties/libjpeg/jmorecfg.h
index 3602114a5c..88d210954c 100644
--- a/core/include/thirdparties/libjpeg/jmorecfg.h
+++ b/core/include/thirdparties/libjpeg/jmorecfg.h
@@ -1,376 +1,376 @@
-/*
- * jmorecfg.h
- *
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file contains additional configuration options that customize the
- * JPEG software for special applications or support machine-dependent
- * optimizations. Most users will not need to touch this file.
- */
-
-#ifdef _MSC_VER
-#pragma warning (disable : 4142)
-#endif
-
-/*
- * Define BITS_IN_JSAMPLE as either
- * 8 for 8-bit sample values (the usual setting)
- * 12 for 12-bit sample values
- * Only 8 and 12 are legal data precisions for lossy JPEG according to the
- * JPEG standard, and the IJG code does not support anything else!
- * We do not support run-time selection of data precision, sorry.
- */
-
-#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
-
-
-/*
- * Maximum number of components (color channels) allowed in JPEG image.
- * To meet the letter of the JPEG spec, set this to 255. However, darn
- * few applications need more than 4 channels (maybe 5 for CMYK + alpha
- * mask). We recommend 10 as a reasonable compromise; use 4 if you are
- * really short on memory. (Each allowed component costs a hundred or so
- * bytes of storage, whether actually used in an image or not.)
- */
-
-#define MAX_COMPONENTS 10 /* maximum number of image components */
-
-
-/*
- * Basic data types.
- * You may need to change these if you have a machine with unusual data
- * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
- * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
- * but it had better be at least 16.
- */
-
-/* Representation of a single sample (pixel element value).
- * We frequently allocate large arrays of these, so it's important to keep
- * them small. But if you have memory to burn and access to char or short
- * arrays is very slow on your hardware, you might want to change these.
- */
-
-#if BITS_IN_JSAMPLE == 8
-/* JSAMPLE should be the smallest type that will hold the values 0..255.
- * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
- */
-
-#ifdef HAVE_UNSIGNED_CHAR
-
-typedef unsigned char JSAMPLE;
-#define GETJSAMPLE(value) ((int) (value))
-
-#else /* not HAVE_UNSIGNED_CHAR */
-
-typedef char JSAMPLE;
-#ifdef CHAR_IS_UNSIGNED
-#define GETJSAMPLE(value) ((int) (value))
-#else
-#define GETJSAMPLE(value) ((int) (value) & 0xFF)
-#endif /* CHAR_IS_UNSIGNED */
-
-#endif /* HAVE_UNSIGNED_CHAR */
-
-#define MAXJSAMPLE 255
-#define CENTERJSAMPLE 128
-
-#endif /* BITS_IN_JSAMPLE == 8 */
-
-
-#if BITS_IN_JSAMPLE == 12
-/* JSAMPLE should be the smallest type that will hold the values 0..4095.
- * On nearly all machines "short" will do nicely.
- */
-
-typedef short JSAMPLE;
-#define GETJSAMPLE(value) ((int) (value))
-
-#define MAXJSAMPLE 4095
-#define CENTERJSAMPLE 2048
-
-#endif /* BITS_IN_JSAMPLE == 12 */
-
-
-/* Representation of a DCT frequency coefficient.
- * This should be a signed value of at least 16 bits; "short" is usually OK.
- * Again, we allocate large arrays of these, but you can change to int
- * if you have memory to burn and "short" is really slow.
- */
-
-typedef short JCOEF;
-
-
-/* Compressed datastreams are represented as arrays of JOCTET.
- * These must be EXACTLY 8 bits wide, at least once they are written to
- * external storage. Note that when using the stdio data source/destination
- * managers, this is also the data type passed to fread/fwrite.
- */
-
-#ifdef HAVE_UNSIGNED_CHAR
-
-typedef unsigned char JOCTET;
-#define GETJOCTET(value) (value)
-
-#else /* not HAVE_UNSIGNED_CHAR */
-
-typedef char JOCTET;
-#ifdef CHAR_IS_UNSIGNED
-#define GETJOCTET(value) (value)
-#else
-#define GETJOCTET(value) ((value) & 0xFF)
-#endif /* CHAR_IS_UNSIGNED */
-
-#endif /* HAVE_UNSIGNED_CHAR */
-
-
-/* These typedefs are used for various table entries and so forth.
- * They must be at least as wide as specified; but making them too big
- * won't cost a huge amount of memory, so we don't provide special
- * extraction code like we did for JSAMPLE. (In other words, these
- * typedefs live at a different point on the speed/space tradeoff curve.)
- */
-
-#if _FX_OS_ != _FX_VXWORKS_
-
-/* UINT8 must hold at least the values 0..255. */
-
-#ifdef HAVE_UNSIGNED_CHAR
-typedef unsigned char UINT8;
-#else /* not HAVE_UNSIGNED_CHAR */
-#ifdef CHAR_IS_UNSIGNED
-typedef char UINT8;
-#else /* not CHAR_IS_UNSIGNED */
-typedef short UINT8;
-#endif /* CHAR_IS_UNSIGNED */
-#endif /* HAVE_UNSIGNED_CHAR */
-
-
-/* UINT16 must hold at least the values 0..65535. */
-
-#ifdef HAVE_UNSIGNED_SHORT
-typedef unsigned short UINT16;
-#else /* not HAVE_UNSIGNED_SHORT */
-typedef unsigned int UINT16;
-#endif /* HAVE_UNSIGNED_SHORT */
-
-/* INT16 must hold at least the values -32768..32767. */
-
-#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
-typedef short INT16;
-#endif
-
-/* INT32 must hold at least signed 32-bit values. */
-
-#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
-typedef int INT32;
-#endif
-
-#endif
-
-/* Datatype used for image dimensions. The JPEG standard only supports
- * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
- * "unsigned int" is sufficient on all machines. However, if you need to
- * handle larger images and you don't mind deviating from the spec, you
- * can change this datatype.
- */
-
-typedef unsigned int JDIMENSION;
-
-#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
-
-
-/* These macros are used in all function definitions and extern declarations.
- * You could modify them if you need to change function linkage conventions;
- * in particular, you'll need to do that to make the library a Windows DLL.
- * Another application is to make all functions global for use with debuggers
- * or code profilers that require it.
- */
-
-/* a function called through method pointers: */
-#define METHODDEF(type) static type
-/* a function used only in its module: */
-#define LOCAL(type) static type
-/* a function referenced thru EXTERNs: */
-#define GLOBAL(type) type
-
-#ifdef _FX_MANAGED_CODE_
-#define EXTERN(type) extern "C" type
-#else
-/* a reference to a GLOBAL function: */
-#define EXTERN(type) extern type
-#endif
-
-
-/* This macro is used to declare a "method", that is, a function pointer.
- * We want to supply prototype parameters if the compiler can cope.
- * Note that the arglist parameter must be parenthesized!
- * Again, you can customize this if you need special linkage keywords.
- */
-
-#ifdef HAVE_PROTOTYPES
-#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
-#else
-#define JMETHOD(type,methodname,arglist) type (*methodname) ()
-#endif
-
-
-/* Here is the pseudo-keyword for declaring pointers that must be "far"
- * on 80x86 machines. Most of the specialized coding for 80x86 is handled
- * by just saying "FAR *" where such a pointer is needed. In a few places
- * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
- */
-
-#ifdef NEED_FAR_POINTERS
-#define FAR far
-#else
-//#define FAR
-#endif
-
-
-/*
- * On a few systems, type boolean and/or its values FALSE, TRUE may appear
- * in standard header files. Or you may have conflicts with application-
- * specific header files that you want to include together with these files.
- * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
- */
-
-#ifndef HAVE_BOOLEAN
-typedef int boolean;
-#endif
-#ifndef FALSE /* in case these macros already exist */
-#define FALSE 0 /* values of boolean */
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-
-/*
- * The remaining options affect code selection within the JPEG library,
- * but they don't need to be visible to most applications using the library.
- * To minimize application namespace pollution, the symbols won't be
- * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
- */
-
-#ifdef JPEG_INTERNALS
-#define JPEG_INTERNAL_OPTIONS
-#endif
-
-#ifdef JPEG_INTERNAL_OPTIONS
-
-
-/*
- * These defines indicate whether to include various optional functions.
- * Undefining some of these symbols will produce a smaller but less capable
- * library. Note that you can leave certain source files out of the
- * compilation/linking process if you've #undef'd the corresponding symbols.
- * (You may HAVE to do that if your compiler doesn't like null source files.)
- */
-
-/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
-
-/* Capability options common to encoder and decoder: */
-
-#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
-#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
-#undef DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
-
-/* Encoder capability options: */
-
-#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
-#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
-/* Note: if you selected 12-bit data precision, it is dangerous to turn off
- * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
- * precision, so jchuff.c normally uses entropy optimization to compute
- * usable tables for higher precision. If you don't want to do optimization,
- * you'll have to supply different default Huffman tables.
- * The exact same statements apply for progressive JPEG: the default tables
- * don't work for progressive mode. (This may get fixed, however.)
- */
-#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
-
-/* Decoder capability options: */
-
-#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
-#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
-#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
-#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
-#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
-#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
-#undef QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
-#undef QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
-
-/* more capability options later, no doubt */
-
-
-/*
- * Ordering of RGB data in scanlines passed to or from the application.
- * If your application wants to deal with data in the order B,G,R, just
- * change these macros. You can also deal with formats such as R,G,B,X
- * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
- * the offsets will also change the order in which colormap data is organized.
- * RESTRICTIONS:
- * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
- * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
- * useful if you are using JPEG color spaces other than YCbCr or grayscale.
- * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
- * is not 3 (they don't understand about dummy color components!). So you
- * can't use color quantization if you change that value.
- */
-
-#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
-#define RGB_GREEN 1 /* Offset of Green */
-#define RGB_BLUE 2 /* Offset of Blue */
-#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
-
-
-/* Definitions for speed-related optimizations. */
-
-
-/* If your compiler supports inline functions, define INLINE
- * as the inline keyword; otherwise define it as empty.
- */
-
-#ifndef INLINE
-#ifdef __GNUC__ /* for instance, GNU C knows about inline */
-#define INLINE __inline__
-#endif
-#ifndef INLINE
-#define INLINE /* default is to define it as empty */
-#endif
-#endif
-
-
-/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
- * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
- * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
- */
-
-#ifndef MULTIPLIER
-#define MULTIPLIER int /* type for fastest integer multiply */
-#endif
-
-
-/* FAST_FLOAT should be either float or double, whichever is done faster
- * by your compiler. (Note that this type is only used in the floating point
- * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
- * Typically, float is faster in ANSI C compilers, while double is faster in
- * pre-ANSI compilers (because they insist on converting to double anyway).
- * The code below therefore chooses float if we have ANSI-style prototypes.
- */
-
-#ifndef FAST_FLOAT
-#ifdef HAVE_PROTOTYPES
-#define FAST_FLOAT float
-#else
-#define FAST_FLOAT double
-#endif
-#endif
-
-#endif /* JPEG_INTERNAL_OPTIONS */
+/*
+ * jmorecfg.h
+ *
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * This file is part of the Independent JPEG Group's software.
+ * For conditions of distribution and use, see the accompanying README file.
+ *
+ * This file contains additional configuration options that customize the
+ * JPEG software for special applications or support machine-dependent
+ * optimizations. Most users will not need to touch this file.
+ */
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4142)
+#endif
+
+/*
+ * Define BITS_IN_JSAMPLE as either
+ * 8 for 8-bit sample values (the usual setting)
+ * 12 for 12-bit sample values
+ * Only 8 and 12 are legal data precisions for lossy JPEG according to the
+ * JPEG standard, and the IJG code does not support anything else!
+ * We do not support run-time selection of data precision, sorry.
+ */
+
+#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
+
+
+/*
+ * Maximum number of components (color channels) allowed in JPEG image.
+ * To meet the letter of the JPEG spec, set this to 255. However, darn
+ * few applications need more than 4 channels (maybe 5 for CMYK + alpha
+ * mask). We recommend 10 as a reasonable compromise; use 4 if you are
+ * really short on memory. (Each allowed component costs a hundred or so
+ * bytes of storage, whether actually used in an image or not.)
+ */
+
+#define MAX_COMPONENTS 10 /* maximum number of image components */
+
+
+/*
+ * Basic data types.
+ * You may need to change these if you have a machine with unusual data
+ * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
+ * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
+ * but it had better be at least 16.
+ */
+
+/* Representation of a single sample (pixel element value).
+ * We frequently allocate large arrays of these, so it's important to keep
+ * them small. But if you have memory to burn and access to char or short
+ * arrays is very slow on your hardware, you might want to change these.
+ */
+
+#if BITS_IN_JSAMPLE == 8
+/* JSAMPLE should be the smallest type that will hold the values 0..255.
+ * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
+ */
+
+#ifdef HAVE_UNSIGNED_CHAR
+
+typedef unsigned char JSAMPLE;
+#define GETJSAMPLE(value) ((int) (value))
+
+#else /* not HAVE_UNSIGNED_CHAR */
+
+typedef char JSAMPLE;
+#ifdef CHAR_IS_UNSIGNED
+#define GETJSAMPLE(value) ((int) (value))
+#else
+#define GETJSAMPLE(value) ((int) (value) & 0xFF)
+#endif /* CHAR_IS_UNSIGNED */
+
+#endif /* HAVE_UNSIGNED_CHAR */
+
+#define MAXJSAMPLE 255
+#define CENTERJSAMPLE 128
+
+#endif /* BITS_IN_JSAMPLE == 8 */
+
+
+#if BITS_IN_JSAMPLE == 12
+/* JSAMPLE should be the smallest type that will hold the values 0..4095.
+ * On nearly all machines "short" will do nicely.
+ */
+
+typedef short JSAMPLE;
+#define GETJSAMPLE(value) ((int) (value))
+
+#define MAXJSAMPLE 4095
+#define CENTERJSAMPLE 2048
+
+#endif /* BITS_IN_JSAMPLE == 12 */
+
+
+/* Representation of a DCT frequency coefficient.
+ * This should be a signed value of at least 16 bits; "short" is usually OK.
+ * Again, we allocate large arrays of these, but you can change to int
+ * if you have memory to burn and "short" is really slow.
+ */
+
+typedef short JCOEF;
+
+
+/* Compressed datastreams are represented as arrays of JOCTET.
+ * These must be EXACTLY 8 bits wide, at least once they are written to
+ * external storage. Note that when using the stdio data source/destination
+ * managers, this is also the data type passed to fread/fwrite.
+ */
+
+#ifdef HAVE_UNSIGNED_CHAR
+
+typedef unsigned char JOCTET;
+#define GETJOCTET(value) (value)
+
+#else /* not HAVE_UNSIGNED_CHAR */
+
+typedef char JOCTET;
+#ifdef CHAR_IS_UNSIGNED
+#define GETJOCTET(value) (value)
+#else
+#define GETJOCTET(value) ((value) & 0xFF)
+#endif /* CHAR_IS_UNSIGNED */
+
+#endif /* HAVE_UNSIGNED_CHAR */
+
+
+/* These typedefs are used for various table entries and so forth.
+ * They must be at least as wide as specified; but making them too big
+ * won't cost a huge amount of memory, so we don't provide special
+ * extraction code like we did for JSAMPLE. (In other words, these
+ * typedefs live at a different point on the speed/space tradeoff curve.)
+ */
+
+#if _FX_OS_ != _FX_VXWORKS_
+
+/* UINT8 must hold at least the values 0..255. */
+
+#ifdef HAVE_UNSIGNED_CHAR
+typedef unsigned char UINT8;
+#else /* not HAVE_UNSIGNED_CHAR */
+#ifdef CHAR_IS_UNSIGNED
+typedef char UINT8;
+#else /* not CHAR_IS_UNSIGNED */
+typedef short UINT8;
+#endif /* CHAR_IS_UNSIGNED */
+#endif /* HAVE_UNSIGNED_CHAR */
+
+
+/* UINT16 must hold at least the values 0..65535. */
+
+#ifdef HAVE_UNSIGNED_SHORT
+typedef unsigned short UINT16;
+#else /* not HAVE_UNSIGNED_SHORT */
+typedef unsigned int UINT16;
+#endif /* HAVE_UNSIGNED_SHORT */
+
+/* INT16 must hold at least the values -32768..32767. */
+
+#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
+typedef short INT16;
+#endif
+
+/* INT32 must hold at least signed 32-bit values. */
+
+#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
+typedef int INT32;
+#endif
+
+#endif
+
+/* Datatype used for image dimensions. The JPEG standard only supports
+ * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
+ * "unsigned int" is sufficient on all machines. However, if you need to
+ * handle larger images and you don't mind deviating from the spec, you
+ * can change this datatype.
+ */
+
+typedef unsigned int JDIMENSION;
+
+#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
+
+
+/* These macros are used in all function definitions and extern declarations.
+ * You could modify them if you need to change function linkage conventions;
+ * in particular, you'll need to do that to make the library a Windows DLL.
+ * Another application is to make all functions global for use with debuggers
+ * or code profilers that require it.
+ */
+
+/* a function called through method pointers: */
+#define METHODDEF(type) static type
+/* a function used only in its module: */
+#define LOCAL(type) static type
+/* a function referenced thru EXTERNs: */
+#define GLOBAL(type) type
+
+#ifdef _FX_MANAGED_CODE_
+#define EXTERN(type) extern "C" type
+#else
+/* a reference to a GLOBAL function: */
+#define EXTERN(type) extern type
+#endif
+
+
+/* This macro is used to declare a "method", that is, a function pointer.
+ * We want to supply prototype parameters if the compiler can cope.
+ * Note that the arglist parameter must be parenthesized!
+ * Again, you can customize this if you need special linkage keywords.
+ */
+
+#ifdef HAVE_PROTOTYPES
+#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
+#else
+#define JMETHOD(type,methodname,arglist) type (*methodname) ()
+#endif
+
+
+/* Here is the pseudo-keyword for declaring pointers that must be "far"
+ * on 80x86 machines. Most of the specialized coding for 80x86 is handled
+ * by just saying "FAR *" where such a pointer is needed. In a few places
+ * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
+ */
+
+#ifdef NEED_FAR_POINTERS
+#define FAR far
+#else
+//#define FAR
+#endif
+
+
+/*
+ * On a few systems, type boolean and/or its values FALSE, TRUE may appear
+ * in standard header files. Or you may have conflicts with application-
+ * specific header files that you want to include together with these files.
+ * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
+ */
+
+#ifndef HAVE_BOOLEAN
+typedef int boolean;
+#endif
+#ifndef FALSE /* in case these macros already exist */
+#define FALSE 0 /* values of boolean */
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+
+/*
+ * The remaining options affect code selection within the JPEG library,
+ * but they don't need to be visible to most applications using the library.
+ * To minimize application namespace pollution, the symbols won't be
+ * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
+ */
+
+#ifdef JPEG_INTERNALS
+#define JPEG_INTERNAL_OPTIONS
+#endif
+
+#ifdef JPEG_INTERNAL_OPTIONS
+
+
+/*
+ * These defines indicate whether to include various optional functions.
+ * Undefining some of these symbols will produce a smaller but less capable
+ * library. Note that you can leave certain source files out of the
+ * compilation/linking process if you've #undef'd the corresponding symbols.
+ * (You may HAVE to do that if your compiler doesn't like null source files.)
+ */
+
+/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
+
+/* Capability options common to encoder and decoder: */
+
+#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
+#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
+#undef DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
+
+/* Encoder capability options: */
+
+#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
+#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
+#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
+#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
+/* Note: if you selected 12-bit data precision, it is dangerous to turn off
+ * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
+ * precision, so jchuff.c normally uses entropy optimization to compute
+ * usable tables for higher precision. If you don't want to do optimization,
+ * you'll have to supply different default Huffman tables.
+ * The exact same statements apply for progressive JPEG: the default tables
+ * don't work for progressive mode. (This may get fixed, however.)
+ */
+#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
+
+/* Decoder capability options: */
+
+#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
+#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
+#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
+#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
+#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
+#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
+#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
+#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
+#undef QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
+#undef QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
+
+/* more capability options later, no doubt */
+
+
+/*
+ * Ordering of RGB data in scanlines passed to or from the application.
+ * If your application wants to deal with data in the order B,G,R, just
+ * change these macros. You can also deal with formats such as R,G,B,X
+ * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
+ * the offsets will also change the order in which colormap data is organized.
+ * RESTRICTIONS:
+ * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
+ * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
+ * useful if you are using JPEG color spaces other than YCbCr or grayscale.
+ * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
+ * is not 3 (they don't understand about dummy color components!). So you
+ * can't use color quantization if you change that value.
+ */
+
+#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
+#define RGB_GREEN 1 /* Offset of Green */
+#define RGB_BLUE 2 /* Offset of Blue */
+#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
+
+
+/* Definitions for speed-related optimizations. */
+
+
+/* If your compiler supports inline functions, define INLINE
+ * as the inline keyword; otherwise define it as empty.
+ */
+
+#ifndef INLINE
+#ifdef __GNUC__ /* for instance, GNU C knows about inline */
+#define INLINE __inline__
+#endif
+#ifndef INLINE
+#define INLINE /* default is to define it as empty */
+#endif
+#endif
+
+
+/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
+ * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
+ * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
+ */
+
+#ifndef MULTIPLIER
+#define MULTIPLIER int /* type for fastest integer multiply */
+#endif
+
+
+/* FAST_FLOAT should be either float or double, whichever is done faster
+ * by your compiler. (Note that this type is only used in the floating point
+ * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
+ * Typically, float is faster in ANSI C compilers, while double is faster in
+ * pre-ANSI compilers (because they insist on converting to double anyway).
+ * The code below therefore chooses float if we have ANSI-style prototypes.
+ */
+
+#ifndef FAST_FLOAT
+#ifdef HAVE_PROTOTYPES
+#define FAST_FLOAT float
+#else
+#define FAST_FLOAT double
+#endif
+#endif
+
+#endif /* JPEG_INTERNAL_OPTIONS */
diff --git a/core/include/thirdparties/libjpeg/jpegint.h b/core/include/thirdparties/libjpeg/jpegint.h
index 685a3610b2..95b00d405c 100644
--- a/core/include/thirdparties/libjpeg/jpegint.h
+++ b/core/include/thirdparties/libjpeg/jpegint.h
@@ -1,392 +1,392 @@
-/*
- * jpegint.h
- *
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file provides common declarations for the various JPEG modules.
- * These declarations are considered internal to the JPEG library; most
- * applications using the library shouldn't need to include this file.
- */
-
-
-/* Declarations for both compression & decompression */
-
-typedef enum { /* Operating modes for buffer controllers */
- JBUF_PASS_THRU, /* Plain stripwise operation */
- /* Remaining modes require a full-image buffer to have been created */
- JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
- JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
- JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
-} J_BUF_MODE;
-
-/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
-#define CSTATE_START 100 /* after create_compress */
-#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
-#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
-#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
-#define DSTATE_START 200 /* after create_decompress */
-#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
-#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
-#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
-#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
-#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
-#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
-#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
-#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
-#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
-#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
-
-
-/* Declarations for compression modules */
-
-/* Master control module */
-struct jpeg_comp_master {
- JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));
- JMETHOD(void, pass_startup, (j_compress_ptr cinfo));
- JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
-
- /* State variables made visible to other modules */
- boolean call_pass_startup; /* True if pass_startup must be called */
- boolean is_last_pass; /* True during last pass */
-};
-
-/* Main buffer control (downsampled-data buffer) */
-struct jpeg_c_main_controller {
- JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, process_data, (j_compress_ptr cinfo,
- JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
- JDIMENSION in_rows_avail));
-};
-
-/* Compression preprocessing (downsampling input buffer control) */
-struct jpeg_c_prep_controller {
- JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
- JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr,
- JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf,
- JDIMENSION *out_row_group_ctr,
- JDIMENSION out_row_groups_avail));
-};
-
-/* Coefficient buffer control */
-struct jpeg_c_coef_controller {
- JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,
- JSAMPIMAGE input_buf));
-};
-
-/* Colorspace conversion */
-struct jpeg_color_converter {
- JMETHOD(void, start_pass, (j_compress_ptr cinfo));
- JMETHOD(void, color_convert, (j_compress_ptr cinfo,
- JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows));
-};
-
-/* Downsampling */
-struct jpeg_downsampler {
- JMETHOD(void, start_pass, (j_compress_ptr cinfo));
- JMETHOD(void, downsample, (j_compress_ptr cinfo,
- JSAMPIMAGE input_buf, JDIMENSION in_row_index,
- JSAMPIMAGE output_buf,
- JDIMENSION out_row_group_index));
-
- boolean need_context_rows; /* TRUE if need rows above & below */
-};
-
-/* Forward DCT (also controls coefficient quantization) */
-struct jpeg_forward_dct {
- JMETHOD(void, start_pass, (j_compress_ptr cinfo));
- /* perhaps this should be an array??? */
- JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
- jpeg_component_info * compptr,
- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
- JDIMENSION start_row, JDIMENSION start_col,
- JDIMENSION num_blocks));
-};
-
-/* Entropy encoding */
-struct jpeg_entropy_encoder {
- JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
- JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
- JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
-};
-
-/* Marker writing */
-struct jpeg_marker_writer {
- JMETHOD(void, write_file_header, (j_compress_ptr cinfo));
- JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));
- JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));
- JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));
- JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));
- /* These routines are exported to allow insertion of extra markers */
- /* Probably only COM and APPn markers should be written this way */
- JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker,
- unsigned int datalen));
- JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
-};
-
-
-/* Declarations for decompression modules */
-
-/* Master control module */
-struct jpeg_decomp_master {
- JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
- JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
-
- /* State variables made visible to other modules */
- boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
-};
-
-/* Input control module */
-struct jpeg_input_controller {
- JMETHOD(int, consume_input, (j_decompress_ptr cinfo));
- JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));
- JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
- JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));
-
- /* State variables made visible to other modules */
- boolean has_multiple_scans; /* True if file has multiple scans */
- boolean eoi_reached; /* True when EOI has been consumed */
-};
-
-/* Main buffer control (downsampled-data buffer) */
-struct jpeg_d_main_controller {
- JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, process_data, (j_decompress_ptr cinfo,
- JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail));
-};
-
-/* Coefficient buffer control */
-struct jpeg_d_coef_controller {
- JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
- JMETHOD(int, consume_data, (j_decompress_ptr cinfo));
- JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));
- JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,
- JSAMPIMAGE output_buf));
- /* Pointer to array of coefficient virtual arrays, or NULL if none */
- jvirt_barray_ptr *coef_arrays;
-};
-
-/* Decompression postprocessing (color quantization buffer control) */
-struct jpeg_d_post_controller {
- JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail));
-};
-
-/* Marker reading & parsing */
-struct jpeg_marker_reader {
- JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));
- /* Read markers until SOS or EOI.
- * Returns same codes as are defined for jpeg_consume_input:
- * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
- */
- JMETHOD(int, read_markers, (j_decompress_ptr cinfo));
- /* Read a restart marker --- exported for use by entropy decoder only */
- jpeg_marker_parser_method read_restart_marker;
-
- /* State of marker reader --- nominally internal, but applications
- * supplying COM or APPn handlers might like to know the state.
- */
- boolean saw_SOI; /* found SOI? */
- boolean saw_SOF; /* found SOF? */
- int next_restart_num; /* next restart number expected (0-7) */
- unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
-};
-
-/* Entropy decoding */
-struct jpeg_entropy_decoder {
- JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
- JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
- JBLOCKROW *MCU_data));
-
- /* This is here to share code between baseline and progressive decoders; */
- /* other modules probably should not use it */
- boolean insufficient_data; /* set TRUE after emitting warning */
-};
-
-/* Inverse DCT (also performs dequantization) */
-typedef JMETHOD(void, inverse_DCT_method_ptr,
- (j_decompress_ptr cinfo, jpeg_component_info * compptr,
- JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col));
-
-struct jpeg_inverse_dct {
- JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
- /* It is useful to allow each component to have a separate IDCT method. */
- inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
-};
-
-/* Upsampling (note that upsampler must also call color converter) */
-struct jpeg_upsampler {
- JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
- JMETHOD(void, upsample, (j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail));
-
- boolean need_context_rows; /* TRUE if need rows above & below */
-};
-
-/* Colorspace conversion */
-struct jpeg_color_deconverter {
- JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
- JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf, JDIMENSION input_row,
- JSAMPARRAY output_buf, int num_rows));
-};
-
-/* Color quantization or color precision reduction */
-struct jpeg_color_quantizer {
- JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
- JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
- JSAMPARRAY input_buf, JSAMPARRAY output_buf,
- int num_rows));
- JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
- JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
-};
-
-
-/* Miscellaneous useful macros */
-
-#undef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#undef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-
-
-/* We assume that right shift corresponds to signed division by 2 with
- * rounding towards minus infinity. This is correct for typical "arithmetic
- * shift" instructions that shift in copies of the sign bit. But some
- * C compilers implement >> with an unsigned shift. For these machines you
- * must define RIGHT_SHIFT_IS_UNSIGNED.
- * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
- * It is only applied with constant shift counts. SHIFT_TEMPS must be
- * included in the variables of any routine using RIGHT_SHIFT.
- */
-
-#ifdef RIGHT_SHIFT_IS_UNSIGNED
-#define SHIFT_TEMPS INT32 shift_temp;
-#define RIGHT_SHIFT(x,shft) \
- ((shift_temp = (x)) < 0 ? \
- (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
- (shift_temp >> (shft)))
-#else
-#define SHIFT_TEMPS
-#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
-#endif
-
-
-/* Short forms of external names for systems with brain-damaged linkers. */
-
-#ifdef NEED_SHORT_EXTERNAL_NAMES
-#define jinit_compress_master jICompress
-#define jinit_c_master_control jICMaster
-#define jinit_c_main_controller jICMainC
-#define jinit_c_prep_controller jICPrepC
-#define jinit_c_coef_controller jICCoefC
-#define jinit_color_converter jICColor
-#define jinit_downsampler jIDownsampler
-#define jinit_forward_dct jIFDCT
-#define jinit_huff_encoder jIHEncoder
-#define jinit_phuff_encoder jIPHEncoder
-#define jinit_marker_writer jIMWriter
-#define jinit_master_decompress jIDMaster
-#define jinit_d_main_controller jIDMainC
-#define jinit_d_coef_controller jIDCoefC
-#define jinit_d_post_controller jIDPostC
-#define jinit_input_controller jIInCtlr
-#define jinit_marker_reader jIMReader
-#define jinit_huff_decoder jIHDecoder
-#define jinit_phuff_decoder jIPHDecoder
-#define jinit_inverse_dct jIIDCT
-#define jinit_upsampler jIUpsampler
-#define jinit_color_deconverter jIDColor
-#define jinit_1pass_quantizer jI1Quant
-#define jinit_2pass_quantizer jI2Quant
-#define jinit_merged_upsampler jIMUpsampler
-#define jinit_memory_mgr jIMemMgr
-#define jdiv_round_up jDivRound
-#define jround_up jRound
-#define jcopy_sample_rows jCopySamples
-#define jcopy_block_row jCopyBlocks
-#define jzero_far jZeroFar
-#define jpeg_zigzag_order jZIGTable
-#define jpeg_natural_order jZAGTable
-#endif /* NEED_SHORT_EXTERNAL_NAMES */
-
-
-/* Compression module initialization routines */
-EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
-EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
- boolean transcode_only));
-EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo,
- boolean need_full_buffer));
-EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo,
- boolean need_full_buffer));
-EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo,
- boolean need_full_buffer));
-EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
-EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
-EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
-EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
-EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
-EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
-/* Decompression module initialization routines */
-EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo,
- boolean need_full_buffer));
-EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo,
- boolean need_full_buffer));
-EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
- boolean need_full_buffer));
-EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo));
-/* Memory manager initialization */
-EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
-
-/* Utility routines in jutils.c */
-EXTERN(long) jdiv_round_up JPP((long a, long b));
-EXTERN(long) jround_up JPP((long a, long b));
-EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
- JSAMPARRAY output_array, int dest_row,
- int num_rows, JDIMENSION num_cols));
-EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
- JDIMENSION num_blocks));
-EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
-/* Constant tables in jutils.c */
-#if 0 /* This table is not actually needed in v6a */
-extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
-#endif
-extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
-
-/* Suppress undefined-structure complaints if necessary. */
-
-#ifdef INCOMPLETE_TYPES_BROKEN
-#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */
-struct jvirt_sarray_control { long dummy; };
-struct jvirt_barray_control { long dummy; };
-#endif
-#endif /* INCOMPLETE_TYPES_BROKEN */
+/*
+ * jpegint.h
+ *
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * This file is part of the Independent JPEG Group's software.
+ * For conditions of distribution and use, see the accompanying README file.
+ *
+ * This file provides common declarations for the various JPEG modules.
+ * These declarations are considered internal to the JPEG library; most
+ * applications using the library shouldn't need to include this file.
+ */
+
+
+/* Declarations for both compression & decompression */
+
+typedef enum { /* Operating modes for buffer controllers */
+ JBUF_PASS_THRU, /* Plain stripwise operation */
+ /* Remaining modes require a full-image buffer to have been created */
+ JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
+ JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
+ JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
+} J_BUF_MODE;
+
+/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
+#define CSTATE_START 100 /* after create_compress */
+#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
+#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
+#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
+#define DSTATE_START 200 /* after create_decompress */
+#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
+#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
+#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
+#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
+#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
+#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
+#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
+#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
+#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
+#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
+
+
+/* Declarations for compression modules */
+
+/* Master control module */
+struct jpeg_comp_master {
+ JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));
+ JMETHOD(void, pass_startup, (j_compress_ptr cinfo));
+ JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
+
+ /* State variables made visible to other modules */
+ boolean call_pass_startup; /* True if pass_startup must be called */
+ boolean is_last_pass; /* True during last pass */
+};
+
+/* Main buffer control (downsampled-data buffer) */
+struct jpeg_c_main_controller {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
+ JMETHOD(void, process_data, (j_compress_ptr cinfo,
+ JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
+ JDIMENSION in_rows_avail));
+};
+
+/* Compression preprocessing (downsampling input buffer control) */
+struct jpeg_c_prep_controller {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
+ JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
+ JSAMPARRAY input_buf,
+ JDIMENSION *in_row_ctr,
+ JDIMENSION in_rows_avail,
+ JSAMPIMAGE output_buf,
+ JDIMENSION *out_row_group_ctr,
+ JDIMENSION out_row_groups_avail));
+};
+
+/* Coefficient buffer control */
+struct jpeg_c_coef_controller {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
+ JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,
+ JSAMPIMAGE input_buf));
+};
+
+/* Colorspace conversion */
+struct jpeg_color_converter {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo));
+ JMETHOD(void, color_convert, (j_compress_ptr cinfo,
+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
+ JDIMENSION output_row, int num_rows));
+};
+
+/* Downsampling */
+struct jpeg_downsampler {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo));
+ JMETHOD(void, downsample, (j_compress_ptr cinfo,
+ JSAMPIMAGE input_buf, JDIMENSION in_row_index,
+ JSAMPIMAGE output_buf,
+ JDIMENSION out_row_group_index));
+
+ boolean need_context_rows; /* TRUE if need rows above & below */
+};
+
+/* Forward DCT (also controls coefficient quantization) */
+struct jpeg_forward_dct {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo));
+ /* perhaps this should be an array??? */
+ JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
+ jpeg_component_info * compptr,
+ JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
+ JDIMENSION start_row, JDIMENSION start_col,
+ JDIMENSION num_blocks));
+};
+
+/* Entropy encoding */
+struct jpeg_entropy_encoder {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
+ JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
+ JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
+};
+
+/* Marker writing */
+struct jpeg_marker_writer {
+ JMETHOD(void, write_file_header, (j_compress_ptr cinfo));
+ JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));
+ JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));
+ JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));
+ JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));
+ /* These routines are exported to allow insertion of extra markers */
+ /* Probably only COM and APPn markers should be written this way */
+ JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker,
+ unsigned int datalen));
+ JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
+};
+
+
+/* Declarations for decompression modules */
+
+/* Master control module */
+struct jpeg_decomp_master {
+ JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
+ JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
+
+ /* State variables made visible to other modules */
+ boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
+};
+
+/* Input control module */
+struct jpeg_input_controller {
+ JMETHOD(int, consume_input, (j_decompress_ptr cinfo));
+ JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));
+ JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
+ JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));
+
+ /* State variables made visible to other modules */
+ boolean has_multiple_scans; /* True if file has multiple scans */
+ boolean eoi_reached; /* True when EOI has been consumed */
+};
+
+/* Main buffer control (downsampled-data buffer) */
+struct jpeg_d_main_controller {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
+ JMETHOD(void, process_data, (j_decompress_ptr cinfo,
+ JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
+ JDIMENSION out_rows_avail));
+};
+
+/* Coefficient buffer control */
+struct jpeg_d_coef_controller {
+ JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
+ JMETHOD(int, consume_data, (j_decompress_ptr cinfo));
+ JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));
+ JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,
+ JSAMPIMAGE output_buf));
+ /* Pointer to array of coefficient virtual arrays, or NULL if none */
+ jvirt_barray_ptr *coef_arrays;
+};
+
+/* Decompression postprocessing (color quantization buffer control) */
+struct jpeg_d_post_controller {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
+ JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
+ JSAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail,
+ JSAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr,
+ JDIMENSION out_rows_avail));
+};
+
+/* Marker reading & parsing */
+struct jpeg_marker_reader {
+ JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));
+ /* Read markers until SOS or EOI.
+ * Returns same codes as are defined for jpeg_consume_input:
+ * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
+ */
+ JMETHOD(int, read_markers, (j_decompress_ptr cinfo));
+ /* Read a restart marker --- exported for use by entropy decoder only */
+ jpeg_marker_parser_method read_restart_marker;
+
+ /* State of marker reader --- nominally internal, but applications
+ * supplying COM or APPn handlers might like to know the state.
+ */
+ boolean saw_SOI; /* found SOI? */
+ boolean saw_SOF; /* found SOF? */
+ int next_restart_num; /* next restart number expected (0-7) */
+ unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
+};
+
+/* Entropy decoding */
+struct jpeg_entropy_decoder {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+ JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
+ JBLOCKROW *MCU_data));
+
+ /* This is here to share code between baseline and progressive decoders; */
+ /* other modules probably should not use it */
+ boolean insufficient_data; /* set TRUE after emitting warning */
+};
+
+/* Inverse DCT (also performs dequantization) */
+typedef JMETHOD(void, inverse_DCT_method_ptr,
+ (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+ JCOEFPTR coef_block,
+ JSAMPARRAY output_buf, JDIMENSION output_col));
+
+struct jpeg_inverse_dct {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+ /* It is useful to allow each component to have a separate IDCT method. */
+ inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
+};
+
+/* Upsampling (note that upsampler must also call color converter) */
+struct jpeg_upsampler {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+ JMETHOD(void, upsample, (j_decompress_ptr cinfo,
+ JSAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail,
+ JSAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr,
+ JDIMENSION out_rows_avail));
+
+ boolean need_context_rows; /* TRUE if need rows above & below */
+};
+
+/* Colorspace conversion */
+struct jpeg_color_deconverter {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+ JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
+ JSAMPIMAGE input_buf, JDIMENSION input_row,
+ JSAMPARRAY output_buf, int num_rows));
+};
+
+/* Color quantization or color precision reduction */
+struct jpeg_color_quantizer {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
+ JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
+ JSAMPARRAY input_buf, JSAMPARRAY output_buf,
+ int num_rows));
+ JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
+ JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
+};
+
+
+/* Miscellaneous useful macros */
+
+#undef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#undef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+
+/* We assume that right shift corresponds to signed division by 2 with
+ * rounding towards minus infinity. This is correct for typical "arithmetic
+ * shift" instructions that shift in copies of the sign bit. But some
+ * C compilers implement >> with an unsigned shift. For these machines you
+ * must define RIGHT_SHIFT_IS_UNSIGNED.
+ * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
+ * It is only applied with constant shift counts. SHIFT_TEMPS must be
+ * included in the variables of any routine using RIGHT_SHIFT.
+ */
+
+#ifdef RIGHT_SHIFT_IS_UNSIGNED
+#define SHIFT_TEMPS INT32 shift_temp;
+#define RIGHT_SHIFT(x,shft) \
+ ((shift_temp = (x)) < 0 ? \
+ (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
+ (shift_temp >> (shft)))
+#else
+#define SHIFT_TEMPS
+#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
+#endif
+
+
+/* Short forms of external names for systems with brain-damaged linkers. */
+
+#ifdef NEED_SHORT_EXTERNAL_NAMES
+#define jinit_compress_master jICompress
+#define jinit_c_master_control jICMaster
+#define jinit_c_main_controller jICMainC
+#define jinit_c_prep_controller jICPrepC
+#define jinit_c_coef_controller jICCoefC
+#define jinit_color_converter jICColor
+#define jinit_downsampler jIDownsampler
+#define jinit_forward_dct jIFDCT
+#define jinit_huff_encoder jIHEncoder
+#define jinit_phuff_encoder jIPHEncoder
+#define jinit_marker_writer jIMWriter
+#define jinit_master_decompress jIDMaster
+#define jinit_d_main_controller jIDMainC
+#define jinit_d_coef_controller jIDCoefC
+#define jinit_d_post_controller jIDPostC
+#define jinit_input_controller jIInCtlr
+#define jinit_marker_reader jIMReader
+#define jinit_huff_decoder jIHDecoder
+#define jinit_phuff_decoder jIPHDecoder
+#define jinit_inverse_dct jIIDCT
+#define jinit_upsampler jIUpsampler
+#define jinit_color_deconverter jIDColor
+#define jinit_1pass_quantizer jI1Quant
+#define jinit_2pass_quantizer jI2Quant
+#define jinit_merged_upsampler jIMUpsampler
+#define jinit_memory_mgr jIMemMgr
+#define jdiv_round_up jDivRound
+#define jround_up jRound
+#define jcopy_sample_rows jCopySamples
+#define jcopy_block_row jCopyBlocks
+#define jzero_far jZeroFar
+#define jpeg_zigzag_order jZIGTable
+#define jpeg_natural_order jZAGTable
+#endif /* NEED_SHORT_EXTERNAL_NAMES */
+
+
+/* Compression module initialization routines */
+EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
+EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
+ boolean transcode_only));
+EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo,
+ boolean need_full_buffer));
+EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo,
+ boolean need_full_buffer));
+EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo,
+ boolean need_full_buffer));
+EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
+EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
+EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
+EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
+EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
+EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
+/* Decompression module initialization routines */
+EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo,
+ boolean need_full_buffer));
+EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo,
+ boolean need_full_buffer));
+EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
+ boolean need_full_buffer));
+EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));
+EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo));
+/* Memory manager initialization */
+EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
+
+/* Utility routines in jutils.c */
+EXTERN(long) jdiv_round_up JPP((long a, long b));
+EXTERN(long) jround_up JPP((long a, long b));
+EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
+ JSAMPARRAY output_array, int dest_row,
+ int num_rows, JDIMENSION num_cols));
+EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
+ JDIMENSION num_blocks));
+EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
+/* Constant tables in jutils.c */
+#if 0 /* This table is not actually needed in v6a */
+extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
+#endif
+extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
+
+/* Suppress undefined-structure complaints if necessary. */
+
+#ifdef INCOMPLETE_TYPES_BROKEN
+#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */
+struct jvirt_sarray_control { long dummy; };
+struct jvirt_barray_control { long dummy; };
+#endif
+#endif /* INCOMPLETE_TYPES_BROKEN */
diff --git a/core/include/thirdparties/libjpeg/jpeglib.h b/core/include/thirdparties/libjpeg/jpeglib.h
index ac2aff90fd..7de5ab726e 100644
--- a/core/include/thirdparties/libjpeg/jpeglib.h
+++ b/core/include/thirdparties/libjpeg/jpeglib.h
@@ -1,1165 +1,1165 @@
-/*
- * jpeglib.h
- *
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file defines the application interface for the JPEG library.
- * Most applications using the library need only include this file,
- * and perhaps jerror.h if they want to know the exact error codes.
- */
-
-#ifndef JPEGLIB_H
-#define JPEGLIB_H
-
-#define FOXIT_PREFIX(origName) FPDFAPIJPEG_##origName
-
-#define jcopy_block_row FOXIT_PREFIX(jcopy_block_row)
-#define jcopy_sample_rows FOXIT_PREFIX(jcopy_sample_rows)
-#define jdiv_round_up FOXIT_PREFIX(jdiv_round_up)
-#define jinit_1pass_quantizer FOXIT_PREFIX(jinit_1pass_quantizer)
-#define jinit_2pass_quantizer FOXIT_PREFIX(jinit_2pass_quantizer)
-#define jinit_color_deconverter FOXIT_PREFIX(jinit_color_deconverter)
-#define jinit_d_coef_controller FOXIT_PREFIX(jinit_d_coef_controller)
-#define jinit_d_main_controller FOXIT_PREFIX(jinit_d_main_controller)
-#define jinit_d_post_controller FOXIT_PREFIX(jinit_d_post_controller)
-#define jinit_huff_decoder FOXIT_PREFIX(jinit_huff_decoder)
-#define jinit_input_controller FOXIT_PREFIX(jinit_input_controller)
-#define jinit_inverse_dct FOXIT_PREFIX(jinit_inverse_dct)
-#define jinit_marker_reader FOXIT_PREFIX(jinit_marker_reader)
-#define jinit_master_decompress FOXIT_PREFIX(jinit_master_decompress)
-#define jinit_memory_mgr FOXIT_PREFIX(jinit_memory_mgr)
-#define jinit_merged_upsampler FOXIT_PREFIX(jinit_merged_upsampler)
-#define jinit_phuff_decoder FOXIT_PREFIX(jinit_phuff_decoder)
-#define jinit_upsampler FOXIT_PREFIX(jinit_upsampler)
-#define jpeg_CreateDecompress FOXIT_PREFIX(jpeg_CreateDecompress)
-#define jpeg_abort FOXIT_PREFIX(jpeg_abort)
-#define jpeg_abort_decompress FOXIT_PREFIX(jpeg_abort_decompress)
-#define jpeg_alloc_huff_table FOXIT_PREFIX(jpeg_alloc_huff_table)
-#define jpeg_alloc_quant_table FOXIT_PREFIX(jpeg_alloc_quant_table)
-#define jpeg_calc_output_dimensions FOXIT_PREFIX(jpeg_calc_output_dimensions)
-#define jpeg_consume_input FOXIT_PREFIX(jpeg_consume_input)
-#define jpeg_destroy FOXIT_PREFIX(jpeg_destroy)
-#define jpeg_destroy_decompress FOXIT_PREFIX(jpeg_destroy_decompress)
-#define jpeg_fill_bit_buffer FOXIT_PREFIX(jpeg_fill_bit_buffer)
-#define jpeg_finish_decompress FOXIT_PREFIX(jpeg_finish_decompress)
-#define jpeg_finish_output FOXIT_PREFIX(jpeg_finish_output)
-#define jpeg_free_large FOXIT_PREFIX(jpeg_free_large)
-#define jpeg_free_small FOXIT_PREFIX(jpeg_free_small)
-#define jpeg_get_large FOXIT_PREFIX(jpeg_get_large)
-#define jpeg_get_small FOXIT_PREFIX(jpeg_get_small)
-#define jpeg_has_multiple_scans FOXIT_PREFIX(jpeg_has_multiple_scans)
-#define jpeg_huff_decode FOXIT_PREFIX(jpeg_huff_decode)
-#define jpeg_idct_1x1 FOXIT_PREFIX(jpeg_idct_1x1)
-#define jpeg_idct_2x2 FOXIT_PREFIX(jpeg_idct_2x2)
-#define jpeg_idct_4x4 FOXIT_PREFIX(jpeg_idct_4x4)
-#define jpeg_idct_float FOXIT_PREFIX(jpeg_idct_float)
-#define jpeg_idct_ifast FOXIT_PREFIX(jpeg_idct_ifast)
-#define jpeg_idct_islow FOXIT_PREFIX(jpeg_idct_islow)
-#define jpeg_input_complete FOXIT_PREFIX(jpeg_input_complete)
-#define jpeg_make_d_derived_tbl FOXIT_PREFIX(jpeg_make_d_derived_tbl)
-#define jpeg_mem_available FOXIT_PREFIX(jpeg_mem_available)
-#define jpeg_mem_init FOXIT_PREFIX(jpeg_mem_init)
-#define jpeg_mem_term FOXIT_PREFIX(jpeg_mem_term)
-#define jpeg_natural_order FOXIT_PREFIX(jpeg_natural_order)
-#define jpeg_new_colormap FOXIT_PREFIX(jpeg_new_colormap)
-#define jpeg_open_backing_store FOXIT_PREFIX(jpeg_open_backing_store)
-#define jpeg_read_coefficients FOXIT_PREFIX(jpeg_read_coefficients)
-#define jpeg_read_header FOXIT_PREFIX(jpeg_read_header)
-#define jpeg_read_raw_data FOXIT_PREFIX(jpeg_read_raw_data)
-#define jpeg_read_scanlines FOXIT_PREFIX(jpeg_read_scanlines)
-#define jpeg_resync_to_restart FOXIT_PREFIX(jpeg_resync_to_restart)
-#define jpeg_save_markers FOXIT_PREFIX(jpeg_save_markers)
-#define jpeg_set_marker_processor FOXIT_PREFIX(jpeg_set_marker_processor)
-#define jpeg_start_decompress FOXIT_PREFIX(jpeg_start_decompress)
-#define jpeg_start_output FOXIT_PREFIX(jpeg_start_output)
-#define jpeg_std_error FOXIT_PREFIX(jpeg_std_error)
-#define jpeg_std_message_table FOXIT_PREFIX(jpeg_std_message_table)
-#define jpeg_stdio_src FOXIT_PREFIX(jpeg_stdio_src)
-#define jround_up FOXIT_PREFIX(jround_up)
-#define jzero_far FOXIT_PREFIX(jzero_far)
-
- /*
- * First we include the configuration files that record how this
- * installation of the JPEG library is set up. jconfig.h can be
- * generated automatically for many systems. jmorecfg.h contains
- * manual configuration options that most people need not worry about.
- */
-
-#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
-#include "jconfig.h" /* widely used configuration options */
-#endif
-#include "jmorecfg.h" /* seldom changed options */
-
-
-/* Version ID for the JPEG library.
- * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
- */
-
-#define JPEG_LIB_VERSION 62 /* Version 6b */
-
-
-/* Various constants determining the sizes of things.
- * All of these are specified by the JPEG standard, so don't change them
- * if you want to be compatible.
- */
-
-#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
-#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
-#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
-#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
-#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
-#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
-#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
-/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
- * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
- * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
- * to handle it. We even let you do this from the jconfig.h file. However,
- * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
- * sometimes emits noncompliant files doesn't mean you should too.
- */
-#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */
-#ifndef D_MAX_BLOCKS_IN_MCU
-#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */
-#endif
-
-
-/* Data structures for images (arrays of samples and of DCT coefficients).
- * On 80x86 machines, the image arrays are too big for near pointers,
- * but the pointer arrays can fit in near memory.
- */
-
-typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
-typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
-typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
-
-typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
-typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
-typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
-typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
-
-typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
-
-
-/* Types for JPEG compression parameters and working tables. */
-
-
-/* DCT coefficient quantization tables. */
-
-typedef struct {
- /* This array gives the coefficient quantizers in natural array order
- * (not the zigzag order in which they are stored in a JPEG DQT marker).
- * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
- */
- UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
- /* This field is used only during compression. It's initialized FALSE when
- * the table is created, and set TRUE when it's been output to the file.
- * You could suppress output of a table by setting this to TRUE.
- * (See jpeg_suppress_tables for an example.)
- */
- boolean sent_table; /* TRUE when table has been output */
-} JQUANT_TBL;
-
-
-/* Huffman coding tables. */
-
-typedef struct {
- /* These two fields directly represent the contents of a JPEG DHT marker */
- UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
- /* length k bits; bits[0] is unused */
- UINT8 huffval[256]; /* The symbols, in order of incr code length */
- /* This field is used only during compression. It's initialized FALSE when
- * the table is created, and set TRUE when it's been output to the file.
- * You could suppress output of a table by setting this to TRUE.
- * (See jpeg_suppress_tables for an example.)
- */
- boolean sent_table; /* TRUE when table has been output */
-} JHUFF_TBL;
-
-
-/* Basic info about one component (color channel). */
-
-typedef struct {
- /* These values are fixed over the whole image. */
- /* For compression, they must be supplied by parameter setup; */
- /* for decompression, they are read from the SOF marker. */
- int component_id; /* identifier for this component (0..255) */
- int component_index; /* its index in SOF or cinfo->comp_info[] */
- int h_samp_factor; /* horizontal sampling factor (1..4) */
- int v_samp_factor; /* vertical sampling factor (1..4) */
- int quant_tbl_no; /* quantization table selector (0..3) */
- /* These values may vary between scans. */
- /* For compression, they must be supplied by parameter setup; */
- /* for decompression, they are read from the SOS marker. */
- /* The decompressor output side may not use these variables. */
- int dc_tbl_no; /* DC entropy table selector (0..3) */
- int ac_tbl_no; /* AC entropy table selector (0..3) */
-
- /* Remaining fields should be treated as private by applications. */
-
- /* These values are computed during compression or decompression startup: */
- /* Component's size in DCT blocks.
- * Any dummy blocks added to complete an MCU are not counted; therefore
- * these values do not depend on whether a scan is interleaved or not.
- */
- JDIMENSION width_in_blocks;
- JDIMENSION height_in_blocks;
- /* Size of a DCT block in samples. Always DCTSIZE for compression.
- * For decompression this is the size of the output from one DCT block,
- * reflecting any scaling we choose to apply during the IDCT step.
- * Values of 1,2,4,8 are likely to be supported. Note that different
- * components may receive different IDCT scalings.
- */
- int DCT_scaled_size;
- /* The downsampled dimensions are the component's actual, unpadded number
- * of samples at the main buffer (preprocessing/compression interface), thus
- * downsampled_width = ceil(image_width * Hi/Hmax)
- * and similarly for height. For decompression, IDCT scaling is included, so
- * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)
- */
- JDIMENSION downsampled_width; /* actual width in samples */
- JDIMENSION downsampled_height; /* actual height in samples */
- /* This flag is used only for decompression. In cases where some of the
- * components will be ignored (eg grayscale output from YCbCr image),
- * we can skip most computations for the unused components.
- */
- boolean component_needed; /* do we need the value of this component? */
-
- /* These values are computed before starting a scan of the component. */
- /* The decompressor output side may not use these variables. */
- int MCU_width; /* number of blocks per MCU, horizontally */
- int MCU_height; /* number of blocks per MCU, vertically */
- int MCU_blocks; /* MCU_width * MCU_height */
- int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */
- int last_col_width; /* # of non-dummy blocks across in last MCU */
- int last_row_height; /* # of non-dummy blocks down in last MCU */
-
- /* Saved quantization table for component; NULL if none yet saved.
- * See jdinput.c comments about the need for this information.
- * This field is currently used only for decompression.
- */
- JQUANT_TBL * quant_table;
-
- /* Private per-component storage for DCT or IDCT subsystem. */
- void * dct_table;
-} jpeg_component_info;
-
-
-/* The script for encoding a multiple-scan file is an array of these: */
-
-typedef struct {
- int comps_in_scan; /* number of components encoded in this scan */
- int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
- int Ss, Se; /* progressive JPEG spectral selection parms */
- int Ah, Al; /* progressive JPEG successive approx. parms */
-} jpeg_scan_info;
-
-/* The decompressor can save APPn and COM markers in a list of these: */
-
-typedef struct jpeg_marker_struct * jpeg_saved_marker_ptr;
-
-struct jpeg_marker_struct {
- jpeg_saved_marker_ptr next; /* next in list, or NULL */
- UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
- unsigned int original_length; /* # bytes of data in the file */
- unsigned int data_length; /* # bytes of data saved at data[] */
- JOCTET * data; /* the data contained in the marker */
- /* the marker length word is not counted in data_length or original_length */
-};
-
-/* Known color spaces. */
-
-typedef enum {
- JCS_UNKNOWN, /* error/unspecified */
- JCS_GRAYSCALE, /* monochrome */
- JCS_RGB, /* red/green/blue */
- JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
- JCS_CMYK, /* C/M/Y/K */
- JCS_YCCK /* Y/Cb/Cr/K */
-} J_COLOR_SPACE;
-
-/* DCT/IDCT algorithm options. */
-
-typedef enum {
- JDCT_ISLOW, /* slow but accurate integer algorithm */
- JDCT_IFAST, /* faster, less accurate integer method */
- JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
-} J_DCT_METHOD;
-
-#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
-#define JDCT_DEFAULT JDCT_ISLOW
-#endif
-#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
-#define JDCT_FASTEST JDCT_IFAST
-#endif
-
-/* Dithering options for decompression. */
-
-typedef enum {
- JDITHER_NONE, /* no dithering */
- JDITHER_ORDERED, /* simple ordered dither */
- JDITHER_FS /* Floyd-Steinberg error diffusion dither */
-} J_DITHER_MODE;
-
-
-/* Common fields between JPEG compression and decompression master structs. */
-
-#define jpeg_common_fields \
- struct jpeg_error_mgr * err; /* Error handler module */\
- struct jpeg_memory_mgr * mem; /* Memory manager module */\
- struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\
- void * client_data; /* Available for use by application */\
- boolean is_decompressor; /* So common code can tell which is which */\
- int global_state /* For checking call sequence validity */
-
-/* Routines that are to be used by both halves of the library are declared
- * to receive a pointer to this structure. There are no actual instances of
- * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
- */
-struct jpeg_common_struct {
- jpeg_common_fields; /* Fields common to both master struct types */
- /* Additional fields follow in an actual jpeg_compress_struct or
- * jpeg_decompress_struct. All three structs must agree on these
- * initial fields! (This would be a lot cleaner in C++.)
- */
-};
-
-typedef struct jpeg_common_struct * j_common_ptr;
-typedef struct jpeg_compress_struct * j_compress_ptr;
-typedef struct jpeg_decompress_struct * j_decompress_ptr;
-
-
-/* Master record for a compression instance */
-
-struct jpeg_compress_struct {
- jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
-
- /* Destination for compressed data */
- struct jpeg_destination_mgr * dest;
-
- /* Description of source image --- these fields must be filled in by
- * outer application before starting compression. in_color_space must
- * be correct before you can even call jpeg_set_defaults().
- */
-
- JDIMENSION image_width; /* input image width */
- JDIMENSION image_height; /* input image height */
- int input_components; /* # of color components in input image */
- J_COLOR_SPACE in_color_space; /* colorspace of input image */
-
- double input_gamma; /* image gamma of input image */
-
- /* Compression parameters --- these fields must be set before calling
- * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
- * initialize everything to reasonable defaults, then changing anything
- * the application specifically wants to change. That way you won't get
- * burnt when new parameters are added. Also note that there are several
- * helper routines to simplify changing parameters.
- */
-
- int data_precision; /* bits of precision in image data */
-
- int num_components; /* # of color components in JPEG image */
- J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
-
- jpeg_component_info * comp_info;
- /* comp_info[i] describes component that appears i'th in SOF */
-
- JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
- /* ptrs to coefficient quantization tables, or NULL if not defined */
-
- JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
- JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
- /* ptrs to Huffman coding tables, or NULL if not defined */
-
- UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
- UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
- UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
-
- int num_scans; /* # of entries in scan_info array */
- const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */
- /* The default value of scan_info is NULL, which causes a single-scan
- * sequential JPEG file to be emitted. To create a multi-scan file,
- * set num_scans and scan_info to point to an array of scan definitions.
- */
-
- boolean raw_data_in; /* TRUE=caller supplies downsampled data */
- boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
- boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
- boolean CCIR601_sampling; /* TRUE=first samples are cosited */
- int smoothing_factor; /* 1..100, or 0 for no input smoothing */
- J_DCT_METHOD dct_method; /* DCT algorithm selector */
-
- /* The restart interval can be specified in absolute MCUs by setting
- * restart_interval, or in MCU rows by setting restart_in_rows
- * (in which case the correct restart_interval will be figured
- * for each scan).
- */
- unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
- int restart_in_rows; /* if > 0, MCU rows per restart interval */
-
- /* Parameters controlling emission of special markers. */
-
- boolean write_JFIF_header; /* should a JFIF marker be written? */
- UINT8 JFIF_major_version; /* What to write for the JFIF version number */
- UINT8 JFIF_minor_version;
- /* These three values are not used by the JPEG code, merely copied */
- /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
- /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */
- /* ratio is defined by X_density/Y_density even when density_unit=0. */
- UINT8 density_unit; /* JFIF code for pixel size units */
- UINT16 X_density; /* Horizontal pixel density */
- UINT16 Y_density; /* Vertical pixel density */
- boolean write_Adobe_marker; /* should an Adobe marker be written? */
-
- /* State variable: index of next scanline to be written to
- * jpeg_write_scanlines(). Application may use this to control its
- * processing loop, e.g., "while (next_scanline < image_height)".
- */
-
- JDIMENSION next_scanline; /* 0 .. image_height-1 */
-
- /* Remaining fields are known throughout compressor, but generally
- * should not be touched by a surrounding application.
- */
-
- /*
- * These fields are computed during compression startup
- */
- boolean progressive_mode; /* TRUE if scan script uses progressive mode */
- int max_h_samp_factor; /* largest h_samp_factor */
- int max_v_samp_factor; /* largest v_samp_factor */
-
- JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
- /* The coefficient controller receives data in units of MCU rows as defined
- * for fully interleaved scans (whether the JPEG file is interleaved or not).
- * There are v_samp_factor * DCTSIZE sample rows of each component in an
- * "iMCU" (interleaved MCU) row.
- */
-
- /*
- * These fields are valid during any one scan.
- * They describe the components and MCUs actually appearing in the scan.
- */
- int comps_in_scan; /* # of JPEG components in this scan */
- jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
- /* *cur_comp_info[i] describes component that appears i'th in SOS */
-
- JDIMENSION MCUs_per_row; /* # of MCUs across the image */
- JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
-
- int blocks_in_MCU; /* # of DCT blocks per MCU */
- int MCU_membership[C_MAX_BLOCKS_IN_MCU];
- /* MCU_membership[i] is index in cur_comp_info of component owning */
- /* i'th block in an MCU */
-
- int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
-
- /*
- * Links to compression subobjects (methods and private variables of modules)
- */
- struct jpeg_comp_master * master;
- struct jpeg_c_main_controller * main;
- struct jpeg_c_prep_controller * prep;
- struct jpeg_c_coef_controller * coef;
- struct jpeg_marker_writer * marker;
- struct jpeg_color_converter * cconvert;
- struct jpeg_downsampler * downsample;
- struct jpeg_forward_dct * fdct;
- struct jpeg_entropy_encoder * entropy;
- jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */
- int script_space_size;
-};
-
-
-/* Master record for a decompression instance */
-
-struct jpeg_decompress_struct {
- jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
-
- /* Source of compressed data */
- struct jpeg_source_mgr * src;
-
- /* Basic description of image --- filled in by jpeg_read_header(). */
- /* Application may inspect these values to decide how to process image. */
-
- JDIMENSION image_width; /* nominal image width (from SOF marker) */
- JDIMENSION image_height; /* nominal image height */
- int num_components; /* # of color components in JPEG image */
- J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
-
- /* Decompression processing parameters --- these fields must be set before
- * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes
- * them to default values.
- */
-
- J_COLOR_SPACE out_color_space; /* colorspace for output */
-
- unsigned int scale_num, scale_denom; /* fraction by which to scale image */
-
- double output_gamma; /* image gamma wanted in output */
-
- boolean buffered_image; /* TRUE=multiple output passes */
- boolean raw_data_out; /* TRUE=downsampled data wanted */
-
- J_DCT_METHOD dct_method; /* IDCT algorithm selector */
- boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
- boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
-
- boolean quantize_colors; /* TRUE=colormapped output wanted */
- /* the following are ignored if not quantize_colors: */
- J_DITHER_MODE dither_mode; /* type of color dithering to use */
- boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
- int desired_number_of_colors; /* max # colors to use in created colormap */
- /* these are significant only in buffered-image mode: */
- boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
- boolean enable_external_quant;/* enable future use of external colormap */
- boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
-
- /* Description of actual output image that will be returned to application.
- * These fields are computed by jpeg_start_decompress().
- * You can also use jpeg_calc_output_dimensions() to determine these values
- * in advance of calling jpeg_start_decompress().
- */
-
- JDIMENSION output_width; /* scaled image width */
- JDIMENSION output_height; /* scaled image height */
- int out_color_components; /* # of color components in out_color_space */
- int output_components; /* # of color components returned */
- /* output_components is 1 (a colormap index) when quantizing colors;
- * otherwise it equals out_color_components.
- */
- int rec_outbuf_height; /* min recommended height of scanline buffer */
- /* If the buffer passed to jpeg_read_scanlines() is less than this many rows
- * high, space and time will be wasted due to unnecessary data copying.
- * Usually rec_outbuf_height will be 1 or 2, at most 4.
- */
-
- /* When quantizing colors, the output colormap is described by these fields.
- * The application can supply a colormap by setting colormap non-NULL before
- * calling jpeg_start_decompress; otherwise a colormap is created during
- * jpeg_start_decompress or jpeg_start_output.
- * The map has out_color_components rows and actual_number_of_colors columns.
- */
- int actual_number_of_colors; /* number of entries in use */
- JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
-
- /* State variables: these variables indicate the progress of decompression.
- * The application may examine these but must not modify them.
- */
-
- /* Row index of next scanline to be read from jpeg_read_scanlines().
- * Application may use this to control its processing loop, e.g.,
- * "while (output_scanline < output_height)".
- */
- JDIMENSION output_scanline; /* 0 .. output_height-1 */
-
- /* Current input scan number and number of iMCU rows completed in scan.
- * These indicate the progress of the decompressor input side.
- */
- int input_scan_number; /* Number of SOS markers seen so far */
- JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
-
- /* The "output scan number" is the notional scan being displayed by the
- * output side. The decompressor will not allow output scan/row number
- * to get ahead of input scan/row, but it can fall arbitrarily far behind.
- */
- int output_scan_number; /* Nominal scan number being displayed */
- JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
-
- /* Current progression status. coef_bits[c][i] indicates the precision
- * with which component c's DCT coefficient i (in zigzag order) is known.
- * It is -1 when no data has yet been received, otherwise it is the point
- * transform (shift) value for the most recent scan of the coefficient
- * (thus, 0 at completion of the progression).
- * This pointer is NULL when reading a non-progressive file.
- */
- int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
-
- /* Internal JPEG parameters --- the application usually need not look at
- * these fields. Note that the decompressor output side may not use
- * any parameters that can change between scans.
- */
-
- /* Quantization and Huffman tables are carried forward across input
- * datastreams when processing abbreviated JPEG datastreams.
- */
-
- JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
- /* ptrs to coefficient quantization tables, or NULL if not defined */
-
- JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
- JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
- /* ptrs to Huffman coding tables, or NULL if not defined */
-
- /* These parameters are never carried across datastreams, since they
- * are given in SOF/SOS markers or defined to be reset by SOI.
- */
-
- int data_precision; /* bits of precision in image data */
-
- jpeg_component_info * comp_info;
- /* comp_info[i] describes component that appears i'th in SOF */
-
- boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
- boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
-
- UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
- UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
- UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
-
- unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
-
- /* These fields record data obtained from optional markers recognized by
- * the JPEG library.
- */
- boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
- /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
- UINT8 JFIF_major_version; /* JFIF version number */
- UINT8 JFIF_minor_version;
- UINT8 density_unit; /* JFIF code for pixel size units */
- UINT16 X_density; /* Horizontal pixel density */
- UINT16 Y_density; /* Vertical pixel density */
- boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
- UINT8 Adobe_transform; /* Color transform code from Adobe marker */
-
- boolean CCIR601_sampling; /* TRUE=first samples are cosited */
-
- /* Aside from the specific data retained from APPn markers known to the
- * library, the uninterpreted contents of any or all APPn and COM markers
- * can be saved in a list for examination by the application.
- */
- jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
-
- /* Remaining fields are known throughout decompressor, but generally
- * should not be touched by a surrounding application.
- */
-
- /*
- * These fields are computed during decompression startup
- */
- int max_h_samp_factor; /* largest h_samp_factor */
- int max_v_samp_factor; /* largest v_samp_factor */
-
- int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
-
- JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
- /* The coefficient controller's input and output progress is measured in
- * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
- * in fully interleaved JPEG scans, but are used whether the scan is
- * interleaved or not. We define an iMCU row as v_samp_factor DCT block
- * rows of each component. Therefore, the IDCT output contains
- * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.
- */
-
- JSAMPLE * sample_range_limit; /* table for fast range-limiting */
-
- /*
- * These fields are valid during any one scan.
- * They describe the components and MCUs actually appearing in the scan.
- * Note that the decompressor output side must not use these fields.
- */
- int comps_in_scan; /* # of JPEG components in this scan */
- jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
- /* *cur_comp_info[i] describes component that appears i'th in SOS */
-
- JDIMENSION MCUs_per_row; /* # of MCUs across the image */
- JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
-
- int blocks_in_MCU; /* # of DCT blocks per MCU */
- int MCU_membership[D_MAX_BLOCKS_IN_MCU];
- /* MCU_membership[i] is index in cur_comp_info of component owning */
- /* i'th block in an MCU */
-
- int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
-
- /* This field is shared between entropy decoder and marker parser.
- * It is either zero or the code of a JPEG marker that has been
- * read from the data source, but has not yet been processed.
- */
- int unread_marker;
-
- /*
- * Links to decompression subobjects (methods, private variables of modules)
- */
- struct jpeg_decomp_master * master;
- struct jpeg_d_main_controller * main;
- struct jpeg_d_coef_controller * coef;
- struct jpeg_d_post_controller * post;
- struct jpeg_input_controller * inputctl;
- struct jpeg_marker_reader * marker;
- struct jpeg_entropy_decoder * entropy;
- struct jpeg_inverse_dct * idct;
- struct jpeg_upsampler * upsample;
- struct jpeg_color_deconverter * cconvert;
- struct jpeg_color_quantizer * cquantize;
-};
-
-
-/* "Object" declarations for JPEG modules that may be supplied or called
- * directly by the surrounding application.
- * As with all objects in the JPEG library, these structs only define the
- * publicly visible methods and state variables of a module. Additional
- * private fields may exist after the public ones.
- */
-
-
-/* Error handler object */
-
-struct jpeg_error_mgr {
- /* Error exit handler: does not return to caller */
- JMETHOD(void, error_exit, (j_common_ptr cinfo));
- /* Conditionally emit a trace or warning message */
- JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
- /* Routine that actually outputs a trace or error message */
- JMETHOD(void, output_message, (j_common_ptr cinfo));
- /* Format a message string for the most recent JPEG error or message */
- JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));
-#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
- /* Reset error state variables at start of a new image */
- JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));
-
- /* The message ID code and any parameters are saved here.
- * A message can have one string parameter or up to 8 int parameters.
- */
- int msg_code;
-#define JMSG_STR_PARM_MAX 80
- union {
- int i[8];
- char s[JMSG_STR_PARM_MAX];
- } msg_parm;
-
- /* Standard state variables for error facility */
-
- int trace_level; /* max msg_level that will be displayed */
-
- /* For recoverable corrupt-data errors, we emit a warning message,
- * but keep going unless emit_message chooses to abort. emit_message
- * should count warnings in num_warnings. The surrounding application
- * can check for bad data by seeing if num_warnings is nonzero at the
- * end of processing.
- */
- long num_warnings; /* number of corrupt-data warnings */
-
- /* These fields point to the table(s) of error message strings.
- * An application can change the table pointer to switch to a different
- * message list (typically, to change the language in which errors are
- * reported). Some applications may wish to add additional error codes
- * that will be handled by the JPEG library error mechanism; the second
- * table pointer is used for this purpose.
- *
- * First table includes all errors generated by JPEG library itself.
- * Error code 0 is reserved for a "no such error string" message.
- */
- const char * const * jpeg_message_table; /* Library errors */
- int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
- /* Second table can be added by application (see cjpeg/djpeg for example).
- * It contains strings numbered first_addon_message..last_addon_message.
- */
- const char * const * addon_message_table; /* Non-library errors */
- int first_addon_message; /* code for first string in addon table */
- int last_addon_message; /* code for last string in addon table */
-};
-
-
-/* Progress monitor object */
-
-struct jpeg_progress_mgr {
- JMETHOD(void, progress_monitor, (j_common_ptr cinfo));
-
- long pass_counter; /* work units completed in this pass */
- long pass_limit; /* total number of work units in this pass */
- int completed_passes; /* passes completed so far */
- int total_passes; /* total number of passes expected */
-};
-
-
-/* Data destination object for compression */
-
-struct jpeg_destination_mgr {
- JOCTET * next_output_byte; /* => next byte to write in buffer */
- size_t free_in_buffer; /* # of byte spaces remaining in buffer */
-
- JMETHOD(void, init_destination, (j_compress_ptr cinfo));
- JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo));
- JMETHOD(void, term_destination, (j_compress_ptr cinfo));
-};
-
-
-/* Data source object for decompression */
-
-struct jpeg_source_mgr {
- const JOCTET * next_input_byte; /* => next byte to read from buffer */
- size_t bytes_in_buffer; /* # of bytes remaining in buffer */
-
- JMETHOD(void, init_source, (j_decompress_ptr cinfo));
- JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo));
- JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes));
- JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired));
- JMETHOD(void, term_source, (j_decompress_ptr cinfo));
-};
-
-
-/* Memory manager object.
- * Allocates "small" objects (a few K total), "large" objects (tens of K),
- * and "really big" objects (virtual arrays with backing store if needed).
- * The memory manager does not allow individual objects to be freed; rather,
- * each created object is assigned to a pool, and whole pools can be freed
- * at once. This is faster and more convenient than remembering exactly what
- * to free, especially where malloc()/free() are not too speedy.
- * NB: alloc routines never return NULL. They exit to error_exit if not
- * successful.
- */
-
-#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
-#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
-#define JPOOL_NUMPOOLS 2
-
-typedef struct jvirt_sarray_control * jvirt_sarray_ptr;
-typedef struct jvirt_barray_control * jvirt_barray_ptr;
-
-
-struct jpeg_memory_mgr {
- /* Method pointers */
- JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id,
- size_t sizeofobject));
- JMETHOD(void *, alloc_large, (j_common_ptr cinfo, int pool_id,
- size_t sizeofobject));
- JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id,
- JDIMENSION samplesperrow,
- JDIMENSION numrows));
- JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id,
- JDIMENSION blocksperrow,
- JDIMENSION numrows));
- JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo,
- int pool_id,
- boolean pre_zero,
- JDIMENSION samplesperrow,
- JDIMENSION numrows,
- JDIMENSION maxaccess));
- JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo,
- int pool_id,
- boolean pre_zero,
- JDIMENSION blocksperrow,
- JDIMENSION numrows,
- JDIMENSION maxaccess));
- JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo));
- JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo,
- jvirt_sarray_ptr ptr,
- JDIMENSION start_row,
- JDIMENSION num_rows,
- boolean writable));
- JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo,
- jvirt_barray_ptr ptr,
- JDIMENSION start_row,
- JDIMENSION num_rows,
- boolean writable));
- JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id));
- JMETHOD(void, self_destruct, (j_common_ptr cinfo));
-
- /* Limit on memory allocation for this JPEG object. (Note that this is
- * merely advisory, not a guaranteed maximum; it only affects the space
- * used for virtual-array buffers.) May be changed by outer application
- * after creating the JPEG object.
- */
- long max_memory_to_use;
-
- /* Maximum allocation request accepted by alloc_large. */
- long max_alloc_chunk;
-};
-
-
-/* Routine signature for application-supplied marker processing methods.
- * Need not pass marker code since it is stored in cinfo->unread_marker.
- */
-typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
-
-
-/* Declarations for routines called by application.
- * The JPP macro hides prototype parameters from compilers that can't cope.
- * Note JPP requires double parentheses.
- */
-
-#ifdef HAVE_PROTOTYPES
-#define JPP(arglist) arglist
-#else
-#define JPP(arglist) ()
-#endif
-
-
-/* Short forms of external names for systems with brain-damaged linkers.
- * We shorten external names to be unique in the first six letters, which
- * is good enough for all known systems.
- * (If your compiler itself needs names to be unique in less than 15
- * characters, you are out of luck. Get a better compiler.)
- */
-
-#ifdef NEED_SHORT_EXTERNAL_NAMES
-#define jpeg_std_error jStdError
-#define jpeg_CreateCompress jCreaCompress
-#define jpeg_CreateDecompress jCreaDecompress
-#define jpeg_destroy_compress jDestCompress
-#define jpeg_destroy_decompress jDestDecompress
-#define jpeg_stdio_dest jStdDest
-#define jpeg_stdio_src jStdSrc
-#define jpeg_set_defaults jSetDefaults
-#define jpeg_set_colorspace jSetColorspace
-#define jpeg_default_colorspace jDefColorspace
-#define jpeg_set_quality jSetQuality
-#define jpeg_set_linear_quality jSetLQuality
-#define jpeg_add_quant_table jAddQuantTable
-#define jpeg_quality_scaling jQualityScaling
-#define jpeg_simple_progression jSimProgress
-#define jpeg_suppress_tables jSuppressTables
-#define jpeg_alloc_quant_table jAlcQTable
-#define jpeg_alloc_huff_table jAlcHTable
-#define jpeg_start_compress jStrtCompress
-#define jpeg_write_scanlines jWrtScanlines
-#define jpeg_finish_compress jFinCompress
-#define jpeg_write_raw_data jWrtRawData
-#define jpeg_write_marker jWrtMarker
-#define jpeg_write_m_header jWrtMHeader
-#define jpeg_write_m_byte jWrtMByte
-#define jpeg_write_tables jWrtTables
-#define jpeg_read_header jReadHeader
-#define jpeg_start_decompress jStrtDecompress
-#define jpeg_read_scanlines jReadScanlines
-#define jpeg_finish_decompress jFinDecompress
-#define jpeg_read_raw_data jReadRawData
-#define jpeg_has_multiple_scans jHasMultScn
-#define jpeg_start_output jStrtOutput
-#define jpeg_finish_output jFinOutput
-#define jpeg_input_complete jInComplete
-#define jpeg_new_colormap jNewCMap
-#define jpeg_consume_input jConsumeInput
-#define jpeg_calc_output_dimensions jCalcDimensions
-#define jpeg_save_markers jSaveMarkers
-#define jpeg_set_marker_processor jSetMarker
-#define jpeg_read_coefficients jReadCoefs
-#define jpeg_write_coefficients jWrtCoefs
-#define jpeg_copy_critical_parameters jCopyCrit
-#define jpeg_abort_compress jAbrtCompress
-#define jpeg_abort_decompress jAbrtDecompress
-#define jpeg_abort jAbort
-#define jpeg_destroy jDestroy
-#define jpeg_resync_to_restart jResyncRestart
-#endif /* NEED_SHORT_EXTERNAL_NAMES */
-
-
-/* Default error-management setup */
-EXTERN(struct jpeg_error_mgr *) jpeg_std_error
- JPP((struct jpeg_error_mgr * err));
-
-/* Initialization of JPEG compression objects.
- * jpeg_create_compress() and jpeg_create_decompress() are the exported
- * names that applications should call. These expand to calls on
- * jpeg_CreateCompress and jpeg_CreateDecompress with additional information
- * passed for version mismatch checking.
- * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
- */
-#define jpeg_create_compress(cinfo) \
- jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
- (size_t) sizeof(struct jpeg_compress_struct))
-#define jpeg_create_decompress(cinfo) \
- jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
- (size_t) sizeof(struct jpeg_decompress_struct))
-EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo,
- int version, size_t structsize));
-EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo,
- int version, size_t structsize));
-/* Destruction of JPEG compression objects */
-EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo));
-EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
-
-#if 0
-/* Standard data source and destination managers: stdio streams. */
-/* Caller is responsible for opening the file before and closing after. */
-EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FXSYS_FILE * outfile));
-EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FXSYS_FILE * infile));
-#endif
-
-/* Default parameter setup for compression */
-EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
-/* Compression parameter setup aids */
-EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo,
- J_COLOR_SPACE colorspace));
-EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo));
-EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
- boolean force_baseline));
-EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
- int scale_factor,
- boolean force_baseline));
-EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
- const unsigned int *basic_table,
- int scale_factor,
- boolean force_baseline));
-EXTERN(int) jpeg_quality_scaling JPP((int quality));
-EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo));
-EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
- boolean suppress));
-EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
-EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
-
-/* Main entry points for compression */
-EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
- boolean write_all_tables));
-EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo,
- JSAMPARRAY scanlines,
- JDIMENSION num_lines));
-EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo));
-
-/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
-EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo,
- JSAMPIMAGE data,
- JDIMENSION num_lines));
-
-/* Write a special marker. See libjpeg.doc concerning safe usage. */
-EXTERN(void) jpeg_write_marker
- JPP((j_compress_ptr cinfo, int marker,
- const JOCTET * dataptr, unsigned int datalen));
-/* Same, but piecemeal. */
-EXTERN(void) jpeg_write_m_header
- JPP((j_compress_ptr cinfo, int marker, unsigned int datalen));
-EXTERN(void) jpeg_write_m_byte
- JPP((j_compress_ptr cinfo, int val));
-
-/* Alternate compression function: just write an abbreviated table file */
-EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo));
-
-/* Decompression startup: read start of JPEG datastream to see what's there */
-EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo,
- boolean require_image));
-/* Return value is one of: */
-#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
-#define JPEG_HEADER_OK 1 /* Found valid image datastream */
-#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
-/* If you pass require_image = TRUE (normal case), you need not check for
- * a TABLES_ONLY return code; an abbreviated file will cause an error exit.
- * JPEG_SUSPENDED is only possible if you use a data source module that can
- * give a suspension return (the stdio source module doesn't).
- */
-
-/* Main entry points for decompression */
-EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo));
-EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo,
- JSAMPARRAY scanlines,
- JDIMENSION max_lines));
-EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo));
-
-/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
-EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo,
- JSAMPIMAGE data,
- JDIMENSION max_lines));
-
-/* Additional entry points for buffered-image mode. */
-EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));
-EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo,
- int scan_number));
-EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo));
-EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo));
-EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo));
-EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
-/* Return value is one of: */
-/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
-#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
-#define JPEG_REACHED_EOI 2 /* Reached end of image */
-#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
-#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
-
-/* Precalculate output dimensions for current decompression parameters. */
-EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
-
-/* Control saving of COM and APPn markers into marker_list. */
-EXTERN(void) jpeg_save_markers
- JPP((j_decompress_ptr cinfo, int marker_code,
- unsigned int length_limit));
-
-/* Install a special processing method for COM or APPn markers. */
-EXTERN(void) jpeg_set_marker_processor
- JPP((j_decompress_ptr cinfo, int marker_code,
- jpeg_marker_parser_method routine));
-
-/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
-EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo));
-EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo,
- jvirt_barray_ptr * coef_arrays));
-EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,
- j_compress_ptr dstinfo));
-
-/* If you choose to abort compression or decompression before completing
- * jpeg_finish_(de)compress, then you need to clean up to release memory,
- * temporary files, etc. You can just call jpeg_destroy_(de)compress
- * if you're done with the JPEG object, but if you want to clean it up and
- * reuse it, call this:
- */
-EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo));
-EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo));
-
-/* Generic versions of jpeg_abort and jpeg_destroy that work on either
- * flavor of JPEG object. These may be more convenient in some places.
- */
-EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo));
-EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo));
-
-/* Default restart-marker-resync procedure for use by data source modules */
-EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo,
- int desired));
-
-
-/* These marker codes are exported since applications and data source modules
- * are likely to want to use them.
- */
-
-#define JPEG_RST0 0xD0 /* RST0 marker code */
-#define JPEG_EOI 0xD9 /* EOI marker code */
-#define JPEG_APP0 0xE0 /* APP0 marker code */
-#define JPEG_COM 0xFE /* COM marker code */
-
-
-/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
- * for structure definitions that are never filled in, keep it quiet by
- * supplying dummy definitions for the various substructures.
- */
-
-#ifdef INCOMPLETE_TYPES_BROKEN
-#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
-struct jvirt_sarray_control { long dummy; };
-struct jvirt_barray_control { long dummy; };
-struct jpeg_comp_master { long dummy; };
-struct jpeg_c_main_controller { long dummy; };
-struct jpeg_c_prep_controller { long dummy; };
-struct jpeg_c_coef_controller { long dummy; };
-struct jpeg_marker_writer { long dummy; };
-struct jpeg_color_converter { long dummy; };
-struct jpeg_downsampler { long dummy; };
-struct jpeg_forward_dct { long dummy; };
-struct jpeg_entropy_encoder { long dummy; };
-struct jpeg_decomp_master { long dummy; };
-struct jpeg_d_main_controller { long dummy; };
-struct jpeg_d_coef_controller { long dummy; };
-struct jpeg_d_post_controller { long dummy; };
-struct jpeg_input_controller { long dummy; };
-struct jpeg_marker_reader { long dummy; };
-struct jpeg_entropy_decoder { long dummy; };
-struct jpeg_inverse_dct { long dummy; };
-struct jpeg_upsampler { long dummy; };
-struct jpeg_color_deconverter { long dummy; };
-struct jpeg_color_quantizer { long dummy; };
-#endif /* JPEG_INTERNALS */
-#endif /* INCOMPLETE_TYPES_BROKEN */
-
-
-/*
- * The JPEG library modules define JPEG_INTERNALS before including this file.
- * The internal structure declarations are read only when that is true.
- * Applications using the library should not include jpegint.h, but may wish
- * to include jerror.h.
- */
-
-#ifdef JPEG_INTERNALS
-#include "jpegint.h" /* fetch private declarations */
-#include "jerror.h" /* fetch error codes too */
-#endif
-
-#endif /* JPEGLIB_H */
+/*
+ * jpeglib.h
+ *
+ * Copyright (C) 1991-1998, Thomas G. Lane.
+ * This file is part of the Independent JPEG Group's software.
+ * For conditions of distribution and use, see the accompanying README file.
+ *
+ * This file defines the application interface for the JPEG library.
+ * Most applications using the library need only include this file,
+ * and perhaps jerror.h if they want to know the exact error codes.
+ */
+
+#ifndef JPEGLIB_H
+#define JPEGLIB_H
+
+#define FOXIT_PREFIX(origName) FPDFAPIJPEG_##origName
+
+#define jcopy_block_row FOXIT_PREFIX(jcopy_block_row)
+#define jcopy_sample_rows FOXIT_PREFIX(jcopy_sample_rows)
+#define jdiv_round_up FOXIT_PREFIX(jdiv_round_up)
+#define jinit_1pass_quantizer FOXIT_PREFIX(jinit_1pass_quantizer)
+#define jinit_2pass_quantizer FOXIT_PREFIX(jinit_2pass_quantizer)
+#define jinit_color_deconverter FOXIT_PREFIX(jinit_color_deconverter)
+#define jinit_d_coef_controller FOXIT_PREFIX(jinit_d_coef_controller)
+#define jinit_d_main_controller FOXIT_PREFIX(jinit_d_main_controller)
+#define jinit_d_post_controller FOXIT_PREFIX(jinit_d_post_controller)
+#define jinit_huff_decoder FOXIT_PREFIX(jinit_huff_decoder)
+#define jinit_input_controller FOXIT_PREFIX(jinit_input_controller)
+#define jinit_inverse_dct FOXIT_PREFIX(jinit_inverse_dct)
+#define jinit_marker_reader FOXIT_PREFIX(jinit_marker_reader)
+#define jinit_master_decompress FOXIT_PREFIX(jinit_master_decompress)
+#define jinit_memory_mgr FOXIT_PREFIX(jinit_memory_mgr)
+#define jinit_merged_upsampler FOXIT_PREFIX(jinit_merged_upsampler)
+#define jinit_phuff_decoder FOXIT_PREFIX(jinit_phuff_decoder)
+#define jinit_upsampler FOXIT_PREFIX(jinit_upsampler)
+#define jpeg_CreateDecompress FOXIT_PREFIX(jpeg_CreateDecompress)
+#define jpeg_abort FOXIT_PREFIX(jpeg_abort)
+#define jpeg_abort_decompress FOXIT_PREFIX(jpeg_abort_decompress)
+#define jpeg_alloc_huff_table FOXIT_PREFIX(jpeg_alloc_huff_table)
+#define jpeg_alloc_quant_table FOXIT_PREFIX(jpeg_alloc_quant_table)
+#define jpeg_calc_output_dimensions FOXIT_PREFIX(jpeg_calc_output_dimensions)
+#define jpeg_consume_input FOXIT_PREFIX(jpeg_consume_input)
+#define jpeg_destroy FOXIT_PREFIX(jpeg_destroy)
+#define jpeg_destroy_decompress FOXIT_PREFIX(jpeg_destroy_decompress)
+#define jpeg_fill_bit_buffer FOXIT_PREFIX(jpeg_fill_bit_buffer)
+#define jpeg_finish_decompress FOXIT_PREFIX(jpeg_finish_decompress)
+#define jpeg_finish_output FOXIT_PREFIX(jpeg_finish_output)
+#define jpeg_free_large FOXIT_PREFIX(jpeg_free_large)
+#define jpeg_free_small FOXIT_PREFIX(jpeg_free_small)
+#define jpeg_get_large FOXIT_PREFIX(jpeg_get_large)
+#define jpeg_get_small FOXIT_PREFIX(jpeg_get_small)
+#define jpeg_has_multiple_scans FOXIT_PREFIX(jpeg_has_multiple_scans)
+#define jpeg_huff_decode FOXIT_PREFIX(jpeg_huff_decode)
+#define jpeg_idct_1x1 FOXIT_PREFIX(jpeg_idct_1x1)
+#define jpeg_idct_2x2 FOXIT_PREFIX(jpeg_idct_2x2)
+#define jpeg_idct_4x4 FOXIT_PREFIX(jpeg_idct_4x4)
+#define jpeg_idct_float FOXIT_PREFIX(jpeg_idct_float)
+#define jpeg_idct_ifast FOXIT_PREFIX(jpeg_idct_ifast)
+#define jpeg_idct_islow FOXIT_PREFIX(jpeg_idct_islow)
+#define jpeg_input_complete FOXIT_PREFIX(jpeg_input_complete)
+#define jpeg_make_d_derived_tbl FOXIT_PREFIX(jpeg_make_d_derived_tbl)
+#define jpeg_mem_available FOXIT_PREFIX(jpeg_mem_available)
+#define jpeg_mem_init FOXIT_PREFIX(jpeg_mem_init)
+#define jpeg_mem_term FOXIT_PREFIX(jpeg_mem_term)
+#define jpeg_natural_order FOXIT_PREFIX(jpeg_natural_order)
+#define jpeg_new_colormap FOXIT_PREFIX(jpeg_new_colormap)
+#define jpeg_open_backing_store FOXIT_PREFIX(jpeg_open_backing_store)
+#define jpeg_read_coefficients FOXIT_PREFIX(jpeg_read_coefficients)
+#define jpeg_read_header FOXIT_PREFIX(jpeg_read_header)
+#define jpeg_read_raw_data FOXIT_PREFIX(jpeg_read_raw_data)
+#define jpeg_read_scanlines FOXIT_PREFIX(jpeg_read_scanlines)
+#define jpeg_resync_to_restart FOXIT_PREFIX(jpeg_resync_to_restart)
+#define jpeg_save_markers FOXIT_PREFIX(jpeg_save_markers)
+#define jpeg_set_marker_processor FOXIT_PREFIX(jpeg_set_marker_processor)
+#define jpeg_start_decompress FOXIT_PREFIX(jpeg_start_decompress)
+#define jpeg_start_output FOXIT_PREFIX(jpeg_start_output)
+#define jpeg_std_error FOXIT_PREFIX(jpeg_std_error)
+#define jpeg_std_message_table FOXIT_PREFIX(jpeg_std_message_table)
+#define jpeg_stdio_src FOXIT_PREFIX(jpeg_stdio_src)
+#define jround_up FOXIT_PREFIX(jround_up)
+#define jzero_far FOXIT_PREFIX(jzero_far)
+
+ /*
+ * First we include the configuration files that record how this
+ * installation of the JPEG library is set up. jconfig.h can be
+ * generated automatically for many systems. jmorecfg.h contains
+ * manual configuration options that most people need not worry about.
+ */
+
+#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
+#include "jconfig.h" /* widely used configuration options */
+#endif
+#include "jmorecfg.h" /* seldom changed options */
+
+
+/* Version ID for the JPEG library.
+ * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
+ */
+
+#define JPEG_LIB_VERSION 62 /* Version 6b */
+
+
+/* Various constants determining the sizes of things.
+ * All of these are specified by the JPEG standard, so don't change them
+ * if you want to be compatible.
+ */
+
+#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
+#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
+#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
+#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
+#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
+#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
+#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
+/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
+ * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
+ * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
+ * to handle it. We even let you do this from the jconfig.h file. However,
+ * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
+ * sometimes emits noncompliant files doesn't mean you should too.
+ */
+#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */
+#ifndef D_MAX_BLOCKS_IN_MCU
+#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */
+#endif
+
+
+/* Data structures for images (arrays of samples and of DCT coefficients).
+ * On 80x86 machines, the image arrays are too big for near pointers,
+ * but the pointer arrays can fit in near memory.
+ */
+
+typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
+typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
+typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
+
+typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
+typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
+typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
+typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
+
+typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
+
+
+/* Types for JPEG compression parameters and working tables. */
+
+
+/* DCT coefficient quantization tables. */
+
+typedef struct {
+ /* This array gives the coefficient quantizers in natural array order
+ * (not the zigzag order in which they are stored in a JPEG DQT marker).
+ * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
+ */
+ UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
+ /* This field is used only during compression. It's initialized FALSE when
+ * the table is created, and set TRUE when it's been output to the file.
+ * You could suppress output of a table by setting this to TRUE.
+ * (See jpeg_suppress_tables for an example.)
+ */
+ boolean sent_table; /* TRUE when table has been output */
+} JQUANT_TBL;
+
+
+/* Huffman coding tables. */
+
+typedef struct {
+ /* These two fields directly represent the contents of a JPEG DHT marker */
+ UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
+ /* length k bits; bits[0] is unused */
+ UINT8 huffval[256]; /* The symbols, in order of incr code length */
+ /* This field is used only during compression. It's initialized FALSE when
+ * the table is created, and set TRUE when it's been output to the file.
+ * You could suppress output of a table by setting this to TRUE.
+ * (See jpeg_suppress_tables for an example.)
+ */
+ boolean sent_table; /* TRUE when table has been output */
+} JHUFF_TBL;
+
+
+/* Basic info about one component (color channel). */
+
+typedef struct {
+ /* These values are fixed over the whole image. */
+ /* For compression, they must be supplied by parameter setup; */
+ /* for decompression, they are read from the SOF marker. */
+ int component_id; /* identifier for this component (0..255) */
+ int component_index; /* its index in SOF or cinfo->comp_info[] */
+ int h_samp_factor; /* horizontal sampling factor (1..4) */
+ int v_samp_factor; /* vertical sampling factor (1..4) */
+ int quant_tbl_no; /* quantization table selector (0..3) */
+ /* These values may vary between scans. */
+ /* For compression, they must be supplied by parameter setup; */
+ /* for decompression, they are read from the SOS marker. */
+ /* The decompressor output side may not use these variables. */
+ int dc_tbl_no; /* DC entropy table selector (0..3) */
+ int ac_tbl_no; /* AC entropy table selector (0..3) */
+
+ /* Remaining fields should be treated as private by applications. */
+
+ /* These values are computed during compression or decompression startup: */
+ /* Component's size in DCT blocks.
+ * Any dummy blocks added to complete an MCU are not counted; therefore
+ * these values do not depend on whether a scan is interleaved or not.
+ */
+ JDIMENSION width_in_blocks;
+ JDIMENSION height_in_blocks;
+ /* Size of a DCT block in samples. Always DCTSIZE for compression.
+ * For decompression this is the size of the output from one DCT block,
+ * reflecting any scaling we choose to apply during the IDCT step.
+ * Values of 1,2,4,8 are likely to be supported. Note that different
+ * components may receive different IDCT scalings.
+ */
+ int DCT_scaled_size;
+ /* The downsampled dimensions are the component's actual, unpadded number
+ * of samples at the main buffer (preprocessing/compression interface), thus
+ * downsampled_width = ceil(image_width * Hi/Hmax)
+ * and similarly for height. For decompression, IDCT scaling is included, so
+ * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)
+ */
+ JDIMENSION downsampled_width; /* actual width in samples */
+ JDIMENSION downsampled_height; /* actual height in samples */
+ /* This flag is used only for decompression. In cases where some of the
+ * components will be ignored (eg grayscale output from YCbCr image),
+ * we can skip most computations for the unused components.
+ */
+ boolean component_needed; /* do we need the value of this component? */
+
+ /* These values are computed before starting a scan of the component. */
+ /* The decompressor output side may not use these variables. */
+ int MCU_width; /* number of blocks per MCU, horizontally */
+ int MCU_height; /* number of blocks per MCU, vertically */
+ int MCU_blocks; /* MCU_width * MCU_height */
+ int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */
+ int last_col_width; /* # of non-dummy blocks across in last MCU */
+ int last_row_height; /* # of non-dummy blocks down in last MCU */
+
+ /* Saved quantization table for component; NULL if none yet saved.
+ * See jdinput.c comments about the need for this information.
+ * This field is currently used only for decompression.
+ */
+ JQUANT_TBL * quant_table;
+
+ /* Private per-component storage for DCT or IDCT subsystem. */
+ void * dct_table;
+} jpeg_component_info;
+
+
+/* The script for encoding a multiple-scan file is an array of these: */
+
+typedef struct {
+ int comps_in_scan; /* number of components encoded in this scan */
+ int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
+ int Ss, Se; /* progressive JPEG spectral selection parms */
+ int Ah, Al; /* progressive JPEG successive approx. parms */
+} jpeg_scan_info;
+
+/* The decompressor can save APPn and COM markers in a list of these: */
+
+typedef struct jpeg_marker_struct * jpeg_saved_marker_ptr;
+
+struct jpeg_marker_struct {
+ jpeg_saved_marker_ptr next; /* next in list, or NULL */
+ UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
+ unsigned int original_length; /* # bytes of data in the file */
+ unsigned int data_length; /* # bytes of data saved at data[] */
+ JOCTET * data; /* the data contained in the marker */
+ /* the marker length word is not counted in data_length or original_length */
+};
+
+/* Known color spaces. */
+
+typedef enum {
+ JCS_UNKNOWN, /* error/unspecified */
+ JCS_GRAYSCALE, /* monochrome */
+ JCS_RGB, /* red/green/blue */
+ JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
+ JCS_CMYK, /* C/M/Y/K */
+ JCS_YCCK /* Y/Cb/Cr/K */
+} J_COLOR_SPACE;
+
+/* DCT/IDCT algorithm options. */
+
+typedef enum {
+ JDCT_ISLOW, /* slow but accurate integer algorithm */
+ JDCT_IFAST, /* faster, less accurate integer method */
+ JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
+} J_DCT_METHOD;
+
+#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
+#define JDCT_DEFAULT JDCT_ISLOW
+#endif
+#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
+#define JDCT_FASTEST JDCT_IFAST
+#endif
+
+/* Dithering options for decompression. */
+
+typedef enum {
+ JDITHER_NONE, /* no dithering */
+ JDITHER_ORDERED, /* simple ordered dither */
+ JDITHER_FS /* Floyd-Steinberg error diffusion dither */
+} J_DITHER_MODE;
+
+
+/* Common fields between JPEG compression and decompression master structs. */
+
+#define jpeg_common_fields \
+ struct jpeg_error_mgr * err; /* Error handler module */\
+ struct jpeg_memory_mgr * mem; /* Memory manager module */\
+ struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\
+ void * client_data; /* Available for use by application */\
+ boolean is_decompressor; /* So common code can tell which is which */\
+ int global_state /* For checking call sequence validity */
+
+/* Routines that are to be used by both halves of the library are declared
+ * to receive a pointer to this structure. There are no actual instances of
+ * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
+ */
+struct jpeg_common_struct {
+ jpeg_common_fields; /* Fields common to both master struct types */
+ /* Additional fields follow in an actual jpeg_compress_struct or
+ * jpeg_decompress_struct. All three structs must agree on these
+ * initial fields! (This would be a lot cleaner in C++.)
+ */
+};
+
+typedef struct jpeg_common_struct * j_common_ptr;
+typedef struct jpeg_compress_struct * j_compress_ptr;
+typedef struct jpeg_decompress_struct * j_decompress_ptr;
+
+
+/* Master record for a compression instance */
+
+struct jpeg_compress_struct {
+ jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
+
+ /* Destination for compressed data */
+ struct jpeg_destination_mgr * dest;
+
+ /* Description of source image --- these fields must be filled in by
+ * outer application before starting compression. in_color_space must
+ * be correct before you can even call jpeg_set_defaults().
+ */
+
+ JDIMENSION image_width; /* input image width */
+ JDIMENSION image_height; /* input image height */
+ int input_components; /* # of color components in input image */
+ J_COLOR_SPACE in_color_space; /* colorspace of input image */
+
+ double input_gamma; /* image gamma of input image */
+
+ /* Compression parameters --- these fields must be set before calling
+ * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
+ * initialize everything to reasonable defaults, then changing anything
+ * the application specifically wants to change. That way you won't get
+ * burnt when new parameters are added. Also note that there are several
+ * helper routines to simplify changing parameters.
+ */
+
+ int data_precision; /* bits of precision in image data */
+
+ int num_components; /* # of color components in JPEG image */
+ J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
+
+ jpeg_component_info * comp_info;
+ /* comp_info[i] describes component that appears i'th in SOF */
+
+ JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
+ /* ptrs to coefficient quantization tables, or NULL if not defined */
+
+ JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ /* ptrs to Huffman coding tables, or NULL if not defined */
+
+ UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+ UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+ UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+ int num_scans; /* # of entries in scan_info array */
+ const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */
+ /* The default value of scan_info is NULL, which causes a single-scan
+ * sequential JPEG file to be emitted. To create a multi-scan file,
+ * set num_scans and scan_info to point to an array of scan definitions.
+ */
+
+ boolean raw_data_in; /* TRUE=caller supplies downsampled data */
+ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
+ boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
+ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
+ int smoothing_factor; /* 1..100, or 0 for no input smoothing */
+ J_DCT_METHOD dct_method; /* DCT algorithm selector */
+
+ /* The restart interval can be specified in absolute MCUs by setting
+ * restart_interval, or in MCU rows by setting restart_in_rows
+ * (in which case the correct restart_interval will be figured
+ * for each scan).
+ */
+ unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
+ int restart_in_rows; /* if > 0, MCU rows per restart interval */
+
+ /* Parameters controlling emission of special markers. */
+
+ boolean write_JFIF_header; /* should a JFIF marker be written? */
+ UINT8 JFIF_major_version; /* What to write for the JFIF version number */
+ UINT8 JFIF_minor_version;
+ /* These three values are not used by the JPEG code, merely copied */
+ /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
+ /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */
+ /* ratio is defined by X_density/Y_density even when density_unit=0. */
+ UINT8 density_unit; /* JFIF code for pixel size units */
+ UINT16 X_density; /* Horizontal pixel density */
+ UINT16 Y_density; /* Vertical pixel density */
+ boolean write_Adobe_marker; /* should an Adobe marker be written? */
+
+ /* State variable: index of next scanline to be written to
+ * jpeg_write_scanlines(). Application may use this to control its
+ * processing loop, e.g., "while (next_scanline < image_height)".
+ */
+
+ JDIMENSION next_scanline; /* 0 .. image_height-1 */
+
+ /* Remaining fields are known throughout compressor, but generally
+ * should not be touched by a surrounding application.
+ */
+
+ /*
+ * These fields are computed during compression startup
+ */
+ boolean progressive_mode; /* TRUE if scan script uses progressive mode */
+ int max_h_samp_factor; /* largest h_samp_factor */
+ int max_v_samp_factor; /* largest v_samp_factor */
+
+ JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
+ /* The coefficient controller receives data in units of MCU rows as defined
+ * for fully interleaved scans (whether the JPEG file is interleaved or not).
+ * There are v_samp_factor * DCTSIZE sample rows of each component in an
+ * "iMCU" (interleaved MCU) row.
+ */
+
+ /*
+ * These fields are valid during any one scan.
+ * They describe the components and MCUs actually appearing in the scan.
+ */
+ int comps_in_scan; /* # of JPEG components in this scan */
+ jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
+ /* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+ JDIMENSION MCUs_per_row; /* # of MCUs across the image */
+ JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
+
+ int blocks_in_MCU; /* # of DCT blocks per MCU */
+ int MCU_membership[C_MAX_BLOCKS_IN_MCU];
+ /* MCU_membership[i] is index in cur_comp_info of component owning */
+ /* i'th block in an MCU */
+
+ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
+
+ /*
+ * Links to compression subobjects (methods and private variables of modules)
+ */
+ struct jpeg_comp_master * master;
+ struct jpeg_c_main_controller * main;
+ struct jpeg_c_prep_controller * prep;
+ struct jpeg_c_coef_controller * coef;
+ struct jpeg_marker_writer * marker;
+ struct jpeg_color_converter * cconvert;
+ struct jpeg_downsampler * downsample;
+ struct jpeg_forward_dct * fdct;
+ struct jpeg_entropy_encoder * entropy;
+ jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */
+ int script_space_size;
+};
+
+
+/* Master record for a decompression instance */
+
+struct jpeg_decompress_struct {
+ jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
+
+ /* Source of compressed data */
+ struct jpeg_source_mgr * src;
+
+ /* Basic description of image --- filled in by jpeg_read_header(). */
+ /* Application may inspect these values to decide how to process image. */
+
+ JDIMENSION image_width; /* nominal image width (from SOF marker) */
+ JDIMENSION image_height; /* nominal image height */
+ int num_components; /* # of color components in JPEG image */
+ J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
+
+ /* Decompression processing parameters --- these fields must be set before
+ * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes
+ * them to default values.
+ */
+
+ J_COLOR_SPACE out_color_space; /* colorspace for output */
+
+ unsigned int scale_num, scale_denom; /* fraction by which to scale image */
+
+ double output_gamma; /* image gamma wanted in output */
+
+ boolean buffered_image; /* TRUE=multiple output passes */
+ boolean raw_data_out; /* TRUE=downsampled data wanted */
+
+ J_DCT_METHOD dct_method; /* IDCT algorithm selector */
+ boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
+ boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
+
+ boolean quantize_colors; /* TRUE=colormapped output wanted */
+ /* the following are ignored if not quantize_colors: */
+ J_DITHER_MODE dither_mode; /* type of color dithering to use */
+ boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
+ int desired_number_of_colors; /* max # colors to use in created colormap */
+ /* these are significant only in buffered-image mode: */
+ boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
+ boolean enable_external_quant;/* enable future use of external colormap */
+ boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
+
+ /* Description of actual output image that will be returned to application.
+ * These fields are computed by jpeg_start_decompress().
+ * You can also use jpeg_calc_output_dimensions() to determine these values
+ * in advance of calling jpeg_start_decompress().
+ */
+
+ JDIMENSION output_width; /* scaled image width */
+ JDIMENSION output_height; /* scaled image height */
+ int out_color_components; /* # of color components in out_color_space */
+ int output_components; /* # of color components returned */
+ /* output_components is 1 (a colormap index) when quantizing colors;
+ * otherwise it equals out_color_components.
+ */
+ int rec_outbuf_height; /* min recommended height of scanline buffer */
+ /* If the buffer passed to jpeg_read_scanlines() is less than this many rows
+ * high, space and time will be wasted due to unnecessary data copying.
+ * Usually rec_outbuf_height will be 1 or 2, at most 4.
+ */
+
+ /* When quantizing colors, the output colormap is described by these fields.
+ * The application can supply a colormap by setting colormap non-NULL before
+ * calling jpeg_start_decompress; otherwise a colormap is created during
+ * jpeg_start_decompress or jpeg_start_output.
+ * The map has out_color_components rows and actual_number_of_colors columns.
+ */
+ int actual_number_of_colors; /* number of entries in use */
+ JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
+
+ /* State variables: these variables indicate the progress of decompression.
+ * The application may examine these but must not modify them.
+ */
+
+ /* Row index of next scanline to be read from jpeg_read_scanlines().
+ * Application may use this to control its processing loop, e.g.,
+ * "while (output_scanline < output_height)".
+ */
+ JDIMENSION output_scanline; /* 0 .. output_height-1 */
+
+ /* Current input scan number and number of iMCU rows completed in scan.
+ * These indicate the progress of the decompressor input side.
+ */
+ int input_scan_number; /* Number of SOS markers seen so far */
+ JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
+
+ /* The "output scan number" is the notional scan being displayed by the
+ * output side. The decompressor will not allow output scan/row number
+ * to get ahead of input scan/row, but it can fall arbitrarily far behind.
+ */
+ int output_scan_number; /* Nominal scan number being displayed */
+ JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
+
+ /* Current progression status. coef_bits[c][i] indicates the precision
+ * with which component c's DCT coefficient i (in zigzag order) is known.
+ * It is -1 when no data has yet been received, otherwise it is the point
+ * transform (shift) value for the most recent scan of the coefficient
+ * (thus, 0 at completion of the progression).
+ * This pointer is NULL when reading a non-progressive file.
+ */
+ int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
+
+ /* Internal JPEG parameters --- the application usually need not look at
+ * these fields. Note that the decompressor output side may not use
+ * any parameters that can change between scans.
+ */
+
+ /* Quantization and Huffman tables are carried forward across input
+ * datastreams when processing abbreviated JPEG datastreams.
+ */
+
+ JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
+ /* ptrs to coefficient quantization tables, or NULL if not defined */
+
+ JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ /* ptrs to Huffman coding tables, or NULL if not defined */
+
+ /* These parameters are never carried across datastreams, since they
+ * are given in SOF/SOS markers or defined to be reset by SOI.
+ */
+
+ int data_precision; /* bits of precision in image data */
+
+ jpeg_component_info * comp_info;
+ /* comp_info[i] describes component that appears i'th in SOF */
+
+ boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
+ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
+
+ UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+ UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+ UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+ unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
+
+ /* These fields record data obtained from optional markers recognized by
+ * the JPEG library.
+ */
+ boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
+ /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
+ UINT8 JFIF_major_version; /* JFIF version number */
+ UINT8 JFIF_minor_version;
+ UINT8 density_unit; /* JFIF code for pixel size units */
+ UINT16 X_density; /* Horizontal pixel density */
+ UINT16 Y_density; /* Vertical pixel density */
+ boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
+ UINT8 Adobe_transform; /* Color transform code from Adobe marker */
+
+ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
+
+ /* Aside from the specific data retained from APPn markers known to the
+ * library, the uninterpreted contents of any or all APPn and COM markers
+ * can be saved in a list for examination by the application.
+ */
+ jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
+
+ /* Remaining fields are known throughout decompressor, but generally
+ * should not be touched by a surrounding application.
+ */
+
+ /*
+ * These fields are computed during decompression startup
+ */
+ int max_h_samp_factor; /* largest h_samp_factor */
+ int max_v_samp_factor; /* largest v_samp_factor */
+
+ int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
+
+ JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
+ /* The coefficient controller's input and output progress is measured in
+ * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
+ * in fully interleaved JPEG scans, but are used whether the scan is
+ * interleaved or not. We define an iMCU row as v_samp_factor DCT block
+ * rows of each component. Therefore, the IDCT output contains
+ * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.
+ */
+
+ JSAMPLE * sample_range_limit; /* table for fast range-limiting */
+
+ /*
+ * These fields are valid during any one scan.
+ * They describe the components and MCUs actually appearing in the scan.
+ * Note that the decompressor output side must not use these fields.
+ */
+ int comps_in_scan; /* # of JPEG components in this scan */
+ jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
+ /* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+ JDIMENSION MCUs_per_row; /* # of MCUs across the image */
+ JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
+
+ int blocks_in_MCU; /* # of DCT blocks per MCU */
+ int MCU_membership[D_MAX_BLOCKS_IN_MCU];
+ /* MCU_membership[i] is index in cur_comp_info of component owning */
+ /* i'th block in an MCU */
+
+ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
+
+ /* This field is shared between entropy decoder and marker parser.
+ * It is either zero or the code of a JPEG marker that has been
+ * read from the data source, but has not yet been processed.
+ */
+ int unread_marker;
+
+ /*
+ * Links to decompression subobjects (methods, private variables of modules)
+ */
+ struct jpeg_decomp_master * master;
+ struct jpeg_d_main_controller * main;
+ struct jpeg_d_coef_controller * coef;
+ struct jpeg_d_post_controller * post;
+ struct jpeg_input_controller * inputctl;
+ struct jpeg_marker_reader * marker;
+ struct jpeg_entropy_decoder * entropy;
+ struct jpeg_inverse_dct * idct;
+ struct jpeg_upsampler * upsample;
+ struct jpeg_color_deconverter * cconvert;
+ struct jpeg_color_quantizer * cquantize;
+};
+
+
+/* "Object" declarations for JPEG modules that may be supplied or called
+ * directly by the surrounding application.
+ * As with all objects in the JPEG library, these structs only define the
+ * publicly visible methods and state variables of a module. Additional
+ * private fields may exist after the public ones.
+ */
+
+
+/* Error handler object */
+
+struct jpeg_error_mgr {
+ /* Error exit handler: does not return to caller */
+ JMETHOD(void, error_exit, (j_common_ptr cinfo));
+ /* Conditionally emit a trace or warning message */
+ JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
+ /* Routine that actually outputs a trace or error message */
+ JMETHOD(void, output_message, (j_common_ptr cinfo));
+ /* Format a message string for the most recent JPEG error or message */
+ JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));
+#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
+ /* Reset error state variables at start of a new image */
+ JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));
+
+ /* The message ID code and any parameters are saved here.
+ * A message can have one string parameter or up to 8 int parameters.
+ */
+ int msg_code;
+#define JMSG_STR_PARM_MAX 80
+ union {
+ int i[8];
+ char s[JMSG_STR_PARM_MAX];
+ } msg_parm;
+
+ /* Standard state variables for error facility */
+
+ int trace_level; /* max msg_level that will be displayed */
+
+ /* For recoverable corrupt-data errors, we emit a warning message,
+ * but keep going unless emit_message chooses to abort. emit_message
+ * should count warnings in num_warnings. The surrounding application
+ * can check for bad data by seeing if num_warnings is nonzero at the
+ * end of processing.
+ */
+ long num_warnings; /* number of corrupt-data warnings */
+
+ /* These fields point to the table(s) of error message strings.
+ * An application can change the table pointer to switch to a different
+ * message list (typically, to change the language in which errors are
+ * reported). Some applications may wish to add additional error codes
+ * that will be handled by the JPEG library error mechanism; the second
+ * table pointer is used for this purpose.
+ *
+ * First table includes all errors generated by JPEG library itself.
+ * Error code 0 is reserved for a "no such error string" message.
+ */
+ const char * const * jpeg_message_table; /* Library errors */
+ int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
+ /* Second table can be added by application (see cjpeg/djpeg for example).
+ * It contains strings numbered first_addon_message..last_addon_message.
+ */
+ const char * const * addon_message_table; /* Non-library errors */
+ int first_addon_message; /* code for first string in addon table */
+ int last_addon_message; /* code for last string in addon table */
+};
+
+
+/* Progress monitor object */
+
+struct jpeg_progress_mgr {
+ JMETHOD(void, progress_monitor, (j_common_ptr cinfo));
+
+ long pass_counter; /* work units completed in this pass */
+ long pass_limit; /* total number of work units in this pass */
+ int completed_passes; /* passes completed so far */
+ int total_passes; /* total number of passes expected */
+};
+
+
+/* Data destination object for compression */
+
+struct jpeg_destination_mgr {
+ JOCTET * next_output_byte; /* => next byte to write in buffer */
+ size_t free_in_buffer; /* # of byte spaces remaining in buffer */
+
+ JMETHOD(void, init_destination, (j_compress_ptr cinfo));
+ JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo));
+ JMETHOD(void, term_destination, (j_compress_ptr cinfo));
+};
+
+
+/* Data source object for decompression */
+
+struct jpeg_source_mgr {
+ const JOCTET * next_input_byte; /* => next byte to read from buffer */
+ size_t bytes_in_buffer; /* # of bytes remaining in buffer */
+
+ JMETHOD(void, init_source, (j_decompress_ptr cinfo));
+ JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo));
+ JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes));
+ JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired));
+ JMETHOD(void, term_source, (j_decompress_ptr cinfo));
+};
+
+
+/* Memory manager object.
+ * Allocates "small" objects (a few K total), "large" objects (tens of K),
+ * and "really big" objects (virtual arrays with backing store if needed).
+ * The memory manager does not allow individual objects to be freed; rather,
+ * each created object is assigned to a pool, and whole pools can be freed
+ * at once. This is faster and more convenient than remembering exactly what
+ * to free, especially where malloc()/free() are not too speedy.
+ * NB: alloc routines never return NULL. They exit to error_exit if not
+ * successful.
+ */
+
+#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
+#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
+#define JPOOL_NUMPOOLS 2
+
+typedef struct jvirt_sarray_control * jvirt_sarray_ptr;
+typedef struct jvirt_barray_control * jvirt_barray_ptr;
+
+
+struct jpeg_memory_mgr {
+ /* Method pointers */
+ JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id,
+ size_t sizeofobject));
+ JMETHOD(void *, alloc_large, (j_common_ptr cinfo, int pool_id,
+ size_t sizeofobject));
+ JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id,
+ JDIMENSION samplesperrow,
+ JDIMENSION numrows));
+ JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id,
+ JDIMENSION blocksperrow,
+ JDIMENSION numrows));
+ JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo,
+ int pool_id,
+ boolean pre_zero,
+ JDIMENSION samplesperrow,
+ JDIMENSION numrows,
+ JDIMENSION maxaccess));
+ JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo,
+ int pool_id,
+ boolean pre_zero,
+ JDIMENSION blocksperrow,
+ JDIMENSION numrows,
+ JDIMENSION maxaccess));
+ JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo));
+ JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo,
+ jvirt_sarray_ptr ptr,
+ JDIMENSION start_row,
+ JDIMENSION num_rows,
+ boolean writable));
+ JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo,
+ jvirt_barray_ptr ptr,
+ JDIMENSION start_row,
+ JDIMENSION num_rows,
+ boolean writable));
+ JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id));
+ JMETHOD(void, self_destruct, (j_common_ptr cinfo));
+
+ /* Limit on memory allocation for this JPEG object. (Note that this is
+ * merely advisory, not a guaranteed maximum; it only affects the space
+ * used for virtual-array buffers.) May be changed by outer application
+ * after creating the JPEG object.
+ */
+ long max_memory_to_use;
+
+ /* Maximum allocation request accepted by alloc_large. */
+ long max_alloc_chunk;
+};
+
+
+/* Routine signature for application-supplied marker processing methods.
+ * Need not pass marker code since it is stored in cinfo->unread_marker.
+ */
+typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
+
+
+/* Declarations for routines called by application.
+ * The JPP macro hides prototype parameters from compilers that can't cope.
+ * Note JPP requires double parentheses.
+ */
+
+#ifdef HAVE_PROTOTYPES
+#define JPP(arglist) arglist
+#else
+#define JPP(arglist) ()
+#endif
+
+
+/* Short forms of external names for systems with brain-damaged linkers.
+ * We shorten external names to be unique in the first six letters, which
+ * is good enough for all known systems.
+ * (If your compiler itself needs names to be unique in less than 15
+ * characters, you are out of luck. Get a better compiler.)
+ */
+
+#ifdef NEED_SHORT_EXTERNAL_NAMES
+#define jpeg_std_error jStdError
+#define jpeg_CreateCompress jCreaCompress
+#define jpeg_CreateDecompress jCreaDecompress
+#define jpeg_destroy_compress jDestCompress
+#define jpeg_destroy_decompress jDestDecompress
+#define jpeg_stdio_dest jStdDest
+#define jpeg_stdio_src jStdSrc
+#define jpeg_set_defaults jSetDefaults
+#define jpeg_set_colorspace jSetColorspace
+#define jpeg_default_colorspace jDefColorspace
+#define jpeg_set_quality jSetQuality
+#define jpeg_set_linear_quality jSetLQuality
+#define jpeg_add_quant_table jAddQuantTable
+#define jpeg_quality_scaling jQualityScaling
+#define jpeg_simple_progression jSimProgress
+#define jpeg_suppress_tables jSuppressTables
+#define jpeg_alloc_quant_table jAlcQTable
+#define jpeg_alloc_huff_table jAlcHTable
+#define jpeg_start_compress jStrtCompress
+#define jpeg_write_scanlines jWrtScanlines
+#define jpeg_finish_compress jFinCompress
+#define jpeg_write_raw_data jWrtRawData
+#define jpeg_write_marker jWrtMarker
+#define jpeg_write_m_header jWrtMHeader
+#define jpeg_write_m_byte jWrtMByte
+#define jpeg_write_tables jWrtTables
+#define jpeg_read_header jReadHeader
+#define jpeg_start_decompress jStrtDecompress
+#define jpeg_read_scanlines jReadScanlines
+#define jpeg_finish_decompress jFinDecompress
+#define jpeg_read_raw_data jReadRawData
+#define jpeg_has_multiple_scans jHasMultScn
+#define jpeg_start_output jStrtOutput
+#define jpeg_finish_output jFinOutput
+#define jpeg_input_complete jInComplete
+#define jpeg_new_colormap jNewCMap
+#define jpeg_consume_input jConsumeInput
+#define jpeg_calc_output_dimensions jCalcDimensions
+#define jpeg_save_markers jSaveMarkers
+#define jpeg_set_marker_processor jSetMarker
+#define jpeg_read_coefficients jReadCoefs
+#define jpeg_write_coefficients jWrtCoefs
+#define jpeg_copy_critical_parameters jCopyCrit
+#define jpeg_abort_compress jAbrtCompress
+#define jpeg_abort_decompress jAbrtDecompress
+#define jpeg_abort jAbort
+#define jpeg_destroy jDestroy
+#define jpeg_resync_to_restart jResyncRestart
+#endif /* NEED_SHORT_EXTERNAL_NAMES */
+
+
+/* Default error-management setup */
+EXTERN(struct jpeg_error_mgr *) jpeg_std_error
+ JPP((struct jpeg_error_mgr * err));
+
+/* Initialization of JPEG compression objects.
+ * jpeg_create_compress() and jpeg_create_decompress() are the exported
+ * names that applications should call. These expand to calls on
+ * jpeg_CreateCompress and jpeg_CreateDecompress with additional information
+ * passed for version mismatch checking.
+ * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
+ */
+#define jpeg_create_compress(cinfo) \
+ jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
+ (size_t) sizeof(struct jpeg_compress_struct))
+#define jpeg_create_decompress(cinfo) \
+ jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
+ (size_t) sizeof(struct jpeg_decompress_struct))
+EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo,
+ int version, size_t structsize));
+EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo,
+ int version, size_t structsize));
+/* Destruction of JPEG compression objects */
+EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
+
+#if 0
+/* Standard data source and destination managers: stdio streams. */
+/* Caller is responsible for opening the file before and closing after. */
+EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FXSYS_FILE * outfile));
+EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FXSYS_FILE * infile));
+#endif
+
+/* Default parameter setup for compression */
+EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
+/* Compression parameter setup aids */
+EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo,
+ J_COLOR_SPACE colorspace));
+EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
+ boolean force_baseline));
+EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
+ int scale_factor,
+ boolean force_baseline));
+EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
+ const unsigned int *basic_table,
+ int scale_factor,
+ boolean force_baseline));
+EXTERN(int) jpeg_quality_scaling JPP((int quality));
+EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
+ boolean suppress));
+EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
+EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
+
+/* Main entry points for compression */
+EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
+ boolean write_all_tables));
+EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo,
+ JSAMPARRAY scanlines,
+ JDIMENSION num_lines));
+EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo));
+
+/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
+EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo,
+ JSAMPIMAGE data,
+ JDIMENSION num_lines));
+
+/* Write a special marker. See libjpeg.doc concerning safe usage. */
+EXTERN(void) jpeg_write_marker
+ JPP((j_compress_ptr cinfo, int marker,
+ const JOCTET * dataptr, unsigned int datalen));
+/* Same, but piecemeal. */
+EXTERN(void) jpeg_write_m_header
+ JPP((j_compress_ptr cinfo, int marker, unsigned int datalen));
+EXTERN(void) jpeg_write_m_byte
+ JPP((j_compress_ptr cinfo, int val));
+
+/* Alternate compression function: just write an abbreviated table file */
+EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo));
+
+/* Decompression startup: read start of JPEG datastream to see what's there */
+EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo,
+ boolean require_image));
+/* Return value is one of: */
+#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
+#define JPEG_HEADER_OK 1 /* Found valid image datastream */
+#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
+/* If you pass require_image = TRUE (normal case), you need not check for
+ * a TABLES_ONLY return code; an abbreviated file will cause an error exit.
+ * JPEG_SUSPENDED is only possible if you use a data source module that can
+ * give a suspension return (the stdio source module doesn't).
+ */
+
+/* Main entry points for decompression */
+EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo));
+EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo,
+ JSAMPARRAY scanlines,
+ JDIMENSION max_lines));
+EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo));
+
+/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
+EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo,
+ JSAMPIMAGE data,
+ JDIMENSION max_lines));
+
+/* Additional entry points for buffered-image mode. */
+EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));
+EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo,
+ int scan_number));
+EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo));
+EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo));
+EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo));
+EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
+/* Return value is one of: */
+/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
+#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
+#define JPEG_REACHED_EOI 2 /* Reached end of image */
+#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
+#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
+
+/* Precalculate output dimensions for current decompression parameters. */
+EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
+
+/* Control saving of COM and APPn markers into marker_list. */
+EXTERN(void) jpeg_save_markers
+ JPP((j_decompress_ptr cinfo, int marker_code,
+ unsigned int length_limit));
+
+/* Install a special processing method for COM or APPn markers. */
+EXTERN(void) jpeg_set_marker_processor
+ JPP((j_decompress_ptr cinfo, int marker_code,
+ jpeg_marker_parser_method routine));
+
+/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
+EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo));
+EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo,
+ jvirt_barray_ptr * coef_arrays));
+EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,
+ j_compress_ptr dstinfo));
+
+/* If you choose to abort compression or decompression before completing
+ * jpeg_finish_(de)compress, then you need to clean up to release memory,
+ * temporary files, etc. You can just call jpeg_destroy_(de)compress
+ * if you're done with the JPEG object, but if you want to clean it up and
+ * reuse it, call this:
+ */
+EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo));
+
+/* Generic versions of jpeg_abort and jpeg_destroy that work on either
+ * flavor of JPEG object. These may be more convenient in some places.
+ */
+EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo));
+EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo));
+
+/* Default restart-marker-resync procedure for use by data source modules */
+EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo,
+ int desired));
+
+
+/* These marker codes are exported since applications and data source modules
+ * are likely to want to use them.
+ */
+
+#define JPEG_RST0 0xD0 /* RST0 marker code */
+#define JPEG_EOI 0xD9 /* EOI marker code */
+#define JPEG_APP0 0xE0 /* APP0 marker code */
+#define JPEG_COM 0xFE /* COM marker code */
+
+
+/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
+ * for structure definitions that are never filled in, keep it quiet by
+ * supplying dummy definitions for the various substructures.
+ */
+
+#ifdef INCOMPLETE_TYPES_BROKEN
+#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
+struct jvirt_sarray_control { long dummy; };
+struct jvirt_barray_control { long dummy; };
+struct jpeg_comp_master { long dummy; };
+struct jpeg_c_main_controller { long dummy; };
+struct jpeg_c_prep_controller { long dummy; };
+struct jpeg_c_coef_controller { long dummy; };
+struct jpeg_marker_writer { long dummy; };
+struct jpeg_color_converter { long dummy; };
+struct jpeg_downsampler { long dummy; };
+struct jpeg_forward_dct { long dummy; };
+struct jpeg_entropy_encoder { long dummy; };
+struct jpeg_decomp_master { long dummy; };
+struct jpeg_d_main_controller { long dummy; };
+struct jpeg_d_coef_controller { long dummy; };
+struct jpeg_d_post_controller { long dummy; };
+struct jpeg_input_controller { long dummy; };
+struct jpeg_marker_reader { long dummy; };
+struct jpeg_entropy_decoder { long dummy; };
+struct jpeg_inverse_dct { long dummy; };
+struct jpeg_upsampler { long dummy; };
+struct jpeg_color_deconverter { long dummy; };
+struct jpeg_color_quantizer { long dummy; };
+#endif /* JPEG_INTERNALS */
+#endif /* INCOMPLETE_TYPES_BROKEN */
+
+
+/*
+ * The JPEG library modules define JPEG_INTERNALS before including this file.
+ * The internal structure declarations are read only when that is true.
+ * Applications using the library should not include jpegint.h, but may wish
+ * to include jerror.h.
+ */
+
+#ifdef JPEG_INTERNALS
+#include "jpegint.h" /* fetch private declarations */
+#include "jerror.h" /* fetch error codes too */
+#endif
+
+#endif /* JPEGLIB_H */
diff --git a/core/include/thirdparties/zlib/zconf.h b/core/include/thirdparties/zlib/zconf.h
index 3a1f9696fc..5708a377e0 100644
--- a/core/include/thirdparties/zlib/zconf.h
+++ b/core/include/thirdparties/zlib/zconf.h
@@ -1,519 +1,519 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- * Even better than compiling with -DZ_PREFIX would be to use configure to set
- * this permanently in zconf.h using "./configure --zprefix".
- */
-#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
-# define Z_PREFIX_SET
-
-/* all linked symbols */
-# define _dist_code z__dist_code
-# define _length_code z__length_code
-# define _tr_align z__tr_align
-# define _tr_flush_bits z__tr_flush_bits
-# define _tr_flush_block z__tr_flush_block
-# define _tr_init z__tr_init
-# define _tr_stored_block z__tr_stored_block
-# define _tr_tally z__tr_tally
-# define adler32 z_adler32
-# define adler32_combine z_adler32_combine
-# define adler32_combine64 z_adler32_combine64
-# ifndef Z_SOLO
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# endif
-# define crc32 z_crc32
-# define crc32_combine z_crc32_combine
-# define crc32_combine64 z_crc32_combine64
-# define deflate z_deflate
-# define deflateBound z_deflateBound
-# define deflateCopy z_deflateCopy
-# define deflateEnd z_deflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateInit_ z_deflateInit_
-# define deflateParams z_deflateParams
-# define deflatePending z_deflatePending
-# define deflatePrime z_deflatePrime
-# define deflateReset z_deflateReset
-# define deflateResetKeep z_deflateResetKeep
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateSetHeader z_deflateSetHeader
-# define deflateTune z_deflateTune
-# define deflate_copyright z_deflate_copyright
-# define get_crc_table z_get_crc_table
-# ifndef Z_SOLO
-# define gz_error z_gz_error
-# define gz_intmax z_gz_intmax
-# define gz_strwinerror z_gz_strwinerror
-# define gzbuffer z_gzbuffer
-# define gzclearerr z_gzclearerr
-# define gzclose z_gzclose
-# define gzclose_r z_gzclose_r
-# define gzclose_w z_gzclose_w
-# define gzdirect z_gzdirect
-# define gzdopen z_gzdopen
-# define gzeof z_gzeof
-# define gzerror z_gzerror
-# define gzflush z_gzflush
-# define gzgetc z_gzgetc
-# define gzgetc_ z_gzgetc_
-# define gzgets z_gzgets
-# define gzoffset z_gzoffset
-# define gzoffset64 z_gzoffset64
-# define gzopen z_gzopen
-# define gzopen64 z_gzopen64
-# ifdef _WIN32
-# define gzopen_w z_gzopen_w
-# endif
-# define gzprintf z_gzprintf
-# define gzvprintf z_gzvprintf
-# define gzputc z_gzputc
-# define gzputs z_gzputs
-# define gzread z_gzread
-# define gzrewind z_gzrewind
-# define gzseek z_gzseek
-# define gzseek64 z_gzseek64
-# define gzsetparams z_gzsetparams
-# define gztell z_gztell
-# define gztell64 z_gztell64
-# define gzungetc z_gzungetc
-# define gzwrite z_gzwrite
-# endif
-# define inflate z_inflate
-# define inflateBack z_inflateBack
-# define inflateBackEnd z_inflateBackEnd
-# define inflateBackInit_ z_inflateBackInit_
-# define inflateCopy z_inflateCopy
-# define inflateEnd z_inflateEnd
-# define inflateGetHeader z_inflateGetHeader
-# define inflateInit2_ z_inflateInit2_
-# define inflateInit_ z_inflateInit_
-# define inflateMark z_inflateMark
-# define inflatePrime z_inflatePrime
-# define inflateReset z_inflateReset
-# define inflateReset2 z_inflateReset2
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateGetDictionary z_inflateGetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateUndermine z_inflateUndermine
-# define inflateResetKeep z_inflateResetKeep
-# define inflate_copyright z_inflate_copyright
-# define inflate_fast z_inflate_fast
-# define inflate_table z_inflate_table
-# ifndef Z_SOLO
-# define uncompress z_uncompress
-# endif
-# define zError z_zError
-# ifndef Z_SOLO
-# define zcalloc z_zcalloc
-# define zcfree z_zcfree
-# endif
-# define zlibCompileFlags z_zlibCompileFlags
-# define zlibVersion z_zlibVersion
-
-/* all zlib typedefs in zlib.h and zconf.h */
-# define Byte z_Byte
-# define Bytef z_Bytef
-# define alloc_func z_alloc_func
-# define charf z_charf
-# define free_func z_free_func
-# ifndef Z_SOLO
-# define gzFile z_gzFile
-# endif
-# define gz_header z_gz_header
-# define gz_headerp z_gz_headerp
-# define in_func z_in_func
-# define intf z_intf
-# define out_func z_out_func
-# define uInt z_uInt
-# define uIntf z_uIntf
-# define uLong z_uLong
-# define uLongf z_uLongf
-# define voidp z_voidp
-# define voidpc z_voidpc
-# define voidpf z_voidpf
-
-/* all zlib structs in zlib.h and zconf.h */
-# define gz_header_s z_gz_header_s
-# define internal_state z_internal_state
-
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-# ifndef WIN32
-# define WIN32
-# endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-#if defined(ZLIB_CONST) && !defined(z_const)
-# define z_const const
-#else
-# define z_const
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-#ifndef Z_ARG /* function prototypes for stdarg */
-# if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# define Z_ARG(args) args
-# else
-# define Z_ARG(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
-# include <limits.h>
-# if (UINT_MAX == 0xffffffffUL)
-# define Z_U4 unsigned
-# elif (ULONG_MAX == 0xffffffffUL)
-# define Z_U4 unsigned long
-# elif (USHRT_MAX == 0xffffffffUL)
-# define Z_U4 unsigned short
-# endif
-#endif
-
-#ifdef Z_U4
- typedef Z_U4 z_crc_t;
-#else
- typedef unsigned long z_crc_t;
-#endif
-
-#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
-#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
-# define Z_HAVE_UNISTD_H
-#endif
-#endif /* 0 */
-
-#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
-# define Z_HAVE_STDARG_H
-#endif
-
-#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
-#ifdef STDC
-# ifndef Z_SOLO
-# include <sys/types.h> /* for off_t */
-# endif
-#endif
-#endif /* 0 */
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-# include <stdarg.h> /* for va_list */
-# endif
-#endif
-
-#ifdef _WIN32
-# ifndef Z_SOLO
-# include <stddef.h> /* for wchar_t */
-# endif
-#endif
-
-#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
-/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
- * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
- * though the former does not conform to the LFS document), but considering
- * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
- * equivalently requesting no 64-bit operations
- */
-#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
-# undef _LARGEFILE64_SOURCE
-#endif
-#endif /* 0 */
-
-#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
-# define Z_HAVE_UNISTD_H
-#endif
-#ifndef Z_SOLO
-#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
-# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
-# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
-# ifdef VMS
-# include <unixio.h> /* for off_t */
-# endif
-# ifndef z_off_t
-# define z_off_t off_t
-# endif
-# endif
-#endif /* 0 */
-#endif
-
-#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
-# define Z_LFS64
-#endif
-
-#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
-# define Z_LARGE64
-#endif
-
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
-# define Z_WANT64
-#endif
-
-#if !defined(SEEK_SET) && !defined(Z_SOLO)
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if !defined(_WIN32) && defined(Z_LARGE64)
-# define z_off64_t off64_t
-#else
-# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
-# define z_off64_t __int64
-# else
-# define z_off64_t z_off_t
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
- #pragma map(deflateInit_,"DEIN")
- #pragma map(deflateInit2_,"DEIN2")
- #pragma map(deflateEnd,"DEEND")
- #pragma map(deflateBound,"DEBND")
- #pragma map(inflateInit_,"ININ")
- #pragma map(inflateInit2_,"ININ2")
- #pragma map(inflateEnd,"INEND")
- #pragma map(inflateSync,"INSY")
- #pragma map(inflateSetDictionary,"INSEDI")
- #pragma map(compressBound,"CMBND")
- #pragma map(inflate_table,"INTABL")
- #pragma map(inflate_fast,"INFA")
- #pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZCONF_H
+#define ZCONF_H
+
+/*
+ * If you *really* need a unique prefix for all types and library functions,
+ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
+ */
+#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
+# define Z_PREFIX_SET
+
+/* all linked symbols */
+# define _dist_code z__dist_code
+# define _length_code z__length_code
+# define _tr_align z__tr_align
+# define _tr_flush_bits z__tr_flush_bits
+# define _tr_flush_block z__tr_flush_block
+# define _tr_init z__tr_init
+# define _tr_stored_block z__tr_stored_block
+# define _tr_tally z__tr_tally
+# define adler32 z_adler32
+# define adler32_combine z_adler32_combine
+# define adler32_combine64 z_adler32_combine64
+# ifndef Z_SOLO
+# define compress z_compress
+# define compress2 z_compress2
+# define compressBound z_compressBound
+# endif
+# define crc32 z_crc32
+# define crc32_combine z_crc32_combine
+# define crc32_combine64 z_crc32_combine64
+# define deflate z_deflate
+# define deflateBound z_deflateBound
+# define deflateCopy z_deflateCopy
+# define deflateEnd z_deflateEnd
+# define deflateInit2_ z_deflateInit2_
+# define deflateInit_ z_deflateInit_
+# define deflateParams z_deflateParams
+# define deflatePending z_deflatePending
+# define deflatePrime z_deflatePrime
+# define deflateReset z_deflateReset
+# define deflateResetKeep z_deflateResetKeep
+# define deflateSetDictionary z_deflateSetDictionary
+# define deflateSetHeader z_deflateSetHeader
+# define deflateTune z_deflateTune
+# define deflate_copyright z_deflate_copyright
+# define get_crc_table z_get_crc_table
+# ifndef Z_SOLO
+# define gz_error z_gz_error
+# define gz_intmax z_gz_intmax
+# define gz_strwinerror z_gz_strwinerror
+# define gzbuffer z_gzbuffer
+# define gzclearerr z_gzclearerr
+# define gzclose z_gzclose
+# define gzclose_r z_gzclose_r
+# define gzclose_w z_gzclose_w
+# define gzdirect z_gzdirect
+# define gzdopen z_gzdopen
+# define gzeof z_gzeof
+# define gzerror z_gzerror
+# define gzflush z_gzflush
+# define gzgetc z_gzgetc
+# define gzgetc_ z_gzgetc_
+# define gzgets z_gzgets
+# define gzoffset z_gzoffset
+# define gzoffset64 z_gzoffset64
+# define gzopen z_gzopen
+# define gzopen64 z_gzopen64
+# ifdef _WIN32
+# define gzopen_w z_gzopen_w
+# endif
+# define gzprintf z_gzprintf
+# define gzvprintf z_gzvprintf
+# define gzputc z_gzputc
+# define gzputs z_gzputs
+# define gzread z_gzread
+# define gzrewind z_gzrewind
+# define gzseek z_gzseek
+# define gzseek64 z_gzseek64
+# define gzsetparams z_gzsetparams
+# define gztell z_gztell
+# define gztell64 z_gztell64
+# define gzungetc z_gzungetc
+# define gzwrite z_gzwrite
+# endif
+# define inflate z_inflate
+# define inflateBack z_inflateBack
+# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit_ z_inflateBackInit_
+# define inflateCopy z_inflateCopy
+# define inflateEnd z_inflateEnd
+# define inflateGetHeader z_inflateGetHeader
+# define inflateInit2_ z_inflateInit2_
+# define inflateInit_ z_inflateInit_
+# define inflateMark z_inflateMark
+# define inflatePrime z_inflatePrime
+# define inflateReset z_inflateReset
+# define inflateReset2 z_inflateReset2
+# define inflateSetDictionary z_inflateSetDictionary
+# define inflateGetDictionary z_inflateGetDictionary
+# define inflateSync z_inflateSync
+# define inflateSyncPoint z_inflateSyncPoint
+# define inflateUndermine z_inflateUndermine
+# define inflateResetKeep z_inflateResetKeep
+# define inflate_copyright z_inflate_copyright
+# define inflate_fast z_inflate_fast
+# define inflate_table z_inflate_table
+# ifndef Z_SOLO
+# define uncompress z_uncompress
+# endif
+# define zError z_zError
+# ifndef Z_SOLO
+# define zcalloc z_zcalloc
+# define zcfree z_zcfree
+# endif
+# define zlibCompileFlags z_zlibCompileFlags
+# define zlibVersion z_zlibVersion
+
+/* all zlib typedefs in zlib.h and zconf.h */
+# define Byte z_Byte
+# define Bytef z_Bytef
+# define alloc_func z_alloc_func
+# define charf z_charf
+# define free_func z_free_func
+# ifndef Z_SOLO
+# define gzFile z_gzFile
+# endif
+# define gz_header z_gz_header
+# define gz_headerp z_gz_headerp
+# define in_func z_in_func
+# define intf z_intf
+# define out_func z_out_func
+# define uInt z_uInt
+# define uIntf z_uIntf
+# define uLong z_uLong
+# define uLongf z_uLongf
+# define voidp z_voidp
+# define voidpc z_voidpc
+# define voidpf z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+# define gz_header_s z_gz_header_s
+# define internal_state z_internal_state
+
+#endif
+
+#if defined(__MSDOS__) && !defined(MSDOS)
+# define MSDOS
+#endif
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
+# define OS2
+#endif
+#if defined(_WINDOWS) && !defined(WINDOWS)
+# define WINDOWS
+#endif
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
+# ifndef WIN32
+# define WIN32
+# endif
+#endif
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
+# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
+# ifndef SYS16BIT
+# define SYS16BIT
+# endif
+# endif
+#endif
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ */
+#ifdef SYS16BIT
+# define MAXSEG_64K
+#endif
+#ifdef MSDOS
+# define UNALIGNED_OK
+#endif
+
+#ifdef __STDC_VERSION__
+# ifndef STDC
+# define STDC
+# endif
+# if __STDC_VERSION__ >= 199901L
+# ifndef STDC99
+# define STDC99
+# endif
+# endif
+#endif
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
+# define STDC
+#endif
+
+#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
+# define STDC
+#endif
+
+#ifndef STDC
+# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
+# define const /* note: need a more gentle solution here */
+# endif
+#endif
+
+#if defined(ZLIB_CONST) && !defined(z_const)
+# define z_const const
+#else
+# define z_const
+#endif
+
+/* Some Mac compilers merge all .h files incorrectly: */
+#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
+# define NO_DUMMY_DECL
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+# ifdef MAXSEG_64K
+# define MAX_MEM_LEVEL 8
+# else
+# define MAX_MEM_LEVEL 9
+# endif
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
+ * created by gzip. (Files created by minigzip can still be extracted by
+ * gzip.)
+ */
+#ifndef MAX_WBITS
+# define MAX_WBITS 15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+ (1 << (windowBits+2)) + (1 << (memLevel+9))
+ that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+ make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+ The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects.
+*/
+
+ /* Type declarations */
+
+#ifndef OF /* function prototypes */
+# ifdef STDC
+# define OF(args) args
+# else
+# define OF(args) ()
+# endif
+#endif
+
+#ifndef Z_ARG /* function prototypes for stdarg */
+# if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# define Z_ARG(args) args
+# else
+# define Z_ARG(args) ()
+# endif
+#endif
+
+/* The following definitions for FAR are needed only for MSDOS mixed
+ * model programming (small or medium model with some far allocations).
+ * This was tested only with MSC; for other MSDOS compilers you may have
+ * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
+ * just define FAR to be empty.
+ */
+#ifdef SYS16BIT
+# if defined(M_I86SM) || defined(M_I86MM)
+ /* MSC small or medium model */
+# define SMALL_MEDIUM
+# ifdef _MSC_VER
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+# if (defined(__SMALL__) || defined(__MEDIUM__))
+ /* Turbo C small or medium model */
+# define SMALL_MEDIUM
+# ifdef __BORLANDC__
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+#endif
+
+#if defined(WINDOWS) || defined(WIN32)
+ /* If building or using zlib as a DLL, define ZLIB_DLL.
+ * This is not mandatory, but it offers a little performance increase.
+ */
+# ifdef ZLIB_DLL
+# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+# ifdef ZLIB_INTERNAL
+# define ZEXTERN extern __declspec(dllexport)
+# else
+# define ZEXTERN extern __declspec(dllimport)
+# endif
+# endif
+# endif /* ZLIB_DLL */
+ /* If building or using zlib with the WINAPI/WINAPIV calling convention,
+ * define ZLIB_WINAPI.
+ * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+ */
+# ifdef ZLIB_WINAPI
+# ifdef FAR
+# undef FAR
+# endif
+# include <windows.h>
+ /* No need for _export, use ZLIB.DEF instead. */
+ /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+# define ZEXPORT WINAPI
+# ifdef WIN32
+# define ZEXPORTVA WINAPIV
+# else
+# define ZEXPORTVA FAR CDECL
+# endif
+# endif
+#endif
+
+#if defined (__BEOS__)
+# ifdef ZLIB_DLL
+# ifdef ZLIB_INTERNAL
+# define ZEXPORT __declspec(dllexport)
+# define ZEXPORTVA __declspec(dllexport)
+# else
+# define ZEXPORT __declspec(dllimport)
+# define ZEXPORTVA __declspec(dllimport)
+# endif
+# endif
+#endif
+
+#ifndef ZEXTERN
+# define ZEXTERN extern
+#endif
+#ifndef ZEXPORT
+# define ZEXPORT
+#endif
+#ifndef ZEXPORTVA
+# define ZEXPORTVA
+#endif
+
+#ifndef FAR
+# define FAR
+#endif
+
+#if !defined(__MACTYPES__)
+typedef unsigned char Byte; /* 8 bits */
+#endif
+typedef unsigned int uInt; /* 16 bits or more */
+typedef unsigned long uLong; /* 32 bits or more */
+
+#ifdef SMALL_MEDIUM
+ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+# define Bytef Byte FAR
+#else
+ typedef Byte FAR Bytef;
+#endif
+typedef char FAR charf;
+typedef int FAR intf;
+typedef uInt FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+ typedef void const *voidpc;
+ typedef void FAR *voidpf;
+ typedef void *voidp;
+#else
+ typedef Byte const *voidpc;
+ typedef Byte FAR *voidpf;
+ typedef Byte *voidp;
+#endif
+
+#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
+# include <limits.h>
+# if (UINT_MAX == 0xffffffffUL)
+# define Z_U4 unsigned
+# elif (ULONG_MAX == 0xffffffffUL)
+# define Z_U4 unsigned long
+# elif (USHRT_MAX == 0xffffffffUL)
+# define Z_U4 unsigned short
+# endif
+#endif
+
+#ifdef Z_U4
+ typedef Z_U4 z_crc_t;
+#else
+ typedef unsigned long z_crc_t;
+#endif
+
+#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
+#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
+# define Z_HAVE_UNISTD_H
+#endif
+#endif /* 0 */
+
+#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
+# define Z_HAVE_STDARG_H
+#endif
+
+#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
+#ifdef STDC
+# ifndef Z_SOLO
+# include <sys/types.h> /* for off_t */
+# endif
+#endif
+#endif /* 0 */
+
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# ifndef Z_SOLO
+# include <stdarg.h> /* for va_list */
+# endif
+#endif
+
+#ifdef _WIN32
+# ifndef Z_SOLO
+# include <stddef.h> /* for wchar_t */
+# endif
+#endif
+
+#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
+# undef _LARGEFILE64_SOURCE
+#endif
+#endif /* 0 */
+
+#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
+# define Z_HAVE_UNISTD_H
+#endif
+#ifndef Z_SOLO
+#if 0 /* Sunliang.Liu 20100908 sync the config to the old revision, otherwise, evc compile failed. */
+# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
+# ifdef VMS
+# include <unixio.h> /* for off_t */
+# endif
+# ifndef z_off_t
+# define z_off_t off_t
+# endif
+# endif
+#endif /* 0 */
+#endif
+
+#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
+# define Z_LFS64
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
+# define Z_LARGE64
+#endif
+
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
+# define Z_WANT64
+#endif
+
+#if !defined(SEEK_SET) && !defined(Z_SOLO)
+# define SEEK_SET 0 /* Seek from beginning of file. */
+# define SEEK_CUR 1 /* Seek from current position. */
+# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
+#endif
+
+#ifndef z_off_t
+# define z_off_t long
+#endif
+
+#if !defined(_WIN32) && defined(Z_LARGE64)
+# define z_off64_t off64_t
+#else
+# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
+# define z_off64_t __int64
+# else
+# define z_off64_t z_off_t
+# endif
+#endif
+
+/* MVS linker does not support external names larger than 8 bytes */
+#if defined(__MVS__)
+ #pragma map(deflateInit_,"DEIN")
+ #pragma map(deflateInit2_,"DEIN2")
+ #pragma map(deflateEnd,"DEEND")
+ #pragma map(deflateBound,"DEBND")
+ #pragma map(inflateInit_,"ININ")
+ #pragma map(inflateInit2_,"ININ2")
+ #pragma map(inflateEnd,"INEND")
+ #pragma map(inflateSync,"INSY")
+ #pragma map(inflateSetDictionary,"INSEDI")
+ #pragma map(compressBound,"CMBND")
+ #pragma map(inflate_table,"INTABL")
+ #pragma map(inflate_fast,"INFA")
+ #pragma map(inflate_copyright,"INCOPY")
+#endif
+
+#endif /* ZCONF_H */
diff --git a/core/include/thirdparties/zlib/zlib.h b/core/include/thirdparties/zlib/zlib.h
index 5e068c4a37..5850070baf 100644
--- a/core/include/thirdparties/zlib/zlib.h
+++ b/core/include/thirdparties/zlib/zlib.h
@@ -1,1828 +1,1828 @@
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.8, April 28th, 2013
-
- Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
- (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#define deflate_copyright FPDFAPI_deflate_copyright
-#define adler32 FPDFAPI_adler32
-#define compress2 FPDFAPI_compress2
-#define compress FPDFAPI_compress
-#define compressBound FPDFAPI_compressBound
-#define get_crc_table FPDFAPI_get_crc_table
-#define crc32 FPDFAPI_crc32
-#define deflateInit_ FPDFAPI_deflateInit_
-#define deflateInit2_ FPDFAPI_deflateInit2_
-#define deflateSetDictionary FPDFAPI_deflateSetDictionary
-#define deflateReset FPDFAPI_deflateReset
-#define deflatePrime FPDFAPI_deflatePrime
-#define deflateParams FPDFAPI_deflateParams
-#define deflateBound FPDFAPI_deflateBound
-#define deflateSetHeader FPDFAPI_deflateSetHeader
-#define deflateTune FPDFAPI_deflateTune
-#define deflate FPDFAPI_deflate
-#define deflateEnd FPDFAPI_deflateEnd
-#define deflateCopy FPDFAPI_deflateCopy
-#define inflateBackInit_ FPDFAPI_inflateBackInit_
-#define inflateBack FPDFAPI_inflateBack
-#define inflateBackEnd FPDFAPI_inflateBackEnd
-#define inflateReset FPDFAPI_inflateReset
-#define inflateInit2_ FPDFAPI_inflateInit2_
-#define inflateInit_ FPDFAPI_inflateInit_
-#define inflate FPDFAPI_inflate
-#define inflateEnd FPDFAPI_inflateEnd
-#define inflateSetDictionary FPDFAPI_inflateSetDictionary
-#define inflateSync FPDFAPI_inflateSync
-#define inflateSyncPoint FPDFAPI_inflateSyncPoint
-#define inflateCopy FPDFAPI_inflateCopy
-#define uncompress FPDFAPI_uncompress
-#define zlibVersion FPDFAPI_zlibVersion
-#define zlibCompileFlags FPDFAPI_zlibCompileFlags
-#define zError FPDFAPI_zError
-#define z_errmsg FPDFAPI_z_errmsg
-#define zcfree FPDFAPI_zcfree
-#define zcalloc FPDFAPI_zcalloc
-#define inflate_fast FPDFAPI_inflate_fast
-#define inflate_table FPDFAPI_inflate_table
-#define inflate_copyright FPDFAPI_inflate_copyright
-#define _length_code FPDFAPI_length_code
-#define _tr_flush_block FPDFAPI_tr_flush_block
-#define _dist_code FPDFAPI_dist_code
-#define _tr_stored_block FPDFAPI_tr_stored_block
-#define _tr_init FPDFAPI_tr_init
-#define _tr_align FPDFAPI_tr_align
-#define _tr_tally FPDFAPI_tr_tally
-#define adler32_combine FPDFAPI_adler32_combine
-#define inflatePrime FPDFAPI_inflatePrime
-#define inflateGetHeader FPDFAPI_inflateGetHeader
-#define crc32_combine FPDFAPI_crc32_combine
-#define inflateReset2 FPDFAPI_inflateReset2
-#define inflateUndermine FPDFAPI_inflateUndermine
-#define inflateMark FPDFAPI_inflateMark
-#define adler32_combine64 FPDFAPI_adler32_combine64
-
-#include "zconf.h"
-
-/* Sunliang.Liu 20100908 sync the config to the old revision. NO_GZIP */
-#define NO_GZIP /* XYQ */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.8"
-#define ZLIB_VERNUM 0x1280
-#define ZLIB_VER_MAJOR 1
-#define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 8
-#define ZLIB_VER_SUBREVISION 0
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed data.
- This version of the library supports only one compression method (deflation)
- but other algorithms will be added later and will have the same stream
- interface.
-
- Compression can be done in a single step if the buffers are large enough,
- or can be done by repeated calls of the compression function. In the latter
- case, the application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The compressed data format used by default by the in-memory functions is
- the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
- around a deflate stream, which is itself documented in RFC 1951.
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio using the functions that start
- with "gz". The gzip format is different from the zlib format. gzip is a
- gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
- This library can optionally read and write gzip streams in memory as well.
-
- The zlib format was designed to be compact and fast for use in memory
- and on communications channels. The gzip format was designed for single-
- file compression on file systems, has a larger header than zlib to maintain
- directory information, and uses a different, slower check method than zlib.
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never crash
- even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- z_const Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total number of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total number of bytes output so far */
-
- z_const char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
- gzip header information passed to and from zlib routines. See RFC 1952
- for more details on the meanings of these fields.
-*/
-typedef struct gz_header_s {
- int text; /* true if compressed data believed to be text */
- uLong time; /* modification time */
- int xflags; /* extra flags (not used when writing a gzip file) */
- int os; /* operating system */
- Bytef *extra; /* pointer to extra field or Z_NULL if none */
- uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
- uInt extra_max; /* space at extra (only when reading header) */
- Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
- uInt name_max; /* space at name (only when reading header) */
- Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
- uInt comm_max; /* space at comment (only when reading header) */
- int hcrc; /* true if there was or will be a header crc */
- int done; /* true when done reading gzip header (not used
- when writing a gzip file) */
-} gz_header;
-
-typedef gz_header FAR *gz_headerp;
-
-/*
- The application must update next_in and avail_in when avail_in has dropped
- to zero. It must update next_out and avail_out when avail_out has dropped
- to zero. The application must initialize zalloc, zfree and opaque before
- calling the init function. All other fields are set by the compression
- library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
-
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this if
- the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
- returned by zalloc for objects of exactly 65536 bytes *must* have their
- offset normalized to zero. The default allocation function provided by this
- library ensures this (see zutil.c). To reduce memory requirements and avoid
- any allocation of 64K objects, at the expense of compression ratio, compile
- the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or progress
- reports. After compression, total_in holds the total size of the
- uncompressed data and may be saved for use in the decompressor (particularly
- if the decompressor wants to decompress everything in a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1
-#define Z_SYNC_FLUSH 2
-#define Z_FULL_FLUSH 3
-#define Z_FINISH 4
-#define Z_BLOCK 5
-#define Z_TREES 6
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative values
- * are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_RLE 3
-#define Z_FIXED 4
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_TEXT 1
-#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
-
- /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is not
- compatible with the zlib.h header file used by the application. This check
- is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller. If
- zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
- allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at all
- (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION
- requests a default compromise between speed and compression (currently
- equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if level is not a valid compression level, or
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION). msg is set to null
- if there is no error message. deflateInit does not perform any compression:
- this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
- deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. deflate performs one or both of the
- following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications). Some
- output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming more
- output, and updating avail_in or avail_out accordingly; avail_out should
- never be zero before the call. The application can consume the compressed
- output when it wants, for example when the output buffer is full (avail_out
- == 0), or after each call of deflate(). If deflate returns Z_OK and with
- zero avail_out, it must be called again after making room in the output
- buffer because there might be more output pending.
-
- Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
- decide how much data to accumulate before producing output, in order to
- maximize compression.
-
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In
- particular avail_in is zero after the call if enough output space has been
- provided before the call.) Flushing may degrade compression for some
- compression algorithms and so it should be used only when necessary. This
- completes the current deflate block and follows it with an empty stored block
- that is three bits plus filler bits to the next byte, followed by four bytes
- (00 00 ff ff).
-
- If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
- output buffer, but the output is not aligned to a byte boundary. All of the
- input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
- This completes the current deflate block and follows it with an empty fixed
- codes block that is 10 bits long. This assures that enough bytes are output
- in order for the decompressor to finish the block before the empty fixed code
- block.
-
- If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
- for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
- seven bits of the current block are held to be written as the next byte after
- the next deflate block is completed. In this case, the decompressor may not
- be provided enough bits at this point in order to complete decompression of
- the data provided so far to the compressor. It may need to wait for the next
- block to be emitted. This is for advanced applications that need to control
- the emission of deflate blocks.
-
- If flush is set to Z_FULL_FLUSH, all output is flushed as with
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
- compression.
-
- If deflate returns with avail_out == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- avail_out), until the flush is complete (deflate returns with non-zero
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
- avail_out is greater than six to avoid repeated flush markers due to
- avail_out == 0 on return.
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there was
- enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the stream
- are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least the
- value returned by deflateBound (see below). Then deflate is guaranteed to
- return Z_STREAM_END. If not enough output space is provided, deflate will
- not return Z_STREAM_END, and it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
-
- deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect the
- compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any pending
- output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case, msg
- may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the
- exact value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller, or Z_STREAM_ERROR if the parameters are
- invalid, such as a null pointer to the structure. msg is set to null if
- there is no error message. inflateInit does not perform any decompression
- apart from possibly reading the zlib header if present: actual decompression
- will be done by inflate(). (So next_in and avail_in may be modified, but
- next_out and avail_out are unused and unchanged.) The current implementation
- of inflateInit() does not process any header information -- that is deferred
- until inflate() is called.
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
- inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. inflate performs one or both of the
- following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing will
- resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there is
- no more input data or no more space in the output buffer (see below about
- the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming more
- output, and updating the next_* and avail_* values accordingly. The
- application can consume the uncompressed output when it wants, for example
- when the output buffer is full (avail_out == 0), or after each call of
- inflate(). If inflate returns Z_OK and with zero avail_out, it must be
- called again after making room in the output buffer because there might be
- more output pending.
-
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
- Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much
- output as possible to the output buffer. Z_BLOCK requests that inflate()
- stop if and when it gets to the next deflate block boundary. When decoding
- the zlib or gzip format, this will cause inflate() to return immediately
- after the header and before the first block. When doing a raw inflate,
- inflate() will go ahead and process the first block, and will return when it
- gets to the end of that block, or when it runs out of data.
-
- The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
- number of unused bits in the last byte taken from strm->next_in, plus 64 if
- inflate() is currently decoding the last block in the deflate stream, plus
- 128 if inflate() returned immediately after decoding an end-of-block code or
- decoding the complete header up to just before the first byte of the deflate
- stream. The end-of-block will not be indicated until all of the uncompressed
- data from that block has been written to strm->next_out. The number of
- unused bits may in general be greater than seven, except when bit 7 of
- data_type is set, in which case the number of unused bits will be less than
- eight. data_type is set as noted here every time inflate() returns for all
- flush options, and so can be used to determine the amount of currently
- consumed input in bits.
-
- The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
- end of each deflate block header is reached, before any actual data in that
- block is decoded. This allows the caller to determine the length of the
- deflate block header for later use in random access within a deflate block.
- 256 is added to the value of strm->data_type when inflate() returns
- immediately after reaching the end of the deflate block header.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step (a
- single call of inflate), the parameter flush should be set to Z_FINISH. In
- this case all pending input is processed and all pending output is flushed;
- avail_out must be large enough to hold all of the uncompressed data for the
- operation to complete. (The size of the uncompressed data may have been
- saved by the compressor for this purpose.) The use of Z_FINISH is not
- required to perform an inflation in one step. However it may be used to
- inform inflate that a faster approach can be used for the single inflate()
- call. Z_FINISH also informs inflate to not maintain a sliding window if the
- stream completes, which reduces inflate's memory footprint. If the stream
- does not complete, either because not all of the stream is provided or not
- enough output space is provided, then a sliding window will be allocated and
- inflate() can be called again to continue the operation as if Z_NO_FLUSH had
- been used.
-
- In this implementation, inflate() always flushes as much output as
- possible to the output buffer, and always uses the faster approach on the
- first call. So the effects of the flush parameter in this implementation are
- on the return value of inflate() as noted below, when inflate() returns early
- when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
- memory for a sliding window when Z_FINISH is used.
-
- If a preset dictionary is needed after this call (see inflateSetDictionary
- below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
- chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
- strm->adler to the Adler-32 checksum of all output produced so far (that is,
- total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
- checksum is equal to that saved by the compressor and returns Z_STREAM_END
- only if the checksum is correct.
-
- inflate() can decompress and check either zlib-wrapped or gzip-wrapped
- deflate data. The header type is detected automatically, if requested when
- initializing with inflateInit2(). Any information contained in the gzip
- header is not retained, so applications that need that information should
- instead use raw inflate, see inflateInit2() below, or inflateBack() and
- perform their own processing of the gzip header and trailer. When processing
- gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
- producted so far. The CRC-32 is checked against the gzip trailer.
-
- inflate() returns Z_OK if some progress has been made (more input processed
- or more output produced), Z_STREAM_END if the end of the compressed data has
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
- inflate() can be called again with more input and more output space to
- continue decompressing. If Z_DATA_ERROR is returned, the application may
- then call inflateSync() to look for a good compression block if a partial
- recovery of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any pending
- output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by the
- caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library.
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- deflateInit is used instead.
-
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
- determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
-
- windowBits can also be greater than 15 for optional gzip encoding. Add
- 16 to windowBits to write a simple gzip header and trailer around the
- compressed data instead of a zlib wrapper. The gzip header will have no
- file name, no extra data, no comment, no modification time (set to zero), no
- header crc, and the operating system will be set to 255 (unknown). If a
- gzip stream is being written, strm->adler is a crc32 instead of an adler32.
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but is
- slow and reduces compression ratio; memLevel=9 uses maximum memory for
- optimal speed. The default value is 8. See zconf.h for total memory usage
- as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match), or Z_RLE to limit match distances to one (run-length
- encoding). Filtered data consists mostly of small values with a somewhat
- random distribution. In this case, the compression algorithm is tuned to
- compress them better. The effect of Z_FILTERED is to force more Huffman
- coding and less string matching; it is somewhat intermediate between
- Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as
- fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The
- strategy parameter only affects the compression ratio but not the
- correctness of the compressed output even if it is not set appropriately.
- Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
- decoder for special applications.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
- method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
- incompatible with the version assumed by the caller (ZLIB_VERSION). msg is
- set to null if there is no error message. deflateInit2 does not perform any
- compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. When using the zlib format, this
- function must be called immediately after deflateInit, deflateInit2 or
- deflateReset, and before any call of deflate. When doing raw deflate, this
- function must be called either before any call of deflate, or immediately
- after the completion of a deflate block, i.e. after all input has been
- consumed and all output has been delivered when using any of the flush
- options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
- compressor and decompressor must use exactly the same dictionary (see
- inflateSetDictionary).
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy; the data can then be compressed better than
- with the default empty dictionary.
-
- Depending on the size of the compression data structures selected by
- deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size
- provided in deflateInit or deflateInit2. Thus the strings most likely to be
- useful should be put at the end of the dictionary, not at the front. In
- addition, the current implementation of deflate will use at most the window
- size minus 262 bytes of the provided dictionary.
-
- Upon return of this function, strm->adler is set to the adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
- inconsistent (for example if deflate has already been called for this stream
- or if not at a block boundary for raw deflate). deflateSetDictionary does
- not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and can
- consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being Z_NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state. The
- stream will keep the same compression level and any other attributes that
- may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being Z_NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
-/*
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different strategy.
- If the compression level is changed, the input available so far is
- compressed with the old level (and may be flushed); the new level will take
- effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to be
- compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
- strm->avail_out was zero.
-*/
-
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
- int good_length,
- int max_lazy,
- int nice_length,
- int max_chain));
-/*
- Fine tune deflate's internal compression parameters. This should only be
- used by someone who understands the algorithm used by zlib's deflate for
- searching for the best matching string, and even then only by the most
- fanatic optimizer trying to squeeze out the last compressed bit for their
- specific input data. Read the deflate.c source code for the meaning of the
- max_lazy, good_length, nice_length, and max_chain parameters.
-
- deflateTune() can be called after deflateInit() or deflateInit2(), and
- returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
- */
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
- uLong sourceLen));
-/*
- deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit() or
- deflateInit2(), and after deflateSetHeader(), if used. This would be used
- to allocate an output buffer for deflation in a single pass, and so would be
- called before deflate(). If that first deflate() call is provided the
- sourceLen input bytes, an output buffer allocated to the size returned by
- deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
- to return Z_STREAM_END. Note that it is possible for the compressed size to
- be larger than the value returned by deflateBound() if flush options other
- than Z_FINISH or Z_NO_FLUSH are used.
-*/
-
-ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
- unsigned *pending,
- int *bits));
-/*
- deflatePending() returns the number of bytes and bits of output that have
- been generated, but not yet provided in the available output. The bytes not
- provided would be due to the available output space having being consumed.
- The number of bits of output not provided are between 0 and 7, where they
- await more bits to join them in order to fill out a full byte. If pending
- or bits are Z_NULL, then those values are not set.
-
- deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
- */
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- deflatePrime() inserts bits in the deflate output stream. The intent
- is that this function is used to start off the deflate output with the bits
- leftover from a previous deflate stream when appending to it. As such, this
- function can only be used for raw deflate, and must be used before the first
- deflate() call after a deflateInit2() or deflateReset(). bits must be less
- than or equal to 16, and that many of the least significant bits of value
- will be inserted in the output.
-
- deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
- room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
- source stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- deflateSetHeader() provides gzip header information for when a gzip
- stream is requested by deflateInit2(). deflateSetHeader() may be called
- after deflateInit2() or deflateReset() and before the first call of
- deflate(). The text, time, os, extra field, name, and comment information
- in the provided gz_header structure are written to the gzip header (xflag is
- ignored -- the extra flags are set according to the compression level). The
- caller must assure that, if not Z_NULL, name and comment are terminated with
- a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
- available there. If hcrc is true, a gzip header crc is included. Note that
- the current versions of the command-line version of gzip (up through version
- 1.3.x) do not support header crc's, and will report that it is a "multi-part
- gzip file" and give up.
-
- If deflateSetHeader is not used, the default gzip header has text false,
- the time set to zero, and os set to 255, with no extra, name, or comment
- fields. The gzip header is returned to the default state by deflateReset().
-
- deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with an extra parameter. The
- fields next_in, avail_in, zalloc, zfree and opaque must be initialized
- before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. windowBits must be greater than or equal to the windowBits value
- provided to deflateInit2() while compressing, or it must be equal to 15 if
- deflateInit2() was not used. If a compressed stream with a larger window
- size is given as input, inflate() will return with the error code
- Z_DATA_ERROR instead of trying to allocate a larger window.
-
- windowBits can also be zero to request that inflate use the window size in
- the zlib header of the compressed stream.
-
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
- determines the window size. inflate() will then process raw deflate data,
- not looking for a zlib or gzip header, not generating a check value, and not
- looking for any check values for comparison at the end of the stream. This
- is for use with other formats that use the deflate compressed data format
- such as zip. Those formats provide their own check values. If a custom
- format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
- the uncompressed data as is done in the zlib, gzip, and zip formats. For
- most applications, the zlib format should be used as is. Note that comments
- above on the use in deflateInit2() applies to the magnitude of windowBits.
-
- windowBits can also be greater than 15 for optional gzip decoding. Add
- 32 to windowBits to enable zlib and gzip decoding with automatic header
- detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
- crc32 instead of an adler32.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller, or Z_STREAM_ERROR if the parameters are
- invalid, such as a null pointer to the structure. msg is set to null if
- there is no error message. inflateInit2 does not perform any decompression
- apart from possibly reading the zlib header if present: actual decompression
- will be done by inflate(). (So next_in and avail_in may be modified, but
- next_out and avail_out are unused and unchanged.) The current implementation
- of inflateInit2() does not process any header information -- that is
- deferred until inflate() is called.
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate,
- if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by that call of inflate.
- The compressor and decompressor must use exactly the same dictionary (see
- deflateSetDictionary). For raw inflate, this function can be called at any
- time to set the dictionary. If the provided dictionary is smaller than the
- window and there is already data in the window, then the provided dictionary
- will amend what's there. The application must insure that the dictionary
- that was used for compression is provided.
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
- Bytef *dictionary,
- uInt *dictLength));
-/*
- Returns the sliding dictionary being maintained by inflate. dictLength is
- set to the number of bytes in the dictionary, and that many bytes are copied
- to dictionary. dictionary must have enough space, where 32768 bytes is
- always enough. If inflateGetDictionary() is called with dictionary equal to
- Z_NULL, then only the dictionary length is returned, and nothing is copied.
- Similary, if dictLength is Z_NULL, then it is not set.
-
- inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
- stream state is inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until a possible full flush point (see above
- for the description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync searches for a 00 00 FF FF pattern in the compressed data.
- All full flush points have this pattern, but not all occurrences of this
- pattern are full flush points.
-
- inflateSync returns Z_OK if a possible full flush point has been found,
- Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
- has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
- In the success case, the application may save the current current value of
- total_in which indicates where valid compressed data was found. In the
- error case, the application may repeatedly call inflateSync, providing more
- input each time, until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when randomly accessing a large stream. The
- first pass through the stream can periodically record the inflate state,
- allowing restarting inflate at those points when randomly accessing the
- stream.
-
- inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being Z_NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state. The
- stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being Z_NULL).
-*/
-
-ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
- int windowBits));
-/*
- This function is the same as inflateReset, but it also permits changing
- the wrap and window size requests. The windowBits parameter is interpreted
- the same as it is for inflateInit2.
-
- inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being Z_NULL), or if
- the windowBits parameter is invalid.
-*/
-
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- This function inserts bits in the inflate input stream. The intent is
- that this function is used to start inflating at a bit position in the
- middle of a byte. The provided bits will be used before any bytes are used
- from next_in. This function should only be used with raw inflate, and
- should be used before the first inflate() call after inflateInit2() or
- inflateReset(). bits must be less than or equal to 16, and that many of the
- least significant bits of value will be inserted in the input.
-
- If bits is negative, then the input stream bit buffer is emptied. Then
- inflatePrime() can be called again to put bits in the buffer. This is used
- to clear out bits leftover after feeding inflate a block description prior
- to feeding inflate codes.
-
- inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
-/*
- This function returns two values, one in the lower 16 bits of the return
- value, and the other in the remaining upper bits, obtained by shifting the
- return value down 16 bits. If the upper value is -1 and the lower value is
- zero, then inflate() is currently decoding information outside of a block.
- If the upper value is -1 and the lower value is non-zero, then inflate is in
- the middle of a stored block, with the lower value equaling the number of
- bytes from the input remaining to copy. If the upper value is not -1, then
- it is the number of bits back from the current bit position in the input of
- the code (literal or length/distance pair) currently being processed. In
- that case the lower value is the number of bytes already emitted for that
- code.
-
- A code is being processed if inflate is waiting for more input to complete
- decoding of the code, or if it has completed decoding but is waiting for
- more output space to write the literal or match data.
-
- inflateMark() is used to mark locations in the input data for random
- access, which may be at bit positions, and to note those cases where the
- output of a code may span boundaries of random access blocks. The current
- location in the input stream can be determined from avail_in and data_type
- as noted in the description for the Z_BLOCK flush parameter for inflate.
-
- inflateMark returns the value noted above or -1 << 16 if the provided
- source stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- inflateGetHeader() requests that gzip header information be stored in the
- provided gz_header structure. inflateGetHeader() may be called after
- inflateInit2() or inflateReset(), and before the first call of inflate().
- As inflate() processes the gzip stream, head->done is zero until the header
- is completed, at which time head->done is set to one. If a zlib stream is
- being decoded, then head->done is set to -1 to indicate that there will be
- no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
- used to force inflate() to return immediately after header processing is
- complete and before any actual data is decompressed.
-
- The text, time, xflags, and os fields are filled in with the gzip header
- contents. hcrc is set to true if there is a header CRC. (The header CRC
- was valid if done is set to one.) If extra is not Z_NULL, then extra_max
- contains the maximum number of bytes to write to extra. Once done is true,
- extra_len contains the actual extra field length, and extra contains the
- extra field, or that field truncated if extra_max is less than extra_len.
- If name is not Z_NULL, then up to name_max characters are written there,
- terminated with a zero unless the length is greater than name_max. If
- comment is not Z_NULL, then up to comm_max characters are written there,
- terminated with a zero unless the length is greater than comm_max. When any
- of extra, name, or comment are not Z_NULL and the respective field is not
- present in the header, then that field is set to Z_NULL to signal its
- absence. This allows the use of deflateSetHeader() with the returned
- structure to duplicate the header. However if those fields are set to
- allocated memory, then the application will need to save those pointers
- elsewhere so that they can be eventually freed.
-
- If inflateGetHeader is not used, then the header information is simply
- discarded. The header is always checked for validity, including the header
- CRC if present. inflateReset() will reset the process to discard the header
- information. The application would need to call inflateGetHeader() again to
- retrieve the header from the next gzip stream.
-
- inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
- unsigned char FAR *window));
-
- Initialize the internal stream state for decompression using inflateBack()
- calls. The fields zalloc, zfree and opaque in strm must be initialized
- before the call. If zalloc and zfree are Z_NULL, then the default library-
- derived memory allocation routines are used. windowBits is the base two
- logarithm of the window size, in the range 8..15. window is a caller
- supplied buffer of that size. Except for special applications where it is
- assured that deflate was used with small window sizes, windowBits must be 15
- and a 32K byte window must be supplied to be able to decompress general
- deflate streams.
-
- See inflateBack() for the usage of these routines.
-
- inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
- the parameters are invalid, Z_MEM_ERROR if the internal state could not be
- allocated, or Z_VERSION_ERROR if the version of the library does not match
- the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *,
- z_const unsigned char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
- in_func in, void FAR *in_desc,
- out_func out, void FAR *out_desc));
-/*
- inflateBack() does a raw inflate with a single call using a call-back
- interface for input and output. This is potentially more efficient than
- inflate() for file i/o applications, in that it avoids copying between the
- output and the sliding window by simply making the window itself the output
- buffer. inflate() can be faster on modern CPUs when used with large
- buffers. inflateBack() trusts the application to not change the output
- buffer passed by the output function, at least until inflateBack() returns.
-
- inflateBackInit() must be called first to allocate the internal state
- and to initialize the state with the user-provided window buffer.
- inflateBack() may then be used multiple times to inflate a complete, raw
- deflate stream with each call. inflateBackEnd() is then called to free the
- allocated state.
-
- A raw deflate stream is one with no zlib or gzip header or trailer.
- This routine would normally be used in a utility that reads zip or gzip
- files and writes out uncompressed files. The utility would decode the
- header and process the trailer on its own, hence this routine expects only
- the raw deflate stream to decompress. This is different from the normal
- behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
-
- inflateBack() uses two subroutines supplied by the caller that are then
- called by inflateBack() for input and output. inflateBack() calls those
- routines until it reads a complete deflate stream and writes out all of the
- uncompressed data, or until it encounters an error. The function's
- parameters and return types are defined above in the in_func and out_func
- typedefs. inflateBack() will call in(in_desc, &buf) which should return the
- number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
- inflateBackInit(), which is also the buffer that out() uses to write from.
- The length written by out() will be at most the window size. Any non-zero
- amount of input may be provided by in().
-
- For convenience, inflateBack() can be provided input on the first call by
- setting strm->next_in and strm->avail_in. If that input is exhausted, then
- in() will be called. Therefore strm->next_in must be initialized before
- calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
- immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
- must also be initialized, and then if strm->avail_in is not zero, input will
- initially be taken from strm->next_in[0 .. strm->avail_in - 1].
-
- The in_desc and out_desc parameters of inflateBack() is passed as the
- first parameter of in() and out() respectively when they are called. These
- descriptors can be optionally used to pass any information that the caller-
- supplied in() and out() functions need to do their job.
-
- On return, inflateBack() will set strm->next_in and strm->avail_in to
- pass back any unused input that was provided by the last in() call. The
- return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
- if in() or out() returned an error, Z_DATA_ERROR if there was a format error
- in the deflate stream (in which case strm->msg is set to indicate the nature
- of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
- In the case of Z_BUF_ERROR, an input or output error can be distinguished
- using strm->next_in which will be Z_NULL only if in() returned an error. If
- strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
- non-zero. (in() will always be called before out(), so strm->next_in is
- assured to be defined if out() returns non-zero.) Note that inflateBack()
- cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
-/*
- All memory allocated by inflateBackInit() is freed.
-
- inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
- state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
- Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
- 1.0: size of uInt
- 3.2: size of uLong
- 5.4: size of voidpf (pointer)
- 7.6: size of z_off_t
-
- Compiler, assembler, and debug options:
- 8: DEBUG
- 9: ASMV or ASMINF -- use ASM code
- 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
- 11: 0 (reserved)
-
- One-time table building (smaller code, but not thread-safe if true):
- 12: BUILDFIXED -- build static block decoding tables when needed
- 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
- 14,15: 0 (reserved)
-
- Library content (indicates missing functionality):
- 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
- deflate code when not needed)
- 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
- and decode gzip streams (to avoid linking crc code)
- 18-19: 0 (reserved)
-
- Operation variations (changes in library functionality):
- 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
- 21: FASTEST -- deflate algorithm with only one, lowest compression level
- 22,23: 0 (reserved)
-
- The sprintf variant used by gzprintf (zero is best):
- 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
- 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
- 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
- Remainder:
- 27-31: 0 (reserved)
- */
-
-#ifndef Z_SOLO
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the basic
- stream-oriented functions. To simplify the interface, some default options
- are assumed (compression level and memory usage, standard memory allocation
- functions). The source code of these utility functions can be modified if
- you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total size
- of the destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int level));
-/*
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
- compressBound() returns an upper bound on the compressed size after
- compress() or compress2() on sourceLen bytes. It would be used before a
- compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total size
- of the destination buffer, which must be large enough to hold the entire
- uncompressed data. (The size of the uncompressed data must have been saved
- previously by the compressor and transmitted to the decompressor by some
- mechanism outside the scope of this compression library.) Upon exit, destLen
- is the actual size of the uncompressed buffer.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
- the case where there is not enough room, uncompress() will fill the output
- buffer with the uncompressed data up to that point.
-*/
-
- /* gzip file access functions */
-
-/*
- This library supports reading and writing files in gzip (.gz) format with
- an interface similar to that of stdio, using the functions that start with
- "gz". The gzip format is different from the zlib format. gzip is a gzip
- wrapper, documented in RFC 1952, wrapped around a deflate stream.
-*/
-
-typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
-
-/*
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
-
- Opens a gzip (.gz) file for reading or writing. The mode parameter is as
- in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
- a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
- compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
- for fixed code compression as in "wb9F". (See the description of
- deflateInit2 for more information about the strategy parameter.) 'T' will
- request transparent writing or appending with no compression and not using
- the gzip format.
-
- "a" can be used instead of "w" to request that the gzip stream that will
- be written be appended to the file. "+" will result in an error, since
- reading and writing to the same gzip file is not supported. The addition of
- "x" when writing will create the file exclusively, which fails if the file
- already exists. On systems that support it, the addition of "e" when
- reading or writing will set the flag to close the file on an execve() call.
-
- These functions, as well as gzip, will read and decode a sequence of gzip
- streams in a file. The append function of gzopen() can be used to create
- such a file. (Also see gzflush() for another way to do this.) When
- appending, gzopen does not test whether the file begins with a gzip stream,
- nor does it look for the end of the gzip streams to begin appending. gzopen
- will simply append a gzip stream to the existing file.
-
- gzopen can be used to read a file which is not in gzip format; in this
- case gzread will directly read from the file without decompression. When
- reading, this will be detected automatically by looking for the magic two-
- byte gzip header.
-
- gzopen returns NULL if the file could not be opened, if there was
- insufficient memory to allocate the gzFile state, or if an invalid mode was
- specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
- errno can be checked to determine if the reason gzopen failed was that the
- file could not be opened.
-*/
-
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
-/*
- gzdopen associates a gzFile with the file descriptor fd. File descriptors
- are obtained from calls like open, dup, creat, pipe or fileno (if the file
- has been previously opened with fopen). The mode parameter is as in gzopen.
-
- The next call of gzclose on the returned gzFile will also close the file
- descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
- fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
- mode);. The duplicated descriptor should be saved to avoid a leak, since
- gzdopen does not close fd if it fails. If you are using fileno() to get the
- file descriptor from a FILE *, then you will have to use dup() to avoid
- double-close()ing the file descriptor. Both gzclose() and fclose() will
- close the associated file descriptor, so they need to have different file
- descriptors.
-
- gzdopen returns NULL if there was insufficient memory to allocate the
- gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
- provided, or '+' was provided), or if fd is -1. The file descriptor is not
- used until the next gz* read, write, seek, or close operation, so gzdopen
- will not detect if fd is invalid (unless fd is -1).
-*/
-
-ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
-/*
- Set the internal buffer size used by this library's functions. The
- default buffer size is 8192 bytes. This function must be called after
- gzopen() or gzdopen(), and before any other calls that read or write the
- file. The buffer memory allocation is always deferred to the first read or
- write. Two buffers are allocated, either both of the specified size when
- writing, or one of the specified size and the other twice that size when
- reading. A larger buffer size of, for example, 64K or 128K bytes will
- noticeably increase the speed of decompression (reading).
-
- The new buffer size also affects the maximum length for gzprintf().
-
- gzbuffer() returns 0 on success, or -1 on failure, such as being called
- too late.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
- Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
-
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
-*/
-
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file. If
- the input file is not in gzip format, gzread copies the given number of
- bytes into the buffer directly from the file.
-
- After reaching the end of a gzip stream in the input, gzread will continue
- to read, looking for another gzip stream. Any number of gzip streams may be
- concatenated in the input file, and will all be decompressed by gzread().
- If something other than a gzip stream is encountered after a gzip stream,
- that remaining trailing garbage is ignored (and no error is returned).
-
- gzread can be used to read a gzip file that is being concurrently written.
- Upon reaching the end of the input, gzread will return with the available
- data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
- gzclearerr can be used to clear the end of file indicator in order to permit
- gzread to be tried again. Z_OK indicates that a gzip stream was completed
- on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
- middle of a gzip stream. Note that gzread does not return -1 in the event
- of an incomplete gzip stream. This error is deferred until gzclose(), which
- will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
- stream. Alternatively, gzerror can be used before gzclose to detect this
- case.
-
- gzread returns the number of uncompressed bytes actually read, less than
- len for end of file, or -1 for error.
-*/
-
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- voidpc buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes written or 0 in case of
- error.
-*/
-
-ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
-/*
- Converts, formats, and writes the arguments to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written, or 0 in case of error. The number of
- uncompressed bytes written is limited to 8191, or one less than the buffer
- size given to gzbuffer(). The caller should assure that this limit is not
- exceeded. If it is exceeded, then gzprintf() will return an error (0) with
- nothing written. In this case, there may also be a buffer overflow with
- unpredictable consequences, which is possible only if zlib was compiled with
- the insecure functions sprintf() or vsprintf() because the secure snprintf()
- or vsnprintf() functions were not available. This can be determined using
- zlibCompileFlags().
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
-
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
- Reads bytes from the compressed file until len-1 characters are read, or a
- newline character is read and transferred to buf, or an end-of-file
- condition is encountered. If any characters are read or if len == 1, the
- string is terminated with a null character. If no characters are read due
- to an end-of-file or len < 1, then the buffer is left untouched.
-
- gzgets returns buf which is a null-terminated string, or it returns NULL
- for end-of-file or in case of error. If there was an error, the contents at
- buf are indeterminate.
-*/
-
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
-/*
- Writes c, converted to an unsigned char, into the compressed file. gzputc
- returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
-/*
- Reads one byte from the compressed file. gzgetc returns this byte or -1
- in case of end of file or error. This is implemented as a macro for speed.
- As such, it does not do all of the checking the other functions do. I.e.
- it does not check to see if file is NULL, nor whether the structure file
- points to has been clobbered or not.
-*/
-
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
-/*
- Push one character back onto the stream to be read as the first character
- on the next read. At least one character of push-back is allowed.
- gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
- fail if c is -1, and may fail if a character has been pushed but not read
- yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
- output buffer size of pushed characters is allowed. (See gzbuffer above.)
- The pushed character will be discarded if the stream is repositioned with
- gzseek() or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter flush
- is as in the deflate() function. The return value is the zlib error number
- (see function gzerror below). gzflush is only permitted when writing.
-
- If the flush parameter is Z_FINISH, the remaining data is written and the
- gzip stream is completed in the output. If gzwrite() is called again, a new
- gzip stream will be started in the output. gzread() is able to read such
- concatented gzip streams.
-
- gzflush should be called only when strictly necessary because it will
- degrade compression if called too often.
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
-
- Sets the starting position for the next gzread or gzwrite on the given
- compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
-
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported; gzseek then compresses a sequence of zeroes up to the new
- starting position.
-
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
-/*
- Rewinds the given file. This function is supported only for reading.
-
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
-
- Returns the starting position for the next gzread or gzwrite on the given
- compressed file. This position represents a number of bytes in the
- uncompressed data stream, and is zero when starting, even if appending or
- reading a gzip stream from the middle of a file using gzdopen().
-
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
-
- Returns the current offset in the file being read or written. This offset
- includes the count of bytes that precede the gzip stream, for example when
- appending or when using gzdopen() for reading. When reading, the offset
- does not include as yet unused buffered input. This information can be used
- for a progress indicator. On error, gzoffset() returns -1.
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
- Returns true (1) if the end-of-file indicator has been set while reading,
- false (0) otherwise. Note that the end-of-file indicator is set only if the
- read tried to go past the end of the input, but came up short. Therefore,
- just like feof(), gzeof() may return false even if there is no more data to
- read, in the event that the last read request was for the exact number of
- bytes remaining in the input file. This will happen if the input file size
- is an exact multiple of the buffer size.
-
- If gzeof() returns true, then the read functions will return no more data,
- unless the end-of-file indicator is reset by gzclearerr() and the input file
- has grown since the previous end of file was detected.
-*/
-
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
-/*
- Returns true (1) if file is being copied directly while reading, or false
- (0) if file is a gzip stream being decompressed.
-
- If the input file is empty, gzdirect() will return true, since the input
- does not contain a gzip stream.
-
- If gzdirect() is used immediately after gzopen() or gzdopen() it will
- cause buffers to be allocated to allow reading the file to determine if it
- is a gzip file. Therefore if gzbuffer() is used, it should be called before
- gzdirect().
-
- When writing, gzdirect() returns true (1) if transparent writing was
- requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
- gzdirect() is not needed when writing. Transparent writing must be
- explicitly requested, so the application already knows the answer. When
- linking statically, using gzdirect() will include all of the zlib code for
- gzip file reading and decompression, which may not be desired.)
-*/
-
-ZEXTERN int ZEXPORT gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file and
- deallocates the (de)compression state. Note that once file is closed, you
- cannot call gzerror with file, since its structures have been deallocated.
- gzclose must not be called more than once on the same file, just as free
- must not be called more than once on the same allocation.
-
- gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
- file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
- last read ended in the middle of a gzip stream, or Z_OK on success.
-*/
-
-ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
-ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
-/*
- Same as gzclose(), but gzclose_r() is only for use when reading, and
- gzclose_w() is only for use when writing or appending. The advantage to
- using these instead of gzclose() is that they avoid linking in zlib
- compression or decompression code that is not used when only reading or only
- writing respectively. If gzclose() is used, then both compression and
- decompression code will be included the application when linking to a static
- zlib library.
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the given
- compressed file. errnum is set to zlib error number. If an error occurred
- in the file system and not in the compression library, errnum is set to
- Z_ERRNO and the application may consult errno to get the exact error code.
-
- The application must not modify the returned string. Future calls to
- this function may invalidate the previously returned string. If file is
- closed, then the string previously returned by gzerror will no longer be
- available.
-
- gzerror() should be used to distinguish errors from end-of-file for those
- functions above that do not distinguish those cases in their return values.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
- Clears the error and end-of-file flags for file. This is analogous to the
- clearerr() function in stdio. This is useful for continuing to read a gzip
- file that is being written concurrently.
-*/
-
-#endif /* !Z_SOLO */
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the compression
- library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is Z_NULL, this function returns the
- required initial value for the checksum.
-
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster.
-
- Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-/*
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
- z_off_t len2));
-
- Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
- and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
- each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
- seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
- that the z_off_t type (like off_t) is a signed integer. If len2 is
- negative, the result has no meaning or utility.
-*/
-
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
-/*
- Update a running CRC-32 with the bytes buf[0..len-1] and return the
- updated CRC-32. If buf is Z_NULL, this function returns the required
- initial value for the crc. Pre- and post-conditioning (one's complement) is
- performed within this function so it shouldn't be done by the application.
-
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-/*
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-
- Combine two CRC-32 check values into one. For two sequences of bytes,
- seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
- calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
- check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
- len2.
-*/
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
- (int)sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, (int)sizeof(z_stream))
-
-#ifndef Z_SOLO
-
-/* gzgetc() macro and its supporting function and exposed data structure. Note
- * that the real internal state is much larger than the exposed structure.
- * This abbreviated structure exposes just enough for the gzgetc() macro. The
- * user should not mess with these exposed elements, since their names or
- * behavior could change in the future, perhaps even capriciously. They can
- * only be used by the gzgetc() macro. You have been warned.
- */
-struct gzFile_s {
- unsigned have;
- unsigned char *next;
- z_off64_t pos;
-};
-ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
-#ifdef Z_PREFIX_SET
-# undef z_gzgetc
-# define z_gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
-#else
-# define gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
-#endif
-
-/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
- * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
- * both are true, the application gets the *64 functions, and the regular
- * functions are changed to 64 bits) -- in case these are set on systems
- * without large file support, _LFS64_LARGEFILE must also be true
- */
-#ifdef Z_LARGE64
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
- ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
- ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
- ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
-#endif
-
-#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
-# ifdef Z_PREFIX_SET
-# define z_gzopen z_gzopen64
-# define z_gzseek z_gzseek64
-# define z_gztell z_gztell64
-# define z_gzoffset z_gzoffset64
-# define z_adler32_combine z_adler32_combine64
-# define z_crc32_combine z_crc32_combine64
-# else
-# define gzopen gzopen64
-# define gzseek gzseek64
-# define gztell gztell64
-# define gzoffset gzoffset64
-# define adler32_combine adler32_combine64
-# define crc32_combine crc32_combine64
-# endif
-# ifndef Z_LARGE64
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
- ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int));
- ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile));
- ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off64_t));
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t));
-# endif
-#else
- ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
- ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
- ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
- ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
- ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
- ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
-#endif
-
-#else /* Z_SOLO */
-
- ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
- ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
-
-#endif /* !Z_SOLO */
-
-/* hack for buggy compilers */
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;};
-#endif
-
-/* undocumented functions */
-ZEXTERN const char * ZEXPORT zError OF((int));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
-ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
-ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
-ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
-ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
-#if defined(_WIN32) && !defined(Z_SOLO)
-ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
- const char *mode));
-#endif
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
- const char *format,
- va_list va));
-# endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+ version 1.2.8, April 28th, 2013
+
+ Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ jloup@gzip.org madler@alumni.caltech.edu
+
+
+ The data format used by the zlib library is described by RFCs (Request for
+ Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
+ (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
+*/
+
+#ifndef ZLIB_H
+#define ZLIB_H
+
+#define deflate_copyright FPDFAPI_deflate_copyright
+#define adler32 FPDFAPI_adler32
+#define compress2 FPDFAPI_compress2
+#define compress FPDFAPI_compress
+#define compressBound FPDFAPI_compressBound
+#define get_crc_table FPDFAPI_get_crc_table
+#define crc32 FPDFAPI_crc32
+#define deflateInit_ FPDFAPI_deflateInit_
+#define deflateInit2_ FPDFAPI_deflateInit2_
+#define deflateSetDictionary FPDFAPI_deflateSetDictionary
+#define deflateReset FPDFAPI_deflateReset
+#define deflatePrime FPDFAPI_deflatePrime
+#define deflateParams FPDFAPI_deflateParams
+#define deflateBound FPDFAPI_deflateBound
+#define deflateSetHeader FPDFAPI_deflateSetHeader
+#define deflateTune FPDFAPI_deflateTune
+#define deflate FPDFAPI_deflate
+#define deflateEnd FPDFAPI_deflateEnd
+#define deflateCopy FPDFAPI_deflateCopy
+#define inflateBackInit_ FPDFAPI_inflateBackInit_
+#define inflateBack FPDFAPI_inflateBack
+#define inflateBackEnd FPDFAPI_inflateBackEnd
+#define inflateReset FPDFAPI_inflateReset
+#define inflateInit2_ FPDFAPI_inflateInit2_
+#define inflateInit_ FPDFAPI_inflateInit_
+#define inflate FPDFAPI_inflate
+#define inflateEnd FPDFAPI_inflateEnd
+#define inflateSetDictionary FPDFAPI_inflateSetDictionary
+#define inflateSync FPDFAPI_inflateSync
+#define inflateSyncPoint FPDFAPI_inflateSyncPoint
+#define inflateCopy FPDFAPI_inflateCopy
+#define uncompress FPDFAPI_uncompress
+#define zlibVersion FPDFAPI_zlibVersion
+#define zlibCompileFlags FPDFAPI_zlibCompileFlags
+#define zError FPDFAPI_zError
+#define z_errmsg FPDFAPI_z_errmsg
+#define zcfree FPDFAPI_zcfree
+#define zcalloc FPDFAPI_zcalloc
+#define inflate_fast FPDFAPI_inflate_fast
+#define inflate_table FPDFAPI_inflate_table
+#define inflate_copyright FPDFAPI_inflate_copyright
+#define _length_code FPDFAPI_length_code
+#define _tr_flush_block FPDFAPI_tr_flush_block
+#define _dist_code FPDFAPI_dist_code
+#define _tr_stored_block FPDFAPI_tr_stored_block
+#define _tr_init FPDFAPI_tr_init
+#define _tr_align FPDFAPI_tr_align
+#define _tr_tally FPDFAPI_tr_tally
+#define adler32_combine FPDFAPI_adler32_combine
+#define inflatePrime FPDFAPI_inflatePrime
+#define inflateGetHeader FPDFAPI_inflateGetHeader
+#define crc32_combine FPDFAPI_crc32_combine
+#define inflateReset2 FPDFAPI_inflateReset2
+#define inflateUndermine FPDFAPI_inflateUndermine
+#define inflateMark FPDFAPI_inflateMark
+#define adler32_combine64 FPDFAPI_adler32_combine64
+
+#include "zconf.h"
+
+/* Sunliang.Liu 20100908 sync the config to the old revision. NO_GZIP */
+#define NO_GZIP /* XYQ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ZLIB_VERSION "1.2.8"
+#define ZLIB_VERNUM 0x1280
+#define ZLIB_VER_MAJOR 1
+#define ZLIB_VER_MINOR 2
+#define ZLIB_VER_REVISION 8
+#define ZLIB_VER_SUBREVISION 0
+
+/*
+ The 'zlib' compression library provides in-memory compression and
+ decompression functions, including integrity checks of the uncompressed data.
+ This version of the library supports only one compression method (deflation)
+ but other algorithms will be added later and will have the same stream
+ interface.
+
+ Compression can be done in a single step if the buffers are large enough,
+ or can be done by repeated calls of the compression function. In the latter
+ case, the application must provide more input and/or consume the output
+ (providing more output space) before each call.
+
+ The compressed data format used by default by the in-memory functions is
+ the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
+ around a deflate stream, which is itself documented in RFC 1951.
+
+ The library also supports reading and writing files in gzip (.gz) format
+ with an interface similar to that of stdio using the functions that start
+ with "gz". The gzip format is different from the zlib format. gzip is a
+ gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+
+ This library can optionally read and write gzip streams in memory as well.
+
+ The zlib format was designed to be compact and fast for use in memory
+ and on communications channels. The gzip format was designed for single-
+ file compression on file systems, has a larger header than zlib to maintain
+ directory information, and uses a different, slower check method than zlib.
+
+ The library does not install any signal handler. The decoder checks
+ the consistency of the compressed data, so the library should never crash
+ even in case of corrupted input.
+*/
+
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void (*free_func) OF((voidpf opaque, voidpf address));
+
+struct internal_state;
+
+typedef struct z_stream_s {
+ z_const Bytef *next_in; /* next input byte */
+ uInt avail_in; /* number of bytes available at next_in */
+ uLong total_in; /* total number of input bytes read so far */
+
+ Bytef *next_out; /* next output byte should be put there */
+ uInt avail_out; /* remaining free space at next_out */
+ uLong total_out; /* total number of bytes output so far */
+
+ z_const char *msg; /* last error message, NULL if no error */
+ struct internal_state FAR *state; /* not visible by applications */
+
+ alloc_func zalloc; /* used to allocate the internal state */
+ free_func zfree; /* used to free the internal state */
+ voidpf opaque; /* private data object passed to zalloc and zfree */
+
+ int data_type; /* best guess about the data type: binary or text */
+ uLong adler; /* adler32 value of the uncompressed data */
+ uLong reserved; /* reserved for future use */
+} z_stream;
+
+typedef z_stream FAR *z_streamp;
+
+/*
+ gzip header information passed to and from zlib routines. See RFC 1952
+ for more details on the meanings of these fields.
+*/
+typedef struct gz_header_s {
+ int text; /* true if compressed data believed to be text */
+ uLong time; /* modification time */
+ int xflags; /* extra flags (not used when writing a gzip file) */
+ int os; /* operating system */
+ Bytef *extra; /* pointer to extra field or Z_NULL if none */
+ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
+ uInt extra_max; /* space at extra (only when reading header) */
+ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
+ uInt name_max; /* space at name (only when reading header) */
+ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
+ uInt comm_max; /* space at comment (only when reading header) */
+ int hcrc; /* true if there was or will be a header crc */
+ int done; /* true when done reading gzip header (not used
+ when writing a gzip file) */
+} gz_header;
+
+typedef gz_header FAR *gz_headerp;
+
+/*
+ The application must update next_in and avail_in when avail_in has dropped
+ to zero. It must update next_out and avail_out when avail_out has dropped
+ to zero. The application must initialize zalloc, zfree and opaque before
+ calling the init function. All other fields are set by the compression
+ library and must not be updated by the application.
+
+ The opaque value provided by the application will be passed as the first
+ parameter for calls of zalloc and zfree. This can be useful for custom
+ memory management. The compression library attaches no meaning to the
+ opaque value.
+
+ zalloc must return Z_NULL if there is not enough memory for the object.
+ If zlib is used in a multi-threaded application, zalloc and zfree must be
+ thread safe.
+
+ On 16-bit systems, the functions zalloc and zfree must be able to allocate
+ exactly 65536 bytes, but will not be required to allocate more than this if
+ the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
+ returned by zalloc for objects of exactly 65536 bytes *must* have their
+ offset normalized to zero. The default allocation function provided by this
+ library ensures this (see zutil.c). To reduce memory requirements and avoid
+ any allocation of 64K objects, at the expense of compression ratio, compile
+ the library with -DMAX_WBITS=14 (see zconf.h).
+
+ The fields total_in and total_out can be used for statistics or progress
+ reports. After compression, total_in holds the total size of the
+ uncompressed data and may be saved for use in the decompressor (particularly
+ if the decompressor wants to decompress everything in a single step).
+*/
+
+ /* constants */
+
+#define Z_NO_FLUSH 0
+#define Z_PARTIAL_FLUSH 1
+#define Z_SYNC_FLUSH 2
+#define Z_FULL_FLUSH 3
+#define Z_FINISH 4
+#define Z_BLOCK 5
+#define Z_TREES 6
+/* Allowed flush values; see deflate() and inflate() below for details */
+
+#define Z_OK 0
+#define Z_STREAM_END 1
+#define Z_NEED_DICT 2
+#define Z_ERRNO (-1)
+#define Z_STREAM_ERROR (-2)
+#define Z_DATA_ERROR (-3)
+#define Z_MEM_ERROR (-4)
+#define Z_BUF_ERROR (-5)
+#define Z_VERSION_ERROR (-6)
+/* Return codes for the compression/decompression functions. Negative values
+ * are errors, positive values are used for special but normal events.
+ */
+
+#define Z_NO_COMPRESSION 0
+#define Z_BEST_SPEED 1
+#define Z_BEST_COMPRESSION 9
+#define Z_DEFAULT_COMPRESSION (-1)
+/* compression levels */
+
+#define Z_FILTERED 1
+#define Z_HUFFMAN_ONLY 2
+#define Z_RLE 3
+#define Z_FIXED 4
+#define Z_DEFAULT_STRATEGY 0
+/* compression strategy; see deflateInit2() below for details */
+
+#define Z_BINARY 0
+#define Z_TEXT 1
+#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
+#define Z_UNKNOWN 2
+/* Possible values of the data_type field (though see inflate()) */
+
+#define Z_DEFLATED 8
+/* The deflate compression method (the only one supported in this version) */
+
+#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
+
+#define zlib_version zlibVersion()
+/* for compatibility with versions < 1.0.2 */
+
+
+ /* basic functions */
+
+ZEXTERN const char * ZEXPORT zlibVersion OF((void));
+/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
+ If the first character differs, the library code actually used is not
+ compatible with the zlib.h header file used by the application. This check
+ is automatically made by deflateInit and inflateInit.
+ */
+
+/*
+ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+
+ Initializes the internal stream state for compression. The fields
+ zalloc, zfree and opaque must be initialized before by the caller. If
+ zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
+ allocation functions.
+
+ The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
+ 1 gives best speed, 9 gives best compression, 0 gives no compression at all
+ (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION
+ requests a default compromise between speed and compression (currently
+ equivalent to level 6).
+
+ deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if level is not a valid compression level, or
+ Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
+ with the version assumed by the caller (ZLIB_VERSION). msg is set to null
+ if there is no error message. deflateInit does not perform any compression:
+ this will be done by deflate().
+*/
+
+
+ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+/*
+ deflate compresses as much data as possible, and stops when the input
+ buffer becomes empty or the output buffer becomes full. It may introduce
+ some output latency (reading input without producing any output) except when
+ forced to flush.
+
+ The detailed semantics are as follows. deflate performs one or both of the
+ following actions:
+
+ - Compress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in and avail_in are updated and
+ processing will resume at this point for the next call of deflate().
+
+ - Provide more output starting at next_out and update next_out and avail_out
+ accordingly. This action is forced if the parameter flush is non zero.
+ Forcing flush frequently degrades the compression ratio, so this parameter
+ should be set only when necessary (in interactive applications). Some
+ output may be provided even if flush is not set.
+
+ Before the call of deflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating avail_in or avail_out accordingly; avail_out should
+ never be zero before the call. The application can consume the compressed
+ output when it wants, for example when the output buffer is full (avail_out
+ == 0), or after each call of deflate(). If deflate returns Z_OK and with
+ zero avail_out, it must be called again after making room in the output
+ buffer because there might be more output pending.
+
+ Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
+ decide how much data to accumulate before producing output, in order to
+ maximize compression.
+
+ If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
+ flushed to the output buffer and the output is aligned on a byte boundary, so
+ that the decompressor can get all input data available so far. (In
+ particular avail_in is zero after the call if enough output space has been
+ provided before the call.) Flushing may degrade compression for some
+ compression algorithms and so it should be used only when necessary. This
+ completes the current deflate block and follows it with an empty stored block
+ that is three bits plus filler bits to the next byte, followed by four bytes
+ (00 00 ff ff).
+
+ If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
+ output buffer, but the output is not aligned to a byte boundary. All of the
+ input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
+ This completes the current deflate block and follows it with an empty fixed
+ codes block that is 10 bits long. This assures that enough bytes are output
+ in order for the decompressor to finish the block before the empty fixed code
+ block.
+
+ If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
+ for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
+ seven bits of the current block are held to be written as the next byte after
+ the next deflate block is completed. In this case, the decompressor may not
+ be provided enough bits at this point in order to complete decompression of
+ the data provided so far to the compressor. It may need to wait for the next
+ block to be emitted. This is for advanced applications that need to control
+ the emission of deflate blocks.
+
+ If flush is set to Z_FULL_FLUSH, all output is flushed as with
+ Z_SYNC_FLUSH, and the compression state is reset so that decompression can
+ restart from this point if previous compressed data has been damaged or if
+ random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
+ compression.
+
+ If deflate returns with avail_out == 0, this function must be called again
+ with the same value of the flush parameter and more output space (updated
+ avail_out), until the flush is complete (deflate returns with non-zero
+ avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
+ avail_out is greater than six to avoid repeated flush markers due to
+ avail_out == 0 on return.
+
+ If the parameter flush is set to Z_FINISH, pending input is processed,
+ pending output is flushed and deflate returns with Z_STREAM_END if there was
+ enough output space; if deflate returns with Z_OK, this function must be
+ called again with Z_FINISH and more output space (updated avail_out) but no
+ more input data, until it returns with Z_STREAM_END or an error. After
+ deflate has returned Z_STREAM_END, the only possible operations on the stream
+ are deflateReset or deflateEnd.
+
+ Z_FINISH can be used immediately after deflateInit if all the compression
+ is to be done in a single step. In this case, avail_out must be at least the
+ value returned by deflateBound (see below). Then deflate is guaranteed to
+ return Z_STREAM_END. If not enough output space is provided, deflate will
+ not return Z_STREAM_END, and it must be called again as described above.
+
+ deflate() sets strm->adler to the adler32 checksum of all input read
+ so far (that is, total_in bytes).
+
+ deflate() may update strm->data_type if it can make a good guess about
+ the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
+ binary. This field is only for information purposes and does not affect the
+ compression algorithm in any manner.
+
+ deflate() returns Z_OK if some progress has been made (more input
+ processed or more output produced), Z_STREAM_END if all input has been
+ consumed and all output has been produced (only when flush is set to
+ Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
+ if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
+ (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
+ fatal, and deflate() can be called again with more input and more output
+ space to continue compressing.
+*/
+
+
+ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any pending
+ output.
+
+ deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
+ stream state was inconsistent, Z_DATA_ERROR if the stream was freed
+ prematurely (some input or output was discarded). In the error case, msg
+ may be set but then points to a static string (which must not be
+ deallocated).
+*/
+
+
+/*
+ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+
+ Initializes the internal stream state for decompression. The fields
+ next_in, avail_in, zalloc, zfree and opaque must be initialized before by
+ the caller. If next_in is not Z_NULL and avail_in is large enough (the
+ exact value depends on the compression method), inflateInit determines the
+ compression method from the zlib header and allocates all data structures
+ accordingly; otherwise the allocation will be deferred to the first call of
+ inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
+ use default allocation functions.
+
+ inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit does not perform any decompression
+ apart from possibly reading the zlib header if present: actual decompression
+ will be done by inflate(). (So next_in and avail_in may be modified, but
+ next_out and avail_out are unused and unchanged.) The current implementation
+ of inflateInit() does not process any header information -- that is deferred
+ until inflate() is called.
+*/
+
+
+ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
+/*
+ inflate decompresses as much data as possible, and stops when the input
+ buffer becomes empty or the output buffer becomes full. It may introduce
+ some output latency (reading input without producing any output) except when
+ forced to flush.
+
+ The detailed semantics are as follows. inflate performs one or both of the
+ following actions:
+
+ - Decompress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in is updated and processing will
+ resume at this point for the next call of inflate().
+
+ - Provide more output starting at next_out and update next_out and avail_out
+ accordingly. inflate() provides as much output as possible, until there is
+ no more input data or no more space in the output buffer (see below about
+ the flush parameter).
+
+ Before the call of inflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating the next_* and avail_* values accordingly. The
+ application can consume the uncompressed output when it wants, for example
+ when the output buffer is full (avail_out == 0), or after each call of
+ inflate(). If inflate returns Z_OK and with zero avail_out, it must be
+ called again after making room in the output buffer because there might be
+ more output pending.
+
+ The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
+ Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much
+ output as possible to the output buffer. Z_BLOCK requests that inflate()
+ stop if and when it gets to the next deflate block boundary. When decoding
+ the zlib or gzip format, this will cause inflate() to return immediately
+ after the header and before the first block. When doing a raw inflate,
+ inflate() will go ahead and process the first block, and will return when it
+ gets to the end of that block, or when it runs out of data.
+
+ The Z_BLOCK option assists in appending to or combining deflate streams.
+ Also to assist in this, on return inflate() will set strm->data_type to the
+ number of unused bits in the last byte taken from strm->next_in, plus 64 if
+ inflate() is currently decoding the last block in the deflate stream, plus
+ 128 if inflate() returned immediately after decoding an end-of-block code or
+ decoding the complete header up to just before the first byte of the deflate
+ stream. The end-of-block will not be indicated until all of the uncompressed
+ data from that block has been written to strm->next_out. The number of
+ unused bits may in general be greater than seven, except when bit 7 of
+ data_type is set, in which case the number of unused bits will be less than
+ eight. data_type is set as noted here every time inflate() returns for all
+ flush options, and so can be used to determine the amount of currently
+ consumed input in bits.
+
+ The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
+ end of each deflate block header is reached, before any actual data in that
+ block is decoded. This allows the caller to determine the length of the
+ deflate block header for later use in random access within a deflate block.
+ 256 is added to the value of strm->data_type when inflate() returns
+ immediately after reaching the end of the deflate block header.
+
+ inflate() should normally be called until it returns Z_STREAM_END or an
+ error. However if all decompression is to be performed in a single step (a
+ single call of inflate), the parameter flush should be set to Z_FINISH. In
+ this case all pending input is processed and all pending output is flushed;
+ avail_out must be large enough to hold all of the uncompressed data for the
+ operation to complete. (The size of the uncompressed data may have been
+ saved by the compressor for this purpose.) The use of Z_FINISH is not
+ required to perform an inflation in one step. However it may be used to
+ inform inflate that a faster approach can be used for the single inflate()
+ call. Z_FINISH also informs inflate to not maintain a sliding window if the
+ stream completes, which reduces inflate's memory footprint. If the stream
+ does not complete, either because not all of the stream is provided or not
+ enough output space is provided, then a sliding window will be allocated and
+ inflate() can be called again to continue the operation as if Z_NO_FLUSH had
+ been used.
+
+ In this implementation, inflate() always flushes as much output as
+ possible to the output buffer, and always uses the faster approach on the
+ first call. So the effects of the flush parameter in this implementation are
+ on the return value of inflate() as noted below, when inflate() returns early
+ when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
+ memory for a sliding window when Z_FINISH is used.
+
+ If a preset dictionary is needed after this call (see inflateSetDictionary
+ below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
+ chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
+ strm->adler to the Adler-32 checksum of all output produced so far (that is,
+ total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
+ below. At the end of the stream, inflate() checks that its computed adler32
+ checksum is equal to that saved by the compressor and returns Z_STREAM_END
+ only if the checksum is correct.
+
+ inflate() can decompress and check either zlib-wrapped or gzip-wrapped
+ deflate data. The header type is detected automatically, if requested when
+ initializing with inflateInit2(). Any information contained in the gzip
+ header is not retained, so applications that need that information should
+ instead use raw inflate, see inflateInit2() below, or inflateBack() and
+ perform their own processing of the gzip header and trailer. When processing
+ gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
+ producted so far. The CRC-32 is checked against the gzip trailer.
+
+ inflate() returns Z_OK if some progress has been made (more input processed
+ or more output produced), Z_STREAM_END if the end of the compressed data has
+ been reached and all uncompressed output has been produced, Z_NEED_DICT if a
+ preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
+ corrupted (input stream not conforming to the zlib format or incorrect check
+ value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
+ next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
+ Z_BUF_ERROR if no progress is possible or if there was not enough room in the
+ output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
+ inflate() can be called again with more input and more output space to
+ continue decompressing. If Z_DATA_ERROR is returned, the application may
+ then call inflateSync() to look for a good compression block if a partial
+ recovery of the data is desired.
+*/
+
+
+ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any pending
+ output.
+
+ inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
+ was inconsistent. In the error case, msg may be set but then points to a
+ static string (which must not be deallocated).
+*/
+
+
+ /* Advanced functions */
+
+/*
+ The following functions are needed only in some special applications.
+*/
+
+/*
+ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
+ int level,
+ int method,
+ int windowBits,
+ int memLevel,
+ int strategy));
+
+ This is another version of deflateInit with more compression options. The
+ fields next_in, zalloc, zfree and opaque must be initialized before by the
+ caller.
+
+ The method parameter is the compression method. It must be Z_DEFLATED in
+ this version of the library.
+
+ The windowBits parameter is the base two logarithm of the window size
+ (the size of the history buffer). It should be in the range 8..15 for this
+ version of the library. Larger values of this parameter result in better
+ compression at the expense of memory usage. The default value is 15 if
+ deflateInit is used instead.
+
+ windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
+ determines the window size. deflate() will then generate raw deflate data
+ with no zlib header or trailer, and will not compute an adler32 check value.
+
+ windowBits can also be greater than 15 for optional gzip encoding. Add
+ 16 to windowBits to write a simple gzip header and trailer around the
+ compressed data instead of a zlib wrapper. The gzip header will have no
+ file name, no extra data, no comment, no modification time (set to zero), no
+ header crc, and the operating system will be set to 255 (unknown). If a
+ gzip stream is being written, strm->adler is a crc32 instead of an adler32.
+
+ The memLevel parameter specifies how much memory should be allocated
+ for the internal compression state. memLevel=1 uses minimum memory but is
+ slow and reduces compression ratio; memLevel=9 uses maximum memory for
+ optimal speed. The default value is 8. See zconf.h for total memory usage
+ as a function of windowBits and memLevel.
+
+ The strategy parameter is used to tune the compression algorithm. Use the
+ value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
+ filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
+ string match), or Z_RLE to limit match distances to one (run-length
+ encoding). Filtered data consists mostly of small values with a somewhat
+ random distribution. In this case, the compression algorithm is tuned to
+ compress them better. The effect of Z_FILTERED is to force more Huffman
+ coding and less string matching; it is somewhat intermediate between
+ Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as
+ fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The
+ strategy parameter only affects the compression ratio but not the
+ correctness of the compressed output even if it is not set appropriately.
+ Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
+ decoder for special applications.
+
+ deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
+ method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
+ incompatible with the version assumed by the caller (ZLIB_VERSION). msg is
+ set to null if there is no error message. deflateInit2 does not perform any
+ compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
+/*
+ Initializes the compression dictionary from the given byte sequence
+ without producing any compressed output. When using the zlib format, this
+ function must be called immediately after deflateInit, deflateInit2 or
+ deflateReset, and before any call of deflate. When doing raw deflate, this
+ function must be called either before any call of deflate, or immediately
+ after the completion of a deflate block, i.e. after all input has been
+ consumed and all output has been delivered when using any of the flush
+ options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
+ compressor and decompressor must use exactly the same dictionary (see
+ inflateSetDictionary).
+
+ The dictionary should consist of strings (byte sequences) that are likely
+ to be encountered later in the data to be compressed, with the most commonly
+ used strings preferably put towards the end of the dictionary. Using a
+ dictionary is most useful when the data to be compressed is short and can be
+ predicted with good accuracy; the data can then be compressed better than
+ with the default empty dictionary.
+
+ Depending on the size of the compression data structures selected by
+ deflateInit or deflateInit2, a part of the dictionary may in effect be
+ discarded, for example if the dictionary is larger than the window size
+ provided in deflateInit or deflateInit2. Thus the strings most likely to be
+ useful should be put at the end of the dictionary, not at the front. In
+ addition, the current implementation of deflate will use at most the window
+ size minus 262 bytes of the provided dictionary.
+
+ Upon return of this function, strm->adler is set to the adler32 value
+ of the dictionary; the decompressor may later use this value to determine
+ which dictionary has been used by the compressor. (The adler32 value
+ applies to the whole dictionary even if only a subset of the dictionary is
+ actually used by the compressor.) If a raw deflate was requested, then the
+ adler32 value is not computed and strm->adler is not set.
+
+ deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
+ inconsistent (for example if deflate has already been called for this stream
+ or if not at a block boundary for raw deflate). deflateSetDictionary does
+ not perform any compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
+ z_streamp source));
+/*
+ Sets the destination stream as a complete copy of the source stream.
+
+ This function can be useful when several compression strategies will be
+ tried, for example when there are several ways of pre-processing the input
+ data with a filter. The streams that will be discarded should then be freed
+ by calling deflateEnd. Note that deflateCopy duplicates the internal
+ compression state which can be quite large, so this strategy is slow and can
+ consume lots of memory.
+
+ deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
+ destination.
+*/
+
+ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
+/*
+ This function is equivalent to deflateEnd followed by deflateInit,
+ but does not free and reallocate all the internal compression state. The
+ stream will keep the same compression level and any other attributes that
+ may have been set by deflateInit2.
+
+ deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
+ int level,
+ int strategy));
+/*
+ Dynamically update the compression level and compression strategy. The
+ interpretation of level and strategy is as in deflateInit2. This can be
+ used to switch between compression and straight copy of the input data, or
+ to switch to a different kind of input data requiring a different strategy.
+ If the compression level is changed, the input available so far is
+ compressed with the old level (and may be flushed); the new level will take
+ effect only at the next call of deflate().
+
+ Before the call of deflateParams, the stream state must be set as for
+ a call of deflate(), since the currently available input may have to be
+ compressed and flushed. In particular, strm->avail_out must be non-zero.
+
+ deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
+ stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
+ strm->avail_out was zero.
+*/
+
+ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
+ int good_length,
+ int max_lazy,
+ int nice_length,
+ int max_chain));
+/*
+ Fine tune deflate's internal compression parameters. This should only be
+ used by someone who understands the algorithm used by zlib's deflate for
+ searching for the best matching string, and even then only by the most
+ fanatic optimizer trying to squeeze out the last compressed bit for their
+ specific input data. Read the deflate.c source code for the meaning of the
+ max_lazy, good_length, nice_length, and max_chain parameters.
+
+ deflateTune() can be called after deflateInit() or deflateInit2(), and
+ returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
+ */
+
+ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
+ uLong sourceLen));
+/*
+ deflateBound() returns an upper bound on the compressed size after
+ deflation of sourceLen bytes. It must be called after deflateInit() or
+ deflateInit2(), and after deflateSetHeader(), if used. This would be used
+ to allocate an output buffer for deflation in a single pass, and so would be
+ called before deflate(). If that first deflate() call is provided the
+ sourceLen input bytes, an output buffer allocated to the size returned by
+ deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
+ to return Z_STREAM_END. Note that it is possible for the compressed size to
+ be larger than the value returned by deflateBound() if flush options other
+ than Z_FINISH or Z_NO_FLUSH are used.
+*/
+
+ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
+ unsigned *pending,
+ int *bits));
+/*
+ deflatePending() returns the number of bytes and bits of output that have
+ been generated, but not yet provided in the available output. The bytes not
+ provided would be due to the available output space having being consumed.
+ The number of bits of output not provided are between 0 and 7, where they
+ await more bits to join them in order to fill out a full byte. If pending
+ or bits are Z_NULL, then those values are not set.
+
+ deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+ */
+
+ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
+ int bits,
+ int value));
+/*
+ deflatePrime() inserts bits in the deflate output stream. The intent
+ is that this function is used to start off the deflate output with the bits
+ leftover from a previous deflate stream when appending to it. As such, this
+ function can only be used for raw deflate, and must be used before the first
+ deflate() call after a deflateInit2() or deflateReset(). bits must be less
+ than or equal to 16, and that many of the least significant bits of value
+ will be inserted in the output.
+
+ deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
+ room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
+ source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
+ gz_headerp head));
+/*
+ deflateSetHeader() provides gzip header information for when a gzip
+ stream is requested by deflateInit2(). deflateSetHeader() may be called
+ after deflateInit2() or deflateReset() and before the first call of
+ deflate(). The text, time, os, extra field, name, and comment information
+ in the provided gz_header structure are written to the gzip header (xflag is
+ ignored -- the extra flags are set according to the compression level). The
+ caller must assure that, if not Z_NULL, name and comment are terminated with
+ a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
+ available there. If hcrc is true, a gzip header crc is included. Note that
+ the current versions of the command-line version of gzip (up through version
+ 1.3.x) do not support header crc's, and will report that it is a "multi-part
+ gzip file" and give up.
+
+ If deflateSetHeader is not used, the default gzip header has text false,
+ the time set to zero, and os set to 255, with no extra, name, or comment
+ fields. The gzip header is returned to the default state by deflateReset().
+
+ deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
+ int windowBits));
+
+ This is another version of inflateInit with an extra parameter. The
+ fields next_in, avail_in, zalloc, zfree and opaque must be initialized
+ before by the caller.
+
+ The windowBits parameter is the base two logarithm of the maximum window
+ size (the size of the history buffer). It should be in the range 8..15 for
+ this version of the library. The default value is 15 if inflateInit is used
+ instead. windowBits must be greater than or equal to the windowBits value
+ provided to deflateInit2() while compressing, or it must be equal to 15 if
+ deflateInit2() was not used. If a compressed stream with a larger window
+ size is given as input, inflate() will return with the error code
+ Z_DATA_ERROR instead of trying to allocate a larger window.
+
+ windowBits can also be zero to request that inflate use the window size in
+ the zlib header of the compressed stream.
+
+ windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
+ determines the window size. inflate() will then process raw deflate data,
+ not looking for a zlib or gzip header, not generating a check value, and not
+ looking for any check values for comparison at the end of the stream. This
+ is for use with other formats that use the deflate compressed data format
+ such as zip. Those formats provide their own check values. If a custom
+ format is developed using the raw deflate format for compressed data, it is
+ recommended that a check value such as an adler32 or a crc32 be applied to
+ the uncompressed data as is done in the zlib, gzip, and zip formats. For
+ most applications, the zlib format should be used as is. Note that comments
+ above on the use in deflateInit2() applies to the magnitude of windowBits.
+
+ windowBits can also be greater than 15 for optional gzip decoding. Add
+ 32 to windowBits to enable zlib and gzip decoding with automatic header
+ detection, or add 16 to decode only the gzip format (the zlib format will
+ return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
+ crc32 instead of an adler32.
+
+ inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit2 does not perform any decompression
+ apart from possibly reading the zlib header if present: actual decompression
+ will be done by inflate(). (So next_in and avail_in may be modified, but
+ next_out and avail_out are unused and unchanged.) The current implementation
+ of inflateInit2() does not process any header information -- that is
+ deferred until inflate() is called.
+*/
+
+ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
+/*
+ Initializes the decompression dictionary from the given uncompressed byte
+ sequence. This function must be called immediately after a call of inflate,
+ if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
+ can be determined from the adler32 value returned by that call of inflate.
+ The compressor and decompressor must use exactly the same dictionary (see
+ deflateSetDictionary). For raw inflate, this function can be called at any
+ time to set the dictionary. If the provided dictionary is smaller than the
+ window and there is already data in the window, then the provided dictionary
+ will amend what's there. The application must insure that the dictionary
+ that was used for compression is provided.
+
+ inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
+ inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
+ expected one (incorrect adler32 value). inflateSetDictionary does not
+ perform any decompression: this will be done by subsequent calls of
+ inflate().
+*/
+
+ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
+ Bytef *dictionary,
+ uInt *dictLength));
+/*
+ Returns the sliding dictionary being maintained by inflate. dictLength is
+ set to the number of bytes in the dictionary, and that many bytes are copied
+ to dictionary. dictionary must have enough space, where 32768 bytes is
+ always enough. If inflateGetDictionary() is called with dictionary equal to
+ Z_NULL, then only the dictionary length is returned, and nothing is copied.
+ Similary, if dictLength is Z_NULL, then it is not set.
+
+ inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
+ stream state is inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
+/*
+ Skips invalid compressed data until a possible full flush point (see above
+ for the description of deflate with Z_FULL_FLUSH) can be found, or until all
+ available input is skipped. No output is provided.
+
+ inflateSync searches for a 00 00 FF FF pattern in the compressed data.
+ All full flush points have this pattern, but not all occurrences of this
+ pattern are full flush points.
+
+ inflateSync returns Z_OK if a possible full flush point has been found,
+ Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
+ has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
+ In the success case, the application may save the current current value of
+ total_in which indicates where valid compressed data was found. In the
+ error case, the application may repeatedly call inflateSync, providing more
+ input each time, until success or end of the input data.
+*/
+
+ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
+ z_streamp source));
+/*
+ Sets the destination stream as a complete copy of the source stream.
+
+ This function can be useful when randomly accessing a large stream. The
+ first pass through the stream can periodically record the inflate state,
+ allowing restarting inflate at those points when randomly accessing the
+ stream.
+
+ inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
+ destination.
+*/
+
+ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
+/*
+ This function is equivalent to inflateEnd followed by inflateInit,
+ but does not free and reallocate all the internal decompression state. The
+ stream will keep attributes that may have been set by inflateInit2.
+
+ inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
+ int windowBits));
+/*
+ This function is the same as inflateReset, but it also permits changing
+ the wrap and window size requests. The windowBits parameter is interpreted
+ the same as it is for inflateInit2.
+
+ inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL), or if
+ the windowBits parameter is invalid.
+*/
+
+ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
+ int bits,
+ int value));
+/*
+ This function inserts bits in the inflate input stream. The intent is
+ that this function is used to start inflating at a bit position in the
+ middle of a byte. The provided bits will be used before any bytes are used
+ from next_in. This function should only be used with raw inflate, and
+ should be used before the first inflate() call after inflateInit2() or
+ inflateReset(). bits must be less than or equal to 16, and that many of the
+ least significant bits of value will be inserted in the input.
+
+ If bits is negative, then the input stream bit buffer is emptied. Then
+ inflatePrime() can be called again to put bits in the buffer. This is used
+ to clear out bits leftover after feeding inflate a block description prior
+ to feeding inflate codes.
+
+ inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
+/*
+ This function returns two values, one in the lower 16 bits of the return
+ value, and the other in the remaining upper bits, obtained by shifting the
+ return value down 16 bits. If the upper value is -1 and the lower value is
+ zero, then inflate() is currently decoding information outside of a block.
+ If the upper value is -1 and the lower value is non-zero, then inflate is in
+ the middle of a stored block, with the lower value equaling the number of
+ bytes from the input remaining to copy. If the upper value is not -1, then
+ it is the number of bits back from the current bit position in the input of
+ the code (literal or length/distance pair) currently being processed. In
+ that case the lower value is the number of bytes already emitted for that
+ code.
+
+ A code is being processed if inflate is waiting for more input to complete
+ decoding of the code, or if it has completed decoding but is waiting for
+ more output space to write the literal or match data.
+
+ inflateMark() is used to mark locations in the input data for random
+ access, which may be at bit positions, and to note those cases where the
+ output of a code may span boundaries of random access blocks. The current
+ location in the input stream can be determined from avail_in and data_type
+ as noted in the description for the Z_BLOCK flush parameter for inflate.
+
+ inflateMark returns the value noted above or -1 << 16 if the provided
+ source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
+ gz_headerp head));
+/*
+ inflateGetHeader() requests that gzip header information be stored in the
+ provided gz_header structure. inflateGetHeader() may be called after
+ inflateInit2() or inflateReset(), and before the first call of inflate().
+ As inflate() processes the gzip stream, head->done is zero until the header
+ is completed, at which time head->done is set to one. If a zlib stream is
+ being decoded, then head->done is set to -1 to indicate that there will be
+ no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
+ used to force inflate() to return immediately after header processing is
+ complete and before any actual data is decompressed.
+
+ The text, time, xflags, and os fields are filled in with the gzip header
+ contents. hcrc is set to true if there is a header CRC. (The header CRC
+ was valid if done is set to one.) If extra is not Z_NULL, then extra_max
+ contains the maximum number of bytes to write to extra. Once done is true,
+ extra_len contains the actual extra field length, and extra contains the
+ extra field, or that field truncated if extra_max is less than extra_len.
+ If name is not Z_NULL, then up to name_max characters are written there,
+ terminated with a zero unless the length is greater than name_max. If
+ comment is not Z_NULL, then up to comm_max characters are written there,
+ terminated with a zero unless the length is greater than comm_max. When any
+ of extra, name, or comment are not Z_NULL and the respective field is not
+ present in the header, then that field is set to Z_NULL to signal its
+ absence. This allows the use of deflateSetHeader() with the returned
+ structure to duplicate the header. However if those fields are set to
+ allocated memory, then the application will need to save those pointers
+ elsewhere so that they can be eventually freed.
+
+ If inflateGetHeader is not used, then the header information is simply
+ discarded. The header is always checked for validity, including the header
+ CRC if present. inflateReset() will reset the process to discard the header
+ information. The application would need to call inflateGetHeader() again to
+ retrieve the header from the next gzip stream.
+
+ inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
+ unsigned char FAR *window));
+
+ Initialize the internal stream state for decompression using inflateBack()
+ calls. The fields zalloc, zfree and opaque in strm must be initialized
+ before the call. If zalloc and zfree are Z_NULL, then the default library-
+ derived memory allocation routines are used. windowBits is the base two
+ logarithm of the window size, in the range 8..15. window is a caller
+ supplied buffer of that size. Except for special applications where it is
+ assured that deflate was used with small window sizes, windowBits must be 15
+ and a 32K byte window must be supplied to be able to decompress general
+ deflate streams.
+
+ See inflateBack() for the usage of these routines.
+
+ inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
+ the parameters are invalid, Z_MEM_ERROR if the internal state could not be
+ allocated, or Z_VERSION_ERROR if the version of the library does not match
+ the version of the header file.
+*/
+
+typedef unsigned (*in_func) OF((void FAR *,
+ z_const unsigned char FAR * FAR *));
+typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
+
+ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
+ in_func in, void FAR *in_desc,
+ out_func out, void FAR *out_desc));
+/*
+ inflateBack() does a raw inflate with a single call using a call-back
+ interface for input and output. This is potentially more efficient than
+ inflate() for file i/o applications, in that it avoids copying between the
+ output and the sliding window by simply making the window itself the output
+ buffer. inflate() can be faster on modern CPUs when used with large
+ buffers. inflateBack() trusts the application to not change the output
+ buffer passed by the output function, at least until inflateBack() returns.
+
+ inflateBackInit() must be called first to allocate the internal state
+ and to initialize the state with the user-provided window buffer.
+ inflateBack() may then be used multiple times to inflate a complete, raw
+ deflate stream with each call. inflateBackEnd() is then called to free the
+ allocated state.
+
+ A raw deflate stream is one with no zlib or gzip header or trailer.
+ This routine would normally be used in a utility that reads zip or gzip
+ files and writes out uncompressed files. The utility would decode the
+ header and process the trailer on its own, hence this routine expects only
+ the raw deflate stream to decompress. This is different from the normal
+ behavior of inflate(), which expects either a zlib or gzip header and
+ trailer around the deflate stream.
+
+ inflateBack() uses two subroutines supplied by the caller that are then
+ called by inflateBack() for input and output. inflateBack() calls those
+ routines until it reads a complete deflate stream and writes out all of the
+ uncompressed data, or until it encounters an error. The function's
+ parameters and return types are defined above in the in_func and out_func
+ typedefs. inflateBack() will call in(in_desc, &buf) which should return the
+ number of bytes of provided input, and a pointer to that input in buf. If
+ there is no input available, in() must return zero--buf is ignored in that
+ case--and inflateBack() will return a buffer error. inflateBack() will call
+ out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
+ should return zero on success, or non-zero on failure. If out() returns
+ non-zero, inflateBack() will return with an error. Neither in() nor out()
+ are permitted to change the contents of the window provided to
+ inflateBackInit(), which is also the buffer that out() uses to write from.
+ The length written by out() will be at most the window size. Any non-zero
+ amount of input may be provided by in().
+
+ For convenience, inflateBack() can be provided input on the first call by
+ setting strm->next_in and strm->avail_in. If that input is exhausted, then
+ in() will be called. Therefore strm->next_in must be initialized before
+ calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
+ immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
+ must also be initialized, and then if strm->avail_in is not zero, input will
+ initially be taken from strm->next_in[0 .. strm->avail_in - 1].
+
+ The in_desc and out_desc parameters of inflateBack() is passed as the
+ first parameter of in() and out() respectively when they are called. These
+ descriptors can be optionally used to pass any information that the caller-
+ supplied in() and out() functions need to do their job.
+
+ On return, inflateBack() will set strm->next_in and strm->avail_in to
+ pass back any unused input that was provided by the last in() call. The
+ return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
+ if in() or out() returned an error, Z_DATA_ERROR if there was a format error
+ in the deflate stream (in which case strm->msg is set to indicate the nature
+ of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
+ In the case of Z_BUF_ERROR, an input or output error can be distinguished
+ using strm->next_in which will be Z_NULL only if in() returned an error. If
+ strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
+ non-zero. (in() will always be called before out(), so strm->next_in is
+ assured to be defined if out() returns non-zero.) Note that inflateBack()
+ cannot return Z_OK.
+*/
+
+ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
+/*
+ All memory allocated by inflateBackInit() is freed.
+
+ inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
+ state was inconsistent.
+*/
+
+ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
+/* Return flags indicating compile-time options.
+
+ Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
+ 1.0: size of uInt
+ 3.2: size of uLong
+ 5.4: size of voidpf (pointer)
+ 7.6: size of z_off_t
+
+ Compiler, assembler, and debug options:
+ 8: DEBUG
+ 9: ASMV or ASMINF -- use ASM code
+ 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
+ 11: 0 (reserved)
+
+ One-time table building (smaller code, but not thread-safe if true):
+ 12: BUILDFIXED -- build static block decoding tables when needed
+ 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
+ 14,15: 0 (reserved)
+
+ Library content (indicates missing functionality):
+ 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
+ deflate code when not needed)
+ 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
+ and decode gzip streams (to avoid linking crc code)
+ 18-19: 0 (reserved)
+
+ Operation variations (changes in library functionality):
+ 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
+ 21: FASTEST -- deflate algorithm with only one, lowest compression level
+ 22,23: 0 (reserved)
+
+ The sprintf variant used by gzprintf (zero is best):
+ 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
+ 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
+ 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
+
+ Remainder:
+ 27-31: 0 (reserved)
+ */
+
+#ifndef Z_SOLO
+
+ /* utility functions */
+
+/*
+ The following utility functions are implemented on top of the basic
+ stream-oriented functions. To simplify the interface, some default options
+ are assumed (compression level and memory usage, standard memory allocation
+ functions). The source code of these utility functions can be modified if
+ you need special options.
+*/
+
+ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Compresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be at least the value returned by
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ compressed buffer.
+
+ compress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer.
+*/
+
+ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int level));
+/*
+ Compresses the source buffer into the destination buffer. The level
+ parameter has the same meaning as in deflateInit. sourceLen is the byte
+ length of the source buffer. Upon entry, destLen is the total size of the
+ destination buffer, which must be at least the value returned by
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ compressed buffer.
+
+ compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_BUF_ERROR if there was not enough room in the output buffer,
+ Z_STREAM_ERROR if the level parameter is invalid.
+*/
+
+ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
+/*
+ compressBound() returns an upper bound on the compressed size after
+ compress() or compress2() on sourceLen bytes. It would be used before a
+ compress() or compress2() call to allocate the destination buffer.
+*/
+
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit, destLen
+ is the actual size of the uncompressed buffer.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
+ the case where there is not enough room, uncompress() will fill the output
+ buffer with the uncompressed data up to that point.
+*/
+
+ /* gzip file access functions */
+
+/*
+ This library supports reading and writing files in gzip (.gz) format with
+ an interface similar to that of stdio, using the functions that start with
+ "gz". The gzip format is different from the zlib format. gzip is a gzip
+ wrapper, documented in RFC 1952, wrapped around a deflate stream.
+*/
+
+typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
+
+/*
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+
+ Opens a gzip (.gz) file for reading or writing. The mode parameter is as
+ in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
+ a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
+ compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
+ for fixed code compression as in "wb9F". (See the description of
+ deflateInit2 for more information about the strategy parameter.) 'T' will
+ request transparent writing or appending with no compression and not using
+ the gzip format.
+
+ "a" can be used instead of "w" to request that the gzip stream that will
+ be written be appended to the file. "+" will result in an error, since
+ reading and writing to the same gzip file is not supported. The addition of
+ "x" when writing will create the file exclusively, which fails if the file
+ already exists. On systems that support it, the addition of "e" when
+ reading or writing will set the flag to close the file on an execve() call.
+
+ These functions, as well as gzip, will read and decode a sequence of gzip
+ streams in a file. The append function of gzopen() can be used to create
+ such a file. (Also see gzflush() for another way to do this.) When
+ appending, gzopen does not test whether the file begins with a gzip stream,
+ nor does it look for the end of the gzip streams to begin appending. gzopen
+ will simply append a gzip stream to the existing file.
+
+ gzopen can be used to read a file which is not in gzip format; in this
+ case gzread will directly read from the file without decompression. When
+ reading, this will be detected automatically by looking for the magic two-
+ byte gzip header.
+
+ gzopen returns NULL if the file could not be opened, if there was
+ insufficient memory to allocate the gzFile state, or if an invalid mode was
+ specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
+ errno can be checked to determine if the reason gzopen failed was that the
+ file could not be opened.
+*/
+
+ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+/*
+ gzdopen associates a gzFile with the file descriptor fd. File descriptors
+ are obtained from calls like open, dup, creat, pipe or fileno (if the file
+ has been previously opened with fopen). The mode parameter is as in gzopen.
+
+ The next call of gzclose on the returned gzFile will also close the file
+ descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
+ fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
+ mode);. The duplicated descriptor should be saved to avoid a leak, since
+ gzdopen does not close fd if it fails. If you are using fileno() to get the
+ file descriptor from a FILE *, then you will have to use dup() to avoid
+ double-close()ing the file descriptor. Both gzclose() and fclose() will
+ close the associated file descriptor, so they need to have different file
+ descriptors.
+
+ gzdopen returns NULL if there was insufficient memory to allocate the
+ gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
+ provided, or '+' was provided), or if fd is -1. The file descriptor is not
+ used until the next gz* read, write, seek, or close operation, so gzdopen
+ will not detect if fd is invalid (unless fd is -1).
+*/
+
+ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
+/*
+ Set the internal buffer size used by this library's functions. The
+ default buffer size is 8192 bytes. This function must be called after
+ gzopen() or gzdopen(), and before any other calls that read or write the
+ file. The buffer memory allocation is always deferred to the first read or
+ write. Two buffers are allocated, either both of the specified size when
+ writing, or one of the specified size and the other twice that size when
+ reading. A larger buffer size of, for example, 64K or 128K bytes will
+ noticeably increase the speed of decompression (reading).
+
+ The new buffer size also affects the maximum length for gzprintf().
+
+ gzbuffer() returns 0 on success, or -1 on failure, such as being called
+ too late.
+*/
+
+ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
+/*
+ Dynamically update the compression level or strategy. See the description
+ of deflateInit2 for the meaning of these parameters.
+
+ gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
+ opened for writing.
+*/
+
+ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
+/*
+ Reads the given number of uncompressed bytes from the compressed file. If
+ the input file is not in gzip format, gzread copies the given number of
+ bytes into the buffer directly from the file.
+
+ After reaching the end of a gzip stream in the input, gzread will continue
+ to read, looking for another gzip stream. Any number of gzip streams may be
+ concatenated in the input file, and will all be decompressed by gzread().
+ If something other than a gzip stream is encountered after a gzip stream,
+ that remaining trailing garbage is ignored (and no error is returned).
+
+ gzread can be used to read a gzip file that is being concurrently written.
+ Upon reaching the end of the input, gzread will return with the available
+ data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
+ gzclearerr can be used to clear the end of file indicator in order to permit
+ gzread to be tried again. Z_OK indicates that a gzip stream was completed
+ on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
+ middle of a gzip stream. Note that gzread does not return -1 in the event
+ of an incomplete gzip stream. This error is deferred until gzclose(), which
+ will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
+ stream. Alternatively, gzerror can be used before gzclose to detect this
+ case.
+
+ gzread returns the number of uncompressed bytes actually read, less than
+ len for end of file, or -1 for error.
+*/
+
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
+ voidpc buf, unsigned len));
+/*
+ Writes the given number of uncompressed bytes into the compressed file.
+ gzwrite returns the number of uncompressed bytes written or 0 in case of
+ error.
+*/
+
+ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
+/*
+ Converts, formats, and writes the arguments to the compressed file under
+ control of the format string, as in fprintf. gzprintf returns the number of
+ uncompressed bytes actually written, or 0 in case of error. The number of
+ uncompressed bytes written is limited to 8191, or one less than the buffer
+ size given to gzbuffer(). The caller should assure that this limit is not
+ exceeded. If it is exceeded, then gzprintf() will return an error (0) with
+ nothing written. In this case, there may also be a buffer overflow with
+ unpredictable consequences, which is possible only if zlib was compiled with
+ the insecure functions sprintf() or vsprintf() because the secure snprintf()
+ or vsnprintf() functions were not available. This can be determined using
+ zlibCompileFlags().
+*/
+
+ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
+/*
+ Writes the given null-terminated string to the compressed file, excluding
+ the terminating null character.
+
+ gzputs returns the number of characters written, or -1 in case of error.
+*/
+
+ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
+/*
+ Reads bytes from the compressed file until len-1 characters are read, or a
+ newline character is read and transferred to buf, or an end-of-file
+ condition is encountered. If any characters are read or if len == 1, the
+ string is terminated with a null character. If no characters are read due
+ to an end-of-file or len < 1, then the buffer is left untouched.
+
+ gzgets returns buf which is a null-terminated string, or it returns NULL
+ for end-of-file or in case of error. If there was an error, the contents at
+ buf are indeterminate.
+*/
+
+ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
+/*
+ Writes c, converted to an unsigned char, into the compressed file. gzputc
+ returns the value that was written, or -1 in case of error.
+*/
+
+ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
+/*
+ Reads one byte from the compressed file. gzgetc returns this byte or -1
+ in case of end of file or error. This is implemented as a macro for speed.
+ As such, it does not do all of the checking the other functions do. I.e.
+ it does not check to see if file is NULL, nor whether the structure file
+ points to has been clobbered or not.
+*/
+
+ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
+/*
+ Push one character back onto the stream to be read as the first character
+ on the next read. At least one character of push-back is allowed.
+ gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
+ fail if c is -1, and may fail if a character has been pushed but not read
+ yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
+ output buffer size of pushed characters is allowed. (See gzbuffer above.)
+ The pushed character will be discarded if the stream is repositioned with
+ gzseek() or gzrewind().
+*/
+
+ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
+/*
+ Flushes all pending output into the compressed file. The parameter flush
+ is as in the deflate() function. The return value is the zlib error number
+ (see function gzerror below). gzflush is only permitted when writing.
+
+ If the flush parameter is Z_FINISH, the remaining data is written and the
+ gzip stream is completed in the output. If gzwrite() is called again, a new
+ gzip stream will be started in the output. gzread() is able to read such
+ concatented gzip streams.
+
+ gzflush should be called only when strictly necessary because it will
+ degrade compression if called too often.
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
+ z_off_t offset, int whence));
+
+ Sets the starting position for the next gzread or gzwrite on the given
+ compressed file. The offset represents a number of bytes in the
+ uncompressed data stream. The whence parameter is defined as in lseek(2);
+ the value SEEK_END is not supported.
+
+ If the file is opened for reading, this function is emulated but can be
+ extremely slow. If the file is opened for writing, only forward seeks are
+ supported; gzseek then compresses a sequence of zeroes up to the new
+ starting position.
+
+ gzseek returns the resulting offset location as measured in bytes from
+ the beginning of the uncompressed stream, or -1 in case of error, in
+ particular if the file is opened for writing and the new starting position
+ would be before the current position.
+*/
+
+ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
+/*
+ Rewinds the given file. This function is supported only for reading.
+
+ gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
+
+ Returns the starting position for the next gzread or gzwrite on the given
+ compressed file. This position represents a number of bytes in the
+ uncompressed data stream, and is zero when starting, even if appending or
+ reading a gzip stream from the middle of a file using gzdopen().
+
+ gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
+
+ Returns the current offset in the file being read or written. This offset
+ includes the count of bytes that precede the gzip stream, for example when
+ appending or when using gzdopen() for reading. When reading, the offset
+ does not include as yet unused buffered input. This information can be used
+ for a progress indicator. On error, gzoffset() returns -1.
+*/
+
+ZEXTERN int ZEXPORT gzeof OF((gzFile file));
+/*
+ Returns true (1) if the end-of-file indicator has been set while reading,
+ false (0) otherwise. Note that the end-of-file indicator is set only if the
+ read tried to go past the end of the input, but came up short. Therefore,
+ just like feof(), gzeof() may return false even if there is no more data to
+ read, in the event that the last read request was for the exact number of
+ bytes remaining in the input file. This will happen if the input file size
+ is an exact multiple of the buffer size.
+
+ If gzeof() returns true, then the read functions will return no more data,
+ unless the end-of-file indicator is reset by gzclearerr() and the input file
+ has grown since the previous end of file was detected.
+*/
+
+ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
+/*
+ Returns true (1) if file is being copied directly while reading, or false
+ (0) if file is a gzip stream being decompressed.
+
+ If the input file is empty, gzdirect() will return true, since the input
+ does not contain a gzip stream.
+
+ If gzdirect() is used immediately after gzopen() or gzdopen() it will
+ cause buffers to be allocated to allow reading the file to determine if it
+ is a gzip file. Therefore if gzbuffer() is used, it should be called before
+ gzdirect().
+
+ When writing, gzdirect() returns true (1) if transparent writing was
+ requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
+ gzdirect() is not needed when writing. Transparent writing must be
+ explicitly requested, so the application already knows the answer. When
+ linking statically, using gzdirect() will include all of the zlib code for
+ gzip file reading and decompression, which may not be desired.)
+*/
+
+ZEXTERN int ZEXPORT gzclose OF((gzFile file));
+/*
+ Flushes all pending output if necessary, closes the compressed file and
+ deallocates the (de)compression state. Note that once file is closed, you
+ cannot call gzerror with file, since its structures have been deallocated.
+ gzclose must not be called more than once on the same file, just as free
+ must not be called more than once on the same allocation.
+
+ gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
+ file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
+ last read ended in the middle of a gzip stream, or Z_OK on success.
+*/
+
+ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
+ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
+/*
+ Same as gzclose(), but gzclose_r() is only for use when reading, and
+ gzclose_w() is only for use when writing or appending. The advantage to
+ using these instead of gzclose() is that they avoid linking in zlib
+ compression or decompression code that is not used when only reading or only
+ writing respectively. If gzclose() is used, then both compression and
+ decompression code will be included the application when linking to a static
+ zlib library.
+*/
+
+ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
+/*
+ Returns the error message for the last error which occurred on the given
+ compressed file. errnum is set to zlib error number. If an error occurred
+ in the file system and not in the compression library, errnum is set to
+ Z_ERRNO and the application may consult errno to get the exact error code.
+
+ The application must not modify the returned string. Future calls to
+ this function may invalidate the previously returned string. If file is
+ closed, then the string previously returned by gzerror will no longer be
+ available.
+
+ gzerror() should be used to distinguish errors from end-of-file for those
+ functions above that do not distinguish those cases in their return values.
+*/
+
+ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
+/*
+ Clears the error and end-of-file flags for file. This is analogous to the
+ clearerr() function in stdio. This is useful for continuing to read a gzip
+ file that is being written concurrently.
+*/
+
+#endif /* !Z_SOLO */
+
+ /* checksum functions */
+
+/*
+ These functions are not related to compression but are exported
+ anyway because they might be useful in applications using the compression
+ library.
+*/
+
+ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
+/*
+ Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+ return the updated checksum. If buf is Z_NULL, this function returns the
+ required initial value for the checksum.
+
+ An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+ much faster.
+
+ Usage example:
+
+ uLong adler = adler32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ adler = adler32(adler, buffer, length);
+ }
+ if (adler != original_adler) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
+ z_off_t len2));
+
+ Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
+ and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
+ each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
+ seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
+ that the z_off_t type (like off_t) is a signed integer. If len2 is
+ negative, the result has no meaning or utility.
+*/
+
+ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
+/*
+ Update a running CRC-32 with the bytes buf[0..len-1] and return the
+ updated CRC-32. If buf is Z_NULL, this function returns the required
+ initial value for the crc. Pre- and post-conditioning (one's complement) is
+ performed within this function so it shouldn't be done by the application.
+
+ Usage example:
+
+ uLong crc = crc32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ crc = crc32(crc, buffer, length);
+ }
+ if (crc != original_crc) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
+
+ Combine two CRC-32 check values into one. For two sequences of bytes,
+ seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
+ calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
+ check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
+ len2.
+*/
+
+
+ /* various hacks, don't look :) */
+
+/* deflateInit and inflateInit are macros to allow checking the zlib version
+ * and the compiler's view of z_stream:
+ */
+ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
+ int windowBits, int memLevel,
+ int strategy, const char *version,
+ int stream_size));
+ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
+ unsigned char FAR *window,
+ const char *version,
+ int stream_size));
+#define deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+#define inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+#define inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+ (int)sizeof(z_stream))
+#define inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, (int)sizeof(z_stream))
+
+#ifndef Z_SOLO
+
+/* gzgetc() macro and its supporting function and exposed data structure. Note
+ * that the real internal state is much larger than the exposed structure.
+ * This abbreviated structure exposes just enough for the gzgetc() macro. The
+ * user should not mess with these exposed elements, since their names or
+ * behavior could change in the future, perhaps even capriciously. They can
+ * only be used by the gzgetc() macro. You have been warned.
+ */
+struct gzFile_s {
+ unsigned have;
+ unsigned char *next;
+ z_off64_t pos;
+};
+ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
+#ifdef Z_PREFIX_SET
+# undef z_gzgetc
+# define z_gzgetc(g) \
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+#else
+# define gzgetc(g) \
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+#endif
+
+/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
+ * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
+ * both are true, the application gets the *64 functions, and the regular
+ * functions are changed to 64 bits) -- in case these are set on systems
+ * without large file support, _LFS64_LARGEFILE must also be true
+ */
+#ifdef Z_LARGE64
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+ ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
+#endif
+
+#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
+# ifdef Z_PREFIX_SET
+# define z_gzopen z_gzopen64
+# define z_gzseek z_gzseek64
+# define z_gztell z_gztell64
+# define z_gzoffset z_gzoffset64
+# define z_adler32_combine z_adler32_combine64
+# define z_crc32_combine z_crc32_combine64
+# else
+# define gzopen gzopen64
+# define gzseek gzseek64
+# define gztell gztell64
+# define gzoffset gzoffset64
+# define adler32_combine adler32_combine64
+# define crc32_combine crc32_combine64
+# endif
+# ifndef Z_LARGE64
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int));
+ ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off64_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t));
+# endif
+#else
+ ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
+ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+#endif
+
+#else /* Z_SOLO */
+
+ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+
+#endif /* !Z_SOLO */
+
+/* hack for buggy compilers */
+#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
+ struct internal_state {int dummy;};
+#endif
+
+/* undocumented functions */
+ZEXTERN const char * ZEXPORT zError OF((int));
+ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
+ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
+ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
+ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
+ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
+#if defined(_WIN32) && !defined(Z_SOLO)
+ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
+ const char *mode));
+#endif
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# ifndef Z_SOLO
+ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
+ const char *format,
+ va_list va));
+# endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZLIB_H */