summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-06 11:36:09 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-03-06 18:48:03 +0000
commitf04b42a9beedb1287977794211d05d92903559db (patch)
tree837f851e4b1204d5fd9d19963324df1ae1af9fe1 /xfa/fgas
parent19fad57424146f0987265c701a58450c43f09008 (diff)
downloadpdfium-f04b42a9beedb1287977794211d05d92903559db.tar.xz
Simplify RTFBreak AppendChar.
This Cl simplifies the AppendChar code by removing the array of callback methods and using a switch instead. Change-Id: I07475d3950395dea2189569d95bfba1be1f9ceb5 Reviewed-on: https://pdfium-review.googlesource.com/2918 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp57
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h7
2 files changed, 34 insertions, 30 deletions
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index 9a83be65ac..d9e5f7f80b 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -14,23 +14,6 @@
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
-namespace {
-
-typedef CFX_RTFBreakType (CFX_RTFBreak::*FX_RTFBreak_LPFAppendChar)(
- CFX_RTFChar* pCurChar);
-const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = {
- &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Tab,
- &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Control,
- &CFX_RTFBreak::AppendChar_Combination, &CFX_RTFBreak::AppendChar_Others,
- &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Arabic,
- &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic,
- &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic,
- &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Others,
- &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others,
-};
-
-} // namespace
-
CFX_RTFBreak::CFX_RTFBreak(uint32_t dwLayoutStyles)
: m_iBoundaryStart(0),
m_iBoundaryEnd(2000000),
@@ -256,14 +239,39 @@ CFX_RTFBreakType CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
pCurChar = &m_pCurLine->m_LineChars[iCount - 1];
}
- CFX_RTFBreakType dwRet2 =
- (this->*g_FX_RTFBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])(
- pCurChar);
+ CFX_RTFBreakType dwRet2 = CFX_RTFBreakType::None;
+ switch (chartype) {
+ case FX_CHARTYPE_Tab:
+ AppendChar_Tab(pCurChar);
+ break;
+ case FX_CHARTYPE_Control:
+ dwRet2 = AppendChar_Control(pCurChar);
+ break;
+ case FX_CHARTYPE_Combination:
+ AppendChar_Combination(pCurChar);
+ break;
+ case FX_CHARTYPE_ArabicAlef:
+ case FX_CHARTYPE_ArabicSpecial:
+ case FX_CHARTYPE_ArabicDistortion:
+ case FX_CHARTYPE_ArabicNormal:
+ case FX_CHARTYPE_ArabicForm:
+ case FX_CHARTYPE_Arabic:
+ dwRet2 = AppendChar_Arabic(pCurChar);
+ break;
+ case FX_CHARTYPE_Unknown:
+ case FX_CHARTYPE_Space:
+ case FX_CHARTYPE_Numeric:
+ case FX_CHARTYPE_Normal:
+ default:
+ dwRet2 = AppendChar_Others(pCurChar);
+ break;
+ }
+
m_eCharType = chartype;
return std::max(dwRet1, dwRet2);
}
-CFX_RTFBreakType CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar) {
+void CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar) {
int32_t iCharWidth = 0;
if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, false))
iCharWidth = 0;
@@ -279,13 +287,11 @@ CFX_RTFBreakType CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar) {
pCurChar->m_iCharWidth = iCharWidth;
if (iCharWidth > 0)
m_pCurLine->m_iWidth += iCharWidth;
-
- return CFX_RTFBreakType::None;
}
-CFX_RTFBreakType CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar) {
+void CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar) {
if (!(m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab))
- return CFX_RTFBreakType::None;
+ return;
int32_t& iLineWidth = m_pCurLine->m_iWidth;
int32_t iCharWidth = iLineWidth;
@@ -296,7 +302,6 @@ CFX_RTFBreakType CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar) {
pCurChar->m_iCharWidth = iCharWidth;
iLineWidth += iCharWidth;
- return CFX_RTFBreakType::None;
}
CFX_RTFBreakType CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar) {
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index 2dfc0248a1..63ad67f6c0 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -172,13 +172,12 @@ class CFX_RTFBreak {
CFX_RTFLine* GetCurrentLineForTesting() const { return m_pCurLine; }
- CFX_RTFBreakType AppendChar_Combination(CFX_RTFChar* pCurChar);
- CFX_RTFBreakType AppendChar_Tab(CFX_RTFChar* pCurChar);
+ private:
+ void AppendChar_Combination(CFX_RTFChar* pCurChar);
+ void AppendChar_Tab(CFX_RTFChar* pCurChar);
CFX_RTFBreakType AppendChar_Control(CFX_RTFChar* pCurChar);
CFX_RTFBreakType AppendChar_Arabic(CFX_RTFChar* pCurChar);
CFX_RTFBreakType AppendChar_Others(CFX_RTFChar* pCurChar);
-
- private:
void FontChanged();
void SetBreakStatus();
CFX_RTFChar* GetLastChar(int32_t index) const;