diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 18 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_form.cpp | 11 | ||||
-rw-r--r-- | core/src/fpdftext/fpdf_text_int.cpp | 20 | ||||
-rw-r--r-- | core/src/fpdftext/text_int.h | 2 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge_fontmap.cpp | 24 |
5 files changed, 33 insertions, 42 deletions
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) { |