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

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

Issue 2227883002: Use smart pointers for class owned pointers in xfa/fxfa (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 4 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_locale.cpp ('k') | no next file » | 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 <memory>
10 #include <utility>
11
9 #include "core/fxcodec/include/fx_codec.h" 12 #include "core/fxcodec/include/fx_codec.h"
10 #include "core/fxcrt/include/fx_xml.h" 13 #include "core/fxcrt/include/fx_xml.h"
11 #include "core/fxge/include/cfx_gemodule.h" 14 #include "core/fxge/include/cfx_gemodule.h"
12 #include "xfa/fxfa/parser/cxfa_document.h" 15 #include "xfa/fxfa/parser/cxfa_document.h"
13 #include "xfa/fxfa/parser/xfa_locale.h" 16 #include "xfa/fxfa/parser/xfa_locale.h"
14 #include "xfa/fxfa/parser/xfa_object.h" 17 #include "xfa/fxfa/parser/xfa_object.h"
15 #include "xfa/fxfa/parser/xfa_utils.h" 18 #include "xfa/fxfa/parser/xfa_utils.h"
16 19
17 const uint8_t g_enUS_Locale[] = { 20 const uint8_t g_enUS_Locale[] = {
18 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6E, 0x9B, 0x30, 0x14, 0x7D, 0x9F, 0xB4, 21 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6E, 0x9B, 0x30, 0x14, 0x7D, 0x9F, 0xB4,
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 0xA7, 0x98, 0x4E, 0xD0, 0x0C, 0x8D, 0x18, 0x39, 0x84, 0x07, 0xC4, 0xA2, 1025 0xA7, 0x98, 0x4E, 0xD0, 0x0C, 0x8D, 0x18, 0x39, 0x84, 0x07, 0xC4, 0xA2,
1023 0x1A, 0xA6, 0xA8, 0x62, 0xAA, 0x19, 0x8C, 0x59, 0x95, 0x54, 0x31, 0x5A, 1026 0x1A, 0xA6, 0xA8, 0x62, 0xAA, 0x19, 0x8C, 0x59, 0x95, 0x54, 0x31, 0x5A,
1024 0xD2, 0xFE, 0x4A, 0x59, 0xC0, 0x55, 0x8A, 0xB7, 0x72, 0x29, 0xB3, 0x54, 1027 0xD2, 0xFE, 0x4A, 0x59, 0xC0, 0x55, 0x8A, 0xB7, 0x72, 0x29, 0xB3, 0x54,
1025 0xAE, 0xC2, 0x23, 0x96, 0x47, 0x59, 0xAE, 0xCB, 0x5A, 0x06, 0x61, 0x91, 1028 0xAE, 0xC2, 0x23, 0x96, 0x47, 0x59, 0xAE, 0xCB, 0x5A, 0x06, 0x61, 0x91,
1026 0xD8, 0xD6, 0x86, 0x8C, 0xE6, 0x89, 0x59, 0xD7, 0x14, 0x9E, 0xD3, 0xD4, 1029 0xD8, 0xD6, 0x86, 0x8C, 0xE6, 0x89, 0x59, 0xD7, 0x14, 0x9E, 0xD3, 0xD4,
1027 0xB3, 0xC7, 0x48, 0xCA, 0x27, 0x43, 0x01, 0x94, 0x3A, 0x09, 0xC8, 0xE5, 1030 0xB3, 0xC7, 0x48, 0xCA, 0x27, 0x43, 0x01, 0x94, 0x3A, 0x09, 0xC8, 0xE5,
1028 0xDC, 0xA3, 0x81, 0x5B, 0xE3, 0x59, 0xA2, 0x27, 0xB9, 0xB4, 0x0A, 0x19, 1031 0xDC, 0xA3, 0x81, 0x5B, 0xE3, 0x59, 0xA2, 0x27, 0xB9, 0xB4, 0x0A, 0x19,
1029 0x89, 0x26, 0xB5, 0x2C, 0xA3, 0xB6, 0x4E, 0x5C, 0xA6, 0x17, 0xA4, 0x7B, 1032 0x89, 0x26, 0xB5, 0x2C, 0xA3, 0xB6, 0x4E, 0x5C, 0xA6, 0x17, 0xA4, 0x7B,
1030 0xB3, 0x85, 0xFA, 0x59, 0x2A, 0x7A, 0xFF, 0x3D, 0xC4, 0x3F, 0xDE, 0xCB, 1033 0xB3, 0x85, 0xFA, 0x59, 0x2A, 0x7A, 0xFF, 0x3D, 0xC4, 0x3F, 0xDE, 0xCB,
1031 0x8B, 0xC4}; 1034 0x8B, 0xC4};
1035
1036 // TODO(weili): Change this function to return std::unique_ptr type.
1032 static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { 1037 static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) {
1033 if (!pBuf || nBufLen <= 0) { 1038 if (!pBuf || nBufLen <= 0) {
1034 return nullptr; 1039 return nullptr;
1035 } 1040 }
1036 CFX_GEModule* pGeModule = CFX_GEModule::Get(); 1041 CFX_GEModule* pGeModule = CFX_GEModule::Get();
1037 if (!pGeModule) { 1042 if (!pGeModule) {
1038 return nullptr; 1043 return nullptr;
1039 } 1044 }
1040 CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); 1045 CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule();
1041 if (!pCodecMgr) { 1046 if (!pCodecMgr) {
1042 return nullptr; 1047 return nullptr;
1043 } 1048 }
1044 CXML_Element* pLocale = nullptr; 1049 std::unique_ptr<CXML_Element> pLocale;
1045 uint8_t* pOut = nullptr; 1050 uint8_t* pOut = nullptr;
1046 uint32_t dwSize; 1051 uint32_t dwSize;
1047 pCodecMgr->GetFlateModule()->FlateOrLZWDecode(FALSE, pBuf, nBufLen, TRUE, 0, 1052 pCodecMgr->GetFlateModule()->FlateOrLZWDecode(FALSE, pBuf, nBufLen, TRUE, 0,
1048 0, 0, 0, 0, pOut, dwSize); 1053 0, 0, 0, 0, pOut, dwSize);
1049 if (pOut) { 1054 if (pOut) {
1050 pLocale = CXML_Element::Parse(pOut, dwSize); 1055 pLocale.reset(CXML_Element::Parse(pOut, dwSize));
1051 FX_Free(pOut); 1056 FX_Free(pOut);
1052 } 1057 }
1053 if (pLocale) { 1058 return pLocale ? new CXFA_XMLLocale(std::move(pLocale)) : nullptr;
1054 return new CXFA_XMLLocale(pLocale);
1055 }
1056 return nullptr;
1057 } 1059 }
1060
1058 static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) { 1061 static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) {
1059 uint16_t dwLangueID = XFA_LANGID_en_US; 1062 uint16_t dwLangueID = XFA_LANGID_en_US;
1060 if (wsLanguage.GetLength() < 2) { 1063 if (wsLanguage.GetLength() < 2) {
1061 return dwLangueID; 1064 return dwLangueID;
1062 } 1065 }
1063 wsLanguage.MakeLower(); 1066 wsLanguage.MakeLower();
1064 uint32_t dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1); 1067 uint32_t dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1);
1065 uint32_t dwIDSecond = wsLanguage.GetLength() >= 5 1068 uint32_t dwIDSecond = wsLanguage.GetLength() >= 5
1066 ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4) 1069 ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4)
1067 : 0; 1070 : 0;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60); 1303 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60);
1301 #endif 1304 #endif
1302 } 1305 }
1303 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {} 1306 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {}
1304 void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) { 1307 void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) {
1305 m_tz = tz; 1308 m_tz = tz;
1306 } 1309 }
1307 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) { 1310 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) {
1308 tz = m_tz; 1311 tz = m_tz;
1309 } 1312 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_locale.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698