Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: xfa/fxfa/parser/xfa_localemgr.cpp

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/xfa_localemgr.h ('k') | xfa/fxfa/parser/xfa_localevalue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/xfa_localemgr.h" 7 #include "xfa/fxfa/parser/xfa_localemgr.h"
8 8
9 #include "core/include/fxcodec/fx_codec.h" 9 #include "core/include/fxcodec/fx_codec.h"
10 #include "core/include/fxcrt/fx_xml.h" 10 #include "core/include/fxcrt/fx_xml.h"
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 0, 0, 0, 0, pOut, dwSize); 1053 0, 0, 0, 0, pOut, dwSize);
1054 if (pOut) { 1054 if (pOut) {
1055 pLocale = CXML_Element::Parse(pOut, dwSize); 1055 pLocale = CXML_Element::Parse(pOut, dwSize);
1056 FX_Free(pOut); 1056 FX_Free(pOut);
1057 } 1057 }
1058 if (pLocale) { 1058 if (pLocale) {
1059 return new CXFA_XMLLocale(pLocale); 1059 return new CXFA_XMLLocale(pLocale);
1060 } 1060 }
1061 return NULL; 1061 return NULL;
1062 } 1062 }
1063 static FX_WORD XFA_GetLanguage(CFX_WideString wsLanguage) { 1063 static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) {
1064 FX_WORD dwLangueID = XFA_LANGID_en_US; 1064 uint16_t dwLangueID = XFA_LANGID_en_US;
1065 if (wsLanguage.GetLength() < 2) { 1065 if (wsLanguage.GetLength() < 2) {
1066 return dwLangueID; 1066 return dwLangueID;
1067 } 1067 }
1068 wsLanguage.MakeLower(); 1068 wsLanguage.MakeLower();
1069 FX_DWORD dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1); 1069 FX_DWORD dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1);
1070 FX_DWORD dwIDSecond = wsLanguage.GetLength() >= 5 1070 FX_DWORD dwIDSecond = wsLanguage.GetLength() >= 5
1071 ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4) 1071 ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4)
1072 : 0; 1072 : 0;
1073 switch (dwIDFirst) { 1073 switch (dwIDFirst) {
1074 case FXBSTR_ID(0, 0, 'z', 'h'): { 1074 case FXBSTR_ID(0, 0, 'z', 'h'): {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 ((IFX_Locale*)m_LocaleArray[i])->Release(); 1140 ((IFX_Locale*)m_LocaleArray[i])->Release();
1141 } 1141 }
1142 int32_t iXmls = m_XMLLocaleArray.GetSize(); 1142 int32_t iXmls = m_XMLLocaleArray.GetSize();
1143 for (int32_t j = 0; j < iXmls; j++) { 1143 for (int32_t j = 0; j < iXmls; j++) {
1144 ((IFX_Locale*)m_XMLLocaleArray[j])->Release(); 1144 ((IFX_Locale*)m_XMLLocaleArray[j])->Release();
1145 } 1145 }
1146 } 1146 }
1147 void CXFA_LocaleMgr::Release() { 1147 void CXFA_LocaleMgr::Release() {
1148 delete this; 1148 delete this;
1149 } 1149 }
1150 FX_WORD CXFA_LocaleMgr::GetDefLocaleID() { 1150 uint16_t CXFA_LocaleMgr::GetDefLocaleID() {
1151 return m_dwDeflcid; 1151 return m_dwDeflcid;
1152 } 1152 }
1153 IFX_Locale* CXFA_LocaleMgr::GetDefLocale() { 1153 IFX_Locale* CXFA_LocaleMgr::GetDefLocale() {
1154 if (m_pDefLocale) { 1154 if (m_pDefLocale) {
1155 return m_pDefLocale; 1155 return m_pDefLocale;
1156 } else if (m_LocaleArray.GetSize()) { 1156 } else if (m_LocaleArray.GetSize()) {
1157 return (IFX_Locale*)m_LocaleArray[0]; 1157 return (IFX_Locale*)m_LocaleArray[0];
1158 } else if (m_XMLLocaleArray.GetSize()) { 1158 } else if (m_XMLLocaleArray.GetSize()) {
1159 return (IFX_Locale*)m_XMLLocaleArray[0]; 1159 return (IFX_Locale*)m_XMLLocaleArray[0];
1160 } 1160 }
1161 m_pDefLocale = GetLocale(m_dwDeflcid); 1161 m_pDefLocale = GetLocale(m_dwDeflcid);
1162 if (m_pDefLocale) 1162 if (m_pDefLocale)
1163 m_XMLLocaleArray.Add(m_pDefLocale); 1163 m_XMLLocaleArray.Add(m_pDefLocale);
1164 return m_pDefLocale; 1164 return m_pDefLocale;
1165 } 1165 }
1166 IFX_Locale* CXFA_LocaleMgr::GetLocale(FX_WORD lcid) { 1166 IFX_Locale* CXFA_LocaleMgr::GetLocale(uint16_t lcid) {
1167 IFX_Locale* pLocal = NULL; 1167 IFX_Locale* pLocal = NULL;
1168 switch (lcid) { 1168 switch (lcid) {
1169 case XFA_LANGID_zh_CN: 1169 case XFA_LANGID_zh_CN:
1170 pLocal = XFA_GetLocaleFromBuffer(g_zhCN_Locale, sizeof(g_zhCN_Locale)); 1170 pLocal = XFA_GetLocaleFromBuffer(g_zhCN_Locale, sizeof(g_zhCN_Locale));
1171 break; 1171 break;
1172 case XFA_LANGID_zh_TW: 1172 case XFA_LANGID_zh_TW:
1173 pLocal = XFA_GetLocaleFromBuffer(g_zhTW_Locale, sizeof(g_zhTW_Locale)); 1173 pLocal = XFA_GetLocaleFromBuffer(g_zhTW_Locale, sizeof(g_zhTW_Locale));
1174 break; 1174 break;
1175 case XFA_LANGID_zh_HK: 1175 case XFA_LANGID_zh_HK:
1176 pLocal = XFA_GetLocaleFromBuffer(g_zhHK_Locale, sizeof(g_zhHK_Locale)); 1176 pLocal = XFA_GetLocaleFromBuffer(g_zhHK_Locale, sizeof(g_zhHK_Locale));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 if (iLen < 2) { 1229 if (iLen < 2) {
1230 return NULL; 1230 return NULL;
1231 } 1231 }
1232 iCount = m_XMLLocaleArray.GetSize(); 1232 iCount = m_XMLLocaleArray.GetSize();
1233 for (i = 0; i < iCount; i++) { 1233 for (i = 0; i < iCount; i++) {
1234 IFX_Locale* pLocale = ((IFX_Locale*)m_XMLLocaleArray[i]); 1234 IFX_Locale* pLocale = ((IFX_Locale*)m_XMLLocaleArray[i]);
1235 if (pLocale->GetName() == wsLocaleName) { 1235 if (pLocale->GetName() == wsLocaleName) {
1236 return pLocale; 1236 return pLocale;
1237 } 1237 }
1238 } 1238 }
1239 FX_WORD dwLangueID = XFA_GetLanguage(wsLocaleName); 1239 uint16_t dwLangueID = XFA_GetLanguage(wsLocaleName);
1240 IFX_Locale* pLocale = GetLocale(dwLangueID); 1240 IFX_Locale* pLocale = GetLocale(dwLangueID);
1241 if (pLocale) 1241 if (pLocale)
1242 m_XMLLocaleArray.Add(pLocale); 1242 m_XMLLocaleArray.Add(pLocale);
1243 return pLocale; 1243 return pLocale;
1244 } 1244 }
1245 void CXFA_LocaleMgr::SetDefLocale(IFX_Locale* pLocale) { 1245 void CXFA_LocaleMgr::SetDefLocale(IFX_Locale* pLocale) {
1246 m_pDefLocale = pLocale; 1246 m_pDefLocale = pLocale;
1247 } 1247 }
1248 CFX_WideStringC CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) { 1248 CFX_WideStringC CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) {
1249 if (!(m_dwLocaleFlags & 0x01)) { 1249 if (!(m_dwLocaleFlags & 0x01)) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60); 1296 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60);
1297 #endif 1297 #endif
1298 } 1298 }
1299 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {} 1299 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {}
1300 void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) { 1300 void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) {
1301 m_tz = tz; 1301 m_tz = tz;
1302 } 1302 }
1303 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) { 1303 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) {
1304 tz = m_tz; 1304 tz = m_tz;
1305 } 1305 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_localemgr.h ('k') | xfa/fxfa/parser/xfa_localevalue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698