summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-06 13:15:46 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-06 13:15:46 -0700
commite00f75c2318d55dfa261f1915decd2545c44ccfb (patch)
treec4189761ba9dc3be9c3e4b11172a0f3bd8ecdad7
parentd29882d3a0567e297756f69b77562ed4892f012a (diff)
downloadpdfium-chromium/2730.tar.xz
CFX_ArabicChar contains only static methods, no need to instantiate.chromium/2733chromium/2732chromium/2731chromium/2730
Review-Url: https://codereview.chromium.org/1954593004
-rw-r--r--core/fxcrt/fx_arabic.cpp74
-rw-r--r--core/fxcrt/include/fx_arabic.h27
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp13
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h2
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp9
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h2
6 files changed, 58 insertions, 69 deletions
diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp
index 191350e24d..01a1a2a15e 100644
--- a/core/fxcrt/fx_arabic.cpp
+++ b/core/fxcrt/fx_arabic.cpp
@@ -114,6 +114,23 @@ const FX_ARASHADDA gs_FX_ShaddaTable[] = {
{0x064F, 0xFC61}, {0x0650, 0xFC62},
};
+const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
+ FX_WCHAR& wChar,
+ FX_CHARTYPE& eType) {
+ if (!pTC) {
+ eType = FX_CHARTYPE_Unknown;
+ wChar = 0xFEFF;
+ return nullptr;
+ }
+ eType = (FX_CHARTYPE)pTC->GetCharType();
+ wChar = (FX_WCHAR)pTC->m_wCharCode;
+ const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
+ if (!pFT || eType >= FX_CHARTYPE_ArabicNormal)
+ eType = FX_CHARTYPE_Unknown;
+
+ return pFT;
+}
+
} // namespace
const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode) {
@@ -145,26 +162,30 @@ FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda) {
return shadda;
}
-FX_BOOL CFX_ArabicChar::IsArabicChar(FX_WCHAR wch) const {
+namespace pdfium {
+namespace arabic {
+
+bool IsArabicChar(FX_WCHAR wch) {
uint32_t dwRet =
kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK;
return dwRet >= FX_CHARTYPE_ArabicAlef;
}
-FX_BOOL CFX_ArabicChar::IsArabicFormChar(FX_WCHAR wch) const {
+
+bool IsArabicFormChar(FX_WCHAR wch) {
return (kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK) ==
FX_CHARTYPE_ArabicForm;
}
-FX_WCHAR CFX_ArabicChar::GetFormChar(FX_WCHAR wch,
- FX_WCHAR prev,
- FX_WCHAR next) const {
+
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev, FX_WCHAR next) {
CFX_Char c(wch, kTextLayoutCodeProperties[(uint16_t)wch]);
CFX_Char p(prev, kTextLayoutCodeProperties[(uint16_t)prev]);
CFX_Char n(next, kTextLayoutCodeProperties[(uint16_t)next]);
return GetFormChar(&c, &p, &n);
}
-FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur,
- const CFX_Char* prev,
- const CFX_Char* next) const {
+
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+ const CFX_Char* prev,
+ const CFX_Char* next) {
FX_CHARTYPE eCur;
FX_WCHAR wCur;
const FX_ARBFORMTABLE* ft = ParseChar(cur, wCur, eCur);
@@ -184,37 +205,22 @@ FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur,
if (ePrev < FX_CHARTYPE_ArabicAlef) {
if (bAlef) {
return FX_GetArabicFromAlefTable(wNext);
- } else {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
- }
- } else {
- if (bAlef) {
- wCur = FX_GetArabicFromAlefTable(wNext);
- return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
- } else if (ePrev == FX_CHARTYPE_ArabicAlef ||
- ePrev == FX_CHARTYPE_ArabicSpecial) {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
- } else {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
}
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
}
-}
-const FX_ARBFORMTABLE* CFX_ArabicChar::ParseChar(const CFX_Char* pTC,
- FX_WCHAR& wChar,
- FX_CHARTYPE& eType) const {
- if (pTC == NULL) {
- eType = FX_CHARTYPE_Unknown;
- wChar = 0xFEFF;
- return NULL;
+ if (bAlef) {
+ wCur = FX_GetArabicFromAlefTable(wNext);
+ return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
}
- eType = (FX_CHARTYPE)pTC->GetCharType();
- wChar = (FX_WCHAR)pTC->m_wCharCode;
- const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
- if (pFT == NULL || eType >= FX_CHARTYPE_ArabicNormal) {
- eType = FX_CHARTYPE_Unknown;
+ if (ePrev == FX_CHARTYPE_ArabicAlef || ePrev == FX_CHARTYPE_ArabicSpecial) {
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
}
- return pFT;
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
}
+
+} // namespace arabic
+} // namespace pdfium
+
void FX_BidiReverseString(CFX_WideString& wsText,
int32_t iStart,
int32_t iCount) {
diff --git a/core/fxcrt/include/fx_arabic.h b/core/fxcrt/include/fx_arabic.h
index 96fa7954c3..2617d1897f 100644
--- a/core/fxcrt/include/fx_arabic.h
+++ b/core/fxcrt/include/fx_arabic.h
@@ -14,25 +14,18 @@
#define FX_BidiGetDeferredType(a) (((a) >> 4) & 0x0F)
#define FX_BidiGetResolvedType(a) ((a)&0x0F)
-class CFX_ArabicChar {
- public:
- void Release() { delete this; }
+namespace pdfium {
+namespace arabic {
- FX_BOOL IsArabicChar(FX_WCHAR wch) const;
- FX_BOOL IsArabicFormChar(FX_WCHAR wch) const;
+bool IsArabicChar(FX_WCHAR wch);
+bool IsArabicFormChar(FX_WCHAR wch);
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev = 0, FX_WCHAR next = 0);
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+ const CFX_Char* prev,
+ const CFX_Char* next);
- FX_WCHAR GetFormChar(FX_WCHAR wch,
- FX_WCHAR prev = 0,
- FX_WCHAR next = 0) const;
- FX_WCHAR GetFormChar(const CFX_Char* cur,
- const CFX_Char* prev,
- const CFX_Char* next) const;
-
- protected:
- const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
- FX_WCHAR& wChar,
- FX_CHARTYPE& eType) const;
-};
+} // namespace arabic
+} // namespace pdfium
void FX_BidiReverseString(CFX_WideString& wsText,
int32_t iStart,
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index b44af96c77..aaef7aec61 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -15,7 +15,6 @@
CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
: m_dwPolicies(dwPolicies),
- m_pArabicChar(NULL),
m_iBoundaryStart(0),
m_iBoundaryEnd(2000000),
m_dwLayoutStyles(0),
@@ -50,13 +49,11 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
m_pCurLine(NULL),
m_iReady(0),
m_iTolerance(0) {
- m_pArabicChar = new CFX_ArabicChar;
m_pCurLine = &m_RTFLine1;
}
CFX_RTFBreak::~CFX_RTFBreak() {
Reset();
m_PositionedTabs.RemoveAll();
- m_pArabicChar->Release();
if (m_pUserData != NULL) {
m_pUserData->Release();
}
@@ -343,7 +340,7 @@ static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = {
&CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others,
};
uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
- ASSERT(m_pFont != NULL && m_pCurLine != NULL && m_pArabicChar != NULL);
+ ASSERT(m_pFont && m_pCurLine);
if (m_bCharCode) {
return AppendChar_CharCode(wch);
}
@@ -520,7 +517,7 @@ uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar,
if (pLastChar != NULL) {
iLineWidth -= pLastChar->m_iCharWidth;
CFX_RTFChar* pPrevChar = GetLastChar(2);
- wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar);
+ wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
bAlef = (wForm == 0xFEFF &&
pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
@@ -544,8 +541,8 @@ uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar,
iCharWidth = 0;
}
}
- wForm =
- m_pArabicChar->GetFormChar(pCurChar, (bAlef ? NULL : pLastChar), NULL);
+ wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar,
+ nullptr);
if (m_bVertical != FX_IsOdd(iRotation)) {
iCharWidth = 1000;
} else if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode) &&
@@ -1268,7 +1265,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
} else {
wNext = 0xFEFF;
}
- wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext);
+ wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext);
} else if (bRTLPiece || bVerticalChar) {
wForm = FX_GetMirrorChar(wch, dwProps, bRTLPiece, bVerticalChar);
} else if (dwCharType == FX_CHARTYPE_Numeric && bArabicNumber) {
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index 95de85bde6..d595ad38d1 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -14,7 +14,6 @@
#include "xfa/fgas/layout/fgas_textbreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-class CFX_ArabicChar;
class IFX_Unknown;
class IFX_Font;
@@ -293,7 +292,6 @@ class CFX_RTFBreak {
protected:
uint32_t m_dwPolicies;
- CFX_ArabicChar* m_pArabicChar;
int32_t m_iBoundaryStart;
int32_t m_iBoundaryEnd;
uint32_t m_dwLayoutStyles;
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 86fecbeef4..4b4ef1fa7b 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -16,7 +16,6 @@
CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
: m_dwPolicies(dwPolicies),
- m_pArabicChar(NULL),
m_iLineWidth(2000000),
m_dwLayoutStyles(0),
m_bVertical(FALSE),
@@ -51,7 +50,6 @@ CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
m_iVerScale(100),
m_iCharSpace(0) {
m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0;
- m_pArabicChar = new CFX_ArabicChar;
if (m_bPagination) {
m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char));
m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char));
@@ -66,7 +64,6 @@ CFX_TxtBreak::~CFX_TxtBreak() {
Reset();
delete m_pTxtLine1;
delete m_pTxtLine2;
- m_pArabicChar->Release();
}
void CFX_TxtBreak::SetLineWidth(FX_FLOAT fLineWidth) {
m_iLineWidth = FXSYS_round(fLineWidth * 20000.0f);
@@ -465,7 +462,7 @@ uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar,
iLineWidth -= iCharWidth;
}
CFX_Char* pPrevChar = GetLastChar(2);
- wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar);
+ wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
bAlef = (wForm == 0xFEFF &&
pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
@@ -488,7 +485,7 @@ uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar,
}
}
m_dwCharType = dwType;
- wForm = m_pArabicChar->GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL);
+ wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL);
if (m_bCombText) {
iCharWidth = m_iCombWidth;
} else {
@@ -1268,7 +1265,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
} else {
wNext = 0xFEFF;
}
- wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext);
+ wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext);
bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647);
} else if (dwCharType == FX_CHARTYPE_Combination) {
wForm = wch;
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index 41bd8f4921..6d961f218a 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -12,7 +12,6 @@
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-class CFX_ArabicChar;
class CFX_Char;
class CFX_TxtChar;
class CFX_TxtPiece;
@@ -270,7 +269,6 @@ class CFX_TxtBreak {
protected:
uint32_t m_dwPolicies;
FX_BOOL m_bPagination;
- CFX_ArabicChar* m_pArabicChar;
int32_t m_iLineWidth;
uint32_t m_dwLayoutStyles;
FX_BOOL m_bVertical;