summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-08 10:55:57 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-08 10:55:57 -0800
commit51709bea3ce113df7d36a5fe6415036e26fc3236 (patch)
treeff2cc5da9de834bda8cbc5c92d45c9a5c00b21c3 /xfa/fgas
parent447b1f3ffc7e0df233d15300bbf8a85ce2bc7278 (diff)
downloadpdfium-51709bea3ce113df7d36a5fe6415036e26fc3236.tar.xz
Replace CFX_WideStringArray with std::vector
Minimalist changes with the tidying of the code to use better loop iterators as a follow-up. Review-Url: https://codereview.chromium.org/2556963004
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp23
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h4
-rw-r--r--xfa/fgas/localization/fgas_locale.cpp15
-rw-r--r--xfa/fgas/localization/fgas_localeimp.h4
4 files changed, 25 insertions, 21 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 6f998a9975..5cf5a46d0e 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -947,12 +947,12 @@ int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled,
int32_t nPenalty = 30000;
if (FontName.GetLength() != 0) {
if (FontName != pInstalled->m_wsFaceName) {
- int32_t i;
- for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) {
+ size_t i;
+ for (i = 0; i < pInstalled->m_wsFamilyNames.size(); ++i) {
if (pInstalled->m_wsFamilyNames[i] == FontName)
break;
}
- if (i == pInstalled->m_wsFamilyNames.GetSize())
+ if (i == pInstalled->m_wsFamilyNames.size())
nPenalty += 0xFFFF;
else
nPenalty -= 28000;
@@ -961,12 +961,12 @@ int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled,
}
if (30000 == nPenalty &&
0 == IsPartName(pInstalled->m_wsFaceName, FontName)) {
- int32_t i;
- for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) {
+ size_t i;
+ for (i = 0; i < pInstalled->m_wsFamilyNames.size(); i++) {
if (IsPartName(pInstalled->m_wsFamilyNames[i], FontName) != 0)
break;
}
- if (i == pInstalled->m_wsFamilyNames.GetSize())
+ if (i == pInstalled->m_wsFamilyNames.size())
nPenalty += 0xFFFF;
else
nPenalty -= 26000;
@@ -1058,13 +1058,12 @@ void CFGAS_FontMgr::RegisterFace(FXFT_Face pFace,
table.clear();
}
GetNames(table.empty() ? nullptr : table.data(), pFont->m_wsFamilyNames);
-
- pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode());
+ pFont->m_wsFamilyNames.push_back(
+ CFX_ByteString(pFace->family_name).UTF8Decode());
pFont->m_wsFaceName =
pFaceName ? *pFaceName
: CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace));
pFont->m_nFaceIndex = pFace->face_index;
-
m_InstalledFonts.Add(pFont.release());
}
@@ -1106,7 +1105,7 @@ uint32_t CFGAS_FontMgr::GetFlags(FXFT_Face pFace) {
}
void CFGAS_FontMgr::GetNames(const uint8_t* name_table,
- CFX_WideStringArray& Names) {
+ std::vector<CFX_WideString>& Names) {
if (!name_table)
return;
@@ -1130,14 +1129,14 @@ void CFGAS_FontMgr::GetNames(const uint8_t* name_table,
FX_WCHAR wcTemp = GetUInt16(lpStr + nNameOffset + k * 2);
wsFamily += wcTemp;
}
- Names.Add(wsFamily);
+ Names.push_back(wsFamily);
continue;
}
for (uint16_t k = 0; k < nNameLength; k++) {
FX_WCHAR wcTemp = GetUInt8(lpStr + nNameOffset + k);
wsFamily += wcTemp;
}
- Names.Add(wsFamily);
+ Names.push_back(wsFamily);
}
}
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index ce87b4e2b8..0da84fd6e9 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -137,7 +137,7 @@ class CFX_FontDescriptor {
int32_t m_nFaceIndex;
CFX_WideString m_wsFaceName;
- CFX_WideStringArray m_wsFamilyNames;
+ std::vector<CFX_WideString> m_wsFamilyNames;
uint32_t m_dwFontStyles;
uint32_t m_dwUsb[4];
uint32_t m_dwCsb[2];
@@ -217,7 +217,7 @@ class CFGAS_FontMgr {
void RegisterFace(FXFT_Face pFace, const CFX_WideString* pFaceName);
void RegisterFaces(const CFX_RetainPtr<IFX_SeekableReadStream>& pFontStream,
const CFX_WideString* pFaceName);
- void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names);
+ void GetNames(const uint8_t* name_table, std::vector<CFX_WideString>& Names);
std::vector<uint16_t> GetCharsets(FXFT_Face pFace) const;
void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB);
uint32_t GetFlags(FXFT_Face pFace);
diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp
index aea7bacc11..d6ef62885d 100644
--- a/xfa/fgas/localization/fgas_locale.cpp
+++ b/xfa/fgas/localization/fgas_locale.cpp
@@ -7,6 +7,7 @@
#include "xfa/fgas/localization/fgas_locale.h"
#include <algorithm>
+#include <vector>
#include "core/fxcrt/fx_ext.h"
#include "core/fxcrt/fx_xml.h"
@@ -262,9 +263,12 @@ CFX_WideString CFX_LCNumeric::ToString(int32_t nTreading,
CFX_FormatString::CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, bool bUseLCID)
: m_pLocaleMgr(pLocaleMgr), m_bUseLCID(bUseLCID) {}
+
CFX_FormatString::~CFX_FormatString() {}
-void CFX_FormatString::SplitFormatString(const CFX_WideString& wsFormatString,
- CFX_WideStringArray& wsPatterns) {
+
+void CFX_FormatString::SplitFormatString(
+ const CFX_WideString& wsFormatString,
+ std::vector<CFX_WideString>& wsPatterns) {
int32_t iStrLen = wsFormatString.GetLength();
const FX_WCHAR* pStr = wsFormatString.c_str();
const FX_WCHAR* pToken = pStr;
@@ -272,20 +276,19 @@ void CFX_FormatString::SplitFormatString(const CFX_WideString& wsFormatString,
bool iQuote = false;
while (true) {
if (pStr >= pEnd) {
- CFX_WideString sub(pToken, pStr - pToken);
- wsPatterns.Add(sub);
+ wsPatterns.push_back(CFX_WideString(pToken, pStr - pToken));
return;
}
if (*pStr == '\'') {
iQuote = !iQuote;
} else if (*pStr == L'|' && !iQuote) {
- CFX_WideString sub(pToken, pStr - pToken);
- wsPatterns.Add(sub);
+ wsPatterns.push_back(CFX_WideString(pToken, pStr - pToken));
pToken = pStr + 1;
}
pStr++;
}
}
+
static CFX_WideString FX_GetLiteralText(const FX_WCHAR* pStrPattern,
int32_t& iPattern,
int32_t iLenPattern) {
diff --git a/xfa/fgas/localization/fgas_localeimp.h b/xfa/fgas/localization/fgas_localeimp.h
index 7389158798..a66921b61c 100644
--- a/xfa/fgas/localization/fgas_localeimp.h
+++ b/xfa/fgas/localization/fgas_localeimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_
#define XFA_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_
+#include <vector>
+
#include "xfa/fgas/localization/fgas_locale.h"
class CFX_LCNumeric;
@@ -17,7 +19,7 @@ class CFX_FormatString {
~CFX_FormatString();
void SplitFormatString(const CFX_WideString& wsFormatString,
- CFX_WideStringArray& wsPatterns);
+ std::vector<CFX_WideString>& wsPatterns);
FX_LOCALECATEGORY GetCategory(const CFX_WideString& wsPattern);
uint16_t GetLCID(const CFX_WideString& wsPattern);
CFX_WideString GetLocaleName(const CFX_WideString& wsPattern);