summaryrefslogtreecommitdiff
path: root/xfa/src/fgas/include
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-10-28 23:03:33 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-11-03 11:10:11 -0800
commitfdc00a7042d912aafaabddae4d9c84199921ef23 (patch)
tree32ab8ac91cc68d2cd15b9168782a71b3f3f5e7b9 /xfa/src/fgas/include
parente9b38fa38de2c95d8260be31c57d9272c4d127ed (diff)
downloadpdfium-fdc00a7042d912aafaabddae4d9c84199921ef23.tar.xz
Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
Diffstat (limited to 'xfa/src/fgas/include')
-rw-r--r--xfa/src/fgas/include/fgas.h24
-rw-r--r--xfa/src/fgas/include/fx_alg.h46
-rw-r--r--xfa/src/fgas/include/fx_cpg.h233
-rw-r--r--xfa/src/fgas/include/fx_datetime.h470
-rw-r--r--xfa/src/fgas/include/fx_fnt.h170
-rw-r--r--xfa/src/fgas/include/fx_lbk.h27
-rw-r--r--xfa/src/fgas/include/fx_lgg.h267
-rw-r--r--xfa/src/fgas/include/fx_locale.h160
-rw-r--r--xfa/src/fgas/include/fx_mem.h58
-rw-r--r--xfa/src/fgas/include/fx_rbk.h235
-rw-r--r--xfa/src/fgas/include/fx_sax.h48
-rw-r--r--xfa/src/fgas/include/fx_stm.h60
-rw-r--r--xfa/src/fgas/include/fx_sys.h63
-rw-r--r--xfa/src/fgas/include/fx_tbk.h211
-rw-r--r--xfa/src/fgas/include/fx_ucd.h23
-rw-r--r--xfa/src/fgas/include/fx_utl.h797
16 files changed, 2892 insertions, 0 deletions
diff --git a/xfa/src/fgas/include/fgas.h b/xfa/src/fgas/include/fgas.h
new file mode 100644
index 0000000000..8f085e4791
--- /dev/null
+++ b/xfa/src/fgas/include/fgas.h
@@ -0,0 +1,24 @@
+// 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 _FGAS_
+#define _FGAS_
+#include "fx_sys.h"
+#include "fx_mem.h"
+#include "fx_lgg.h"
+#include "fx_utl.h"
+#include "fx_alg.h"
+#include "fx_cpg.h"
+#include "fx_stm.h"
+#include "fx_datetime.h"
+#include "fx_locale.h"
+#include "fx_sax.h"
+#include "fx_fnt.h"
+#include "fx_ucd.h"
+#include "fx_lbk.h"
+#include "fx_tbk.h"
+#include "fx_rbk.h"
+#endif
diff --git a/xfa/src/fgas/include/fx_alg.h b/xfa/src/fgas/include/fx_alg.h
new file mode 100644
index 0000000000..ed946641f2
--- /dev/null
+++ b/xfa/src/fgas/include/fx_alg.h
@@ -0,0 +1,46 @@
+// 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_ALGORITHM
+#define _FX_ALGORITHM
+#define FX_IsOdd(a) ((a) & 1)
+#ifdef __cplusplus
+extern "C" {
+#endif
+FX_INT32 FX_Base64EncodeA(FX_LPCBYTE pSrc, FX_INT32 iSrcLen, FX_LPSTR pDst);
+FX_INT32 FX_Base64DecodeA(FX_LPCSTR pSrc, FX_INT32 iSrcLen, FX_LPBYTE pDst);
+FX_INT32 FX_Base64DecodeW(FX_LPCWSTR pSrc, FX_INT32 iSrcLen, FX_LPBYTE pDst);
+FX_BYTE FX_Hex2Dec(FX_BYTE hexHigh, FX_BYTE hexLow);
+FX_INT32 FX_SeparateStringW(FX_LPCWSTR pStr, FX_INT32 iStrLen, FX_WCHAR delimiter, CFX_WideStringArray &pieces);
+#ifdef __cplusplus
+};
+#endif
+template<class baseType>
+class CFX_DSPATemplate
+{
+public:
+ FX_INT32 Lookup(const baseType &find, const baseType *pArray, FX_INT32 iCount)
+ {
+ FXSYS_assert(pArray != NULL);
+ if (iCount < 1) {
+ return -1;
+ }
+ FX_INT32 iStart = 0, iEnd = iCount - 1, iMid;
+ do {
+ iMid = (iStart + iEnd) / 2;
+ const baseType &v = pArray[iMid];
+ if (find == v) {
+ return iMid;
+ } else if (find < v) {
+ iEnd = iMid - 1;
+ } else {
+ iStart = iMid + 1;
+ }
+ } while (iStart <= iEnd);
+ return -1;
+ }
+};
+#endif
diff --git a/xfa/src/fgas/include/fx_cpg.h b/xfa/src/fgas/include/fx_cpg.h
new file mode 100644
index 0000000000..43c6520152
--- /dev/null
+++ b/xfa/src/fgas/include/fx_cpg.h
@@ -0,0 +1,233 @@
+// 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_CODEPAGE
+#define _FX_CODEPAGE
+class IFX_CodePage;
+#define FX_CODEPAGE_DefANSI 0
+#define FX_CODEPAGE_DefOEM 1
+#define FX_CODEPAGE_DefMAC 2
+#define FX_CODEPAGE_Thread 3
+#define FX_CODEPAGE_Symbol 42
+#define FX_CODEPAGE_MSDOS_US 437
+#define FX_CODEPAGE_Arabic_ASMO708 708
+#define FX_CODEPAGE_Arabic_ASMO449Plus 709
+#define FX_CODEPAGE_Arabic_Transparent 710
+#define FX_CODEPAGE_Arabic_NafithaEnhanced 711
+#define FX_CODEPAGE_Arabic_TransparentASMO 720
+#define FX_CODEPAGE_MSDOS_Greek1 737
+#define FX_CODEPAGE_MSDOS_Baltic 775
+#define FX_CODEPAGE_MSWin31_WesternEuropean 819
+#define FX_CODEPAGE_MSDOS_WesternEuropean 850
+#define FX_CODEPAGE_MSDOS_EasternEuropean 852
+#define FX_CODEPAGE_MSDOS_Latin3 853
+#define FX_CODEPAGE_MSDOS_Cyrillic 855
+#define FX_CODEPAGE_MSDOS_Turkish 857
+#define FX_CODEPAGE_MSDOS_Latin1Euro 858
+#define FX_CODEPAGE_MSDOS_Portuguese 860
+#define FX_CODEPAGE_MSDOS_Icelandic 861
+#define FX_CODEPAGE_MSDOS_Hebrew 862
+#define FX_CODEPAGE_MSDOS_FrenchCanadian 863
+#define FX_CODEPAGE_MSDOS_Arabic 864
+#define FX_CODEPAGE_MSDOS_Norwegian 865
+#define FX_CODEPAGE_MSDOS_Russian 866
+#define FX_CODEPAGE_MSDOS_Greek2 869
+#define FX_CODEPAGE_MSDOS_Thai 874
+#define FX_CODEPAGE_MSDOS_KamenickyCS 895
+#define FX_CODEPAGE_ShiftJIS 932
+#define FX_CODEPAGE_ChineseSimplified 936
+#define FX_CODEPAGE_Korean 949
+#define FX_CODEPAGE_ChineseTraditional 950
+#define FX_CODEPAGE_UTF16LE 1200
+#define FX_CODEPAGE_UTF16BE 1201
+#define FX_CODEPAGE_MSWin_EasternEuropean 1250
+#define FX_CODEPAGE_MSWin_Cyrillic 1251
+#define FX_CODEPAGE_MSWin_WesternEuropean 1252
+#define FX_CODEPAGE_MSWin_Greek 1253
+#define FX_CODEPAGE_MSWin_Turkish 1254
+#define FX_CODEPAGE_MSWin_Hebrew 1255
+#define FX_CODEPAGE_MSWin_Arabic 1256
+#define FX_CODEPAGE_MSWin_Baltic 1257
+#define FX_CODEPAGE_MSWin_Vietnamese 1258
+#define FX_CODEPAGE_Johab 1361
+#define FX_CODEPAGE_MAC_Roman 10000
+#define FX_CODEPAGE_MAC_ShiftJIS 10001
+#define FX_CODEPAGE_MAC_ChineseTraditional 10002
+#define FX_CODEPAGE_MAC_Korean 10003
+#define FX_CODEPAGE_MAC_Arabic 10004
+#define FX_CODEPAGE_MAC_Hebrew 10005
+#define FX_CODEPAGE_MAC_Greek 10006
+#define FX_CODEPAGE_MAC_Cyrillic 10007
+#define FX_CODEPAGE_MAC_ChineseSimplified 10008
+#define FX_CODEPAGE_MAC_Thai 10021
+#define FX_CODEPAGE_MAC_EasternEuropean 10029
+#define FX_CODEPAGE_MAC_Turkish 10081
+#define FX_CODEPAGE_UTF32LE 12000
+#define FX_CODEPAGE_UTF32BE 12001
+#define FX_CODEPAGE_ISO8859_1 28591
+#define FX_CODEPAGE_ISO8859_2 28592
+#define FX_CODEPAGE_ISO8859_3 28593
+#define FX_CODEPAGE_ISO8859_4 28594
+#define FX_CODEPAGE_ISO8859_5 28595
+#define FX_CODEPAGE_ISO8859_6 28596
+#define FX_CODEPAGE_ISO8859_7 28597
+#define FX_CODEPAGE_ISO8859_8 28598
+#define FX_CODEPAGE_ISO8859_9 28599
+#define FX_CODEPAGE_ISO8859_10 28600
+#define FX_CODEPAGE_ISO8859_11 28601
+#define FX_CODEPAGE_ISO8859_12 28602
+#define FX_CODEPAGE_ISO8859_13 28603
+#define FX_CODEPAGE_ISO8859_14 28604
+#define FX_CODEPAGE_ISO8859_15 28605
+#define FX_CODEPAGE_ISO8859_16 28606
+#define FX_CODEPAGE_ISCII_Devanagari 57002
+#define FX_CODEPAGE_ISCII_Bengali 57003
+#define FX_CODEPAGE_ISCII_Tamil 57004
+#define FX_CODEPAGE_ISCII_Telugu 57005
+#define FX_CODEPAGE_ISCII_Assamese 57006
+#define FX_CODEPAGE_ISCII_Oriya 57007
+#define FX_CODEPAGE_ISCII_Kannada 57008
+#define FX_CODEPAGE_ISCII_Malayalam 57009
+#define FX_CODEPAGE_ISCII_Gujarati 57010
+#define FX_CODEPAGE_ISCII_Punjabi 57011
+#define FX_CODEPAGE_UTF7 65000
+#define FX_CODEPAGE_UTF8 65001
+#define FX_CHARSET_ANSI 0
+#define FX_CHARSET_Default 1
+#define FX_CHARSET_Symbol 2
+#define FX_CHARSET_MAC_Roman 77
+#define FX_CHARSET_MAC_ShiftJIS 78
+#define FX_CHARSET_MAC_Korean 79
+#define FX_CHARSET_MAC_ChineseSimplified 80
+#define FX_CHARSET_MAC_ChineseTriditional 81
+#define FX_CHARSET_MAC_Johab 82
+#define FX_CHARSET_MAC_Hebrew 83
+#define FX_CHARSET_MAC_Arabic 84
+#define FX_CHARSET_MAC_Greek 85
+#define FX_CHARSET_MAC_Turkish 86
+#define FX_CHARSET_MAC_Thai 87
+#define FX_CHARSET_MAC_EasternEuropean 88
+#define FX_CHARSET_MAC_Cyrillic 89
+#define FX_CHARSET_ShiftJIS 128
+#define FX_CHARSET_Korean 129
+#define FX_CHARSET_Johab 130
+#define FX_CHARSET_ChineseSimplified 134
+#define FX_CHARSET_ChineseTriditional 136
+#define FX_CHARSET_MSWin_Greek 161
+#define FX_CHARSET_MSWin_Turkish 162
+#define FX_CHARSET_MSWin_Vietnamese 163
+#define FX_CHARSET_MSWin_Hebrew 177
+#define FX_CHARSET_MSWin_Arabic 178
+#define FX_CHARSET_ArabicTraditional 179
+#define FX_CHARSET_ArabicUser 180
+#define FX_CHARSET_HebrewUser 181
+#define FX_CHARSET_MSWin_Baltic 186
+#define FX_CHARSET_MSWin_Cyrillic 204
+#define FX_CHARSET_Thai 222
+#define FX_CHARSET_MSWin_EasterEuropean 238
+#define FX_CHARSET_US 254
+#define FX_CHARSET_OEM 255
+FX_WORD FX_GetCodePageFromCharset(FX_BYTE charset);
+FX_WORD FX_GetCharsetFromCodePage(FX_WORD codepage);
+FX_WORD FX_GetCodePageFromStringA(FX_LPCSTR pStr, FX_INT32 iLength);
+FX_WORD FX_GetCodePageFormStringW(FX_LPCWSTR pStr, FX_INT32 iLength);
+FX_WORD FX_GetDefCodePageByLanguage(FX_WORD wLanguage);
+void FX_SwapByteOrder(FX_LPWSTR pStr, FX_INT32 iLength);
+void FX_SwapByteOrderCopy(FX_LPCWSTR pSrc, FX_LPWSTR pDst, FX_INT32 iLength);
+void FX_UTF16ToWChar(FX_LPVOID pBuffer, FX_INT32 iLength);
+void FX_UTF16ToWCharCopy(const FX_WORD *pUTF16, FX_LPWSTR pWChar, FX_INT32 iLength);
+void FX_WCharToUTF16(FX_LPVOID pBuffer, FX_INT32 iLength);
+void FX_WCharToUTF16Copy(FX_LPCWSTR pWChar, FX_WORD *pUTF16, FX_INT32 iLength);
+FX_INT32 FX_DecodeString(FX_WORD wCodePage, FX_LPCSTR pSrc, FX_INT32 *pSrcLen, FX_LPWSTR pDst, FX_INT32 *pDstLen, FX_BOOL bErrBreak = FALSE);
+FX_INT32 FX_UTF8Decode(FX_LPCSTR pSrc, FX_INT32 *pSrcLen, FX_LPWSTR pDst, FX_INT32 *pDstLen);
+enum FX_CODESYSTEM {
+ FX_MBCS = 0,
+ FX_SBCS ,
+ FX_DBCS ,
+};
+typedef struct _FX_CODEPAGE_HEADER {
+ FX_UINT16 uCPID;
+ FX_UINT8 uMinCharBytes;
+ FX_UINT8 uMaxCharBytes;
+ FX_CODESYSTEM eCPType;
+ FX_BOOL bHasLeadByte;
+ FX_WCHAR wMinChar;
+ FX_WCHAR wMaxChar;
+ FX_WCHAR wDefChar;
+ FX_WCHAR wMinUnicode;
+ FX_WCHAR wMaxUnicode;
+ FX_WCHAR wDefUnicode;
+} FX_CODEPAGE_HEADER;
+#define FX_CPMAPTYPE_Consecution 1
+#define FX_CPMAPTYPE_Strict 2
+#define FX_CPMAPTYPE_NoMapping 3
+#define FX_CPMAPTYPE_Delta 4
+typedef struct _FX_CPCU_MAPTABLE1 {
+ FX_UINT16 uMapType;
+ FX_UINT16 uUniocde;
+} FX_CPCU_MAPTABLE1;
+typedef struct _FX_CPCU_MAPTABLE2 {
+ FX_UINT8 uTrailByte;
+ FX_UINT8 uMapType;
+ FX_UINT16 uOffset;
+} FX_CPCU_MAPTABLE2;
+typedef struct _FX_CPCU_MAPINFO {
+ FX_CPCU_MAPTABLE1 *pMapTable1;
+ FX_CPCU_MAPTABLE2 *pMapTable2;
+ FX_LPCBYTE pMapData;
+} FX_CPCU_MAPINFO;
+typedef struct _FX_CPUC_MAPTABLE {
+ FX_UINT16 uStartUnicode;
+ FX_UINT16 uEndUnicode;
+ FX_UINT16 uMapType;
+ FX_UINT16 uOffset;
+} FX_CPUC_MAPTABLE;
+typedef struct _FX_CPUC_MAPINFO {
+ FX_UINT32 uMapCount;
+ FX_CPUC_MAPTABLE *pMapTable;
+ FX_LPCBYTE pMapData;
+} FX_CPUC_MAPINFO;
+typedef struct _FX_CODEPAGE {
+ FX_CODEPAGE_HEADER const *pCPHeader;
+ FX_CPCU_MAPINFO const *pCPCUMapInfo;
+ FX_CPUC_MAPINFO const *pCPUCMapInfo;
+} FX_CODEPAGE, * FX_LPCODEPAGE;
+typedef FX_CODEPAGE const * FX_LPCCODEPAGE;
+typedef struct _FX_STR2CPHASH {
+ FX_UINT32 uHash;
+ FX_UINT32 uCodePage;
+} FX_STR2CPHASH;
+typedef struct _FX_CHARSET_MAP {
+ FX_UINT16 charset;
+ FX_UINT16 codepage;
+} FX_CHARSET_MAP;
+typedef struct _FX_LANG2CPMAP {
+ FX_WORD wLanguage;
+ FX_WORD wCodepage;
+} FX_LANG2CPMAP;
+class IFX_CodePage
+{
+public:
+ static IFX_CodePage* Create(FX_WORD wCodePage);
+ virtual void Release() = 0;
+ virtual FX_WORD GetCodePageNumber() const = 0;
+ virtual FX_CODESYSTEM GetCodeSystemType() const = 0;
+ virtual FX_BOOL HasLeadByte() const = 0;
+ virtual FX_BOOL IsLeadByte(FX_BYTE byte) const = 0;
+ virtual FX_INT32 GetMinBytesPerChar() const = 0;
+ virtual FX_INT32 GetMaxBytesPerChar() const = 0;
+ virtual FX_WCHAR GetMinCharcode() const = 0;
+ virtual FX_WCHAR GetMaxCharcode() const = 0;
+ virtual FX_WCHAR GetDefCharcode() const = 0;
+ virtual FX_WCHAR GetMinUnicode() const = 0;
+ virtual FX_WCHAR GetMaxUnicode() const = 0;
+ virtual FX_WCHAR GetDefUnicode() const = 0;
+ virtual FX_BOOL IsValidCharcode(FX_WORD wCharcode) const = 0;
+ virtual FX_WCHAR GetUnicode(FX_WORD wCharcode) const = 0;
+ virtual FX_BOOL IsValidUnicode(FX_WCHAR wUnicode) const = 0;
+ virtual FX_WORD GetCharcode(FX_WCHAR wUnicode) const = 0;
+};
+#endif
diff --git a/xfa/src/fgas/include/fx_datetime.h b/xfa/src/fgas/include/fx_datetime.h
new file mode 100644
index 0000000000..dd0a5d6147
--- /dev/null
+++ b/xfa/src/fgas/include/fx_datetime.h
@@ -0,0 +1,470 @@
+// 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_DATETIME_H_
+#define _FX_DATETIME_H_
+class CFX_Unitime;
+class CFX_DateTime;
+typedef FX_INT64 FX_UNITIME;
+enum FX_WEEKDAY {
+ FX_Sunday = 0,
+ FX_Monday ,
+ FX_Tuesday ,
+ FX_Wednesday ,
+ FX_Thursday ,
+ FX_Friday ,
+ FX_Saturday ,
+};
+FX_BOOL FX_IsLeapYear(FX_INT32 iYear);
+FX_INT32 FX_DaysInYear(FX_INT32 iYear);
+FX_BYTE FX_DaysInMonth(FX_INT32 iYear, FX_BYTE iMonth);
+class CFX_Unitime : public CFX_Object
+{
+public:
+ CFX_Unitime()
+ {
+ m_iUnitime = 0;
+ }
+ CFX_Unitime(FX_UNITIME iUnitime)
+ {
+ m_iUnitime = iUnitime;
+ }
+ CFX_Unitime(const CFX_Unitime &unitime)
+ {
+ m_iUnitime = unitime.m_iUnitime;
+ }
+ operator FX_UNITIME * ()
+ {
+ return &m_iUnitime;
+ }
+ operator FX_UNITIME const * () const
+ {
+ return &m_iUnitime;
+ }
+ operator FX_UNITIME& ()
+ {
+ return m_iUnitime;
+ }
+ operator const FX_UNITIME& () const
+ {
+ return m_iUnitime;
+ }
+ CFX_Unitime& operator = (const CFX_Unitime &t)
+ {
+ m_iUnitime = t.m_iUnitime;
+ return *this;
+ }
+ CFX_Unitime& operator = (FX_UNITIME t)
+ {
+ m_iUnitime = t;
+ return *this;
+ }
+ CFX_Unitime& operator += (const CFX_Unitime &t)
+ {
+ m_iUnitime += t.m_iUnitime;
+ return *this;
+ }
+ CFX_Unitime& operator += (FX_UNITIME t)
+ {
+ m_iUnitime += t;
+ return *this;
+ }
+ CFX_Unitime& operator -= (const CFX_Unitime &t)
+ {
+ m_iUnitime -= t.m_iUnitime;
+ return *this;
+ }
+ CFX_Unitime& operator -= (FX_UNITIME t)
+ {
+ m_iUnitime -= t;
+ return *this;
+ }
+ void Now();
+ void SetGMTime();
+ void Set(FX_INT32 year, FX_BYTE month, FX_BYTE day, FX_BYTE hour = 0, FX_BYTE minute = 0, FX_BYTE second = 0, FX_WORD millisecond = 0);
+ void Set(FX_UNITIME t);
+ FX_INT32 GetYear() const;
+ FX_BYTE GetMonth() const;
+ FX_BYTE GetDay() const;
+ FX_WEEKDAY GetDayOfWeek() const;
+ FX_WORD GetDayOfYear() const;
+ FX_INT64 GetDayOfAD() const;
+ FX_BYTE GetHour() const;
+ FX_BYTE GetMinute() const;
+ FX_BYTE GetSecond() const;
+ FX_WORD GetMillisecond() const;
+ FX_BOOL AddYears(FX_INT32 iYears);
+ FX_BOOL AddMonths(FX_INT32 iMonths);
+ FX_BOOL AddDays(FX_INT32 iDays);
+ FX_BOOL AddHours(FX_INT32 iHours);
+ FX_BOOL AddMinutes(FX_INT32 iMinutes);
+ FX_BOOL AddSeconds(FX_INT32 iSeconds);
+ FX_BOOL AddMilliseconds(FX_INT32 iMilliseconds);
+ friend CFX_Unitime operator + (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime);
+ }
+ friend CFX_Unitime operator + (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return CFX_Unitime(t1.m_iUnitime + t2);
+ }
+ friend CFX_Unitime operator + (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return CFX_Unitime(t1 + t2.m_iUnitime);
+ }
+ friend CFX_Unitime operator - (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime);
+ }
+ friend CFX_Unitime operator - (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return CFX_Unitime(t1.m_iUnitime + t2);
+ }
+ friend CFX_Unitime operator - (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return CFX_Unitime(t1 + t2.m_iUnitime);
+ }
+ friend FX_BOOL operator == (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return t1.m_iUnitime == t2.m_iUnitime;
+ }
+ friend FX_BOOL operator == (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return t1.m_iUnitime == t2;
+ }
+ friend FX_BOOL operator == (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return t1 == t2.m_iUnitime;
+ }
+ friend FX_BOOL operator != (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return t1.m_iUnitime != t2.m_iUnitime;
+ }
+ friend FX_BOOL operator != (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return t1.m_iUnitime != t2;
+ }
+ friend FX_BOOL operator != (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return t1 != t2.m_iUnitime;
+ }
+ friend FX_BOOL operator > (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return t1.m_iUnitime > t2.m_iUnitime;
+ }
+ friend FX_BOOL operator > (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return t1.m_iUnitime > t2;
+ }
+ friend FX_BOOL operator > (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return t1 > t2.m_iUnitime;
+ }
+ friend FX_BOOL operator >= (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return t1.m_iUnitime >= t2.m_iUnitime;
+ }
+ friend FX_BOOL operator >= (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return t1.m_iUnitime >= t2;
+ }
+ friend FX_BOOL operator >= (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return t1 >= t2.m_iUnitime;
+ }
+ friend FX_BOOL operator < (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return t1.m_iUnitime < t2.m_iUnitime;
+ }
+ friend FX_BOOL operator < (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return t1.m_iUnitime < t2;
+ }
+ friend FX_BOOL operator < (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return t1 < t2.m_iUnitime;
+ }
+ friend FX_BOOL operator <= (const CFX_Unitime &t1, const CFX_Unitime &t2)
+ {
+ return t1.m_iUnitime <= t2.m_iUnitime;
+ }
+ friend FX_BOOL operator <= (const CFX_Unitime &t1, FX_UNITIME t2)
+ {
+ return t1.m_iUnitime <= t2;
+ }
+ friend FX_BOOL operator <= (FX_UNITIME t1, const CFX_Unitime &t2)
+ {
+ return t1 <= t2.m_iUnitime;
+ }
+private:
+ FX_UNITIME m_iUnitime;
+};
+#if _FX_OS_ != _FX_ANDROID_
+#pragma pack(push, 1)
+#endif
+typedef struct _FX_DATE {
+ FX_INT32 year;
+ FX_BYTE month;
+ FX_BYTE day;
+} FX_DATE, * FX_LPDATE;
+typedef FX_DATE const * FX_LPCDATE;
+typedef struct _FX_TIME {
+ FX_BYTE hour;
+ FX_BYTE minute;
+ FX_BYTE second;
+ FX_WORD millisecond;
+} FX_TIME, * FX_LPTIME;
+typedef FX_TIME const * FX_LPCTIME;
+typedef struct _FX_TIMEZONE {
+ FX_INT8 tzHour;
+ FX_BYTE tzMinute;
+} FX_TIMEZONE, * FX_LPTIMEZONE;
+typedef FX_TIMEZONE const * FX_LPCTIMEZONE;
+typedef struct _FX_DATETIME {
+ union {
+ struct {
+ FX_INT32 year;
+ FX_BYTE month;
+ FX_BYTE day;
+ } sDate;
+ FX_DATE aDate;
+ } Date;
+ union {
+ struct {
+ FX_BYTE hour;
+ FX_BYTE minute;
+ FX_BYTE second;
+ FX_WORD millisecond;
+ } sTime;
+ FX_TIME aTime;
+ } Time;
+} FX_DATETIME, * FX_LPDATETIME;
+typedef FX_DATETIME const * FX_LPCDATETIME;
+typedef struct _FX_DATETIMEZONE {
+ union {
+ struct {
+ union {
+ struct {
+ FX_INT32 year;
+ FX_BYTE month;
+ FX_BYTE day;
+ };
+ FX_DATE date;
+ };
+ union {
+ struct {
+ FX_BYTE hour;
+ FX_BYTE minute;
+ FX_BYTE second;
+ FX_WORD millisecond;
+ };
+ FX_TIME time;
+ };
+ };
+ FX_DATETIME dt;
+ };
+ union {
+ struct {
+ FX_INT8 tzHour;
+ FX_BYTE tzMinute;
+ };
+ FX_TIMEZONE tz;
+ };
+} FX_DATETIMEZONE, * FX_LPDATETIMEZONE;
+typedef FX_DATETIMEZONE const * FX_LPCDATETIMEZONE;
+#if _FX_OS_ != _FX_ANDROID_
+#pragma pack(pop)
+#endif
+class CFX_DateTime : public CFX_Object
+{
+public:
+ CFX_DateTime() {}
+ CFX_DateTime(const FX_DATETIME &dt)
+ {
+ m_DateTime = dt;
+ }
+ CFX_DateTime(const CFX_DateTime &dt)
+ {
+ m_DateTime = dt.m_DateTime;
+ }
+ operator FX_DATETIME * ()
+ {
+ return &m_DateTime;
+ }
+ operator FX_DATETIME const * () const
+ {
+ return &m_DateTime;
+ }
+ operator FX_DATETIME& ()
+ {
+ return m_DateTime;
+ }
+ operator const FX_DATETIME& () const
+ {
+ return m_DateTime;
+ }
+ CFX_DateTime& operator = (const CFX_DateTime &dt)
+ {
+ m_DateTime = dt.m_DateTime;
+ return *this;
+ }
+ CFX_DateTime& operator = (const FX_DATETIME &dt)
+ {
+ m_DateTime = dt;
+ return *this;
+ }
+ CFX_DateTime& operator += (const CFX_DateTime &dt)
+ {
+ FromUnitime(ToUnitime() + dt.ToUnitime());
+ return *this;
+ }
+ CFX_DateTime& operator += (const FX_DATETIME &dt)
+ {
+ FromUnitime(ToUnitime() + ((const CFX_DateTime&)dt).ToUnitime());
+ return *this;
+ }
+ CFX_DateTime& operator -= (const CFX_DateTime &dt)
+ {
+ FromUnitime(ToUnitime() - dt.ToUnitime());
+ return *this;
+ }
+ CFX_DateTime& operator -= (const FX_DATETIME &dt)
+ {
+ FromUnitime(ToUnitime() - ((const CFX_DateTime&)dt).ToUnitime());
+ return *this;
+ }
+ virtual FX_BOOL Set(FX_INT32 year, FX_BYTE month, FX_BYTE day, FX_BYTE hour = 0, FX_BYTE minute = 0, FX_BYTE second = 0, FX_WORD millisecond = 0);
+ virtual FX_BOOL FromUnitime(FX_UNITIME t);
+ virtual FX_UNITIME ToUnitime() const;
+ virtual FX_INT32 GetYear() const;
+ virtual FX_BYTE GetMonth() const;
+ virtual FX_BYTE GetDay() const;
+ virtual FX_WEEKDAY GetDayOfWeek() const;
+ virtual FX_WORD GetDayOfYear() const;
+ virtual FX_INT64 GetDayOfAD() const;
+ virtual FX_BYTE GetHour() const;
+ virtual FX_BYTE GetMinute() const;
+ virtual FX_BYTE GetSecond() const;
+ virtual FX_WORD GetMillisecond() const;
+ virtual FX_BOOL AddYears(FX_INT32 iYears);
+ virtual FX_BOOL AddMonths(FX_INT32 iMonths);
+ virtual FX_BOOL AddDays(FX_INT32 iDays);
+ virtual FX_BOOL AddHours(FX_INT32 iHours);
+ virtual FX_BOOL AddMinutes(FX_INT32 iMinutes);
+ virtual FX_BOOL AddSeconds(FX_INT32 iSeconds);
+ virtual FX_BOOL AddMilliseconds(FX_INT32 iMilliseconds);
+ friend CFX_DateTime operator + (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() + dt2.ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator + (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() + ((const CFX_DateTime&)dt2).ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator + (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ CFX_DateTime dt;
+ dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() + dt2.ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator - (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() - dt2.ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator - (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() - ((const CFX_DateTime&)dt2).ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator - (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ CFX_DateTime dt;
+ dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() - dt2.ToUnitime());
+ return dt;
+ }
+ friend FX_BOOL operator == (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) == 0;
+ }
+ friend FX_BOOL operator == (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, &dt2, sizeof(FX_DATETIME)) == 0;
+ }
+ friend FX_BOOL operator == (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ return FXSYS_memcmp(&dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) == 0;
+ }
+ friend FX_BOOL operator != (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) != 0;
+ }
+ friend FX_BOOL operator != (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, &dt2, sizeof(FX_DATETIME)) != 0;
+ }
+ friend FX_BOOL operator != (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ return FXSYS_memcmp(&dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) != 0;
+ }
+ friend FX_BOOL operator > (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ return dt1.ToUnitime() > dt2.ToUnitime();
+ }
+ friend FX_BOOL operator > (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ return dt1.ToUnitime() > ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator > (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ return ((const CFX_DateTime&)dt1).ToUnitime() > dt2.ToUnitime();
+ }
+ friend FX_BOOL operator >= (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ return dt1.ToUnitime() >= dt2.ToUnitime();
+ }
+ friend FX_BOOL operator >= (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ return dt1.ToUnitime() >= ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator >= (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ return ((const CFX_DateTime&)dt1).ToUnitime() >= dt2.ToUnitime();
+ }
+ friend FX_BOOL operator < (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ return dt1.ToUnitime() < dt2.ToUnitime();
+ }
+ friend FX_BOOL operator < (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ return dt1.ToUnitime() < ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator < (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ return ((const CFX_DateTime&)dt1).ToUnitime() < dt2.ToUnitime();
+ }
+ friend FX_BOOL operator <= (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
+ {
+ return dt1.ToUnitime() <= dt2.ToUnitime();
+ }
+ friend FX_BOOL operator <= (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
+ {
+ return dt1.ToUnitime() <= ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator <= (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
+ {
+ return ((const CFX_DateTime&)dt1).ToUnitime() <= dt2.ToUnitime();
+ }
+private:
+ FX_DATETIME m_DateTime;
+};
+#endif
diff --git a/xfa/src/fgas/include/fx_fnt.h b/xfa/src/fgas/include/fx_fnt.h
new file mode 100644
index 0000000000..d664853df7
--- /dev/null
+++ b/xfa/src/fgas/include/fx_fnt.h
@@ -0,0 +1,170 @@
+// 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
+#define _FX_FONT
+class IFX_Font;
+class IFX_FontMgr;
+#define FX_FONTSTYLE_Normal 0x00
+#define FX_FONTSTYLE_FixedPitch 0x01
+#define FX_FONTSTYLE_Serif 0x02
+#define FX_FONTSTYLE_Symbolic 0x04
+#define FX_FONTSTYLE_Script 0x08
+#define FX_FONTSTYLE_Italic 0x40
+#define FX_FONTSTYLE_Bold 0x40000
+#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold|FX_FONTSTYLE_Italic)
+#define FX_FONTSTYLE_ExactMatch 0x80000000
+#define FX_FONTDECORATION_Underline 0x00000001
+#define FX_FONTDECORATION_Strikeout 0x00000002
+#define FX_FONTDECORATION_Overline 0x00000004
+#define FX_FONTDECORATION_Emphasis 0x00000008
+#define FX_FONTDECORATION_Superscript 0x00000010
+#define FX_FONTDECORATION_Subscript 0x00000020
+#define FX_FONTDECORATION_SmallCapital 0x00000040
+#define FX_FONTDECORATION_Capital 0x00000080
+#define FX_FONTDECORATION_Lowercase 0x000000C0
+#define FX_FONTDECORATION_Raised 0x00000100
+#define FX_FONTDECORATION_Sunken 0x00000200
+#define FX_FONTDECORATION_Shadow 0x00000400
+#define FX_FONTDECORATION_BoundingShape 0x20000000
+#define FX_FONTDECORATION_Hide 0x40000000
+#define FX_FONTDECORATION_StrokeFill 0x80000000
+#define FX_BOUNDINGSHAPE_None 0
+#define FX_BOUNDINGSHAPE_Circle 1
+#define FX_BOUNDINGSHAPE_Square 2
+#define FX_BOUNDINGSHAPE_Triangle 3
+#define FX_BOUNDINGSHAPE_Diamond 4
+class IFX_FontProvider
+{
+public:
+ virtual FX_BOOL GetCharWidth(IFX_Font* pFont, FX_WCHAR wUnicode, FX_INT32 &iWidth, FX_BOOL bCharCode = FALSE) = 0;
+};
+class IFX_Font
+{
+public:
+ static IFX_Font* LoadFont(FX_LPCWSTR pszFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage, IFX_FontMgr *pFontMgr);
+ static IFX_Font* LoadFont(FX_LPCBYTE pBuffer, FX_INT32 iLength, IFX_FontMgr *pFontMgr);
+ static IFX_Font* LoadFont(FX_LPCWSTR pszFileName, IFX_FontMgr *pFontMgr);
+ static IFX_Font* LoadFont(IFX_Stream *pFontStream, IFX_FontMgr *pFontMgr, FX_BOOL bSaveStream = FALSE);
+ static IFX_Font* LoadFont(CFX_Font *pExtFont, IFX_FontMgr *pFontMgr, FX_BOOL bTakeOver = FALSE);
+ virtual void Release() = 0;
+ virtual IFX_Font* Retain() = 0;
+ virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0) = 0;
+ virtual void GetFamilyName(CFX_WideString &wsFamily) const = 0;
+ virtual void GetPsName(CFX_WideString &wsName) const = 0;
+ virtual FX_DWORD GetFontStyles() const = 0;
+ virtual FX_BYTE GetCharSet() const = 0;
+ virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, FX_INT32 &iWidth, FX_BOOL bCharCode = FALSE) = 0;
+ virtual FX_INT32 GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE) = 0;
+ virtual FX_INT32 GetAscent() const = 0;
+ virtual FX_INT32 GetDescent() const = 0;
+ virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, CFX_Rect &bbox, FX_BOOL bCharCode = FALSE) = 0;
+ virtual FX_BOOL GetBBox(CFX_Rect &bbox) = 0;
+ virtual FX_INT32 GetItalicAngle() const = 0;
+ virtual void Reset() = 0;
+ virtual IFX_Font* GetSubstFont(FX_INT32 iGlyphIndex) const = 0;
+ virtual void* GetDevFont() const = 0;
+ virtual void SetFontProvider(IFX_FontProvider* pProvider) = 0;
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) = 0;
+#endif
+};
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+typedef struct _FX_FONTMATCHPARAMS : public CFX_Object {
+ FX_LPCWSTR pwsFamily;
+ FX_DWORD dwFontStyles;
+ FX_DWORD dwUSB;
+ FX_DWORD dwMatchFlags;
+ FX_WCHAR wUnicode;
+ FX_WORD wCodePage;
+} FX_FONTMATCHPARAMS, * FX_LPFONTMATCHPARAMS;
+typedef FX_FONTMATCHPARAMS const * FX_LPCFONTMATCHPARAMS;
+typedef struct _FX_FONTSIGNATURE : public CFX_Target {
+ FX_DWORD fsUsb[4];
+ FX_DWORD fsCsb[2];
+} FX_FONTSIGNATURE;
+typedef struct _FX_FONTDESCRIPTOR : public CFX_Target {
+ FX_WCHAR wsFontFace[32];
+ FX_DWORD dwFontStyles;
+ FX_BYTE uCharSet;
+ FX_FONTSIGNATURE FontSignature;
+} FX_FONTDESCRIPTOR, * FX_LPFONTDESCRIPTOR;
+typedef FX_FONTDESCRIPTOR const * FX_LPCFONTDESCRIPTOR;
+typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors;
+inline FX_BOOL operator == (const FX_FONTDESCRIPTOR &left, const FX_FONTDESCRIPTOR &right)
+{
+ return left.uCharSet == right.uCharSet
+ && left.dwFontStyles == right.dwFontStyles
+ && FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0
+ && FXSYS_memcmp(&left.FontSignature, &right.FontSignature, sizeof(FX_FONTSIGNATURE)) == 0;
+}
+#define FX_FONTMATCHPARA_MacthStyle 0x01
+#define FX_FONTMATCHPARA_MacthFamily 0x02
+#define FX_FONTMATCHPARA_MacthUnicode 0x04
+typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors &fonts, FX_LPVOID pUserData, FX_LPCWSTR pwsFaceName, FX_WCHAR wUnicode);
+FX_LPEnumAllFonts FX_GetDefFontEnumerator();
+typedef FX_LPCFONTDESCRIPTOR (*FX_LPMatchFont)(FX_LPFONTMATCHPARAMS pParams, const CFX_FontDescriptors &fonts, FX_LPVOID pUserData);
+FX_LPMatchFont FX_GetDefFontMatchor();
+class IFX_FontMgr
+{
+public:
+ static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator, FX_LPMatchFont pMatcher = NULL, FX_LPVOID pUserData = NULL);
+ virtual void Release() = 0;
+ virtual IFX_Font* GetDefFontByCodePage(FX_WORD wCodePage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByCharset(FX_BYTE nCharset, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByLanguage(FX_WORD wLanguage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* LoadFont(FX_LPCWSTR pszFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage = 0xFFFF) = 0;
+ virtual IFX_Font* LoadFont(FX_LPCBYTE pBuffer, FX_INT32 iLength) = 0;
+ virtual IFX_Font* LoadFont(FX_LPCWSTR pszFileName) = 0;
+ virtual IFX_Font* LoadFont(IFX_Stream *pFontStream, FX_LPCWSTR pszFontAlias = NULL, FX_DWORD dwFontStyles = 0, FX_WORD wCodePage = 0, FX_BOOL bSaveStream = FALSE) = 0;
+ virtual IFX_Font* LoadFont(IFX_Font *pSrcFont, FX_DWORD dwFontStyles, FX_WORD wCodePage = 0xFFFF) = 0;
+ virtual void ClearFontCache() = 0;
+ virtual void RemoveFont(IFX_Font *pFont) = 0;
+};
+#else
+class IFX_FontMgrDelegate
+{
+public:
+ virtual IFX_Font* GetDefFontByCodePage(IFX_FontMgr* pFontMgr, FX_WORD wCodePage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByCharset(IFX_FontMgr* pFontMgr, FX_BYTE nCharset, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByUnicode(IFX_FontMgr* pFontMgr, FX_WCHAR wUnicode, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByLanguage(IFX_FontMgr* pFontMgr, FX_WORD wLanguage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+};
+class IFX_FontSourceEnum
+{
+public:
+ virtual void Release() = 0;
+ virtual FX_POSITION GetStartPosition(FX_LPVOID pUserData = NULL) = 0;
+ virtual IFX_FileAccess* GetNext(FX_POSITION& pos, FX_LPVOID pUserData = NULL) = 0;
+};
+IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum();
+class IFX_FontMgr
+{
+public:
+ static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum, IFX_FontMgrDelegate* pDelegate = NULL, FX_LPVOID pUserData = NULL);
+ virtual void Release() = 0;
+ virtual IFX_Font* GetDefFontByCodePage(FX_WORD wCodePage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByCharset(FX_BYTE nCharset, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetDefFontByLanguage(FX_WORD wLanguage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ inline IFX_Font* LoadFont(FX_LPCWSTR pszFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage)
+ {
+ return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
+ }
+ virtual IFX_Font* GetFontByCharset(FX_BYTE nCharset, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage, FX_DWORD dwFontStyles, FX_LPCWSTR pszFontFamily = NULL) = 0;
+ virtual IFX_Font* LoadFont(FX_LPCBYTE pBuffer, FX_INT32 iLength, FX_INT32 iFaceIndex, FX_INT32* pFaceCount = NULL) = 0;
+ virtual IFX_Font* LoadFont(FX_LPCWSTR pszFileName, FX_INT32 iFaceIndex, FX_INT32* pFaceCount = NULL) = 0;
+ virtual IFX_Font* LoadFont(IFX_Stream *pFontStream, FX_INT32 iFaceIndex, FX_INT32* pFaceCount = NULL, FX_BOOL bSaveStream = FALSE) = 0;
+
+ virtual void ClearFontCache() = 0;
+ virtual void RemoveFont(IFX_Font *pFont) = 0;
+};
+#endif
+#endif
diff --git a/xfa/src/fgas/include/fx_lbk.h b/xfa/src/fgas/include/fx_lbk.h
new file mode 100644
index 0000000000..3c7aa5d7dd
--- /dev/null
+++ b/xfa/src/fgas/include/fx_lbk.h
@@ -0,0 +1,27 @@
+// 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_LINEBREAK
+#define _FX_LINEBREAK
+enum FX_LINEBREAKTYPE {
+ FX_LBT_UNKNOWN = 0x00,
+ FX_LBT_DIRECT_BRK = 0x1A,
+ FX_LBT_INDIRECT_BRK = 0x2B,
+ FX_LBT_COM_INDIRECT_BRK = 0x3C,
+ FX_LBT_COM_PROHIBITED_BRK = 0x4D,
+ FX_LBT_PROHIBITED_BRK = 0x5E,
+ FX_LBT_HANGUL_SPACE_BRK = 0x6F,
+};
+#define FX_LBUN FX_LBT_UNKNOWN
+#define FX_LBDB FX_LBT_DIRECT_BRK
+#define FX_LBIB FX_LBT_INDIRECT_BRK
+#define FX_LBCB FX_LBT_COM_INDIRECT_BRK
+#define FX_LBCP FX_LBT_COM_PROHIBITED_BRK
+#define FX_LBPB FX_LBT_PROHIBITED_BRK
+#define FX_LBHS FX_LBT_HANGUL_SPACE_BRK
+void FX_GetLineBreakPositions(FX_LPCWSTR pwsText, FX_LINEBREAKTYPE *pBrkType, FX_INT32 iLength);
+void FX_GetLineBreakPositions(FX_LPCWSTR pwsText, FX_INT32 iLength, CFX_Int32MassArray &bp);
+#endif
diff --git a/xfa/src/fgas/include/fx_lgg.h b/xfa/src/fgas/include/fx_lgg.h
new file mode 100644
index 0000000000..6f4786e319
--- /dev/null
+++ b/xfa/src/fgas/include/fx_lgg.h
@@ -0,0 +1,267 @@
+// 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_LANGUAGE
+#define _FX_LANGUAGE
+#define FX_LANG_Neutral 0x0000
+#define FX_LANG_Invariant 0x007f
+#define FX_LANG_UserDefault 0x0400
+#define FX_LANG_SystemDefault 0x0800
+#define FX_LANG_Afrikaans_SouthAfrica 0x0436
+#define FX_LANG_Albanian_Albania 0x041c
+#define FX_LANG_Alsatian_France 0x0484
+#define FX_LANG_Amharic_Ethiopia 0x045e
+#define FX_LANG_Arabic_Algeria 0x1401
+#define FX_LANG_Arabic_Bahrain 0x3c01
+#define FX_LANG_Arabic_Egypt 0x0c01
+#define FX_LANG_Arabic_Iraq 0x0801
+#define FX_LANG_Arabic_Jordan 0x2c01
+#define FX_LANG_Arabic_Kuwait 0x3401
+#define FX_LANG_Arabic_Lebanon 0x3001
+#define FX_LANG_Arabic_Libya 0x1001
+#define FX_LANG_Arabic_Morocco 0x1801
+#define FX_LANG_Arabic_Oman 0x2001
+#define FX_LANG_Arabic_Qatar 0x4001
+#define FX_LANG_Arabic_SaudiArabia 0x0401
+#define FX_LANG_Arabic_Syria 0x2801
+#define FX_LANG_Arabic_Tunisia 0x1c01
+#define FX_LANG_Arabic_UAE 0x3801
+#define FX_LANG_Arabic_Yemen 0x2401
+#define FX_LANG_Armenian_Armenia 0x042b
+#define FX_LANG_Assamese_India 0x044d
+#define FX_LANG_Azerbaijan_Cyrillic 0x082c
+#define FX_LANG_Azerbaijan_Latin 0x042c
+#define FX_LANG_Bashkir_Russia 0x046d
+#define FX_LANG_Basque_Basque 0x042d
+#define FX_LANG_Belarusian_Belarus 0x0423
+#define FX_LANG_Bengali_Bangladesh 0x0845
+#define FX_LANG_Bengali_India 0x0445
+#define FX_LANG_Bosnia_Herzegovina 0x101a
+#define FX_LANG_Bosnian_Cyrillic 0x201a
+#define FX_LANG_Bosnian_Latin 0x141a
+#define FX_LANG_Breton_France 0x047e
+#define FX_LANG_Bulgarian_Bulgaria 0x0402
+#define FX_LANG_Burmese 0x0455
+#define FX_LANG_Catalan_Catalan 0x0403
+#define FX_LANG_Cherokee 0x045c
+#define FX_LANG_Chinese_HongKong 0x0c04
+#define FX_LANG_Chinese_Macao 0x1404
+#define FX_LANG_Chinese_PRC 0x0804
+#define FX_LANG_Chinese_Singapore 0x1004
+#define FX_LANG_Chinese_Taiwan 0x0404
+#define FX_LANG_Corsican_France 0x0483
+#define FX_LANG_Croatian_Croatia 0x041a
+#define FX_LANG_Croatian_Latin 0x101a
+#define FX_LANG_CustomCurrent 0x0c00
+#define FX_LANG_CzechRepublic 0x0405
+#define FX_LANG_Danish_Denmark 0x0406
+#define FX_LANG_Dari_Afghanistan 0x048c
+#define FX_LANG_Divehi_Maldives 0x0465
+#define FX_LANG_Dutch_Belgium 0x0813
+#define FX_LANG_Dutch_Netherlands 0x0413
+#define FX_LANG_Dutch_Preferred 0x0013
+#define FX_LANG_Dzongkha 0x0851
+#define FX_LANG_Edo 0x0466
+#define FX_LANG_English_Australia 0x0c09
+#define FX_LANG_English_Belize 0x2809
+#define FX_LANG_English_Canada 0x1009
+#define FX_LANG_English_Caribbean 0x2409
+#define FX_LANG_English_HongKong 0x3c09
+#define FX_LANG_English_India 0x4009
+#define FX_LANG_English_Indonesia 0x3809
+#define FX_LANG_English_Ireland 0x1809
+#define FX_LANG_English_Jamaica 0x2009
+#define FX_LANG_English_Malaysia 0x4409
+#define FX_LANG_English_NewZealand 0x1409
+#define FX_LANG_English_Philippines 0x3409
+#define FX_LANG_English_Singapore 0x4809
+#define FX_LANG_English_SouthAfrica 0x1c09
+#define FX_LANG_English_TrinidadTobago 0x2c09
+#define FX_LANG_English_UnitedKingdom 0x0809
+#define FX_LANG_English_UnitedStates 0x0409
+#define FX_LANG_English_Zimbabwe 0x3009
+#define FX_LANG_Estonian_Estonia 0x0425
+#define FX_LANG_Faroese_FaroeIslands 0x0438
+#define FX_LANG_Filipino_Philippines 0x0464
+#define FX_LANG_Finnish_Finland 0x040b
+#define FX_LANG_French_Belgium 0x080c
+#define FX_LANG_French_Cameroon 0x2c0c
+#define FX_LANG_French_Canada 0x0c0c
+#define FX_LANG_French_CongoDRC 0x240c
+#define FX_LANG_French_CotedIvoire 0x300c
+#define FX_LANG_French_France 0x040c
+#define FX_LANG_French_Haiti 0x3c0c
+#define FX_LANG_French_Luxembourg 0x140c
+#define FX_LANG_French_Mali 0x340c
+#define FX_LANG_French_Monaco 0x180c
+#define FX_LANG_French_Morocco 0x380c
+#define FX_LANG_French_Reunion 0x200c
+#define FX_LANG_French_Senegal 0x280c
+#define FX_LANG_French_Switzerland 0x100c
+#define FX_LANG_French_WestIndies 0x1c0c
+#define FX_LANG_Frisian_Netherlands 0x0462
+#define FX_LANG_Fulfulde 0x0467
+#define FX_LANG_Gaelic_Ireland 0x083c
+#define FX_LANG_Gaelic_Scotland 0x043c
+#define FX_LANG_Galician_Galician 0x0456
+#define FX_LANG_Georgian_Georgia 0x0437
+#define FX_LANG_German_Austria 0x0c07
+#define FX_LANG_German_Germany 0x0407
+#define FX_LANG_German_Liechtenstein 0x1407
+#define FX_LANG_German_Luxembourg 0x1007
+#define FX_LANG_German_Switzerland 0x0807
+#define FX_LANG_Greek_Greece 0x0408
+#define FX_LANG_Greenlandic_Greenland 0x046f
+#define FX_LANG_Guarani 0x0474
+#define FX_LANG_Gujarati_India 0x0447
+#define FX_LANG_Hausa_LatinNigeria 0x0468
+#define FX_LANG_Hawaiian 0x0475
+#define FX_LANG_Hebrew_Israel 0x040d
+#define FX_LANG_Hindi_India 0x0439
+#define FX_LANG_Hungarian_Hungary 0x040e
+#define FX_LANG_Ibibio_Nigeria 0x0469
+#define FX_LANG_Icelandic_Iceland 0x040f
+#define FX_LANG_Igbo_Nigeria 0x0470
+#define FX_LANG_Indonesian_Indonesia 0x0421
+#define FX_LANG_Inuktitut_LatinCanada 0x085d
+#define FX_LANG_Inuktitut_SyllabicsCanada 0x045d
+#define FX_LANG_IsiXhosa_SouthAfrica 0x0434
+#define FX_LANG_IsiZulu_SouthAfrica 0x0435
+#define FX_LANG_Italian_Italy 0x0410
+#define FX_LANG_Italian_Switzerland 0x0810
+#define FX_LANG_Japanese_Japan 0x0411
+#define FX_LANG_Kannada_India 0x044b
+#define FX_LANG_Kanuri 0x0471
+#define FX_LANG_Kashmiri 0x0860
+#define FX_LANG_Kashmiri_Arabic 0x0460
+#define FX_LANG_Kazakh_Kazakhstan 0x043f
+#define FX_LANG_Khmer_Cambodia 0x0453
+#define FX_LANG_Kiche_Guatemala 0x0486
+#define FX_LANG_Kinyarwanda_Rwanda 0x0487
+#define FX_LANG_Kiswahili_Kenya 0x0441
+#define FX_LANG_Konkani_India 0x0457
+#define FX_LANG_Korean_Korea 0x0412
+#define FX_LANG_Kyrgyz_Kyrgyzstan 0x0440
+#define FX_LANG_Lao_LaoPDR 0x0454
+#define FX_LANG_Latin 0x0476
+#define FX_LANG_Latvian_Latvia 0x0426
+#define FX_LANG_Lithuanian_Lithuania 0x0427
+#define FX_LANG_LithuanianTrad 0x0827
+#define FX_LANG_Lower Sorbian_Germany 0x082e
+#define FX_LANG_Luxembourgish_Luxembourg 0x046e
+#define FX_LANG_Macedonian 0x042f
+#define FX_LANG_Malay_BruneiDarussalam 0x083e
+#define FX_LANG_Malay_Malaysia 0x043e
+#define FX_LANG_Malayalam_India 0x044c
+#define FX_LANG_Maldivian 0x0465
+#define FX_LANG_Maltese_Malta 0x043a
+#define FX_LANG_Manipuri 0x0458
+#define FX_LANG_Maori_NewZealand 0x0481
+#define FX_LANG_Mapudungun_Chile 0x047a
+#define FX_LANG_Marathi_India 0x044e
+#define FX_LANG_Mohawk_Mohawk 0x047c
+#define FX_LANG_Mongolian_CyrillicMongolia 0x0450
+#define FX_LANG_Mongolian_TraditionalMongolian 0x0850
+#define FX_LANG_Nepali_India 0x0861
+#define FX_LANG_Nepali_Nepal 0x0461
+#define FX_LANG_Norwegian_Bokmal 0x0414
+#define FX_LANG_Norwegian_Nynorsk 0x0814
+#define FX_LANG_Occitan_France 0x0482
+#define FX_LANG_Oriya_India 0x0448
+#define FX_LANG_Oromo 0x0472
+#define FX_LANG_Papiamentu 0x0479
+#define FX_LANG_Pashto_Afghanistan 0x0463
+#define FX_LANG_Persian 0x0429
+#define FX_LANG_Polish_Poland 0x0415
+#define FX_LANG_Portuguese_Brazil 0x0416
+#define FX_LANG_Portuguese_Portugal 0x0816
+#define FX_LANG_Punjabi_India 0x0446
+#define FX_LANG_Punjabi_Pakistan 0x0846
+#define FX_LANG_Quechua_Bolivia 0x046b
+#define FX_LANG_Quechua_Ecuador 0x086b
+#define FX_LANG_Quechua_Peru 0x0c6b
+#define FX_LANG_Romanian_Moldova 0x0818
+#define FX_LANG_Romanian_Romania 0x0418
+#define FX_LANG_Romansh_Switzerland 0x0417
+#define FX_LANG_Russian_Moldova 0x0819
+#define FX_LANG_Russian_Russia 0x0419
+#define FX_LANG_Sami_InariFinland 0x243b
+#define FX_LANG_Sami_LuleNorway 0x103b
+#define FX_LANG_Sami_LuleSweden 0x143b
+#define FX_LANG_Sami_NorthernFinland 0x0c3b
+#define FX_LANG_Sami_NorthernNorway 0x043b
+#define FX_LANG_Sami_NorthernSweden 0x083b
+#define FX_LANG_Sami_SkoltFinland 0x203b
+#define FX_LANG_Sami_SouthernNorway 0x183b
+#define FX_LANG_Sami_SouthernSweden 0x1c3b
+#define FX_LANG_SanskritIndia 0x044f
+#define FX_LANG_SerbianCyrillic_BosniaHerzegovina 0x1c1a
+#define FX_LANG_SerbianCyrillic_Serbia 0x0c1a
+#define FX_LANG_SerbianLatin_BosniaHerzegovina 0x181a
+#define FX_LANG_SerbianLatin_Serbia 0x081a
+#define FX_LANG_SesothoSaLeboa 0x046c
+#define FX_LANG_Setswana_SouthAfrica 0x0432
+#define FX_LANG_Sindhi_Arabic 0x0859
+#define FX_LANG_Sindhi_Devanagari 0x0459
+#define FX_LANG_Sinhala_SriLanka 0x045b
+#define FX_LANG_Slovak_Slovakia 0x041b
+#define FX_LANG_Slovenian_Slovenia 0x0424
+#define FX_LANG_Somali 0x0477
+#define FX_LANG_Spanish_Argentina 0x2c0a
+#define FX_LANG_Spanish_Bolivia 0x400a
+#define FX_LANG_Spanish_Chile 0x340a
+#define FX_LANG_Spanish_Colombia 0x240a
+#define FX_LANG_Spanish_CostaRica 0x140a
+#define FX_LANG_Spanish_DominicanRepublic 0x1c0a
+#define FX_LANG_Spanish_Ecuador 0x300a
+#define FX_LANG_Spanish_ElSalvador 0x440a
+#define FX_LANG_Spanish_Guatemala 0x100a
+#define FX_LANG_Spanish_Honduras 0x480a
+#define FX_LANG_Spanish_Mexico 0x080a
+#define FX_LANG_Spanish_Nicaragua 0x4c0a
+#define FX_LANG_Spanish_Panama 0x180a
+#define FX_LANG_Spanish_Paraguay 0x3c0a
+#define FX_LANG_Spanish_Peru 0x280a
+#define FX_LANG_Spanish_PuertoRico 0x500a
+#define FX_LANG_Spanish_InternationalSort 0x0c0a
+#define FX_LANG_Spanish_TraditionalSort 0x040a
+#define FX_LANG_Spanish_UnitedStates 0x540a
+#define FX_LANG_Spanish_Uruguay 0x380a
+#define FX_LANG_Spanish_Venezuela 0x200a
+#define FX_LANG_Sutu_SouthAfrica 0x0430
+#define FX_LANG_Swedish_Finland 0x081d
+#define FX_LANG_Swedish_Sweden 0x041d
+#define FX_LANG_Syriac_Syria 0x045a
+#define FX_LANG_Tajik_CyrillicTajikistan 0x0428
+#define FX_LANG_Tamazight_ArabicMorocco 0x045f
+#define FX_LANG_Tamazight_LatinAlgeria 0x085f
+#define FX_LANG_Tamil_India 0x0449
+#define FX_LANG_Tatar_Russia 0x0444
+#define FX_LANG_Telugu_India 0x044a
+#define FX_LANG_Thai_Thailand 0x041e
+#define FX_LANG_TibetanPRC 0x0451
+#define FX_LANG_Tigrigna_Eritrea 0x0873
+#define FX_LANG_Tigrigna_Ethiopia 0x0473
+#define FX_LANG_Tsonga 0x0431
+#define FX_LANG_Turkish_Turkey 0x041f
+#define FX_LANG_Turkmen_Turkmenistan 0x0442
+#define FX_LANG_UighurPRC 0x0480
+#define FX_LANG_Ukrainian_Ukraine 0x0422
+#define FX_LANG_UpperSorbian_Germany 0x042e
+#define FX_LANG_Urdu_Pakistan 0x0420
+#define FX_LANG_Urdu_India 0x0820
+#define FX_LANG_Uzbek_CyrillicUzbekistan 0x0843
+#define FX_LANG_Uzbek_LatinUzbekistan 0x0443
+#define FX_LANG_Venda 0x0433
+#define FX_LANG_Vietnamese_Vietnam 0x042a
+#define FX_LANG_Welsh_UnitedKingdom 0x0452
+#define FX_LANG_Wolof_Senegal 0x0488
+#define FX_LANG_Xhosa 0x0434
+#define FX_LANG_Yakut_Russia 0x0485
+#define FX_LANG_YiPRC 0x0478
+#define FX_LANG_Yiddish 0x043d
+#define FX_LANG_Yoruba_Nigeria 0x046a
+#endif
diff --git a/xfa/src/fgas/include/fx_locale.h b/xfa/src/fgas/include/fx_locale.h
new file mode 100644
index 0000000000..6886974fd2
--- /dev/null
+++ b/xfa/src/fgas/include/fx_locale.h
@@ -0,0 +1,160 @@
+// 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_LOCALE_H_
+#define _FX_LOCALE_H_
+class CFX_Unitime;
+class IFX_Locale;
+class IFX_FormatString;
+class IFX_LocaleMgr;
+enum FX_LOCALENUMSYMBOL {
+ FX_LOCALENUMSYMBOL_Decimal,
+ FX_LOCALENUMSYMBOL_Grouping,
+ FX_LOCALENUMSYMBOL_Percent,
+ FX_LOCALENUMSYMBOL_Minus,
+ FX_LOCALENUMSYMBOL_Zero,
+ FX_LOCALENUMSYMBOL_CurrencySymbol,
+ FX_LOCALENUMSYMBOL_CurrencyName,
+};
+enum FX_LOCALEDATETIMESUBCATEGORY {
+ FX_LOCALEDATETIMESUBCATEGORY_Default,
+ FX_LOCALEDATETIMESUBCATEGORY_Short,
+ FX_LOCALEDATETIMESUBCATEGORY_Medium,
+ FX_LOCALEDATETIMESUBCATEGORY_Full,
+ FX_LOCALEDATETIMESUBCATEGORY_Long,
+};
+enum FX_LOCALENUMSUBCATEGORY {
+ FX_LOCALENUMPATTERN_Percent,
+ FX_LOCALENUMPATTERN_Currency,
+ FX_LOCALENUMPATTERN_Decimal,
+ FX_LOCALENUMPATTERN_Integer,
+};
+enum FX_LOCALECATEGORY {
+ FX_LOCALECATEGORY_Unknown,
+ FX_LOCALECATEGORY_Date,
+ FX_LOCALECATEGORY_Time,
+ FX_LOCALECATEGORY_DateTime,
+ FX_LOCALECATEGORY_Num,
+ FX_LOCALECATEGORY_Text,
+ FX_LOCALECATEGORY_Zero,
+ FX_LOCALECATEGORY_Null,
+};
+enum FX_DATETIMETYPE {
+ FX_DATETIMETYPE_Unknown,
+ FX_DATETIMETYPE_Date,
+ FX_DATETIMETYPE_Time,
+ FX_DATETIMETYPE_DateTime,
+ FX_DATETIMETYPE_TimeDate,
+};
+class IFX_Locale
+{
+public:
+ static IFX_Locale* Create(CXML_Element* pLocaleData);
+
+ virtual void Release() = 0;
+
+
+ virtual CFX_WideString GetName() = 0;
+
+ virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, CFX_WideString& wsNumSymbol) const = 0;
+ virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const = 0;
+ virtual void GetMonthName(FX_INT32 nMonth, CFX_WideString& wsMonthName, FX_BOOL bAbbr = TRUE) const = 0;
+ virtual void GetDayName(FX_INT32 nWeek, CFX_WideString& wsDayName, FX_BOOL bAbbr = TRUE) const = 0;
+ virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, FX_BOOL bAM = TRUE) const = 0;
+ virtual void GetTimeZone(FX_TIMEZONE& tz) const = 0;
+ virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const = 0;
+ virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const = 0;
+ virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const = 0;
+ virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, CFX_WideString& wsPattern) const = 0;
+};
+class IFX_LocaleMgr
+{
+public:
+ virtual void Release() = 0;
+ virtual FX_WORD GetDefLocaleID() = 0;
+ virtual IFX_Locale* GetDefLocale() = 0;
+ virtual IFX_Locale* GetLocale(FX_WORD lcid) = 0;
+ virtual IFX_Locale* GetLocaleByName(FX_WSTR wsLocaleName) = 0;
+};
+IFX_LocaleMgr* FX_LocaleMgr_Create(FX_LPCWSTR pszLocalPath, FX_WORD wDefaultLCID);
+void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult);
+FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_Unitime& datetime);
+FX_BOOL FX_TimeFromCanonical(FX_WSTR wsTime, CFX_Unitime& datetime, IFX_Locale* pLocale);
+class IFX_FormatString
+{
+public:
+ static IFX_FormatString* Create(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID);
+
+ virtual void Release() = 0;
+ virtual void SplitFormatString(const CFX_WideString& wsFormatString, CFX_WideStringArray& wsPatterns) = 0;
+ virtual FX_LOCALECATEGORY GetCategory(const CFX_WideString& wsPattern) = 0;
+ virtual FX_WORD GetLCID(const CFX_WideString& wsPattern) = 0;
+ virtual CFX_WideString GetLocaleName(const CFX_WideString& wsPattern) = 0;
+ virtual FX_BOOL ParseText(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern, CFX_WideString& wsValue) = 0;
+ virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum, const CFX_WideString& wsPattern, FX_FLOAT &fValue) = 0;
+ virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum, const CFX_WideString& wsPattern, CFX_WideString &wsValue) = 0;
+ virtual FX_BOOL ParseDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, FX_DATETIMETYPE eDateTimeType, CFX_Unitime& dtValue) = 0;
+ virtual FX_BOOL ParseZero(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern) = 0;
+ virtual FX_BOOL ParseNull(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern) = 0;
+ virtual FX_BOOL FormatText(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
+ virtual FX_BOOL FormatNum(const CFX_WideString& wsSrcNum, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
+ virtual FX_BOOL FormatNum(FX_FLOAT fNum, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
+ virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
+ virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, CFX_WideString& wsOutput, FX_DATETIMETYPE eDateTimeType) = 0;
+ virtual FX_BOOL FormatDateTime(const CFX_Unitime& dt, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
+ virtual FX_BOOL FormatZero(const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
+ virtual FX_BOOL FormatNull(const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
+};
+class CFX_Decimal : CFX_Object
+{
+public:
+ CFX_Decimal();
+ CFX_Decimal(FX_UINT32 val);
+ CFX_Decimal(FX_UINT64 val);
+ CFX_Decimal(FX_INT32 val);
+ CFX_Decimal(FX_INT64 val);
+ CFX_Decimal(FX_FLOAT val, FX_UINT8 scale = 3);
+ CFX_Decimal(FX_WSTR str);
+ CFX_Decimal(FX_BSTR str);
+ operator CFX_WideString() const;
+ operator double() const;
+ FX_BOOL operator == (const CFX_Decimal& val) const;
+ FX_BOOL operator <= (const CFX_Decimal& val) const;
+ FX_BOOL operator >= (const CFX_Decimal& val) const;
+ FX_BOOL operator != (const CFX_Decimal& val) const;
+ FX_BOOL operator < (const CFX_Decimal& val) const;
+ FX_BOOL operator > (const CFX_Decimal& val) const;
+ CFX_Decimal operator + (const CFX_Decimal& val) const;
+ CFX_Decimal operator - (const CFX_Decimal& val) const;
+ CFX_Decimal operator * (const CFX_Decimal& val) const;
+ CFX_Decimal operator / (const CFX_Decimal& val) const;
+ CFX_Decimal operator % (const CFX_Decimal& val) const;
+ void SetScale(FX_UINT8 newScale);
+ FX_UINT8 GetScale();
+ void SetAbs();
+ void SetNegate();
+ void SetFloor();
+ void SetCeiling();
+ void SetTruncate();
+protected:
+ CFX_Decimal(FX_UINT32 hi, FX_UINT32 mid, FX_UINT32 lo, FX_BOOL neg, FX_UINT8 scale);
+ inline FX_BOOL IsNotZero() const
+ {
+ return m_uHi || m_uMid || m_uLo;
+ }
+ inline FX_INT8 Compare (const CFX_Decimal& val) const;
+ inline void Swap(CFX_Decimal& val);
+ inline void FloorOrCeil(FX_BOOL bFloor);
+ CFX_Decimal AddOrMinus(const CFX_Decimal& val, FX_BOOL isAdding) const;
+ CFX_Decimal Multiply(const CFX_Decimal& val) const;
+ CFX_Decimal Divide(const CFX_Decimal& val) const;
+ CFX_Decimal Modulus(const CFX_Decimal& val) const;
+ FX_UINT32 m_uFlags;
+ FX_UINT32 m_uHi;
+ FX_UINT32 m_uLo;
+ FX_UINT32 m_uMid;
+};
+#endif
diff --git a/xfa/src/fgas/include/fx_mem.h b/xfa/src/fgas/include/fx_mem.h
new file mode 100644
index 0000000000..18cd85e422
--- /dev/null
+++ b/xfa/src/fgas/include/fx_mem.h
@@ -0,0 +1,58 @@
+// 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
+#define _FX_MEMORY
+class IFX_MEMAllocator;
+class CFX_Target;
+enum FX_ALLOCTYPE {
+ FX_ALLOCTYPE_Default = 0,
+ FX_ALLOCTYPE_Static ,
+ FX_ALLOCTYPE_Fixed ,
+ FX_ALLOCTYPE_Dynamic ,
+};
+class IFX_MEMAllocator
+{
+public:
+ virtual void Release() = 0;
+ virtual void* Alloc(size_t size) = 0;
+ virtual void Free(void *pBlock) = 0;
+ virtual size_t GetBlockSize() const = 0;
+ virtual size_t GetDefChunkSize() const = 0;
+ virtual size_t SetDefChunkSize(size_t size) = 0;
+ virtual size_t GetCurrentDataSize() const = 0;
+};
+IFX_MEMAllocator* FX_CreateAllocator(FX_ALLOCTYPE eType, size_t chunkSize, size_t blockSize);
+class CFX_Target
+{
+public:
+ void* operator new(size_t size)
+ {
+ return FX_Alloc(FX_BYTE, size);
+ }
+ void operator delete(void *p)
+ {
+ FX_Free(p);
+ }
+ void* operator new(size_t size, IFX_MEMAllocator *pAllocator)
+ {
+ return pAllocator->Alloc(size);
+ }
+ void operator delete(void *p, IFX_MEMAllocator *pAllocator)
+ {
+ pAllocator->Free(p);
+ }
+ void* operator new(size_t size, void *place)
+ {
+ return place;
+ }
+ void operator delete(void *p, void *place) {}
+};
+#define FXTARGET_New new
+#define FXTARGET_NewWith(__allocator__) new(__allocator__)
+#define FXTARGET_Delete delete
+#define FXTARGET_DeleteWith(__class__, __allocator__, pointer) {(pointer)->~__class__(); (pointer)->operator delete((pointer), (__allocator__));}
+#endif
diff --git a/xfa/src/fgas/include/fx_rbk.h b/xfa/src/fgas/include/fx_rbk.h
new file mode 100644
index 0000000000..3053fc5e1b
--- /dev/null
+++ b/xfa/src/fgas/include/fx_rbk.h
@@ -0,0 +1,235 @@
+// 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_RTFBREAK
+#define _FX_RTFBREAK
+class IFX_Unknown;
+class IFX_Font;
+class CFX_Char;
+class CFX_RTFChar;
+class CFX_RTFBreakPiece;
+class IFX_RTFBreak;
+#define FX_RTFBREAKPOLICY_None 0x00
+#define FX_RTFBREAKPOLICY_SpaceBreak 0x01
+#define FX_RTFBREAKPOLICY_NumberBreak 0x02
+#define FX_RTFBREAKPOLICY_InfixBreak 0x04
+#define FX_RTFBREAKPOLICY_TabBreak 0x08
+#define FX_RTFBREAKPOLICY_OrphanPositionedTab 0x10
+#define FX_RTFBREAK_None 0x00
+#define FX_RTFBREAK_PieceBreak 0x01
+#define FX_RTFBREAK_LineBreak 0x02
+#define FX_RTFBREAK_ParagraphBreak 0x03
+#define FX_RTFBREAK_PageBreak 0x04
+#define FX_RTFLAYOUTSTYLE_Pagination 0x01
+#define FX_RTFLAYOUTSTYLE_VerticalLayout 0x02
+#define FX_RTFLAYOUTSTYLE_VerticalChars 0x04
+#define FX_RTFLAYOUTSTYLE_LineDirection 0x08
+#define FX_RTFLAYOUTSTYLE_ExpandTab 0x10
+#define FX_RTFLAYOUTSTYLE_ArabicNumber 0x20
+#define FX_RTFLAYOUTSTYLE_SingleLine 0x40
+#define FX_RTFLAYOUTSTYLE_MBCSCode 0x80
+#define FX_RTFCHARSTYLE_Alignment 0x000F
+#define FX_RTFCHARSTYLE_ArabicNumber 0x0010
+#define FX_RTFCHARSTYLE_ArabicShadda 0x0020
+#define FX_RTFCHARSTYLE_OddBidiLevel 0x0040
+#define FX_RTFCHARSTYLE_RTLReadingOrder 0x0080
+#define FX_RTFCHARSTYLE_ArabicContext 0x0300
+#define FX_RTFCHARSTYLE_ArabicIndic 0x0400
+#define FX_RTFCHARSTYLE_ArabicComma 0x0800
+#define FX_RTFLINEALIGNMENT_Left 0
+#define FX_RTFLINEALIGNMENT_Center 1
+#define FX_RTFLINEALIGNMENT_Right 2
+#define FX_RTFLINEALIGNMENT_Justified (1 << 2)
+#define FX_RTFLINEALIGNMENT_Distributed (2 << 2)
+#define FX_RTFLINEALIGNMENT_JustifiedLeft (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Justified)
+#define FX_RTFLINEALIGNMENT_JustifiedCenter (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Justified)
+#define FX_RTFLINEALIGNMENT_JustifiedRight (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Justified)
+#define FX_RTFLINEALIGNMENT_DistributedLeft (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Distributed)
+#define FX_RTFLINEALIGNMENT_DistributedCenter (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Distributed)
+#define FX_RTFLINEALIGNMENT_DistributedRight (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Distributed)
+#define FX_RTFLINEALIGNMENT_LowerMask 0x03
+#define FX_RTFLINEALIGNMENT_HigherMask 0x0C
+typedef struct _FX_RTFTEXTOBJ {
+ _FX_RTFTEXTOBJ()
+ {
+ pStr = NULL;
+ pWidths = NULL;
+ iLength = 0;
+ pFont = NULL;
+ fFontSize = 12.0f;
+ dwLayoutStyles = 0;
+ iCharRotation = 0;
+ iBidiLevel = 0;
+ pRect = NULL;
+ wLineBreakChar = L'\n';
+ iHorizontalScale = 100;
+ iVerticalScale = 100;
+ }
+ FX_LPCWSTR pStr;
+ FX_INT32 *pWidths;
+ FX_INT32 iLength;
+ IFX_Font *pFont;
+ FX_FLOAT fFontSize;
+ FX_DWORD dwLayoutStyles;
+ FX_INT32 iCharRotation;
+ FX_INT32 iBidiLevel;
+ FX_LPCRECTF pRect;
+ FX_WCHAR wLineBreakChar;
+ FX_INT32 iHorizontalScale;
+ FX_INT32 iVerticalScale;
+} FX_RTFTEXTOBJ, * FX_LPRTFTEXTOBJ;
+typedef FX_RTFTEXTOBJ const * FX_LPCRTFTEXTOBJ;
+class CFX_RTFPiece : public CFX_Target
+{
+public:
+ CFX_RTFPiece() : m_dwStatus(FX_RTFBREAK_PieceBreak)
+ , m_iStartPos(0)
+ , m_iWidth(-1)
+ , m_iStartChar(0)
+ , m_iChars(0)
+ , m_iBidiLevel(0)
+ , m_iBidiPos(0)
+ , m_iFontSize(0)
+ , m_iFontHeight(0)
+ , m_iHorizontalScale(100)
+ , m_iVerticalScale(100)
+ , m_dwLayoutStyles(0)
+ , m_dwIdentity(0)
+ , m_pChars(NULL)
+ , m_pUserData(NULL)
+ {
+ }
+ ~CFX_RTFPiece()
+ {
+ Reset();
+ }
+ void AppendChar(const CFX_RTFChar &tc)
+ {
+ FXSYS_assert(m_pChars != NULL);
+ m_pChars->Add(tc);
+ if (m_iWidth < 0) {
+ m_iWidth = tc.m_iCharWidth;
+ } else {
+ m_iWidth += tc.m_iCharWidth;
+ }
+ m_iChars ++;
+ }
+ FX_INT32 GetEndPos() const
+ {
+ return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
+ }
+ FX_INT32 GetLength() const
+ {
+ return m_iChars;
+ }
+ FX_INT32 GetEndChar() const
+ {
+ return m_iStartChar + m_iChars;
+ }
+ CFX_RTFChar& GetChar(FX_INT32 index)
+ {
+ FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
+ return *m_pChars->GetDataPtr(m_iStartChar + index);
+ }
+ CFX_RTFChar* GetCharPtr(FX_INT32 index) const
+ {
+ FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
+ return m_pChars->GetDataPtr(m_iStartChar + index);
+ }
+ void GetString (FX_LPWSTR pText) const
+ {
+ FXSYS_assert(pText != NULL);
+ FX_INT32 iEndChar = m_iStartChar + m_iChars;
+ CFX_RTFChar *pChar;
+ for (FX_INT32 i = m_iStartChar; i < iEndChar; i ++) {
+ pChar = m_pChars->GetDataPtr(i);
+ *pText ++ = (FX_WCHAR)pChar->m_wCharCode;
+ }
+ }
+ void GetString(CFX_WideString &wsText) const
+ {
+ FX_LPWSTR pText = wsText.GetBuffer(m_iChars);
+ GetString(pText);
+ wsText.ReleaseBuffer(m_iChars);
+ }
+ void GetWidths(FX_INT32 *pWidths) const
+ {
+ FXSYS_assert(pWidths != NULL);
+ FX_INT32 iEndChar = m_iStartChar + m_iChars;
+ CFX_RTFChar *pChar;
+ for (FX_INT32 i = m_iStartChar; i < iEndChar; i ++) {
+ pChar = m_pChars->GetDataPtr(i);
+ *pWidths ++ = pChar->m_iCharWidth;
+ }
+ }
+ void Reset()
+ {
+ m_dwStatus = FX_RTFBREAK_PieceBreak;
+ if (m_iWidth > -1) {
+ m_iStartPos += m_iWidth;
+ }
+ m_iWidth = -1;
+ m_iStartChar += m_iChars;
+ m_iChars = 0;
+ m_iBidiLevel = 0;
+ m_iBidiPos = 0;
+ m_iHorizontalScale = 100;
+ m_iVerticalScale = 100;
+ }
+ FX_DWORD m_dwStatus;
+ FX_INT32 m_iStartPos;
+ FX_INT32 m_iWidth;
+ FX_INT32 m_iStartChar;
+ FX_INT32 m_iChars;
+ FX_INT32 m_iBidiLevel;
+ FX_INT32 m_iBidiPos;
+ FX_INT32 m_iFontSize;
+ FX_INT32 m_iFontHeight;
+ FX_INT32 m_iHorizontalScale;
+ FX_INT32 m_iVerticalScale;
+ FX_DWORD m_dwLayoutStyles;
+ FX_DWORD m_dwIdentity;
+ CFX_RTFCharArray *m_pChars;
+ IFX_Unknown *m_pUserData;
+};
+typedef CFX_BaseArrayTemplate<CFX_RTFPiece> CFX_RTFPieceArray;
+class IFX_RTFBreak
+{
+public:
+ static IFX_RTFBreak* Create(FX_DWORD dwPolicies);
+ virtual void Release() = 0;
+ virtual void SetLineWidth(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) = 0;
+ virtual void SetLinePos(FX_FLOAT fLinePos) = 0;
+ virtual FX_DWORD GetLayoutStyles() const = 0;
+ virtual void SetLayoutStyles(FX_DWORD dwLayoutStyles) = 0;
+ virtual void SetFont(IFX_Font *pFont) = 0;
+ virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
+ virtual void SetTabWidth(FX_FLOAT fTabWidth) = 0;
+ virtual void AddPositionedTab(FX_FLOAT fTabPos) = 0;
+ virtual void SetPositionedTabs(const CFX_FloatArray &tabs) = 0;
+ virtual void ClearPositionedTabs() = 0;
+ virtual void SetDefaultChar(FX_WCHAR wch) = 0;
+ virtual void SetLineBreakChar(FX_WCHAR wch) = 0;
+ virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
+ virtual void SetHorizontalScale(FX_INT32 iScale) = 0;
+ virtual void SetVerticalScale(FX_INT32 iScale) = 0;
+ virtual void SetCharRotation(FX_INT32 iCharRotation) = 0;
+ virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
+ virtual void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) = 0;
+ virtual void SetReadingOrder(FX_BOOL bRTL = FALSE) = 0;
+ virtual void SetAlignment(FX_INT32 iAlignment = FX_RTFLINEALIGNMENT_Left) = 0;
+ virtual void SetUserData(IFX_Unknown *pUserData) = 0;
+ virtual FX_DWORD AppendChar(FX_WCHAR wch) = 0;
+ virtual FX_DWORD EndBreak(FX_DWORD dwStatus = FX_RTFBREAK_PieceBreak) = 0;
+ virtual FX_INT32 CountBreakPieces() const = 0;
+ virtual const CFX_RTFPiece* GetBreakPiece(FX_INT32 index) const = 0;
+ virtual void GetLineRect(CFX_RectF &rect) const = 0;
+ virtual void ClearBreakPieces() = 0;
+ virtual void Reset() = 0;
+ virtual FX_INT32 GetDisplayPos(FX_LPCRTFTEXTOBJ pText, FXTEXT_CHARPOS *pCharPos, FX_BOOL bCharCode = FALSE, CFX_WideString *pWSForms = NULL, FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
+ virtual FX_INT32 GetCharRects(FX_LPCRTFTEXTOBJ pText, CFX_RectFArray &rtArray, FX_BOOL bCharBBox = FALSE) const = 0;
+};
+#endif
diff --git a/xfa/src/fgas/include/fx_sax.h b/xfa/src/fgas/include/fx_sax.h
new file mode 100644
index 0000000000..c0159f8c22
--- /dev/null
+++ b/xfa/src/fgas/include/fx_sax.h
@@ -0,0 +1,48 @@
+// 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_SAX_
+#define _FX_SAX_
+class IFX_SAXReaderHandler;
+class IFX_SAXReader;
+#define FX_SAXPARSEMODE_NotConvert_amp 0x0001
+#define FX_SAXPARSEMODE_NotConvert_lt 0x0002
+#define FX_SAXPARSEMODE_NotConvert_gt 0x0004
+#define FX_SAXPARSEMODE_NotConvert_apos 0x0008
+#define FX_SAXPARSEMODE_NotConvert_quot 0x0010
+#define FX_SAXPARSEMODE_NotConvert_sharp 0x0020
+#define FX_SAXPARSEMODE_NotSkipSpace 0x0100
+enum FX_SAXNODE {
+ FX_SAXNODE_Unknown = 0,
+ FX_SAXNODE_Instruction,
+ FX_SAXNODE_Declaration,
+ FX_SAXNODE_Comment,
+ FX_SAXNODE_Tag,
+ FX_SAXNODE_Text,
+ FX_SAXNODE_CharData,
+};
+class IFX_SAXReaderHandler
+{
+public:
+ virtual FX_LPVOID OnTagEnter(FX_BSTR bsTagName, FX_SAXNODE eType, FX_DWORD dwStartPos) = 0;
+ virtual void OnTagAttribute(FX_LPVOID pTag, FX_BSTR bsAttri, FX_BSTR bsValue) = 0;
+ virtual void OnTagBreak(FX_LPVOID pTag) = 0;
+ virtual void OnTagData(FX_LPVOID pTag, FX_SAXNODE eType, FX_BSTR bsData, FX_DWORD dwStartPos) = 0;
+ virtual void OnTagClose(FX_LPVOID pTag, FX_DWORD dwEndPos) = 0;
+ virtual void OnTagEnd(FX_LPVOID pTag, FX_BSTR bsTagName, FX_DWORD dwEndPos) = 0;
+ virtual void OnTargetData(FX_LPVOID pTag, FX_SAXNODE eType, FX_BSTR bsData, FX_DWORD dwStartPos) = 0;
+};
+class IFX_SAXReader
+{
+public:
+ virtual void Release() = 0;
+ virtual FX_INT32 StartParse(IFX_FileRead *pFile, FX_DWORD dwStart = 0, FX_DWORD dwLen = -1, FX_DWORD dwParseMode = 0) = 0;
+ virtual FX_INT32 ContinueParse(IFX_Pause *pPause = NULL) = 0;
+ virtual void SkipCurrentNode() = 0;
+ virtual void SetHandler(IFX_SAXReaderHandler *pHandler) = 0;
+};
+IFX_SAXReader* FX_SAXReader_Create();
+#endif
diff --git a/xfa/src/fgas/include/fx_stm.h b/xfa/src/fgas/include/fx_stm.h
new file mode 100644
index 0000000000..ae424dba2d
--- /dev/null
+++ b/xfa/src/fgas/include/fx_stm.h
@@ -0,0 +1,60 @@
+// 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
+#define _FX_STREAM
+class IFX_Stream;
+IFX_FileRead* FX_CreateFileRead(IFX_Stream *pBaseStream, FX_BOOL bReleaseStream = FALSE);
+#ifdef FX_FILESIZE
+IFX_FileRead* FX_CreateFileRead(IFX_BufferRead *pBufferRead, FX_FILESIZE iFileSize = -1, FX_BOOL bReleaseStream = TRUE);
+#else
+IFX_FileRead* FX_CreateFileRead(IFX_BufferRead *pBufferRead, FX_INT32 iFileSize = -1, FX_BOOL bReleaseStream = TRUE);
+#endif
+IFX_FileWrite* FX_CreateFileWrite(IFX_Stream *pBaseStream, FX_BOOL bReleaseStream = FALSE);
+enum FX_STREAMACCESS {
+ FX_STREAMACCESS_Binary = 0x00,
+ FX_STREAMACCESS_Text = 0x01,
+ FX_STREAMACCESS_Read = 0x02,
+ FX_STREAMACCESS_Write = 0x04,
+ FX_STREAMACCESS_Truncate = 0x10,
+ FX_STREAMACCESS_Append = 0x20,
+ FX_STREAMACCESS_Create = 0x80,
+};
+enum FX_STREAMSEEK {
+ FX_STREAMSEEK_Begin = 0 ,
+ FX_STREAMSEEK_Current ,
+ FX_STREAMSEEK_End ,
+};
+class IFX_Stream
+{
+public:
+ static IFX_Stream* CreateStream(IFX_FileRead *pFileRead, FX_DWORD dwAccess);
+ static IFX_Stream* CreateStream(IFX_FileWrite *pFileWrite, FX_DWORD dwAccess);
+ static IFX_Stream* CreateStream(FX_LPCWSTR pszFileName, FX_DWORD dwAccess);
+ static IFX_Stream* CreateStream(FX_LPBYTE pData, FX_INT32 length, FX_DWORD dwAccess);
+ static IFX_Stream* CreateStream(IFX_BufferRead *pBufferRead, FX_DWORD dwAccess, FX_INT32 iFileSize = -1, FX_BOOL bReleaseBufferRead = TRUE);
+ static IFX_Stream* CreateTextStream(IFX_Stream *pBaseStream, FX_BOOL bDeleteOnRelease);
+ virtual void Release() = 0;
+ virtual IFX_Stream* Retain() = 0;
+ virtual FX_DWORD GetAccessModes() const = 0;
+ virtual FX_INT32 GetLength() const = 0;
+ virtual FX_INT32 Seek(FX_STREAMSEEK eSeek, FX_INT32 iOffset) = 0;
+ virtual FX_INT32 GetPosition() = 0;
+ virtual FX_BOOL IsEOF() const = 0;
+ virtual FX_INT32 ReadData(FX_LPBYTE pBuffer, FX_INT32 iBufferSize) = 0;
+ virtual FX_INT32 ReadString(FX_LPWSTR pStr, FX_INT32 iMaxLength, FX_BOOL &bEOS, FX_INT32 const *pByteSize = NULL) = 0;
+ virtual FX_INT32 WriteData(FX_LPCBYTE pBuffer, FX_INT32 iBufferSize) = 0;
+ virtual FX_INT32 WriteString(FX_LPCWSTR pStr, FX_INT32 iLength) = 0;
+ virtual void Flush() = 0;
+ virtual FX_BOOL SetLength(FX_INT32 iLength) = 0;
+ virtual FX_INT32 GetBOM(FX_BYTE bom[4]) const = 0;
+ virtual FX_WORD GetCodePage() const = 0;
+ virtual FX_WORD SetCodePage(FX_WORD wCodePage) = 0;
+ virtual void Lock() = 0;
+ virtual void Unlock() = 0;
+ virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, FX_INT32 iOffset, FX_INT32 iLength) = 0;
+};
+#endif
diff --git a/xfa/src/fgas/include/fx_sys.h b/xfa/src/fgas/include/fx_sys.h
new file mode 100644
index 0000000000..c0b5c7445f
--- /dev/null
+++ b/xfa/src/fgas/include/fx_sys.h
@@ -0,0 +1,63 @@
+// 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
+#define _FX_SYSTEM
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define FX_RAD2DEG(r) ((r) * 180.0f / FX_PI)
+#define FX_DEG2RAD(a) ((a) * FX_PI / 180.0f)
+typedef FX_INT8 * FX_LPINT8;
+typedef FX_INT8 const * FX_LPCINT8;
+typedef FX_INT32 * FX_LPINT32;
+typedef FX_INT32 const * FX_LPCINT32;
+typedef long FX_LONG;
+typedef FX_LONG * FX_LPLONG;
+typedef FX_LONG const * FX_LPCLONG;
+typedef FX_FLOAT const * FX_LPCFLOAT;
+typedef double FX_DOUBLE;
+typedef FX_DOUBLE * FX_LPDOUBLE;
+typedef FX_DOUBLE const * FX_LPCDOUBLE;
+FX_FLOAT FX_tan(FX_FLOAT a);
+FX_FLOAT FX_log(FX_FLOAT b, FX_FLOAT x);
+FX_FLOAT FX_strtof(FX_LPCSTR pcsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
+FX_FLOAT FX_wcstof(FX_LPCWSTR pwsStr, FX_INT32 iLength = -1, FX_INT32 *pUsedLen = NULL);
+FX_LPWSTR FX_wcsncpy(FX_LPWSTR dstStr, FX_LPCWSTR srcStr, size_t count);
+FX_INT32 FX_wcsnicmp(FX_LPCWSTR s1, FX_LPCWSTR s2, size_t count);
+FX_INT32 FX_strnicmp(FX_LPCSTR s1, FX_LPCSTR s2, size_t count);
+inline FX_BOOL FX_islower(FX_INT32 ch)
+{
+ return ch >= 'a' && ch <= 'z';
+}
+inline FX_BOOL FX_isupper(FX_INT32 ch)
+{
+ return ch >= 'A' && ch <= 'Z';
+}
+inline FX_INT32 FX_tolower(FX_INT32 ch)
+{
+ return FX_isupper(ch) ? (ch + 0x20) : ch;
+}
+inline FX_INT32 FX_toupper(FX_INT32 ch)
+{
+ return FX_islower(ch) ? (ch - 0x20) : ch;
+}
+FX_INT32 FX_filelength(FXSYS_FILE *file);
+FX_BOOL FX_fsetsize(FXSYS_FILE *file, FX_INT32 size);
+void FX_memset(FX_LPVOID pBuf, FX_INT32 iValue, size_t size);
+void FX_memcpy(FX_LPVOID pDst, FX_LPCVOID pSrc, size_t size);
+FX_BOOL FX_IsRelativePath(const CFX_WideStringC &wsPath);
+FX_BOOL FX_JoinPath(const CFX_WideStringC &wsBasePath, const CFX_WideStringC &wsRelativePath, CFX_WideString &wsAbsolutePath);
+typedef struct _FX_VERSION {
+ FX_DWORD dwMajorVersion;
+ FX_DWORD dwMinorVersion;
+ FX_DWORD dwBuildVersion;
+} FX_VERSION, * FX_LPVERSION;
+typedef FX_VERSION const * FX_LPCVERSION;
+#ifdef __cplusplus
+};
+#endif
+#endif
diff --git a/xfa/src/fgas/include/fx_tbk.h b/xfa/src/fgas/include/fx_tbk.h
new file mode 100644
index 0000000000..ab64d1dac0
--- /dev/null
+++ b/xfa/src/fgas/include/fx_tbk.h
@@ -0,0 +1,211 @@
+// 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_TEXTBREAK
+#define _FX_TEXTBREAK
+class IFX_Font;
+class CFX_Char;
+class IFX_TxtAccess;
+class CFX_TxtChar;
+class CFX_TxtPiece;
+class IFX_TxtBreak;
+#define FX_TXTBREAKPOLICY_None 0x00
+#define FX_TXTBREAKPOLICY_Pagination 0x01
+#define FX_TXTBREAKPOLICY_SpaceBreak 0x02
+#define FX_TXTBREAKPOLICY_NumberBreak 0x04
+#define FX_TXTBREAK_None 0x00
+#define FX_TXTBREAK_PieceBreak 0x01
+#define FX_TXTBREAK_LineBreak 0x02
+#define FX_TXTBREAK_ParagraphBreak 0x03
+#define FX_TXTBREAK_PageBreak 0x04
+#define FX_TXTBREAK_ControlChar 0x10
+#define FX_TXTBREAK_BreakChar 0x20
+#define FX_TXTBREAK_UnknownChar 0x40
+#define FX_TXTBREAK_RemoveChar 0x80
+#define FX_TXTLAYOUTSTYLE_MutipleFormat 0x0001
+#define FX_TXTLAYOUTSTYLE_VerticalLayout 0x0002
+#define FX_TXTLAYOUTSTYLE_VerticalChars 0x0004
+#define FX_TXTLAYOUTSTYLE_ReverseLine 0x0008
+#define FX_TXTLAYOUTSTYLE_ArabicContext 0x0010
+#define FX_TXTLAYOUTSTYLE_ArabicShapes 0x0020
+#define FX_TXTLAYOUTSTYLE_RTLReadingOrder 0x0040
+#define FX_TXTLAYOUTSTYLE_ExpandTab 0x0100
+#define FX_TXTLAYOUTSTYLE_SingleLine 0x0200
+#define FX_TXTLAYOUTSTYLE_CombText 0x0400
+#define FX_TXTCHARSTYLE_Alignment 0x000F
+#define FX_TXTCHARSTYLE_ArabicNumber 0x0010
+#define FX_TXTCHARSTYLE_ArabicShadda 0x0020
+#define FX_TXTCHARSTYLE_OddBidiLevel 0x0040
+#define FX_TXTCHARSTYLE_RTLReadingOrder 0x0080
+#define FX_TXTCHARSTYLE_ArabicContext 0x0300
+#define FX_TXTCHARSTYLE_ArabicIndic 0x0400
+#define FX_TXTCHARSTYLE_ArabicComma 0x0800
+#define FX_TXTLINEALIGNMENT_Left 0
+#define FX_TXTLINEALIGNMENT_Center 1
+#define FX_TXTLINEALIGNMENT_Right 2
+#define FX_TXTLINEALIGNMENT_Justified (1 << 2)
+#define FX_TXTLINEALIGNMENT_Distributed (2 << 2)
+#define FX_TXTLINEALIGNMENT_JustifiedLeft (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Justified)
+#define FX_TXTLINEALIGNMENT_JustifiedCenter (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Justified)
+#define FX_TXTLINEALIGNMENT_JustifiedRight (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Justified)
+#define FX_TXTLINEALIGNMENT_DistributedLeft (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Distributed)
+#define FX_TXTLINEALIGNMENT_DistributedCenter (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Distributed)
+#define FX_TXTLINEALIGNMENT_DistributedRight (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Distributed)
+#define FX_TXTLINEALIGNMENT_LowerMask 0x03
+#define FX_TXTLINEALIGNMENT_HigherMask 0x0C
+#define FX_TXTBREAK_MinimumTabWidth 160000
+class IFX_TxtAccess
+{
+public:
+ virtual FX_WCHAR GetChar(FX_LPVOID pIdentity, FX_INT32 index) const = 0;
+ virtual FX_INT32 GetWidth(FX_LPVOID pIdentity, FX_INT32 index) const = 0;
+};
+typedef struct _FX_TXTRUN {
+ _FX_TXTRUN()
+ {
+ pAccess = NULL;
+ pIdentity = NULL;
+ pStr = NULL;
+ pWidths = NULL;
+ iLength = 0;
+ pFont = NULL;
+ fFontSize = 12;
+ dwStyles = 0;
+ iHorizontalScale = 100;
+ iVerticalScale = 100;
+ iCharRotation = 0;
+ dwCharStyles = 0;
+ pRect = NULL;
+ wLineBreakChar = L'\n';
+ bSkipSpace = TRUE;
+ }
+ IFX_TxtAccess *pAccess;
+ FX_LPVOID pIdentity;
+ FX_LPCWSTR pStr;
+ FX_INT32 *pWidths;
+ FX_INT32 iLength;
+ IFX_Font *pFont;
+ FX_FLOAT fFontSize;
+ FX_DWORD dwStyles;
+ FX_INT32 iHorizontalScale;
+ FX_INT32 iVerticalScale;
+ FX_INT32 iCharRotation;
+ FX_DWORD dwCharStyles;
+ FX_LPCRECTF pRect;
+ FX_WCHAR wLineBreakChar;
+ FX_BOOL bSkipSpace;
+} FX_TXTRUN, * FX_LPTXTRUN;
+typedef FX_TXTRUN const * FX_LPCTXTRUN;
+class CFX_TxtPiece : public CFX_Target
+{
+public:
+ CFX_TxtPiece() : m_dwStatus(FX_TXTBREAK_PieceBreak)
+ , m_iStartPos(0)
+ , m_iWidth(-1)
+ , m_iStartChar(0)
+ , m_iChars(0)
+ , m_iBidiLevel(0)
+ , m_iBidiPos(0)
+ , m_iHorizontalScale(100)
+ , m_iVerticalScale(100)
+ , m_dwCharStyles(0)
+ , m_pChars(NULL)
+ , m_pUserData(NULL)
+ {
+ }
+ FX_INT32 GetEndPos() const
+ {
+ return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
+ }
+ FX_INT32 GetLength() const
+ {
+ return m_iChars;
+ }
+ FX_INT32 GetEndChar() const
+ {
+ return m_iStartChar + m_iChars;
+ }
+ CFX_TxtChar* GetCharPtr(FX_INT32 index) const
+ {
+ FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
+ return m_pChars->GetDataPtr(m_iStartChar + index);
+ }
+ void GetString(FX_LPWSTR pText) const
+ {
+ FXSYS_assert(pText != NULL);
+ FX_INT32 iEndChar = m_iStartChar + m_iChars;
+ CFX_Char *pChar;
+ for (FX_INT32 i = m_iStartChar; i < iEndChar; i ++) {
+ pChar = m_pChars->GetDataPtr(i);
+ *pText ++ = (FX_WCHAR)pChar->m_wCharCode;
+ }
+ }
+
+ void GetString(CFX_WideString &wsText) const
+ {
+ FX_LPWSTR pText = wsText.GetBuffer(m_iChars);
+ GetString(pText);
+ wsText.ReleaseBuffer(m_iChars);
+ }
+ void GetWidths(FX_INT32 *pWidths) const
+ {
+ FXSYS_assert(pWidths != NULL);
+ FX_INT32 iEndChar = m_iStartChar + m_iChars;
+ CFX_Char *pChar;
+ for (FX_INT32 i = m_iStartChar; i < iEndChar; i ++) {
+ pChar = m_pChars->GetDataPtr(i);
+ *pWidths ++ = pChar->m_iCharWidth;
+ }
+ }
+ FX_DWORD m_dwStatus;
+ FX_INT32 m_iStartPos;
+ FX_INT32 m_iWidth;
+ FX_INT32 m_iStartChar;
+ FX_INT32 m_iChars;
+ FX_INT32 m_iBidiLevel;
+ FX_INT32 m_iBidiPos;
+ FX_INT32 m_iHorizontalScale;
+ FX_INT32 m_iVerticalScale;
+ FX_DWORD m_dwCharStyles;
+ CFX_TxtCharArray *m_pChars;
+ FX_LPVOID m_pUserData;
+};
+typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray;
+class IFX_TxtBreak
+{
+public:
+ static IFX_TxtBreak* Create(FX_DWORD dwPolicies);
+ virtual void Release() = 0;
+ virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0;
+ virtual void SetLinePos(FX_FLOAT fLinePos) = 0;
+ virtual FX_DWORD GetLayoutStyles() const = 0;
+ virtual void SetLayoutStyles(FX_DWORD dwLayoutStyles) = 0;
+ virtual void SetFont(IFX_Font *pFont) = 0;
+ virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
+ virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) = 0;
+ virtual void SetDefaultChar(FX_WCHAR wch) = 0;
+ virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0;
+ virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
+ virtual void SetHorizontalScale(FX_INT32 iScale) = 0;
+ virtual void SetVerticalScale(FX_INT32 iScale) = 0;
+ virtual void SetCharRotation(FX_INT32 iCharRotation) = 0;
+ virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
+ virtual void SetAlignment(FX_INT32 iAlignment) = 0;
+ virtual FX_DWORD GetContextCharStyles() const = 0;
+ virtual void SetContextCharStyles(FX_DWORD dwCharStyles) = 0;
+ virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0;
+ virtual void SetUserData(FX_LPVOID pUserData) = 0;
+ virtual FX_DWORD AppendChar(FX_WCHAR wch) = 0;
+ virtual FX_DWORD EndBreak(FX_DWORD dwStatus = FX_TXTBREAK_PieceBreak) = 0;
+ virtual FX_INT32 CountBreakChars() const = 0;
+ virtual FX_INT32 CountBreakPieces() const = 0;
+ virtual const CFX_TxtPiece* GetBreakPiece(FX_INT32 index) const = 0;
+ virtual void ClearBreakPieces() = 0;
+ virtual void Reset() = 0;
+ virtual FX_INT32 GetDisplayPos(FX_LPCTXTRUN pTxtRun, FXTEXT_CHARPOS *pCharPos, FX_BOOL bCharCode = FALSE, CFX_WideString *pWSForms = NULL, FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
+ virtual FX_INT32 GetCharRects(FX_LPCTXTRUN pTxtRun, CFX_RectFArray &rtArray, FX_BOOL bCharBBox = FALSE) const = 0;
+};
+#endif
diff --git a/xfa/src/fgas/include/fx_ucd.h b/xfa/src/fgas/include/fx_ucd.h
new file mode 100644
index 0000000000..715c8af4dd
--- /dev/null
+++ b/xfa/src/fgas/include/fx_ucd.h
@@ -0,0 +1,23 @@
+// 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 _FGAS_UNICODE_
+#define _FGAS_UNICODE_
+#define FX_JAPCHARPROPERTYEX_Left 0x01
+#define FX_JAPCHARPROPERTYEX_Center 0x02
+#define FX_JAPCHARPROPERTYEX_Right 0x03
+#define FX_JAPCHARPROPERTYEX_Top 0x10
+#define FX_JAPCHARPROPERTYEX_Middle 0x20
+#define FX_JAPCHARPROPERTYEX_Bottom 0x30
+typedef struct _FX_JAPCHARPROPERTYEX {
+ FX_WCHAR wChar;
+ FX_BYTE uAlign;
+} FX_JAPCHARPROPERTYEX, *FX_LPJAPCHARPROPERTYEX;
+typedef FX_JAPCHARPROPERTYEX const * FX_LPCJAPCHARPROPERTYEX;
+FX_LPCJAPCHARPROPERTYEX FX_GetJapCharPropertyEx(FX_WCHAR wch);
+typedef FX_BOOL (*FX_AdjustCharDisplayPos)(FX_WCHAR wch, FX_BOOL bMBCSCode, IFX_Font *pFont, FX_FLOAT fFontSize, FX_BOOL bVertical, CFX_PointF &ptOffset);
+FX_BOOL FX_AdjustJapCharDisplayPos(FX_WCHAR wch, FX_BOOL bMBCSCode, IFX_Font *pFont, FX_FLOAT fFontSize, FX_BOOL bVertical, CFX_PointF &ptOffset);
+#endif
diff --git a/xfa/src/fgas/include/fx_utl.h b/xfa/src/fgas/include/fx_utl.h
new file mode 100644
index 0000000000..3bb7b61986
--- /dev/null
+++ b/xfa/src/fgas/include/fx_utl.h
@@ -0,0 +1,797 @@
+// 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_UTILS
+#define _FX_UTILS
+class CFX_ThreadLock;
+class CFX_BaseArray;
+template<class baseType> class CFX_BaseArrayTemplate;
+template<class baseType> class CFX_ObjectBaseArrayTemplate;
+class CFX_BaseMassArray;
+template<class baseType> class CFX_MassArrayTemplate;
+template<class baseType> class CFX_ObjectMassArrayTemplate;
+class CFX_BaseDiscreteArray;
+template<class baseType> class CFX_DiscreteArrayTemplate;
+class CFX_BaseStack;
+template<class baseType> class CFX_StackTemplate;
+template<class baseType> class CFX_ObjectStackTemplate;
+template<class baseType> class CFX_CPLTreeNode;
+template<class baseType> class CFX_CPLTree;
+class CFX_ThreadLock
+{
+public:
+ CFX_ThreadLock();
+ virtual ~CFX_ThreadLock();
+ void Lock();
+ void Unlock();
+private:
+ FX_LPVOID m_pData;
+};
+class CFX_BaseArray : public CFX_Target
+{
+protected:
+ CFX_BaseArray(FX_INT32 iGrowSize, FX_INT32 iBlockSize);
+ ~CFX_BaseArray();
+ FX_INT32 GetSize() const;
+ FX_INT32 GetBlockSize() const;
+ FX_LPBYTE AddSpaceTo(FX_INT32 index);
+ FX_LPBYTE GetAt(FX_INT32 index) const;
+ FX_LPBYTE GetBuffer() const;
+ FX_INT32 Append(const CFX_BaseArray &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1);
+ FX_INT32 Copy(const CFX_BaseArray &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1);
+ FX_INT32 RemoveLast(FX_INT32 iCount = -1);
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE);
+ FX_LPVOID m_pData;
+};
+template<class baseType>
+class CFX_BaseArrayTemplate : public CFX_BaseArray
+{
+public:
+ CFX_BaseArrayTemplate(FX_INT32 iGrowSize = 100) : CFX_BaseArray(iGrowSize, sizeof(baseType)) {}
+ CFX_BaseArrayTemplate(FX_INT32 iGrowSize, FX_INT32 iBlockSize) : CFX_BaseArray(iGrowSize, iBlockSize) {}
+ FX_INT32 GetSize() const
+ {
+ return CFX_BaseArray::GetSize();
+ }
+ FX_INT32 GetBlockSize() const
+ {
+ return CFX_BaseArray::GetBlockSize();
+ }
+ baseType* AddSpace()
+ {
+ return (baseType*)CFX_BaseArray::AddSpaceTo(CFX_BaseArray::GetSize());
+ }
+ FX_INT32 Add(const baseType &element)
+ {
+ FX_INT32 index = CFX_BaseArray::GetSize();
+ *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element;
+ return index;
+ }
+ baseType* GetBuffer() const
+ {
+ return (baseType*)CFX_BaseArray::GetBuffer();
+ }
+ baseType& GetAt(FX_INT32 index) const
+ {
+ return *(baseType*)CFX_BaseArray::GetAt(index);
+ }
+ baseType* GetPtrAt(FX_INT32 index) const
+ {
+ return (baseType*)CFX_BaseArray::GetAt(index);
+ }
+ void SetAt(FX_INT32 index, const baseType &element)
+ {
+ *(baseType*)CFX_BaseArray::GetAt(index) = element;
+ }
+ void SetAtGrow(FX_INT32 index, const baseType &element)
+ {
+ *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element;
+ }
+ FX_INT32 Append(const CFX_BaseArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ return CFX_BaseArray::Append(src, iStart, iCount);
+ }
+ FX_INT32 Copy(const CFX_BaseArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ return CFX_BaseArray::Copy(src, iStart, iCount);
+ }
+ FX_INT32 RemoveLast(FX_INT32 iCount = -1)
+ {
+ return CFX_BaseArray::RemoveLast(iCount);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE)
+ {
+ CFX_BaseArray::RemoveAll(bLeaveMemory);
+ }
+};
+typedef CFX_BaseArrayTemplate<FX_LPVOID> CFDE_PtrArray;
+typedef CFX_BaseArrayTemplate<FX_DWORD> CFDE_DWordArray;
+typedef CFX_BaseArrayTemplate<FX_WORD> CFDE_WordArray;
+template<class baseType>
+class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray
+{
+public:
+ CFX_ObjectBaseArrayTemplate(FX_INT32 iGrowSize = 100) : CFX_BaseArray(iGrowSize, sizeof(baseType)) {}
+ ~CFX_ObjectBaseArrayTemplate()
+ {
+ RemoveAll(FALSE);
+ }
+ FX_INT32 GetSize() const
+ {
+ return CFX_BaseArray::GetSize();
+ }
+ FX_INT32 GetBlockSize() const
+ {
+ return CFX_BaseArray::GetBlockSize();
+ }
+ FX_INT32 Add(const baseType &element)
+ {
+ FX_INT32 index = CFX_BaseArray::GetSize();
+ baseType *p = (baseType*)CFX_BaseArray::AddSpaceTo(index);
+ FXTARGET_New ((void*)p)baseType(element);
+ return index;
+ }
+ baseType& GetAt(FX_INT32 index) const
+ {
+ return *(baseType*)CFX_BaseArray::GetAt(index);
+ }
+ baseType* GetPtrAt(FX_INT32 index) const
+ {
+ return (baseType*)CFX_BaseArray::GetAt(index);
+ }
+ FX_INT32 Append(const CFX_ObjectBaseArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ FXSYS_assert(GetBlockSize() == src.GetBlockSize());
+ if (iCount == 0) {
+ return 0;
+ }
+ FX_INT32 iSize = src.GetSize();
+ FXSYS_assert(iStart > -1 && iStart < iSize);
+ if (iCount < 0) {
+ iCount = iSize;
+ }
+ if (iStart + iCount > iSize) {
+ iCount = iSize - iStart;
+ }
+ if (iCount < 1) {
+ return 0;
+ }
+ iSize = CFX_BaseArray::GetSize();
+ CFX_BaseArray::AddSpaceTo(iSize + iCount - 1);
+ FX_LPBYTE *pStart = CFX_BaseArray::GetAt(iSize);
+ FX_INT32 iBlockSize = CFX_BaseArray::GetBlockSize();
+ iSize = iStart + iCount;
+ for (FX_INT32 i = iStart; i < iSize; i ++) {
+ FXTARGET_NewWith ((void*)pStart)baseType(src.GetAt(i));
+ pStart += iBlockSize;
+ }
+ return iCount;
+ }
+ FX_INT32 Copy(const CFX_ObjectBaseArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ FXSYS_assert(GetBlockSize() == src.GetBlockSize());
+ if (iCount == 0) {
+ return 0;
+ }
+ FX_INT32 iSize = src.GetSize();
+ FXSYS_assert(iStart > -1 && iStart < iSize);
+ if (iCount < 0) {
+ iCount = iSize;
+ }
+ if (iStart + iCount > iSize) {
+ iCount = iSize - iStart;
+ }
+ if (iCount < 1) {
+ return 0;
+ }
+ RemoveAll(TRUE);
+ CFX_BaseArray::AddSpaceTo(iCount - 1);
+ FX_LPBYTE *pStart = CFX_BaseArray::GetAt(0);
+ FX_INT32 iBlockSize = CFX_BaseArray::GetBlockSize();
+ iSize = iStart + iCount;
+ for (FX_INT32 i = iStart; i < iSize; i ++) {
+ FXTARGET_New ((void*)pStart)baseType(src.GetAt(i));
+ pStart += iBlockSize;
+ }
+ return iCount;
+ }
+ FX_INT32 RemoveLast(FX_INT32 iCount = -1)
+ {
+ FX_INT32 iSize = CFX_BaseArray::GetSize();
+ if (iCount < 0 || iCount > iSize) {
+ iCount = iSize;
+ }
+ if (iCount == 0) {
+ return iSize;
+ }
+ for (FX_INT32 i = iSize - iCount; i < iSize; i ++) {
+ ((baseType*)GetPtrAt(i))->~baseType();
+ }
+ return CFX_BaseArray::RemoveLast(iCount);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE)
+ {
+ FX_INT32 iSize = CFX_BaseArray::GetSize();
+ for (FX_INT32 i = 0; i < iSize; i ++) {
+ ((baseType*)GetPtrAt(i))->~baseType();
+ }
+ CFX_BaseArray::RemoveAll(bLeaveMemory);
+ }
+};
+class CFX_BaseMassArray : public CFX_Target
+{
+protected:
+ CFX_BaseMassArray(FX_INT32 iChunkSize, FX_INT32 iBlockSize);
+ ~CFX_BaseMassArray();
+ FX_INT32 GetSize() const;
+ FX_LPBYTE AddSpaceTo(FX_INT32 index);
+ FX_LPBYTE GetAt(FX_INT32 index) const;
+ FX_INT32 Append(const CFX_BaseMassArray &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1);
+ FX_INT32 Copy(const CFX_BaseMassArray &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1);
+ FX_INT32 RemoveLast(FX_INT32 iCount = -1);
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE);
+ FX_LPVOID m_pData;
+};
+template<class baseType>
+class CFX_MassArrayTemplate : public CFX_BaseMassArray
+{
+public:
+ CFX_MassArrayTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {}
+ CFX_MassArrayTemplate(FX_INT32 iChunkSize, FX_INT32 iBlockSize) : CFX_BaseMassArray(iChunkSize, iBlockSize) {}
+ FX_INT32 GetSize() const
+ {
+ return CFX_BaseMassArray::GetSize();
+ }
+ baseType* AddSpace()
+ {
+ return (baseType*)CFX_BaseMassArray::AddSpaceTo(CFX_BaseMassArray::GetSize());
+ }
+ FX_INT32 Add(const baseType &element)
+ {
+ FX_INT32 index = CFX_BaseMassArray::GetSize();
+ *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element;
+ return index;
+ }
+ baseType& GetAt(FX_INT32 index) const
+ {
+ return *(baseType*)CFX_BaseMassArray::GetAt(index);
+ }
+ baseType* GetPtrAt(FX_INT32 index) const
+ {
+ return (baseType*)CFX_BaseMassArray::GetAt(index);
+ }
+ void SetAt(FX_INT32 index, const baseType &element)
+ {
+ *(baseType*)CFX_BaseMassArray::GetAt(index) = element;
+ }
+ void SetAtGrow(FX_INT32 index, const baseType &element)
+ {
+ *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element;
+ }
+ FX_INT32 Append(const CFX_MassArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ return CFX_BaseMassArray::Append(src, iStart, iCount);
+ }
+ FX_INT32 Copy(const CFX_MassArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ return CFX_BaseMassArray::Copy(src, iStart, iCount);
+ }
+ FX_INT32 RemoveLast(FX_INT32 iCount = -1)
+ {
+ return CFX_BaseMassArray::RemoveLast(iCount);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE)
+ {
+ CFX_BaseMassArray::RemoveAll(bLeaveMemory);
+ }
+};
+typedef CFX_MassArrayTemplate<FX_LPVOID> CFX_PtrMassArray;
+typedef CFX_MassArrayTemplate<FX_INT32> CFX_Int32MassArray;
+typedef CFX_MassArrayTemplate<FX_DWORD> CFX_DWordMassArray;
+typedef CFX_MassArrayTemplate<FX_WORD> CFX_WordMassArray;
+typedef CFX_MassArrayTemplate<CFX_Rect> CFX_RectMassArray;
+typedef CFX_MassArrayTemplate<CFX_RectF> CFX_RectFMassArray;
+template<class baseType>
+class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray
+{
+public:
+ CFX_ObjectMassArrayTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {}
+ ~CFX_ObjectMassArrayTemplate()
+ {
+ RemoveAll(FALSE);
+ }
+ FX_INT32 GetSize() const
+ {
+ return CFX_BaseMassArray::GetSize();
+ }
+ FX_INT32 Add(const baseType &element)
+ {
+ FX_INT32 index = CFX_BaseMassArray::GetSize();
+ baseType *p = (baseType*)CFX_BaseMassArray::AddSpaceTo(index);
+ FXTARGET_New ((void*)p)baseType(element);
+ return index;
+ }
+ baseType& GetAt(FX_INT32 index) const
+ {
+ return *(baseType*)CFX_BaseMassArray::GetAt(index);
+ }
+ baseType* GetPtrAt(FX_INT32 index) const
+ {
+ return (baseType*)CFX_BaseMassArray::GetAt(index);
+ }
+ FX_INT32 Append(const CFX_ObjectMassArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ if (iCount == 0) {
+ return CFX_BaseMassArray::GetSize();
+ }
+ FX_INT32 iSize = src.GetSize();
+ FXSYS_assert(iStart > -1 && iStart < iSize);
+ if (iCount < 0) {
+ iCount = iSize;
+ }
+ FX_INT32 iEnd = iStart + iCount;
+ if (iEnd > iSize) {
+ iEnd = iSize;
+ }
+ for (FX_INT32 i = iStart; i < iEnd; i ++) {
+ Add(src.GetAt(i));
+ }
+ return CFX_BaseMassArray::GetSize();
+ }
+ FX_INT32 Copy(const CFX_ObjectMassArrayTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ if (iCount == 0) {
+ return CFX_BaseMassArray::GetSize();
+ }
+ FX_INT32 iSize = src.GetSize();
+ FXSYS_assert(iStart > -1 && iStart < iSize);
+ if (iCount < 0) {
+ iCount = iSize;
+ }
+ FX_INT32 iEnd = iStart + iCount;
+ if (iEnd > iSize) {
+ iEnd = iSize;
+ }
+ RemoveAll(TRUE);
+ for (FX_INT32 i = iStart; i < iEnd; i ++) {
+ Add(src.GetAt(i));
+ }
+ return CFX_BaseMassArray::GetSize();
+ }
+ FX_INT32 RemoveLast(FX_INT32 iCount = -1)
+ {
+ FX_INT32 iSize = CFX_BaseMassArray::GetSize();
+ if (iCount < 0 || iCount > iSize) {
+ iCount = iSize;
+ }
+ if (iCount == 0) {
+ return iSize;
+ }
+ for (FX_INT32 i = iSize - iCount; i < iSize; i ++) {
+ ((baseType*)GetPtrAt(i))->~baseType();
+ }
+ return CFX_BaseMassArray::RemoveLast(iCount);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE)
+ {
+ FX_INT32 iSize = CFX_BaseMassArray::GetSize();
+ for (FX_INT32 i = 0; i < iSize; i ++) {
+ ((baseType*)GetPtrAt(i))->~baseType();
+ }
+ CFX_BaseMassArray::RemoveAll(bLeaveMemory);
+ }
+};
+class CFX_BaseDiscreteArray : public CFX_Target
+{
+protected:
+ CFX_BaseDiscreteArray(FX_INT32 iChunkSize, FX_INT32 iBlockSize);
+ ~CFX_BaseDiscreteArray();
+ FX_LPBYTE AddSpaceTo(FX_INT32 index);
+ FX_LPBYTE GetAt(FX_INT32 index) const;
+ void RemoveAll();
+ FX_LPVOID m_pData;
+};
+template<class baseType>
+class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray
+{
+public:
+ CFX_DiscreteArrayTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {}
+ baseType& GetAt(FX_INT32 index, const baseType &defValue) const
+ {
+ baseType *p = (baseType*)CFX_BaseDiscreteArray::GetAt(index);
+ return p == NULL ? (baseType&)defValue : *p;
+ }
+ baseType* GetPtrAt(FX_INT32 index) const
+ {
+ return (baseType*)CFX_BaseDiscreteArray::GetAt(index);
+ }
+ void SetAtGrow(FX_INT32 index, const baseType &element)
+ {
+ *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element;
+ }
+ void RemoveAll()
+ {
+ CFX_BaseDiscreteArray::RemoveAll();
+ }
+};
+typedef CFX_DiscreteArrayTemplate<FX_LPVOID> CFX_PtrDiscreteArray;
+typedef CFX_DiscreteArrayTemplate<FX_DWORD> CFX_DWordDiscreteArray;
+typedef CFX_DiscreteArrayTemplate<FX_WORD> CFX_WordDiscreteArray;
+class CFX_BaseStack : public CFX_Target
+{
+protected:
+ CFX_BaseStack(FX_INT32 iChunkSize, FX_INT32 iBlockSize);
+ ~CFX_BaseStack();
+ FX_LPBYTE Push();
+ void Pop();
+ FX_LPBYTE GetTopElement() const;
+ FX_INT32 GetSize() const;
+ FX_LPBYTE GetAt(FX_INT32 index) const;
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE);
+ FX_LPVOID m_pData;
+};
+template<class baseType>
+class CFX_StackTemplate : public CFX_BaseStack
+{
+public:
+ CFX_StackTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseStack(iChunkSize, sizeof(baseType)) {}
+ FX_INT32 Push(const baseType &element)
+ {
+ FX_INT32 index = CFX_BaseStack::GetSize();
+ *(baseType*)CFX_BaseStack::Push() = element;
+ return index;
+ }
+ void Pop()
+ {
+ CFX_BaseStack::Pop();
+ }
+ baseType* GetTopElement() const
+ {
+ return (baseType*)CFX_BaseStack::GetTopElement();
+ }
+ FX_INT32 GetSize() const
+ {
+ return CFX_BaseStack::GetSize();
+ }
+ baseType* GetAt(FX_INT32 index) const
+ {
+ return (baseType*)CFX_BaseStack::GetAt(index);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE)
+ {
+ CFX_BaseStack::RemoveAll(bLeaveMemory);
+ }
+};
+typedef CFX_StackTemplate<FX_LPVOID> CFX_PtrStack;
+typedef CFX_StackTemplate<FX_DWORD> CFX_DWordStack;
+typedef CFX_StackTemplate<FX_WORD> CFX_WordStack;
+typedef CFX_StackTemplate<FX_INT32> CFX_Int32Stack;
+template<class baseType>
+class CFX_ObjectStackTemplate : public CFX_BaseStack
+{
+public:
+ CFX_ObjectStackTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseStack(iChunkSize, sizeof(baseType)) {}
+ ~CFX_ObjectStackTemplate()
+ {
+ RemoveAll();
+ }
+ FX_INT32 Push(const baseType &element)
+ {
+ FX_INT32 index = CFX_BaseStack::GetSize();
+ baseType *p = (baseType*)CFX_BaseStack::Push();
+ FXTARGET_New ((void*)p)baseType(element);
+ return index;
+ }
+ void Pop()
+ {
+ baseType *p = (baseType*)CFX_BaseStack::GetTopElement();
+ if (p != NULL) {
+ p->~baseType();
+ }
+ CFX_BaseStack::Pop();
+ }
+ baseType* GetTopElement() const
+ {
+ return (baseType*)CFX_BaseStack::GetTopElement();
+ }
+ FX_INT32 GetSize() const
+ {
+ return CFX_BaseStack::GetSize();
+ }
+ baseType* GetAt(FX_INT32 index) const
+ {
+ return (baseType*)CFX_BaseStack::GetAt(index);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE)
+ {
+ FX_INT32 iSize = CFX_BaseStack::GetSize();
+ for (FX_INT32 i = 0; i < iSize; i ++) {
+ ((baseType*)CFX_BaseStack::GetAt(i))->~baseType();
+ }
+ CFX_BaseStack::RemoveAll(bLeaveMemory);
+ }
+ FX_INT32 Copy(const CFX_ObjectStackTemplate &src, FX_INT32 iStart = 0, FX_INT32 iCount = -1)
+ {
+ if (iCount == 0) {
+ return CFX_BaseStack::GetSize();
+ }
+ FX_INT32 iSize = src.GetSize();
+ FXSYS_assert(iStart > -1 && iStart < iSize);
+ if (iCount < 0) {
+ iCount = iSize;
+ }
+ FX_INT32 iEnd = iStart + iCount;
+ if (iEnd > iSize) {
+ iEnd = iSize;
+ }
+ RemoveAll(TRUE);
+ for (FX_INT32 i = iStart; i < iEnd; i ++) {
+ Push(*src.GetAt(i));
+ }
+ return CFX_BaseStack::GetSize();
+ }
+};
+template<class baseType>
+class CFX_CPLTreeNode : public CFX_Target
+{
+public:
+ typedef CFX_CPLTreeNode<baseType> CPLTreeNode;
+ CFX_CPLTreeNode() : m_pParentNode(NULL)
+ , m_pChildNode(NULL)
+ , m_pPrevNode(NULL)
+ , m_pNextNode(NULL)
+ , m_Data()
+ {
+ }
+ enum TreeNode {Root = 0, Parent, FirstSibling, PreviousSibling, NextSibling, LastSibling, FirstNeighbor, PreviousNeighbor, NextNeighbor, LastNeighbor, FirstChild, LastChild};
+ CPLTreeNode* GetNode(TreeNode eNode) const
+ {
+ switch (eNode) {
+ case Root: {
+ CPLTreeNode *pParent = (CPLTreeNode*)this;
+ CPLTreeNode *pTemp;
+ while ((pTemp = pParent->m_pParentNode) != NULL) {
+ pParent = pTemp;
+ }
+ return pParent;
+ }
+ case Parent:
+ return m_pParentNode;
+ case FirstSibling: {
+ CPLTreeNode *pNode = (CPLTreeNode*)this;
+ CPLTreeNode *pTemp;
+ while ((pTemp = pNode->m_pPrevNode) != NULL) {
+ pNode = pTemp;
+ }
+ return pNode == (CPLTreeNode*)this ? NULL : pNode;
+ }
+ case PreviousSibling:
+ return m_pPrevNode;
+ case NextSibling:
+ return m_pNextNode;
+ case LastSibling: {
+ CPLTreeNode *pNode = (CPLTreeNode*)this;
+ CPLTreeNode *pTemp;
+ while ((pTemp = pNode->m_pNextNode) != NULL) {
+ pNode = pTemp;
+ }
+ return pNode == (CPLTreeNode*)this ? NULL : pNode;
+ }
+ case FirstNeighbor: {
+ CPLTreeNode *pParent = (CPLTreeNode*)this;
+ CPLTreeNode *pTemp;
+ while ((pTemp = pParent->m_pParentNode) != NULL) {
+ pParent = pTemp;
+ }
+ return pParent == (CPLTreeNode*)this ? NULL : pParent;
+ }
+ case PreviousNeighbor: {
+ if (m_pPrevNode == NULL) {
+ return m_pParentNode;
+ }
+ CPLTreeNode *pNode = m_pPrevNode;
+ CPLTreeNode *pTemp;
+ while ((pTemp = pNode->m_pChildNode) != NULL) {
+ pNode = pTemp;
+ while ((pTemp = pNode->m_pNextNode) != NULL) {
+ pNode = pTemp;
+ }
+ }
+ return pNode;
+ }
+ case NextNeighbor: {
+ if (m_pChildNode != NULL) {
+ return m_pChildNode;
+ }
+ if (m_pNextNode != NULL) {
+ return m_pNextNode;
+ }
+ CPLTreeNode *pNode = m_pParentNode;
+ while (pNode != NULL) {
+ if (pNode->m_pNextNode != NULL) {
+ return pNode->m_pNextNode;
+ }
+ pNode = pNode->m_pParentNode;
+ }
+ return NULL;
+ }
+ case LastNeighbor: {
+ CPLTreeNode *pNode = (CPLTreeNode*)this;
+ CPLTreeNode *pTemp;
+ while ((pTemp = pNode->m_pParentNode) != NULL) {
+ pNode = pTemp;
+ }
+ while (TRUE) {
+ CPLTreeNode *pTemp;
+ while ((pTemp = pNode->m_pNextNode) != NULL) {
+ pNode = pTemp;
+ }
+ if (pNode->m_pChildNode == NULL) {
+ break;
+ }
+ pNode = pNode->m_pChildNode;
+ }
+ return pNode == (CPLTreeNode*)this ? NULL : pNode;
+ }
+ case FirstChild:
+ return m_pChildNode;
+ case LastChild: {
+ if (m_pChildNode == NULL) {
+ return NULL;
+ }
+ CPLTreeNode *pChild = m_pChildNode;
+ CPLTreeNode *pTemp;
+ while ((pTemp = pChild->m_pNextNode) != NULL) {
+ pChild = pTemp;
+ }
+ return pChild;
+ }
+ default:
+ break;
+ }
+ return NULL;
+ }
+ void SetParentNode(CPLTreeNode *pNode)
+ {
+ m_pParentNode = pNode;
+ }
+ FX_INT32 CountChildNodes() const
+ {
+ FX_INT32 iCount = 0;
+ CPLTreeNode *pNode = m_pChildNode;
+ while (pNode) {
+ iCount ++;
+ pNode = pNode->m_pNextNode;
+ }
+ return iCount;
+ }
+ CPLTreeNode* GetChildNode(FX_INT32 iIndex) const
+ {
+ FX_INT32 iCount = 0;
+ CPLTreeNode *pNode = m_pChildNode;
+ while (pNode) {
+ if (iIndex == iCount) {
+ return pNode;
+ }
+ iCount ++;
+ pNode = pNode->m_pNextNode;
+ }
+ return NULL;
+ }
+ FX_INT32 GetNodeIndex() const
+ {
+ FX_INT32 index = 0;
+ CPLTreeNode *pNode = m_pPrevNode;
+ while (pNode != NULL) {
+ index ++;
+ pNode = pNode->m_pPrevNode;
+ }
+ return index;
+ }
+ FX_BOOL IsParentNode(const CPLTreeNode *pNode) const
+ {
+ CPLTreeNode *pParent = m_pParentNode;
+ while (pParent != NULL) {
+ if (pParent == pNode) {
+ return TRUE;
+ }
+ pParent = pParent->GetTreeNode(Parent);
+ }
+ return FALSE;
+ }
+ FX_BOOL IsChildNode(const CPLTreeNode *pNode) const
+ {
+ if (pNode == NULL) {
+ return FALSE;
+ }
+ return pNode->IsParentNode((const CPLTreeNode*)this);
+ }
+ void SetChildNode(CPLTreeNode *pNode)
+ {
+ m_pChildNode = pNode;
+ }
+ void SetPrevNode(CPLTreeNode *pNode)
+ {
+ m_pPrevNode = pNode;
+ }
+ void SetNextNode(CPLTreeNode *pNode)
+ {
+ m_pNextNode = pNode;
+ }
+ FX_INT32 GetNodeLevel() const
+ {
+ FX_INT32 iLevel = 0;
+ CPLTreeNode *pNode = (CPLTreeNode*)this;
+ while ((pNode = pNode->m_pParentNode) != NULL) {
+ iLevel ++;
+ }
+ return iLevel;
+ }
+ FX_BOOL IsRootNode() const
+ {
+ return m_pParentNode == NULL;
+ }
+ baseType GetData() const
+ {
+ return m_Data;
+ }
+ void SetData(baseType data)
+ {
+ m_Data = data;
+ }
+protected:
+ CPLTreeNode *m_pParentNode;
+ CPLTreeNode *m_pChildNode;
+ CPLTreeNode *m_pPrevNode;
+ CPLTreeNode *m_pNextNode;
+ baseType m_Data;
+ friend class CFX_CPLTree<baseType>;
+};
+template<class baseType>
+class CFX_CPLTree : public CFX_Object
+{
+public:
+ typedef CFX_CPLTreeNode<baseType> CPLTreeNode;
+ CFX_CPLTree() : m_Root()
+ {
+ }
+ ~CFX_CPLTree()
+ {
+ CPLTreeNode *pNode = m_Root.GetNode(CPLTreeNode::LastNeighbor);
+ while (pNode != NULL) {
+ if (pNode->IsRootNode()) {
+ break;
+ }
+ CPLTreeNode *pTemp = pNode->GetNode(CPLTreeNode::PreviousNeighbor);
+ delete pNode;
+ pNode = pTemp;
+ }
+ }
+ CPLTreeNode* GetRoot()
+ {
+ return &m_Root;
+ }
+ CPLTreeNode* AddChild(baseType data, CPLTreeNode *pParent = NULL)
+ {
+ if (pParent == NULL) {
+ pParent = &m_Root;
+ }
+ CPLTreeNode *pChild = FXTARGET_New CPLTreeNode;
+ pChild->SetParentNode(pParent);
+ pChild->SetData(data);
+ if (pParent->m_pChildNode == NULL) {
+ pParent->m_pChildNode = pChild;
+ } else {
+ CPLTreeNode *pLast = pParent->GetNode(CPLTreeNode::LastChild);
+ pChild->SetPrevNode(pLast);
+ pLast->SetNextNode(pChild);
+ }
+ return pChild;
+ }
+protected:
+ CPLTreeNode m_Root;
+};
+#endif