summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-19 12:46:53 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-19 17:08:38 +0000
commitf51a02a29e10fcc490ba28f44d43f50104f940ed (patch)
tree354215ff5deeea419ce5a88b369535b5e4468a62 /core/fpdfdoc
parent2a473dbecab2b47c513de9127a2cddf4c2800306 (diff)
downloadpdfium-f51a02a29e10fcc490ba28f44d43f50104f940ed.tar.xz
Cleanup codepage and charset definitions.
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 <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp77
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp5
-rw-r--r--core/fpdfdoc/cpvt_fontmap.cpp3
-rw-r--r--core/fpdfdoc/cpvt_wordinfo.cpp5
4 files changed, 47 insertions, 43 deletions
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),