diff options
Diffstat (limited to 'core/fpdfapi/fpdf_parser')
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_array.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp | 60 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp | 34 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_document.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp | 22 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp | 34 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_parser.cpp | 30 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/include/cpdf_array.h | 8 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h | 4 |
12 files changed, 110 insertions, 110 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_array.cpp b/core/fpdfapi/fpdf_parser/cpdf_array.cpp index 544469916b..7ea2734745 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_array.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_array.cpp @@ -76,13 +76,13 @@ CFX_Matrix CPDF_Array::GetMatrix() { return matrix; } -CPDF_Object* CPDF_Array::GetElement(uint32_t i) const { +CPDF_Object* CPDF_Array::GetObjectAt(uint32_t i) const { if (i >= (uint32_t)m_Objects.GetSize()) return nullptr; return m_Objects.GetAt(i); } -CPDF_Object* CPDF_Array::GetElementValue(uint32_t i) const { +CPDF_Object* CPDF_Array::GetDirectObjectAt(uint32_t i) const { if (i >= (uint32_t)m_Objects.GetSize()) return nullptr; return m_Objects.GetAt(i)->GetDirect(); @@ -113,7 +113,7 @@ FX_FLOAT CPDF_Array::GetNumberAt(uint32_t i) const { } CPDF_Dictionary* CPDF_Array::GetDictAt(uint32_t i) const { - CPDF_Object* p = GetElementValue(i); + CPDF_Object* p = GetDirectObjectAt(i); if (!p) return NULL; if (CPDF_Dictionary* pDict = p->AsDictionary()) @@ -124,11 +124,11 @@ CPDF_Dictionary* CPDF_Array::GetDictAt(uint32_t i) const { } CPDF_Stream* CPDF_Array::GetStreamAt(uint32_t i) const { - return ToStream(GetElementValue(i)); + return ToStream(GetDirectObjectAt(i)); } CPDF_Array* CPDF_Array::GetArrayAt(uint32_t i) const { - return ToArray(GetElementValue(i)); + return ToArray(GetDirectObjectAt(i)); } void CPDF_Array::RemoveAt(uint32_t i, int nCount) { diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp index 858133d58e..a4b85a34fa 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp @@ -153,7 +153,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail( case CPDF_Object::ARRAY: { CPDF_Array* pArray = pObj->GetArray(); for (uint32_t k = 0; k < pArray->GetCount(); ++k) - new_obj_array.Add(pArray->GetElement(k)); + new_obj_array.Add(pArray->GetObjectAt(k)); } break; case CPDF_Object::STREAM: pObj = pObj->GetDict(); @@ -451,7 +451,7 @@ FX_BOOL CPDF_DataAvail::CheckRoot(IPDF_DataAvail::DownloadHints* pHints) { return FALSE; } - CPDF_Reference* pRef = ToReference(pDict->GetElement("Pages")); + CPDF_Reference* pRef = ToReference(pDict->GetObjectBy("Pages")); if (!pRef) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; @@ -459,7 +459,7 @@ FX_BOOL CPDF_DataAvail::CheckRoot(IPDF_DataAvail::DownloadHints* pHints) { m_PagesObjNum = pRef->GetRefObjNum(); CPDF_Reference* pAcroFormRef = - ToReference(m_pRoot->GetDict()->GetElement("AcroForm")); + ToReference(m_pRoot->GetDict()->GetObjectBy("AcroForm")); if (pAcroFormRef) { m_bHaveAcroForm = TRUE; m_dwAcroFormObjNum = pAcroFormRef->GetRefObjNum(); @@ -477,7 +477,7 @@ FX_BOOL CPDF_DataAvail::CheckRoot(IPDF_DataAvail::DownloadHints* pHints) { FX_BOOL CPDF_DataAvail::PreparePageItem() { CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); CPDF_Reference* pRef = - ToReference(pRoot ? pRoot->GetElement("Pages") : nullptr); + ToReference(pRoot ? pRoot->GetObjectBy("Pages") : nullptr); if (!pRef) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; @@ -515,7 +515,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IPDF_DataAvail::DownloadHints* pHints) { if (pArray) { int32_t iSize = pArray->GetCount(); for (int32_t j = 0; j < iSize; ++j) { - if (CPDF_Reference* pRef = ToReference(pArray->GetElement(j))) + if (CPDF_Reference* pRef = ToReference(pArray->GetObjectAt(j))) UnavailObjList.Add(pRef->GetRefObjNum()); } } @@ -573,7 +573,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { } CPDF_Dictionary* pDict = pPages->GetDict(); - CPDF_Object* pKids = pDict ? pDict->GetElement("Kids") : NULL; + CPDF_Object* pKids = pDict ? pDict->GetObjectBy("Kids") : NULL; if (!pKids) return TRUE; @@ -584,7 +584,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { case CPDF_Object::ARRAY: { CPDF_Array* pKidsArray = pKids->AsArray(); for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) { - if (CPDF_Reference* pRef = ToReference(pKidsArray->GetElement(i))) + if (CPDF_Reference* pRef = ToReference(pKidsArray->GetObjectAt(i))) m_PageObjList.Add(pRef->GetRefObjNum()); } } break; @@ -647,19 +647,19 @@ FX_BOOL CPDF_DataAvail::CheckHeader(IPDF_DataAvail::DownloadHints* pHints) { FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) { CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - CPDF_Object* pEndOffSet = pDict ? pDict->GetElement("E") : NULL; + CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : NULL; if (!pEndOffSet) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } - CPDF_Object* pXRefOffset = pDict ? pDict->GetElement("T") : NULL; + CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectBy("T") : NULL; if (!pXRefOffset) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } - CPDF_Object* pFileLen = pDict ? pDict->GetElement("L") : NULL; + CPDF_Object* pFileLen = pDict ? pDict->GetObjectBy("L") : NULL; if (!pFileLen) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; @@ -746,7 +746,7 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(IPDF_DataAvail::DownloadHints* pHints) { return FALSE; } - int nPageCount = pDict->GetElementValue("N")->GetInteger(); + int nPageCount = pDict->GetDirectObjectBy("N")->GetInteger(); if (nPageCount <= 1) { m_docStatus = PDF_DATAAVAIL_DONE; return TRUE; @@ -754,12 +754,12 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(IPDF_DataAvail::DownloadHints* pHints) { CPDF_Array* pHintStreamRange = pDict->GetArrayBy("H"); FX_FILESIZE szHSStart = - pHintStreamRange->GetElementValue(0) - ? pHintStreamRange->GetElementValue(0)->GetInteger() + pHintStreamRange->GetDirectObjectAt(0) + ? pHintStreamRange->GetDirectObjectAt(0)->GetInteger() : 0; FX_FILESIZE szHSLength = - pHintStreamRange->GetElementValue(1) - ? pHintStreamRange->GetElementValue(1)->GetInteger() + pHintStreamRange->GetDirectObjectAt(1) + ? pHintStreamRange->GetDirectObjectAt(1)->GetInteger() : 0; if (szHSStart < 0 || szHSLength <= 0) { m_docStatus = PDF_DATAAVAIL_ERROR; @@ -864,8 +864,8 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) { return FALSE; CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - if (pDict && pDict->GetElement("Linearized")) { - CPDF_Object* pLen = pDict->GetElement("L"); + if (pDict && pDict->GetObjectBy("Linearized")) { + CPDF_Object* pLen = pDict->GetObjectBy("L"); if (!pLen) return FALSE; @@ -874,7 +874,7 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) { m_bLinearized = TRUE; - if (CPDF_Number* pNo = ToNumber(pDict->GetElement("P"))) + if (CPDF_Number* pNo = ToNumber(pDict->GetObjectBy("P"))) m_dwFirstPageNo = pNo->GetInteger(); return TRUE; @@ -954,7 +954,7 @@ int32_t CPDF_DataAvail::CheckCrossRefStream( } CPDF_Dictionary* pDict = pObj->GetDict(); - CPDF_Name* pName = ToName(pDict ? pDict->GetElement("Type") : nullptr); + CPDF_Name* pName = ToName(pDict ? pDict->GetObjectBy("Type") : nullptr); if (pName) { if (pName->GetString() == "XRef") { m_Pos += m_parser.m_pSyntax->SavePos(); @@ -1204,7 +1204,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IPDF_DataAvail::DownloadHints* pHints) { return FALSE; CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); - CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); + CPDF_Object* pEncrypt = pTrailerDict->GetObjectBy("Encrypt"); if (ToReference(pEncrypt)) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; return TRUE; @@ -1286,7 +1286,7 @@ FX_BOOL CPDF_DataAvail::CheckArrayPageNode( pPageNode->m_type = PDF_PAGENODE_PAGES; for (uint32_t i = 0; i < pArray->GetCount(); ++i) { - CPDF_Reference* pKid = ToReference(pArray->GetElement(i)); + CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i)); if (!pKid) continue; @@ -1333,7 +1333,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode( CFX_ByteString type = pDict->GetStringBy("Type"); if (type == "Pages") { pPageNode->m_type = PDF_PAGENODE_PAGES; - CPDF_Object* pKids = pDict->GetElement("Kids"); + CPDF_Object* pKids = pDict->GetObjectBy("Kids"); if (!pKids) { m_docStatus = PDF_DATAAVAIL_PAGE; return TRUE; @@ -1349,7 +1349,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode( case CPDF_Object::ARRAY: { CPDF_Array* pKidsArray = pKids->AsArray(); for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) { - CPDF_Reference* pKid = ToReference(pKidsArray->GetElement(i)); + CPDF_Reference* pKid = ToReference(pKidsArray->GetObjectAt(i)); if (!pKid) continue; @@ -1544,7 +1544,7 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, if (!pPageDict) return TRUE; - CPDF_Object* pAnnots = pPageDict->GetElement("Annots"); + CPDF_Object* pAnnots = pPageDict->GetObjectBy("Annots"); if (!pAnnots) return TRUE; @@ -1587,7 +1587,7 @@ FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary* pDict) { if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) return FALSE; - CPDF_Object* pParent = pDict->GetElement("Parent"); + CPDF_Object* pParent = pDict->GetObjectBy("Parent"); if (!pParent) return FALSE; @@ -1595,7 +1595,7 @@ FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary* pDict) { if (!pParentDict) return FALSE; - CPDF_Object* pRet = pParentDict->GetElement("Resources"); + CPDF_Object* pRet = pParentDict->GetObjectBy("Resources"); if (pRet) { m_pPageResource = pRet; return TRUE; @@ -1709,7 +1709,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( } if (m_pPageDict && !m_bNeedDownLoadResource) { - m_pPageResource = m_pPageDict->GetElement("Resources"); + m_pPageResource = m_pPageDict->GetObjectBy("Resources"); if (!m_pPageResource) m_bNeedDownLoadResource = HaveResourceAncestor(m_pPageDict); else @@ -1763,7 +1763,7 @@ void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, int CPDF_DataAvail::GetPageCount() const { if (m_pLinearized) { CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - CPDF_Object* pObj = pDict ? pDict->GetElementValue("N") : nullptr; + CPDF_Object* pObj = pDict ? pDict->GetDirectObjectBy("N") : nullptr; return pObj ? pObj->GetInteger() : 0; } return m_pDocument ? m_pDocument->GetPageCount() : 0; @@ -1775,7 +1775,7 @@ CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { if (m_pLinearized) { CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - CPDF_Object* pObj = pDict ? pDict->GetElementValue("P") : nullptr; + CPDF_Object* pObj = pDict ? pDict->GetDirectObjectBy("P") : nullptr; int pageNum = pObj ? pObj->GetInteger() : 0; if (m_pHintTables && index != pageNum) { @@ -1810,7 +1810,7 @@ IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( if (!pRoot) return FormAvailable; - CPDF_Object* pAcroForm = pRoot->GetElement("AcroForm"); + CPDF_Object* pAcroForm = pRoot->GetObjectBy("AcroForm"); if (!pAcroForm) return FormNotExist; diff --git a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp index 75730e5754..5f86a7bbc2 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp @@ -51,32 +51,32 @@ CPDF_Object* CPDF_Dictionary::Clone(FX_BOOL bDirect) const { return pCopy; } -CPDF_Object* CPDF_Dictionary::GetElement(const CFX_ByteStringC& key) const { +CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteStringC& key) const { auto it = m_Map.find(key); if (it == m_Map.end()) return nullptr; return it->second; } -CPDF_Object* CPDF_Dictionary::GetElementValue( +CPDF_Object* CPDF_Dictionary::GetDirectObjectBy( const CFX_ByteStringC& key) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetDirect() : nullptr; } CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetString() : CFX_ByteString(); } CFX_ByteStringC CPDF_Dictionary::GetConstStringBy( const CFX_ByteStringC& key) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetConstString() : CFX_ByteStringC(); } CFX_WideString CPDF_Dictionary::GetUnicodeTextBy( const CFX_ByteStringC& key) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); if (CPDF_Reference* pRef = ToReference(p)) p = pRef->GetDirect(); return p ? p->GetUnicodeText() : CFX_WideString(); @@ -84,40 +84,40 @@ CFX_WideString CPDF_Dictionary::GetUnicodeTextBy( CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key, const CFX_ByteStringC& def) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetString() : CFX_ByteString(def); } CFX_ByteStringC CPDF_Dictionary::GetConstStringBy( const CFX_ByteStringC& key, const CFX_ByteStringC& def) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetConstString() : CFX_ByteStringC(def); } int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetInteger() : 0; } int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key, int def) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetInteger() : def; } FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteStringC& key) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return p ? p->GetNumber() : 0; } FX_BOOL CPDF_Dictionary::GetBooleanBy(const CFX_ByteStringC& key, FX_BOOL bDefault) const { - CPDF_Object* p = GetElement(key); + CPDF_Object* p = GetObjectBy(key); return ToBoolean(p) ? p->GetInteger() : bDefault; } CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteStringC& key) const { - CPDF_Object* p = GetElementValue(key); + CPDF_Object* p = GetDirectObjectBy(key); if (!p) return nullptr; if (CPDF_Dictionary* pDict = p->AsDictionary()) @@ -128,11 +128,11 @@ CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteStringC& key) const { } CPDF_Array* CPDF_Dictionary::GetArrayBy(const CFX_ByteStringC& key) const { - return ToArray(GetElementValue(key)); + return ToArray(GetDirectObjectBy(key)); } CPDF_Stream* CPDF_Dictionary::GetStreamBy(const CFX_ByteStringC& key) const { - return ToStream(GetElementValue(key)); + return ToStream(GetDirectObjectBy(key)); } CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteStringC& key) const { @@ -156,9 +156,9 @@ FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const { } bool CPDF_Dictionary::IsSignatureDict() const { - CPDF_Object* pType = GetElementValue("Type"); + CPDF_Object* pType = GetDirectObjectBy("Type"); if (!pType) - pType = GetElementValue("FT"); + pType = GetDirectObjectBy("FT"); return pType && pType->GetString() == "Sig"; } diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp index 9ed8b3fac6..9058ed6767 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp @@ -115,16 +115,16 @@ void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) { m_ID2 = pIDArray->GetStringAt(1); } uint32_t dwPageCount = 0; - CPDF_Object* pCount = pLinearized->GetElement("N"); + CPDF_Object* pCount = pLinearized->GetObjectBy("N"); if (ToNumber(pCount)) dwPageCount = pCount->GetInteger(); m_PageList.SetSize(dwPageCount); - CPDF_Object* pNo = pLinearized->GetElement("P"); + CPDF_Object* pNo = pLinearized->GetObjectBy("P"); if (ToNumber(pNo)) m_dwFirstPageNo = pNo->GetInteger(); - CPDF_Object* pObjNum = pLinearized->GetElement("O"); + CPDF_Object* pObjNum = pLinearized->GetObjectBy("O"); if (ToNumber(pObjNum)) m_dwFirstPageObjNum = pObjNum->GetInteger(); } @@ -236,7 +236,7 @@ int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode, } if (count && count == pKidList->GetCount()) { for (uint32_t i = 0; i < count; i++) { - if (CPDF_Reference* pKid = ToReference(pKidList->GetElement(i))) { + if (CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i))) { if (pKid->GetRefObjNum() == objnum) { m_PageList.SetAt(index + i, objnum); return index + i; diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp index 147ae37ed0..d81725d06f 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp @@ -102,7 +102,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { // Item 13: Skip Item 13 which has 16 bits. hStream->SkipBits(16); - CPDF_Object* pPageNum = m_pLinearizedDict->GetElementValue("N"); + CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectBy("N"); int nPages = pPageNum ? pPageNum->GetInteger() : 0; if (nPages < 1) return FALSE; @@ -135,12 +135,12 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { dwPageLenArray.Add(safePageLen.ValueOrDie()); } - CPDF_Object* pOffsetE = m_pLinearizedDict->GetElementValue("E"); + CPDF_Object* pOffsetE = m_pLinearizedDict->GetDirectObjectBy("E"); int nOffsetE = pOffsetE ? pOffsetE->GetInteger() : -1; if (nOffsetE < 0) return FALSE; - CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetElementValue("P"); + CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetDirectObjectBy("P"); int nFirstPageNum = pFirstPageNum ? pFirstPageNum->GetInteger() : 0; for (int i = 0; i < nPages; ++i) { if (i == nFirstPageNum) { @@ -256,7 +256,7 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream, // Item 7: The number of bits needed to represent the difference between the // greatest and least length of a shared object group, in bytes. uint32_t dwDeltaGroupLen = hStream->GetBits(16); - CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetElementValue("O"); + CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectBy("O"); int nFirstPageObjNum = pFirstPageObj ? pFirstPageObj->GetInteger() : -1; if (nFirstPageObjNum < 0) return FALSE; @@ -331,10 +331,10 @@ FX_BOOL CPDF_HintTables::GetPagePos(int index, szPageStartPos = m_szPageOffsetArray[index]; szPageLength = GetItemLength(index, m_szPageOffsetArray); - CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetElementValue("P"); + CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetDirectObjectBy("P"); int nFirstPageNum = pFirstPageNum ? pFirstPageNum->GetInteger() : 0; - CPDF_Object* pFirstPageObjNum = m_pLinearizedDict->GetElementValue("O"); + CPDF_Object* pFirstPageObjNum = m_pLinearizedDict->GetDirectObjectBy("O"); if (!pFirstPageObjNum) return FALSE; @@ -360,7 +360,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage( if (!m_pLinearizedDict || !pHints) return IPDF_DataAvail::DataError; - CPDF_Object* pFirstAvailPage = m_pLinearizedDict->GetElementValue("P"); + CPDF_Object* pFirstAvailPage = m_pLinearizedDict->GetDirectObjectBy("P"); int nFirstAvailPage = pFirstAvailPage ? pFirstAvailPage->GetInteger() : 0; if (index == nFirstAvailPage) return IPDF_DataAvail::DataAvailable; @@ -378,7 +378,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage( for (int i = 0; i < index; ++i) offset += m_dwNSharedObjsArray[i]; - CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetElementValue("O"); + CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectBy("O"); int nFirstPageObjNum = pFirstPageObj ? pFirstPageObj->GetInteger() : -1; if (nFirstPageObjNum < 0) return IPDF_DataAvail::DataError; @@ -414,7 +414,7 @@ FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { return FALSE; CPDF_Dictionary* pDict = pHintStream->GetDict(); - CPDF_Object* pOffset = pDict ? pDict->GetElement("S") : nullptr; + CPDF_Object* pOffset = pDict ? pDict->GetObjectBy("S") : nullptr; if (!pOffset || !pOffset->IsNumber()) return FALSE; @@ -447,7 +447,7 @@ int CPDF_HintTables::ReadPrimaryHintStreamOffset() const { if (!pRange) return -1; - CPDF_Object* pStreamOffset = pRange->GetElementValue(0); + CPDF_Object* pStreamOffset = pRange->GetDirectObjectAt(0); if (!pStreamOffset) return -1; @@ -462,7 +462,7 @@ int CPDF_HintTables::ReadPrimaryHintStreamLength() const { if (!pRange) return -1; - CPDF_Object* pStreamLen = pRange->GetElementValue(1); + CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(1); if (!pStreamLen) return -1; diff --git a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp index 84ad7cfc32..2069a161ea 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp @@ -123,7 +123,7 @@ class PDFObjectsTest : public testing::Test { if (array1->GetCount() != array2->GetCount()) return false; for (size_t i = 0; i < array1->GetCount(); ++i) { - if (!Equal(array1->GetElement(i), array2->GetElement(i))) + if (!Equal(array1->GetObjectAt(i), array2->GetObjectAt(i))) return false; } return true; @@ -135,7 +135,7 @@ class PDFObjectsTest : public testing::Test { return false; for (CPDF_Dictionary::const_iterator it = dict1->begin(); it != dict1->end(); ++it) { - if (!Equal(it->second, dict2->GetElement(it->first))) + if (!Equal(it->second, dict2->GetObjectBy(it->first))) return false; } return true; @@ -706,8 +706,8 @@ TEST(PDFArrayTest, AddNumber) { for (size_t i = 0; i < FX_ArraySize(vals); ++i) arr->AddNumber(vals[i]); for (size_t i = 0; i < FX_ArraySize(vals); ++i) { - EXPECT_EQ(CPDF_Object::NUMBER, arr->GetElement(i)->GetType()); - EXPECT_EQ(vals[i], arr->GetElement(i)->GetNumber()); + EXPECT_EQ(CPDF_Object::NUMBER, arr->GetObjectAt(i)->GetType()); + EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber()); } } @@ -717,8 +717,8 @@ TEST(PDFArrayTest, AddInteger) { for (size_t i = 0; i < FX_ArraySize(vals); ++i) arr->AddInteger(vals[i]); for (size_t i = 0; i < FX_ArraySize(vals); ++i) { - EXPECT_EQ(CPDF_Object::NUMBER, arr->GetElement(i)->GetType()); - EXPECT_EQ(vals[i], arr->GetElement(i)->GetNumber()); + EXPECT_EQ(CPDF_Object::NUMBER, arr->GetObjectAt(i)->GetType()); + EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber()); } } @@ -732,14 +732,14 @@ TEST(PDFArrayTest, AddStringAndName) { name_array->AddName(vals[i]); } for (size_t i = 0; i < FX_ArraySize(vals); ++i) { - EXPECT_EQ(CPDF_Object::STRING, string_array->GetElement(i)->GetType()); - EXPECT_STREQ(vals[i], string_array->GetElement(i)->GetString().c_str()); - EXPECT_EQ(CPDF_Object::NAME, name_array->GetElement(i)->GetType()); - EXPECT_STREQ(vals[i], name_array->GetElement(i)->GetString().c_str()); + EXPECT_EQ(CPDF_Object::STRING, string_array->GetObjectAt(i)->GetType()); + EXPECT_STREQ(vals[i], string_array->GetObjectAt(i)->GetString().c_str()); + EXPECT_EQ(CPDF_Object::NAME, name_array->GetObjectAt(i)->GetType()); + EXPECT_STREQ(vals[i], name_array->GetObjectAt(i)->GetString().c_str()); } } -TEST(PDFArrayTest, AddReferenceAndGetElement) { +TEST(PDFArrayTest, AddReferenceAndGetObjectAt) { std::unique_ptr<CPDF_IndirectObjectHolder> holder( new CPDF_IndirectObjectHolder(nullptr)); CPDF_Boolean* boolean_obj = new CPDF_Boolean(true); @@ -766,11 +766,11 @@ TEST(PDFArrayTest, AddReferenceAndGetElement) { // Check arrays. EXPECT_EQ(arr->GetCount(), arr1->GetCount()); for (size_t i = 0; i < arr->GetCount(); ++i) { - EXPECT_EQ(CPDF_Object::REFERENCE, arr->GetElement(i)->GetType()); - EXPECT_EQ(indirect_objs[i], arr->GetElement(i)->GetDirect()); - EXPECT_EQ(indirect_objs[i], arr->GetElementValue(i)); - EXPECT_EQ(CPDF_Object::REFERENCE, arr1->GetElement(i)->GetType()); - EXPECT_EQ(indirect_objs[i], arr1->GetElement(i)->GetDirect()); - EXPECT_EQ(indirect_objs[i], arr1->GetElementValue(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)); + EXPECT_EQ(CPDF_Object::REFERENCE, arr1->GetObjectAt(i)->GetType()); + EXPECT_EQ(indirect_objs[i], arr1->GetObjectAt(i)->GetDirect()); + EXPECT_EQ(indirect_objs[i], arr1->GetDirectObjectAt(i)); } } diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index bebd3d62be..305401525c 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -249,7 +249,7 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess) { } if (m_pSecurityHandler && !m_pSecurityHandler->IsMetadataEncrypted()) { CPDF_Reference* pMetadata = - ToReference(m_pDocument->GetRoot()->GetElement("Metadata")); + ToReference(m_pDocument->GetRoot()->GetObjectBy("Metadata")); if (pMetadata) m_pSyntax->m_MetadataObjnum = pMetadata->GetRefObjNum(); } @@ -262,7 +262,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() { if (!m_pTrailer) return FORMAT_ERROR; - CPDF_Object* pEncryptObj = m_pTrailer->GetElement("Encrypt"); + CPDF_Object* pEncryptObj = m_pTrailer->GetObjectBy("Encrypt"); if (pEncryptObj) { if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) { SetEncryptDictionary(pEncryptDict); @@ -743,9 +743,9 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { if ((pDict->KeyExist("Type")) && (pDict->GetStringBy("Type") == "XRef" && pDict->KeyExist("Size"))) { - CPDF_Object* pRoot = pDict->GetElement("Root"); + CPDF_Object* pRoot = pDict->GetObjectBy("Root"); if (pRoot && pRoot->GetDict() && - pRoot->GetDict()->GetElement("Pages")) { + pRoot->GetDict()->GetObjectBy("Pages")) { if (m_pTrailer) m_pTrailer->Release(); m_pTrailer = ToDictionary(pDict->Clone()); @@ -809,7 +809,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { if (CPDF_Dictionary* pTrailer = pStream ? pStream->GetDict() : pObj->AsDictionary()) { if (m_pTrailer) { - CPDF_Object* pRoot = pTrailer->GetElement("Root"); + CPDF_Object* pRoot = pTrailer->GetObjectBy("Root"); CPDF_Reference* pRef = ToReference(pRoot); if (!pRoot || (pRef && IsValidObjectNumber(pRef->GetRefObjNum()) && @@ -989,8 +989,8 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { if (pArray) { uint32_t nPairSize = pArray->GetCount() / 2; for (uint32_t i = 0; i < nPairSize; i++) { - CPDF_Object* pStartNumObj = pArray->GetElement(i * 2); - CPDF_Object* pCountObj = pArray->GetElement(i * 2 + 1); + CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2); + CPDF_Object* pCountObj = pArray->GetObjectAt(i * 2 + 1); if (ToNumber(pStartNumObj) && ToNumber(pCountObj)) { int nStartNum = pStartNumObj->GetInteger(); @@ -1095,7 +1095,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { } CPDF_Array* CPDF_Parser::GetIDArray() { - CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetElement("ID") : nullptr; + CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetObjectBy("ID") : nullptr; if (!pID) return nullptr; @@ -1108,13 +1108,13 @@ CPDF_Array* CPDF_Parser::GetIDArray() { uint32_t CPDF_Parser::GetRootObjNum() { CPDF_Reference* pRef = - ToReference(m_pTrailer ? m_pTrailer->GetElement("Root") : nullptr); + ToReference(m_pTrailer ? m_pTrailer->GetObjectBy("Root") : nullptr); return pRef ? pRef->GetRefObjNum() : 0; } uint32_t CPDF_Parser::GetInfoObjNum() { CPDF_Reference* pRef = - ToReference(m_pTrailer ? m_pTrailer->GetElement("Info") : nullptr); + ToReference(m_pTrailer ? m_pTrailer->GetObjectBy("Info") : nullptr); return pRef ? pRef->GetRefObjNum() : 0; } @@ -1493,10 +1493,10 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, return FALSE; CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - if (pDict && pDict->GetElement("Linearized")) { + if (pDict && pDict->GetObjectBy("Linearized")) { m_pSyntax->GetNextWord(nullptr); - CPDF_Object* pLen = pDict->GetElement("L"); + CPDF_Object* pLen = pDict->GetObjectBy("L"); if (!pLen) { m_pLinearized->Release(); m_pLinearized = nullptr; @@ -1506,10 +1506,10 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, if (pLen->GetInteger() != (int)pFileAccess->GetSize()) return FALSE; - if (CPDF_Number* pNo = ToNumber(pDict->GetElement("P"))) + if (CPDF_Number* pNo = ToNumber(pDict->GetObjectBy("P"))) m_dwFirstPageNo = pNo->GetInteger(); - if (CPDF_Number* pTable = ToNumber(pDict->GetElement("T"))) + if (CPDF_Number* pTable = ToNumber(pDict->GetObjectBy("T"))) m_LastXRefOffset = pTable->GetInteger(); return TRUE; @@ -1591,7 +1591,7 @@ CPDF_Parser::Error CPDF_Parser::StartAsyncParse(IFX_FileRead* pFileAccess) { if (m_pSecurityHandler && m_pSecurityHandler->IsMetadataEncrypted()) { if (CPDF_Reference* pMetadata = - ToReference(m_pDocument->GetRoot()->GetElement("Metadata"))) + ToReference(m_pDocument->GetRoot()->GetObjectBy("Metadata"))) m_pSyntax->m_MetadataObjnum = pMetadata->GetRefObjNum(); } return SUCCESS; diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index d14eeb991c..5a3db292e0 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -630,7 +630,7 @@ unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) { CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, uint32_t objnum, uint32_t gennum) { - CPDF_Object* pLenObj = pDict->GetElement("Length"); + CPDF_Object* pLenObj = pDict->GetObjectBy("Length"); FX_FILESIZE len = -1; CPDF_Reference* pLenObjRef = ToReference(pLenObj); diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 346476b62b..5d9254901a 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -336,12 +336,12 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, CPDF_Dictionary*& pImageParms, uint32_t last_estimated_size, FX_BOOL bImageAcc) { - CPDF_Object* pDecoder = pDict ? pDict->GetElementValue("Filter") : nullptr; + CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectBy("Filter") : nullptr; if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) return FALSE; CPDF_Object* pParams = - pDict ? pDict->GetElementValue("DecodeParms") : nullptr; + pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr; std::vector<CFX_ByteString> DecoderList; CFX_ArrayTemplate<CPDF_Object*> ParamList; if (CPDF_Array* pDecoders = pDecoder->AsArray()) { diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 5bfbfaebac..8228c497e9 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -82,7 +82,7 @@ int32_t GetHeaderOffset(IFX_FileRead* pFile) { } int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { - CPDF_Number* pObj = ToNumber(pDict->GetElement(key)); + CPDF_Number* pObj = ToNumber(pDict->GetObjectBy(key)); return pObj ? pObj->GetInteger() : 0; } @@ -180,7 +180,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { const CPDF_Array* p = pObj->AsArray(); buf << "["; for (uint32_t i = 0; i < p->GetCount(); i++) { - CPDF_Object* pElement = p->GetElement(i); + CPDF_Object* pElement = p->GetObjectAt(i); if (pElement->GetObjNum()) { buf << " " << pElement->GetObjNum() << " 0 R"; } else { diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_array.h b/core/fpdfapi/fpdf_parser/include/cpdf_array.h index 3efa03e0d5..ea367785ed 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_array.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_array.h @@ -25,10 +25,8 @@ class CPDF_Array : public CPDF_Object { const CPDF_Array* AsArray() const override; uint32_t GetCount() const { return m_Objects.GetSize(); } - CPDF_Object* GetElement(uint32_t index) const; - CPDF_Object* GetElementValue(uint32_t index) const; - CFX_Matrix GetMatrix(); - CFX_FloatRect GetRect(); + CPDF_Object* GetObjectAt(uint32_t index) const; + CPDF_Object* GetDirectObjectAt(uint32_t index) const; CFX_ByteString GetStringAt(uint32_t index) const; CFX_ByteStringC GetConstStringAt(uint32_t index) const; int GetIntegerAt(uint32_t index) const; @@ -37,6 +35,8 @@ class CPDF_Array : public CPDF_Object { CPDF_Stream* GetStreamAt(uint32_t index) const; CPDF_Array* GetArrayAt(uint32_t index) const; FX_FLOAT GetFloatAt(uint32_t index) const { return GetNumberAt(index); } + CFX_Matrix GetMatrix(); + CFX_FloatRect GetRect(); void SetAt(uint32_t index, CPDF_Object* pObj, diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h index 73eabf9368..82abc35c02 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h @@ -31,8 +31,8 @@ class CPDF_Dictionary : public CPDF_Object { const CPDF_Dictionary* AsDictionary() const override; size_t GetCount() const { return m_Map.size(); } - CPDF_Object* GetElement(const CFX_ByteStringC& key) const; - CPDF_Object* GetElementValue(const CFX_ByteStringC& key) const; + CPDF_Object* GetObjectBy(const CFX_ByteStringC& key) const; + CPDF_Object* GetDirectObjectBy(const CFX_ByteStringC& key) const; CFX_ByteString GetStringBy(const CFX_ByteStringC& key) const; CFX_ByteStringC GetConstStringBy(const CFX_ByteStringC& key) const; CFX_ByteString GetStringBy(const CFX_ByteStringC& key, |