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

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: remove deleters 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
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 "core/fxge/include/fx_ge.h" 15 #include "core/fxge/include/fx_ge.h"
13 #include "xfa/fxfa/parser/cxfa_document.h" 16 #include "xfa/fxfa/parser/cxfa_document.h"
14 #include "xfa/fxfa/parser/xfa_locale.h" 17 #include "xfa/fxfa/parser/xfa_locale.h"
15 #include "xfa/fxfa/parser/xfa_object.h" 18 #include "xfa/fxfa/parser/xfa_object.h"
16 #include "xfa/fxfa/parser/xfa_utils.h" 19 #include "xfa/fxfa/parser/xfa_utils.h"
17 20
18 const uint8_t g_enUS_Locale[] = { 21 const uint8_t g_enUS_Locale[] = {
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 0xA7, 0x98, 0x4E, 0xD0, 0x0C, 0x8D, 0x18, 0x39, 0x84, 0x07, 0xC4, 0xA2, 1026 0xA7, 0x98, 0x4E, 0xD0, 0x0C, 0x8D, 0x18, 0x39, 0x84, 0x07, 0xC4, 0xA2,
1024 0x1A, 0xA6, 0xA8, 0x62, 0xAA, 0x19, 0x8C, 0x59, 0x95, 0x54, 0x31, 0x5A, 1027 0x1A, 0xA6, 0xA8, 0x62, 0xAA, 0x19, 0x8C, 0x59, 0x95, 0x54, 0x31, 0x5A,
1025 0xD2, 0xFE, 0x4A, 0x59, 0xC0, 0x55, 0x8A, 0xB7, 0x72, 0x29, 0xB3, 0x54, 1028 0xD2, 0xFE, 0x4A, 0x59, 0xC0, 0x55, 0x8A, 0xB7, 0x72, 0x29, 0xB3, 0x54,
1026 0xAE, 0xC2, 0x23, 0x96, 0x47, 0x59, 0xAE, 0xCB, 0x5A, 0x06, 0x61, 0x91, 1029 0xAE, 0xC2, 0x23, 0x96, 0x47, 0x59, 0xAE, 0xCB, 0x5A, 0x06, 0x61, 0x91,
1027 0xD8, 0xD6, 0x86, 0x8C, 0xE6, 0x89, 0x59, 0xD7, 0x14, 0x9E, 0xD3, 0xD4, 1030 0xD8, 0xD6, 0x86, 0x8C, 0xE6, 0x89, 0x59, 0xD7, 0x14, 0x9E, 0xD3, 0xD4,
1028 0xB3, 0xC7, 0x48, 0xCA, 0x27, 0x43, 0x01, 0x94, 0x3A, 0x09, 0xC8, 0xE5, 1031 0xB3, 0xC7, 0x48, 0xCA, 0x27, 0x43, 0x01, 0x94, 0x3A, 0x09, 0xC8, 0xE5,
1029 0xDC, 0xA3, 0x81, 0x5B, 0xE3, 0x59, 0xA2, 0x27, 0xB9, 0xB4, 0x0A, 0x19, 1032 0xDC, 0xA3, 0x81, 0x5B, 0xE3, 0x59, 0xA2, 0x27, 0xB9, 0xB4, 0x0A, 0x19,
1030 0x89, 0x26, 0xB5, 0x2C, 0xA3, 0xB6, 0x4E, 0x5C, 0xA6, 0x17, 0xA4, 0x7B, 1033 0x89, 0x26, 0xB5, 0x2C, 0xA3, 0xB6, 0x4E, 0x5C, 0xA6, 0x17, 0xA4, 0x7B,
1031 0xB3, 0x85, 0xFA, 0x59, 0x2A, 0x7A, 0xFF, 0x3D, 0xC4, 0x3F, 0xDE, 0xCB, 1034 0xB3, 0x85, 0xFA, 0x59, 0x2A, 0x7A, 0xFF, 0x3D, 0xC4, 0x3F, 0xDE, 0xCB,
1032 0x8B, 0xC4}; 1035 0x8B, 0xC4};
1033 static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { 1036 static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) {
dsinclair 2016/08/10 19:47:25 Should this return a unique_ptr? (possibly as a fo
Wei Li 2016/08/10 21:44:57 Add a TODO to followup.
1034 if (!pBuf || nBufLen <= 0) { 1037 if (!pBuf || nBufLen <= 0) {
1035 return nullptr; 1038 return nullptr;
1036 } 1039 }
1037 CFX_GEModule* pGeModule = CFX_GEModule::Get(); 1040 CFX_GEModule* pGeModule = CFX_GEModule::Get();
1038 if (!pGeModule) { 1041 if (!pGeModule) {
1039 return nullptr; 1042 return nullptr;
1040 } 1043 }
1041 CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); 1044 CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule();
1042 if (!pCodecMgr) { 1045 if (!pCodecMgr) {
1043 return nullptr; 1046 return nullptr;
1044 } 1047 }
1045 CXML_Element* pLocale = nullptr; 1048 std::unique_ptr<CXML_Element> pLocale;
1046 uint8_t* pOut = nullptr; 1049 uint8_t* pOut = nullptr;
1047 uint32_t dwSize; 1050 uint32_t dwSize;
1048 pCodecMgr->GetFlateModule()->FlateOrLZWDecode(FALSE, pBuf, nBufLen, TRUE, 0, 1051 pCodecMgr->GetFlateModule()->FlateOrLZWDecode(FALSE, pBuf, nBufLen, TRUE, 0,
1049 0, 0, 0, 0, pOut, dwSize); 1052 0, 0, 0, 0, pOut, dwSize);
1050 if (pOut) { 1053 if (pOut) {
1051 pLocale = CXML_Element::Parse(pOut, dwSize); 1054 pLocale.reset(CXML_Element::Parse(pOut, dwSize));
1052 FX_Free(pOut); 1055 FX_Free(pOut);
1053 } 1056 }
1054 if (pLocale) { 1057 return pLocale ? new CXFA_XMLLocale(std::move(pLocale)) : nullptr;
1055 return new CXFA_XMLLocale(pLocale);
1056 }
1057 return nullptr;
1058 } 1058 }
1059
1059 static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) { 1060 static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) {
1060 uint16_t dwLangueID = XFA_LANGID_en_US; 1061 uint16_t dwLangueID = XFA_LANGID_en_US;
1061 if (wsLanguage.GetLength() < 2) { 1062 if (wsLanguage.GetLength() < 2) {
1062 return dwLangueID; 1063 return dwLangueID;
1063 } 1064 }
1064 wsLanguage.MakeLower(); 1065 wsLanguage.MakeLower();
1065 uint32_t dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1); 1066 uint32_t dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1);
1066 uint32_t dwIDSecond = wsLanguage.GetLength() >= 5 1067 uint32_t dwIDSecond = wsLanguage.GetLength() >= 5
1067 ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4) 1068 ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4)
1068 : 0; 1069 : 0;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60); 1302 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60);
1302 #endif 1303 #endif
1303 } 1304 }
1304 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {} 1305 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {}
1305 void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) { 1306 void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) {
1306 m_tz = tz; 1307 m_tz = tz;
1307 } 1308 }
1308 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) { 1309 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) {
1309 tz = m_tz; 1310 tz = m_tz;
1310 } 1311 }
OLDNEW
« xfa/fxfa/include/xfa_ffdocview.h ('K') | « xfa/fxfa/parser/xfa_locale.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698