diff options
Diffstat (limited to 'core/fpdfapi')
29 files changed, 80 insertions, 82 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp b/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp index b3fe4ae39a..f9057dbe32 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp @@ -80,7 +80,7 @@ size_t CPDF_PageContentManager::AddStream(std::ostringstream* buf) { // If there is an array, just add the new stream to it, at the last position. if (contents_array_) { contents_array_->Add(new_stream->MakeReference(doc_.Get())); - return contents_array_->GetCount() - 1; + return contents_array_->size() - 1; } // There were no Contents, so add the new stream as the single Content stream. @@ -113,7 +113,7 @@ void CPDF_PageContentManager::ExecuteScheduledRemovals() { } else if (contents_array_) { // Initialize a vector with the old stream indexes. This will be used to // build a map from the old to the new indexes. - std::vector<size_t> streams_left(contents_array_->GetCount()); + std::vector<size_t> streams_left(contents_array_->size()); std::iota(streams_left.begin(), streams_left.end(), 0); // In reverse order so as to not change the indexes in the middle of the diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 03442b5897..41627c069f 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -333,7 +333,7 @@ bool CPDF_CIDFont::Load() { } const CPDF_Array* pFonts = m_pFontDict->GetArrayFor("DescendantFonts"); - if (!pFonts || pFonts->GetCount() != 1) + if (!pFonts || pFonts->size() != 1) return false; const CPDF_Dictionary* pCIDFontDict = pFonts->GetDictAt(0); @@ -771,7 +771,7 @@ void CPDF_CIDFont::LoadMetricsArray(const CPDF_Array* pArray, int iCurElement = 0; uint32_t first_code = 0; uint32_t last_code = 0; - for (size_t i = 0; i < pArray->GetCount(); i++) { + for (size_t i = 0; i < pArray->size(); i++) { const CPDF_Object* pObj = pArray->GetDirectObjectAt(i); if (!pObj) continue; @@ -780,12 +780,12 @@ void CPDF_CIDFont::LoadMetricsArray(const CPDF_Array* pArray, if (width_status != 1) return; if (first_code > - std::numeric_limits<uint32_t>::max() - pObjArray->GetCount()) { + std::numeric_limits<uint32_t>::max() - pObjArray->size()) { width_status = 0; continue; } - for (size_t j = 0; j < pObjArray->GetCount(); j += nElements) { + for (size_t j = 0; j < pObjArray->size(); j += nElements) { result->push_back(first_code); result->push_back(first_code); for (int k = 0; k < nElements; k++) diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp index dd1a1f33f3..38deef7cc8 100644 --- a/core/fpdfapi/font/cpdf_simplefont.cpp +++ b/core/fpdfapi/font/cpdf_simplefont.cpp @@ -146,7 +146,7 @@ void CPDF_SimpleFont::LoadPDFEncoding(bool bEmbedded, bool bTrueType) { m_CharNames.resize(256); uint32_t cur_code = 0; - for (uint32_t i = 0; i < pDiffs->GetCount(); i++) { + for (uint32_t i = 0; i < pDiffs->size(); i++) { const CPDF_Object* pElement = pDiffs->GetDirectObjectAt(i); if (!pElement) continue; @@ -202,8 +202,8 @@ bool CPDF_SimpleFont::LoadCommon() { size_t width_start = m_pFontDict->GetIntegerFor("FirstChar", 0); size_t width_end = m_pFontDict->GetIntegerFor("LastChar", 0); if (width_start <= 255) { - if (width_end == 0 || width_end >= width_start + pWidthArray->GetCount()) - width_end = width_start + pWidthArray->GetCount() - 1; + if (width_end == 0 || width_end >= width_start + pWidthArray->size()) + width_end = width_start + pWidthArray->size() - 1; if (width_end > 255) width_end = 255; for (size_t i = width_start; i <= width_end; i++) diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp index 5993c1c7cb..1d70c8bb48 100644 --- a/core/fpdfapi/font/cpdf_type3font.cpp +++ b/core/fpdfapi/font/cpdf_type3font.cpp @@ -69,7 +69,7 @@ bool CPDF_Type3Font::Load() { if (StartChar >= 0 && static_cast<size_t>(StartChar) < kCharLimit) { const CPDF_Array* pWidthArray = m_pFontDict->GetArrayFor("Widths"); if (pWidthArray) { - size_t count = std::min(pWidthArray->GetCount(), kCharLimit); + size_t count = std::min(pWidthArray->size(), kCharLimit); count = std::min(count, kCharLimit - StartChar); for (size_t i = 0; i < count; i++) { m_CharWidthL[StartChar + i] = diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index 882b5657d8..2266dec9e8 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -80,7 +80,7 @@ void GetDefaultBlackPoint(float* pPoints) { void GetBlackPoint(const CPDF_Dictionary* pDict, float* pPoints) { const CPDF_Array* pParam = pDict->GetArrayFor("BlackPoint"); - if (!pParam || pParam->GetCount() != kBlackWhitePointCount) { + if (!pParam || pParam->size() != kBlackWhitePointCount) { GetDefaultBlackPoint(pPoints); return; } @@ -97,7 +97,7 @@ void GetBlackPoint(const CPDF_Dictionary* pDict, float* pPoints) { bool GetWhitePoint(const CPDF_Dictionary* pDict, float* pPoints) { const CPDF_Array* pParam = pDict->GetArrayFor("WhitePoint"); - if (!pParam || pParam->GetCount() != kBlackWhitePointCount) + if (!pParam || pParam->size() != kBlackWhitePointCount) return false; for (size_t i = 0; i < kBlackWhitePointCount; ++i) @@ -481,7 +481,7 @@ std::unique_ptr<CPDF_ColorSpace> CPDF_ColorSpace::Load( return nullptr; ByteString familyname = pFamilyObj->GetString(); - if (pArray->GetCount() == 1) + if (pArray->size() == 1) return pdfium::WrapUnique(ColorspaceFromName(familyname)); std::unique_ptr<CPDF_ColorSpace> pCS; @@ -1101,7 +1101,7 @@ CPDF_IndexedCS::~CPDF_IndexedCS() { uint32_t CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, const CPDF_Array* pArray, std::set<const CPDF_Object*>* pVisited) { - if (pArray->GetCount() < 4) + if (pArray->size() < 4) return 0; const CPDF_Object* pBaseObj = pArray->GetDirectObjectAt(1); @@ -1299,7 +1299,7 @@ uint32_t CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) return 0; - return pObj->GetCount(); + return pObj->size(); } bool CPDF_DeviceNCS::GetRGB(const float* pBuf, diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index 3427fe5230..cf31447697 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -52,7 +52,7 @@ CPDF_ContentParser::CPDF_ContentParser(CPDF_Page* pPage) return; } - m_nStreams = pArray->GetCount(); + m_nStreams = pArray->size(); if (m_nStreams == 0) { m_CurrentStage = Stage::kComplete; return; diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index bc1c1c5a60..b41a8466b1 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp @@ -278,7 +278,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceInternal( if (!pArray || pArray->IsEmpty()) return nullptr; - if (pArray->GetCount() == 1) { + if (pArray->size() == 1) { return GetColorSpaceInternal(pArray->GetDirectObjectAt(0), pResources, pVisited, pVisitedInternal); } diff --git a/core/fpdfapi/page/cpdf_expintfunc.cpp b/core/fpdfapi/page/cpdf_expintfunc.cpp index cb83ac2d0b..e04ce1282c 100644 --- a/core/fpdfapi/page/cpdf_expintfunc.cpp +++ b/core/fpdfapi/page/cpdf_expintfunc.cpp @@ -30,7 +30,7 @@ bool CPDF_ExpIntFunc::v_Init(const CPDF_Object* pObj, const CPDF_Array* pArray0 = pDict->GetArrayFor("C0"); if (pArray0 && m_nOutputs == 0) - m_nOutputs = pArray0->GetCount(); + m_nOutputs = pArray0->size(); if (m_nOutputs == 0) m_nOutputs = 1; diff --git a/core/fpdfapi/page/cpdf_function.cpp b/core/fpdfapi/page/cpdf_function.cpp index def72992cd..fc8eb46d73 100644 --- a/core/fpdfapi/page/cpdf_function.cpp +++ b/core/fpdfapi/page/cpdf_function.cpp @@ -85,7 +85,7 @@ bool CPDF_Function::Init(const CPDF_Object* pObj, if (!pDomains) return false; - m_nInputs = pDomains->GetCount() / 2; + m_nInputs = pDomains->size() / 2; if (m_nInputs == 0) return false; @@ -95,7 +95,7 @@ bool CPDF_Function::Init(const CPDF_Object* pObj, m_Domains[i] = pDomains->GetFloatAt(i); const CPDF_Array* pRanges = pDict->GetArrayFor("Range"); - m_nOutputs = pRanges ? pRanges->GetCount() / 2 : 0; + m_nOutputs = pRanges ? pRanges->size() / 2 : 0; // Ranges are required for type 0 and type 4 functions. A non-zero // |m_nOutputs| here implied Ranges meets the requirements. diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp index 5d8e1f2342..dce4c8a7c8 100644 --- a/core/fpdfapi/page/cpdf_meshstream.cpp +++ b/core/fpdfapi/page/cpdf_meshstream.cpp @@ -142,7 +142,7 @@ bool CPDF_MeshStream::Load() { m_nComponents = m_funcs.empty() ? nComponents : 1; const CPDF_Array* pDecode = pDict->GetArrayFor("Decode"); - if (!pDecode || pDecode->GetCount() != 4 + m_nComponents * 2) + if (!pDecode || pDecode->size() != 4 + m_nComponents * 2) return false; m_xmin = pDecode->GetNumberAt(0); diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp index 52f4e1e10a..79ea6f84ec 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.cpp +++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp @@ -72,7 +72,7 @@ bool CPDF_ShadingPattern::Load() { const CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function"); if (pFunc) { if (const CPDF_Array* pArray = pFunc->AsArray()) { - m_pFunctions.resize(std::min<size_t>(pArray->GetCount(), 4)); + m_pFunctions.resize(std::min<size_t>(pArray->size(), 4)); for (size_t i = 0; i < m_pFunctions.size(); ++i) m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); } else { diff --git a/core/fpdfapi/page/cpdf_stitchfunc.cpp b/core/fpdfapi/page/cpdf_stitchfunc.cpp index b400a987c0..40f7c44d72 100644 --- a/core/fpdfapi/page/cpdf_stitchfunc.cpp +++ b/core/fpdfapi/page/cpdf_stitchfunc.cpp @@ -43,14 +43,14 @@ bool CPDF_StitchFunc::v_Init(const CPDF_Object* pObj, if (!pEncodeArray) return false; - const uint32_t nSubs = pFunctionsArray->GetCount(); + const uint32_t nSubs = pFunctionsArray->size(); if (nSubs == 0) return false; // Check array sizes. The checks are slightly relaxed to allow the "Bounds" // and "Encode" arrays to have more than the required number of elements. { - if (pBoundsArray->GetCount() < nSubs - 1) + if (pBoundsArray->size() < nSubs - 1) return false; FX_SAFE_UINT32 nExpectedEncodeSize = nSubs; @@ -58,7 +58,7 @@ bool CPDF_StitchFunc::v_Init(const CPDF_Object* pObj, if (!nExpectedEncodeSize.IsValid()) return false; - if (pEncodeArray->GetCount() < nExpectedEncodeSize.ValueOrDie()) + if (pEncodeArray->size() < nExpectedEncodeSize.ValueOrDie()) return false; } diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index d84d4d62ec..79fa3d2890 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -216,7 +216,7 @@ void ReplaceAbbr(CPDF_Object* pObj) { } case CPDF_Object::ARRAY: { CPDF_Array* pArray = pObj->AsArray(); - for (size_t i = 0; i < pArray->GetCount(); i++) { + for (size_t i = 0; i < pArray->size(); i++) { CPDF_Object* pElement = pArray->GetObjectAt(i); if (pElement->IsName()) { ByteString name = pElement->GetString(); @@ -1286,7 +1286,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { if (!pArray) return; - size_t n = pArray->GetCount(); + size_t n = pArray->size(); size_t nsegs = 0; for (size_t i = 0; i < n; i++) { if (pArray->GetDirectObjectAt(i)->IsString()) diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp index 79be0c8bae..f2eca1be70 100644 --- a/core/fpdfapi/parser/cpdf_array.cpp +++ b/core/fpdfapi/parser/cpdf_array.cpp @@ -236,7 +236,7 @@ bool CPDF_Array::WriteTo(IFX_ArchiveStream* archive, if (!archive->WriteString("[")) return false; - for (size_t i = 0; i < GetCount(); ++i) { + for (size_t i = 0; i < size(); ++i) { if (!GetObjectAt(i)->WriteTo(archive, encryptor)) return false; } diff --git a/core/fpdfapi/parser/cpdf_array.h b/core/fpdfapi/parser/cpdf_array.h index c4686c08e1..0905251382 100644 --- a/core/fpdfapi/parser/cpdf_array.h +++ b/core/fpdfapi/parser/cpdf_array.h @@ -37,7 +37,7 @@ class CPDF_Array final : public CPDF_Object { const CPDF_Encryptor* encryptor) const override; bool IsEmpty() const { return m_Objects.empty(); } - size_t GetCount() const { return m_Objects.size(); } + size_t size() const { return m_Objects.size(); } CPDF_Object* GetObjectAt(size_t index); const CPDF_Object* GetObjectAt(size_t index) const; CPDF_Object* GetDirectObjectAt(size_t index); diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp index 4ce66dcadb..a70f9910ed 100644 --- a/core/fpdfapi/parser/cpdf_array_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp @@ -21,13 +21,13 @@ TEST(cpdf_array, RemoveAt) { for (size_t i = 0; i < 3; ++i) arr->RemoveAt(3); const int expected[] = {1, 2, 3, 7, 8, 9, 10}; - ASSERT_EQ(FX_ArraySize(expected), arr->GetCount()); + ASSERT_EQ(FX_ArraySize(expected), arr->size()); for (size_t i = 0; i < FX_ArraySize(expected); ++i) EXPECT_EQ(expected[i], arr->GetIntegerAt(i)); arr->RemoveAt(4); arr->RemoveAt(4); const int expected2[] = {1, 2, 3, 7, 10}; - ASSERT_EQ(FX_ArraySize(expected2), arr->GetCount()); + ASSERT_EQ(FX_ArraySize(expected2), arr->size()); for (size_t i = 0; i < FX_ArraySize(expected2); ++i) EXPECT_EQ(expected2[i], arr->GetIntegerAt(i)); } @@ -38,19 +38,19 @@ TEST(cpdf_array, RemoveAt) { for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->AddNew<CPDF_Number>(elems[i]); arr->RemoveAt(11); - EXPECT_EQ(FX_ArraySize(elems), arr->GetCount()); + EXPECT_EQ(FX_ArraySize(elems), arr->size()); } } TEST(cpdf_array, Clear) { const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto arr = pdfium::MakeUnique<CPDF_Array>(); - EXPECT_EQ(0U, arr->GetCount()); + EXPECT_EQ(0U, arr->size()); for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->AddNew<CPDF_Number>(elems[i]); - EXPECT_EQ(FX_ArraySize(elems), arr->GetCount()); + EXPECT_EQ(FX_ArraySize(elems), arr->size()); arr->Clear(); - EXPECT_EQ(0U, arr->GetCount()); + EXPECT_EQ(0U, arr->size()); } TEST(cpdf_array, InsertAt) { @@ -59,14 +59,14 @@ TEST(cpdf_array, InsertAt) { auto arr = pdfium::MakeUnique<CPDF_Array>(); for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->InsertNewAt<CPDF_Number>(i, elems[i]); - ASSERT_EQ(FX_ArraySize(elems), arr->GetCount()); + ASSERT_EQ(FX_ArraySize(elems), arr->size()); for (size_t i = 0; i < FX_ArraySize(elems); ++i) EXPECT_EQ(elems[i], arr->GetIntegerAt(i)); arr->InsertNewAt<CPDF_Number>(3, 33); arr->InsertNewAt<CPDF_Number>(6, 55); arr->InsertNewAt<CPDF_Number>(12, 12); const int expected[] = {1, 2, 3, 33, 4, 5, 55, 6, 7, 8, 9, 10, 12}; - ASSERT_EQ(FX_ArraySize(expected), arr->GetCount()); + ASSERT_EQ(FX_ArraySize(expected), arr->size()); for (size_t i = 0; i < FX_ArraySize(expected); ++i) EXPECT_EQ(expected[i], arr->GetIntegerAt(i)); } @@ -79,7 +79,7 @@ TEST(cpdf_array, InsertAt) { for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->InsertNewAt<CPDF_Number>(i, elems[i]); arr->InsertNewAt<CPDF_Number>(10, 10); - ASSERT_EQ(11u, arr->GetCount()); + ASSERT_EQ(11u, arr->size()); for (size_t i = 0; i < FX_ArraySize(elems); ++i) EXPECT_EQ(elems[i], arr->GetIntegerAt(i)); for (size_t i = FX_ArraySize(elems); i < 10; ++i) @@ -96,7 +96,7 @@ TEST(cpdf_array, Clone) { for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->InsertNewAt<CPDF_Number>(i, elems[i]); std::unique_ptr<CPDF_Array> arr2 = ToArray(arr->Clone()); - ASSERT_EQ(arr->GetCount(), arr2->GetCount()); + ASSERT_EQ(arr->size(), arr2->size()); for (size_t i = 0; i < FX_ArraySize(elems); ++i) { // Clone() always create new objects. EXPECT_NE(arr->GetObjectAt(i), arr2->GetObjectAt(i)); @@ -124,14 +124,14 @@ TEST(cpdf_array, Clone) { } arr->InsertAt(i, std::move(arr_elem)); } - ASSERT_EQ(kNumOfRows, arr->GetCount()); + ASSERT_EQ(kNumOfRows, arr->size()); // Not dereferencing reference objects means just creating new references // instead of new copies of direct objects. std::unique_ptr<CPDF_Array> arr1 = ToArray(arr->Clone()); - ASSERT_EQ(arr->GetCount(), arr1->GetCount()); + ASSERT_EQ(arr->size(), arr1->size()); // Dereferencing reference objects creates new copies of direct objects. std::unique_ptr<CPDF_Array> arr2 = ToArray(arr->CloneDirectObject()); - ASSERT_EQ(arr->GetCount(), arr2->GetCount()); + ASSERT_EQ(arr->size(), arr2->size()); for (size_t i = 0; i < kNumOfRows; ++i) { CPDF_Array* arr_elem = arr->GetObjectAt(i)->AsArray(); CPDF_Array* arr1_elem = arr1->GetObjectAt(i)->AsArray(); @@ -156,7 +156,7 @@ TEST(cpdf_array, Clone) { } } arr.reset(); - ASSERT_EQ(kNumOfRows, arr1->GetCount()); + ASSERT_EQ(kNumOfRows, arr1->size()); for (size_t i = 0; i < kNumOfRows; ++i) { for (size_t j = 0; j < kNumOfRowElems; ++j) { // Results from not deferencing reference objects. diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index 904b0ad9fc..c046996498 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -357,7 +357,7 @@ bool CPDF_DataAvail::GetPageKids(CPDF_Object* pPages) { break; case CPDF_Object::ARRAY: { CPDF_Array* pKidsArray = pKids->AsArray(); - for (size_t i = 0; i < pKidsArray->GetCount(); ++i) { + for (size_t i = 0; i < pKidsArray->size(); ++i) { if (CPDF_Reference* pRef = ToReference(pKidsArray->GetObjectAt(i))) m_PageObjList.push_back(pRef->GetRefObjNum()); } @@ -545,7 +545,7 @@ bool CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo, } pPageNode->m_type = PDF_PAGENODE_PAGES; - for (size_t i = 0; i < pArray->GetCount(); ++i) { + for (size_t i = 0; i < pArray->size(); ++i) { CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i)); if (!pKid) continue; @@ -610,7 +610,7 @@ bool CPDF_DataAvail::CheckUnknownPageNode(uint32_t dwPageNo, } case CPDF_Object::ARRAY: { CPDF_Array* pKidsArray = pKids->AsArray(); - for (size_t i = 0; i < pKidsArray->GetCount(); ++i) { + for (size_t i = 0; i < pKidsArray->size(); ++i) { CPDF_Reference* pKid = ToReference(pKidsArray->GetObjectAt(i)); if (!pKid) continue; diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h index a0e678c6fd..2e972d0577 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.h +++ b/core/fpdfapi/parser/cpdf_dictionary.h @@ -41,7 +41,7 @@ class CPDF_Dictionary final : public CPDF_Object { bool WriteTo(IFX_ArchiveStream* archive, const CPDF_Encryptor* encryptor) const override; - size_t GetCount() const { return m_Map.size(); } + size_t size() const { return m_Map.size(); } const CPDF_Object* GetObjectFor(const ByteString& key) const; CPDF_Object* GetObjectFor(const ByteString& key); const CPDF_Object* GetDirectObjectFor(const ByteString& key) const; diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index c82112e044..c2ad8b7553 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -46,7 +46,7 @@ void InsertWidthArrayImpl(std::vector<int> widths, CPDF_Array* pWidthArray) { break; } if (i == widths.size()) { - int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1); + int first = pWidthArray->GetIntegerAt(pWidthArray->size() - 1); pWidthArray->AddNew<CPDF_Number>(first + static_cast<int>(widths.size()) - 1); pWidthArray->AddNew<CPDF_Number>(widths[0]); @@ -99,7 +99,7 @@ int CountPages(CPDF_Dictionary* pPages, if (!pKidList) return 0; count = 0; - for (size_t i = 0; i < pKidList->GetCount(); i++) { + for (size_t i = 0; i < pKidList->size(); i++) { CPDF_Dictionary* pKid = pKidList->GetDictAt(i); if (!pKid || pdfium::ContainsKey(*visited_pages, pKid)) continue; @@ -259,8 +259,7 @@ CPDF_Dictionary* CPDF_Document::TraversePDFPages(int iPage, return nullptr; } CPDF_Dictionary* page = nullptr; - for (size_t i = m_pTreeTraversal[level].second; i < pKidList->GetCount(); - i++) { + for (size_t i = m_pTreeTraversal[level].second; i < pKidList->size(); i++) { if (*nPagesToGo == 0) break; pKidList->ConvertToIndirectObjectAt(i, this); @@ -299,7 +298,7 @@ CPDF_Dictionary* CPDF_Document::TraversePDFPages(int iPage, } } } - if (m_pTreeTraversal[level].second == pKidList->GetCount()) + if (m_pTreeTraversal[level].second == pKidList->size()) m_pTreeTraversal.pop_back(); return page; } @@ -388,7 +387,7 @@ int CPDF_Document::FindPageIndex(const CPDF_Dictionary* pNode, return -1; } - if (count && count == pKidList->GetCount()) { + if (count && count == pKidList->size()) { for (size_t i = 0; i < count; i++) { const CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i)); if (pKid && pKid->GetRefObjNum() == objnum) @@ -396,7 +395,7 @@ int CPDF_Document::FindPageIndex(const CPDF_Dictionary* pNode, } } - for (size_t i = 0; i < pKidList->GetCount(); i++) { + for (size_t i = 0; i < pKidList->size(); i++) { const CPDF_Dictionary* pKid = pKidList->GetDictAt(i); if (!pKid || pKid == pNode) continue; @@ -527,7 +526,7 @@ bool CPDF_Document::InsertDeletePDFPage(CPDF_Dictionary* pPages, if (!pKidList) return false; - for (size_t i = 0; i < pKidList->GetCount(); i++) { + for (size_t i = 0; i < pKidList->size(); i++) { CPDF_Dictionary* pKid = pKidList->GetDictAt(i); if (pKid->GetStringFor("Type") == "Page") { if (nPagesToGo != 0) { diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp index daaab5de32..fd726f03bf 100644 --- a/core/fpdfapi/parser/cpdf_document_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp @@ -33,7 +33,7 @@ CPDF_Dictionary* CreatePageTreeNode(std::unique_ptr<CPDF_Array> kids, pageNode->SetNewFor<CPDF_String>("Type", "Pages", false); pageNode->SetNewFor<CPDF_Reference>("Kids", pDoc, pUnowned->GetObjNum()); pageNode->SetNewFor<CPDF_Number>("Count", count); - for (size_t i = 0; i < pUnowned->GetCount(); i++) { + for (size_t i = 0; i < pUnowned->size(); i++) { pUnowned->GetDictAt(i)->SetNewFor<CPDF_Reference>("Parent", pDoc, pageNode->GetObjNum()); } diff --git a/core/fpdfapi/parser/cpdf_linearized_header.cpp b/core/fpdfapi/parser/cpdf_linearized_header.cpp index da7a7ad384..467d7c64dd 100644 --- a/core/fpdfapi/parser/cpdf_linearized_header.cpp +++ b/core/fpdfapi/parser/cpdf_linearized_header.cpp @@ -93,7 +93,7 @@ CPDF_LinearizedHeader::CPDF_LinearizedHeader(const CPDF_Dictionary* pDict, m_szLastXRefOffset(szLastXRefOffset) { const CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H"); const size_t nHintStreamSize = - pHintStreamRange ? pHintStreamRange->GetCount() : 0; + pHintStreamRange ? pHintStreamRange->size() : 0; if (nHintStreamSize == 2 || nHintStreamSize == 4) { m_szHintStart = std::max(pHintStreamRange->GetIntegerAt(0), 0); const FX_SAFE_UINT32 safe_hint_length = pHintStreamRange->GetIntegerAt(1); diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index ca01949c65..e5b322ff42 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -125,9 +125,9 @@ class PDFObjectsTest : public testing::Test { case CPDF_Object::ARRAY: { const CPDF_Array* array1 = obj1->AsArray(); const CPDF_Array* array2 = obj2->AsArray(); - if (array1->GetCount() != array2->GetCount()) + if (array1->size() != array2->size()) return false; - for (size_t i = 0; i < array1->GetCount(); ++i) { + for (size_t i = 0; i < array1->size(); ++i) { if (!Equal(array1->GetObjectAt(i), array2->GetObjectAt(i))) return false; } @@ -136,7 +136,7 @@ class PDFObjectsTest : public testing::Test { case CPDF_Object::DICTIONARY: { const CPDF_Dictionary* dict1 = obj1->AsDictionary(); const CPDF_Dictionary* dict2 = obj2->AsDictionary(); - if (dict1->GetCount() != dict2->GetCount()) + if (dict1->size() != dict2->size()) return false; for (CPDF_Dictionary::const_iterator it = dict1->begin(); it != dict1->end(); ++it) { @@ -667,7 +667,7 @@ TEST(PDFArrayTest, GetTypeAt) { 0, 0, 0, 0, 0, 0, 0}; const float expected_float[] = {0, 0, 0, -1234, 2345, 0.05f, 0, 0, 0, 0, 0, 0, 0, 0}; - for (size_t i = 0; i < arr->GetCount(); ++i) { + for (size_t i = 0; i < arr->size(); ++i) { EXPECT_STREQ(expected_str[i], arr->GetStringAt(i).c_str()); EXPECT_EQ(expected_int[i], arr->GetIntegerAt(i)); EXPECT_EQ(expected_float[i], arr->GetNumberAt(i)); @@ -756,8 +756,8 @@ TEST(PDFArrayTest, AddReferenceAndGetObjectAt) { for (size_t i = 0; i < FX_ArraySize(obj_nums); ++i) EXPECT_EQ(indirect_objs[i], holder->GetOrParseIndirectObject(obj_nums[i])); // Check arrays. - EXPECT_EQ(arr->GetCount(), arr1->GetCount()); - for (size_t i = 0; i < arr->GetCount(); ++i) { + EXPECT_EQ(arr->size(), arr1->size()); + for (size_t i = 0; i < arr->size(); ++i) { EXPECT_EQ(CPDF_Object::REFERENCE, arr->GetObjectAt(i)->GetType()); EXPECT_EQ(indirect_objs[i], arr->GetObjectAt(i)->GetDirect()); EXPECT_EQ(indirect_objs[i], arr->GetDirectObjectAt(i)); @@ -771,7 +771,7 @@ TEST(PDFArrayTest, CloneDirectObject) { CPDF_IndirectObjectHolder objects_holder; auto array = pdfium::MakeUnique<CPDF_Array>(); array->AddNew<CPDF_Reference>(&objects_holder, 1234); - ASSERT_EQ(1U, array->GetCount()); + ASSERT_EQ(1U, array->size()); CPDF_Object* obj = array->GetObjectAt(0); ASSERT_TRUE(obj); EXPECT_TRUE(obj->IsReference()); @@ -782,7 +782,7 @@ TEST(PDFArrayTest, CloneDirectObject) { std::unique_ptr<CPDF_Array> cloned_array = ToArray(std::move(cloned_array_object)); - ASSERT_EQ(0U, cloned_array->GetCount()); + ASSERT_EQ(0U, cloned_array->size()); CPDF_Object* cloned_obj = cloned_array->GetObjectAt(0); EXPECT_FALSE(cloned_obj); } @@ -878,7 +878,7 @@ TEST(PDFDictionaryTest, CloneDirectObject) { CPDF_IndirectObjectHolder objects_holder; auto dict = pdfium::MakeUnique<CPDF_Dictionary>(); dict->SetNewFor<CPDF_Reference>("foo", &objects_holder, 1234); - ASSERT_EQ(1U, dict->GetCount()); + ASSERT_EQ(1U, dict->size()); CPDF_Object* obj = dict->GetObjectFor("foo"); ASSERT_TRUE(obj); EXPECT_TRUE(obj->IsReference()); @@ -889,7 +889,7 @@ TEST(PDFDictionaryTest, CloneDirectObject) { std::unique_ptr<CPDF_Dictionary> cloned_dict = ToDictionary(std::move(cloned_dict_object)); - ASSERT_EQ(0U, cloned_dict->GetCount()); + ASSERT_EQ(0U, cloned_dict->size()); CPDF_Object* cloned_obj = cloned_dict->GetObjectFor("foo"); EXPECT_FALSE(cloned_obj); } @@ -906,7 +906,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { std::unique_ptr<CPDF_Array> cloned_array = ToArray(arr_obj->Clone()); // Cloned object should be the same as the original. ASSERT_TRUE(cloned_array); - EXPECT_EQ(1u, cloned_array->GetCount()); + EXPECT_EQ(1u, cloned_array->size()); CPDF_Object* cloned_dict = cloned_array->GetObjectAt(0); ASSERT_TRUE(cloned_dict); ASSERT_TRUE(cloned_dict->IsDictionary()); @@ -953,7 +953,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { CPDF_Object* cloned_arr = cloned_dict->GetObjectFor("arr"); ASSERT_TRUE(cloned_arr); ASSERT_TRUE(cloned_arr->IsArray()); - EXPECT_EQ(0U, cloned_arr->AsArray()->GetCount()); + EXPECT_EQ(0U, cloned_arr->AsArray()->size()); // Recursively referenced object is not cloned. EXPECT_EQ(nullptr, cloned_arr->AsArray()->GetObjectAt(0)); } diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 32629bc873..08d5a3358d 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -688,7 +688,7 @@ bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { std::vector<std::pair<int32_t, int32_t>> arrIndex; CPDF_Array* pArray = pDict->GetArrayFor("Index"); if (pArray) { - for (size_t i = 0; i < pArray->GetCount() / 2; i++) { + for (size_t i = 0; i < pArray->size() / 2; i++) { CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2); CPDF_Object* pCountObj = pArray->GetObjectAt(i * 2 + 1); @@ -710,7 +710,7 @@ bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { std::vector<uint32_t> WidthArray; FX_SAFE_UINT32 dwAccWidth = 0; - for (size_t i = 0; i < pArray->GetCount(); ++i) { + for (size_t i = 0; i < pArray->size(); ++i) { WidthArray.push_back(pArray->GetIntegerAt(i)); dwAccWidth += WidthArray[i]; } diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index a581dcc44f..99b6154e8d 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -89,7 +89,7 @@ const uint16_t PDFDocEncoding[256] = { 0x00fc, 0x00fd, 0x00fe, 0x00ff}; bool ValidateDecoderPipeline(const CPDF_Array* pDecoders) { - size_t count = pDecoders->GetCount(); + size_t count = pDecoders->size(); if (count <= 1) return true; @@ -379,7 +379,7 @@ bool PDF_DataDecode(pdfium::span<const uint8_t> src_span, return false; const CPDF_Array* pParamsArray = ToArray(pParams); - for (size_t i = 0; i < pDecoders->GetCount(); ++i) { + for (size_t i = 0; i < pDecoders->size(); ++i) { DecoderArray.push_back( {pDecoders->GetStringAt(i), pParamsArray ? pParamsArray->GetDictAt(i) : nullptr}); diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index 83c967d8c2..4cd02f009e 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -180,7 +180,7 @@ std::ostream& operator<<(std::ostream& buf, const CPDF_Object* pObj) { case CPDF_Object::ARRAY: { const CPDF_Array* p = pObj->AsArray(); buf << "["; - for (size_t i = 0; i < p->GetCount(); i++) { + for (size_t i = 0; i < p->size(); i++) { const CPDF_Object* pElement = p->GetObjectAt(i); if (pElement && !pElement->IsInline()) { buf << " " << pElement->GetObjNum() << " 0 R"; diff --git a/core/fpdfapi/render/cpdf_dibbase.cpp b/core/fpdfapi/render/cpdf_dibbase.cpp index 3557672e81..b95c14b59f 100644 --- a/core/fpdfapi/render/cpdf_dibbase.cpp +++ b/core/fpdfapi/render/cpdf_dibbase.cpp @@ -357,7 +357,7 @@ bool CPDF_DIBBase::LoadColorInfo(const CPDF_Dictionary* pFormResources, if (pFilter->IsName()) { filter = pFilter->GetString(); } else if (const CPDF_Array* pArray = pFilter->AsArray()) { - filter = pArray->GetStringAt(pArray->GetCount() - 1); + filter = pArray->GetStringAt(pArray->size() - 1); } if (filter == "JPXDecode") { @@ -441,7 +441,7 @@ bool CPDF_DIBBase::GetDecodeAndMaskArray(bool* bDefaultDecode, return true; if (const CPDF_Array* pArray = pMask->AsArray()) { - if (pArray->GetCount() >= m_nComponents * 2) { + if (pArray->size() >= m_nComponents * 2) { for (uint32_t i = 0; i < m_nComponents; i++) { int min_num = pArray->GetIntegerAt(i * 2); int max_num = pArray->GetIntegerAt(i * 2 + 1); @@ -825,7 +825,7 @@ void CPDF_DIBBase::ValidateDictParam() { m_bpc = 8; } } else if (const CPDF_Array* pArray = pFilter->AsArray()) { - ByteString filter = pArray->GetStringAt(pArray->GetCount() - 1); + ByteString filter = pArray->GetStringAt(pArray->size() - 1); if (filter == "CCITTFaxDecode" || filter == "JBIG2Decode") { m_bpc = 1; m_nComponents = 1; diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp index c86eb9b147..fb54e147fa 100644 --- a/core/fpdfapi/render/cpdf_docrenderdata.cpp +++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp @@ -75,7 +75,7 @@ RetainPtr<CPDF_TransferFunc> CPDF_DocRenderData::GetTransferFunc( bool bIdentity = true; if (const CPDF_Array* pArray = pObj->AsArray()) { bUniTransfer = false; - if (pArray->GetCount() < 3) + if (pArray->size() < 3) return nullptr; for (uint32_t i = 0; i < 3; ++i) { diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index affe12d6aa..da63f556a7 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -565,7 +565,7 @@ void CPDF_ImageRenderer::HandleFilters() { if (!pArray) return; - for (size_t i = 0; i < pArray->GetCount(); i++) { + for (size_t i = 0; i < pArray->size(); i++) { ByteString bsDecodeType = pArray->GetStringAt(i); if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { m_Flags |= FXRENDER_IMAGE_LOSSY; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index f77b6c654f..842272bc02 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -2028,8 +2028,7 @@ void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern, FX_ARGB background = 0; if (!pPattern->IsShadingObject() && pDict->KeyExist("Background")) { const CPDF_Array* pBackColor = pDict->GetArrayFor("Background"); - if (pBackColor && - pBackColor->GetCount() >= pColorSpace->CountComponents()) { + if (pBackColor && pBackColor->size() >= pColorSpace->CountComponents()) { std::vector<float> comps(pColorSpace->CountComponents()); for (uint32_t i = 0; i < pColorSpace->CountComponents(); i++) comps[i] = pBackColor->GetNumberAt(i); @@ -2638,7 +2637,7 @@ FX_ARGB CPDF_RenderStatus::GetBackColor(const CPDF_Dictionary* pSMaskDict, uint32_t comps = std::max(8u, pCS->CountComponents()); std::vector<float> floats(comps); - size_t count = std::min<size_t>(8, pBC->GetCount()); + size_t count = std::min<size_t>(8, pBC->size()); for (size_t i = 0; i < count; i++) floats[i] = pBC->GetNumberAt(i); |