summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfdoc/fpdf_doc.h2
-rw-r--r--core/include/fxcrt/fx_basic.h2
-rw-r--r--core/include/fxge/fx_font.h23
-rw-r--r--core/include/fxge/fx_ge.h4
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp18
-rw-r--r--core/src/fpdfdoc/doc_form.cpp11
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp20
-rw-r--r--core/src/fpdftext/text_int.h2
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp24
9 files changed, 49 insertions, 57 deletions
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h
index 7ade012bf0..17f2c824c6 100644
--- a/core/include/fpdfdoc/fpdf_doc.h
+++ b/core/include/fpdfdoc/fpdf_doc.h
@@ -563,8 +563,6 @@ class CPDF_InterForm : public CFX_PrivateData {
CPDF_FormField* GetField(FX_DWORD index,
const CFX_WideString& csFieldName = L"");
- void GetAllFieldNames(CFX_WideStringArray& allFieldNames);
-
CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage,
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 95927c38f2..7099e28447 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -545,9 +545,9 @@ class CFX_ObjectArray : public CFX_BasicArray {
CFX_BasicArray::SetSize(0);
}
};
+#ifdef PDF_ENABLE_XFA
typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray;
typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
-#ifdef PDF_ENABLE_XFA
class CFX_BaseSegmentedArray {
public:
CFX_BaseSegmentedArray(int unit_size = 1,
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h
index f2db4a1dc0..044e949ca4 100644
--- a/core/include/fxge/fx_font.h
+++ b/core/include/fxge/fx_font.h
@@ -9,9 +9,10 @@
#include <map>
#include <memory>
+#include <vector>
#include "core/include/fxcrt/fx_system.h"
-#include "fx_dib.h"
+#include "core/include/fxge/fx_dib.h"
typedef struct FT_FaceRec_* FXFT_Face;
typedef void* FXFT_Library;
@@ -306,7 +307,7 @@ class CFX_FontMapper {
IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; }
void AddInstalledFont(const CFX_ByteString& name, int charset);
void LoadInstalledFonts();
- CFX_ByteStringArray m_InstalledTTFonts;
+ std::vector<CFX_ByteString> m_InstalledTTFonts;
void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) {
m_pFontEnumerator = pFontEnumerator;
}
@@ -325,7 +326,7 @@ class CFX_FontMapper {
int italic_angle);
#endif // PDF_ENABLE_XFA
FX_BOOL IsBuiltinFace(const FXFT_Face face) const;
- int GetFaceSize() const { return m_FaceArray.GetSize(); }
+ int GetFaceSize() const;
CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; }
private:
@@ -344,7 +345,7 @@ class CFX_FontMapper {
FXFT_Face m_MMFaces[MM_FACE_COUNT];
CFX_ByteString m_LastFamily;
CFX_DWordArray m_CharsetArray;
- CFX_ByteStringArray m_FaceArray;
+ std::vector<CFX_ByteString> m_FaceArray;
IFX_SystemFontInfo* m_pFontInfo;
FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT];
IFX_FontEnumerator* m_pFontEnumerator;
@@ -417,12 +418,9 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
FX_BOOL GetFontCharset(void* hFont, int& charset) override;
protected:
- std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList;
- CFX_ByteStringArray m_PathList;
- CFX_FontMapper* m_pMapper;
- void ScanPath(CFX_ByteString& path);
- void ScanFile(CFX_ByteString& path);
- void ReportFace(CFX_ByteString& path,
+ void ScanPath(const CFX_ByteString& path);
+ void ScanFile(const CFX_ByteString& path);
+ void ReportFace(const CFX_ByteString& path,
FXSYS_FILE* pFile,
FX_DWORD filesize,
FX_DWORD offset);
@@ -433,7 +431,12 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
int pitch_family,
const FX_CHAR* family,
FX_BOOL bMatchName);
+
+ std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList;
+ std::vector<CFX_ByteString> m_PathList;
+ CFX_FontMapper* m_pMapper;
};
+
class CFX_CountedFaceCache {
public:
CFX_FaceCache* m_Obj;
diff --git a/core/include/fxge/fx_ge.h b/core/include/fxge/fx_ge.h
index 01a1c72a8f..ebcdea1483 100644
--- a/core/include/fxge/fx_ge.h
+++ b/core/include/fxge/fx_ge.h
@@ -7,8 +7,8 @@
#ifndef CORE_INCLUDE_FXGE_FX_GE_H_
#define CORE_INCLUDE_FXGE_FX_GE_H_
-#include "fx_dib.h"
-#include "fx_font.h"
+#include "core/include/fxge/fx_dib.h"
+#include "core/include/fxge/fx_font.h"
class CFX_Font;
class CFX_FontMgr;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index d3ef4d738a..7c1c6b1f53 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -10,6 +10,7 @@
#include "core/include/fpdfapi/fpdf_parser.h"
#include "core/include/fxcodec/fx_codec.h"
#include "core/include/fxcrt/fx_ext.h"
+#include "third_party/base/stl_util.h"
#define _STREAM_MAX_SIZE_ 20 * 1024 * 1024
@@ -339,7 +340,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
CPDF_Object* pParams =
pDict ? pDict->GetElementValue("DecodeParms") : nullptr;
- CFX_ByteStringArray DecoderList;
+ std::vector<CFX_ByteString> DecoderList;
CFX_ArrayTemplate<CPDF_Object*> ParamList;
if (CPDF_Array* pDecoders = pDecoder->AsArray()) {
CPDF_Array* pParamsArray = ToArray(pParams);
@@ -347,19 +348,18 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
pParams = nullptr;
for (FX_DWORD i = 0; i < pDecoders->GetCount(); i++) {
- CFX_ByteStringC str = pDecoders->GetConstStringAt(i);
- DecoderList.Add(str);
+ DecoderList.push_back(pDecoders->GetConstStringAt(i));
ParamList.Add(pParams ? pParamsArray->GetDictAt(i) : nullptr);
}
} else {
- DecoderList.Add(pDecoder->GetConstString());
+ DecoderList.push_back(pDecoder->GetConstString());
ParamList.Add(pParams ? pParams->GetDict() : nullptr);
}
uint8_t* last_buf = (uint8_t*)src_buf;
FX_DWORD last_size = src_size;
- for (int i = 0; i < DecoderList.GetSize(); i++) {
- int estimated_size =
- i == DecoderList.GetSize() - 1 ? last_estimated_size : 0;
+ int nSize = pdfium::CollectionSize<int>(DecoderList);
+ for (int i = 0; i < nSize; i++) {
+ int estimated_size = i == nSize - 1 ? last_estimated_size : 0;
CFX_ByteString decoder = DecoderList[i];
// Use ToDictionary here because we can push nullptr into the ParamList.
CPDF_Dictionary* pParam = ToDictionary(ParamList[i]);
@@ -367,7 +367,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
FX_DWORD new_size = (FX_DWORD)-1;
int offset = -1;
if (decoder == "FlateDecode" || decoder == "Fl") {
- if (bImageAcc && i == DecoderList.GetSize() - 1) {
+ if (bImageAcc && i == nSize - 1) {
ImageEncoding = "FlateDecode";
dest_buf = (uint8_t*)last_buf;
dest_size = last_size;
@@ -384,7 +384,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
} else if (decoder == "ASCIIHexDecode" || decoder == "AHx") {
offset = HexDecode(last_buf, last_size, new_buf, new_size);
} else if (decoder == "RunLengthDecode" || decoder == "RL") {
- if (bImageAcc && i == DecoderList.GetSize() - 1) {
+ if (bImageAcc && i == nSize - 1) {
ImageEncoding = "RunLengthDecode";
dest_buf = (uint8_t*)last_buf;
dest_size = last_size;
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 5cfad3f068..b4735bed41 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -663,17 +663,6 @@ CPDF_FormField* CPDF_InterForm::GetField(FX_DWORD index,
CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
return pNode ? pNode->GetField(index) : nullptr;
}
-void CPDF_InterForm::GetAllFieldNames(CFX_WideStringArray& allFieldNames) {
- allFieldNames.RemoveAll();
- int nCount = m_pFieldTree->m_Root.CountFields();
- for (int i = 0; i < nCount; i++) {
- CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
- if (pField) {
- CFX_WideString full_name = GetFullName(pField->GetFieldDict());
- allFieldNames.Add(full_name);
- }
- }
-}
CPDF_FormField* CPDF_InterForm::GetFieldByDict(
CPDF_Dictionary* pFieldDict) const {
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index b6e39de004..aa13acee8a 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -1988,7 +1988,7 @@ FX_BOOL CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat,
} else {
m_findPreStart = startPos;
}
- m_csFindWhatArray.RemoveAll();
+ m_csFindWhatArray.clear();
int i = 0;
while (i < len) {
if (findwhatStr.GetAt(i) != ' ') {
@@ -1999,9 +1999,9 @@ FX_BOOL CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat,
if (i < len) {
ExtractFindWhat(findwhatStr);
} else {
- m_csFindWhatArray.Add(findwhatStr);
+ m_csFindWhatArray.push_back(findwhatStr);
}
- if (m_csFindWhatArray.GetSize() <= 0) {
+ if (m_csFindWhatArray.empty()) {
return FALSE;
}
m_IsFind = TRUE;
@@ -2027,7 +2027,7 @@ FX_BOOL CPDF_TextPageFind::FindNext() {
m_IsFind = FALSE;
return m_IsFind;
}
- int nCount = m_csFindWhatArray.GetSize();
+ int nCount = pdfium::CollectionSize<int>(m_csFindWhatArray);
int nResultPos = 0;
int nStartPos = 0;
nStartPos = m_findNextStart;
@@ -2102,8 +2102,7 @@ FX_BOOL CPDF_TextPageFind::FindNext() {
}
}
}
- m_resEnd = nResultPos +
- m_csFindWhatArray[m_csFindWhatArray.GetSize() - 1].GetLength() - 1;
+ m_resEnd = nResultPos + m_csFindWhatArray.back().GetLength() - 1;
m_IsFind = TRUE;
int resStart = GetCharIndex(m_resStart);
int resEnd = GetCharIndex(m_resEnd);
@@ -2175,7 +2174,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
ExtractSubString(csWord, findwhat.c_str(), index, TEXT_BLANK_CHAR);
if (csWord.IsEmpty()) {
if (ret) {
- m_csFindWhatArray.Add(CFX_WideString(L""));
+ m_csFindWhatArray.push_back(L"");
index++;
continue;
} else {
@@ -2192,10 +2191,9 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
continue;
}
if (pos > 0) {
- CFX_WideString preStr = csWord.Mid(0, pos);
- m_csFindWhatArray.Add(preStr);
+ m_csFindWhatArray.push_back(csWord.Mid(0, pos));
}
- m_csFindWhatArray.Add(curStr);
+ m_csFindWhatArray.push_back(curStr);
if (pos == csWord.GetLength() - 1) {
csWord.Empty();
break;
@@ -2207,7 +2205,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
pos++;
}
if (!csWord.IsEmpty()) {
- m_csFindWhatArray.Add(csWord);
+ m_csFindWhatArray.push_back(csWord);
}
index++;
}
diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h
index edde651ddb..9b7d654930 100644
--- a/core/src/fpdftext/text_int.h
+++ b/core/src/fpdftext/text_int.h
@@ -186,7 +186,7 @@ class CPDF_TextPageFind : public IPDF_TextPageFind {
CFX_WideString m_strText;
CFX_WideString m_findWhat;
int m_flags;
- CFX_WideStringArray m_csFindWhatArray;
+ std::vector<CFX_WideString> m_csFindWhatArray;
int m_findNextStart;
int m_findPreStart;
FX_BOOL m_bMatchCase;
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index f624d5abd6..b9850f85db 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -724,7 +724,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
}
if (m_CharsetArray.Find((FX_DWORD)charset) == -1) {
m_CharsetArray.Add((FX_DWORD)charset);
- m_FaceArray.Add(name);
+ m_FaceArray.push_back(name);
}
if (name == m_LastFamily) {
return;
@@ -749,11 +749,11 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
CFX_ByteString new_name = GetPSNameFromTT(hFont);
if (!new_name.IsEmpty()) {
new_name.Insert(0, ' ');
- m_InstalledTTFonts.Add(new_name);
+ m_InstalledTTFonts.push_back(new_name);
}
m_pFontInfo->DeleteFont(hFont);
}
- m_InstalledTTFonts.Add(name);
+ m_InstalledTTFonts.push_back(name);
m_LastFamily = name;
}
void CFX_FontMapper::LoadInstalledFonts() {
@@ -773,7 +773,7 @@ CFX_ByteString CFX_FontMapper::MatchInstalledFonts(
const CFX_ByteString& norm_name) {
LoadInstalledFonts();
int i;
- for (i = m_InstalledTTFonts.GetSize() - 1; i >= 0; i--) {
+ for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) {
CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i]);
if (norm1 == norm_name) {
break;
@@ -1288,6 +1288,10 @@ FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(FX_DWORD dwUnicode,
}
#endif // PDF_ENABLE_XFA
+int CFX_FontMapper::GetFaceSize() const {
+ return pdfium::CollectionSize<int>(m_FaceArray);
+}
+
FX_BOOL CFX_FontMapper::IsBuiltinFace(const FXFT_Face face) const {
for (int i = 0; i < MM_FACE_COUNT; ++i) {
if (m_MMFaces[i] == face) {
@@ -1321,19 +1325,19 @@ CFX_FolderFontInfo::~CFX_FolderFontInfo() {
}
}
void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) {
- m_PathList.Add(path);
+ m_PathList.push_back(path);
}
void CFX_FolderFontInfo::Release() {
delete this;
}
FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
m_pMapper = pMapper;
- for (int i = 0; i < m_PathList.GetSize(); i++) {
- ScanPath(m_PathList[i]);
+ for (const auto& path : m_PathList) {
+ ScanPath(path);
}
return TRUE;
}
-void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
+void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) {
void* handle = FX_OpenFolder(path);
if (!handle) {
return;
@@ -1367,7 +1371,7 @@ void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
}
FX_CloseFolder(handle);
}
-void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) {
+void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) {
FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
if (!pFile) {
return;
@@ -1406,7 +1410,7 @@ void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) {
}
FXSYS_fclose(pFile);
}
-void CFX_FolderFontInfo::ReportFace(CFX_ByteString& path,
+void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
FXSYS_FILE* pFile,
FX_DWORD filesize,
FX_DWORD offset) {