diff options
Diffstat (limited to 'xfa/src/fgas/include')
-rw-r--r-- | xfa/src/fgas/include/fgas.h | 52 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_alg.h | 94 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_cpg.h | 496 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_datetime.h | 784 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_fnt.h | 528 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_lbk.h | 78 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_lgg.h | 534 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_locale.h | 406 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_mem.h | 112 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_rbk.h | 456 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_sax.h | 126 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_stm.h | 144 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_sys.h | 130 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_tbk.h | 428 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_ucd.h | 66 | ||||
-rw-r--r-- | xfa/src/fgas/include/fx_utl.h | 1448 |
16 files changed, 2941 insertions, 2941 deletions
diff --git a/xfa/src/fgas/include/fgas.h b/xfa/src/fgas/include/fgas.h index dc155a0818..adc4d2bd95 100644 --- a/xfa/src/fgas/include/fgas.h +++ b/xfa/src/fgas/include/fgas.h @@ -1,26 +1,26 @@ -// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-// TODO(thestig): Remove this file and do IWYU.
-
-#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
+// 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 + +// TODO(thestig): Remove this file and do IWYU. + +#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 index 5be7e31d0b..11ccdc63a7 100644 --- a/xfa/src/fgas/include/fx_alg.h +++ b/xfa/src/fgas/include/fx_alg.h @@ -1,47 +1,47 @@ -// 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
-int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst);
-int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst);
-int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst);
-uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow);
-int32_t FX_SeparateStringW(const FX_WCHAR* pStr,
- int32_t iStrLen,
- FX_WCHAR delimiter,
- CFX_WideStringArray& pieces);
-#ifdef __cplusplus
-};
-#endif
-template <class baseType>
-class CFX_DSPATemplate {
- public:
- int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) {
- FXSYS_assert(pArray != NULL);
- if (iCount < 1) {
- return -1;
- }
- int32_t 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
+// 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 +int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst); +int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); +int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); +uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow); +int32_t FX_SeparateStringW(const FX_WCHAR* pStr, + int32_t iStrLen, + FX_WCHAR delimiter, + CFX_WideStringArray& pieces); +#ifdef __cplusplus +}; +#endif +template <class baseType> +class CFX_DSPATemplate { + public: + int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { + FXSYS_assert(pArray != NULL); + if (iCount < 1) { + return -1; + } + int32_t 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 index 3155e46398..357ffd820a 100644 --- a/xfa/src/fgas/include/fx_cpg.h +++ b/xfa/src/fgas/include/fx_cpg.h @@ -1,248 +1,248 @@ -// 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(uint8_t charset);
-FX_WORD FX_GetCharsetFromCodePage(FX_WORD codepage);
-FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength);
-FX_WORD FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength);
-FX_WORD FX_GetDefCodePageByLanguage(FX_WORD wLanguage);
-void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength);
-void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc,
- FX_WCHAR* pDst,
- int32_t iLength);
-void FX_UTF16ToWChar(void* pBuffer, int32_t iLength);
-void FX_UTF16ToWCharCopy(const FX_WORD* pUTF16,
- FX_WCHAR* pWChar,
- int32_t iLength);
-void FX_WCharToUTF16(void* pBuffer, int32_t iLength);
-void FX_WCharToUTF16Copy(const FX_WCHAR* pWChar,
- FX_WORD* pUTF16,
- int32_t iLength);
-int32_t FX_DecodeString(FX_WORD wCodePage,
- const FX_CHAR* pSrc,
- int32_t* pSrcLen,
- FX_WCHAR* pDst,
- int32_t* pDstLen,
- FX_BOOL bErrBreak = FALSE);
-int32_t FX_UTF8Decode(const FX_CHAR* pSrc,
- int32_t* pSrcLen,
- FX_WCHAR* pDst,
- int32_t* pDstLen);
-enum FX_CODESYSTEM {
- FX_MBCS = 0,
- FX_SBCS,
- FX_DBCS,
-};
-typedef struct _FX_CODEPAGE_HEADER {
- uint16_t uCPID;
- uint8_t uMinCharBytes;
- uint8_t 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 {
- uint16_t uMapType;
- uint16_t uUniocde;
-} FX_CPCU_MAPTABLE1;
-typedef struct _FX_CPCU_MAPTABLE2 {
- uint8_t uTrailByte;
- uint8_t uMapType;
- uint16_t uOffset;
-} FX_CPCU_MAPTABLE2;
-typedef struct _FX_CPCU_MAPINFO {
- FX_CPCU_MAPTABLE1* pMapTable1;
- FX_CPCU_MAPTABLE2* pMapTable2;
- const uint8_t* pMapData;
-} FX_CPCU_MAPINFO;
-typedef struct _FX_CPUC_MAPTABLE {
- uint16_t uStartUnicode;
- uint16_t uEndUnicode;
- uint16_t uMapType;
- uint16_t uOffset;
-} FX_CPUC_MAPTABLE;
-typedef struct _FX_CPUC_MAPINFO {
- uint32_t uMapCount;
- FX_CPUC_MAPTABLE* pMapTable;
- const uint8_t* 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 {
- uint32_t uHash;
- uint32_t uCodePage;
-} FX_STR2CPHASH;
-typedef struct _FX_CHARSET_MAP {
- uint16_t charset;
- uint16_t 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 ~IFX_CodePage() {}
- 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(uint8_t byte) const = 0;
- virtual int32_t GetMinBytesPerChar() const = 0;
- virtual int32_t 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
+// 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(uint8_t charset); +FX_WORD FX_GetCharsetFromCodePage(FX_WORD codepage); +FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength); +FX_WORD FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength); +FX_WORD FX_GetDefCodePageByLanguage(FX_WORD wLanguage); +void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength); +void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc, + FX_WCHAR* pDst, + int32_t iLength); +void FX_UTF16ToWChar(void* pBuffer, int32_t iLength); +void FX_UTF16ToWCharCopy(const FX_WORD* pUTF16, + FX_WCHAR* pWChar, + int32_t iLength); +void FX_WCharToUTF16(void* pBuffer, int32_t iLength); +void FX_WCharToUTF16Copy(const FX_WCHAR* pWChar, + FX_WORD* pUTF16, + int32_t iLength); +int32_t FX_DecodeString(FX_WORD wCodePage, + const FX_CHAR* pSrc, + int32_t* pSrcLen, + FX_WCHAR* pDst, + int32_t* pDstLen, + FX_BOOL bErrBreak = FALSE); +int32_t FX_UTF8Decode(const FX_CHAR* pSrc, + int32_t* pSrcLen, + FX_WCHAR* pDst, + int32_t* pDstLen); +enum FX_CODESYSTEM { + FX_MBCS = 0, + FX_SBCS, + FX_DBCS, +}; +typedef struct _FX_CODEPAGE_HEADER { + uint16_t uCPID; + uint8_t uMinCharBytes; + uint8_t 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 { + uint16_t uMapType; + uint16_t uUniocde; +} FX_CPCU_MAPTABLE1; +typedef struct _FX_CPCU_MAPTABLE2 { + uint8_t uTrailByte; + uint8_t uMapType; + uint16_t uOffset; +} FX_CPCU_MAPTABLE2; +typedef struct _FX_CPCU_MAPINFO { + FX_CPCU_MAPTABLE1* pMapTable1; + FX_CPCU_MAPTABLE2* pMapTable2; + const uint8_t* pMapData; +} FX_CPCU_MAPINFO; +typedef struct _FX_CPUC_MAPTABLE { + uint16_t uStartUnicode; + uint16_t uEndUnicode; + uint16_t uMapType; + uint16_t uOffset; +} FX_CPUC_MAPTABLE; +typedef struct _FX_CPUC_MAPINFO { + uint32_t uMapCount; + FX_CPUC_MAPTABLE* pMapTable; + const uint8_t* 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 { + uint32_t uHash; + uint32_t uCodePage; +} FX_STR2CPHASH; +typedef struct _FX_CHARSET_MAP { + uint16_t charset; + uint16_t 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 ~IFX_CodePage() {} + 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(uint8_t byte) const = 0; + virtual int32_t GetMinBytesPerChar() const = 0; + virtual int32_t 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 index d723b4367e..773acbd2fb 100644 --- a/xfa/src/fgas/include/fx_datetime.h +++ b/xfa/src/fgas/include/fx_datetime.h @@ -1,392 +1,392 @@ -// 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 int64_t FX_UNITIME;
-enum FX_WEEKDAY {
- FX_Sunday = 0,
- FX_Monday,
- FX_Tuesday,
- FX_Wednesday,
- FX_Thursday,
- FX_Friday,
- FX_Saturday,
-};
-FX_BOOL FX_IsLeapYear(int32_t iYear);
-int32_t FX_DaysInYear(int32_t iYear);
-uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth);
-class CFX_Unitime {
- 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(int32_t year,
- uint8_t month,
- uint8_t day,
- uint8_t hour = 0,
- uint8_t minute = 0,
- uint8_t second = 0,
- FX_WORD millisecond = 0);
- void Set(FX_UNITIME t);
- int32_t GetYear() const;
- uint8_t GetMonth() const;
- uint8_t GetDay() const;
- FX_WEEKDAY GetDayOfWeek() const;
- FX_WORD GetDayOfYear() const;
- int64_t GetDayOfAD() const;
- uint8_t GetHour() const;
- uint8_t GetMinute() const;
- uint8_t GetSecond() const;
- FX_WORD GetMillisecond() const;
- FX_BOOL AddYears(int32_t iYears);
- FX_BOOL AddMonths(int32_t iMonths);
- FX_BOOL AddDays(int32_t iDays);
- FX_BOOL AddHours(int32_t iHours);
- FX_BOOL AddMinutes(int32_t iMinutes);
- FX_BOOL AddSeconds(int32_t iSeconds);
- FX_BOOL AddMilliseconds(int32_t 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 {
- int32_t year;
- uint8_t month;
- uint8_t day;
-} FX_DATE, *FX_LPDATE;
-typedef FX_DATE const* FX_LPCDATE;
-typedef struct _FX_TIME {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- FX_WORD millisecond;
-} FX_TIME, *FX_LPTIME;
-typedef FX_TIME const* FX_LPCTIME;
-typedef struct _FX_TIMEZONE {
- int8_t tzHour;
- uint8_t tzMinute;
-} FX_TIMEZONE, *FX_LPTIMEZONE;
-typedef FX_TIMEZONE const* FX_LPCTIMEZONE;
-typedef struct _FX_DATETIME {
- union {
- struct {
- int32_t year;
- uint8_t month;
- uint8_t day;
- } sDate;
- FX_DATE aDate;
- } Date;
- union {
- struct {
- uint8_t hour;
- uint8_t minute;
- uint8_t 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 {
- int32_t year;
- uint8_t month;
- uint8_t day;
- };
- FX_DATE date;
- };
- union {
- struct {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- FX_WORD millisecond;
- };
- FX_TIME time;
- };
- };
- FX_DATETIME dt;
- };
- union {
- struct {
- int8_t tzHour;
- uint8_t 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_DateTime() {}
- CFX_DateTime(const FX_DATETIME& dt) { m_DateTime = dt; }
- CFX_DateTime(const CFX_DateTime& dt) { m_DateTime = dt.m_DateTime; }
- virtual ~CFX_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(int32_t year,
- uint8_t month,
- uint8_t day,
- uint8_t hour = 0,
- uint8_t minute = 0,
- uint8_t second = 0,
- FX_WORD millisecond = 0);
- virtual FX_BOOL FromUnitime(FX_UNITIME t);
- virtual FX_UNITIME ToUnitime() const;
- virtual int32_t GetYear() const;
- virtual uint8_t GetMonth() const;
- virtual uint8_t GetDay() const;
- virtual FX_WEEKDAY GetDayOfWeek() const;
- virtual FX_WORD GetDayOfYear() const;
- virtual int64_t GetDayOfAD() const;
- virtual uint8_t GetHour() const;
- virtual uint8_t GetMinute() const;
- virtual uint8_t GetSecond() const;
- virtual FX_WORD GetMillisecond() const;
- virtual FX_BOOL AddYears(int32_t iYears);
- virtual FX_BOOL AddMonths(int32_t iMonths);
- virtual FX_BOOL AddDays(int32_t iDays);
- virtual FX_BOOL AddHours(int32_t iHours);
- virtual FX_BOOL AddMinutes(int32_t iMinutes);
- virtual FX_BOOL AddSeconds(int32_t iSeconds);
- virtual FX_BOOL AddMilliseconds(int32_t 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
+// 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 int64_t FX_UNITIME; +enum FX_WEEKDAY { + FX_Sunday = 0, + FX_Monday, + FX_Tuesday, + FX_Wednesday, + FX_Thursday, + FX_Friday, + FX_Saturday, +}; +FX_BOOL FX_IsLeapYear(int32_t iYear); +int32_t FX_DaysInYear(int32_t iYear); +uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); +class CFX_Unitime { + 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(int32_t year, + uint8_t month, + uint8_t day, + uint8_t hour = 0, + uint8_t minute = 0, + uint8_t second = 0, + FX_WORD millisecond = 0); + void Set(FX_UNITIME t); + int32_t GetYear() const; + uint8_t GetMonth() const; + uint8_t GetDay() const; + FX_WEEKDAY GetDayOfWeek() const; + FX_WORD GetDayOfYear() const; + int64_t GetDayOfAD() const; + uint8_t GetHour() const; + uint8_t GetMinute() const; + uint8_t GetSecond() const; + FX_WORD GetMillisecond() const; + FX_BOOL AddYears(int32_t iYears); + FX_BOOL AddMonths(int32_t iMonths); + FX_BOOL AddDays(int32_t iDays); + FX_BOOL AddHours(int32_t iHours); + FX_BOOL AddMinutes(int32_t iMinutes); + FX_BOOL AddSeconds(int32_t iSeconds); + FX_BOOL AddMilliseconds(int32_t 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 { + int32_t year; + uint8_t month; + uint8_t day; +} FX_DATE, *FX_LPDATE; +typedef FX_DATE const* FX_LPCDATE; +typedef struct _FX_TIME { + uint8_t hour; + uint8_t minute; + uint8_t second; + FX_WORD millisecond; +} FX_TIME, *FX_LPTIME; +typedef FX_TIME const* FX_LPCTIME; +typedef struct _FX_TIMEZONE { + int8_t tzHour; + uint8_t tzMinute; +} FX_TIMEZONE, *FX_LPTIMEZONE; +typedef FX_TIMEZONE const* FX_LPCTIMEZONE; +typedef struct _FX_DATETIME { + union { + struct { + int32_t year; + uint8_t month; + uint8_t day; + } sDate; + FX_DATE aDate; + } Date; + union { + struct { + uint8_t hour; + uint8_t minute; + uint8_t 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 { + int32_t year; + uint8_t month; + uint8_t day; + }; + FX_DATE date; + }; + union { + struct { + uint8_t hour; + uint8_t minute; + uint8_t second; + FX_WORD millisecond; + }; + FX_TIME time; + }; + }; + FX_DATETIME dt; + }; + union { + struct { + int8_t tzHour; + uint8_t 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_DateTime() {} + CFX_DateTime(const FX_DATETIME& dt) { m_DateTime = dt; } + CFX_DateTime(const CFX_DateTime& dt) { m_DateTime = dt.m_DateTime; } + virtual ~CFX_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(int32_t year, + uint8_t month, + uint8_t day, + uint8_t hour = 0, + uint8_t minute = 0, + uint8_t second = 0, + FX_WORD millisecond = 0); + virtual FX_BOOL FromUnitime(FX_UNITIME t); + virtual FX_UNITIME ToUnitime() const; + virtual int32_t GetYear() const; + virtual uint8_t GetMonth() const; + virtual uint8_t GetDay() const; + virtual FX_WEEKDAY GetDayOfWeek() const; + virtual FX_WORD GetDayOfYear() const; + virtual int64_t GetDayOfAD() const; + virtual uint8_t GetHour() const; + virtual uint8_t GetMinute() const; + virtual uint8_t GetSecond() const; + virtual FX_WORD GetMillisecond() const; + virtual FX_BOOL AddYears(int32_t iYears); + virtual FX_BOOL AddMonths(int32_t iMonths); + virtual FX_BOOL AddDays(int32_t iDays); + virtual FX_BOOL AddHours(int32_t iHours); + virtual FX_BOOL AddMinutes(int32_t iMinutes); + virtual FX_BOOL AddSeconds(int32_t iSeconds); + virtual FX_BOOL AddMilliseconds(int32_t 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 index 4d60af22e2..894ad183f5 100644 --- a/xfa/src/fgas/include/fx_fnt.h +++ b/xfa/src/fgas/include/fx_fnt.h @@ -1,264 +1,264 @@ -// 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 ~IFX_FontProvider() {}
- virtual FX_BOOL GetCharWidth(IFX_Font* pFont,
- FX_WCHAR wUnicode,
- int32_t& iWidth,
- FX_BOOL bCharCode = FALSE) = 0;
-};
-
-class IFX_Font {
- public:
- static IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
- FX_DWORD dwFontStyles,
- FX_WORD wCodePage,
- IFX_FontMgr* pFontMgr);
- static IFX_Font* LoadFont(const uint8_t* pBuffer,
- int32_t iLength,
- IFX_FontMgr* pFontMgr);
- static IFX_Font* LoadFont(const FX_WCHAR* 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 ~IFX_Font() {}
- 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 uint8_t GetCharSet() const = 0;
- virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
- int32_t& iWidth,
- FX_BOOL bCharCode = FALSE) = 0;
- virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode,
- FX_BOOL bCharCode = FALSE) = 0;
- virtual int32_t GetAscent() const = 0;
- virtual int32_t 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 int32_t GetItalicAngle() const = 0;
- virtual void Reset() = 0;
- virtual IFX_Font* GetSubstFont(int32_t 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 {
- const FX_WCHAR* 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;
- uint8_t 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,
- void* pUserData,
- const FX_WCHAR* pwsFaceName,
- FX_WCHAR wUnicode);
-FX_LPEnumAllFonts FX_GetDefFontEnumerator();
-typedef FX_LPCFONTDESCRIPTOR (*FX_LPMatchFont)(FX_LPFONTMATCHPARAMS pParams,
- const CFX_FontDescriptors& fonts,
- void* pUserData);
-FX_LPMatchFont FX_GetDefFontMatchor();
-class IFX_FontMgr {
- public:
- static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator,
- FX_LPMatchFont pMatcher = NULL,
- void* pUserData = NULL);
- virtual ~IFX_FontMgr() {}
- virtual void Release() = 0;
- virtual IFX_Font* GetDefFontByCodePage(
- FX_WORD wCodePage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByCharset(
- uint8_t nCharset,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByUnicode(
- FX_WCHAR wUnicode,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByLanguage(
- FX_WORD wLanguage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
- FX_DWORD dwFontStyles,
- FX_WORD wCodePage = 0xFFFF) = 0;
- virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0;
- virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName) = 0;
- virtual IFX_Font* LoadFont(IFX_Stream* pFontStream,
- const FX_WCHAR* 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_FontMgrDelegate() {}
- virtual IFX_Font* GetDefFontByCodePage(
- IFX_FontMgr* pFontMgr,
- FX_WORD wCodePage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByCharset(
- IFX_FontMgr* pFontMgr,
- uint8_t nCharset,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByUnicode(
- IFX_FontMgr* pFontMgr,
- FX_WCHAR wUnicode,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByLanguage(
- IFX_FontMgr* pFontMgr,
- FX_WORD wLanguage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
-};
-class IFX_FontSourceEnum {
- public:
- virtual ~IFX_FontSourceEnum() {}
- virtual void Release() = 0;
- virtual FX_POSITION GetStartPosition(void* pUserData = NULL) = 0;
- virtual IFX_FileAccess* GetNext(FX_POSITION& pos, void* pUserData = NULL) = 0;
-};
-IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum();
-class IFX_FontMgr {
- public:
- static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum,
- IFX_FontMgrDelegate* pDelegate = NULL,
- void* pUserData = NULL);
- virtual ~IFX_FontMgr() {}
- virtual void Release() = 0;
- virtual IFX_Font* GetDefFontByCodePage(
- FX_WORD wCodePage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByCharset(
- uint8_t nCharset,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByUnicode(
- FX_WCHAR wUnicode,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByLanguage(
- FX_WORD wLanguage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- inline IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
- FX_DWORD dwFontStyles,
- FX_WORD wCodePage) {
- return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
- }
- virtual IFX_Font* GetFontByCharset(uint8_t nCharset,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage,
- FX_DWORD dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* LoadFont(const uint8_t* pBuffer,
- int32_t iLength,
- int32_t iFaceIndex,
- int32_t* pFaceCount = NULL) = 0;
- virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName,
- int32_t iFaceIndex,
- int32_t* pFaceCount = NULL) = 0;
- virtual IFX_Font* LoadFont(IFX_Stream* pFontStream,
- int32_t iFaceIndex,
- int32_t* pFaceCount = NULL,
- FX_BOOL bSaveStream = FALSE) = 0;
-
- virtual void ClearFontCache() = 0;
- virtual void RemoveFont(IFX_Font* pFont) = 0;
-};
-#endif
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _FX_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 ~IFX_FontProvider() {} + virtual FX_BOOL GetCharWidth(IFX_Font* pFont, + FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bCharCode = FALSE) = 0; +}; + +class IFX_Font { + public: + static IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage, + IFX_FontMgr* pFontMgr); + static IFX_Font* LoadFont(const uint8_t* pBuffer, + int32_t iLength, + IFX_FontMgr* pFontMgr); + static IFX_Font* LoadFont(const FX_WCHAR* 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 ~IFX_Font() {} + 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 uint8_t GetCharSet() const = 0; + virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bCharCode = FALSE) = 0; + virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, + FX_BOOL bCharCode = FALSE) = 0; + virtual int32_t GetAscent() const = 0; + virtual int32_t 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 int32_t GetItalicAngle() const = 0; + virtual void Reset() = 0; + virtual IFX_Font* GetSubstFont(int32_t 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 { + const FX_WCHAR* 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; + uint8_t 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, + void* pUserData, + const FX_WCHAR* pwsFaceName, + FX_WCHAR wUnicode); +FX_LPEnumAllFonts FX_GetDefFontEnumerator(); +typedef FX_LPCFONTDESCRIPTOR (*FX_LPMatchFont)(FX_LPFONTMATCHPARAMS pParams, + const CFX_FontDescriptors& fonts, + void* pUserData); +FX_LPMatchFont FX_GetDefFontMatchor(); +class IFX_FontMgr { + public: + static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator, + FX_LPMatchFont pMatcher = NULL, + void* pUserData = NULL); + virtual ~IFX_FontMgr() {} + virtual void Release() = 0; + virtual IFX_Font* GetDefFontByCodePage( + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByCharset( + uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByUnicode( + FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByLanguage( + FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF) = 0; + virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName) = 0; + virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, + const FX_WCHAR* 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_FontMgrDelegate() {} + virtual IFX_Font* GetDefFontByCodePage( + IFX_FontMgr* pFontMgr, + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByCharset( + IFX_FontMgr* pFontMgr, + uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByUnicode( + IFX_FontMgr* pFontMgr, + FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByLanguage( + IFX_FontMgr* pFontMgr, + FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; +}; +class IFX_FontSourceEnum { + public: + virtual ~IFX_FontSourceEnum() {} + virtual void Release() = 0; + virtual FX_POSITION GetStartPosition(void* pUserData = NULL) = 0; + virtual IFX_FileAccess* GetNext(FX_POSITION& pos, void* pUserData = NULL) = 0; +}; +IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum(); +class IFX_FontMgr { + public: + static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum, + IFX_FontMgrDelegate* pDelegate = NULL, + void* pUserData = NULL); + virtual ~IFX_FontMgr() {} + virtual void Release() = 0; + virtual IFX_Font* GetDefFontByCodePage( + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByCharset( + uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByUnicode( + FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByLanguage( + FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + inline IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); + } + virtual IFX_Font* GetFontByCharset(uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* LoadFont(const uint8_t* pBuffer, + int32_t iLength, + int32_t iFaceIndex, + int32_t* pFaceCount = NULL) = 0; + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName, + int32_t iFaceIndex, + int32_t* pFaceCount = NULL) = 0; + virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, + int32_t iFaceIndex, + int32_t* 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 index a7421eb66b..2f0a300cd4 100644 --- a/xfa/src/fgas/include/fx_lbk.h +++ b/xfa/src/fgas/include/fx_lbk.h @@ -1,39 +1,39 @@ -// 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
-
-#include "core/include/fxcrt/fx_system.h"
-#include "xfa/src/fgas/include/fx_utl.h"
-
-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
-
-extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32];
-
-void FX_GetLineBreakPositions(const FX_WCHAR* pwsText,
- FX_LINEBREAKTYPE* pBrkType,
- int32_t iLength);
-void FX_GetLineBreakPositions(const FX_WCHAR* pwsText,
- int32_t iLength,
- CFX_Int32MassArray& bp);
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _FX_LINEBREAK +#define _FX_LINEBREAK + +#include "core/include/fxcrt/fx_system.h" +#include "xfa/src/fgas/include/fx_utl.h" + +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 + +extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32]; + +void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, + FX_LINEBREAKTYPE* pBrkType, + int32_t iLength); +void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, + int32_t iLength, + CFX_Int32MassArray& bp); +#endif diff --git a/xfa/src/fgas/include/fx_lgg.h b/xfa/src/fgas/include/fx_lgg.h index 9b981fc883..ff30c53bc7 100644 --- a/xfa/src/fgas/include/fx_lgg.h +++ b/xfa/src/fgas/include/fx_lgg.h @@ -1,267 +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
+// 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 index 17a2f91d0a..7ead311c53 100644 --- a/xfa/src/fgas/include/fx_locale.h +++ b/xfa/src/fgas/include/fx_locale.h @@ -1,203 +1,203 @@ -// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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 ~IFX_Locale() {}
- 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(int32_t nMonth,
- CFX_WideString& wsMonthName,
- FX_BOOL bAbbr = TRUE) const = 0;
- virtual void GetDayName(int32_t 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 ~IFX_LocaleMgr() {}
- 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(const CFX_WideStringC& wsLocaleName) = 0;
-};
-IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* 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(const CFX_WideStringC& wsTime,
- CFX_Unitime& datetime,
- IFX_Locale* pLocale);
-class IFX_FormatString {
- public:
- static IFX_FormatString* Create(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID);
-
- virtual ~IFX_FormatString() {}
- 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 {
- public:
- CFX_Decimal();
- CFX_Decimal(uint32_t val);
- CFX_Decimal(uint64_t val);
- CFX_Decimal(int32_t val);
- CFX_Decimal(int64_t val);
- CFX_Decimal(FX_FLOAT val, uint8_t scale = 3);
- CFX_Decimal(const CFX_WideStringC& str);
- CFX_Decimal(const CFX_ByteStringC& 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(uint8_t newScale);
- uint8_t GetScale();
- void SetAbs();
- void SetNegate();
- void SetFloor();
- void SetCeiling();
- void SetTruncate();
-
- protected:
- CFX_Decimal(uint32_t hi,
- uint32_t mid,
- uint32_t lo,
- FX_BOOL neg,
- uint8_t scale);
- inline FX_BOOL IsNotZero() const { return m_uHi || m_uMid || m_uLo; }
- inline int8_t 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;
- uint32_t m_uFlags;
- uint32_t m_uHi;
- uint32_t m_uLo;
- uint32_t m_uMid;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _FX_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 ~IFX_Locale() {} + 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(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr = TRUE) const = 0; + virtual void GetDayName(int32_t 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 ~IFX_LocaleMgr() {} + 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(const CFX_WideStringC& wsLocaleName) = 0; +}; +IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* 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(const CFX_WideStringC& wsTime, + CFX_Unitime& datetime, + IFX_Locale* pLocale); +class IFX_FormatString { + public: + static IFX_FormatString* Create(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID); + + virtual ~IFX_FormatString() {} + 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 { + public: + CFX_Decimal(); + CFX_Decimal(uint32_t val); + CFX_Decimal(uint64_t val); + CFX_Decimal(int32_t val); + CFX_Decimal(int64_t val); + CFX_Decimal(FX_FLOAT val, uint8_t scale = 3); + CFX_Decimal(const CFX_WideStringC& str); + CFX_Decimal(const CFX_ByteStringC& 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(uint8_t newScale); + uint8_t GetScale(); + void SetAbs(); + void SetNegate(); + void SetFloor(); + void SetCeiling(); + void SetTruncate(); + + protected: + CFX_Decimal(uint32_t hi, + uint32_t mid, + uint32_t lo, + FX_BOOL neg, + uint8_t scale); + inline FX_BOOL IsNotZero() const { return m_uHi || m_uMid || m_uLo; } + inline int8_t 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; + uint32_t m_uFlags; + uint32_t m_uHi; + uint32_t m_uLo; + uint32_t m_uMid; +}; +#endif diff --git a/xfa/src/fgas/include/fx_mem.h b/xfa/src/fgas/include/fx_mem.h index 5e65ea7c88..5d933dc06c 100644 --- a/xfa/src/fgas/include/fx_mem.h +++ b/xfa/src/fgas/include/fx_mem.h @@ -1,56 +1,56 @@ -// 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
-
-#include "core/include/fxcrt/fx_memory.h" // For FX_Alloc().
-
-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 ~IFX_MEMAllocator() {}
- 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:
- virtual ~CFX_Target() {}
- void* operator new(size_t size) { return FX_Alloc(uint8_t, 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_NewWith(__allocator__) new (__allocator__)
-#define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \
- { \
- (pointer)->~__class__(); \
- (pointer)->operator delete((pointer), (__allocator__)); \
- }
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _FX_MEMORY +#define _FX_MEMORY + +#include "core/include/fxcrt/fx_memory.h" // For FX_Alloc(). + +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 ~IFX_MEMAllocator() {} + 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: + virtual ~CFX_Target() {} + void* operator new(size_t size) { return FX_Alloc(uint8_t, 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_NewWith(__allocator__) new (__allocator__) +#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 index ed5e8e456f..e344959830 100644 --- a/xfa/src/fgas/include/fx_rbk.h +++ b/xfa/src/fgas/include/fx_rbk.h @@ -1,228 +1,228 @@ -// 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;
- }
- const FX_WCHAR* pStr;
- int32_t* pWidths;
- int32_t iLength;
- IFX_Font* pFont;
- FX_FLOAT fFontSize;
- FX_DWORD dwLayoutStyles;
- int32_t iCharRotation;
- int32_t iBidiLevel;
- FX_LPCRECTF pRect;
- FX_WCHAR wLineBreakChar;
- int32_t iHorizontalScale;
- int32_t 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++;
- }
- int32_t GetEndPos() const {
- return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
- }
- int32_t GetLength() const { return m_iChars; }
- int32_t GetEndChar() const { return m_iStartChar + m_iChars; }
- CFX_RTFChar& GetChar(int32_t index) {
- FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
- return *m_pChars->GetDataPtr(m_iStartChar + index);
- }
- CFX_RTFChar* GetCharPtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
- return m_pChars->GetDataPtr(m_iStartChar + index);
- }
- void GetString(FX_WCHAR* pText) const {
- FXSYS_assert(pText != NULL);
- int32_t iEndChar = m_iStartChar + m_iChars;
- CFX_RTFChar* pChar;
- for (int32_t i = m_iStartChar; i < iEndChar; i++) {
- pChar = m_pChars->GetDataPtr(i);
- *pText++ = (FX_WCHAR)pChar->m_wCharCode;
- }
- }
- void GetString(CFX_WideString& wsText) const {
- FX_WCHAR* pText = wsText.GetBuffer(m_iChars);
- GetString(pText);
- wsText.ReleaseBuffer(m_iChars);
- }
- void GetWidths(int32_t* pWidths) const {
- FXSYS_assert(pWidths != NULL);
- int32_t iEndChar = m_iStartChar + m_iChars;
- CFX_RTFChar* pChar;
- for (int32_t 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;
- int32_t m_iStartPos;
- int32_t m_iWidth;
- int32_t m_iStartChar;
- int32_t m_iChars;
- int32_t m_iBidiLevel;
- int32_t m_iBidiPos;
- int32_t m_iFontSize;
- int32_t m_iFontHeight;
- int32_t m_iHorizontalScale;
- int32_t 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 ~IFX_RTFBreak() {}
- virtual void Release() = 0;
- virtual void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) = 0;
- virtual void SetLineStartPos(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(int32_t iScale) = 0;
- virtual void SetVerticalScale(int32_t iScale) = 0;
- virtual void SetCharRotation(int32_t 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(int32_t 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 int32_t CountBreakPieces() const = 0;
- virtual const CFX_RTFPiece* GetBreakPiece(int32_t index) const = 0;
- virtual void GetLineRect(CFX_RectF& rect) const = 0;
- virtual void ClearBreakPieces() = 0;
- virtual void Reset() = 0;
- virtual int32_t GetDisplayPos(
- FX_LPCRTFTEXTOBJ pText,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
- virtual int32_t GetCharRects(FX_LPCRTFTEXTOBJ pText,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const = 0;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _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; + } + const FX_WCHAR* pStr; + int32_t* pWidths; + int32_t iLength; + IFX_Font* pFont; + FX_FLOAT fFontSize; + FX_DWORD dwLayoutStyles; + int32_t iCharRotation; + int32_t iBidiLevel; + FX_LPCRECTF pRect; + FX_WCHAR wLineBreakChar; + int32_t iHorizontalScale; + int32_t 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++; + } + int32_t GetEndPos() const { + return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; + } + int32_t GetLength() const { return m_iChars; } + int32_t GetEndChar() const { return m_iStartChar + m_iChars; } + CFX_RTFChar& GetChar(int32_t index) { + FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL); + return *m_pChars->GetDataPtr(m_iStartChar + index); + } + CFX_RTFChar* GetCharPtr(int32_t index) const { + FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL); + return m_pChars->GetDataPtr(m_iStartChar + index); + } + void GetString(FX_WCHAR* pText) const { + FXSYS_assert(pText != NULL); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_RTFChar* pChar; + for (int32_t i = m_iStartChar; i < iEndChar; i++) { + pChar = m_pChars->GetDataPtr(i); + *pText++ = (FX_WCHAR)pChar->m_wCharCode; + } + } + void GetString(CFX_WideString& wsText) const { + FX_WCHAR* pText = wsText.GetBuffer(m_iChars); + GetString(pText); + wsText.ReleaseBuffer(m_iChars); + } + void GetWidths(int32_t* pWidths) const { + FXSYS_assert(pWidths != NULL); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_RTFChar* pChar; + for (int32_t 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; + int32_t m_iStartPos; + int32_t m_iWidth; + int32_t m_iStartChar; + int32_t m_iChars; + int32_t m_iBidiLevel; + int32_t m_iBidiPos; + int32_t m_iFontSize; + int32_t m_iFontHeight; + int32_t m_iHorizontalScale; + int32_t 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 ~IFX_RTFBreak() {} + virtual void Release() = 0; + virtual void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) = 0; + virtual void SetLineStartPos(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(int32_t iScale) = 0; + virtual void SetVerticalScale(int32_t iScale) = 0; + virtual void SetCharRotation(int32_t 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(int32_t 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 int32_t CountBreakPieces() const = 0; + virtual const CFX_RTFPiece* GetBreakPiece(int32_t index) const = 0; + virtual void GetLineRect(CFX_RectF& rect) const = 0; + virtual void ClearBreakPieces() = 0; + virtual void Reset() = 0; + virtual int32_t GetDisplayPos( + FX_LPCRTFTEXTOBJ pText, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode = FALSE, + CFX_WideString* pWSForms = NULL, + FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0; + virtual int32_t 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 index 94943547bb..70978a017b 100644 --- a/xfa/src/fgas/include/fx_sax.h +++ b/xfa/src/fgas/include/fx_sax.h @@ -1,63 +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_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 ~IFX_SAXReaderHandler() {}
- virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName,
- FX_SAXNODE eType,
- FX_DWORD dwStartPos) = 0;
- virtual void OnTagAttribute(void* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue) = 0;
- virtual void OnTagBreak(void* pTag) = 0;
- virtual void OnTagData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- FX_DWORD dwStartPos) = 0;
- virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos) = 0;
- virtual void OnTagEnd(void* pTag,
- const CFX_ByteStringC& bsTagName,
- FX_DWORD dwEndPos) = 0;
- virtual void OnTargetData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- FX_DWORD dwStartPos) = 0;
-};
-class IFX_SAXReader {
- public:
- virtual ~IFX_SAXReader() {}
- virtual void Release() = 0;
- virtual int32_t StartParse(IFX_FileRead* pFile,
- FX_DWORD dwStart = 0,
- FX_DWORD dwLen = -1,
- FX_DWORD dwParseMode = 0) = 0;
- virtual int32_t ContinueParse(IFX_Pause* pPause = NULL) = 0;
- virtual void SkipCurrentNode() = 0;
- virtual void SetHandler(IFX_SAXReaderHandler* pHandler) = 0;
-};
-IFX_SAXReader* FX_SAXReader_Create();
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _FX_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 ~IFX_SAXReaderHandler() {} + virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName, + FX_SAXNODE eType, + FX_DWORD dwStartPos) = 0; + virtual void OnTagAttribute(void* pTag, + const CFX_ByteStringC& bsAttri, + const CFX_ByteStringC& bsValue) = 0; + virtual void OnTagBreak(void* pTag) = 0; + virtual void OnTagData(void* pTag, + FX_SAXNODE eType, + const CFX_ByteStringC& bsData, + FX_DWORD dwStartPos) = 0; + virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos) = 0; + virtual void OnTagEnd(void* pTag, + const CFX_ByteStringC& bsTagName, + FX_DWORD dwEndPos) = 0; + virtual void OnTargetData(void* pTag, + FX_SAXNODE eType, + const CFX_ByteStringC& bsData, + FX_DWORD dwStartPos) = 0; +}; +class IFX_SAXReader { + public: + virtual ~IFX_SAXReader() {} + virtual void Release() = 0; + virtual int32_t StartParse(IFX_FileRead* pFile, + FX_DWORD dwStart = 0, + FX_DWORD dwLen = -1, + FX_DWORD dwParseMode = 0) = 0; + virtual int32_t 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 index 89422b0a8c..43a2c8de08 100644 --- a/xfa/src/fgas/include/fx_stm.h +++ b/xfa/src/fgas/include/fx_stm.h @@ -1,72 +1,72 @@ -// 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);
-IFX_FileRead* FX_CreateFileRead(IFX_BufferRead* pBufferRead,
- FX_FILESIZE iFileSize = -1,
- FX_BOOL bReleaseStream = TRUE);
-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(const FX_WCHAR* pszFileName,
- FX_DWORD dwAccess);
- static IFX_Stream* CreateStream(uint8_t* pData,
- int32_t length,
- FX_DWORD dwAccess);
- static IFX_Stream* CreateStream(IFX_BufferRead* pBufferRead,
- FX_DWORD dwAccess,
- int32_t iFileSize = -1,
- FX_BOOL bReleaseBufferRead = TRUE);
- static IFX_Stream* CreateTextStream(IFX_Stream* pBaseStream,
- FX_BOOL bDeleteOnRelease);
- virtual ~IFX_Stream() {}
- virtual void Release() = 0;
- virtual IFX_Stream* Retain() = 0;
- virtual FX_DWORD GetAccessModes() const = 0;
- virtual int32_t GetLength() const = 0;
- virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0;
- virtual int32_t GetPosition() = 0;
- virtual FX_BOOL IsEOF() const = 0;
- virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0;
- virtual int32_t ReadString(FX_WCHAR* pStr,
- int32_t iMaxLength,
- FX_BOOL& bEOS,
- int32_t const* pByteSize = NULL) = 0;
- virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0;
- virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0;
- virtual void Flush() = 0;
- virtual FX_BOOL SetLength(int32_t iLength) = 0;
- virtual int32_t GetBOM(uint8_t 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,
- int32_t iOffset,
- int32_t iLength) = 0;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _FX_STREAM +#define _FX_STREAM +class IFX_Stream; +IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, + FX_BOOL bReleaseStream = FALSE); +IFX_FileRead* FX_CreateFileRead(IFX_BufferRead* pBufferRead, + FX_FILESIZE iFileSize = -1, + FX_BOOL bReleaseStream = TRUE); +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(const FX_WCHAR* pszFileName, + FX_DWORD dwAccess); + static IFX_Stream* CreateStream(uint8_t* pData, + int32_t length, + FX_DWORD dwAccess); + static IFX_Stream* CreateStream(IFX_BufferRead* pBufferRead, + FX_DWORD dwAccess, + int32_t iFileSize = -1, + FX_BOOL bReleaseBufferRead = TRUE); + static IFX_Stream* CreateTextStream(IFX_Stream* pBaseStream, + FX_BOOL bDeleteOnRelease); + virtual ~IFX_Stream() {} + virtual void Release() = 0; + virtual IFX_Stream* Retain() = 0; + virtual FX_DWORD GetAccessModes() const = 0; + virtual int32_t GetLength() const = 0; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0; + virtual int32_t GetPosition() = 0; + virtual FX_BOOL IsEOF() const = 0; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0; + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize = NULL) = 0; + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; + virtual void Flush() = 0; + virtual FX_BOOL SetLength(int32_t iLength) = 0; + virtual int32_t GetBOM(uint8_t 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, + int32_t iOffset, + int32_t iLength) = 0; +}; +#endif diff --git a/xfa/src/fgas/include/fx_sys.h b/xfa/src/fgas/include/fx_sys.h index 766b26a46a..f2fe2157c6 100644 --- a/xfa/src/fgas/include/fx_sys.h +++ b/xfa/src/fgas/include/fx_sys.h @@ -1,65 +1,65 @@ -// 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 int8_t* FX_LPINT8;
-typedef int8_t const* FX_LPCINT8;
-typedef int32_t* FX_LPINT32;
-typedef int32_t 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(const FX_CHAR* pcsStr,
- int32_t iLength = -1,
- int32_t* pUsedLen = NULL);
-FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr,
- int32_t iLength = -1,
- int32_t* pUsedLen = NULL);
-FX_WCHAR* FX_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count);
-int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count);
-int32_t FX_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count);
-inline FX_BOOL FX_islower(int32_t ch) {
- return ch >= 'a' && ch <= 'z';
-}
-inline FX_BOOL FX_isupper(int32_t ch) {
- return ch >= 'A' && ch <= 'Z';
-}
-inline int32_t FX_tolower(int32_t ch) {
- return FX_isupper(ch) ? (ch + 0x20) : ch;
-}
-inline int32_t FX_toupper(int32_t ch) {
- return FX_islower(ch) ? (ch - 0x20) : ch;
-}
-int32_t FX_filelength(FXSYS_FILE* file);
-FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size);
-void FX_memset(void* pBuf, int32_t iValue, size_t size);
-void FX_memcpy(void* pDst, const void* 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
+// 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 int8_t* FX_LPINT8; +typedef int8_t const* FX_LPCINT8; +typedef int32_t* FX_LPINT32; +typedef int32_t 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(const FX_CHAR* pcsStr, + int32_t iLength = -1, + int32_t* pUsedLen = NULL); +FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, + int32_t iLength = -1, + int32_t* pUsedLen = NULL); +FX_WCHAR* FX_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count); +int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); +int32_t FX_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count); +inline FX_BOOL FX_islower(int32_t ch) { + return ch >= 'a' && ch <= 'z'; +} +inline FX_BOOL FX_isupper(int32_t ch) { + return ch >= 'A' && ch <= 'Z'; +} +inline int32_t FX_tolower(int32_t ch) { + return FX_isupper(ch) ? (ch + 0x20) : ch; +} +inline int32_t FX_toupper(int32_t ch) { + return FX_islower(ch) ? (ch - 0x20) : ch; +} +int32_t FX_filelength(FXSYS_FILE* file); +FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size); +void FX_memset(void* pBuf, int32_t iValue, size_t size); +void FX_memcpy(void* pDst, const void* 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 index 349fc166a0..d9fef51f65 100644 --- a/xfa/src/fgas/include/fx_tbk.h +++ b/xfa/src/fgas/include/fx_tbk.h @@ -1,214 +1,214 @@ -// 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
-
-#include "core/include/fxcrt/fx_ucd.h"
-
-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 ~IFX_TxtAccess() {}
- virtual FX_WCHAR GetChar(void* pIdentity, int32_t index) const = 0;
- virtual int32_t GetWidth(void* pIdentity, int32_t 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;
- void* pIdentity;
- const FX_WCHAR* pStr;
- int32_t* pWidths;
- int32_t iLength;
- IFX_Font* pFont;
- FX_FLOAT fFontSize;
- FX_DWORD dwStyles;
- int32_t iHorizontalScale;
- int32_t iVerticalScale;
- int32_t 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) {}
- int32_t GetEndPos() const {
- return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
- }
- int32_t GetLength() const { return m_iChars; }
- int32_t GetEndChar() const { return m_iStartChar + m_iChars; }
- CFX_TxtChar* GetCharPtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
- return m_pChars->GetDataPtr(m_iStartChar + index);
- }
- void GetString(FX_WCHAR* pText) const {
- FXSYS_assert(pText != NULL);
- int32_t iEndChar = m_iStartChar + m_iChars;
- CFX_Char* pChar;
- for (int32_t i = m_iStartChar; i < iEndChar; i++) {
- pChar = m_pChars->GetDataPtr(i);
- *pText++ = (FX_WCHAR)pChar->m_wCharCode;
- }
- }
-
- void GetString(CFX_WideString& wsText) const {
- FX_WCHAR* pText = wsText.GetBuffer(m_iChars);
- GetString(pText);
- wsText.ReleaseBuffer(m_iChars);
- }
- void GetWidths(int32_t* pWidths) const {
- FXSYS_assert(pWidths != NULL);
- int32_t iEndChar = m_iStartChar + m_iChars;
- CFX_Char* pChar;
- for (int32_t i = m_iStartChar; i < iEndChar; i++) {
- pChar = m_pChars->GetDataPtr(i);
- *pWidths++ = pChar->m_iCharWidth;
- }
- }
- FX_DWORD m_dwStatus;
- int32_t m_iStartPos;
- int32_t m_iWidth;
- int32_t m_iStartChar;
- int32_t m_iChars;
- int32_t m_iBidiLevel;
- int32_t m_iBidiPos;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
- FX_DWORD m_dwCharStyles;
- CFX_TxtCharArray* m_pChars;
- void* m_pUserData;
-};
-typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray;
-class IFX_TxtBreak {
- public:
- static IFX_TxtBreak* Create(FX_DWORD dwPolicies);
- virtual ~IFX_TxtBreak() {}
- 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(int32_t iScale) = 0;
- virtual void SetVerticalScale(int32_t iScale) = 0;
- virtual void SetCharRotation(int32_t iCharRotation) = 0;
- virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
- virtual void SetAlignment(int32_t 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(void* pUserData) = 0;
- virtual FX_DWORD AppendChar(FX_WCHAR wch) = 0;
- virtual FX_DWORD EndBreak(FX_DWORD dwStatus = FX_TXTBREAK_PieceBreak) = 0;
- virtual int32_t CountBreakChars() const = 0;
- virtual int32_t CountBreakPieces() const = 0;
- virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const = 0;
- virtual void ClearBreakPieces() = 0;
- virtual void Reset() = 0;
- virtual int32_t GetDisplayPos(
- FX_LPCTXTRUN pTxtRun,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
- virtual int32_t GetCharRects(FX_LPCTXTRUN pTxtRun,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const = 0;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef _FX_TEXTBREAK +#define _FX_TEXTBREAK + +#include "core/include/fxcrt/fx_ucd.h" + +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 ~IFX_TxtAccess() {} + virtual FX_WCHAR GetChar(void* pIdentity, int32_t index) const = 0; + virtual int32_t GetWidth(void* pIdentity, int32_t 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; + void* pIdentity; + const FX_WCHAR* pStr; + int32_t* pWidths; + int32_t iLength; + IFX_Font* pFont; + FX_FLOAT fFontSize; + FX_DWORD dwStyles; + int32_t iHorizontalScale; + int32_t iVerticalScale; + int32_t 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) {} + int32_t GetEndPos() const { + return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; + } + int32_t GetLength() const { return m_iChars; } + int32_t GetEndChar() const { return m_iStartChar + m_iChars; } + CFX_TxtChar* GetCharPtr(int32_t index) const { + FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL); + return m_pChars->GetDataPtr(m_iStartChar + index); + } + void GetString(FX_WCHAR* pText) const { + FXSYS_assert(pText != NULL); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_Char* pChar; + for (int32_t i = m_iStartChar; i < iEndChar; i++) { + pChar = m_pChars->GetDataPtr(i); + *pText++ = (FX_WCHAR)pChar->m_wCharCode; + } + } + + void GetString(CFX_WideString& wsText) const { + FX_WCHAR* pText = wsText.GetBuffer(m_iChars); + GetString(pText); + wsText.ReleaseBuffer(m_iChars); + } + void GetWidths(int32_t* pWidths) const { + FXSYS_assert(pWidths != NULL); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_Char* pChar; + for (int32_t i = m_iStartChar; i < iEndChar; i++) { + pChar = m_pChars->GetDataPtr(i); + *pWidths++ = pChar->m_iCharWidth; + } + } + FX_DWORD m_dwStatus; + int32_t m_iStartPos; + int32_t m_iWidth; + int32_t m_iStartChar; + int32_t m_iChars; + int32_t m_iBidiLevel; + int32_t m_iBidiPos; + int32_t m_iHorizontalScale; + int32_t m_iVerticalScale; + FX_DWORD m_dwCharStyles; + CFX_TxtCharArray* m_pChars; + void* m_pUserData; +}; +typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; +class IFX_TxtBreak { + public: + static IFX_TxtBreak* Create(FX_DWORD dwPolicies); + virtual ~IFX_TxtBreak() {} + 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(int32_t iScale) = 0; + virtual void SetVerticalScale(int32_t iScale) = 0; + virtual void SetCharRotation(int32_t iCharRotation) = 0; + virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0; + virtual void SetAlignment(int32_t 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(void* pUserData) = 0; + virtual FX_DWORD AppendChar(FX_WCHAR wch) = 0; + virtual FX_DWORD EndBreak(FX_DWORD dwStatus = FX_TXTBREAK_PieceBreak) = 0; + virtual int32_t CountBreakChars() const = 0; + virtual int32_t CountBreakPieces() const = 0; + virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const = 0; + virtual void ClearBreakPieces() = 0; + virtual void Reset() = 0; + virtual int32_t GetDisplayPos( + FX_LPCTXTRUN pTxtRun, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode = FALSE, + CFX_WideString* pWSForms = NULL, + FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0; + virtual int32_t 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 index 02d2ce5791..6aa11ce8b4 100644 --- a/xfa/src/fgas/include/fx_ucd.h +++ b/xfa/src/fgas/include/fx_ucd.h @@ -1,33 +1,33 @@ -// 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;
- uint8_t 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
+// 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; + uint8_t 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 index f65aa994ea..0e4a35a651 100644 --- a/xfa/src/fgas/include/fx_utl.h +++ b/xfa/src/fgas/include/fx_utl.h @@ -1,724 +1,724 @@ -// 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
-
-#include "fx_mem.h"
-#include "core/include/fxcrt/fx_coordinates.h" // For CFX_Rect.
-
-class CFX_ThreadLock;
-class CFX_BaseArray;
-template <class baseType>
-class CFX_BaseArrayTemplate;
-template <class baseType>
-class CFX_ObjectBaseArrayTemplate;
-class CFX_BaseMassArray;
-class CFX_BaseMassArrayImp;
-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 FX_BASEARRAYDATA;
-
-class CFX_ThreadLock {
- public:
- CFX_ThreadLock();
- virtual ~CFX_ThreadLock();
- void Lock();
- void Unlock();
-};
-class CFX_BaseArray : public CFX_Target {
- protected:
- CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize);
- ~CFX_BaseArray();
- int32_t GetSize() const;
- int32_t GetBlockSize() const;
- uint8_t* AddSpaceTo(int32_t index);
- uint8_t* GetAt(int32_t index) const;
- uint8_t* GetBuffer() const;
- int32_t Append(const CFX_BaseArray& src,
- int32_t iStart = 0,
- int32_t iCount = -1);
- int32_t Copy(const CFX_BaseArray& src,
- int32_t iStart = 0,
- int32_t iCount = -1);
- int32_t RemoveLast(int32_t iCount = -1);
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE);
-
- FX_BASEARRAYDATA* m_pData;
-};
-template <class baseType>
-class CFX_BaseArrayTemplate : public CFX_BaseArray {
- public:
- CFX_BaseArrayTemplate(int32_t iGrowSize = 100)
- : CFX_BaseArray(iGrowSize, sizeof(baseType)) {}
- CFX_BaseArrayTemplate(int32_t iGrowSize, int32_t iBlockSize)
- : CFX_BaseArray(iGrowSize, iBlockSize) {}
- int32_t GetSize() const { return CFX_BaseArray::GetSize(); }
- int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); }
- baseType* AddSpace() {
- return (baseType*)CFX_BaseArray::AddSpaceTo(CFX_BaseArray::GetSize());
- }
- int32_t Add(const baseType& element) {
- int32_t index = CFX_BaseArray::GetSize();
- *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element;
- return index;
- }
- baseType* GetBuffer() const { return (baseType*)CFX_BaseArray::GetBuffer(); }
- baseType& GetAt(int32_t index) const {
- return *(baseType*)CFX_BaseArray::GetAt(index);
- }
- baseType* GetPtrAt(int32_t index) const {
- return (baseType*)CFX_BaseArray::GetAt(index);
- }
- void SetAt(int32_t index, const baseType& element) {
- *(baseType*)CFX_BaseArray::GetAt(index) = element;
- }
- void SetAtGrow(int32_t index, const baseType& element) {
- *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element;
- }
- int32_t Append(const CFX_BaseArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- return CFX_BaseArray::Append(src, iStart, iCount);
- }
- int32_t Copy(const CFX_BaseArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- return CFX_BaseArray::Copy(src, iStart, iCount);
- }
- int32_t RemoveLast(int32_t iCount = -1) {
- return CFX_BaseArray::RemoveLast(iCount);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- CFX_BaseArray::RemoveAll(bLeaveMemory);
- }
-};
-typedef CFX_BaseArrayTemplate<void*> 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(int32_t iGrowSize = 100)
- : CFX_BaseArray(iGrowSize, sizeof(baseType)) {}
- ~CFX_ObjectBaseArrayTemplate() { RemoveAll(FALSE); }
- int32_t GetSize() const { return CFX_BaseArray::GetSize(); }
- int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); }
- int32_t Add(const baseType& element) {
- int32_t index = CFX_BaseArray::GetSize();
- baseType* p = (baseType*)CFX_BaseArray::AddSpaceTo(index);
- new ((void*)p) baseType(element);
- return index;
- }
- baseType& GetAt(int32_t index) const {
- return *(baseType*)CFX_BaseArray::GetAt(index);
- }
- baseType* GetPtrAt(int32_t index) const {
- return (baseType*)CFX_BaseArray::GetAt(index);
- }
- int32_t Append(const CFX_ObjectBaseArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- FXSYS_assert(GetBlockSize() == src.GetBlockSize());
- if (iCount == 0) {
- return 0;
- }
- int32_t 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);
- uint8_t** pStart = CFX_BaseArray::GetAt(iSize);
- int32_t iBlockSize = CFX_BaseArray::GetBlockSize();
- iSize = iStart + iCount;
- for (int32_t i = iStart; i < iSize; i++) {
- FXTARGET_NewWith((void*)pStart) baseType(src.GetAt(i));
- pStart += iBlockSize;
- }
- return iCount;
- }
- int32_t Copy(const CFX_ObjectBaseArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- FXSYS_assert(GetBlockSize() == src.GetBlockSize());
- if (iCount == 0) {
- return 0;
- }
- int32_t 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);
- uint8_t** pStart = CFX_BaseArray::GetAt(0);
- int32_t iBlockSize = CFX_BaseArray::GetBlockSize();
- iSize = iStart + iCount;
- for (int32_t i = iStart; i < iSize; i++) {
- new ((void*)pStart) baseType(src.GetAt(i));
- pStart += iBlockSize;
- }
- return iCount;
- }
- int32_t RemoveLast(int32_t iCount = -1) {
- int32_t iSize = CFX_BaseArray::GetSize();
- if (iCount < 0 || iCount > iSize) {
- iCount = iSize;
- }
- if (iCount == 0) {
- return iSize;
- }
- for (int32_t i = iSize - iCount; i < iSize; i++) {
- ((baseType*)GetPtrAt(i))->~baseType();
- }
- return CFX_BaseArray::RemoveLast(iCount);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- int32_t iSize = CFX_BaseArray::GetSize();
- for (int32_t i = 0; i < iSize; i++) {
- ((baseType*)GetPtrAt(i))->~baseType();
- }
- CFX_BaseArray::RemoveAll(bLeaveMemory);
- }
-};
-class CFX_BaseMassArray : public CFX_Target {
- protected:
- CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize);
- ~CFX_BaseMassArray();
- int32_t GetSize() const;
- uint8_t* AddSpaceTo(int32_t index);
- uint8_t* GetAt(int32_t index) const;
- int32_t Append(const CFX_BaseMassArray& src,
- int32_t iStart = 0,
- int32_t iCount = -1);
- int32_t Copy(const CFX_BaseMassArray& src,
- int32_t iStart = 0,
- int32_t iCount = -1);
- int32_t RemoveLast(int32_t iCount = -1);
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE);
- CFX_BaseMassArrayImp* m_pData;
-};
-template <class baseType>
-class CFX_MassArrayTemplate : public CFX_BaseMassArray {
- public:
- CFX_MassArrayTemplate(int32_t iChunkSize = 100)
- : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {}
- CFX_MassArrayTemplate(int32_t iChunkSize, int32_t iBlockSize)
- : CFX_BaseMassArray(iChunkSize, iBlockSize) {}
- int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); }
- baseType* AddSpace() {
- return (baseType*)CFX_BaseMassArray::AddSpaceTo(
- CFX_BaseMassArray::GetSize());
- }
- int32_t Add(const baseType& element) {
- int32_t index = CFX_BaseMassArray::GetSize();
- *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element;
- return index;
- }
- baseType& GetAt(int32_t index) const {
- return *(baseType*)CFX_BaseMassArray::GetAt(index);
- }
- baseType* GetPtrAt(int32_t index) const {
- return (baseType*)CFX_BaseMassArray::GetAt(index);
- }
- void SetAt(int32_t index, const baseType& element) {
- *(baseType*)CFX_BaseMassArray::GetAt(index) = element;
- }
- void SetAtGrow(int32_t index, const baseType& element) {
- *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element;
- }
- int32_t Append(const CFX_MassArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- return CFX_BaseMassArray::Append(src, iStart, iCount);
- }
- int32_t Copy(const CFX_MassArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- return CFX_BaseMassArray::Copy(src, iStart, iCount);
- }
- int32_t RemoveLast(int32_t iCount = -1) {
- return CFX_BaseMassArray::RemoveLast(iCount);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- CFX_BaseMassArray::RemoveAll(bLeaveMemory);
- }
-};
-typedef CFX_MassArrayTemplate<void*> CFX_PtrMassArray;
-typedef CFX_MassArrayTemplate<int32_t> 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(int32_t iChunkSize = 100)
- : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {}
- ~CFX_ObjectMassArrayTemplate() { RemoveAll(FALSE); }
- int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); }
- int32_t Add(const baseType& element) {
- int32_t index = CFX_BaseMassArray::GetSize();
- baseType* p = (baseType*)CFX_BaseMassArray::AddSpaceTo(index);
- new ((void*)p) baseType(element);
- return index;
- }
- baseType& GetAt(int32_t index) const {
- return *(baseType*)CFX_BaseMassArray::GetAt(index);
- }
- baseType* GetPtrAt(int32_t index) const {
- return (baseType*)CFX_BaseMassArray::GetAt(index);
- }
- int32_t Append(const CFX_ObjectMassArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- if (iCount == 0) {
- return CFX_BaseMassArray::GetSize();
- }
- int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
- if (iCount < 0) {
- iCount = iSize;
- }
- int32_t iEnd = iStart + iCount;
- if (iEnd > iSize) {
- iEnd = iSize;
- }
- for (int32_t i = iStart; i < iEnd; i++) {
- Add(src.GetAt(i));
- }
- return CFX_BaseMassArray::GetSize();
- }
- int32_t Copy(const CFX_ObjectMassArrayTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- if (iCount == 0) {
- return CFX_BaseMassArray::GetSize();
- }
- int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
- if (iCount < 0) {
- iCount = iSize;
- }
- int32_t iEnd = iStart + iCount;
- if (iEnd > iSize) {
- iEnd = iSize;
- }
- RemoveAll(TRUE);
- for (int32_t i = iStart; i < iEnd; i++) {
- Add(src.GetAt(i));
- }
- return CFX_BaseMassArray::GetSize();
- }
- int32_t RemoveLast(int32_t iCount = -1) {
- int32_t iSize = CFX_BaseMassArray::GetSize();
- if (iCount < 0 || iCount > iSize) {
- iCount = iSize;
- }
- if (iCount == 0) {
- return iSize;
- }
- for (int32_t i = iSize - iCount; i < iSize; i++) {
- ((baseType*)GetPtrAt(i))->~baseType();
- }
- return CFX_BaseMassArray::RemoveLast(iCount);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- int32_t iSize = CFX_BaseMassArray::GetSize();
- for (int32_t i = 0; i < iSize; i++) {
- ((baseType*)GetPtrAt(i))->~baseType();
- }
- CFX_BaseMassArray::RemoveAll(bLeaveMemory);
- }
-};
-class CFX_BaseDiscreteArray : public CFX_Target {
- protected:
- CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize);
- ~CFX_BaseDiscreteArray();
- uint8_t* AddSpaceTo(int32_t index);
- uint8_t* GetAt(int32_t index) const;
- void RemoveAll();
- void* m_pData;
-};
-template <class baseType>
-class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray {
- public:
- CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100)
- : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {}
- baseType& GetAt(int32_t index, const baseType& defValue) const {
- baseType* p = (baseType*)CFX_BaseDiscreteArray::GetAt(index);
- return p == NULL ? (baseType&)defValue : *p;
- }
- baseType* GetPtrAt(int32_t index) const {
- return (baseType*)CFX_BaseDiscreteArray::GetAt(index);
- }
- void SetAtGrow(int32_t index, const baseType& element) {
- *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element;
- }
- void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); }
-};
-typedef CFX_DiscreteArrayTemplate<void*> 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(int32_t iChunkSize, int32_t iBlockSize);
- ~CFX_BaseStack();
- uint8_t* Push();
- void Pop();
- uint8_t* GetTopElement() const;
- int32_t GetSize() const;
- uint8_t* GetAt(int32_t index) const;
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE);
- CFX_BaseMassArrayImp* m_pData;
-};
-template <class baseType>
-class CFX_StackTemplate : public CFX_BaseStack {
- public:
- CFX_StackTemplate(int32_t iChunkSize = 100)
- : CFX_BaseStack(iChunkSize, sizeof(baseType)) {}
- int32_t Push(const baseType& element) {
- int32_t index = CFX_BaseStack::GetSize();
- *(baseType*)CFX_BaseStack::Push() = element;
- return index;
- }
- void Pop() { CFX_BaseStack::Pop(); }
- baseType* GetTopElement() const {
- return (baseType*)CFX_BaseStack::GetTopElement();
- }
- int32_t GetSize() const { return CFX_BaseStack::GetSize(); }
- baseType* GetAt(int32_t index) const {
- return (baseType*)CFX_BaseStack::GetAt(index);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- CFX_BaseStack::RemoveAll(bLeaveMemory);
- }
-};
-typedef CFX_StackTemplate<void*> CFX_PtrStack;
-typedef CFX_StackTemplate<FX_DWORD> CFX_DWordStack;
-typedef CFX_StackTemplate<FX_WORD> CFX_WordStack;
-typedef CFX_StackTemplate<int32_t> CFX_Int32Stack;
-template <class baseType>
-class CFX_ObjectStackTemplate : public CFX_BaseStack {
- public:
- CFX_ObjectStackTemplate(int32_t iChunkSize = 100)
- : CFX_BaseStack(iChunkSize, sizeof(baseType)) {}
- ~CFX_ObjectStackTemplate() { RemoveAll(); }
- int32_t Push(const baseType& element) {
- int32_t index = CFX_BaseStack::GetSize();
- baseType* p = (baseType*)CFX_BaseStack::Push();
- 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();
- }
- int32_t GetSize() const { return CFX_BaseStack::GetSize(); }
- baseType* GetAt(int32_t index) const {
- return (baseType*)CFX_BaseStack::GetAt(index);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- int32_t iSize = CFX_BaseStack::GetSize();
- for (int32_t i = 0; i < iSize; i++) {
- ((baseType*)CFX_BaseStack::GetAt(i))->~baseType();
- }
- CFX_BaseStack::RemoveAll(bLeaveMemory);
- }
- int32_t Copy(const CFX_ObjectStackTemplate& src,
- int32_t iStart = 0,
- int32_t iCount = -1) {
- if (iCount == 0) {
- return CFX_BaseStack::GetSize();
- }
- int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
- if (iCount < 0) {
- iCount = iSize;
- }
- int32_t iEnd = iStart + iCount;
- if (iEnd > iSize) {
- iEnd = iSize;
- }
- RemoveAll(TRUE);
- for (int32_t 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; }
- int32_t CountChildNodes() const {
- int32_t iCount = 0;
- CPLTreeNode* pNode = m_pChildNode;
- while (pNode) {
- iCount++;
- pNode = pNode->m_pNextNode;
- }
- return iCount;
- }
- CPLTreeNode* GetChildNode(int32_t iIndex) const {
- int32_t iCount = 0;
- CPLTreeNode* pNode = m_pChildNode;
- while (pNode) {
- if (iIndex == iCount) {
- return pNode;
- }
- iCount++;
- pNode = pNode->m_pNextNode;
- }
- return NULL;
- }
- int32_t GetNodeIndex() const {
- int32_t 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; }
- int32_t GetNodeLevel() const {
- int32_t 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:
- 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 = 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
+// 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 + +#include "fx_mem.h" +#include "core/include/fxcrt/fx_coordinates.h" // For CFX_Rect. + +class CFX_ThreadLock; +class CFX_BaseArray; +template <class baseType> +class CFX_BaseArrayTemplate; +template <class baseType> +class CFX_ObjectBaseArrayTemplate; +class CFX_BaseMassArray; +class CFX_BaseMassArrayImp; +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 FX_BASEARRAYDATA; + +class CFX_ThreadLock { + public: + CFX_ThreadLock(); + virtual ~CFX_ThreadLock(); + void Lock(); + void Unlock(); +}; +class CFX_BaseArray : public CFX_Target { + protected: + CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize); + ~CFX_BaseArray(); + int32_t GetSize() const; + int32_t GetBlockSize() const; + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + uint8_t* GetBuffer() const; + int32_t Append(const CFX_BaseArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t Copy(const CFX_BaseArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t RemoveLast(int32_t iCount = -1); + void RemoveAll(FX_BOOL bLeaveMemory = FALSE); + + FX_BASEARRAYDATA* m_pData; +}; +template <class baseType> +class CFX_BaseArrayTemplate : public CFX_BaseArray { + public: + CFX_BaseArrayTemplate(int32_t iGrowSize = 100) + : CFX_BaseArray(iGrowSize, sizeof(baseType)) {} + CFX_BaseArrayTemplate(int32_t iGrowSize, int32_t iBlockSize) + : CFX_BaseArray(iGrowSize, iBlockSize) {} + int32_t GetSize() const { return CFX_BaseArray::GetSize(); } + int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); } + baseType* AddSpace() { + return (baseType*)CFX_BaseArray::AddSpaceTo(CFX_BaseArray::GetSize()); + } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseArray::GetSize(); + *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; + return index; + } + baseType* GetBuffer() const { return (baseType*)CFX_BaseArray::GetBuffer(); } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseArray::GetAt(index); + } + void SetAt(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseArray::GetAt(index) = element; + } + void SetAtGrow(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; + } + int32_t Append(const CFX_BaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseArray::Append(src, iStart, iCount); + } + int32_t Copy(const CFX_BaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseArray::Copy(src, iStart, iCount); + } + int32_t RemoveLast(int32_t iCount = -1) { + return CFX_BaseArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + CFX_BaseArray::RemoveAll(bLeaveMemory); + } +}; +typedef CFX_BaseArrayTemplate<void*> 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(int32_t iGrowSize = 100) + : CFX_BaseArray(iGrowSize, sizeof(baseType)) {} + ~CFX_ObjectBaseArrayTemplate() { RemoveAll(FALSE); } + int32_t GetSize() const { return CFX_BaseArray::GetSize(); } + int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseArray::GetSize(); + baseType* p = (baseType*)CFX_BaseArray::AddSpaceTo(index); + new ((void*)p) baseType(element); + return index; + } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseArray::GetAt(index); + } + int32_t Append(const CFX_ObjectBaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + FXSYS_assert(GetBlockSize() == src.GetBlockSize()); + if (iCount == 0) { + return 0; + } + int32_t 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); + uint8_t** pStart = CFX_BaseArray::GetAt(iSize); + int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); + iSize = iStart + iCount; + for (int32_t i = iStart; i < iSize; i++) { + FXTARGET_NewWith((void*)pStart) baseType(src.GetAt(i)); + pStart += iBlockSize; + } + return iCount; + } + int32_t Copy(const CFX_ObjectBaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + FXSYS_assert(GetBlockSize() == src.GetBlockSize()); + if (iCount == 0) { + return 0; + } + int32_t 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); + uint8_t** pStart = CFX_BaseArray::GetAt(0); + int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); + iSize = iStart + iCount; + for (int32_t i = iStart; i < iSize; i++) { + new ((void*)pStart) baseType(src.GetAt(i)); + pStart += iBlockSize; + } + return iCount; + } + int32_t RemoveLast(int32_t iCount = -1) { + int32_t iSize = CFX_BaseArray::GetSize(); + if (iCount < 0 || iCount > iSize) { + iCount = iSize; + } + if (iCount == 0) { + return iSize; + } + for (int32_t i = iSize - iCount; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + return CFX_BaseArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + int32_t iSize = CFX_BaseArray::GetSize(); + for (int32_t i = 0; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + CFX_BaseArray::RemoveAll(bLeaveMemory); + } +}; +class CFX_BaseMassArray : public CFX_Target { + protected: + CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseMassArray(); + int32_t GetSize() const; + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + int32_t Append(const CFX_BaseMassArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t Copy(const CFX_BaseMassArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t RemoveLast(int32_t iCount = -1); + void RemoveAll(FX_BOOL bLeaveMemory = FALSE); + CFX_BaseMassArrayImp* m_pData; +}; +template <class baseType> +class CFX_MassArrayTemplate : public CFX_BaseMassArray { + public: + CFX_MassArrayTemplate(int32_t iChunkSize = 100) + : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {} + CFX_MassArrayTemplate(int32_t iChunkSize, int32_t iBlockSize) + : CFX_BaseMassArray(iChunkSize, iBlockSize) {} + int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); } + baseType* AddSpace() { + return (baseType*)CFX_BaseMassArray::AddSpaceTo( + CFX_BaseMassArray::GetSize()); + } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseMassArray::GetSize(); + *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; + return index; + } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseMassArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseMassArray::GetAt(index); + } + void SetAt(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseMassArray::GetAt(index) = element; + } + void SetAtGrow(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; + } + int32_t Append(const CFX_MassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseMassArray::Append(src, iStart, iCount); + } + int32_t Copy(const CFX_MassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseMassArray::Copy(src, iStart, iCount); + } + int32_t RemoveLast(int32_t iCount = -1) { + return CFX_BaseMassArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + CFX_BaseMassArray::RemoveAll(bLeaveMemory); + } +}; +typedef CFX_MassArrayTemplate<void*> CFX_PtrMassArray; +typedef CFX_MassArrayTemplate<int32_t> 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(int32_t iChunkSize = 100) + : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {} + ~CFX_ObjectMassArrayTemplate() { RemoveAll(FALSE); } + int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseMassArray::GetSize(); + baseType* p = (baseType*)CFX_BaseMassArray::AddSpaceTo(index); + new ((void*)p) baseType(element); + return index; + } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseMassArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseMassArray::GetAt(index); + } + int32_t Append(const CFX_ObjectMassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + if (iCount == 0) { + return CFX_BaseMassArray::GetSize(); + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + int32_t iEnd = iStart + iCount; + if (iEnd > iSize) { + iEnd = iSize; + } + for (int32_t i = iStart; i < iEnd; i++) { + Add(src.GetAt(i)); + } + return CFX_BaseMassArray::GetSize(); + } + int32_t Copy(const CFX_ObjectMassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + if (iCount == 0) { + return CFX_BaseMassArray::GetSize(); + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + int32_t iEnd = iStart + iCount; + if (iEnd > iSize) { + iEnd = iSize; + } + RemoveAll(TRUE); + for (int32_t i = iStart; i < iEnd; i++) { + Add(src.GetAt(i)); + } + return CFX_BaseMassArray::GetSize(); + } + int32_t RemoveLast(int32_t iCount = -1) { + int32_t iSize = CFX_BaseMassArray::GetSize(); + if (iCount < 0 || iCount > iSize) { + iCount = iSize; + } + if (iCount == 0) { + return iSize; + } + for (int32_t i = iSize - iCount; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + return CFX_BaseMassArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + int32_t iSize = CFX_BaseMassArray::GetSize(); + for (int32_t i = 0; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + CFX_BaseMassArray::RemoveAll(bLeaveMemory); + } +}; +class CFX_BaseDiscreteArray : public CFX_Target { + protected: + CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseDiscreteArray(); + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + void RemoveAll(); + void* m_pData; +}; +template <class baseType> +class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { + public: + CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100) + : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {} + baseType& GetAt(int32_t index, const baseType& defValue) const { + baseType* p = (baseType*)CFX_BaseDiscreteArray::GetAt(index); + return p == NULL ? (baseType&)defValue : *p; + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseDiscreteArray::GetAt(index); + } + void SetAtGrow(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element; + } + void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); } +}; +typedef CFX_DiscreteArrayTemplate<void*> 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(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseStack(); + uint8_t* Push(); + void Pop(); + uint8_t* GetTopElement() const; + int32_t GetSize() const; + uint8_t* GetAt(int32_t index) const; + void RemoveAll(FX_BOOL bLeaveMemory = FALSE); + CFX_BaseMassArrayImp* m_pData; +}; +template <class baseType> +class CFX_StackTemplate : public CFX_BaseStack { + public: + CFX_StackTemplate(int32_t iChunkSize = 100) + : CFX_BaseStack(iChunkSize, sizeof(baseType)) {} + int32_t Push(const baseType& element) { + int32_t index = CFX_BaseStack::GetSize(); + *(baseType*)CFX_BaseStack::Push() = element; + return index; + } + void Pop() { CFX_BaseStack::Pop(); } + baseType* GetTopElement() const { + return (baseType*)CFX_BaseStack::GetTopElement(); + } + int32_t GetSize() const { return CFX_BaseStack::GetSize(); } + baseType* GetAt(int32_t index) const { + return (baseType*)CFX_BaseStack::GetAt(index); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + CFX_BaseStack::RemoveAll(bLeaveMemory); + } +}; +typedef CFX_StackTemplate<void*> CFX_PtrStack; +typedef CFX_StackTemplate<FX_DWORD> CFX_DWordStack; +typedef CFX_StackTemplate<FX_WORD> CFX_WordStack; +typedef CFX_StackTemplate<int32_t> CFX_Int32Stack; +template <class baseType> +class CFX_ObjectStackTemplate : public CFX_BaseStack { + public: + CFX_ObjectStackTemplate(int32_t iChunkSize = 100) + : CFX_BaseStack(iChunkSize, sizeof(baseType)) {} + ~CFX_ObjectStackTemplate() { RemoveAll(); } + int32_t Push(const baseType& element) { + int32_t index = CFX_BaseStack::GetSize(); + baseType* p = (baseType*)CFX_BaseStack::Push(); + 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(); + } + int32_t GetSize() const { return CFX_BaseStack::GetSize(); } + baseType* GetAt(int32_t index) const { + return (baseType*)CFX_BaseStack::GetAt(index); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + int32_t iSize = CFX_BaseStack::GetSize(); + for (int32_t i = 0; i < iSize; i++) { + ((baseType*)CFX_BaseStack::GetAt(i))->~baseType(); + } + CFX_BaseStack::RemoveAll(bLeaveMemory); + } + int32_t Copy(const CFX_ObjectStackTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + if (iCount == 0) { + return CFX_BaseStack::GetSize(); + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + int32_t iEnd = iStart + iCount; + if (iEnd > iSize) { + iEnd = iSize; + } + RemoveAll(TRUE); + for (int32_t 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; } + int32_t CountChildNodes() const { + int32_t iCount = 0; + CPLTreeNode* pNode = m_pChildNode; + while (pNode) { + iCount++; + pNode = pNode->m_pNextNode; + } + return iCount; + } + CPLTreeNode* GetChildNode(int32_t iIndex) const { + int32_t iCount = 0; + CPLTreeNode* pNode = m_pChildNode; + while (pNode) { + if (iIndex == iCount) { + return pNode; + } + iCount++; + pNode = pNode->m_pNextNode; + } + return NULL; + } + int32_t GetNodeIndex() const { + int32_t 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; } + int32_t GetNodeLevel() const { + int32_t 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: + 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 = 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 |