diff options
author | tsepez <tsepez@chromium.org> | 2016-10-12 09:38:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-12 09:38:41 -0700 |
commit | 74b8c6ed314cfcc83aea13f028b4231db26e6ff8 (patch) | |
tree | e417f5d3ec4286aa9709354d9418f06eb1b8887b | |
parent | 47cbc06ef6f528e4d30a869ec533d010ee79b064 (diff) | |
download | pdfium-74b8c6ed314cfcc83aea13f028b4231db26e6ff8.tar.xz |
Get rid of CFX_ArrayTemplate<CPDF_Object*>
They won't work with std::unique_ptr down the road, so replace
with std::vector.
Review-Url: https://codereview.chromium.org/2411703003
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 18 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 207 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.h | 16 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.h | 3 | ||||
-rw-r--r-- | fpdfsdk/fpdf_flatten.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffapp.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffdoc.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/xfa_ffapp.h | 3 |
10 files changed, 139 insertions, 158 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 66a47406f5..ad1ffaf687 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -34,21 +34,19 @@ CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage) CPDF_PageContentGenerator::~CPDF_PageContentGenerator() {} -FX_BOOL CPDF_PageContentGenerator::InsertPageObject( - CPDF_PageObject* pPageObject) { - return pPageObject && m_pageObjects.Add(pPageObject); +void CPDF_PageContentGenerator::InsertPageObject(CPDF_PageObject* pPageObject) { + if (pPageObject) + m_pageObjects.push_back(pPageObject); } void CPDF_PageContentGenerator::GenerateContent() { CFX_ByteTextBuf buf; - CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; - for (int i = 0; i < m_pageObjects.GetSize(); ++i) { - CPDF_PageObject* pPageObj = m_pageObjects[i]; - if (!pPageObj || !pPageObj->IsImage()) { - continue; - } - ProcessImage(buf, pPageObj->AsImage()); + for (CPDF_PageObject* pPageObj : m_pageObjects) { + CPDF_ImageObject* pImageObject = pPageObj->AsImage(); + if (pImageObject) + ProcessImage(buf, pImageObject); } + CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; CPDF_Object* pContent = pPageDict ? pPageDict->GetDirectObjectFor("Contents") : nullptr; if (pContent) diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h index 1470ca8e83..ce605f0dfe 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_EDIT_CPDF_PAGECONTENTGENERATOR_H_ #define CORE_FPDFAPI_EDIT_CPDF_PAGECONTENTGENERATOR_H_ +#include <vector> + #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_coordinates.h" @@ -22,7 +24,7 @@ class CPDF_PageContentGenerator { explicit CPDF_PageContentGenerator(CPDF_Page* pPage); ~CPDF_PageContentGenerator(); - FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject); + void InsertPageObject(CPDF_PageObject* pPageObject); void GenerateContent(); void TransformContent(CFX_Matrix& matrix); @@ -37,7 +39,7 @@ class CPDF_PageContentGenerator { CPDF_Page* m_pPage; CPDF_Document* m_pDocument; - CFX_ArrayTemplate<CPDF_PageObject*> m_pageObjects; + std::vector<CPDF_PageObject*> m_pageObjects; }; #endif // CORE_FPDFAPI_EDIT_CPDF_PAGECONTENTGENERATOR_H_ diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index da7f6948a3..e23aa8ecfb 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -80,6 +80,7 @@ CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail, m_bLinearedDataOK = FALSE; m_bSupportHintTable = bSupportHintTable; } + CPDF_DataAvail::~CPDF_DataAvail() { m_pHintTables.reset(); if (m_pLinearized) @@ -91,9 +92,8 @@ CPDF_DataAvail::~CPDF_DataAvail() { if (m_pTrailer) m_pTrailer->Release(); - int iSize = m_arrayAcroforms.GetSize(); - for (int i = 0; i < iSize; ++i) - m_arrayAcroforms.GetAt(i)->Release(); + for (CPDF_Object* pObject : m_arrayAcroforms) + pObject->Release(); } void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) { @@ -125,18 +125,17 @@ uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) { return *it - offset; } -FX_BOOL CPDF_DataAvail::IsObjectsAvail( - CFX_ArrayTemplate<CPDF_Object*>& obj_array, +FX_BOOL CPDF_DataAvail::AreObjectsAvailable( + std::vector<CPDF_Object*>& obj_array, FX_BOOL bParsePage, DownloadHints* pHints, - CFX_ArrayTemplate<CPDF_Object*>& ret_array) { - if (!obj_array.GetSize()) + std::vector<CPDF_Object*>& ret_array) { + if (obj_array.empty()) return TRUE; uint32_t count = 0; - CFX_ArrayTemplate<CPDF_Object*> new_obj_array; - for (int i = 0; i < obj_array.GetSize(); i++) { - CPDF_Object* pObj = obj_array[i]; + std::vector<CPDF_Object*> new_obj_array; + for (CPDF_Object* pObj : obj_array) { if (!pObj) continue; @@ -145,7 +144,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail( case CPDF_Object::ARRAY: { CPDF_Array* pArray = pObj->AsArray(); for (size_t k = 0; k < pArray->GetCount(); ++k) - new_obj_array.Add(pArray->GetObjectAt(k)); + new_obj_array.push_back(pArray->GetObjectAt(k)); } break; case CPDF_Object::STREAM: pObj = pObj->GetDict(); @@ -158,7 +157,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail( const CFX_ByteString& key = it.first; CPDF_Object* value = it.second; if (key != "Parent") - new_obj_array.Add(value); + new_obj_array.push_back(value); } } break; case CPDF_Object::REFERENCE: { @@ -171,36 +170,31 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail( break; if (!IsDataAvail(offset, size, pHints)) { - ret_array.Add(pObj); + ret_array.push_back(pObj); count++; } else if (!pdfium::ContainsKey(m_ObjectSet, dwNum)) { m_ObjectSet.insert(dwNum); CPDF_Object* pReferred = m_pDocument->GetOrParseIndirectObject(pRef->GetRefObjNum()); if (pReferred) - new_obj_array.Add(pReferred); + new_obj_array.push_back(pReferred); } } break; } } if (count > 0) { - for (int i = 0; i < new_obj_array.GetSize(); ++i) { - CPDF_Object* pObj = new_obj_array[i]; - if (CPDF_Reference* pRef = pObj->AsReference()) { - uint32_t dwNum = pRef->GetRefObjNum(); - if (!pdfium::ContainsKey(m_ObjectSet, dwNum)) - ret_array.Add(pObj); - } else { - ret_array.Add(pObj); - } + for (CPDF_Object* pObj : new_obj_array) { + CPDF_Reference* pRef = pObj->AsReference(); + if (pRef && pdfium::ContainsKey(m_ObjectSet, pRef->GetRefObjNum())) + continue; + ret_array.push_back(pObj); } return FALSE; } - obj_array.RemoveAll(); - obj_array.Append(new_obj_array); - return IsObjectsAvail(obj_array, FALSE, pHints, ret_array); + obj_array = new_obj_array; + return AreObjectsAvailable(obj_array, FALSE, pHints, ret_array); } CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail( @@ -220,30 +214,27 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail( } FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(DownloadHints* pHints) { - if (!m_objs_array.GetSize()) { - m_objs_array.RemoveAll(); + if (m_objs_array.empty()) { m_ObjectSet.clear(); - CFX_ArrayTemplate<CPDF_Object*> obj_array; - obj_array.Append(m_arrayAcroforms); - FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); - if (bRet) - m_objs_array.RemoveAll(); - return bRet; - } - - CFX_ArrayTemplate<CPDF_Object*> new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - if (bRet) { - int32_t iSize = m_arrayAcroforms.GetSize(); - for (int32_t i = 0; i < iSize; ++i) { - m_arrayAcroforms.GetAt(i)->Release(); - } - m_arrayAcroforms.RemoveAll(); - } else { - m_objs_array.RemoveAll(); - m_objs_array.Append(new_objs_array); + std::vector<CPDF_Object*> obj_array = m_arrayAcroforms; + if (!AreObjectsAvailable(obj_array, FALSE, pHints, m_objs_array)) + return FALSE; + + m_objs_array.clear(); + return TRUE; + } + + std::vector<CPDF_Object*> new_objs_array; + if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) { + m_objs_array = new_objs_array; + return FALSE; } - return bRet; + + for (CPDF_Object* pObject : m_arrayAcroforms) + pObject->Release(); + + m_arrayAcroforms.clear(); + return TRUE; } FX_BOOL CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) { @@ -262,7 +253,7 @@ FX_BOOL CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) { return FALSE; } - m_arrayAcroforms.Add(m_pAcroForm); + m_arrayAcroforms.push_back(m_pAcroForm); m_docStatus = PDF_DATAAVAIL_PAGETREE; return TRUE; } @@ -515,7 +506,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) { CFX_ByteString type = pObj->GetDict()->GetStringFor("Type"); if (type == "Pages") { - m_PagesArray.Add(pObj); + m_PagesArray.push_back(pObj); continue; } pObj->Release(); @@ -527,27 +518,25 @@ FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) { return FALSE; } - uint32_t iPages = m_PagesArray.GetSize(); + uint32_t iPages = m_PagesArray.size(); for (uint32_t i = 0; i < iPages; i++) { - CPDF_Object* pPages = m_PagesArray.GetAt(i); + CPDF_Object* pPages = m_PagesArray[i]; if (!pPages) continue; if (!GetPageKids(m_pCurrentParser, pPages)) { pPages->Release(); - while (++i < iPages) { - pPages = m_PagesArray.GetAt(i); - pPages->Release(); - } - m_PagesArray.RemoveAll(); + while (++i < iPages) + m_PagesArray[i]->Release(); + m_PagesArray.clear(); m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } pPages->Release(); } - m_PagesArray.RemoveAll(); + m_PagesArray.clear(); if (!m_PageObjList.GetSize()) m_docStatus = PDF_DATAAVAIL_DONE; return TRUE; @@ -1535,8 +1524,7 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData( FX_BOOL CPDF_DataAvail::CheckPageAnnots(uint32_t dwPage, DownloadHints* pHints) { - if (!m_objs_array.GetSize()) { - m_objs_array.RemoveAll(); + if (m_objs_array.empty()) { m_ObjectSet.clear(); FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage); @@ -1548,23 +1536,22 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(uint32_t dwPage, if (!pAnnots) return TRUE; - CFX_ArrayTemplate<CPDF_Object*> obj_array; - obj_array.Add(pAnnots); - - FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); - if (bRet) - m_objs_array.RemoveAll(); + std::vector<CPDF_Object*> obj_array; + obj_array.push_back(pAnnots); + if (!AreObjectsAvailable(obj_array, FALSE, pHints, m_objs_array)) + return FALSE; - return bRet; + m_objs_array.clear(); + return TRUE; } - CFX_ArrayTemplate<CPDF_Object*> new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - m_objs_array.RemoveAll(); - if (!bRet) - m_objs_array.Append(new_objs_array); - - return bRet; + std::vector<CPDF_Object*> new_objs_array; + if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) { + m_objs_array = new_objs_array; + return FALSE; + } + m_objs_array.clear(); + return TRUE; } CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage( @@ -1615,7 +1602,7 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( m_bPageLoadedOK = FALSE; m_bAnnotsLoad = FALSE; m_bNeedDownLoadResource = FALSE; - m_objs_array.RemoveAll(); + m_objs_array.clear(); m_ObjectSet.clear(); } @@ -1671,8 +1658,7 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( } if (!m_bPageLoadedOK) { - if (!m_objs_array.GetSize()) { - m_objs_array.RemoveAll(); + if (m_objs_array.empty()) { m_ObjectSet.clear(); FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage); @@ -1682,24 +1668,20 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( return DataAvailable; } - CFX_ArrayTemplate<CPDF_Object*> obj_array; - obj_array.Add(m_pPageDict); - FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); - if (!bRet) + std::vector<CPDF_Object*> obj_array; + obj_array.push_back(m_pPageDict); + if (!AreObjectsAvailable(obj_array, TRUE, pHints, m_objs_array)) return DataNotAvailable; - m_objs_array.RemoveAll(); + m_objs_array.clear(); } else { - CFX_ArrayTemplate<CPDF_Object*> new_objs_array; - FX_BOOL bRet = - IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - - m_objs_array.RemoveAll(); - if (!bRet) { - m_objs_array.Append(new_objs_array); + std::vector<CPDF_Object*> new_objs_array; + if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) { + m_objs_array = new_objs_array; return DataNotAvailable; } } + m_objs_array.clear(); m_bPageLoadedOK = TRUE; } @@ -1731,23 +1713,22 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( } FX_BOOL CPDF_DataAvail::CheckResources(DownloadHints* pHints) { - if (!m_objs_array.GetSize()) { - m_objs_array.RemoveAll(); - CFX_ArrayTemplate<CPDF_Object*> obj_array; - obj_array.Add(m_pPageResource); - - FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); - if (bRet) - m_objs_array.RemoveAll(); - return bRet; - } - - CFX_ArrayTemplate<CPDF_Object*> new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - m_objs_array.RemoveAll(); - if (!bRet) - m_objs_array.Append(new_objs_array); - return bRet; + if (m_objs_array.empty()) { + std::vector<CPDF_Object*> obj_array; + obj_array.push_back(m_pPageResource); + if (!AreObjectsAvailable(obj_array, TRUE, pHints, m_objs_array)) + return FALSE; + + m_objs_array.clear(); + return TRUE; + } + std::vector<CPDF_Object*> new_objs_array; + if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) { + m_objs_array = new_objs_array; + return FALSE; + } + m_objs_array.clear(); + return TRUE; } void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, @@ -1820,18 +1801,18 @@ CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( if (nDocStatus == DataNotAvailable) return FormNotAvailable; - if (!m_objs_array.GetSize()) - m_objs_array.Add(pAcroForm->GetDict()); + if (m_objs_array.empty()) + m_objs_array.push_back(pAcroForm->GetDict()); m_bLinearizedFormParamLoad = TRUE; } - CFX_ArrayTemplate<CPDF_Object*> new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - m_objs_array.RemoveAll(); - if (!bRet) { - m_objs_array.Append(new_objs_array); + std::vector<CPDF_Object*> new_objs_array; + if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) { + m_objs_array = new_objs_array; return FormNotAvailable; } + + m_objs_array.clear(); return FormAvailable; } diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index f4fb753d1d..fe5c481af2 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_PARSER_CPDF_DATA_AVAIL_H_ #define CORE_FPDFAPI_PARSER_CPDF_DATA_AVAIL_H_ +#include <vector> + #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/cpdf_syntax_parser.h" #include "core/fxcrt/fx_basic.h" @@ -124,10 +126,10 @@ class CPDF_DataAvail final { static const int kMaxPageRecursionDepth = 1024; uint32_t GetObjectSize(uint32_t objnum, FX_FILESIZE& offset); - FX_BOOL IsObjectsAvail(CFX_ArrayTemplate<CPDF_Object*>& obj_array, - FX_BOOL bParsePage, - DownloadHints* pHints, - CFX_ArrayTemplate<CPDF_Object*>& ret_array); + FX_BOOL AreObjectsAvailable(std::vector<CPDF_Object*>& obj_array, + FX_BOOL bParsePage, + DownloadHints* pHints, + std::vector<CPDF_Object*>& ret_array); FX_BOOL CheckDocStatus(DownloadHints* pHints); FX_BOOL CheckHeader(DownloadHints* pHints); FX_BOOL CheckFirstPage(DownloadHints* pHints); @@ -209,7 +211,7 @@ class CPDF_DataAvail final { FX_FILESIZE m_dwFileLen; CPDF_Document* m_pDocument; std::set<uint32_t> m_ObjectSet; - CFX_ArrayTemplate<CPDF_Object*> m_objs_array; + std::vector<CPDF_Object*> m_objs_array; FX_FILESIZE m_Pos; FX_FILESIZE m_bufferOffset; uint32_t m_bufferSize; @@ -232,13 +234,13 @@ class CPDF_DataAvail final { uint32_t m_dwAcroFormObjNum; FX_BOOL m_bAcroFormLoad; CPDF_Object* m_pAcroForm; - CFX_ArrayTemplate<CPDF_Object*> m_arrayAcroforms; + std::vector<CPDF_Object*> m_arrayAcroforms; CPDF_Dictionary* m_pPageDict; CPDF_Object* m_pPageResource; FX_BOOL m_bNeedDownLoadResource; FX_BOOL m_bPageLoadedOK; FX_BOOL m_bLinearizedFormParamLoad; - CFX_ArrayTemplate<CPDF_Object*> m_PagesArray; + std::vector<CPDF_Object*> m_PagesArray; uint32_t m_dwEncryptObjNum; FX_FILESIZE m_dwPrevXRefOffset; FX_BOOL m_bTotalLoadPageTree; diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index f4cde0c198..c29ae18da2 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -72,9 +72,8 @@ CPDF_Parser::~CPDF_Parser() { m_pSyntax->m_pFileAccess = nullptr; } - int32_t iLen = m_Trailers.GetSize(); - for (int32_t i = 0; i < iLen; ++i) { - if (CPDF_Dictionary* trailer = m_Trailers.GetAt(i)) + for (CPDF_Dictionary* trailer : m_Trailers) { + if (trailer) trailer->Release(); } @@ -368,7 +367,7 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) { // SLOW ... XRefStreamList.insert(XRefStreamList.begin(), pDict->GetIntegerFor("XRefStm")); - m_Trailers.Add(pDict.release()); + m_Trailers.push_back(pDict.release()); } for (size_t i = 0; i < CrossRefList.size(); ++i) { @@ -423,7 +422,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, // SLOW ... XRefStreamList.insert(XRefStreamList.begin(), pDict->GetIntegerFor("XRefStm")); - m_Trailers.Add(pDict.release()); + m_Trailers.push_back(pDict.release()); } for (size_t i = 1; i < CrossRefList.size(); ++i) { @@ -992,7 +991,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { for (auto& it : m_ObjectInfo) it.second.type = 0; } else { - m_Trailers.Add(pNewTrailer); + m_Trailers.push_back(pNewTrailer); } std::vector<std::pair<int32_t, int32_t>> arrIndex; diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h index 876ea6cb3d..83b591f3b2 100644 --- a/core/fpdfapi/parser/cpdf_parser.h +++ b/core/fpdfapi/parser/cpdf_parser.h @@ -10,6 +10,7 @@ #include <map> #include <memory> #include <set> +#include <vector> #include "core/fxcrt/fx_basic.h" @@ -153,7 +154,7 @@ class CPDF_Parser { std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler; CFX_ByteString m_Password; std::set<FX_FILESIZE> m_SortedOffset; - CFX_ArrayTemplate<CPDF_Dictionary*> m_Trailers; + std::vector<CPDF_Dictionary*> m_Trailers; bool m_bVersionUpdated; CPDF_Object* m_pLinearized; uint32_t m_dwFirstPageNo; diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp index 251da34d39..4be0135da9 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp @@ -17,8 +17,8 @@ #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fpdfdoc/cpdf_annot.h" #include "fpdfsdk/fsdk_define.h" +#include "third_party/base/stl_util.h" -typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; typedef CFX_ArrayTemplate<CFX_FloatRect> CPDF_RectArray; enum FPDF_TYPE { MAX, MIN }; @@ -65,7 +65,7 @@ void GetContentsRect(CPDF_Document* pDoc, void ParserStream(CPDF_Dictionary* pPageDic, CPDF_Dictionary* pStream, CPDF_RectArray* pRectArray, - CPDF_ObjectArray* pObjectArray) { + std::vector<CPDF_Dictionary*>* pObjectArray) { if (!pStream) return; CFX_FloatRect rect; @@ -77,13 +77,13 @@ void ParserStream(CPDF_Dictionary* pPageDic, if (IsValiableRect(rect, pPageDic->GetRectFor("MediaBox"))) pRectArray->Add(rect); - pObjectArray->Add(pStream); + pObjectArray->push_back(pStream); } int ParserAnnots(CPDF_Document* pSourceDoc, CPDF_Dictionary* pPageDic, CPDF_RectArray* pRectArray, - CPDF_ObjectArray* pObjectArray, + std::vector<CPDF_Dictionary*>* pObjectArray, int nUsage) { if (!pSourceDoc || !pPageDic) return FLATTEN_FAIL; @@ -261,7 +261,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { return FLATTEN_FAIL; } - CPDF_ObjectArray ObjectArray; + std::vector<CPDF_Dictionary*> ObjectArray; CPDF_RectArray RectArray; int iRet = FLATTEN_FAIL; @@ -329,7 +329,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { } CFX_ByteString key = ""; - int nStreams = ObjectArray.GetSize(); + int nStreams = pdfium::CollectionSize<int>(ObjectArray); if (nStreams > 0) { for (int iKey = 0; /*iKey < 100*/; iKey++) { @@ -359,7 +359,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { } for (int i = 0; i < nStreams; i++) { - CPDF_Dictionary* pAnnotDic = ObjectArray.GetAt(i); + CPDF_Dictionary* pAnnotDic = ObjectArray[i]; if (!pAnnotDic) continue; @@ -453,8 +453,6 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { } pPageDict->RemoveFor("Annots"); - ObjectArray.RemoveAll(); RectArray.RemoveAll(); - return FLATTEN_SUCCESS; } diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index bc16ddf101..6bedcd41a0 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -18,11 +18,10 @@ #include "xfa/fxfa/xfa_ffwidgethandler.h" #include "xfa/fxfa/xfa_fontmgr.h" -CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) { - int32_t iCount = streams.GetSize(); - for (int32_t i = 0; i < iCount; i++) { +CXFA_FileRead::CXFA_FileRead(const std::vector<CPDF_Stream*>& streams) { + for (CPDF_Stream* pStream : streams) { CPDF_StreamAcc& acc = m_Data.Add(); - acc.LoadAllData(streams[i]); + acc.LoadAllData(pStream); } } diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 5e39adc0b3..25c78bd14b 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -311,19 +311,19 @@ FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { if (!pElementXFA) return FALSE; - CFX_ArrayTemplate<CPDF_Stream*> xfaStreams; + std::vector<CPDF_Stream*> xfaStreams; if (pElementXFA->IsArray()) { CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; for (size_t i = 0; i < pXFAArray->GetCount() / 2; i++) { if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) - xfaStreams.Add(pStream); + xfaStreams.push_back(pStream); } } else if (pElementXFA->IsStream()) { - xfaStreams.Add((CPDF_Stream*)pElementXFA); + xfaStreams.push_back((CPDF_Stream*)pElementXFA); } - if (xfaStreams.GetSize() < 1) { + if (xfaStreams.empty()) return FALSE; - } + IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams); m_pPDFDoc = pPDFDoc; if (m_pStream) { diff --git a/xfa/fxfa/xfa_ffapp.h b/xfa/fxfa/xfa_ffapp.h index b3353616de..dd670b83d7 100644 --- a/xfa/fxfa/xfa_ffapp.h +++ b/xfa/fxfa/xfa_ffapp.h @@ -8,6 +8,7 @@ #define XFA_FXFA_XFA_FFAPP_H_ #include <memory> +#include <vector> #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" @@ -25,7 +26,7 @@ class IFWL_AdapterTimerMgr; class CXFA_FileRead : public IFX_FileRead { public: - explicit CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams); + explicit CXFA_FileRead(const std::vector<CPDF_Stream*>& streams); ~CXFA_FileRead() override; // IFX_FileRead |