From f51a02a29e10fcc490ba28f44d43f50104f940ed Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 19 Apr 2017 12:46:53 -0400 Subject: Cleanup codepage and charset definitions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl cleans up the unused defines in fx_codepage.h. The FXFONT_CHARSET_ defines are replaced with fx_codepage defines, this moves fx_codepage into core instead of xfa only. Static asserts are added to verify the public/ charsets match the fx_codepage charsets. Change-Id: Ie2f749e093de60a9a6743128a1fb087912e4cc96 Reviewed-on: https://pdfium-review.googlesource.com/4316 Commit-Queue: dsinclair Commit-Queue: Nicolás Peña Reviewed-by: Nicolás Peña --- core/fpdfdoc/cpdf_interform.cpp | 77 +++++++++++++++++++------------------- core/fpdfdoc/cpdf_variabletext.cpp | 5 ++- core/fpdfdoc/cpvt_fontmap.cpp | 3 +- core/fpdfdoc/cpvt_wordinfo.cpp | 5 ++- 4 files changed, 47 insertions(+), 43 deletions(-) (limited to 'core/fpdfdoc') diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index ebe5079f3b..23102a20ad 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -20,6 +20,7 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfdoc/cpdf_filespec.h" #include "core/fpdfdoc/cpdf_formcontrol.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_substfont.h" #include "core/fxge/fx_font.h" #include "third_party/base/stl_util.h" @@ -75,7 +76,7 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { if (pFont) AddFont(pFormDict, pDocument, pFont, &csBaseName); - if (charSet != FXFONT_ANSI_CHARSET) { + if (charSet != FX_CHARSET_ANSI) { CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); if (!pFont || csFontName != "Helvetica") { @@ -571,56 +572,56 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, // static uint8_t CPDF_InterForm::GetNativeCharSet() { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - uint8_t charSet = FXFONT_ANSI_CHARSET; + uint8_t charSet = FX_CHARSET_ANSI; UINT iCodePage = ::GetACP(); switch (iCodePage) { - case 932: - charSet = FXFONT_SHIFTJIS_CHARSET; + case FX_CODEPAGE_ShiftJIS: + charSet = FX_CHARSET_ShiftJIS; break; - case 936: - charSet = FXFONT_GB2312_CHARSET; + case FX_CODEPAGE_ChineseSimplified: + charSet = FX_CHARSET_ChineseSimplified; break; - case 950: - charSet = FXFONT_CHINESEBIG5_CHARSET; + case FX_CODEPAGE_ChineseTraditional: + charSet = FX_CHARSET_ChineseTraditional; break; - case 1252: - charSet = FXFONT_ANSI_CHARSET; + case FX_CODEPAGE_MSWin_WesternEuropean: + charSet = FX_CHARSET_ANSI; break; - case 874: - charSet = FXFONT_THAI_CHARSET; + case FX_CODEPAGE_MSDOS_Thai: + charSet = FX_CHARSET_Thai; break; - case 949: - charSet = FXFONT_HANGUL_CHARSET; + case FX_CODEPAGE_Hangul: + charSet = FX_CHARSET_Hangul; break; - case 1200: - charSet = FXFONT_ANSI_CHARSET; + case FX_CODEPAGE_UTF16LE: + charSet = FX_CHARSET_ANSI; break; - case 1250: - charSet = FXFONT_EASTEUROPE_CHARSET; + case FX_CODEPAGE_MSWin_EasternEuropean: + charSet = FX_CHARSET_MSWin_EasternEuropean; break; - case 1251: - charSet = FXFONT_RUSSIAN_CHARSET; + case FX_CODEPAGE_MSWin_Cyrillic: + charSet = FX_CHARSET_MSWin_Cyrillic; break; - case 1253: - charSet = FXFONT_GREEK_CHARSET; + case FX_CODEPAGE_MSWin_Greek: + charSet = FX_CHARSET_MSWin_Greek; break; - case 1254: - charSet = FXFONT_TURKISH_CHARSET; + case FX_CODEPAGE_MSWin_Turkish: + charSet = FX_CHARSET_MSWin_Turkish; break; - case 1255: - charSet = FXFONT_HEBREW_CHARSET; + case FX_CODEPAGE_MSWin_Hebrew: + charSet = FX_CHARSET_MSWin_Hebrew; break; - case 1256: - charSet = FXFONT_ARABIC_CHARSET; + case FX_CODEPAGE_MSWin_Arabic: + charSet = FX_CHARSET_MSWin_Arabic; break; - case 1257: - charSet = FXFONT_BALTIC_CHARSET; + case FX_CODEPAGE_MSWin_Baltic: + charSet = FX_CHARSET_MSWin_Baltic; break; - case 1258: - charSet = FXFONT_VIETNAMESE_CHARSET; + case FX_CODEPAGE_MSWin_Vietnamese: + charSet = FX_CHARSET_MSWin_Vietnamese; break; - case 1361: - charSet = FXFONT_JOHAB_CHARSET; + case FX_CODEPAGE_Johab: + charSet = FX_CHARSET_Johab; break; } return charSet; @@ -734,18 +735,18 @@ CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { CFX_ByteString csFontName; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ LOGFONTA lf = {}; - if (charSet == FXFONT_ANSI_CHARSET) { + if (charSet == FX_CHARSET_ANSI) { csFontName = "Helvetica"; return csFontName; } bool bRet = false; - if (charSet == FXFONT_SHIFTJIS_CHARSET) { + if (charSet == FX_CHARSET_ShiftJIS) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mincho", lf); - } else if (charSet == FXFONT_GB2312_CHARSET) { + } else if (charSet == FX_CHARSET_ChineseSimplified) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSun", lf); - } else if (charSet == FXFONT_CHINESEBIG5_CHARSET) { + } else if (charSet == FX_CHARSET_ChineseTraditional) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingLiU", lf); } diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index ab5c5e8050..1fc32946fc 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -16,6 +16,7 @@ #include "core/fpdfdoc/cpvt_wordinfo.h" #include "core/fpdfdoc/csection.h" #include "core/fpdfdoc/ipvt_fontmap.h" +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -378,7 +379,7 @@ CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place, case 0x09: word = 0x20; default: - wp = InsertWord(wp, word, FXFONT_DEFAULT_CHARSET, nullptr); + wp = InsertWord(wp, word, FX_CHARSET_Default, nullptr); break; } if (wp == oldwp) @@ -448,7 +449,7 @@ void CPDF_VariableText::SetText(const CFX_WideString& swText) { case 0x09: word = 0x20; default: - wp = InsertWord(wp, word, FXFONT_DEFAULT_CHARSET, nullptr); + wp = InsertWord(wp, word, FX_CHARSET_Default, nullptr); break; } nCharCount++; diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index 17ce673fde..42774d43d2 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -11,6 +11,7 @@ #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfdoc/cpdf_interform.h" +#include "core/fxcrt/fx_codepage.h" CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, @@ -88,5 +89,5 @@ int32_t CPVT_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) { int32_t CPVT_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { ASSERT(false); - return FXFONT_ANSI_CHARSET; + return FX_CHARSET_ANSI; } diff --git a/core/fpdfdoc/cpvt_wordinfo.cpp b/core/fpdfdoc/cpvt_wordinfo.cpp index f1ea11915c..36859c2309 100644 --- a/core/fpdfdoc/cpvt_wordinfo.cpp +++ b/core/fpdfdoc/cpvt_wordinfo.cpp @@ -5,11 +5,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fpdfdoc/cpvt_wordinfo.h" +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/ptr_util.h" CPVT_WordInfo::CPVT_WordInfo() : Word(0), - nCharset(FXFONT_ANSI_CHARSET), + nCharset(FX_CHARSET_ANSI), fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), @@ -28,7 +29,7 @@ CPVT_WordInfo::CPVT_WordInfo(uint16_t word, CPVT_WordInfo::CPVT_WordInfo(const CPVT_WordInfo& word) : Word(0), - nCharset(FXFONT_ANSI_CHARSET), + nCharset(FX_CHARSET_ANSI), fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), -- cgit v1.2.3