summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-09 07:01:36 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-09 07:01:36 -0800
commit0fa471794a88b262f9114b973d74b1c33e4e592b (patch)
tree0922c56f6e8ba029cd59dc85c8e2c05689cc334a /core/fpdfapi/font
parent5037839bb0b91792b81a3e455dead1314fcc7a6d (diff)
downloadpdfium-0fa471794a88b262f9114b973d74b1c33e4e592b.tar.xz
Remove CFX_ArrayTemplate from fpdfapi
Review-Url: https://codereview.chromium.org/2611413002
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp42
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.h7
-rw-r--r--core/fpdfapi/font/font_int.h3
-rw-r--r--core/fpdfapi/font/fpdf_font_cid.cpp10
4 files changed, 32 insertions, 30 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 91df025e0f..c6c6992562 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -391,7 +391,7 @@ bool CPDF_CIDFont::Load() {
m_DefaultWidth = pCIDFontDict->GetIntegerFor("DW", 1000);
CPDF_Array* pWidthArray = pCIDFontDict->GetArrayFor("W");
if (pWidthArray)
- LoadMetricsArray(pWidthArray, m_WidthList, 1);
+ LoadMetricsArray(pWidthArray, &m_WidthList, 1);
if (!IsEmbedded())
LoadSubstFont();
@@ -416,7 +416,7 @@ bool CPDF_CIDFont::Load() {
if (IsVertWriting()) {
pWidthArray = pCIDFontDict->GetArrayFor("W2");
if (pWidthArray)
- LoadMetricsArray(pWidthArray, m_VertMetrics, 3);
+ LoadMetricsArray(pWidthArray, &m_VertMetrics, 3);
CPDF_Array* pDefaultArray = pCIDFontDict->GetArrayFor("DW2");
if (pDefaultArray) {
m_DefaultVY = pDefaultArray->GetIntegerAt(0);
@@ -505,9 +505,9 @@ int CPDF_CIDFont::GetCharWidthF(uint32_t charcode) {
return (charcode >= 32 && charcode < 127) ? 500 : 0;
uint16_t cid = CIDFromCharCode(charcode);
- int size = m_WidthList.GetSize();
- const uint32_t* pList = m_WidthList.GetData();
- for (int i = 0; i < size; i += 3) {
+ size_t size = m_WidthList.size();
+ const uint32_t* pList = m_WidthList.data();
+ for (size_t i = 0; i < size; i += 3) {
const uint32_t* pEntry = pList + i;
if (IsMetricForCID(pEntry, cid))
return static_cast<int>(pEntry[2]);
@@ -516,10 +516,10 @@ int CPDF_CIDFont::GetCharWidthF(uint32_t charcode) {
}
short CPDF_CIDFont::GetVertWidth(uint16_t CID) const {
- uint32_t vertsize = m_VertMetrics.GetSize() / 5;
+ size_t vertsize = m_VertMetrics.size() / 5;
if (vertsize) {
- const uint32_t* pTable = m_VertMetrics.GetData();
- for (uint32_t i = 0; i < vertsize; i++) {
+ const uint32_t* pTable = m_VertMetrics.data();
+ for (size_t i = 0; i < vertsize; i++) {
const uint32_t* pEntry = pTable + (i * 5);
if (IsMetricForCID(pEntry, CID))
return static_cast<short>(pEntry[2]);
@@ -529,10 +529,10 @@ short CPDF_CIDFont::GetVertWidth(uint16_t CID) const {
}
void CPDF_CIDFont::GetVertOrigin(uint16_t CID, short& vx, short& vy) const {
- uint32_t vertsize = m_VertMetrics.GetSize() / 5;
+ size_t vertsize = m_VertMetrics.size() / 5;
if (vertsize) {
- const uint32_t* pTable = m_VertMetrics.GetData();
- for (uint32_t i = 0; i < vertsize; i++) {
+ const uint32_t* pTable = m_VertMetrics.data();
+ for (size_t i = 0; i < vertsize; i++) {
const uint32_t* pEntry = pTable + (i * 5);
if (IsMetricForCID(pEntry, CID)) {
vx = static_cast<short>(pEntry[3]);
@@ -542,9 +542,9 @@ void CPDF_CIDFont::GetVertOrigin(uint16_t CID, short& vx, short& vy) const {
}
}
uint32_t dwWidth = m_DefaultWidth;
- int size = m_WidthList.GetSize();
- const uint32_t* pList = m_WidthList.GetData();
- for (int i = 0; i < size; i += 3) {
+ size_t size = m_WidthList.size();
+ const uint32_t* pList = m_WidthList.data();
+ for (size_t i = 0; i < size; i += 3) {
const uint32_t* pEntry = pList + i;
if (IsMetricForCID(pEntry, CID)) {
dwWidth = pEntry[2];
@@ -771,7 +771,7 @@ void CPDF_CIDFont::LoadSubstFont() {
}
void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray,
- CFX_ArrayTemplate<uint32_t>& result,
+ std::vector<uint32_t>* result,
int nElements) {
int width_status = 0;
int iCurElement = 0;
@@ -787,10 +787,10 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray,
return;
for (size_t j = 0; j < pObjArray->GetCount(); j += nElements) {
- result.Add(first_code);
- result.Add(first_code);
+ result->push_back(first_code);
+ result->push_back(first_code);
for (int k = 0; k < nElements; k++)
- result.Add(pObjArray->GetIntegerAt(j + k));
+ result->push_back(pObjArray->GetIntegerAt(j + k));
first_code++;
}
width_status = 0;
@@ -804,10 +804,10 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray,
iCurElement = 0;
} else {
if (!iCurElement) {
- result.Add(first_code);
- result.Add(last_code);
+ result->push_back(first_code);
+ result->push_back(last_code);
}
- result.Add(pObj->GetInteger());
+ result->push_back(pObj->GetInteger());
iCurElement++;
if (iCurElement == nElements)
width_status = 0;
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h
index a2d16ed14c..ae3be3908f 100644
--- a/core/fpdfapi/font/cpdf_cidfont.h
+++ b/core/fpdfapi/font/cpdf_cidfont.h
@@ -8,6 +8,7 @@
#define CORE_FPDFAPI_FONT_CPDF_CIDFONT_H_
#include <memory>
+#include <vector>
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fxcrt/fx_string.h"
@@ -65,7 +66,7 @@ class CPDF_CIDFont : public CPDF_Font {
int GetGlyphIndex(uint32_t unicodeb, bool* pVertGlyph);
int GetVerticalGlyph(int index, bool* pVertGlyph);
void LoadMetricsArray(CPDF_Array* pArray,
- CFX_ArrayTemplate<uint32_t>& result,
+ std::vector<uint32_t>* result,
int nElements);
void LoadSubstFont();
FX_WCHAR GetUnicodeFromCharCode(uint32_t charcode) const;
@@ -80,10 +81,10 @@ class CPDF_CIDFont : public CPDF_Font {
std::unique_ptr<CPDF_StreamAcc> m_pStreamAcc;
bool m_bAnsiWidthsFixed;
FX_RECT m_CharBBox[256];
- CFX_ArrayTemplate<uint32_t> m_WidthList;
+ std::vector<uint32_t> m_WidthList;
short m_DefaultVY;
short m_DefaultW1;
- CFX_ArrayTemplate<uint32_t> m_VertMetrics;
+ std::vector<uint32_t> m_VertMetrics;
bool m_bAdobeCourierStd;
std::unique_ptr<CFX_CTTGSUBTable> m_pTTGSUBTable;
};
diff --git a/core/fpdfapi/font/font_int.h b/core/fpdfapi/font/font_int.h
index 02131eb67c..2410741e53 100644
--- a/core/fpdfapi/font/font_int.h
+++ b/core/fpdfapi/font/font_int.h
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
+#include <vector>
#include "core/fpdfapi/font/cpdf_cidfont.h"
#include "core/fxcrt/fx_basic.h"
@@ -107,7 +108,7 @@ class CPDF_CMapParser {
int m_Status;
int m_CodeSeq;
uint32_t m_CodePoints[4];
- CFX_ArrayTemplate<CMap_CodeRange> m_CodeRanges;
+ std::vector<CMap_CodeRange> m_CodeRanges;
CFX_ByteString m_LastWord;
};
diff --git a/core/fpdfapi/font/fpdf_font_cid.cpp b/core/fpdfapi/font/fpdf_font_cid.cpp
index 02f8f7f058..010c94ced2 100644
--- a/core/fpdfapi/font/fpdf_font_cid.cpp
+++ b/core/fpdfapi/font/fpdf_font_cid.cpp
@@ -15,6 +15,7 @@
#include "core/fpdfapi/parser/cpdf_simple_parser.h"
#include "core/fxcrt/fx_ext.h"
#include "core/fxge/fx_freetype.h"
+#include "third_party/base/stl_util.h"
namespace {
@@ -403,14 +404,14 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) {
m_Status = 0;
} else if (m_Status == 7) {
if (word == "endcodespacerange") {
- int nSegs = m_CodeRanges.GetSize();
+ uint32_t nSegs = pdfium::CollectionSize<uint32_t>(m_CodeRanges);
if (nSegs > 1) {
m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes;
m_pCMap->m_nCodeRanges = nSegs;
FX_Free(m_pCMap->m_pLeadingBytes);
m_pCMap->m_pLeadingBytes =
FX_Alloc2D(uint8_t, nSegs, sizeof(CMap_CodeRange));
- FXSYS_memcpy(m_pCMap->m_pLeadingBytes, m_CodeRanges.GetData(),
+ FXSYS_memcpy(m_pCMap->m_pLeadingBytes, m_CodeRanges.data(),
nSegs * sizeof(CMap_CodeRange));
} else if (nSegs == 1) {
m_pCMap->m_CodingScheme = (m_CodeRanges[0].m_CharSize == 2)
@@ -424,9 +425,8 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) {
}
if (m_CodeSeq % 2) {
CMap_CodeRange range;
- if (CMap_GetCodeRange(range, m_LastWord.AsStringC(), word)) {
- m_CodeRanges.Add(range);
- }
+ if (CMap_GetCodeRange(range, m_LastWord.AsStringC(), word))
+ m_CodeRanges.push_back(range);
}
m_CodeSeq++;
}