diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2016-03-09 13:49:00 -0500 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2016-03-09 13:49:00 -0500 |
commit | 9332e0c2fced598a632e3bbe905b6f63b1f5b06b (patch) | |
tree | a8957a09cb34ecd28afcd6ebbed309d9c60e4644 /xfa/src/fgas | |
parent | 8388037a5c58d60043b11c03a8efe78c54c65a4b (diff) | |
download | pdfium-9332e0c2fced598a632e3bbe905b6f63b1f5b06b.tar.xz |
Cleanup the xfa/src/fgas directory.
This CL moves the code from xfa/src/fgas/src up one level. It then takes the
headers in xfa/src/fgas/include and moves them to their correct folder. The
src/ and include/ directories are then removed.
In some cases, when moving from include/ there was another header with the
same name. Those headers were either folded together, or the content of the
conflicting folder moved to an anonymous namespace in the cpp file as they were
not used anywhere else.
Files with duplicate names as core/src/crt were renamed to be fgas_ instead of
fx_. (e.g. fgas_system.h, fgas_memory.h, fgas_stream.h)
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1776303002 .
Diffstat (limited to 'xfa/src/fgas')
-rw-r--r-- | xfa/src/fgas/crt/fgas_algorithm.cpp (renamed from xfa/src/fgas/src/crt/fx_algorithm.cpp) | 2 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_algorithm.h (renamed from xfa/src/fgas/include/fx_alg.h) | 8 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_codepage.cpp (renamed from xfa/src/fgas/src/crt/fx_codepage.cpp) | 4 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_codepage.h (renamed from xfa/src/fgas/include/fx_cpg.h) | 90 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_encode.cpp (renamed from xfa/src/fgas/src/crt/fx_encode.cpp) | 2 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_language.h (renamed from xfa/src/fgas/include/fx_lgg.h) | 6 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_memory.cpp (renamed from xfa/src/fgas/src/crt/fx_memory.cpp) | 130 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_memory.h (renamed from xfa/src/fgas/include/fx_mem.h) | 9 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_stream.cpp (renamed from xfa/src/fgas/src/crt/fx_stream.cpp) | 304 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_stream.h (renamed from xfa/src/fgas/include/fx_stm.h) | 9 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_system.cpp (renamed from xfa/src/fgas/src/crt/fx_system.cpp) | 2 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_system.h (renamed from xfa/src/fgas/include/fx_sys.h) | 6 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_utils.cpp (renamed from xfa/src/fgas/src/crt/fx_utils.cpp) | 5 | ||||
-rw-r--r-- | xfa/src/fgas/crt/fgas_utils.h (renamed from xfa/src/fgas/include/fx_utl.h) | 74 | ||||
-rw-r--r-- | xfa/src/fgas/font/fgas_font.h (renamed from xfa/src/fgas/include/fx_fnt.h) | 12 | ||||
-rw-r--r-- | xfa/src/fgas/font/fgas_fontutils.cpp (renamed from xfa/src/fgas/src/font/fx_fontutils.cpp) | 4 | ||||
-rw-r--r-- | xfa/src/fgas/font/fgas_fontutils.h (renamed from xfa/src/fgas/src/font/fx_fontutils.h) | 6 | ||||
-rw-r--r-- | xfa/src/fgas/font/fgas_gefont.cpp (renamed from xfa/src/fgas/src/font/fx_gefont.cpp) | 6 | ||||
-rw-r--r-- | xfa/src/fgas/font/fgas_gefont.h (renamed from xfa/src/fgas/src/font/fx_gefont.h) | 10 | ||||
-rw-r--r-- | xfa/src/fgas/font/fgas_stdfontmgr.cpp (renamed from xfa/src/fgas/src/font/fx_stdfontmgr.cpp) | 6 | ||||
-rw-r--r-- | xfa/src/fgas/font/fgas_stdfontmgr.h (renamed from xfa/src/fgas/src/font/fx_stdfontmgr.h) | 8 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_linebreak.cpp (renamed from xfa/src/fgas/src/layout/fx_linebreak.cpp) | 3 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_linebreak.h (renamed from xfa/src/fgas/include/fx_lbk.h) | 8 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_rtfbreak.cpp (renamed from xfa/src/fgas/src/layout/fx_rtfbreak.cpp) | 173 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_rtfbreak.h (renamed from xfa/src/fgas/include/fx_rbk.h) | 16 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_textbreak.cpp (renamed from xfa/src/fgas/src/layout/fx_textbreak.cpp) | 169 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_textbreak.h (renamed from xfa/src/fgas/include/fx_tbk.h) | 11 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_unicode.cpp (renamed from xfa/src/fgas/src/layout/fx_unicode.cpp) | 4 | ||||
-rw-r--r-- | xfa/src/fgas/layout/fgas_unicode.h (renamed from xfa/src/fgas/include/fx_ucd.h) | 17 | ||||
-rw-r--r-- | xfa/src/fgas/localization/fgas_datetime.cpp (renamed from xfa/src/fgas/src/localization/fx_datetime.cpp) | 2 | ||||
-rw-r--r-- | xfa/src/fgas/localization/fgas_datetime.h (renamed from xfa/src/fgas/include/fx_datetime.h) | 10 | ||||
-rw-r--r-- | xfa/src/fgas/localization/fgas_locale.cpp (renamed from xfa/src/fgas/src/localization/fx_locale.cpp) | 2 | ||||
-rw-r--r-- | xfa/src/fgas/localization/fgas_locale.h (renamed from xfa/src/fgas/include/fx_locale.h) | 8 | ||||
-rw-r--r-- | xfa/src/fgas/localization/fgas_localeimp.h (renamed from xfa/src/fgas/src/localization/fx_localeimp.h) | 8 | ||||
-rw-r--r-- | xfa/src/fgas/localization/fgas_localemgr.cpp (renamed from xfa/src/fgas/src/localization/fx_localemgr.cpp) | 2 | ||||
-rw-r--r-- | xfa/src/fgas/localization/fgas_localemgr.h (renamed from xfa/src/fgas/src/localization/fx_localemgr.h) | 8 | ||||
-rw-r--r-- | xfa/src/fgas/src/crt/fx_memory.h | 140 | ||||
-rw-r--r-- | xfa/src/fgas/src/crt/fx_stream.h | 310 | ||||
-rw-r--r-- | xfa/src/fgas/src/crt/fx_utils.h | 41 | ||||
-rw-r--r-- | xfa/src/fgas/src/layout/fx_rtfbreak.h | 177 | ||||
-rw-r--r-- | xfa/src/fgas/src/layout/fx_textbreak.h | 174 | ||||
-rw-r--r-- | xfa/src/fgas/src/layout/fx_unicode.h | 20 | ||||
-rw-r--r-- | xfa/src/fgas/xml/fgas_sax.h (renamed from xfa/src/fgas/include/fx_sax.h) | 6 | ||||
-rw-r--r-- | xfa/src/fgas/xml/fgas_sax_imp.cpp (renamed from xfa/src/fgas/src/xml/fx_sax_imp.cpp) | 2 | ||||
-rw-r--r-- | xfa/src/fgas/xml/fgas_sax_imp.h (renamed from xfa/src/fgas/src/xml/fx_sax_imp.h) | 8 |
45 files changed, 937 insertions, 1085 deletions
diff --git a/xfa/src/fgas/src/crt/fx_algorithm.cpp b/xfa/src/fgas/crt/fgas_algorithm.cpp index 7de22b73fa..60b43ac886 100644 --- a/xfa/src/fgas/src/crt/fx_algorithm.cpp +++ b/xfa/src/fgas/crt/fgas_algorithm.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "xfa/src/fgas/crt/fgas_algorithm.h" + #include "core/include/fxcrt/fx_basic.h" #ifdef __cplusplus diff --git a/xfa/src/fgas/include/fx_alg.h b/xfa/src/fgas/crt/fgas_algorithm.h index e2682729a3..f819716820 100644 --- a/xfa/src/fgas/include/fx_alg.h +++ b/xfa/src/fgas/crt/fgas_algorithm.h @@ -4,15 +4,13 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ +#ifndef XFA_SRC_FGAS_CRT_FGAS_ALGORITHM_H_ +#define XFA_SRC_FGAS_CRT_FGAS_ALGORITHM_H_ #include <cstdint> #include "core/include/fxcrt/fx_basic.h" -#define FX_IsOdd(a) ((a)&1) - #ifdef __cplusplus extern "C" { #endif @@ -53,4 +51,4 @@ class CFX_DSPATemplate { } }; -#endif // XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ +#endif // XFA_SRC_FGAS_CRT_FGAS_ALGORITHM_H_ diff --git a/xfa/src/fgas/src/crt/fx_codepage.cpp b/xfa/src/fgas/crt/fgas_codepage.cpp index 0928d005ff..622c4174bc 100644 --- a/xfa/src/fgas/src/crt/fx_codepage.cpp +++ b/xfa/src/fgas/crt/fgas_codepage.cpp @@ -5,8 +5,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/include/fx_cpg.h" -#include "xfa/src/fgas/include/fx_lgg.h" +#include "xfa/src/fgas/crt/fgas_codepage.h" +#include "xfa/src/fgas/crt/fgas_language.h" static const FX_CHARSET_MAP g_FXCharset2CodePageTable[] = { {0, 1252}, {1, 0}, {2, 42}, {77, 10000}, {78, 10001}, diff --git a/xfa/src/fgas/include/fx_cpg.h b/xfa/src/fgas/crt/fgas_codepage.h index 0652411779..e9111d1ec4 100644 --- a/xfa/src/fgas/include/fx_cpg.h +++ b/xfa/src/fgas/crt/fgas_codepage.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_CPG_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_CPG_H_ +#ifndef XFA_SRC_FGAS_CRT_FGAS_CODEPAGE_H_ +#define XFA_SRC_FGAS_CRT_FGAS_CODEPAGE_H_ #include "core/include/fxcrt/fx_basic.h" @@ -132,6 +132,7 @@ #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); @@ -159,66 +160,6 @@ 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, -}; - -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; -}; - -#define FX_CPMAPTYPE_Consecution 1 -#define FX_CPMAPTYPE_Strict 2 -#define FX_CPMAPTYPE_NoMapping 3 -#define FX_CPMAPTYPE_Delta 4 - -struct FX_CPCU_MAPTABLE1 { - uint16_t uMapType; - uint16_t uUniocde; -}; - -struct FX_CPCU_MAPTABLE2 { - uint8_t uTrailByte; - uint8_t uMapType; - uint16_t uOffset; -}; - -struct FX_CPCU_MAPINFO { - FX_CPCU_MAPTABLE1* pMapTable1; - FX_CPCU_MAPTABLE2* pMapTable2; - const uint8_t* pMapData; -}; - -struct FX_CPUC_MAPTABLE { - uint16_t uStartUnicode; - uint16_t uEndUnicode; - uint16_t uMapType; - uint16_t uOffset; -}; - -struct FX_CPUC_MAPINFO { - uint32_t uMapCount; - FX_CPUC_MAPTABLE* pMapTable; - const uint8_t* pMapData; -}; - -struct FX_CODEPAGE { - FX_CODEPAGE_HEADER const* pCPHeader; - FX_CPCU_MAPINFO const* pCPCUMapInfo; - FX_CPUC_MAPINFO const* pCPUCMapInfo; -}; struct FX_STR2CPHASH { uint32_t uHash; @@ -235,27 +176,4 @@ struct FX_LANG2CPMAP { FX_WORD wCodepage; }; -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 // XFA_SRC_FGAS_INCLUDE_FX_CPG_H_ +#endif // XFA_SRC_FGAS_CRT_FGAS_CODEPAGE_H_ diff --git a/xfa/src/fgas/src/crt/fx_encode.cpp b/xfa/src/fgas/crt/fgas_encode.cpp index 79be09819a..564ccf63c4 100644 --- a/xfa/src/fgas/src/crt/fx_encode.cpp +++ b/xfa/src/fgas/crt/fgas_encode.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/include/fx_cpg.h" +#include "xfa/src/fgas/crt/fgas_codepage.h" void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength) { FXSYS_assert(pStr != NULL); diff --git a/xfa/src/fgas/include/fx_lgg.h b/xfa/src/fgas/crt/fgas_language.h index 68e7ebd3ba..15f32e1379 100644 --- a/xfa/src/fgas/include/fx_lgg.h +++ b/xfa/src/fgas/crt/fgas_language.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_LGG_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_LGG_H_ +#ifndef XFA_SRC_FGAS_CRT_FGAS_LANGUAGE_H_ +#define XFA_SRC_FGAS_CRT_FGAS_LANGUAGE_H_ #define FX_LANG_Neutral 0x0000 #define FX_LANG_Invariant 0x007f @@ -266,4 +266,4 @@ #define FX_LANG_Yiddish 0x043d #define FX_LANG_Yoruba_Nigeria 0x046a -#endif // XFA_SRC_FGAS_INCLUDE_FX_LGG_H_ +#endif // XFA_SRC_FGAS_CRT_FGAS_LANGUAGE_H_ diff --git a/xfa/src/fgas/src/crt/fx_memory.cpp b/xfa/src/fgas/crt/fgas_memory.cpp index 5c14a9430c..c88c7e3aac 100644 --- a/xfa/src/fgas/src/crt/fx_memory.cpp +++ b/xfa/src/fgas/crt/fgas_memory.cpp @@ -4,10 +4,138 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/crt/fx_memory.h" +#include "xfa/src/fgas/crt/fgas_memory.h" #include <algorithm> +namespace { + +class CFX_DefStore : public IFX_MEMAllocator, public CFX_Target { + public: + CFX_DefStore() {} + ~CFX_DefStore() {} + virtual void Release() { delete this; } + virtual void* Alloc(size_t size) { return FX_Alloc(uint8_t, size); } + virtual void Free(void* pBlock) { FX_Free(pBlock); } + virtual size_t GetBlockSize() const { return 0; } + virtual size_t GetDefChunkSize() const { return 0; } + virtual size_t SetDefChunkSize(size_t size) { return 0; } + virtual size_t GetCurrentDataSize() const { return 0; } +}; + +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(push, 1) +#endif +struct FX_STATICSTORECHUNK { + FX_STATICSTORECHUNK* pNextChunk; + size_t iChunkSize; + size_t iFreeSize; +}; +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(pop) +#endif + +class CFX_StaticStore : public IFX_MEMAllocator, public CFX_Target { + public: + CFX_StaticStore(size_t iDefChunkSize = 4096); + ~CFX_StaticStore(); + virtual void Release() { delete this; } + virtual void* Alloc(size_t size); + virtual void Free(void* pBlock) {} + virtual size_t GetBlockSize() const { return 0; } + virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; } + virtual size_t SetDefChunkSize(size_t size); + virtual size_t GetCurrentDataSize() const { return m_iAllocatedSize; } + + protected: + size_t m_iAllocatedSize; + size_t m_iDefChunkSize; + FX_STATICSTORECHUNK* m_pChunk; + FX_STATICSTORECHUNK* m_pLastChunk; + FX_STATICSTORECHUNK* AllocChunk(size_t size); + FX_STATICSTORECHUNK* FindChunk(size_t size); +}; + +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(push, 1) +#endif +struct FX_FIXEDSTORECHUNK { + uint8_t* FirstFlag() { return reinterpret_cast<uint8_t*>(this + 1); } + uint8_t* FirstBlock() { return FirstFlag() + iChunkSize; } + + FX_FIXEDSTORECHUNK* pNextChunk; + size_t iChunkSize; + size_t iFreeNum; +}; +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(pop) +#endif + +class CFX_FixedStore : public IFX_MEMAllocator, public CFX_Target { + public: + CFX_FixedStore(size_t iBlockSize, size_t iBlockNumsInChunk); + virtual ~CFX_FixedStore(); + virtual void Release() { delete this; } + virtual void* Alloc(size_t size); + virtual void Free(void* pBlock); + virtual size_t GetBlockSize() const { return m_iBlockSize; } + virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; } + virtual size_t SetDefChunkSize(size_t iChunkSize); + virtual size_t GetCurrentDataSize() const { return 0; } + + protected: + FX_FIXEDSTORECHUNK* AllocChunk(); + + size_t m_iBlockSize; + size_t m_iDefChunkSize; + FX_FIXEDSTORECHUNK* m_pChunk; +}; + +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(push, 1) +#endif +struct FX_DYNAMICSTOREBLOCK { + uint8_t* Data() { return reinterpret_cast<uint8_t*>(this + 1); } + FX_DYNAMICSTOREBLOCK* NextBlock() { + return reinterpret_cast<FX_DYNAMICSTOREBLOCK*>(Data() + iBlockSize); + } + size_t iBlockSize; + FX_BOOL bUsed; +}; + +struct FX_DYNAMICSTORECHUNK { + FX_DYNAMICSTOREBLOCK* FirstBlock() { + return reinterpret_cast<FX_DYNAMICSTOREBLOCK*>(this + 1); + } + FX_DYNAMICSTORECHUNK* pNextChunk; + size_t iChunkSize; + size_t iFreeSize; +}; +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(pop) +#endif + +class CFX_DynamicStore : public IFX_MEMAllocator, public CFX_Target { + public: + CFX_DynamicStore(size_t iDefChunkSize = 4096); + virtual ~CFX_DynamicStore(); + virtual void Release() { delete this; } + virtual void* Alloc(size_t size); + virtual void Free(void* pBlock); + virtual size_t GetBlockSize() const { return 0; } + virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; } + virtual size_t SetDefChunkSize(size_t size); + virtual size_t GetCurrentDataSize() const { return 0; } + + protected: + FX_DYNAMICSTORECHUNK* AllocChunk(size_t size); + + size_t m_iDefChunkSize; + FX_DYNAMICSTORECHUNK* m_pChunk; +}; + +} // namespace + #define FX_4BYTEALIGN(size) (((size) + 3) / 4 * 4) IFX_MEMAllocator* FX_CreateAllocator(FX_ALLOCTYPE eType, diff --git a/xfa/src/fgas/include/fx_mem.h b/xfa/src/fgas/crt/fgas_memory.h index e768c454ac..90a8ddaf9a 100644 --- a/xfa/src/fgas/include/fx_mem.h +++ b/xfa/src/fgas/crt/fgas_memory.h @@ -4,10 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_MEM_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_MEM_H_ +#ifndef XFA_SRC_FGAS_CRT_FGAS_MEMORY_H_ +#define XFA_SRC_FGAS_CRT_FGAS_MEMORY_H_ -#include "core/include/fxcrt/fx_memory.h" // For FX_Alloc(). +#include "core/include/fxcrt/fx_memory.h" +#include "core/include/fxcrt/fx_system.h" class IFX_MEMAllocator; class CFX_Target; @@ -55,4 +56,4 @@ class CFX_Target { (pointer)->operator delete((pointer), (__allocator__)); \ } -#endif // XFA_SRC_FGAS_INCLUDE_FX_MEM_H_ +#endif // XFA_SRC_FGAS_CRT_FGAS_MEMORY_H_ diff --git a/xfa/src/fgas/src/crt/fx_stream.cpp b/xfa/src/fgas/crt/fgas_stream.cpp index 4f5c292ab8..c515b56662 100644 --- a/xfa/src/fgas/src/crt/fx_stream.cpp +++ b/xfa/src/fgas/crt/fgas_stream.cpp @@ -4,12 +4,310 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/crt/fx_stream.h" +#include "xfa/src/fgas/crt/fgas_stream.h" #include <algorithm> -#include "xfa/src/fgas/include/fx_cpg.h" -#include "xfa/src/fgas/include/fx_sys.h" +#include "xfa/src/fgas/crt/fgas_system.h" +#include "xfa/src/fgas/crt/fgas_codepage.h" + +namespace { + +class CFX_StreamImp { + public: + virtual void Release() { delete this; } + virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } + 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) = 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; + + protected: + CFX_StreamImp(); + virtual ~CFX_StreamImp() {} + FX_DWORD m_dwAccess; +}; + +class CFX_FileStreamImp : public CFX_StreamImp { + public: + CFX_FileStreamImp(); + virtual ~CFX_FileStreamImp(); + FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength); + + protected: + FXSYS_FILE* m_hFile; + int32_t m_iLength; +}; + +class CFX_BufferStreamImp : public CFX_StreamImp { + public: + CFX_BufferStreamImp(); + virtual ~CFX_BufferStreamImp() {} + FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush() {} + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + protected: + uint8_t* m_pData; + int32_t m_iTotalSize; + int32_t m_iPosition; + int32_t m_iLength; +}; + +class CFX_FileReadStreamImp : public CFX_StreamImp { + public: + CFX_FileReadStreamImp(); + virtual ~CFX_FileReadStreamImp() {} + FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition() { return m_iPosition; } + virtual FX_BOOL IsEOF() const; + + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { + return 0; + } + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { + return 0; + } + virtual void Flush() {} + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + protected: + IFX_FileRead* m_pFileRead; + int32_t m_iPosition; + int32_t m_iLength; +}; + +class CFX_BufferReadStreamImp : public CFX_StreamImp { + public: + CFX_BufferReadStreamImp(); + ~CFX_BufferReadStreamImp(); + FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, + int32_t iFileSize, + FX_DWORD dwAccess, + FX_BOOL bReleaseBufferRead); + + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition() { return m_iPosition; } + virtual FX_BOOL IsEOF() const; + + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { + return 0; + } + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { + return 0; + } + virtual void Flush() {} + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + private: + IFX_BufferRead* m_pBufferRead; + FX_BOOL m_bReleaseBufferRead; + int32_t m_iPosition; + int32_t m_iBufferSize; +}; + +class CFX_FileWriteStreamImp : public CFX_StreamImp { + public: + CFX_FileWriteStreamImp(); + virtual ~CFX_FileWriteStreamImp() {} + FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition() { return m_iPosition; } + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) { return 0; } + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS) { + return 0; + } + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + protected: + IFX_FileWrite* m_pFileWrite; + int32_t m_iPosition; +}; + +enum FX_STREAMTYPE { + FX_SREAMTYPE_Unknown = 0, + FX_STREAMTYPE_File, + FX_STREAMTYPE_Buffer, + FX_STREAMTYPE_Stream, + FX_STREAMTYPE_BufferRead, +}; + +class CFX_Stream : public IFX_Stream { + public: + CFX_Stream(); + ~CFX_Stream(); + FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); + FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); + FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); + FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); + FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, + int32_t iFileSize, + FX_DWORD dwAccess, + FX_BOOL bReleaseBufferRead); + virtual void Release(); + virtual IFX_Stream* Retain(); + virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize = NULL); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength); + virtual int32_t GetBOM(uint8_t bom[4]) const; + virtual FX_WORD GetCodePage() const; + virtual FX_WORD SetCodePage(FX_WORD wCodePage); + virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength); + + protected: + FX_STREAMTYPE m_eStreamType; + CFX_StreamImp* m_pStreamImp; + FX_DWORD m_dwAccess; + int32_t m_iTotalSize; + int32_t m_iPosition; + int32_t m_iStart; + int32_t m_iLength; + int32_t m_iRefCount; +}; + +class CFX_TextStream : public IFX_Stream { + public: + CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream); + ~CFX_TextStream(); + virtual void Release(); + virtual IFX_Stream* Retain(); + + virtual FX_DWORD GetAccessModes() const; + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize = NULL); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength); + + virtual int32_t GetBOM(uint8_t bom[4]) const; + virtual FX_WORD GetCodePage() const; + virtual FX_WORD SetCodePage(FX_WORD wCodePage); + + virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength); + + protected: + FX_WORD m_wCodePage; + int32_t m_wBOMLength; + FX_DWORD m_dwBOM; + uint8_t* m_pBuf; + int32_t m_iBufSize; + FX_BOOL m_bDelStream; + IFX_Stream* m_pStreamImp; + int32_t m_iRefCount; + void InitStream(); +}; + +class CFGAS_FileRead : public IFX_FileRead { + public: + CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream); + virtual ~CFGAS_FileRead(); + virtual void Release() { delete this; } + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); + + protected: + FX_BOOL m_bReleaseStream; + IFX_Stream* m_pStream; +}; + +class CFX_BufferAccImp : public IFX_FileRead { + public: + CFX_BufferAccImp(IFX_BufferRead* pBufferRead, + FX_FILESIZE iFileSize, + FX_BOOL bReleaseStream); + virtual ~CFX_BufferAccImp(); + virtual void Release() { delete this; } + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); + + protected: + IFX_BufferRead* m_pBufferRead; + FX_BOOL m_bReleaseStream; + FX_FILESIZE m_iBufSize; +}; + +class CFGAS_FileWrite : public IFX_FileWrite { + public: + CFGAS_FileWrite(IFX_Stream* pStream, FX_BOOL bReleaseStream); + virtual ~CFGAS_FileWrite(); + virtual void Release() { delete this; } + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL Flush(); + virtual FX_BOOL WriteBlock(const void* pData, size_t size); + virtual FX_BOOL WriteBlock(const void* pData, + FX_FILESIZE offset, + size_t size); + + protected: + IFX_Stream* m_pStream; + FX_BOOL m_bReleaseStream; +}; + +} // namespace IFX_Stream* IFX_Stream::CreateStream(IFX_BufferRead* pBufferRead, FX_DWORD dwAccess, diff --git a/xfa/src/fgas/include/fx_stm.h b/xfa/src/fgas/crt/fgas_stream.h index 199a03f677..cc40a76cc6 100644 --- a/xfa/src/fgas/include/fx_stm.h +++ b/xfa/src/fgas/crt/fgas_stream.h @@ -4,10 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_STM_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_STM_H_ +#ifndef XFA_SRC_FGAS_CRT_FGAS_STREAM_H_ +#define XFA_SRC_FGAS_CRT_FGAS_STREAM_H_ #include "core/include/fxcrt/fx_stream.h" +#include "core/include/fxcrt/fx_system.h" class IFX_Stream; @@ -27,11 +28,13 @@ enum FX_STREAMACCESS { 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); @@ -72,4 +75,4 @@ class IFX_Stream { int32_t iLength) = 0; }; -#endif // XFA_SRC_FGAS_INCLUDE_FX_STM_H_ +#endif // XFA_SRC_FGAS_CRT_FGAS_STREAM_H_ diff --git a/xfa/src/fgas/src/crt/fx_system.cpp b/xfa/src/fgas/crt/fgas_system.cpp index 43cccba20a..a4ca7546e0 100644 --- a/xfa/src/fgas/src/crt/fx_system.cpp +++ b/xfa/src/fgas/crt/fgas_system.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "xfa/src/fgas/crt/fgas_system.h" + #include <algorithm> #include "core/include/fxcrt/fx_system.h" diff --git a/xfa/src/fgas/include/fx_sys.h b/xfa/src/fgas/crt/fgas_system.h index d4fec2a74d..fb5a88efb5 100644 --- a/xfa/src/fgas/include/fx_sys.h +++ b/xfa/src/fgas/crt/fgas_system.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_SYS_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_SYS_H_ +#ifndef XFA_SRC_FGAS_CRT_FGAS_SYSTEM_H_ +#define XFA_SRC_FGAS_CRT_FGAS_SYSTEM_H_ #include "core/include/fxcrt/fx_system.h" @@ -20,4 +20,4 @@ int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); int32_t FX_filelength(FXSYS_FILE* file); FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size); -#endif // XFA_SRC_FGAS_INCLUDE_FX_SYS_H_ +#endif // XFA_SRC_FGAS_CRT_FGAS_SYSTEM_H_ diff --git a/xfa/src/fgas/src/crt/fx_utils.cpp b/xfa/src/fgas/crt/fgas_utils.cpp index 382f64649f..8b3ed0aa0b 100644 --- a/xfa/src/fgas/src/crt/fx_utils.cpp +++ b/xfa/src/fgas/crt/fgas_utils.cpp @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/crt/fx_utils.h" +#include "xfa/src/fgas/crt/fgas_utils.h" #include <algorithm> -#include "xfa/src/fgas/include/fx_utl.h" +#include "core/include/fxcrt/fx_basic.h" class FX_BASEARRAYDATA : public CFX_Target { public: @@ -135,6 +135,7 @@ void CFX_BaseArray::RemoveAll(FX_BOOL bLeaveMemory) { } m_pData->iBlockCount = 0; } + CFX_BaseMassArrayImp::CFX_BaseMassArrayImp(int32_t iChunkSize, int32_t iBlockSize) : m_iChunkSize(iChunkSize), diff --git a/xfa/src/fgas/include/fx_utl.h b/xfa/src/fgas/crt/fgas_utils.h index 8ce736569d..f52255a5d3 100644 --- a/xfa/src/fgas/include/fx_utl.h +++ b/xfa/src/fgas/crt/fgas_utils.h @@ -4,36 +4,16 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_UTL_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_UTL_H_ +#ifndef XFA_SRC_FGAS_CRT_FGAS_UTILS_H_ +#define XFA_SRC_FGAS_CRT_FGAS_UTILS_H_ -#include "core/include/fxcrt/fx_coordinates.h" // For CFX_Rect. -#include "xfa/src/fgas/include/fx_mem.h" +#include "core/include/fxcrt/fx_coordinates.h" +#include "xfa/src/fgas/crt/fgas_memory.h" + +class FX_BASEARRAYDATA; -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_BaseArray : public CFX_Target { protected: @@ -55,6 +35,7 @@ class CFX_BaseArray : public CFX_Target { FX_BASEARRAYDATA* m_pData; }; + template <class baseType> class CFX_BaseArrayTemplate : public CFX_BaseArray { public: @@ -105,6 +86,7 @@ class CFX_BaseArrayTemplate : public CFX_BaseArray { 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: @@ -204,6 +186,35 @@ class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray { CFX_BaseArray::RemoveAll(bLeaveMemory); } }; + +class CFX_BaseMassArrayImp : public CFX_Target { + public: + CFX_BaseMassArrayImp(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseMassArrayImp(); + uint8_t* AddSpace() { return AddSpaceTo(m_iBlockCount); } + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + int32_t Append(const CFX_BaseMassArrayImp& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t Copy(const CFX_BaseMassArrayImp& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t RemoveLast(int32_t iCount = -1); + void RemoveAll(FX_BOOL bLeaveMemory = FALSE); + int32_t m_iChunkSize; + int32_t m_iBlockSize; + int32_t m_iChunkCount; + int32_t m_iBlockCount; + CFX_PtrArray* m_pData; + + protected: + void Append(int32_t iDstStart, + const CFX_BaseMassArrayImp& src, + int32_t iSrcStart = 0, + int32_t iSrcCount = -1); +}; + class CFX_BaseMassArray : public CFX_Target { protected: CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize); @@ -221,6 +232,7 @@ class CFX_BaseMassArray : public CFX_Target { void RemoveAll(FX_BOOL bLeaveMemory = FALSE); CFX_BaseMassArrayImp* m_pData; }; + template <class baseType> class CFX_MassArrayTemplate : public CFX_BaseMassArray { public: @@ -273,6 +285,7 @@ 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: @@ -354,6 +367,7 @@ class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray { CFX_BaseMassArray::RemoveAll(bLeaveMemory); } }; + class CFX_BaseDiscreteArray : public CFX_Target { protected: CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize); @@ -363,6 +377,7 @@ class CFX_BaseDiscreteArray : public CFX_Target { void RemoveAll(); void* m_pData; }; + template <class baseType> class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { public: @@ -383,6 +398,7 @@ class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { 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); @@ -395,6 +411,7 @@ class CFX_BaseStack : public CFX_Target { void RemoveAll(FX_BOOL bLeaveMemory = FALSE); CFX_BaseMassArrayImp* m_pData; }; + template <class baseType> class CFX_StackTemplate : public CFX_BaseStack { public: @@ -421,6 +438,7 @@ 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: @@ -476,6 +494,7 @@ class CFX_ObjectStackTemplate : public CFX_BaseStack { return CFX_BaseStack::GetSize(); } }; + template <class baseType> class CFX_CPLTreeNode : public CFX_Target { public: @@ -676,6 +695,7 @@ class CFX_CPLTreeNode : public CFX_Target { baseType m_Data; friend class CFX_CPLTree<baseType>; }; + template <class baseType> class CFX_CPLTree { public: @@ -714,4 +734,4 @@ class CFX_CPLTree { CPLTreeNode m_Root; }; -#endif // XFA_SRC_FGAS_INCLUDE_FX_UTL_H_ +#endif // XFA_SRC_FGAS_CRT_FGAS_UTILS_H_ diff --git a/xfa/src/fgas/include/fx_fnt.h b/xfa/src/fgas/font/fgas_font.h index 3d44eaa8d4..0484dee3e6 100644 --- a/xfa/src/fgas/include/fx_fnt.h +++ b/xfa/src/fgas/font/fgas_font.h @@ -4,15 +4,15 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_FNT_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_FNT_H_ +#ifndef XFA_SRC_FGAS_FONT_FGAS_FONT_H_ +#define XFA_SRC_FGAS_FONT_FGAS_FONT_H_ #include "core/include/fxge/fx_font.h" -#include "xfa/src/fgas/include/fx_stm.h" +#include "xfa/src/fgas/crt/fgas_stream.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -#include "xfa/src/fgas/include/fx_mem.h" -#include "xfa/src/fgas/include/fx_utl.h" +#include "xfa/src/fgas/crt/fgas_memory.h" +#include "xfa/src/fgas/crt/fgas_utils.h" #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ class IFX_Font; @@ -282,4 +282,4 @@ class IFX_FontMgr { }; #endif -#endif // XFA_SRC_FGAS_INCLUDE_FX_FNT_H_ +#endif // XFA_SRC_FGAS_FONT_FGAS_FONT_H_ diff --git a/xfa/src/fgas/src/font/fx_fontutils.cpp b/xfa/src/fgas/font/fgas_fontutils.cpp index 5499994eef..62f26f515a 100644 --- a/xfa/src/fgas/src/font/fx_fontutils.cpp +++ b/xfa/src/fgas/font/fgas_fontutils.cpp @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/font/fx_fontutils.h" +#include "xfa/src/fgas/font/fgas_fontutils.h" #include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/include/fx_fnt.h" +#include "xfa/src/fgas/font/fgas_font.h" FX_DWORD FGAS_GetFontHashCode(FX_WORD wCodePage, FX_DWORD dwFontStyles) { FX_DWORD dwHash = wCodePage; diff --git a/xfa/src/fgas/src/font/fx_fontutils.h b/xfa/src/fgas/font/fgas_fontutils.h index ec14686c8e..4cceb68574 100644 --- a/xfa/src/fgas/src/font/fx_fontutils.h +++ b/xfa/src/fgas/font/fgas_fontutils.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_SRC_FONT_FX_FONTUTILS_H_ -#define XFA_SRC_FGAS_SRC_FONT_FX_FONTUTILS_H_ +#ifndef XFA_SRC_FGAS_FONT_FGAS_FONTUTILS_H_ +#define XFA_SRC_FGAS_FONT_FGAS_FONTUTILS_H_ #include "core/include/fxcrt/fx_string.h" @@ -22,4 +22,4 @@ FX_DWORD FGAS_GetFontFamilyHash(const FX_WCHAR* pszFontFamily, FX_WORD wCodePage); const FGAS_FONTUSB* FGAS_GetUnicodeBitField(FX_WCHAR wUnicode); -#endif // XFA_SRC_FGAS_SRC_FONT_FX_FONTUTILS_H_ +#endif // XFA_SRC_FGAS_FONT_FGAS_FONTUTILS_H_ diff --git a/xfa/src/fgas/src/font/fx_gefont.cpp b/xfa/src/fgas/font/fgas_gefont.cpp index 468e28ea96..df614a57c3 100644 --- a/xfa/src/fgas/src/font/fx_gefont.cpp +++ b/xfa/src/fgas/font/fgas_gefont.cpp @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/font/fx_gefont.h" +#include "xfa/src/fgas/font/fgas_gefont.h" -#include "xfa/src/fgas/include/fx_cpg.h" -#include "xfa/src/fgas/src/font/fx_fontutils.h" +#include "xfa/src/fgas/crt/fgas_codepage.h" +#include "xfa/src/fgas/font/fgas_fontutils.h" IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFontFamily, FX_DWORD dwFontStyles, diff --git a/xfa/src/fgas/src/font/fx_gefont.h b/xfa/src/fgas/font/fgas_gefont.h index ef7803d2a5..1bc8a6a902 100644 --- a/xfa/src/fgas/src/font/fx_gefont.h +++ b/xfa/src/fgas/font/fgas_gefont.h @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_SRC_FONT_FX_GEFONT_H_ -#define XFA_SRC_FGAS_SRC_FONT_FX_GEFONT_H_ +#ifndef XFA_SRC_FGAS_FONT_FGAS_GEFONT_H_ +#define XFA_SRC_FGAS_FONT_FGAS_GEFONT_H_ -#include "xfa/src/fgas/include/fx_fnt.h" -#include "xfa/src/fgas/include/fx_utl.h" +#include "xfa/src/fgas/crt/fgas_utils.h" +#include "xfa/src/fgas/font/fgas_font.h" #define FXFONT_SUBST_ITALIC 0x02 @@ -89,4 +89,4 @@ class CFX_GEFont : public IFX_Font { FX_BOOL bCharCode = FALSE); }; -#endif // XFA_SRC_FGAS_SRC_FONT_FX_GEFONT_H_ +#endif // XFA_SRC_FGAS_FONT_FGAS_GEFONT_H_ diff --git a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp b/xfa/src/fgas/font/fgas_stdfontmgr.cpp index 8ec8fc51fe..99f1fdda44 100644 --- a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp +++ b/xfa/src/fgas/font/fgas_stdfontmgr.cpp @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/font/fx_stdfontmgr.h" +#include "xfa/src/fgas/font/fgas_stdfontmgr.h" #include "core/include/fxcrt/fx_stream.h" -#include "xfa/src/fgas/include/fx_cpg.h" -#include "xfa/src/fgas/src/font/fx_fontutils.h" +#include "xfa/src/fgas/crt/fgas_codepage.h" +#include "xfa/src/fgas/font/fgas_fontutils.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ IFX_FontMgr* IFX_FontMgr::Create(FX_LPEnumAllFonts pEnumerator, diff --git a/xfa/src/fgas/src/font/fx_stdfontmgr.h b/xfa/src/fgas/font/fgas_stdfontmgr.h index d1cc095805..cf16033919 100644 --- a/xfa/src/fgas/src/font/fx_stdfontmgr.h +++ b/xfa/src/fgas/font/fgas_stdfontmgr.h @@ -4,14 +4,14 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_SRC_FONT_FX_STDFONTMGR_H_ -#define XFA_SRC_FGAS_SRC_FONT_FX_STDFONTMGR_H_ +#ifndef XFA_SRC_FGAS_FONT_FGAS_STDFONTMGR_H_ +#define XFA_SRC_FGAS_FONT_FGAS_STDFONTMGR_H_ #include "core/include/fxcrt/fx_ext.h" #include "core/include/fxge/fx_freetype.h" #include "core/include/fxge/fx_ge.h" #include "third_party/freetype/include/freetype/fttypes.h" -#include "xfa/src/fgas/include/fx_fnt.h" +#include "xfa/src/fgas/font/fgas_font.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ int32_t FX_GetSimilarValue(FX_LPCFONTDESCRIPTOR pFont, FX_DWORD dwFontStyles); @@ -249,4 +249,4 @@ class CFX_FontMgrImp : public IFX_FontMgr { }; #endif -#endif // XFA_SRC_FGAS_SRC_FONT_FX_STDFONTMGR_H_ +#endif // XFA_SRC_FGAS_FONT_FGAS_STDFONTMGR_H_ diff --git a/xfa/src/fgas/src/layout/fx_linebreak.cpp b/xfa/src/fgas/layout/fgas_linebreak.cpp index ed3c1b57f3..b43b8007b4 100644 --- a/xfa/src/fgas/src/layout/fx_linebreak.cpp +++ b/xfa/src/fgas/layout/fgas_linebreak.cpp @@ -4,8 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "xfa/src/fgas/layout/fgas_linebreak.h" + #include "core/include/fxcrt/fx_ucd.h" -#include "xfa/src/fgas/include/fx_lbk.h" const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32] = { {FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, diff --git a/xfa/src/fgas/include/fx_lbk.h b/xfa/src/fgas/layout/fgas_linebreak.h index 12a0fc1cad..7b91124bc2 100644 --- a/xfa/src/fgas/include/fx_lbk.h +++ b/xfa/src/fgas/layout/fgas_linebreak.h @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_LBK_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_LBK_H_ +#ifndef XFA_SRC_FGAS_LAYOUT_FGAS_LINEBREAK_H_ +#define XFA_SRC_FGAS_LAYOUT_FGAS_LINEBREAK_H_ #include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fgas/include/fx_utl.h" +#include "xfa/src/fgas/crt/fgas_utils.h" enum FX_LINEBREAKTYPE { FX_LBT_UNKNOWN = 0x00, @@ -37,4 +37,4 @@ void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, int32_t iLength, CFX_Int32MassArray& bp); -#endif // XFA_SRC_FGAS_INCLUDE_FX_LBK_H_ +#endif // XFA_SRC_FGAS_LAYOUT_FGAS_LINEBREAK_H_ diff --git a/xfa/src/fgas/src/layout/fx_rtfbreak.cpp b/xfa/src/fgas/layout/fgas_rtfbreak.cpp index b1f9d5e9ae..7e4ab4c08c 100644 --- a/xfa/src/fgas/src/layout/fx_rtfbreak.cpp +++ b/xfa/src/fgas/layout/fgas_rtfbreak.cpp @@ -4,12 +4,179 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/layout/fx_rtfbreak.h" +#include "xfa/src/fgas/layout/fgas_rtfbreak.h" #include <algorithm> -#include "xfa/src/fgas/include/fx_lbk.h" -#include "xfa/src/fgas/src/layout/fx_unicode.h" +#include "core/include/fxcrt/fx_arb.h" +#include "xfa/src/fgas/layout/fgas_linebreak.h" +#include "xfa/src/fgas/layout/fgas_unicode.h" + +namespace { + +class CFX_RTFLine { + public: + CFX_RTFLine() + : m_LinePieces(16), + m_iStart(0), + m_iWidth(0), + m_iArabicChars(0), + m_iMBCSChars(0) {} + ~CFX_RTFLine() { RemoveAll(); } + int32_t CountChars() const { return m_LineChars.GetSize(); } + CFX_RTFChar& GetChar(int32_t index) { + FXSYS_assert(index > -1 && index < m_LineChars.GetSize()); + return *m_LineChars.GetDataPtr(index); + } + CFX_RTFChar* GetCharPtr(int32_t index) { + FXSYS_assert(index > -1 && index < m_LineChars.GetSize()); + return m_LineChars.GetDataPtr(index); + } + int32_t CountPieces() const { return m_LinePieces.GetSize(); } + CFX_RTFPiece& GetPiece(int32_t index) const { + FXSYS_assert(index > -1 && index < m_LinePieces.GetSize()); + return m_LinePieces.GetAt(index); + } + CFX_RTFPiece* GetPiecePtr(int32_t index) const { + FXSYS_assert(index > -1 && index < m_LinePieces.GetSize()); + return m_LinePieces.GetPtrAt(index); + } + int32_t GetLineEnd() const { return m_iStart + m_iWidth; } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + CFX_RTFChar* pChar; + IFX_Unknown* pUnknown; + int32_t iCount = m_LineChars.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + pChar = m_LineChars.GetDataPtr(i); + if ((pUnknown = pChar->m_pUserData) != NULL) { + pUnknown->Release(); + } + } + m_LineChars.RemoveAll(); + m_LinePieces.RemoveAll(bLeaveMemory); + m_iWidth = 0; + m_iArabicChars = 0; + m_iMBCSChars = 0; + } + CFX_RTFCharArray m_LineChars; + CFX_RTFPieceArray m_LinePieces; + int32_t m_iStart; + int32_t m_iWidth; + int32_t m_iArabicChars; + int32_t m_iMBCSChars; +}; + +class CFX_RTFBreak : public IFX_RTFBreak { + public: + CFX_RTFBreak(FX_DWORD dwPolicies); + ~CFX_RTFBreak(); + void Release() override { delete this; } + void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override; + void SetLineStartPos(FX_FLOAT fLinePos) override; + FX_DWORD GetLayoutStyles() const override { return m_dwLayoutStyles; } + void SetLayoutStyles(FX_DWORD dwLayoutStyles) override; + void SetFont(IFX_Font* pFont) override; + void SetFontSize(FX_FLOAT fFontSize) override; + void SetTabWidth(FX_FLOAT fTabWidth) override; + void AddPositionedTab(FX_FLOAT fTabPos) override; + void SetPositionedTabs(const CFX_FloatArray& tabs) override; + void ClearPositionedTabs() override; + void SetDefaultChar(FX_WCHAR wch) override; + void SetLineBreakChar(FX_WCHAR wch) override; + void SetLineBreakTolerance(FX_FLOAT fTolerance) override; + void SetHorizontalScale(int32_t iScale) override; + void SetVerticalScale(int32_t iScale) override; + void SetCharRotation(int32_t iCharRotation) override; + void SetCharSpace(FX_FLOAT fCharSpace) override; + void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) override; + void SetReadingOrder(FX_BOOL bRTL = FALSE) override; + void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) override; + void SetUserData(IFX_Unknown* pUserData) override; + FX_DWORD AppendChar(FX_WCHAR wch) override; + FX_DWORD EndBreak(FX_DWORD dwStatus = FX_RTFBREAK_PieceBreak) override; + int32_t CountBreakPieces() const override; + const CFX_RTFPiece* GetBreakPiece(int32_t index) const override; + void GetLineRect(CFX_RectF& rect) const override; + void ClearBreakPieces() override; + void Reset() override; + int32_t GetDisplayPos( + const FX_RTFTEXTOBJ* pText, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode = FALSE, + CFX_WideString* pWSForms = NULL, + FX_AdjustCharDisplayPos pAdjustPos = NULL) const override; + int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, + CFX_RectFArray& rtArray, + FX_BOOL bCharBBox = FALSE) const override; + FX_DWORD AppendChar_CharCode(FX_WCHAR wch); + FX_DWORD AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); + + protected: + FX_DWORD m_dwPolicies; + IFX_ArabicChar* m_pArabicChar; + int32_t m_iBoundaryStart; + int32_t m_iBoundaryEnd; + FX_DWORD m_dwLayoutStyles; + FX_BOOL m_bPagination; + FX_BOOL m_bVertical; + FX_BOOL m_bSingleLine; + FX_BOOL m_bCharCode; + IFX_Font* m_pFont; + int32_t m_iFontHeight; + int32_t m_iFontSize; + int32_t m_iTabWidth; + CFX_Int32Array m_PositionedTabs; + FX_BOOL m_bOrphanLine; + FX_WCHAR m_wDefChar; + int32_t m_iDefChar; + FX_WCHAR m_wLineBreakChar; + int32_t m_iHorizontalScale; + int32_t m_iVerticalScale; + int32_t m_iLineRotation; + int32_t m_iCharRotation; + int32_t m_iRotation; + int32_t m_iCharSpace; + FX_BOOL m_bWordSpace; + int32_t m_iWordSpace; + FX_BOOL m_bRTL; + int32_t m_iAlignment; + IFX_Unknown* m_pUserData; + FX_DWORD m_dwCharType; + FX_DWORD m_dwIdentity; + CFX_RTFLine m_RTFLine1; + CFX_RTFLine m_RTFLine2; + CFX_RTFLine* m_pCurLine; + int32_t m_iReady; + int32_t m_iTolerance; + int32_t GetLineRotation(FX_DWORD dwStyles) const; + void SetBreakStatus(); + CFX_RTFChar* GetLastChar(int32_t index) const; + CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const; + CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const; + FX_DWORD GetUnifiedCharType(FX_DWORD dwType) const; + int32_t GetLastPositionedTab() const; + FX_BOOL GetPositionedTab(int32_t& iTabPos) const; + int32_t GetBreakPos(CFX_RTFCharArray& tca, + int32_t& iEndPos, + FX_BOOL bAllChars = FALSE, + FX_BOOL bOnlyBrk = FALSE); + void SplitTextLine(CFX_RTFLine* pCurLine, + CFX_RTFLine* pNextLine, + FX_BOOL bAllChars = FALSE); + FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine, + FX_BOOL bAllChars, + FX_DWORD dwStatus); + void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); + void EndBreak_Alignment(CFX_TPOArray& tpos, + FX_BOOL bAllChars, + FX_DWORD dwStatus); +}; + +} // namespace IFX_RTFBreak* IFX_RTFBreak::Create(FX_DWORD dwPolicies) { return new CFX_RTFBreak(dwPolicies); diff --git a/xfa/src/fgas/include/fx_rbk.h b/xfa/src/fgas/layout/fgas_rtfbreak.h index ef76ab6243..24cf2e32cb 100644 --- a/xfa/src/fgas/include/fx_rbk.h +++ b/xfa/src/fgas/layout/fgas_rtfbreak.h @@ -4,19 +4,18 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_RBK_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_RBK_H_ +#ifndef XFA_SRC_FGAS_LAYOUT_FGAS_RTFBREAK_H_ +#define XFA_SRC_FGAS_LAYOUT_FGAS_RTFBREAK_H_ #include "core/include/fxcrt/fx_ucd.h" #include "core/include/fxge/fx_ge.h" -#include "xfa/src/fgas/include/fx_mem.h" -#include "xfa/src/fgas/include/fx_tbk.h" -#include "xfa/src/fgas/include/fx_ucd.h" -#include "xfa/src/fgas/include/fx_utl.h" +#include "xfa/src/fgas/crt/fgas_memory.h" +#include "xfa/src/fgas/crt/fgas_utils.h" +#include "xfa/src/fgas/layout/fgas_textbreak.h" +#include "xfa/src/fgas/layout/fgas_unicode.h" class IFX_Unknown; class IFX_Font; -class IFX_RTFBreak; #define FX_RTFBREAKPOLICY_None 0x00 #define FX_RTFBREAKPOLICY_SpaceBreak 0x01 @@ -190,6 +189,7 @@ class CFX_RTFPiece : public CFX_Target { IFX_Unknown* m_pUserData; }; typedef CFX_BaseArrayTemplate<CFX_RTFPiece> CFX_RTFPieceArray; + class IFX_RTFBreak { public: static IFX_RTFBreak* Create(FX_DWORD dwPolicies); @@ -234,4 +234,4 @@ class IFX_RTFBreak { FX_BOOL bCharBBox = FALSE) const = 0; }; -#endif // XFA_SRC_FGAS_INCLUDE_FX_RBK_H_ +#endif // XFA_SRC_FGAS_LAYOUT_FGAS_RTFBREAK_H_ diff --git a/xfa/src/fgas/src/layout/fx_textbreak.cpp b/xfa/src/fgas/layout/fgas_textbreak.cpp index 6263463bd4..af7be50a51 100644 --- a/xfa/src/fgas/src/layout/fx_textbreak.cpp +++ b/xfa/src/fgas/layout/fgas_textbreak.cpp @@ -4,13 +4,176 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/layout/fx_textbreak.h" +#include "xfa/src/fgas/layout/fgas_textbreak.h" #include <algorithm> #include "core/include/fxcrt/fx_arb.h" -#include "xfa/src/fgas/include/fx_lbk.h" -#include "xfa/src/fgas/src/layout/fx_unicode.h" +#include "core/include/fxcrt/fx_memory.h" +#include "xfa/src/fgas/layout/fgas_linebreak.h" +#include "xfa/src/fgas/layout/fgas_unicode.h" + +namespace { + +class CFX_TxtLine { + public: + CFX_TxtLine(int32_t iBlockSize) + : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { + m_pLineChars = new CFX_TxtCharArray; + m_pLinePieces = new CFX_TxtPieceArray(16); + } + ~CFX_TxtLine() { + RemoveAll(); + delete m_pLineChars; + delete m_pLinePieces; + } + int32_t CountChars() const { return m_pLineChars->GetSize(); } + CFX_TxtChar* GetCharPtr(int32_t index) const { + FXSYS_assert(index > -1 && index < m_pLineChars->GetSize()); + return m_pLineChars->GetDataPtr(index); + } + int32_t CountPieces() const { return m_pLinePieces->GetSize(); } + CFX_TxtPiece* GetPiecePtr(int32_t index) const { + FXSYS_assert(index > -1 && index < m_pLinePieces->GetSize()); + return m_pLinePieces->GetPtrAt(index); + } + void GetString(CFX_WideString& wsStr) const { + int32_t iCount = m_pLineChars->GetSize(); + FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); + CFX_Char* pChar; + for (int32_t i = 0; i < iCount; i++) { + pChar = m_pLineChars->GetDataPtr(i); + *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; + } + wsStr.ReleaseBuffer(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + m_pLineChars->RemoveAll(); + m_pLinePieces->RemoveAll(bLeaveMemory); + m_iWidth = 0; + m_iArabicChars = 0; + } + CFX_TxtCharArray* m_pLineChars; + CFX_TxtPieceArray* m_pLinePieces; + int32_t m_iStart; + int32_t m_iWidth; + int32_t m_iArabicChars; +}; + +class CFX_TxtBreak : public IFX_TxtBreak { + public: + CFX_TxtBreak(FX_DWORD dwPolicies); + ~CFX_TxtBreak(); + virtual void Release() { delete this; } + virtual void SetLineWidth(FX_FLOAT fLineWidth); + virtual void SetLinePos(FX_FLOAT fLinePos); + virtual FX_DWORD GetLayoutStyles() const { return m_dwLayoutStyles; } + virtual void SetLayoutStyles(FX_DWORD dwLayoutStyles); + virtual void SetFont(IFX_Font* pFont); + virtual void SetFontSize(FX_FLOAT fFontSize); + virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); + virtual void SetDefaultChar(FX_WCHAR wch); + virtual void SetParagraphBreakChar(FX_WCHAR wch); + virtual void SetLineBreakTolerance(FX_FLOAT fTolerance); + virtual void SetHorizontalScale(int32_t iScale); + virtual void SetVerticalScale(int32_t iScale); + virtual void SetCharRotation(int32_t iCharRotation); + virtual void SetCharSpace(FX_FLOAT fCharSpace); + virtual void SetAlignment(int32_t iAlignment); + virtual FX_DWORD GetContextCharStyles() const; + virtual void SetContextCharStyles(FX_DWORD dwCharStyles); + virtual void SetCombWidth(FX_FLOAT fCombWidth); + virtual void SetUserData(void* pUserData); + virtual FX_DWORD AppendChar(FX_WCHAR wch); + virtual FX_DWORD EndBreak(FX_DWORD dwStatus = FX_TXTBREAK_PieceBreak); + virtual int32_t CountBreakChars() const; + virtual int32_t CountBreakPieces() const; + virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const; + virtual void ClearBreakPieces(); + virtual void Reset(); + virtual int32_t GetDisplayPos( + const FX_TXTRUN* pTxtRun, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode = FALSE, + CFX_WideString* pWSForms = NULL, + FX_AdjustCharDisplayPos pAdjustPos = NULL) const; + virtual int32_t GetCharRects(const FX_TXTRUN* pTxtRun, + CFX_RectFArray& rtArray, + FX_BOOL bCharBBox = FALSE) const; + void AppendChar_PageLoad(CFX_Char* pCurChar, FX_DWORD dwProps); + FX_DWORD AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation); + + protected: + FX_DWORD m_dwPolicies; + FX_BOOL m_bPagination; + IFX_ArabicChar* m_pArabicChar; + int32_t m_iLineWidth; + FX_DWORD m_dwLayoutStyles; + FX_BOOL m_bVertical; + FX_BOOL m_bArabicContext; + FX_BOOL m_bArabicShapes; + FX_BOOL m_bRTL; + FX_BOOL m_bSingleLine; + FX_BOOL m_bCombText; + int32_t m_iArabicContext; + int32_t m_iCurArabicContext; + IFX_Font* m_pFont; + int32_t m_iFontSize; + FX_BOOL m_bEquidistant; + int32_t m_iTabWidth; + FX_WCHAR m_wDefChar; + FX_WCHAR m_wParagBreakChar; + int32_t m_iDefChar; + int32_t m_iLineRotation; + int32_t m_iCharRotation; + int32_t m_iRotation; + int32_t m_iAlignment; + FX_DWORD m_dwContextCharStyles; + int32_t m_iCombWidth; + void* m_pUserData; + FX_DWORD m_dwCharType; + FX_BOOL m_bCurRTL; + int32_t m_iCurAlignment; + FX_BOOL m_bArabicNumber; + FX_BOOL m_bArabicComma; + CFX_TxtLine* m_pTxtLine1; + CFX_TxtLine* m_pTxtLine2; + CFX_TxtLine* m_pCurLine; + int32_t m_iReady; + int32_t m_iTolerance; + int32_t m_iHorScale; + int32_t m_iVerScale; + int32_t m_iCharSpace; + void SetBreakStatus(); + int32_t GetLineRotation(FX_DWORD dwStyles) const; + CFX_TxtChar* GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const; + CFX_TxtLine* GetTxtLine(FX_BOOL bReady) const; + CFX_TxtPieceArray* GetTxtPieces(FX_BOOL bReady) const; + FX_DWORD GetUnifiedCharType(FX_DWORD dwType) const; + void ResetArabicContext(); + void ResetContextCharStyles(); + void EndBreak_UpdateArabicShapes(); + FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine, + FX_BOOL bAllChars, + FX_DWORD dwStatus); + void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); + void EndBreak_Alignment(CFX_TPOArray& tpos, + FX_BOOL bAllChars, + FX_DWORD dwStatus); + int32_t GetBreakPos(CFX_TxtCharArray& ca, + int32_t& iEndPos, + FX_BOOL bAllChars = FALSE, + FX_BOOL bOnlyBrk = FALSE); + void SplitTextLine(CFX_TxtLine* pCurLine, + CFX_TxtLine* pNextLine, + FX_BOOL bAllChars = FALSE); +}; + +} // namespace extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32]; IFX_TxtBreak* IFX_TxtBreak::Create(FX_DWORD dwPolicies) { diff --git a/xfa/src/fgas/include/fx_tbk.h b/xfa/src/fgas/layout/fgas_textbreak.h index aa207a568f..65fba720d5 100644 --- a/xfa/src/fgas/include/fx_tbk.h +++ b/xfa/src/fgas/layout/fgas_textbreak.h @@ -4,13 +4,13 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_TBK_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_TBK_H_ +#ifndef XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ +#define XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ #include "core/include/fxcrt/fx_ucd.h" #include "core/include/fxge/fx_ge.h" -#include "xfa/src/fgas/include/fx_ucd.h" -#include "xfa/src/fgas/include/fx_utl.h" +#include "xfa/src/fgas/crt/fgas_utils.h" +#include "xfa/src/fgas/layout/fgas_unicode.h" class IFX_Font; class CFX_Char; @@ -176,6 +176,7 @@ class CFX_TxtPiece : public CFX_Target { void* m_pUserData; }; typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; + class IFX_TxtBreak { public: static IFX_TxtBreak* Create(FX_DWORD dwPolicies); @@ -218,4 +219,4 @@ class IFX_TxtBreak { FX_BOOL bCharBBox = FALSE) const = 0; }; -#endif // XFA_SRC_FGAS_INCLUDE_FX_TBK_H_ +#endif // XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ diff --git a/xfa/src/fgas/src/layout/fx_unicode.cpp b/xfa/src/fgas/layout/fgas_unicode.cpp index 8b9546e051..f463d753b5 100644 --- a/xfa/src/fgas/src/layout/fx_unicode.cpp +++ b/xfa/src/fgas/layout/fgas_unicode.cpp @@ -4,9 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/layout/fx_unicode.h" - -#include "xfa/src/fgas/include/fx_ucd.h" +#include "xfa/src/fgas/layout/fgas_unicode.h" void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd) { FXSYS_assert(iStart > -1 && iStart < tpos.GetSize()); diff --git a/xfa/src/fgas/include/fx_ucd.h b/xfa/src/fgas/layout/fgas_unicode.h index 1d86562473..f25da87e96 100644 --- a/xfa/src/fgas/include/fx_ucd.h +++ b/xfa/src/fgas/layout/fgas_unicode.h @@ -4,10 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_UCD_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_UCD_H_ +#ifndef XFA_SRC_FGAS_LAYOUT_FGAS_UNICODE_H_ +#define XFA_SRC_FGAS_LAYOUT_FGAS_UNICODE_H_ -#include "xfa/src/fgas/include/fx_fnt.h" +#include "xfa/src/fgas/font/fgas_font.h" +#include "xfa/src/fgas/crt/fgas_utils.h" #define FX_JAPCHARPROPERTYEX_Left 0x01 #define FX_JAPCHARPROPERTYEX_Center 0x02 @@ -16,6 +17,14 @@ #define FX_JAPCHARPROPERTYEX_Middle 0x20 #define FX_JAPCHARPROPERTYEX_Bottom 0x30 +struct FX_TPO { + int32_t index; + int32_t pos; +}; +typedef CFX_MassArrayTemplate<FX_TPO> CFX_TPOArray; + +void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd); + struct FX_JAPCHARPROPERTYEX { FX_WCHAR wChar; uint8_t uAlign; @@ -35,4 +44,4 @@ FX_BOOL FX_AdjustJapCharDisplayPos(FX_WCHAR wch, FX_BOOL bVertical, CFX_PointF& ptOffset); -#endif // XFA_SRC_FGAS_INCLUDE_FX_UCD_H_ +#endif // XFA_SRC_FGAS_LAYOUT_FGAS_UNICODE_H_ diff --git a/xfa/src/fgas/src/localization/fx_datetime.cpp b/xfa/src/fgas/localization/fgas_datetime.cpp index 536f19e30e..e803b490d6 100644 --- a/xfa/src/fgas/src/localization/fx_datetime.cpp +++ b/xfa/src/fgas/localization/fgas_datetime.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fgas/include/fx_datetime.h" +#include "xfa/src/fgas/localization/fgas_datetime.h" #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || \ _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ diff --git a/xfa/src/fgas/include/fx_datetime.h b/xfa/src/fgas/localization/fgas_datetime.h index fa1ff6e16a..5dd70ccc65 100644 --- a/xfa/src/fgas/include/fx_datetime.h +++ b/xfa/src/fgas/localization/fgas_datetime.h @@ -4,13 +4,14 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_DATETIME_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_DATETIME_H_ +#ifndef XFA_SRC_FGAS_LOCALIZATION_FGAS_DATETIME_H_ +#define XFA_SRC_FGAS_LOCALIZATION_FGAS_DATETIME_H_ #include "core/include/fxcrt/fx_system.h" class CFX_Unitime; class CFX_DateTime; + typedef int64_t FX_UNITIME; enum FX_WEEKDAY { FX_Sunday = 0, @@ -21,9 +22,11 @@ enum FX_WEEKDAY { 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; } @@ -160,6 +163,7 @@ class CFX_Unitime { private: FX_UNITIME m_iUnitime; }; + #if _FX_OS_ != _FX_ANDROID_ #pragma pack(push, 1) #endif @@ -399,4 +403,4 @@ class CFX_DateTime { FX_DATETIME m_DateTime; }; -#endif // XFA_SRC_FGAS_INCLUDE_FX_DATETIME_H_ +#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_DATETIME_H_ diff --git a/xfa/src/fgas/src/localization/fx_locale.cpp b/xfa/src/fgas/localization/fgas_locale.cpp index a5498945ae..1eaa0ebd48 100644 --- a/xfa/src/fgas/src/localization/fx_locale.cpp +++ b/xfa/src/fgas/localization/fgas_locale.cpp @@ -8,7 +8,7 @@ #include "core/include/fxcrt/fx_ext.h" #include "core/include/fxcrt/fx_xml.h" -#include "xfa/src/fgas/src/localization/fx_localeimp.h" +#include "xfa/src/fgas/localization/fgas_localeimp.h" #define FX_LOCALECATEGORY_DateHash 0xbde9abde #define FX_LOCALECATEGORY_TimeHash 0x2d71b00f diff --git a/xfa/src/fgas/include/fx_locale.h b/xfa/src/fgas/localization/fgas_locale.h index c558af62d0..03dd518715 100644 --- a/xfa/src/fgas/include/fx_locale.h +++ b/xfa/src/fgas/localization/fgas_locale.h @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_LOCALE_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_LOCALE_H_ +#ifndef XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_ +#define XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_ #include "core/include/fxcrt/fx_xml.h" -#include "xfa/src/fgas/include/fx_datetime.h" +#include "xfa/src/fgas/localization/fgas_datetime.h" class CFX_Unitime; @@ -203,4 +203,4 @@ class CFX_Decimal { uint32_t m_uMid; }; -#endif // XFA_SRC_FGAS_INCLUDE_FX_LOCALE_H_ +#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_ diff --git a/xfa/src/fgas/src/localization/fx_localeimp.h b/xfa/src/fgas/localization/fgas_localeimp.h index 2d4783d726..5da8b51208 100644 --- a/xfa/src/fgas/src/localization/fx_localeimp.h +++ b/xfa/src/fgas/localization/fgas_localeimp.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_SRC_LOCALIZATION_FX_LOCALEIMP_H_ -#define XFA_SRC_FGAS_SRC_LOCALIZATION_FX_LOCALEIMP_H_ +#ifndef XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ +#define XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ -#include "xfa/src/fgas/include/fx_locale.h" +#include "xfa/src/fgas/localization/fgas_locale.h" class CFX_LCNumeric; @@ -119,4 +119,4 @@ class CFX_FormatString : public IFX_FormatString { FX_BOOL m_bUseLCID; }; -#endif // XFA_SRC_FGAS_SRC_LOCALIZATION_FX_LOCALEIMP_H_ +#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ diff --git a/xfa/src/fgas/src/localization/fx_localemgr.cpp b/xfa/src/fgas/localization/fgas_localemgr.cpp index 49cc5068e2..81dbfd3885 100644 --- a/xfa/src/fgas/src/localization/fx_localemgr.cpp +++ b/xfa/src/fgas/localization/fgas_localemgr.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/localization/fx_localemgr.h" +#include "xfa/src/fgas/localization/fgas_localemgr.h" #include "core/include/fxcrt/fx_xml.h" diff --git a/xfa/src/fgas/src/localization/fx_localemgr.h b/xfa/src/fgas/localization/fgas_localemgr.h index 3405b9ecab..f2693c7f60 100644 --- a/xfa/src/fgas/src/localization/fx_localemgr.h +++ b/xfa/src/fgas/localization/fgas_localemgr.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_SRC_LOCALIZATION_FX_LOCALEMGR_H_ -#define XFA_SRC_FGAS_SRC_LOCALIZATION_FX_LOCALEMGR_H_ +#ifndef XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ +#define XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ -#include "xfa/src/fgas/include/fx_locale.h" +#include "xfa/src/fgas/localization/fgas_locale.h" class CFX_LocaleMgr : public IFX_LocaleMgr { public: @@ -25,4 +25,4 @@ class CFX_LocaleMgr : public IFX_LocaleMgr { FX_WORD m_wDefLCID; }; -#endif // XFA_SRC_FGAS_SRC_LOCALIZATION_FX_LOCALEMGR_H_ +#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ diff --git a/xfa/src/fgas/src/crt/fx_memory.h b/xfa/src/fgas/src/crt/fx_memory.h deleted file mode 100644 index d933945cb6..0000000000 --- a/xfa/src/fgas/src/crt/fx_memory.h +++ /dev/null @@ -1,140 +0,0 @@ -// 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 XFA_SRC_FGAS_SRC_CRT_FX_MEMORY_H_ -#define XFA_SRC_FGAS_SRC_CRT_FX_MEMORY_H_ - -#include "xfa/src/fgas/include/fx_mem.h" - -class CFX_DefStore; -class CFX_StaticStore; -class CFX_FixedStore; -class CFX_DynamicStore; -class CFX_DefStore : public IFX_MEMAllocator, public CFX_Target { - public: - CFX_DefStore() {} - ~CFX_DefStore() {} - virtual void Release() { delete this; } - virtual void* Alloc(size_t size) { return FX_Alloc(uint8_t, size); } - virtual void Free(void* pBlock) { FX_Free(pBlock); } - virtual size_t GetBlockSize() const { return 0; } - virtual size_t GetDefChunkSize() const { return 0; } - virtual size_t SetDefChunkSize(size_t size) { return 0; } - virtual size_t GetCurrentDataSize() const { return 0; } -}; - -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(push, 1) -#endif -struct FX_STATICSTORECHUNK { - FX_STATICSTORECHUNK* pNextChunk; - size_t iChunkSize; - size_t iFreeSize; -}; -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(pop) -#endif - -class CFX_StaticStore : public IFX_MEMAllocator, public CFX_Target { - public: - CFX_StaticStore(size_t iDefChunkSize = 4096); - ~CFX_StaticStore(); - virtual void Release() { delete this; } - virtual void* Alloc(size_t size); - virtual void Free(void* pBlock) {} - virtual size_t GetBlockSize() const { return 0; } - virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; } - virtual size_t SetDefChunkSize(size_t size); - virtual size_t GetCurrentDataSize() const { return m_iAllocatedSize; } - - protected: - size_t m_iAllocatedSize; - size_t m_iDefChunkSize; - FX_STATICSTORECHUNK* m_pChunk; - FX_STATICSTORECHUNK* m_pLastChunk; - FX_STATICSTORECHUNK* AllocChunk(size_t size); - FX_STATICSTORECHUNK* FindChunk(size_t size); -}; - -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(push, 1) -#endif -struct FX_FIXEDSTORECHUNK { - uint8_t* FirstFlag() { return reinterpret_cast<uint8_t*>(this + 1); } - uint8_t* FirstBlock() { return FirstFlag() + iChunkSize; } - - FX_FIXEDSTORECHUNK* pNextChunk; - size_t iChunkSize; - size_t iFreeNum; -}; -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(pop) -#endif - -class CFX_FixedStore : public IFX_MEMAllocator, public CFX_Target { - public: - CFX_FixedStore(size_t iBlockSize, size_t iBlockNumsInChunk); - virtual ~CFX_FixedStore(); - virtual void Release() { delete this; } - virtual void* Alloc(size_t size); - virtual void Free(void* pBlock); - virtual size_t GetBlockSize() const { return m_iBlockSize; } - virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; } - virtual size_t SetDefChunkSize(size_t iChunkSize); - virtual size_t GetCurrentDataSize() const { return 0; } - - protected: - FX_FIXEDSTORECHUNK* AllocChunk(); - - size_t m_iBlockSize; - size_t m_iDefChunkSize; - FX_FIXEDSTORECHUNK* m_pChunk; -}; - -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(push, 1) -#endif -struct FX_DYNAMICSTOREBLOCK { - uint8_t* Data() { return reinterpret_cast<uint8_t*>(this + 1); } - FX_DYNAMICSTOREBLOCK* NextBlock() { - return reinterpret_cast<FX_DYNAMICSTOREBLOCK*>(Data() + iBlockSize); - } - size_t iBlockSize; - FX_BOOL bUsed; -}; - -struct FX_DYNAMICSTORECHUNK { - FX_DYNAMICSTOREBLOCK* FirstBlock() { - return reinterpret_cast<FX_DYNAMICSTOREBLOCK*>(this + 1); - } - FX_DYNAMICSTORECHUNK* pNextChunk; - size_t iChunkSize; - size_t iFreeSize; -}; -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(pop) -#endif - -class CFX_DynamicStore : public IFX_MEMAllocator, public CFX_Target { - public: - CFX_DynamicStore(size_t iDefChunkSize = 4096); - virtual ~CFX_DynamicStore(); - virtual void Release() { delete this; } - virtual void* Alloc(size_t size); - virtual void Free(void* pBlock); - virtual size_t GetBlockSize() const { return 0; } - virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; } - virtual size_t SetDefChunkSize(size_t size); - virtual size_t GetCurrentDataSize() const { return 0; } - - protected: - FX_DYNAMICSTORECHUNK* AllocChunk(size_t size); - - size_t m_iDefChunkSize; - FX_DYNAMICSTORECHUNK* m_pChunk; -}; - -#endif // XFA_SRC_FGAS_SRC_CRT_FX_MEMORY_H_ diff --git a/xfa/src/fgas/src/crt/fx_stream.h b/xfa/src/fgas/src/crt/fx_stream.h deleted file mode 100644 index 6fd8ff9af8..0000000000 --- a/xfa/src/fgas/src/crt/fx_stream.h +++ /dev/null @@ -1,310 +0,0 @@ -// 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 XFA_SRC_FGAS_SRC_CRT_FX_STREAM_H_ -#define XFA_SRC_FGAS_SRC_CRT_FX_STREAM_H_ - -#include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fgas/include/fx_stm.h" - -class CFX_FileStreamImp; -class CFX_BufferStreamImp; -class CFX_FileReadStreamImp; -class CFX_BufferReadStreamImp; -class CFX_FileWriteStreamImp; -class CFX_Stream; -class CFX_TextStream; -class CFX_FileRead; -class CFX_FileWrite; -class CFX_BufferAccImp; - -class CFX_StreamImp { - public: - virtual void Release() { delete this; } - virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } - 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) = 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; - - protected: - CFX_StreamImp(); - virtual ~CFX_StreamImp() {} - FX_DWORD m_dwAccess; -}; -class CFX_FileStreamImp : public CFX_StreamImp { - public: - CFX_FileStreamImp(); - virtual ~CFX_FileStreamImp(); - FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength); - - protected: - FXSYS_FILE* m_hFile; - int32_t m_iLength; -}; -class CFX_BufferStreamImp : public CFX_StreamImp { - public: - CFX_BufferStreamImp(); - virtual ~CFX_BufferStreamImp() {} - FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush() {} - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - protected: - uint8_t* m_pData; - int32_t m_iTotalSize; - int32_t m_iPosition; - int32_t m_iLength; -}; -class CFX_FileReadStreamImp : public CFX_StreamImp { - public: - CFX_FileReadStreamImp(); - virtual ~CFX_FileReadStreamImp() {} - FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition() { return m_iPosition; } - virtual FX_BOOL IsEOF() const; - - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - return 0; - } - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { - return 0; - } - virtual void Flush() {} - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - protected: - IFX_FileRead* m_pFileRead; - int32_t m_iPosition; - int32_t m_iLength; -}; -class CFX_BufferReadStreamImp : public CFX_StreamImp { - public: - CFX_BufferReadStreamImp(); - ~CFX_BufferReadStreamImp(); - FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, - int32_t iFileSize, - FX_DWORD dwAccess, - FX_BOOL bReleaseBufferRead); - - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition() { return m_iPosition; } - virtual FX_BOOL IsEOF() const; - - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - return 0; - } - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { - return 0; - } - virtual void Flush() {} - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - private: - IFX_BufferRead* m_pBufferRead; - FX_BOOL m_bReleaseBufferRead; - int32_t m_iPosition; - int32_t m_iBufferSize; -}; -class CFX_FileWriteStreamImp : public CFX_StreamImp { - public: - CFX_FileWriteStreamImp(); - virtual ~CFX_FileWriteStreamImp() {} - FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition() { return m_iPosition; } - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) { return 0; } - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS) { - return 0; - } - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - protected: - IFX_FileWrite* m_pFileWrite; - int32_t m_iPosition; -}; -enum FX_STREAMTYPE { - FX_SREAMTYPE_Unknown = 0, - FX_STREAMTYPE_File, - FX_STREAMTYPE_Buffer, - FX_STREAMTYPE_Stream, - FX_STREAMTYPE_BufferRead, -}; -class CFX_Stream : public IFX_Stream { - public: - CFX_Stream(); - ~CFX_Stream(); - FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); - FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); - FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); - FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); - FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, - int32_t iFileSize, - FX_DWORD dwAccess, - FX_BOOL bReleaseBufferRead); - virtual void Release(); - virtual IFX_Stream* Retain(); - virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize = NULL); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength); - virtual int32_t GetBOM(uint8_t bom[4]) const; - virtual FX_WORD GetCodePage() const; - virtual FX_WORD SetCodePage(FX_WORD wCodePage); - virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength); - - protected: - FX_STREAMTYPE m_eStreamType; - CFX_StreamImp* m_pStreamImp; - FX_DWORD m_dwAccess; - int32_t m_iTotalSize; - int32_t m_iPosition; - int32_t m_iStart; - int32_t m_iLength; - int32_t m_iRefCount; -}; -class CFX_TextStream : public IFX_Stream { - public: - CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream); - ~CFX_TextStream(); - virtual void Release(); - virtual IFX_Stream* Retain(); - - virtual FX_DWORD GetAccessModes() const; - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize = NULL); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength); - - virtual int32_t GetBOM(uint8_t bom[4]) const; - virtual FX_WORD GetCodePage() const; - virtual FX_WORD SetCodePage(FX_WORD wCodePage); - - virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength); - - protected: - FX_WORD m_wCodePage; - int32_t m_wBOMLength; - FX_DWORD m_dwBOM; - uint8_t* m_pBuf; - int32_t m_iBufSize; - FX_BOOL m_bDelStream; - IFX_Stream* m_pStreamImp; - int32_t m_iRefCount; - void InitStream(); -}; - -class CFGAS_FileRead : public IFX_FileRead { - public: - CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream); - virtual ~CFGAS_FileRead(); - virtual void Release() { delete this; } - virtual FX_FILESIZE GetSize(); - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); - - protected: - FX_BOOL m_bReleaseStream; - IFX_Stream* m_pStream; -}; - -class CFX_BufferAccImp : public IFX_FileRead { - public: - CFX_BufferAccImp(IFX_BufferRead* pBufferRead, - FX_FILESIZE iFileSize, - FX_BOOL bReleaseStream); - virtual ~CFX_BufferAccImp(); - virtual void Release() { delete this; } - virtual FX_FILESIZE GetSize(); - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); - - protected: - IFX_BufferRead* m_pBufferRead; - FX_BOOL m_bReleaseStream; - FX_FILESIZE m_iBufSize; -}; - -class CFGAS_FileWrite : public IFX_FileWrite { - public: - CFGAS_FileWrite(IFX_Stream* pStream, FX_BOOL bReleaseStream); - virtual ~CFGAS_FileWrite(); - virtual void Release() { delete this; } - virtual FX_FILESIZE GetSize(); - virtual FX_BOOL Flush(); - virtual FX_BOOL WriteBlock(const void* pData, size_t size); - virtual FX_BOOL WriteBlock(const void* pData, - FX_FILESIZE offset, - size_t size); - - protected: - IFX_Stream* m_pStream; - FX_BOOL m_bReleaseStream; -}; - -#endif // XFA_SRC_FGAS_SRC_CRT_FX_STREAM_H_ diff --git a/xfa/src/fgas/src/crt/fx_utils.h b/xfa/src/fgas/src/crt/fx_utils.h deleted file mode 100644 index 3683e5a821..0000000000 --- a/xfa/src/fgas/src/crt/fx_utils.h +++ /dev/null @@ -1,41 +0,0 @@ -// 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 XFA_SRC_FGAS_SRC_CRT_FX_UTILS_H_ -#define XFA_SRC_FGAS_SRC_CRT_FX_UTILS_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fgas/include/fx_mem.h" - -class CFX_BaseMassArrayImp : public CFX_Target { - public: - CFX_BaseMassArrayImp(int32_t iChunkSize, int32_t iBlockSize); - ~CFX_BaseMassArrayImp(); - uint8_t* AddSpace() { return AddSpaceTo(m_iBlockCount); } - uint8_t* AddSpaceTo(int32_t index); - uint8_t* GetAt(int32_t index) const; - int32_t Append(const CFX_BaseMassArrayImp& src, - int32_t iStart = 0, - int32_t iCount = -1); - int32_t Copy(const CFX_BaseMassArrayImp& src, - int32_t iStart = 0, - int32_t iCount = -1); - int32_t RemoveLast(int32_t iCount = -1); - void RemoveAll(FX_BOOL bLeaveMemory = FALSE); - int32_t m_iChunkSize; - int32_t m_iBlockSize; - int32_t m_iChunkCount; - int32_t m_iBlockCount; - CFX_PtrArray* m_pData; - - protected: - void Append(int32_t iDstStart, - const CFX_BaseMassArrayImp& src, - int32_t iSrcStart = 0, - int32_t iSrcCount = -1); -}; - -#endif // XFA_SRC_FGAS_SRC_CRT_FX_UTILS_H_ diff --git a/xfa/src/fgas/src/layout/fx_rtfbreak.h b/xfa/src/fgas/src/layout/fx_rtfbreak.h deleted file mode 100644 index 7aecef7f10..0000000000 --- a/xfa/src/fgas/src/layout/fx_rtfbreak.h +++ /dev/null @@ -1,177 +0,0 @@ -// 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 XFA_SRC_FGAS_SRC_LAYOUT_FX_RTFBREAK_H_ -#define XFA_SRC_FGAS_SRC_LAYOUT_FX_RTFBREAK_H_ - -#include "core/include/fxcrt/fx_arb.h" -#include "xfa/src/fgas/include/fx_rbk.h" -#include "xfa/src/fgas/src/layout/fx_unicode.h" - -class CFX_RTFLine; -class CFX_RTFBreak; -class CFX_RTFLine { - public: - CFX_RTFLine() - : m_LinePieces(16), - m_iStart(0), - m_iWidth(0), - m_iArabicChars(0), - m_iMBCSChars(0) {} - ~CFX_RTFLine() { RemoveAll(); } - int32_t CountChars() const { return m_LineChars.GetSize(); } - CFX_RTFChar& GetChar(int32_t index) { - FXSYS_assert(index > -1 && index < m_LineChars.GetSize()); - return *m_LineChars.GetDataPtr(index); - } - CFX_RTFChar* GetCharPtr(int32_t index) { - FXSYS_assert(index > -1 && index < m_LineChars.GetSize()); - return m_LineChars.GetDataPtr(index); - } - int32_t CountPieces() const { return m_LinePieces.GetSize(); } - CFX_RTFPiece& GetPiece(int32_t index) const { - FXSYS_assert(index > -1 && index < m_LinePieces.GetSize()); - return m_LinePieces.GetAt(index); - } - CFX_RTFPiece* GetPiecePtr(int32_t index) const { - FXSYS_assert(index > -1 && index < m_LinePieces.GetSize()); - return m_LinePieces.GetPtrAt(index); - } - int32_t GetLineEnd() const { return m_iStart + m_iWidth; } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - CFX_RTFChar* pChar; - IFX_Unknown* pUnknown; - int32_t iCount = m_LineChars.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - pChar = m_LineChars.GetDataPtr(i); - if ((pUnknown = pChar->m_pUserData) != NULL) { - pUnknown->Release(); - } - } - m_LineChars.RemoveAll(); - m_LinePieces.RemoveAll(bLeaveMemory); - m_iWidth = 0; - m_iArabicChars = 0; - m_iMBCSChars = 0; - } - CFX_RTFCharArray m_LineChars; - CFX_RTFPieceArray m_LinePieces; - int32_t m_iStart; - int32_t m_iWidth; - int32_t m_iArabicChars; - int32_t m_iMBCSChars; -}; -class CFX_RTFBreak : public IFX_RTFBreak { - public: - CFX_RTFBreak(FX_DWORD dwPolicies); - ~CFX_RTFBreak(); - void Release() override { delete this; } - void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override; - void SetLineStartPos(FX_FLOAT fLinePos) override; - FX_DWORD GetLayoutStyles() const override { return m_dwLayoutStyles; } - void SetLayoutStyles(FX_DWORD dwLayoutStyles) override; - void SetFont(IFX_Font* pFont) override; - void SetFontSize(FX_FLOAT fFontSize) override; - void SetTabWidth(FX_FLOAT fTabWidth) override; - void AddPositionedTab(FX_FLOAT fTabPos) override; - void SetPositionedTabs(const CFX_FloatArray& tabs) override; - void ClearPositionedTabs() override; - void SetDefaultChar(FX_WCHAR wch) override; - void SetLineBreakChar(FX_WCHAR wch) override; - void SetLineBreakTolerance(FX_FLOAT fTolerance) override; - void SetHorizontalScale(int32_t iScale) override; - void SetVerticalScale(int32_t iScale) override; - void SetCharRotation(int32_t iCharRotation) override; - void SetCharSpace(FX_FLOAT fCharSpace) override; - void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) override; - void SetReadingOrder(FX_BOOL bRTL = FALSE) override; - void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) override; - void SetUserData(IFX_Unknown* pUserData) override; - FX_DWORD AppendChar(FX_WCHAR wch) override; - FX_DWORD EndBreak(FX_DWORD dwStatus = FX_RTFBREAK_PieceBreak) override; - int32_t CountBreakPieces() const override; - const CFX_RTFPiece* GetBreakPiece(int32_t index) const override; - void GetLineRect(CFX_RectF& rect) const override; - void ClearBreakPieces() override; - void Reset() override; - int32_t GetDisplayPos( - const FX_RTFTEXTOBJ* pText, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode = FALSE, - CFX_WideString* pWSForms = NULL, - FX_AdjustCharDisplayPos pAdjustPos = NULL) const override; - int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, - CFX_RectFArray& rtArray, - FX_BOOL bCharBBox = FALSE) const override; - FX_DWORD AppendChar_CharCode(FX_WCHAR wch); - FX_DWORD AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); - - protected: - FX_DWORD m_dwPolicies; - IFX_ArabicChar* m_pArabicChar; - int32_t m_iBoundaryStart; - int32_t m_iBoundaryEnd; - FX_DWORD m_dwLayoutStyles; - FX_BOOL m_bPagination; - FX_BOOL m_bVertical; - FX_BOOL m_bSingleLine; - FX_BOOL m_bCharCode; - IFX_Font* m_pFont; - int32_t m_iFontHeight; - int32_t m_iFontSize; - int32_t m_iTabWidth; - CFX_Int32Array m_PositionedTabs; - FX_BOOL m_bOrphanLine; - FX_WCHAR m_wDefChar; - int32_t m_iDefChar; - FX_WCHAR m_wLineBreakChar; - int32_t m_iHorizontalScale; - int32_t m_iVerticalScale; - int32_t m_iLineRotation; - int32_t m_iCharRotation; - int32_t m_iRotation; - int32_t m_iCharSpace; - FX_BOOL m_bWordSpace; - int32_t m_iWordSpace; - FX_BOOL m_bRTL; - int32_t m_iAlignment; - IFX_Unknown* m_pUserData; - FX_DWORD m_dwCharType; - FX_DWORD m_dwIdentity; - CFX_RTFLine m_RTFLine1; - CFX_RTFLine m_RTFLine2; - CFX_RTFLine* m_pCurLine; - int32_t m_iReady; - int32_t m_iTolerance; - int32_t GetLineRotation(FX_DWORD dwStyles) const; - void SetBreakStatus(); - CFX_RTFChar* GetLastChar(int32_t index) const; - CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const; - CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const; - FX_DWORD GetUnifiedCharType(FX_DWORD dwType) const; - int32_t GetLastPositionedTab() const; - FX_BOOL GetPositionedTab(int32_t& iTabPos) const; - int32_t GetBreakPos(CFX_RTFCharArray& tca, - int32_t& iEndPos, - FX_BOOL bAllChars = FALSE, - FX_BOOL bOnlyBrk = FALSE); - void SplitTextLine(CFX_RTFLine* pCurLine, - CFX_RTFLine* pNextLine, - FX_BOOL bAllChars = FALSE); - FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine, - FX_BOOL bAllChars, - FX_DWORD dwStatus); - void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); - void EndBreak_Alignment(CFX_TPOArray& tpos, - FX_BOOL bAllChars, - FX_DWORD dwStatus); -}; - -#endif // XFA_SRC_FGAS_SRC_LAYOUT_FX_RTFBREAK_H_ diff --git a/xfa/src/fgas/src/layout/fx_textbreak.h b/xfa/src/fgas/src/layout/fx_textbreak.h deleted file mode 100644 index fa15afd76a..0000000000 --- a/xfa/src/fgas/src/layout/fx_textbreak.h +++ /dev/null @@ -1,174 +0,0 @@ -// 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 XFA_SRC_FGAS_SRC_LAYOUT_FX_TEXTBREAK_H_ -#define XFA_SRC_FGAS_SRC_LAYOUT_FX_TEXTBREAK_H_ - -#include "core/include/fxcrt/fx_ucd.h" -#include "core/include/fxcrt/fx_memory.h" -#include "xfa/src/fgas/include/fx_tbk.h" -#include "xfa/src/fgas/src/layout/fx_unicode.h" - -class IFX_ArabicChar; - -class CFX_TxtLine { - public: - CFX_TxtLine(int32_t iBlockSize) - : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { - m_pLineChars = new CFX_TxtCharArray; - m_pLinePieces = new CFX_TxtPieceArray(16); - } - ~CFX_TxtLine() { - RemoveAll(); - delete m_pLineChars; - delete m_pLinePieces; - } - int32_t CountChars() const { return m_pLineChars->GetSize(); } - CFX_TxtChar* GetCharPtr(int32_t index) const { - FXSYS_assert(index > -1 && index < m_pLineChars->GetSize()); - return m_pLineChars->GetDataPtr(index); - } - int32_t CountPieces() const { return m_pLinePieces->GetSize(); } - CFX_TxtPiece* GetPiecePtr(int32_t index) const { - FXSYS_assert(index > -1 && index < m_pLinePieces->GetSize()); - return m_pLinePieces->GetPtrAt(index); - } - void GetString(CFX_WideString& wsStr) const { - int32_t iCount = m_pLineChars->GetSize(); - FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); - CFX_Char* pChar; - for (int32_t i = 0; i < iCount; i++) { - pChar = m_pLineChars->GetDataPtr(i); - *pBuf++ = (FX_WCHAR)pChar->m_wCharCode; - } - wsStr.ReleaseBuffer(iCount); - } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - m_pLineChars->RemoveAll(); - m_pLinePieces->RemoveAll(bLeaveMemory); - m_iWidth = 0; - m_iArabicChars = 0; - } - CFX_TxtCharArray* m_pLineChars; - CFX_TxtPieceArray* m_pLinePieces; - int32_t m_iStart; - int32_t m_iWidth; - int32_t m_iArabicChars; -}; -class CFX_TxtBreak : public IFX_TxtBreak { - public: - CFX_TxtBreak(FX_DWORD dwPolicies); - ~CFX_TxtBreak(); - virtual void Release() { delete this; } - virtual void SetLineWidth(FX_FLOAT fLineWidth); - virtual void SetLinePos(FX_FLOAT fLinePos); - virtual FX_DWORD GetLayoutStyles() const { return m_dwLayoutStyles; } - virtual void SetLayoutStyles(FX_DWORD dwLayoutStyles); - virtual void SetFont(IFX_Font* pFont); - virtual void SetFontSize(FX_FLOAT fFontSize); - virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); - virtual void SetDefaultChar(FX_WCHAR wch); - virtual void SetParagraphBreakChar(FX_WCHAR wch); - virtual void SetLineBreakTolerance(FX_FLOAT fTolerance); - virtual void SetHorizontalScale(int32_t iScale); - virtual void SetVerticalScale(int32_t iScale); - virtual void SetCharRotation(int32_t iCharRotation); - virtual void SetCharSpace(FX_FLOAT fCharSpace); - virtual void SetAlignment(int32_t iAlignment); - virtual FX_DWORD GetContextCharStyles() const; - virtual void SetContextCharStyles(FX_DWORD dwCharStyles); - virtual void SetCombWidth(FX_FLOAT fCombWidth); - virtual void SetUserData(void* pUserData); - virtual FX_DWORD AppendChar(FX_WCHAR wch); - virtual FX_DWORD EndBreak(FX_DWORD dwStatus = FX_TXTBREAK_PieceBreak); - virtual int32_t CountBreakChars() const; - virtual int32_t CountBreakPieces() const; - virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const; - virtual void ClearBreakPieces(); - virtual void Reset(); - virtual int32_t GetDisplayPos( - const FX_TXTRUN* pTxtRun, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode = FALSE, - CFX_WideString* pWSForms = NULL, - FX_AdjustCharDisplayPos pAdjustPos = NULL) const; - virtual int32_t GetCharRects(const FX_TXTRUN* pTxtRun, - CFX_RectFArray& rtArray, - FX_BOOL bCharBBox = FALSE) const; - void AppendChar_PageLoad(CFX_Char* pCurChar, FX_DWORD dwProps); - FX_DWORD AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation); - - protected: - FX_DWORD m_dwPolicies; - FX_BOOL m_bPagination; - IFX_ArabicChar* m_pArabicChar; - int32_t m_iLineWidth; - FX_DWORD m_dwLayoutStyles; - FX_BOOL m_bVertical; - FX_BOOL m_bArabicContext; - FX_BOOL m_bArabicShapes; - FX_BOOL m_bRTL; - FX_BOOL m_bSingleLine; - FX_BOOL m_bCombText; - int32_t m_iArabicContext; - int32_t m_iCurArabicContext; - IFX_Font* m_pFont; - int32_t m_iFontSize; - FX_BOOL m_bEquidistant; - int32_t m_iTabWidth; - FX_WCHAR m_wDefChar; - FX_WCHAR m_wParagBreakChar; - int32_t m_iDefChar; - int32_t m_iLineRotation; - int32_t m_iCharRotation; - int32_t m_iRotation; - int32_t m_iAlignment; - FX_DWORD m_dwContextCharStyles; - int32_t m_iCombWidth; - void* m_pUserData; - FX_DWORD m_dwCharType; - FX_BOOL m_bCurRTL; - int32_t m_iCurAlignment; - FX_BOOL m_bArabicNumber; - FX_BOOL m_bArabicComma; - CFX_TxtLine* m_pTxtLine1; - CFX_TxtLine* m_pTxtLine2; - CFX_TxtLine* m_pCurLine; - int32_t m_iReady; - int32_t m_iTolerance; - int32_t m_iHorScale; - int32_t m_iVerScale; - int32_t m_iCharSpace; - void SetBreakStatus(); - int32_t GetLineRotation(FX_DWORD dwStyles) const; - CFX_TxtChar* GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const; - CFX_TxtLine* GetTxtLine(FX_BOOL bReady) const; - CFX_TxtPieceArray* GetTxtPieces(FX_BOOL bReady) const; - FX_DWORD GetUnifiedCharType(FX_DWORD dwType) const; - void ResetArabicContext(); - void ResetContextCharStyles(); - void EndBreak_UpdateArabicShapes(); - FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine, - FX_BOOL bAllChars, - FX_DWORD dwStatus); - void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); - void EndBreak_Alignment(CFX_TPOArray& tpos, - FX_BOOL bAllChars, - FX_DWORD dwStatus); - int32_t GetBreakPos(CFX_TxtCharArray& ca, - int32_t& iEndPos, - FX_BOOL bAllChars = FALSE, - FX_BOOL bOnlyBrk = FALSE); - void SplitTextLine(CFX_TxtLine* pCurLine, - CFX_TxtLine* pNextLine, - FX_BOOL bAllChars = FALSE); -}; - -#endif // XFA_SRC_FGAS_SRC_LAYOUT_FX_TEXTBREAK_H_ diff --git a/xfa/src/fgas/src/layout/fx_unicode.h b/xfa/src/fgas/src/layout/fx_unicode.h deleted file mode 100644 index 0b119dec1c..0000000000 --- a/xfa/src/fgas/src/layout/fx_unicode.h +++ /dev/null @@ -1,20 +0,0 @@ -// 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 XFA_SRC_FGAS_SRC_LAYOUT_FX_UNICODE_H_ -#define XFA_SRC_FGAS_SRC_LAYOUT_FX_UNICODE_H_ - -#include "xfa/src/fgas/include/fx_utl.h" - -struct FX_TPO { - int32_t index; - int32_t pos; -}; -typedef CFX_MassArrayTemplate<FX_TPO> CFX_TPOArray; - -void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd); - -#endif // XFA_SRC_FGAS_SRC_LAYOUT_FX_UNICODE_H_ diff --git a/xfa/src/fgas/include/fx_sax.h b/xfa/src/fgas/xml/fgas_sax.h index e4b72f6328..50762d4401 100644 --- a/xfa/src/fgas/include/fx_sax.h +++ b/xfa/src/fgas/xml/fgas_sax.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_INCLUDE_FX_SAX_H_ -#define XFA_SRC_FGAS_INCLUDE_FX_SAX_H_ +#ifndef XFA_SRC_FGAS_XML_FGAS_SAX_H_ +#define XFA_SRC_FGAS_XML_FGAS_SAX_H_ #include "core/include/fxcrt/fx_basic.h" @@ -65,4 +65,4 @@ class IFX_SAXReader { }; IFX_SAXReader* FX_SAXReader_Create(); -#endif // XFA_SRC_FGAS_INCLUDE_FX_SAX_H_ +#endif // XFA_SRC_FGAS_XML_FGAS_SAX_H_ diff --git a/xfa/src/fgas/src/xml/fx_sax_imp.cpp b/xfa/src/fgas/xml/fgas_sax_imp.cpp index 251af01a06..f30a357497 100644 --- a/xfa/src/fgas/src/xml/fx_sax_imp.cpp +++ b/xfa/src/fgas/xml/fgas_sax_imp.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/src/fgas/src/xml/fx_sax_imp.h" +#include "xfa/src/fgas/xml/fgas_sax_imp.h" #include <algorithm> diff --git a/xfa/src/fgas/src/xml/fx_sax_imp.h b/xfa/src/fgas/xml/fgas_sax_imp.h index 13e5036ec3..a65f2abaa9 100644 --- a/xfa/src/fgas/src/xml/fx_sax_imp.h +++ b/xfa/src/fgas/xml/fgas_sax_imp.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_SRC_FGAS_SRC_XML_FX_SAX_IMP_H_ -#define XFA_SRC_FGAS_SRC_XML_FX_SAX_IMP_H_ +#ifndef XFA_SRC_FGAS_XML_FGAS_SAX_IMP_H_ +#define XFA_SRC_FGAS_XML_FGAS_SAX_IMP_H_ -#include "xfa/src/fgas/include/fx_sax.h" +#include "xfa/src/fgas/xml/fgas_sax.h" class CFX_SAXFile { public: @@ -138,4 +138,4 @@ class CFX_SAXReader : public IFX_SAXReader { void ParseChar(uint8_t ch); }; -#endif // XFA_SRC_FGAS_SRC_XML_FX_SAX_IMP_H_ +#endif // XFA_SRC_FGAS_XML_FGAS_SAX_IMP_H_ |