From 04f736099c065d83193d2ceeccd6d125d7fe789d Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 1 Aug 2017 14:00:19 -0700 Subject: Encapsulate some CFX_Char members. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iab34de5858ae06582023be220ef7dd0d1d0a91c9 Reviewed-on: https://pdfium-review.googlesource.com/9530 Commit-Queue: Lei Zhang Reviewed-by: Nicolás Peña --- core/fxcrt/cfx_char.cpp | 31 +++++++++++-------------------- core/fxcrt/cfx_char.h | 20 +++++++++++++++----- core/fxcrt/fx_arabic.cpp | 13 +++++++------ 3 files changed, 33 insertions(+), 31 deletions(-) (limited to 'core') diff --git a/core/fxcrt/cfx_char.cpp b/core/fxcrt/cfx_char.cpp index 1c166353f1..bc04b0fd72 100644 --- a/core/fxcrt/cfx_char.cpp +++ b/core/fxcrt/cfx_char.cpp @@ -6,36 +6,27 @@ #include "core/fxcrt/cfx_char.h" -CFX_Char::CFX_Char() +CFX_Char::CFX_Char(uint16_t wCharCode, uint32_t dwCharProps) + : CFX_Char(wCharCode, dwCharProps, 100, 100) {} + +CFX_Char::CFX_Char(uint16_t wCharCode, + uint32_t dwCharProps, + int32_t iHorizontalScale, + int32_t iVerticalScale) : 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_dwIdentity(0) {} - -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_dwIdentity(0), m_wCharCode(wCharCode), - m_iFontSize(0), - m_dwIdentity(0) {} + m_dwCharProps(dwCharProps), + m_iHorizontalScale(iHorizontalScale), + m_iVerticalScale(iVerticalScale) {} CFX_Char::CFX_Char(const CFX_Char& other) = default; diff --git a/core/fxcrt/cfx_char.h b/core/fxcrt/cfx_char.h index cd0166feb2..009e87b388 100644 --- a/core/fxcrt/cfx_char.h +++ b/core/fxcrt/cfx_char.h @@ -15,28 +15,38 @@ 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(uint16_t wCharCode, + uint32_t dwCharProps, + int32_t iHorizontalScale, + int32_t iVerticalScale); CFX_Char(const CFX_Char& other); ~CFX_Char(); FX_CHARTYPE GetCharType() const; + uint16_t char_code() const { return m_wCharCode; } + uint32_t char_props() const { return m_dwCharProps; } + int16_t horizonal_scale() const { return m_iHorizontalScale; } + int16_t vertical_scale() const { return m_iVerticalScale; } + 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; uint32_t m_dwIdentity; CFX_RetainPtr m_pUserData; + + private: + uint16_t m_wCharCode; + uint32_t m_dwCharProps; + int32_t m_iHorizontalScale; + int32_t m_iVerticalScale; }; #endif // CORE_FXCRT_CFX_CHAR_H_ diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp index 095db8d728..fecfc3f759 100644 --- a/core/fxcrt/fx_arabic.cpp +++ b/core/fxcrt/fx_arabic.cpp @@ -336,7 +336,7 @@ const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC, } *eType = pTC->GetCharType(); - *wChar = static_cast(pTC->m_wCharCode); + *wChar = static_cast(pTC->char_code()); const FX_ARBFORMTABLE* pFT = GetArabicFormTable(*wChar); if (!pFT || *eType >= FX_CHARTYPE_ArabicNormal) *eType = FX_CHARTYPE_Unknown; @@ -424,17 +424,18 @@ class CFX_BidiLine { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize(*chars)); if (bWS) { for (int32_t i = 0; i < iCount; i++) { - (*chars)[i].m_iBidiClass = - static_cast((*chars)[i].m_dwCharProps & - FX_BIDICLASSBITSMASK) >> + CFX_Char& cur = (*chars)[i]; + cur.m_iBidiClass = + static_cast(cur.char_props() & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; } return; } for (int32_t i = 0; i < iCount; i++) { - (*chars)[i].m_iBidiClass = static_cast( - gc_FX_BidiNTypes[((*chars)[i].m_dwCharProps & FX_BIDICLASSBITSMASK) >> + CFX_Char& cur = (*chars)[i]; + cur.m_iBidiClass = static_cast( + gc_FX_BidiNTypes[(cur.char_props() & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS]); } } -- cgit v1.2.3