summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/cfx_char.cpp50
-rw-r--r--core/fxcrt/cfx_char.h43
-rw-r--r--core/fxcrt/fx_arabic.cpp39
-rw-r--r--core/fxcrt/fx_arabic.h7
-rw-r--r--core/fxcrt/fx_ucd.h76
5 files changed, 111 insertions, 104 deletions
diff --git a/core/fxcrt/cfx_char.cpp b/core/fxcrt/cfx_char.cpp
new file mode 100644
index 0000000000..ab7abd9884
--- /dev/null
+++ b/core/fxcrt/cfx_char.cpp
@@ -0,0 +1,50 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxcrt/cfx_char.h"
+
+CFX_Char::CFX_Char()
+ : m_dwStatus(CFX_BreakType::None),
+ m_nBreakType(0),
+ m_dwCharStyles(0),
+ m_dwCharProps(0),
+ m_iCharWidth(0),
+ m_iHorizontalScale(100),
+ m_iVerticalScale(100),
+ m_iBidiClass(0),
+ m_iBidiLevel(0),
+ m_iBidiPos(0),
+ m_iBidiOrder(0),
+ m_wCharCode(0),
+ m_iFontSize(0),
+ m_iFontHeight(0),
+ m_dwIdentity(0),
+ m_pUserData(nullptr) {}
+
+CFX_Char::CFX_Char(uint16_t wCharCode, uint32_t dwCharProps)
+ : m_nBreakType(0),
+ m_dwCharStyles(0),
+ m_dwCharProps(dwCharProps),
+ m_iCharWidth(0),
+ m_iHorizontalScale(100),
+ m_iVerticalScale(100),
+ m_iBidiClass(0),
+ m_iBidiLevel(0),
+ m_iBidiPos(0),
+ m_iBidiOrder(0),
+ m_wCharCode(wCharCode),
+ m_iFontSize(0),
+ m_iFontHeight(0),
+ m_dwIdentity(0),
+ m_pUserData(nullptr) {}
+
+CFX_Char::CFX_Char(const CFX_Char& other) = default;
+
+CFX_Char::~CFX_Char() = default;
+
+FX_CHARTYPE CFX_Char::GetCharType() const {
+ return GetCharTypeFromProp(m_dwCharProps);
+}
diff --git a/core/fxcrt/cfx_char.h b/core/fxcrt/cfx_char.h
new file mode 100644
index 0000000000..bc91c91386
--- /dev/null
+++ b/core/fxcrt/cfx_char.h
@@ -0,0 +1,43 @@
+// Copyright 2017 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 CORE_FXCRT_CFX_CHAR_H_
+#define CORE_FXCRT_CFX_CHAR_H_
+
+#include <stdint.h>
+
+#include "core/fxcrt/fx_ucd.h"
+
+enum class CFX_BreakType { None = 0, Piece, Line, Paragraph, Page };
+
+class CFX_Char {
+ public:
+ CFX_Char();
+ CFX_Char(uint16_t wCharCode, uint32_t dwCharProps);
+ CFX_Char(const CFX_Char& other);
+ ~CFX_Char();
+
+ FX_CHARTYPE GetCharType() const;
+
+ CFX_BreakType m_dwStatus;
+ uint8_t m_nBreakType;
+ uint32_t m_dwCharStyles;
+ uint32_t m_dwCharProps;
+ int32_t m_iCharWidth;
+ int32_t m_iHorizontalScale;
+ int32_t m_iVerticalScale;
+ int16_t m_iBidiClass;
+ int16_t m_iBidiLevel;
+ int16_t m_iBidiPos;
+ int16_t m_iBidiOrder;
+ uint16_t m_wCharCode;
+ int32_t m_iFontSize;
+ int32_t m_iFontHeight;
+ uint32_t m_dwIdentity;
+ CFX_RetainPtr<CFX_Retainable> m_pUserData;
+};
+
+#endif // CORE_FXCRT_CFX_CHAR_H_
diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp
index 29e6e437e8..11743e41ad 100644
--- a/core/fxcrt/fx_arabic.cpp
+++ b/core/fxcrt/fx_arabic.cpp
@@ -410,10 +410,9 @@ void FX_BidiReorder(int32_t iBaseLevel,
}
}
-template <class baseType>
class CFX_BidiLineTemplate {
public:
- void FX_BidiReverseString(std::vector<baseType>& chars,
+ void FX_BidiReverseString(std::vector<CFX_Char>& chars,
int32_t iStart,
int32_t iCount) {
ASSERT(iStart >= 0 && iStart < pdfium::CollectionSize<int32_t>(chars));
@@ -422,7 +421,7 @@ class CFX_BidiLineTemplate {
std::reverse(chars.begin() + iStart, chars.begin() + iStart + iCount);
}
- void FX_BidiSetDeferredRun(std::vector<baseType>& chars,
+ void FX_BidiSetDeferredRun(std::vector<CFX_Char>& chars,
bool bClass,
int32_t iStart,
int32_t iCount,
@@ -439,7 +438,7 @@ class CFX_BidiLineTemplate {
}
}
- void FX_BidiClassify(std::vector<baseType>& chars, int32_t iCount, bool bWS) {
+ void FX_BidiClassify(std::vector<CFX_Char>& chars, int32_t iCount, bool bWS) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
if (bWS) {
for (int32_t i = 0; i < iCount; i++) {
@@ -456,7 +455,7 @@ class CFX_BidiLineTemplate {
}
}
- void FX_BidiResolveExplicit(std::vector<baseType>& chars,
+ void FX_BidiResolveExplicit(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
@@ -465,7 +464,7 @@ class CFX_BidiLineTemplate {
chars[i].m_iBidiLevel = static_cast<int16_t>(iBaseLevel);
}
- void FX_BidiResolveWeak(std::vector<baseType>& chars,
+ void FX_BidiResolveWeak(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
@@ -473,7 +472,7 @@ class CFX_BidiLineTemplate {
if (iCount < 1) {
return;
}
- baseType *pTC, *pTCNext;
+ CFX_Char *pTC, *pTCNext;
int32_t iLevelCur = iBaseLevel;
int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BWSxr : FX_BWSxl;
int32_t i = 0, iNum = 0, iClsCur, iClsRun, iClsNew, iAction;
@@ -537,7 +536,7 @@ class CFX_BidiLineTemplate {
}
}
- void FX_BidiResolveNeutrals(std::vector<baseType>& chars,
+ void FX_BidiResolveNeutrals(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
@@ -546,7 +545,7 @@ class CFX_BidiLineTemplate {
if (iCount < 1) {
return;
}
- baseType* pTC;
+ CFX_Char* pTC;
int32_t iLevel = iBaseLevel;
int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BNSr : FX_BNSl;
int32_t i = 0, iNum = 0, iClsCur, iClsRun, iClsNew, iAction;
@@ -586,7 +585,7 @@ class CFX_BidiLineTemplate {
}
}
- void FX_BidiResolveImplicit(std::vector<baseType>& chars, int32_t iCount) {
+ void FX_BidiResolveImplicit(std::vector<CFX_Char>& chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
for (int32_t i = 0; i < iCount; i++) {
int32_t iCls = chars[i].m_iBidiClass;
@@ -600,7 +599,7 @@ class CFX_BidiLineTemplate {
}
}
- void FX_BidiResolveWhitespace(std::vector<baseType>& chars,
+ void FX_BidiResolveWhitespace(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
@@ -644,7 +643,7 @@ class CFX_BidiLineTemplate {
}
}
- int32_t FX_BidiReorderLevel(std::vector<baseType>& chars,
+ int32_t FX_BidiReorderLevel(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel,
int32_t iStart,
@@ -672,7 +671,7 @@ class CFX_BidiLineTemplate {
return iNum;
}
- void FX_BidiReorder(std::vector<baseType>& chars,
+ void FX_BidiReorder(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
@@ -683,13 +682,13 @@ class CFX_BidiLineTemplate {
}
}
- void FX_BidiPosition(std::vector<baseType>& chars, int32_t iCount) {
+ void FX_BidiPosition(std::vector<CFX_Char>& chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
for (int32_t i = 0; i < iCount; ++i)
chars[chars[i].m_iBidiPos].m_iBidiOrder = i;
}
- void FX_BidiLine(std::vector<baseType>& chars,
+ void FX_BidiLine(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars));
@@ -708,15 +707,9 @@ class CFX_BidiLineTemplate {
}
};
-void FX_BidiLine(std::vector<CFX_TxtChar>& chars,
+void FX_BidiLine(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel) {
- CFX_BidiLineTemplate<CFX_TxtChar> blt;
- blt.FX_BidiLine(chars, iCount, iBaseLevel);
-}
-void FX_BidiLine(std::vector<CFX_RTFChar>& chars,
- int32_t iCount,
- int32_t iBaseLevel) {
- CFX_BidiLineTemplate<CFX_RTFChar> blt;
+ CFX_BidiLineTemplate blt;
blt.FX_BidiLine(chars, iCount, iBaseLevel);
}
diff --git a/core/fxcrt/fx_arabic.h b/core/fxcrt/fx_arabic.h
index 9f6ec50ef6..1856f106c2 100644
--- a/core/fxcrt/fx_arabic.h
+++ b/core/fxcrt/fx_arabic.h
@@ -9,8 +9,8 @@
#include <vector>
+#include "core/fxcrt/cfx_char.h"
#include "core/fxcrt/fx_system.h"
-#include "core/fxcrt/fx_ucd.h"
#define FX_BIDIMAXLEVEL 61
#define FX_BidiDirection(a) (FX_IsOdd(a) ? FX_BIDICLASS_R : FX_BIDICLASS_L)
@@ -164,10 +164,7 @@ const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode);
FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef);
FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda);
-void FX_BidiLine(std::vector<CFX_TxtChar>& chars,
- int32_t iCount,
- int32_t iBaseLevel = 0);
-void FX_BidiLine(std::vector<CFX_RTFChar>& chars,
+void FX_BidiLine(std::vector<CFX_Char>& chars,
int32_t iCount,
int32_t iBaseLevel = 0);
diff --git a/core/fxcrt/fx_ucd.h b/core/fxcrt/fx_ucd.h
index f8a92a18f2..488c275808 100644
--- a/core/fxcrt/fx_ucd.h
+++ b/core/fxcrt/fx_ucd.h
@@ -119,82 +119,6 @@ FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch,
bool bRTL,
bool bVertical);
-enum class CFX_BreakType { None = 0, Piece, Line, Paragraph, Page };
-
-class CFX_Char {
- public:
- CFX_Char()
- : m_dwStatus(CFX_BreakType::None),
- m_wCharCode(0),
- m_nBreakType(0),
- m_dwCharProps(0),
- m_iCharWidth(0),
- m_iHorizontalScale(100),
- m_iVerticalScale(100) {}
-
- CFX_Char(uint16_t wCharCode, uint32_t dwCharProps)
- : m_wCharCode(wCharCode),
- m_nBreakType(0),
- m_dwCharProps(dwCharProps),
- m_iCharWidth(0),
- m_iHorizontalScale(100),
- m_iVerticalScale(100) {}
-
- FX_CHARTYPE GetCharType() const { return GetCharTypeFromProp(m_dwCharProps); }
-
- CFX_BreakType m_dwStatus;
- uint16_t m_wCharCode;
- uint8_t m_nBreakType;
- uint32_t m_dwCharProps;
- int32_t m_iCharWidth;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
-};
-
-class CFX_TxtChar : public CFX_Char {
- public:
- CFX_TxtChar()
- : m_dwCharStyles(0),
- m_iBidiClass(0),
- m_iBidiLevel(0),
- m_iBidiPos(0),
- m_iBidiOrder(0) {}
-
- uint32_t m_dwCharStyles;
- int16_t m_iBidiClass;
- int16_t m_iBidiLevel;
- int16_t m_iBidiPos;
- int16_t m_iBidiOrder;
-};
-
-class CFX_RTFChar : public CFX_Char {
- public:
- CFX_RTFChar();
- CFX_RTFChar(const CFX_RTFChar& other);
- ~CFX_RTFChar();
-
- int32_t m_iFontSize;
- int32_t m_iFontHeight;
- int16_t m_iBidiClass;
- int16_t m_iBidiLevel;
- int16_t m_iBidiPos;
- int16_t m_iBidiOrder;
- uint32_t m_dwIdentity;
- CFX_RetainPtr<CFX_Retainable> m_pUserData;
-};
-
-inline CFX_RTFChar::CFX_RTFChar()
- : m_iFontSize(0),
- m_iFontHeight(0),
- m_iBidiClass(0),
- m_iBidiLevel(0),
- m_iBidiPos(0),
- m_dwIdentity(0),
- m_pUserData(nullptr) {}
-
-inline CFX_RTFChar::CFX_RTFChar(const CFX_RTFChar& other) = default;
-inline CFX_RTFChar::~CFX_RTFChar() = default;
-
#endif // PDF_ENABLE_XFA
#endif // CORE_FXCRT_FX_UCD_H_