diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-15 10:15:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-15 10:15:32 -0700 |
commit | 38fd84428a1ea007a043be0b7d9b289e47aa5da0 (patch) | |
tree | 2bae09e8ae60d6d86e451eb7fa212f7aa9d899a8 /core/fpdfapi | |
parent | 41d6bbe3d413e7854be89142b70c42a89e315cba (diff) | |
download | pdfium-38fd84428a1ea007a043be0b7d9b289e47aa5da0.tar.xz |
Rename dictionary set and get methods
This Cl makes the Get and Set methods consistenly use {G|S}et<Type>For.
BUG=pdfium:596
Review-Url: https://codereview.chromium.org/2334323005
Diffstat (limited to 'core/fpdfapi')
41 files changed, 580 insertions, 579 deletions
diff --git a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp index 0e4bab1ae1..d3d55b91b5 100644 --- a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp @@ -49,14 +49,14 @@ void CPDF_PageContentGenerator::GenerateContent() { ProcessImage(buf, pPageObj->AsImage()); } CPDF_Object* pContent = - pPageDict ? pPageDict->GetDirectObjectBy("Contents") : nullptr; + pPageDict ? pPageDict->GetDirectObjectFor("Contents") : nullptr; if (pContent) { - pPageDict->RemoveAt("Contents"); + pPageDict->RemoveFor("Contents"); } CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); m_pDocument->AddIndirectObject(pStream); - pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); + pPageDict->SetReferenceFor("Contents", m_pDocument, pStream->GetObjNum()); } CFX_ByteString CPDF_PageContentGenerator::RealizeResource( @@ -65,12 +65,12 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( if (!m_pPage->m_pResources) { m_pPage->m_pResources = new CPDF_Dictionary; int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); - m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum); + m_pPage->m_pFormDict->SetReferenceFor("Resources", m_pDocument, objnum); } - CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(bsType); + CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictFor(bsType); if (!pResList) { pResList = new CPDF_Dictionary; - m_pPage->m_pResources->SetAt(bsType, pResList); + m_pPage->m_pResources->SetFor(bsType, pResList); } m_pDocument->AddIndirectObject(pResourceObj); CFX_ByteString name; @@ -82,7 +82,7 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( } idnum++; } - pResList->SetAtReference(name, m_pDocument, pResourceObj->GetObjNum()); + pResList->SetReferenceFor(name, m_pDocument, pResourceObj->GetObjNum()); return name; } @@ -114,11 +114,11 @@ void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, } CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); CPDF_Dictionary* pFormDict = new CPDF_Dictionary; - pFormDict->SetAtName("Type", "XObject"); - pFormDict->SetAtName("Subtype", "Form"); + pFormDict->SetNameFor("Type", "XObject"); + pFormDict->SetNameFor("Subtype", "Form"); CFX_FloatRect bbox = m_pPage->GetPageBBox(); matrix.TransformRect(bbox); - pFormDict->SetAtRect("BBox", bbox); + pFormDict->SetRectFor("BBox", bbox); pStream->InitStream(data, size, pFormDict); buf << "q " << matrix << " cm "; CFX_ByteString name = RealizeResource(pStream, "XObject"); @@ -127,7 +127,7 @@ void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { CPDF_Dictionary* pDict = m_pPage->m_pFormDict; CPDF_Object* pContent = - pDict ? pDict->GetDirectObjectBy("Contents") : nullptr; + pDict ? pDict->GetDirectObjectFor("Contents") : nullptr; if (!pContent) return; @@ -167,6 +167,6 @@ void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); m_pDocument->AddIndirectObject(pStream); - m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, - pStream->GetObjNum()); + m_pPage->m_pFormDict->SetReferenceFor("Contents", m_pDocument, + pStream->GetObjNum()); } diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 7ece85a602..cab99ecf7f 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -426,7 +426,7 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode) m_dwSize = destAcc.GetSize(); m_pData = (uint8_t*)destAcc.DetachData(); m_pDict = ToDictionary(pStream->GetDict()->Clone()); - m_pDict->RemoveAt("Filter"); + m_pDict->RemoveFor("Filter"); m_bNewData = TRUE; m_bCloned = TRUE; } else { @@ -442,9 +442,9 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode) // TODO(thestig): Move to Init() and check return value. ::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), &m_pData, &m_dwSize); m_pDict = ToDictionary(pStream->GetDict()->Clone()); - m_pDict->SetAtInteger("Length", m_dwSize); - m_pDict->SetAtName("Filter", "FlateDecode"); - m_pDict->RemoveAt("DecodeParms"); + m_pDict->SetIntegerFor("Length", m_dwSize); + m_pDict->SetNameFor("Filter", "FlateDecode"); + m_pDict->RemoveFor("DecodeParms"); } CPDF_FlateEncoder::CPDF_FlateEncoder(const uint8_t* pBuffer, @@ -923,7 +923,7 @@ int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) { CPDF_Dictionary* pDict = pObj->GetDict(); if (pObj->IsStream()) { - if (pDict && pDict->GetStringBy("Type") == "XRef") + if (pDict && pDict->GetStringFor("Type") == "XRef") return 0; return 1; } @@ -933,7 +933,7 @@ int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) { return 1; if (pDict->IsSignatureDict()) return 1; - if (pDict->GetStringBy("Type") == "Page") + if (pDict->GetStringFor("Type") == "Page") return 1; } @@ -993,9 +993,10 @@ int32_t CPDF_Creator::WriteStream(const CPDF_Object* pStream, CPDF_FlateEncoder encoder(const_cast<CPDF_Stream*>(pStream->AsStream()), pStream != m_pMetadata); CPDF_Encryptor encryptor(pCrypto, objnum, encoder.m_pData, encoder.m_dwSize); - if ((uint32_t)encoder.m_pDict->GetIntegerBy("Length") != encryptor.m_dwSize) { + if ((uint32_t)encoder.m_pDict->GetIntegerFor("Length") != + encryptor.m_dwSize) { encoder.CloneDict(); - encoder.m_pDict->SetAtInteger("Length", encryptor.m_dwSize); + encoder.m_pDict->SetIntegerFor("Length", encryptor.m_dwSize); } if (WriteDirectObj(objnum, encoder.m_pDict) < 0) { return -1; @@ -1105,10 +1106,10 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, TRUE); CPDF_Encryptor encryptor(m_pCryptoHandler, objnum, encoder.m_pData, encoder.m_dwSize); - if ((uint32_t)encoder.m_pDict->GetIntegerBy("Length") != + if ((uint32_t)encoder.m_pDict->GetIntegerFor("Length") != encryptor.m_dwSize) { encoder.CloneDict(); - encoder.m_pDict->SetAtInteger("Length", encryptor.m_dwSize); + encoder.m_pDict->SetIntegerFor("Length", encryptor.m_dwSize); } if (WriteDirectObj(objnum, encoder.m_pDict) < 0) { return -1; @@ -1446,7 +1447,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) { m_dwFlags &= ~FPDFCREATE_INCREMENTAL; } CPDF_Dictionary* pDict = m_pDocument->GetRoot(); - m_pMetadata = pDict ? pDict->GetDirectObjectBy("Metadata") : nullptr; + m_pMetadata = pDict ? pDict->GetDirectObjectFor("Metadata") : nullptr; if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) { m_pXRefStream.reset(new CPDF_XRefStream); m_pXRefStream->Start(); @@ -1959,7 +1960,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) { } m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { - if (m_pEncryptDict->GetStringBy("Filter") == "Standard") { + if (m_pEncryptDict->GetStringFor("Filter") == "Standard") { CFX_ByteString user_pass = m_pParser->GetPassword(); uint32_t flag = PDF_ENCRYPT_CONTENT; diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp index df087810f8..d0549a8fac 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp @@ -323,12 +323,12 @@ uint32_t CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { } FX_BOOL CPDF_CIDFont::Load() { - if (m_pFontDict->GetStringBy("Subtype") == "TrueType") { + if (m_pFontDict->GetStringFor("Subtype") == "TrueType") { LoadGB2312(); return TRUE; } - CPDF_Array* pFonts = m_pFontDict->GetArrayBy("DescendantFonts"); + CPDF_Array* pFonts = m_pFontDict->GetArrayFor("DescendantFonts"); if (!pFonts || pFonts->GetCount() != 1) return FALSE; @@ -336,7 +336,7 @@ FX_BOOL CPDF_CIDFont::Load() { if (!pCIDFontDict) return FALSE; - m_BaseFont = pCIDFontDict->GetStringBy("BaseFont"); + m_BaseFont = pCIDFontDict->GetStringFor("BaseFont"); if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd-Bold") == 0 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || @@ -344,15 +344,15 @@ FX_BOOL CPDF_CIDFont::Load() { !IsEmbedded()) { m_bAdobeCourierStd = true; } - CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDictBy("FontDescriptor"); + CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDictFor("FontDescriptor"); if (pFontDesc) LoadFontDescriptor(pFontDesc); - CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); + CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); if (!pEncoding) return FALSE; - CFX_ByteString subtype = pCIDFontDict->GetStringBy("Subtype"); + CFX_ByteString subtype = pCIDFontDict->GetStringFor("Subtype"); m_bType1 = (subtype == "CIDFontType0"); CPDF_CMapManager& manager = GetFontGlobals()->m_CMapManager; @@ -374,10 +374,10 @@ FX_BOOL CPDF_CIDFont::Load() { m_Charset = m_pCMap->m_Charset; if (m_Charset == CIDSET_UNKNOWN) { - CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictBy("CIDSystemInfo"); + CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictFor("CIDSystemInfo"); if (pCIDInfo) { m_Charset = - CharsetFromOrdering(pCIDInfo->GetStringBy("Ordering").AsStringC()); + CharsetFromOrdering(pCIDInfo->GetStringFor("Ordering").AsStringC()); } } if (m_Charset != CIDSET_UNKNOWN) { @@ -391,15 +391,15 @@ FX_BOOL CPDF_CIDFont::Load() { else FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->m_Coding); } - m_DefaultWidth = pCIDFontDict->GetIntegerBy("DW", 1000); - CPDF_Array* pWidthArray = pCIDFontDict->GetArrayBy("W"); + m_DefaultWidth = pCIDFontDict->GetIntegerFor("DW", 1000); + CPDF_Array* pWidthArray = pCIDFontDict->GetArrayFor("W"); if (pWidthArray) LoadMetricsArray(pWidthArray, m_WidthList, 1); if (!IsEmbedded()) LoadSubstFont(); if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { - CPDF_Object* pmap = pCIDFontDict->GetDirectObjectBy("CIDToGIDMap"); + CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap"); if (pmap) { if (CPDF_Stream* pStream = pmap->AsStream()) { m_pStreamAcc.reset(new CPDF_StreamAcc); @@ -418,11 +418,11 @@ FX_BOOL CPDF_CIDFont::Load() { CheckFontMetrics(); if (IsVertWriting()) { - pWidthArray = pCIDFontDict->GetArrayBy("W2"); + pWidthArray = pCIDFontDict->GetArrayFor("W2"); if (pWidthArray) { LoadMetricsArray(pWidthArray, m_VertMetrics, 3); } - CPDF_Array* pDefaultArray = pCIDFontDict->GetArrayBy("DW2"); + CPDF_Array* pDefaultArray = pCIDFontDict->GetArrayFor("DW2"); if (pDefaultArray) { m_DefaultVY = pDefaultArray->GetIntegerAt(0); m_DefaultW1 = pDefaultArray->GetIntegerAt(1); @@ -832,8 +832,8 @@ FX_FLOAT CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) { } void CPDF_CIDFont::LoadGB2312() { - m_BaseFont = m_pFontDict->GetStringBy("BaseFont"); - CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor"); + m_BaseFont = m_pFontDict->GetStringFor("BaseFont"); + CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictFor("FontDescriptor"); if (pFontDesc) LoadFontDescriptor(pFontDesc); diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp index 4747093ac4..d3f8664cd3 100644 --- a/core/fpdfapi/fpdf_font/cpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp @@ -163,11 +163,11 @@ uint32_t CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const { } void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { - m_Flags = pFontDesc->GetIntegerBy("Flags", PDFFONT_NONSYMBOLIC); + m_Flags = pFontDesc->GetIntegerFor("Flags", PDFFONT_NONSYMBOLIC); int ItalicAngle = 0; FX_BOOL bExistItalicAngle = FALSE; if (pFontDesc->KeyExist("ItalicAngle")) { - ItalicAngle = pFontDesc->GetIntegerBy("ItalicAngle"); + ItalicAngle = pFontDesc->GetIntegerFor("ItalicAngle"); bExistItalicAngle = TRUE; } if (ItalicAngle < 0) { @@ -176,17 +176,17 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { } FX_BOOL bExistStemV = FALSE; if (pFontDesc->KeyExist("StemV")) { - m_StemV = pFontDesc->GetIntegerBy("StemV"); + m_StemV = pFontDesc->GetIntegerFor("StemV"); bExistStemV = TRUE; } FX_BOOL bExistAscent = FALSE; if (pFontDesc->KeyExist("Ascent")) { - m_Ascent = pFontDesc->GetIntegerBy("Ascent"); + m_Ascent = pFontDesc->GetIntegerFor("Ascent"); bExistAscent = TRUE; } FX_BOOL bExistDescent = FALSE; if (pFontDesc->KeyExist("Descent")) { - m_Descent = pFontDesc->GetIntegerBy("Descent"); + m_Descent = pFontDesc->GetIntegerFor("Descent"); bExistDescent = TRUE; } FX_BOOL bExistCapHeight = FALSE; @@ -200,7 +200,7 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { if (m_Descent > 10) { m_Descent = -m_Descent; } - CPDF_Array* pBBox = pFontDesc->GetArrayBy("FontBBox"); + CPDF_Array* pBBox = pFontDesc->GetArrayFor("FontBBox"); if (pBBox) { m_FontBBox.left = pBBox->GetIntegerAt(0); m_FontBBox.bottom = pBBox->GetIntegerAt(1); @@ -208,11 +208,11 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { m_FontBBox.top = pBBox->GetIntegerAt(3); } - CPDF_Stream* pFontFile = pFontDesc->GetStreamBy("FontFile"); + CPDF_Stream* pFontFile = pFontDesc->GetStreamFor("FontFile"); if (!pFontFile) - pFontFile = pFontDesc->GetStreamBy("FontFile2"); + pFontFile = pFontDesc->GetStreamFor("FontFile2"); if (!pFontFile) - pFontFile = pFontDesc->GetStreamBy("FontFile3"); + pFontFile = pFontDesc->GetStreamFor("FontFile3"); if (!pFontFile) return; @@ -277,7 +277,7 @@ void CPDF_Font::CheckFontMetrics() { void CPDF_Font::LoadUnicodeMap() const { m_bToUnicodeLoaded = TRUE; - CPDF_Stream* pStream = m_pFontDict->GetStreamBy("ToUnicode"); + CPDF_Stream* pStream = m_pFontDict->GetStreamFor("ToUnicode"); if (!pStream) { return; } @@ -309,10 +309,10 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, return pFont; } CPDF_Dictionary* pDict = new CPDF_Dictionary; - pDict->SetAtName("Type", "Font"); - pDict->SetAtName("Subtype", "Type1"); - pDict->SetAtName("BaseFont", fontname); - pDict->SetAtName("Encoding", "WinAnsiEncoding"); + pDict->SetNameFor("Type", "Font"); + pDict->SetNameFor("Subtype", "Type1"); + pDict->SetNameFor("BaseFont", fontname); + pDict->SetNameFor("Encoding", "WinAnsiEncoding"); pFont = CPDF_Font::CreateFontF(nullptr, pDict); pFontGlobals->Set(pDoc, font_id, pFont); return pFont; @@ -320,13 +320,13 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDict) { - CFX_ByteString type = pFontDict->GetStringBy("Subtype"); + CFX_ByteString type = pFontDict->GetStringFor("Subtype"); std::unique_ptr<CPDF_Font> pFont; if (type == "TrueType") { - CFX_ByteString tag = pFontDict->GetStringBy("BaseFont").Left(4); + CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) { if (tag == CFX_ByteString(kChineseFontNames[i], 4)) { - CPDF_Dictionary* pFontDesc = pFontDict->GetDictBy("FontDescriptor"); + CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor"); if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) pFont.reset(new CPDF_CIDFont); break; @@ -343,7 +343,7 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, } pFont->m_pFontDict = pFontDict; pFont->m_pDocument = pDoc; - pFont->m_BaseFont = pFontDict->GetStringBy("BaseFont"); + pFont->m_BaseFont = pFontDict->GetStringFor("BaseFont"); return pFont->Load() ? pFont.release() : nullptr; } @@ -396,7 +396,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, if (iBaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && iBaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) { - CFX_ByteString bsEncoding = pDict->GetStringBy("BaseEncoding"); + CFX_ByteString bsEncoding = pDict->GetStringFor("BaseEncoding"); if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) { bsEncoding = "WinAnsiEncoding"; } @@ -405,7 +405,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, if ((!bEmbedded || bTrueType) && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) iBaseEncoding = PDFFONT_ENCODING_STANDARD; - CPDF_Array* pDiffs = pDict->GetArrayBy("Differences"); + CPDF_Array* pDiffs = pDict->GetArrayFor("Differences"); if (!pDiffs) return; diff --git a/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp b/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp index 6b726f0a32..29587927bc 100644 --- a/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp @@ -1711,8 +1711,8 @@ CPDF_Object* CPDF_FontEncoding::Realize() { } CPDF_Dictionary* pDict = new CPDF_Dictionary; - pDict->SetAtName("BaseEncoding", "WinAnsiEncoding"); - pDict->SetAt("Differences", pDiff); + pDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); + pDict->SetFor("Differences", pDiff); return pDict; } diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp index 8c4dc8d2cd..fbc1a64e30 100644 --- a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp @@ -102,21 +102,21 @@ FX_RECT CPDF_SimpleFont::GetCharBBox(uint32_t charcode, int level) { } FX_BOOL CPDF_SimpleFont::LoadCommon() { - CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor"); + CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictFor("FontDescriptor"); if (pFontDesc) { LoadFontDescriptor(pFontDesc); } - CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); + CPDF_Array* pWidthArray = m_pFontDict->GetArrayFor("Widths"); m_bUseFontWidth = !pWidthArray; if (pWidthArray) { if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) { - int MissingWidth = pFontDesc->GetIntegerBy("MissingWidth"); + int MissingWidth = pFontDesc->GetIntegerFor("MissingWidth"); for (int i = 0; i < 256; i++) { m_CharWidth[i] = MissingWidth; } } - size_t width_start = m_pFontDict->GetIntegerBy("FirstChar", 0); - size_t width_end = m_pFontDict->GetIntegerBy("LastChar", 0); + 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; @@ -136,7 +136,7 @@ FX_BOOL CPDF_SimpleFont::LoadCommon() { if (!(m_Flags & PDFFONT_SYMBOLIC)) { m_BaseEncoding = PDFFONT_ENCODING_STANDARD; } - CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); + CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, !!m_pFontFile, m_Font.IsTTFont()); LoadGlyphMap(); diff --git a/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp b/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp index 25baf45d02..d54553ab10 100644 --- a/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp @@ -68,7 +68,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { (m_Flags & PDFFONT_NONSYMBOLIC)) { if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) && (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) { - int nStartChar = m_pFontDict->GetIntegerBy("FirstChar"); + int nStartChar = m_pFontDict->GetIntegerFor("FirstChar"); if (nStartChar < 0 || nStartChar > 255) return; diff --git a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp index c316d8d424..72fc947d31 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp @@ -80,9 +80,9 @@ CPDF_Type1Font* CPDF_Type1Font::AsType1Font() { FX_BOOL CPDF_Type1Font::Load() { m_Base14Font = PDF_GetStandardFontName(&m_BaseFont); if (m_Base14Font >= 0) { - CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor"); + CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictFor("FontDescriptor"); if (pFontDesc && pFontDesc->KeyExist("Flags")) - m_Flags = pFontDesc->GetIntegerBy("Flags"); + m_Flags = pFontDesc->GetIntegerFor("Flags"); else m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLIC; diff --git a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp index 849ad92298..69857575b5 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp @@ -38,23 +38,23 @@ CPDF_Type3Font* CPDF_Type3Font::AsType3Font() { } FX_BOOL CPDF_Type3Font::Load() { - m_pFontResources = m_pFontDict->GetDictBy("Resources"); - CPDF_Array* pMatrix = m_pFontDict->GetArrayBy("FontMatrix"); + m_pFontResources = m_pFontDict->GetDictFor("Resources"); + CPDF_Array* pMatrix = m_pFontDict->GetArrayFor("FontMatrix"); FX_FLOAT xscale = 1.0f, yscale = 1.0f; if (pMatrix) { m_FontMatrix = pMatrix->GetMatrix(); xscale = m_FontMatrix.a; yscale = m_FontMatrix.d; } - CPDF_Array* pBBox = m_pFontDict->GetArrayBy("FontBBox"); + CPDF_Array* pBBox = m_pFontDict->GetArrayFor("FontBBox"); if (pBBox) { m_FontBBox.left = (int32_t)(pBBox->GetNumberAt(0) * xscale * 1000); m_FontBBox.bottom = (int32_t)(pBBox->GetNumberAt(1) * yscale * 1000); m_FontBBox.right = (int32_t)(pBBox->GetNumberAt(2) * xscale * 1000); m_FontBBox.top = (int32_t)(pBBox->GetNumberAt(3) * yscale * 1000); } - int StartChar = m_pFontDict->GetIntegerBy("FirstChar"); - CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); + int StartChar = m_pFontDict->GetIntegerFor("FirstChar"); + CPDF_Array* pWidthArray = m_pFontDict->GetArrayFor("Widths"); if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { size_t count = pWidthArray->GetCount(); if (count > 256) @@ -66,8 +66,8 @@ FX_BOOL CPDF_Type3Font::Load() { FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000); } } - m_pCharProcs = m_pFontDict->GetDictBy("CharProcs"); - CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); + m_pCharProcs = m_pFontDict->GetDictFor("CharProcs"); + CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); if (pEncoding) { LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, FALSE, FALSE); if (!m_CharNames.empty()) { @@ -100,7 +100,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) { return nullptr; CPDF_Stream* pStream = - ToStream(m_pCharProcs ? m_pCharProcs->GetDirectObjectBy(name) : nullptr); + ToStream(m_pCharProcs ? m_pCharProcs->GetDirectObjectFor(name) : nullptr); if (!pStream) return nullptr; diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp index 759d0f37b5..88a74f0189 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp @@ -568,16 +568,16 @@ FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { if (!pDict) return FALSE; - CPDF_Array* pParam = pDict->GetArrayBy("WhitePoint"); + CPDF_Array* pParam = pDict->GetArrayFor("WhitePoint"); int i; for (i = 0; i < 3; i++) m_WhitePoint[i] = pParam ? pParam->GetNumberAt(i) : 0; - pParam = pDict->GetArrayBy("BlackPoint"); + pParam = pDict->GetArrayFor("BlackPoint"); for (i = 0; i < 3; i++) m_BlackPoint[i] = pParam ? pParam->GetNumberAt(i) : 0; - m_Gamma = pDict->GetNumberBy("Gamma"); + m_Gamma = pDict->GetNumberFor("Gamma"); if (m_Gamma == 0) m_Gamma = 1.0f; return TRUE; @@ -623,16 +623,16 @@ FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { if (!pDict) return FALSE; - CPDF_Array* pParam = pDict->GetArrayBy("WhitePoint"); + CPDF_Array* pParam = pDict->GetArrayFor("WhitePoint"); int i; for (i = 0; i < 3; i++) m_WhitePoint[i] = pParam ? pParam->GetNumberAt(i) : 0; - pParam = pDict->GetArrayBy("BlackPoint"); + pParam = pDict->GetArrayFor("BlackPoint"); for (i = 0; i < 3; i++) m_BlackPoint[i] = pParam ? pParam->GetNumberAt(i) : 0; - pParam = pDict->GetArrayBy("Gamma"); + pParam = pDict->GetArrayFor("Gamma"); if (pParam) { m_bGamma = TRUE; for (i = 0; i < 3; i++) @@ -641,7 +641,7 @@ FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { m_bGamma = FALSE; } - pParam = pDict->GetArrayBy("Matrix"); + pParam = pDict->GetArrayFor("Matrix"); if (pParam) { m_bMatrix = TRUE; for (i = 0; i < 9; i++) @@ -745,16 +745,16 @@ FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { if (!pDict) return FALSE; - CPDF_Array* pParam = pDict->GetArrayBy("WhitePoint"); + CPDF_Array* pParam = pDict->GetArrayFor("WhitePoint"); int i; for (i = 0; i < 3; i++) m_WhitePoint[i] = pParam ? pParam->GetNumberAt(i) : 0; - pParam = pDict->GetArrayBy("BlackPoint"); + pParam = pDict->GetArrayFor("BlackPoint"); for (i = 0; i < 3; i++) m_BlackPoint[i] = pParam ? pParam->GetNumberAt(i) : 0; - pParam = pDict->GetArrayBy("Range"); + pParam = pDict->GetArrayFor("Range"); const FX_FLOAT def_ranges[4] = {-100 * 1.0f, 100 * 1.0f, -100 * 1.0f, 100 * 1.0f}; for (i = 0; i < 4; i++) @@ -852,7 +852,7 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Dictionary* pDict = pStream->GetDict(); if (!m_pProfile->m_pTransform) { // No valid ICC profile or using sRGB CPDF_Object* pAlterCSObj = - pDict ? pDict->GetDirectObjectBy("Alternate") : nullptr; + pDict ? pDict->GetDirectObjectFor("Alternate") : nullptr; if (pAlterCSObj) { CPDF_ColorSpace* pAlterCS = CPDF_ColorSpace::Load(pDoc, pAlterCSObj); if (pAlterCS) { @@ -863,7 +863,7 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { m_bOwn = TRUE; } else { // No valid alternative colorspace pAlterCS->ReleaseCS(); - int32_t nDictComponents = pDict ? pDict->GetIntegerBy("N") : 0; + int32_t nDictComponents = pDict ? pDict->GetIntegerFor("N") : 0; if (nDictComponents != 1 && nDictComponents != 3 && nDictComponents != 4) { return FALSE; @@ -890,7 +890,7 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { m_pAlterCS = GetStockCS(PDFCS_DEVICECMYK); } } - CPDF_Array* pRanges = pDict->GetArrayBy("Range"); + CPDF_Array* pRanges = pDict->GetArrayFor("Range"); m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2); for (uint32_t i = 0; i < m_nComponents * 2; i++) { if (pRanges) diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp index 2e28989976..99a16004cd 100644 --- a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp @@ -104,7 +104,7 @@ int CPDF_ContentMark::MarkData::GetMCID() const { type == CPDF_ContentMarkItem::DirectDict) { CPDF_Dictionary* pDict = mark.GetParam(); if (pDict->KeyExist("MCID")) - return pDict->GetIntegerBy("MCID"); + return pDict->GetIntegerFor("MCID"); } } return -1; diff --git a/core/fpdfapi/fpdf_page/cpdf_form.cpp b/core/fpdfapi/fpdf_page/cpdf_form.cpp index 570419f58f..bf0dade4b1 100644 --- a/core/fpdfapi/fpdf_page/cpdf_form.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_form.cpp @@ -19,7 +19,7 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc, m_pDocument = pDoc; m_pFormStream = pFormStream; m_pFormDict = pFormStream ? pFormStream->GetDict() : nullptr; - m_pResources = m_pFormDict->GetDictBy("Resources"); + m_pResources = m_pFormDict->GetDictFor("Resources"); m_pPageResources = pPageResources; if (!m_pResources) m_pResources = pParentResources; diff --git a/core/fpdfapi/fpdf_page/cpdf_image.cpp b/core/fpdfapi/fpdf_page/cpdf_image.cpp index 2b3625bfc2..02e492b27d 100644 --- a/core/fpdfapi/fpdf_page/cpdf_image.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_image.cpp @@ -45,12 +45,12 @@ CPDF_Image::CPDF_Image(CPDF_Document* pDoc, CPDF_Stream* pStream, bool bInline) if (m_bInline) m_pInlineDict = ToDictionary(pDict->Clone()); - m_pOC = pDict->GetDictBy("OC"); + m_pOC = pDict->GetDictFor("OC"); m_bIsMask = - !pDict->KeyExist("ColorSpace") || pDict->GetIntegerBy("ImageMask"); - m_bInterpolate = !!pDict->GetIntegerBy("Interpolate"); - m_Height = pDict->GetIntegerBy("Height"); - m_Width = pDict->GetIntegerBy("Width"); + !pDict->KeyExist("ColorSpace") || pDict->GetIntegerFor("ImageMask"); + m_bInterpolate = !!pDict->GetIntegerFor("Interpolate"); + m_Height = pDict->GetIntegerFor("Height"); + m_Width = pDict->GetIntegerFor("Width"); } CPDF_Image::~CPDF_Image() { @@ -86,10 +86,10 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) { } CPDF_Dictionary* pDict = new CPDF_Dictionary; - pDict->SetAtName("Type", "XObject"); - pDict->SetAtName("Subtype", "Image"); - pDict->SetAtInteger("Width", width); - pDict->SetAtInteger("Height", height); + pDict->SetNameFor("Type", "XObject"); + pDict->SetNameFor("Subtype", "Image"); + pDict->SetIntegerFor("Width", width); + pDict->SetIntegerFor("Height", height); const FX_CHAR* csname = nullptr; if (num_comps == 1) { csname = "DeviceGray"; @@ -102,15 +102,15 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) { pDecode->AddInteger(1); pDecode->AddInteger(0); } - pDict->SetAt("Decode", pDecode); + pDict->SetFor("Decode", pDecode); } - pDict->SetAtName("ColorSpace", csname); - pDict->SetAtInteger("BitsPerComponent", bits); - pDict->SetAtName("Filter", "DCTDecode"); + pDict->SetNameFor("ColorSpace", csname); + pDict->SetIntegerFor("BitsPerComponent", bits); + pDict->SetNameFor("Filter", "DCTDecode"); if (!color_trans) { CPDF_Dictionary* pParms = new CPDF_Dictionary; - pDict->SetAt("DecodeParms", pParms); - pParms->SetAtInteger("ColorTransform", 0); + pDict->SetFor("DecodeParms", pParms); + pParms->SetIntegerFor("ColorTransform", 0); } m_bIsMask = FALSE; m_Width = width; @@ -151,10 +151,10 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { int32_t bpp = pBitmap->GetBPP(); CPDF_Dictionary* pDict = new CPDF_Dictionary; - pDict->SetAtName("Type", "XObject"); - pDict->SetAtName("Subtype", "Image"); - pDict->SetAtInteger("Width", BitmapWidth); - pDict->SetAtInteger("Height", BitmapHeight); + pDict->SetNameFor("Type", "XObject"); + pDict->SetNameFor("Subtype", "Image"); + pDict->SetIntegerFor("Width", BitmapWidth); + pDict->SetIntegerFor("Height", BitmapHeight); uint8_t* dest_buf = nullptr; FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1; if (bpp == 1) { @@ -166,12 +166,12 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { ArgbDecode(pBitmap->GetPaletteArgb(1), set_a, set_r, set_g, set_b); } if (set_a == 0 || reset_a == 0) { - pDict->SetAt("ImageMask", new CPDF_Boolean(TRUE)); + pDict->SetFor("ImageMask", new CPDF_Boolean(TRUE)); if (reset_a == 0) { CPDF_Array* pArray = new CPDF_Array; pArray->AddInteger(1); pArray->AddInteger(0); - pDict->SetAt("Decode", pArray); + pDict->SetFor("Decode", pArray); } } else { CPDF_Array* pCS = new CPDF_Array; @@ -188,9 +188,9 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { pBuf[5] = (FX_CHAR)set_b; ct.ReleaseBuffer(6); pCS->Add(new CPDF_String(ct, TRUE)); - pDict->SetAt("ColorSpace", pCS); + pDict->SetFor("ColorSpace", pCS); } - pDict->SetAtInteger("BitsPerComponent", 1); + pDict->SetIntegerFor("BitsPerComponent", 1); dest_pitch = (BitmapWidth + 7) / 8; if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { opType = 1; @@ -218,11 +218,11 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { new CPDF_Stream(pColorTable, iPalette * 3, new CPDF_Dictionary); m_pDocument->AddIndirectObject(pCTS); pCS->AddReference(m_pDocument, pCTS); - pDict->SetAtReference("ColorSpace", m_pDocument, pCS); + pDict->SetReferenceFor("ColorSpace", m_pDocument, pCS); } else { - pDict->SetAtName("ColorSpace", "DeviceGray"); + pDict->SetNameFor("ColorSpace", "DeviceGray"); } - pDict->SetAtInteger("BitsPerComponent", 8); + pDict->SetIntegerFor("BitsPerComponent", 8); if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { dest_pitch = BitmapWidth; opType = 1; @@ -230,8 +230,8 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { opType = 0; } } else { - pDict->SetAtName("ColorSpace", "DeviceRGB"); - pDict->SetAtInteger("BitsPerComponent", 8); + pDict->SetNameFor("ColorSpace", "DeviceRGB"); + pDict->SetIntegerFor("BitsPerComponent", 8); if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { dest_pitch = BitmapWidth * 3; opType = 2; @@ -251,12 +251,12 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { uint8_t* mask_buf = nullptr; FX_STRSIZE mask_size = 0; CPDF_Dictionary* pMaskDict = new CPDF_Dictionary; - pMaskDict->SetAtName("Type", "XObject"); - pMaskDict->SetAtName("Subtype", "Image"); - pMaskDict->SetAtInteger("Width", maskWidth); - pMaskDict->SetAtInteger("Height", maskHeight); - pMaskDict->SetAtName("ColorSpace", "DeviceGray"); - pMaskDict->SetAtInteger("BitsPerComponent", 8); + pMaskDict->SetNameFor("Type", "XObject"); + pMaskDict->SetNameFor("Subtype", "Image"); + pMaskDict->SetIntegerFor("Width", maskWidth); + pMaskDict->SetIntegerFor("Height", maskHeight); + pMaskDict->SetNameFor("ColorSpace", "DeviceGray"); + pMaskDict->SetIntegerFor("BitsPerComponent", 8); if (pMaskBitmap->GetBPP() == 8 && (iCompress & PDF_IMAGE_MASK_LOSSY_COMPRESS) != 0) { } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) { @@ -268,11 +268,11 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { maskWidth); } } - pMaskDict->SetAtInteger("Length", mask_size); + pMaskDict->SetIntegerFor("Length", mask_size); CPDF_Stream* pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict); m_pDocument->AddIndirectObject(pMaskStream); - pDict->SetAtReference("SMask", m_pDocument, pMaskStream); + pDict->SetReferenceFor("SMask", m_pDocument, pMaskStream); if (bDeleteMask) { delete pMaskBitmap; } diff --git a/core/fpdfapi/fpdf_page/cpdf_meshstream.cpp b/core/fpdfapi/fpdf_page/cpdf_meshstream.cpp index 1d9c56046a..d2dfac34be 100644 --- a/core/fpdfapi/fpdf_page/cpdf_meshstream.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_meshstream.cpp @@ -110,8 +110,8 @@ bool CPDF_MeshStream::Load() { m_Stream.LoadAllData(m_pShadingStream); m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize()); CPDF_Dictionary* pDict = m_pShadingStream->GetDict(); - m_nCoordBits = pDict->GetIntegerBy("BitsPerCoordinate"); - m_nComponentBits = pDict->GetIntegerBy("BitsPerComponent"); + m_nCoordBits = pDict->GetIntegerFor("BitsPerCoordinate"); + m_nComponentBits = pDict->GetIntegerFor("BitsPerComponent"); if (ShouldCheckBPC(m_type)) { if (!IsValidBitsPerCoordinate(m_nCoordBits)) return false; @@ -119,7 +119,7 @@ bool CPDF_MeshStream::Load() { return false; } - m_nFlagBits = pDict->GetIntegerBy("BitsPerFlag"); + m_nFlagBits = pDict->GetIntegerFor("BitsPerFlag"); if (ShouldCheckBitsPerFlag(m_type) && !IsValidBitsPerFlag(m_nFlagBits)) return false; @@ -128,7 +128,7 @@ bool CPDF_MeshStream::Load() { return false; m_nComponents = m_funcs.empty() ? nComponents : 1; - CPDF_Array* pDecode = pDict->GetArrayBy("Decode"); + CPDF_Array* pDecode = pDict->GetArrayFor("Decode"); if (!pDecode || pDecode->GetCount() != 4 + m_nComponents * 2) return false; diff --git a/core/fpdfapi/fpdf_page/cpdf_page.cpp b/core/fpdfapi/fpdf_page/cpdf_page.cpp index 289ef717c4..b9931713c4 100644 --- a/core/fpdfapi/fpdf_page/cpdf_page.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_page.cpp @@ -106,10 +106,10 @@ CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const { std::set<CPDF_Dictionary*> visited; while (1) { visited.insert(pPageDict); - if (CPDF_Object* pObj = pPageDict->GetDirectObjectBy(name)) + if (CPDF_Object* pObj = pPageDict->GetDirectObjectFor(name)) return pObj; - pPageDict = pPageDict->GetDictBy("Parent"); + pPageDict = pPageDict->GetDictFor("Parent"); if (!pPageDict || pdfium::ContainsKey(visited, pPageDict)) break; } diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp b/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp index 77ec205518..eb7cb8e2f5 100644 --- a/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp @@ -60,18 +60,18 @@ void CPDF_PageObjectHolder::LoadTransInfo() { if (!m_pFormDict) { return; } - CPDF_Dictionary* pGroup = m_pFormDict->GetDictBy("Group"); + CPDF_Dictionary* pGroup = m_pFormDict->GetDictFor("Group"); if (!pGroup) { return; } - if (pGroup->GetStringBy("S") != "Transparency") { + if (pGroup->GetStringFor("S") != "Transparency") { return; } m_Transparency |= PDFTRANS_GROUP; - if (pGroup->GetIntegerBy("I")) { + if (pGroup->GetIntegerFor("I")) { m_Transparency |= PDFTRANS_ISOLATED; } - if (pGroup->GetIntegerBy("K")) { + if (pGroup->GetIntegerFor("K")) { m_Transparency |= PDFTRANS_KNOCKOUT; } } diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp index e2205f956d..8da9b4769f 100644 --- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp @@ -38,8 +38,8 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, m_pCountedCS(nullptr) { if (!bShading) { CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); - m_Pattern2Form = pDict->GetMatrixBy("Matrix"); - m_pShadingObj = pDict->GetDirectObjectBy("Shading"); + m_Pattern2Form = pDict->GetMatrixFor("Matrix"); + m_pShadingObj = pDict->GetDirectObjectFor("Shading"); m_Pattern2Form.Concat(parentMatrix); } } @@ -68,7 +68,7 @@ bool CPDF_ShadingPattern::Load() { return FALSE; m_pFunctions.clear(); - CPDF_Object* pFunc = pShadingDict->GetDirectObjectBy("Function"); + CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function"); if (pFunc) { if (CPDF_Array* pArray = pFunc->AsArray()) { m_pFunctions.resize(std::min<size_t>(pArray->GetCount(), 4)); @@ -78,7 +78,7 @@ bool CPDF_ShadingPattern::Load() { m_pFunctions.push_back(CPDF_Function::Load(pFunc)); } } - CPDF_Object* pCSObj = pShadingDict->GetDirectObjectBy("ColorSpace"); + CPDF_Object* pCSObj = pShadingDict->GetDirectObjectFor("ColorSpace"); if (!pCSObj) return FALSE; @@ -87,7 +87,7 @@ bool CPDF_ShadingPattern::Load() { if (m_pCS) m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray()); - m_ShadingType = ToShadingType(pShadingDict->GetIntegerBy("ShadingType")); + m_ShadingType = ToShadingType(pShadingDict->GetIntegerFor("ShadingType")); // We expect to have a stream if our shading type is a mesh. if (IsMeshShading() && !ToStream(m_pShadingObj)) diff --git a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp index f7370de0bc..7c1716dc01 100644 --- a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp @@ -16,8 +16,8 @@ CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, const CFX_Matrix& parentMatrix) : CPDF_Pattern(TILING, pDoc, pPatternObj, parentMatrix) { CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); - m_Pattern2Form = pDict->GetMatrixBy("Matrix"); - m_bColored = pDict->GetIntegerBy("PaintType") == 1; + m_Pattern2Form = pDict->GetMatrixFor("Matrix"); + m_bColored = pDict->GetIntegerFor("PaintType") == 1; m_Pattern2Form.Concat(parentMatrix); } @@ -40,9 +40,9 @@ FX_BOOL CPDF_TilingPattern::Load() { if (!pDict) return FALSE; - m_bColored = pDict->GetIntegerBy("PaintType") == 1; - m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumberBy("XStep")); - m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumberBy("YStep")); + m_bColored = pDict->GetIntegerFor("PaintType") == 1; + m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumberFor("XStep")); + m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumberFor("YStep")); CPDF_Stream* pStream = m_pPatternObj->AsStream(); if (!pStream) @@ -50,6 +50,6 @@ FX_BOOL CPDF_TilingPattern::Load() { m_pForm.reset(new CPDF_Form(m_pDocument, nullptr, pStream)); m_pForm->ParseContent(nullptr, &m_ParentMatrix, nullptr); - m_BBox = pDict->GetRectBy("BBox"); + m_BBox = pDict->GetRectFor("BBox"); return TRUE; } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index fa242ffb85..9e586e326f 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -185,11 +185,11 @@ CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteString& fontName, } CPDF_Dictionary* pDict = new CPDF_Dictionary; - pDict->SetAtName("Type", "Font"); - pDict->SetAtName("Subtype", "Type1"); - pDict->SetAtName("BaseFont", fontName); + pDict->SetNameFor("Type", "Font"); + pDict->SetNameFor("Subtype", "Type1"); + pDict->SetNameFor("BaseFont", fontName); if (pEncoding) { - pDict->SetAt("Encoding", pEncoding->Realize()); + pDict->SetFor("Encoding", pEncoding->Realize()); } m_pPDFDoc->AddIndirectObject(pDict); CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pDict); @@ -241,30 +241,30 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceImpl( CFX_ByteString name = pCSObj->GetString(); CPDF_ColorSpace* pCS = CPDF_ColorSpace::ColorspaceFromName(name); if (!pCS && pResources) { - CPDF_Dictionary* pList = pResources->GetDictBy("ColorSpace"); + CPDF_Dictionary* pList = pResources->GetDictFor("ColorSpace"); if (pList) { pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj); - return GetColorSpaceImpl(pList->GetDirectObjectBy(name), nullptr, + return GetColorSpaceImpl(pList->GetDirectObjectFor(name), nullptr, pVisited); } } if (!pCS || !pResources) return pCS; - CPDF_Dictionary* pColorSpaces = pResources->GetDictBy("ColorSpace"); + CPDF_Dictionary* pColorSpaces = pResources->GetDictFor("ColorSpace"); if (!pColorSpaces) return pCS; CPDF_Object* pDefaultCS = nullptr; switch (pCS->GetFamily()) { case PDFCS_DEVICERGB: - pDefaultCS = pColorSpaces->GetDirectObjectBy("DefaultRGB"); + pDefaultCS = pColorSpaces->GetDirectObjectFor("DefaultRGB"); break; case PDFCS_DEVICEGRAY: - pDefaultCS = pColorSpaces->GetDirectObjectBy("DefaultGray"); + pDefaultCS = pColorSpaces->GetDirectObjectFor("DefaultGray"); break; case PDFCS_DEVICECMYK: - pDefaultCS = pColorSpaces->GetDirectObjectBy("DefaultCMYK"); + pDefaultCS = pColorSpaces->GetDirectObjectFor("DefaultCMYK"); break; } if (!pDefaultCS) @@ -357,7 +357,7 @@ CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj, } else { CPDF_Dictionary* pDict = pPatternObj ? pPatternObj->GetDict() : nullptr; if (pDict) { - int type = pDict->GetIntegerBy("PatternType"); + int type = pDict->GetIntegerFor("PatternType"); if (type == CPDF_Pattern::TILING) { pPattern = new CPDF_TilingPattern(m_pPDFDoc, pPatternObj, matrix); } else if (type == CPDF_Pattern::SHADING) { @@ -491,9 +491,9 @@ CPDF_StreamAcc* CPDF_DocPageData::GetFontFileStreamAcc( return it->second->AddRef(); CPDF_Dictionary* pFontDict = pFontStream->GetDict(); - int32_t org_size = pFontDict->GetIntegerBy("Length1") + - pFontDict->GetIntegerBy("Length2") + - pFontDict->GetIntegerBy("Length3"); + int32_t org_size = pFontDict->GetIntegerFor("Length1") + + pFontDict->GetIntegerFor("Length2") + + pFontDict->GetIntegerFor("Length3"); org_size = std::max(org_size, 0); CPDF_StreamAcc* pFontFile = new CPDF_StreamAcc; diff --git a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp index 6a5bbacda5..63ab3056c7 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -471,10 +471,10 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { return false; CPDF_Dictionary* pDict = pStream->GetDict(); - CPDF_Array* pSize = pDict->GetArrayBy("Size"); - CPDF_Array* pEncode = pDict->GetArrayBy("Encode"); - CPDF_Array* pDecode = pDict->GetArrayBy("Decode"); - m_nBitsPerSample = pDict->GetIntegerBy("BitsPerSample"); + CPDF_Array* pSize = pDict->GetArrayFor("Size"); + CPDF_Array* pEncode = pDict->GetArrayFor("Encode"); + CPDF_Array* pDecode = pDict->GetArrayFor("Decode"); + m_nBitsPerSample = pDict->GetIntegerFor("BitsPerSample"); if (!IsValidBitsPerSample(m_nBitsPerSample)) return FALSE; @@ -486,7 +486,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { for (uint32_t i = 0; i < m_nInputs; i++) { m_EncodeInfo[i].sizes = pSize ? pSize->GetIntegerAt(i) : 0; if (!pSize && i == 0) - m_EncodeInfo[i].sizes = pDict->GetIntegerBy("Size"); + m_EncodeInfo[i].sizes = pDict->GetIntegerFor("Size"); nTotalSampleBits *= m_EncodeInfo[i].sizes; if (pEncode) { m_EncodeInfo[i].encode_min = pEncode->GetFloatAt(i * 2); @@ -601,21 +601,21 @@ FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) { if (!pDict) { return FALSE; } - CPDF_Array* pArray0 = pDict->GetArrayBy("C0"); + CPDF_Array* pArray0 = pDict->GetArrayFor("C0"); if (m_nOutputs == 0) { m_nOutputs = 1; if (pArray0) { m_nOutputs = pArray0->GetCount(); } } - CPDF_Array* pArray1 = pDict->GetArrayBy("C1"); + CPDF_Array* pArray1 = pDict->GetArrayFor("C1"); m_pBeginValues = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2); m_pEndValues = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2); for (uint32_t i = 0; i < m_nOutputs; i++) { m_pBeginValues[i] = pArray0 ? pArray0->GetFloatAt(i) : 0.0f; m_pEndValues[i] = pArray1 ? pArray1->GetFloatAt(i) : 1.0f; } - m_Exponent = pDict->GetFloatBy("N"); + m_Exponent = pDict->GetFloatFor("N"); m_nOrigOutputs = m_nOutputs; if (m_nOutputs && m_nInputs > INT_MAX / m_nOutputs) { return FALSE; @@ -652,7 +652,7 @@ FX_BOOL CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { if (m_nInputs != kRequiredNumInputs) { return FALSE; } - CPDF_Array* pArray = pDict->GetArrayBy("Functions"); + CPDF_Array* pArray = pDict->GetArrayFor("Functions"); if (!pArray) { return FALSE; } @@ -682,14 +682,14 @@ FX_BOOL CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { } m_pBounds = FX_Alloc(FX_FLOAT, nSubs + 1); m_pBounds[0] = m_pDomains[0]; - pArray = pDict->GetArrayBy("Bounds"); + pArray = pDict->GetArrayFor("Bounds"); if (!pArray) return FALSE; for (uint32_t i = 0; i < nSubs - 1; i++) m_pBounds[i + 1] = pArray->GetFloatAt(i); m_pBounds[nSubs] = m_pDomains[1]; m_pEncode = FX_Alloc2D(FX_FLOAT, nSubs, 2); - pArray = pDict->GetArrayBy("Encode"); + pArray = pDict->GetArrayFor("Encode"); if (!pArray) return FALSE; @@ -720,9 +720,9 @@ std::unique_ptr<CPDF_Function> CPDF_Function::Load(CPDF_Object* pFuncObj) { int iType = -1; if (CPDF_Stream* pStream = pFuncObj->AsStream()) - iType = pStream->GetDict()->GetIntegerBy("FunctionType"); + iType = pStream->GetDict()->GetIntegerFor("FunctionType"); else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) - iType = pDict->GetIntegerBy("FunctionType"); + iType = pDict->GetIntegerFor("FunctionType"); Type type = IntegerToFunctionType(iType); if (type == Type::kType0Sampled) @@ -764,7 +764,7 @@ FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { CPDF_Stream* pStream = pObj->AsStream(); CPDF_Dictionary* pDict = pStream ? pStream->GetDict() : pObj->AsDictionary(); - CPDF_Array* pDomains = pDict->GetArrayBy("Domain"); + CPDF_Array* pDomains = pDict->GetArrayFor("Domain"); if (!pDomains) return FALSE; @@ -776,7 +776,7 @@ FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { for (uint32_t i = 0; i < m_nInputs * 2; i++) { m_pDomains[i] = pDomains->GetFloatAt(i); } - CPDF_Array* pRanges = pDict->GetArrayBy("Range"); + CPDF_Array* pRanges = pDict->GetArrayFor("Range"); m_nOutputs = 0; if (pRanges) { m_nOutputs = pRanges->GetCount() / 2; diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index d7f1f3c3e0..46ab067b3e 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -611,22 +611,22 @@ void CPDF_StreamContentParser::Handle_BeginImage() { if (!key.IsEmpty()) { uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; if (dwObjNum) - pDict->SetAtReference(key, m_pDocument, dwObjNum); + pDict->SetReferenceFor(key, m_pDocument, dwObjNum); else - pDict->SetAt(key, pObj.release()); + pDict->SetFor(key, pObj.release()); } } PDF_ReplaceAbbr(pDict); CPDF_Object* pCSObj = nullptr; if (pDict->KeyExist("ColorSpace")) { - pCSObj = pDict->GetDirectObjectBy("ColorSpace"); + pCSObj = pDict->GetDirectObjectFor("ColorSpace"); if (pCSObj->IsName()) { CFX_ByteString name = pCSObj->GetString(); if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") { pCSObj = FindResourceObj("ColorSpace", name); if (pCSObj && !pCSObj->GetObjNum()) { pCSObj = pCSObj->Clone(); - pDict->SetAt("ColorSpace", pCSObj); + pDict->SetFor("ColorSpace", pCSObj); } } } @@ -646,7 +646,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { break; } } - pDict->SetAtName("Subtype", "Image"); + pDict->SetNameFor("Subtype", "Image"); CPDF_ImageObject* pImgObj = AddImage(pStream, nullptr, true); if (!pImgObj) { if (pStream) { @@ -737,7 +737,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { CFX_ByteString type; if (pXObject->GetDict()) - type = pXObject->GetDict()->GetStringBy("Subtype"); + type = pXObject->GetDict()->GetStringFor("Subtype"); if (type == "Image") { CPDF_ImageObject* pObj = AddImage(pXObject, nullptr, false); @@ -1134,14 +1134,14 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj( const CFX_ByteString& name) { if (!m_pResources) return nullptr; - CPDF_Dictionary* pDict = m_pResources->GetDictBy(type); + CPDF_Dictionary* pDict = m_pResources->GetDictFor(type); if (pDict) - return pDict->GetDirectObjectBy(name); + return pDict->GetDirectObjectFor(name); if (m_pResources == m_pPageResources || !m_pPageResources) return nullptr; - CPDF_Dictionary* pPageDict = m_pPageResources->GetDictBy(type); - return pPageDict ? pPageDict->GetDirectObjectBy(name) : nullptr; + CPDF_Dictionary* pPageDict = m_pPageResources->GetDictFor(type); + return pPageDict ? pPageDict->GetDirectObjectFor(name) : nullptr; } CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { @@ -1652,7 +1652,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) { if (op.is_replace_key) pDict->ReplaceKey(op.key, CFX_ByteString(op.replacement)); else - pDict->SetAtName(op.key, CFX_ByteString(op.replacement)); + pDict->SetNameFor(op.key, CFX_ByteString(op.replacement)); } break; } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 745a707902..eab0ee595b 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -121,7 +121,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, CCodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( src_buf, limit, width, height, 0, - pParam ? pParam->GetIntegerBy("ColorTransform", 1) : 1); + pParam ? pParam->GetIntegerFor("ColorTransform", 1) : 1); return DecodeAllScanlines(pDecoder, dest_buf, dest_size); } if (decoder == "RunLengthDecode" || decoder == "RL") { @@ -143,23 +143,23 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, CFX_ByteString Decoder; CPDF_Dictionary* pParam = nullptr; - CPDF_Object* pFilter = pDict->GetDirectObjectBy("Filter"); + CPDF_Object* pFilter = pDict->GetDirectObjectFor("Filter"); if (pFilter) { if (CPDF_Array* pArray = pFilter->AsArray()) { Decoder = pArray->GetStringAt(0); - CPDF_Array* pParams = pDict->GetArrayBy("DecodeParms"); + CPDF_Array* pParams = pDict->GetArrayFor("DecodeParms"); if (pParams) pParam = pParams->GetDictAt(0); } else { Decoder = pFilter->GetString(); - pParam = pDict->GetDictBy("DecodeParms"); + pParam = pDict->GetDictFor("DecodeParms"); } } - uint32_t width = pDict->GetIntegerBy("Width"); - uint32_t height = pDict->GetIntegerBy("Height"); + uint32_t width = pDict->GetIntegerFor("Width"); + uint32_t height = pDict->GetIntegerFor("Height"); uint32_t OrigSize = 0; if (pCSObj) { - uint32_t bpc = pDict->GetIntegerBy("BitsPerComponent"); + uint32_t bpc = pDict->GetIntegerFor("BitsPerComponent"); uint32_t nComponents = 1; CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj); if (pCS) { @@ -236,7 +236,7 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize); m_Pos += dwStreamSize; } - pDict->SetAtInteger("Length", (int)dwStreamSize); + pDict->SetIntegerFor("Length", (int)dwStreamSize); return new CPDF_Stream(pData, dwStreamSize, pDict); } @@ -369,7 +369,7 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray, if (key.IsEmpty()) pObj->Release(); else - pDict->SetAt(key, pObj); + pDict->SetFor(key, pObj); } return pDict; } @@ -651,7 +651,7 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage) { m_InternalStage = STAGE_GETCONTENT; m_CurrentOffset = 0; - CPDF_Object* pContent = pPage->m_pFormDict->GetDirectObjectBy("Contents"); + CPDF_Object* pContent = pPage->m_pFormDict->GetDirectObjectFor("Contents"); if (!pContent) { m_Status = Done; return; @@ -679,11 +679,11 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, m_pType3Char = pType3Char; m_pObjectHolder = pForm; m_bForm = TRUE; - CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); + CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixFor("Matrix"); if (pGraphicStates) { form_matrix.Concat(pGraphicStates->m_CTM); } - CPDF_Array* pBBox = pForm->m_pFormDict->GetArrayBy("BBox"); + CPDF_Array* pBBox = pForm->m_pFormDict->GetArrayFor("BBox"); CFX_FloatRect form_bbox; CPDF_Path ClipPath; if (pBBox) { @@ -700,7 +700,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, form_bbox.Transform(pParentMatrix); } } - CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictBy("Resources"); + CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources"); m_pParser.reset(new CPDF_StreamContentParser( pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level)); @@ -759,7 +759,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) { m_CurrentOffset = 0; } else { CPDF_Array* pContent = - m_pObjectHolder->m_pFormDict->GetArrayBy("Contents"); + m_pObjectHolder->m_pFormDict->GetArrayFor("Contents"); m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc); CPDF_Stream* pStreamObj = ToStream( pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr); diff --git a/core/fpdfapi/fpdf_parser/cfdf_document.cpp b/core/fpdfapi/fpdf_parser/cfdf_document.cpp index e2e4d0cf1e..0182948173 100644 --- a/core/fpdfapi/fpdf_parser/cfdf_document.cpp +++ b/core/fpdfapi/fpdf_parser/cfdf_document.cpp @@ -26,7 +26,7 @@ CFDF_Document* CFDF_Document::CreateNewDoc() { pDoc->m_pRootDict = new CPDF_Dictionary; pDoc->AddIndirectObject(pDoc->m_pRootDict); CPDF_Dictionary* pFDFDict = new CPDF_Dictionary; - pDoc->m_pRootDict->SetAt("FDF", pFDFDict); + pDoc->m_pRootDict->SetFor("FDF", pFDFDict); return pDoc; } @@ -76,7 +76,7 @@ void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) { if (CPDF_Dictionary* pMainDict = ToDictionary(parser.GetObject(this, 0, 0, true))) { - m_pRootDict = pMainDict->GetDictBy("Root"); + m_pRootDict = pMainDict->GetDictFor("Root"); pMainDict->Release(); } break; diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp index b7395ee7a5..7a9b704f53 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp @@ -151,7 +151,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail( pObj = pObj->GetDict(); case CPDF_Object::DICTIONARY: { CPDF_Dictionary* pDict = pObj->GetDict(); - if (pDict && pDict->GetStringBy("Type") == "Page" && !bParsePage) + if (pDict && pDict->GetStringFor("Type") == "Page" && !bParsePage) continue; for (const auto& it : *pDict) { @@ -441,7 +441,7 @@ FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { return FALSE; } - CPDF_Reference* pRef = ToReference(pDict->GetObjectBy("Pages")); + CPDF_Reference* pRef = ToReference(pDict->GetObjectFor("Pages")); if (!pRef) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; @@ -449,7 +449,7 @@ FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { m_PagesObjNum = pRef->GetRefObjNum(); CPDF_Reference* pAcroFormRef = - ToReference(m_pRoot->GetDict()->GetObjectBy("AcroForm")); + ToReference(m_pRoot->GetDict()->GetObjectFor("AcroForm")); if (pAcroFormRef) { m_bHaveAcroForm = TRUE; m_dwAcroFormObjNum = pAcroFormRef->GetRefObjNum(); @@ -467,7 +467,7 @@ FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { FX_BOOL CPDF_DataAvail::PreparePageItem() { CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); CPDF_Reference* pRef = - ToReference(pRoot ? pRoot->GetObjectBy("Pages") : nullptr); + ToReference(pRoot ? pRoot->GetObjectFor("Pages") : nullptr); if (!pRef) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; @@ -513,7 +513,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) { continue; } - CFX_ByteString type = pObj->GetDict()->GetStringBy("Type"); + CFX_ByteString type = pObj->GetDict()->GetStringFor("Type"); if (type == "Pages") { m_PagesArray.Add(pObj); continue; @@ -560,7 +560,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { } CPDF_Dictionary* pDict = pPages->GetDict(); - CPDF_Object* pKids = pDict ? pDict->GetObjectBy("Kids") : nullptr; + CPDF_Object* pKids = pDict ? pDict->GetObjectFor("Kids") : nullptr; if (!pKids) return TRUE; @@ -633,19 +633,19 @@ FX_BOOL CPDF_DataAvail::CheckHeader(DownloadHints* pHints) { FX_BOOL CPDF_DataAvail::CheckFirstPage(DownloadHints* pHints) { CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : nullptr; + CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectFor("E") : nullptr; if (!pEndOffSet) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } - CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectBy("T") : nullptr; + CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectFor("T") : nullptr; if (!pXRefOffset) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } - CPDF_Object* pFileLen = pDict ? pDict->GetObjectBy("L") : nullptr; + CPDF_Object* pFileLen = pDict ? pDict->GetObjectFor("L") : nullptr; if (!pFileLen) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; @@ -728,13 +728,13 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) { } // The actual value is not required here, but validate its existence and type. - CPDF_Number* pFirstPage = ToNumber(pDict->GetDirectObjectBy("O")); + CPDF_Number* pFirstPage = ToNumber(pDict->GetDirectObjectFor("O")); if (!pFirstPage || !pFirstPage->IsInteger()) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } - CPDF_Number* pPageCount = ToNumber(pDict->GetDirectObjectBy("N")); + CPDF_Number* pPageCount = ToNumber(pDict->GetDirectObjectFor("N")); if (!pPageCount || !pPageCount->IsInteger()) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; @@ -746,7 +746,7 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) { return TRUE; } - CPDF_Array* pHintStreamRange = pDict->GetArrayBy("H"); + CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H"); size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->GetCount() : 0; if (nHintStreamSize != 2 && nHintStreamSize != 4) { m_docStatus = PDF_DATAAVAIL_ERROR; @@ -869,10 +869,10 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) { return FALSE; CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - if (!pDict || !pDict->GetObjectBy("Linearized")) + if (!pDict || !pDict->GetObjectFor("Linearized")) return FALSE; - CPDF_Object* pLen = pDict->GetObjectBy("L"); + CPDF_Object* pLen = pDict->GetObjectFor("L"); if (!pLen) return FALSE; @@ -881,7 +881,7 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) { m_bLinearized = TRUE; - if (CPDF_Number* pNo = ToNumber(pDict->GetObjectBy("P"))) + if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P"))) m_dwFirstPageNo = pNo->GetInteger(); return TRUE; @@ -958,11 +958,11 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(DownloadHints* pHints, } CPDF_Dictionary* pDict = pObj->GetDict(); - CPDF_Name* pName = ToName(pDict ? pDict->GetObjectBy("Type") : nullptr); + CPDF_Name* pName = ToName(pDict ? pDict->GetObjectFor("Type") : nullptr); if (pName) { if (pName->GetString() == "XRef") { m_Pos += m_parser.m_pSyntax->SavePos(); - xref_offset = pObj->GetDict()->GetIntegerBy("Prev"); + xref_offset = pObj->GetDict()->GetIntegerFor("Prev"); pObj->Release(); return 1; } @@ -1205,7 +1205,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) { return FALSE; CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); - CPDF_Object* pEncrypt = pTrailerDict->GetObjectBy("Encrypt"); + CPDF_Object* pEncrypt = pTrailerDict->GetObjectFor("Encrypt"); if (ToReference(pEncrypt)) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; return TRUE; @@ -1328,10 +1328,10 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, pPageNode->m_dwPageNo = dwPageNo; CPDF_Dictionary* pDict = pPage->GetDict(); - CFX_ByteString type = pDict->GetStringBy("Type"); + CFX_ByteString type = pDict->GetStringFor("Type"); if (type == "Pages") { pPageNode->m_type = PDF_PAGENODE_PAGES; - CPDF_Object* pKids = pDict->GetObjectBy("Kids"); + CPDF_Object* pKids = pDict->GetObjectFor("Kids"); if (!pKids) { m_docStatus = PDF_DATAAVAIL_PAGE; return TRUE; @@ -1464,7 +1464,7 @@ FX_BOOL CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) { return TRUE; } - int count = pPagesDict->GetIntegerBy("Count"); + int count = pPagesDict->GetIntegerFor("Count"); if (count > 0) { pPages->Release(); return TRUE; @@ -1544,7 +1544,7 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(uint32_t dwPage, if (!pPageDict) return TRUE; - CPDF_Object* pAnnots = pPageDict->GetObjectBy("Annots"); + CPDF_Object* pAnnots = pPageDict->GetObjectFor("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->GetObjectBy("Parent"); + CPDF_Object* pParent = pDict->GetObjectFor("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->GetObjectBy("Resources"); + CPDF_Object* pRet = pParentDict->GetObjectFor("Resources"); if (pRet) { m_pPageResource = pRet; return TRUE; @@ -1710,7 +1710,7 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( } if (m_pPageDict && !m_bNeedDownLoadResource) { - m_pPageResource = m_pPageDict->GetObjectBy("Resources"); + m_pPageResource = m_pPageDict->GetObjectFor("Resources"); m_bNeedDownLoadResource = m_pPageResource || HaveResourceAncestor(m_pPageDict); } @@ -1761,7 +1761,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->GetDirectObjectBy("N") : nullptr; + CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("N") : nullptr; return pObj ? pObj->GetInteger() : 0; } return m_pDocument ? m_pDocument->GetPageCount() : 0; @@ -1773,7 +1773,7 @@ CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { if (m_pLinearized) { CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - CPDF_Object* pObj = pDict ? pDict->GetDirectObjectBy("P") : nullptr; + CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("P") : nullptr; int pageNum = pObj ? pObj->GetInteger() : 0; if (m_pHintTables && index != pageNum) { @@ -1810,7 +1810,7 @@ CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( if (!pRoot) return FormAvailable; - CPDF_Object* pAcroForm = pRoot->GetObjectBy("AcroForm"); + CPDF_Object* pAcroForm = pRoot->GetObjectFor("AcroForm"); if (!pAcroForm) return FormNotExist; diff --git a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp index e79bac1839..cc395a2e08 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp @@ -71,59 +71,59 @@ CPDF_Object* CPDF_Dictionary::CloneNonCyclic( return pCopy; } -CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteString& key) const { +CPDF_Object* CPDF_Dictionary::GetObjectFor(const CFX_ByteString& key) const { auto it = m_Map.find(key); return it != m_Map.end() ? it->second : nullptr; } -CPDF_Object* CPDF_Dictionary::GetDirectObjectBy( +CPDF_Object* CPDF_Dictionary::GetDirectObjectFor( const CFX_ByteString& key) const { - CPDF_Object* p = GetObjectBy(key); + CPDF_Object* p = GetObjectFor(key); return p ? p->GetDirect() : nullptr; } -CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteString& key) const { - CPDF_Object* p = GetObjectBy(key); +CFX_ByteString CPDF_Dictionary::GetStringFor(const CFX_ByteString& key) const { + CPDF_Object* p = GetObjectFor(key); return p ? p->GetString() : CFX_ByteString(); } -CFX_WideString CPDF_Dictionary::GetUnicodeTextBy( +CFX_WideString CPDF_Dictionary::GetUnicodeTextFor( const CFX_ByteString& key) const { - CPDF_Object* p = GetObjectBy(key); + CPDF_Object* p = GetObjectFor(key); if (CPDF_Reference* pRef = ToReference(p)) p = pRef->GetDirect(); return p ? p->GetUnicodeText() : CFX_WideString(); } -CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteString& key, - const CFX_ByteString& def) const { - CPDF_Object* p = GetObjectBy(key); +CFX_ByteString CPDF_Dictionary::GetStringFor(const CFX_ByteString& key, + const CFX_ByteString& def) const { + CPDF_Object* p = GetObjectFor(key); return p ? p->GetString() : CFX_ByteString(def); } -int CPDF_Dictionary::GetIntegerBy(const CFX_ByteString& key) const { - CPDF_Object* p = GetObjectBy(key); +int CPDF_Dictionary::GetIntegerFor(const CFX_ByteString& key) const { + CPDF_Object* p = GetObjectFor(key); return p ? p->GetInteger() : 0; } -int CPDF_Dictionary::GetIntegerBy(const CFX_ByteString& key, int def) const { - CPDF_Object* p = GetObjectBy(key); +int CPDF_Dictionary::GetIntegerFor(const CFX_ByteString& key, int def) const { + CPDF_Object* p = GetObjectFor(key); return p ? p->GetInteger() : def; } -FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteString& key) const { - CPDF_Object* p = GetObjectBy(key); +FX_FLOAT CPDF_Dictionary::GetNumberFor(const CFX_ByteString& key) const { + CPDF_Object* p = GetObjectFor(key); return p ? p->GetNumber() : 0; } -bool CPDF_Dictionary::GetBooleanBy(const CFX_ByteString& key, - bool bDefault) const { - CPDF_Object* p = GetObjectBy(key); +bool CPDF_Dictionary::GetBooleanFor(const CFX_ByteString& key, + bool bDefault) const { + CPDF_Object* p = GetObjectFor(key); return ToBoolean(p) ? p->GetInteger() != 0 : bDefault; } -CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteString& key) const { - CPDF_Object* p = GetDirectObjectBy(key); +CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const CFX_ByteString& key) const { + CPDF_Object* p = GetDirectObjectFor(key); if (!p) return nullptr; if (CPDF_Dictionary* pDict = p->AsDictionary()) @@ -133,25 +133,25 @@ CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteString& key) const { return nullptr; } -CPDF_Array* CPDF_Dictionary::GetArrayBy(const CFX_ByteString& key) const { - return ToArray(GetDirectObjectBy(key)); +CPDF_Array* CPDF_Dictionary::GetArrayFor(const CFX_ByteString& key) const { + return ToArray(GetDirectObjectFor(key)); } -CPDF_Stream* CPDF_Dictionary::GetStreamBy(const CFX_ByteString& key) const { - return ToStream(GetDirectObjectBy(key)); +CPDF_Stream* CPDF_Dictionary::GetStreamFor(const CFX_ByteString& key) const { + return ToStream(GetDirectObjectFor(key)); } -CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteString& key) const { +CFX_FloatRect CPDF_Dictionary::GetRectFor(const CFX_ByteString& key) const { CFX_FloatRect rect; - CPDF_Array* pArray = GetArrayBy(key); + CPDF_Array* pArray = GetArrayFor(key); if (pArray) rect = pArray->GetRect(); return rect; } -CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteString& key) const { +CFX_Matrix CPDF_Dictionary::GetMatrixFor(const CFX_ByteString& key) const { CFX_Matrix matrix; - CPDF_Array* pArray = GetArrayBy(key); + CPDF_Array* pArray = GetArrayFor(key); if (pArray) matrix = pArray->GetMatrix(); return matrix; @@ -162,13 +162,13 @@ FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteString& key) const { } bool CPDF_Dictionary::IsSignatureDict() const { - CPDF_Object* pType = GetDirectObjectBy("Type"); + CPDF_Object* pType = GetDirectObjectFor("Type"); if (!pType) - pType = GetDirectObjectBy("FT"); + pType = GetDirectObjectFor("FT"); return pType && pType->GetString() == "Sig"; } -void CPDF_Dictionary::SetAt(const CFX_ByteString& key, CPDF_Object* pObj) { +void CPDF_Dictionary::SetFor(const CFX_ByteString& key, CPDF_Object* pObj) { auto it = m_Map.find(key); if (it == m_Map.end()) { if (pObj) @@ -186,7 +186,7 @@ void CPDF_Dictionary::SetAt(const CFX_ByteString& key, CPDF_Object* pObj) { m_Map.erase(it); } -void CPDF_Dictionary::RemoveAt(const CFX_ByteString& key) { +void CPDF_Dictionary::RemoveFor(const CFX_ByteString& key) { auto it = m_Map.find(key); if (it == m_Map.end()) return; @@ -214,46 +214,46 @@ void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey, m_Map.erase(old_it); } -void CPDF_Dictionary::SetAtInteger(const CFX_ByteString& key, int i) { - SetAt(key, new CPDF_Number(i)); +void CPDF_Dictionary::SetIntegerFor(const CFX_ByteString& key, int i) { + SetFor(key, new CPDF_Number(i)); } -void CPDF_Dictionary::SetAtName(const CFX_ByteString& key, - const CFX_ByteString& name) { - SetAt(key, new CPDF_Name(name)); +void CPDF_Dictionary::SetNameFor(const CFX_ByteString& key, + const CFX_ByteString& name) { + SetFor(key, new CPDF_Name(name)); } -void CPDF_Dictionary::SetAtString(const CFX_ByteString& key, - const CFX_ByteString& str) { - SetAt(key, new CPDF_String(str, FALSE)); +void CPDF_Dictionary::SetStringFor(const CFX_ByteString& key, + const CFX_ByteString& str) { + SetFor(key, new CPDF_String(str, FALSE)); } -void CPDF_Dictionary::SetAtReference(const CFX_ByteString& key, - CPDF_IndirectObjectHolder* pDoc, - uint32_t objnum) { - SetAt(key, new CPDF_Reference(pDoc, objnum)); +void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key, + CPDF_IndirectObjectHolder* pDoc, + uint32_t objnum) { + SetFor(key, new CPDF_Reference(pDoc, objnum)); } -void CPDF_Dictionary::SetAtNumber(const CFX_ByteString& key, FX_FLOAT f) { - SetAt(key, new CPDF_Number(f)); +void CPDF_Dictionary::SetNumberFor(const CFX_ByteString& key, FX_FLOAT f) { + SetFor(key, new CPDF_Number(f)); } -void CPDF_Dictionary::SetAtBoolean(const CFX_ByteString& key, bool bValue) { - SetAt(key, new CPDF_Boolean(bValue)); +void CPDF_Dictionary::SetBooleanFor(const CFX_ByteString& key, bool bValue) { + SetFor(key, new CPDF_Boolean(bValue)); } -void CPDF_Dictionary::SetAtRect(const CFX_ByteString& key, - const CFX_FloatRect& rect) { +void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key, + const CFX_FloatRect& rect) { CPDF_Array* pArray = new CPDF_Array; pArray->AddNumber(rect.left); pArray->AddNumber(rect.bottom); pArray->AddNumber(rect.right); pArray->AddNumber(rect.top); - SetAt(key, pArray); + SetFor(key, pArray); } -void CPDF_Dictionary::SetAtMatrix(const CFX_ByteString& key, - const CFX_Matrix& matrix) { +void CPDF_Dictionary::SetMatrixFor(const CFX_ByteString& key, + const CFX_Matrix& matrix) { CPDF_Array* pArray = new CPDF_Array; pArray->AddNumber(matrix.a); pArray->AddNumber(matrix.b); @@ -261,5 +261,5 @@ void CPDF_Dictionary::SetAtMatrix(const CFX_ByteString& key, pArray->AddNumber(matrix.d); pArray->AddNumber(matrix.e); pArray->AddNumber(matrix.f); - SetAt(key, pArray); + SetFor(key, pArray); } diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp index b3fdc7c07f..9f5a4299e9 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp @@ -255,27 +255,27 @@ int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPage, FX_BOOL bInsert, std::set<CPDF_Dictionary*>* pVisited) { - CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); + CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); if (!pKidList) return -1; for (size_t i = 0; i < pKidList->GetCount(); i++) { CPDF_Dictionary* pKid = pKidList->GetDictAt(i); - if (pKid->GetStringBy("Type") == "Page") { + if (pKid->GetStringFor("Type") == "Page") { if (nPagesToGo == 0) { if (bInsert) { pKidList->InsertAt(i, new CPDF_Reference(pDoc, pPage->GetObjNum())); - pPage->SetAtReference("Parent", pDoc, pPages->GetObjNum()); + pPage->SetReferenceFor("Parent", pDoc, pPages->GetObjNum()); } else { pKidList->RemoveAt(i); } - pPages->SetAtInteger( - "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1)); + pPages->SetIntegerFor( + "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); return 1; } nPagesToGo--; } else { - int nPages = pKid->GetIntegerBy("Count"); + int nPages = pKid->GetIntegerFor("Count"); if (nPagesToGo < nPages) { if (pdfium::ContainsKey(*pVisited, pKid)) return -1; @@ -285,8 +285,8 @@ int InsertDeletePDFPage(CPDF_Document* pDoc, pVisited) < 0) { return -1; } - pPages->SetAtInteger( - "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1)); + pPages->SetIntegerFor( + "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); return 1; } nPagesToGo -= nPages; @@ -300,7 +300,7 @@ int InsertNewPage(CPDF_Document* pDoc, CPDF_Dictionary* pPageDict, CFX_ArrayTemplate<uint32_t>& pageList) { CPDF_Dictionary* pRoot = pDoc->GetRoot(); - CPDF_Dictionary* pPages = pRoot ? pRoot->GetDictBy("Pages") : nullptr; + CPDF_Dictionary* pPages = pRoot ? pRoot->GetDictFor("Pages") : nullptr; if (!pPages) return -1; @@ -309,14 +309,14 @@ int InsertNewPage(CPDF_Document* pDoc, return -1; if (iPage == nPages) { - CPDF_Array* pPagesList = pPages->GetArrayBy("Kids"); + CPDF_Array* pPagesList = pPages->GetArrayFor("Kids"); if (!pPagesList) { pPagesList = new CPDF_Array; - pPages->SetAt("Kids", pPagesList); + pPages->SetFor("Kids", pPagesList); } pPagesList->Add(pPageDict, pDoc); - pPages->SetAtInteger("Count", nPages + 1); - pPageDict->SetAtReference("Parent", pDoc, pPages->GetObjNum()); + pPages->SetIntegerFor("Count", nPages + 1); + pPageDict->SetReferenceFor("Parent", pDoc, pPages->GetObjNum()); } else { std::set<CPDF_Dictionary*> stack = {pPages}; if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, &stack) < 0) @@ -328,10 +328,10 @@ int InsertNewPage(CPDF_Document* pDoc, int CountPages(CPDF_Dictionary* pPages, std::set<CPDF_Dictionary*>* visited_pages) { - int count = pPages->GetIntegerBy("Count"); + int count = pPages->GetIntegerFor("Count"); if (count > 0 && count < FPDF_PAGE_MAX_NUM) return count; - CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); + CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); if (!pKidList) return 0; count = 0; @@ -349,7 +349,7 @@ int CountPages(CPDF_Dictionary* pPages, count++; } } - pPages->SetAtInteger("Count", count); + pPages->SetIntegerFor("Count", count); return count; } @@ -388,11 +388,11 @@ void ProcessNonbCJK(CPDF_Dictionary* pBaseDict, basefont += ",Bold"; else if (italic) basefont += ",Italic"; - pBaseDict->SetAtName("Subtype", "TrueType"); - pBaseDict->SetAtName("BaseFont", basefont); - pBaseDict->SetAtNumber("FirstChar", 32); - pBaseDict->SetAtNumber("LastChar", 255); - pBaseDict->SetAt("Widths", pWidths); + pBaseDict->SetNameFor("Subtype", "TrueType"); + pBaseDict->SetNameFor("BaseFont", basefont); + pBaseDict->SetNumberFor("FirstChar", 32); + pBaseDict->SetNumberFor("LastChar", 255); + pBaseDict->SetFor("Widths", pWidths); } } // namespace @@ -446,16 +446,16 @@ void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) { LoadDocInternal(); uint32_t dwPageCount = 0; - CPDF_Object* pCount = pLinearizationParams->GetObjectBy("N"); + CPDF_Object* pCount = pLinearizationParams->GetObjectFor("N"); if (ToNumber(pCount)) dwPageCount = pCount->GetInteger(); m_PageList.SetSize(dwPageCount); - CPDF_Object* pNo = pLinearizationParams->GetObjectBy("P"); + CPDF_Object* pNo = pLinearizationParams->GetObjectFor("P"); if (ToNumber(pNo)) m_iFirstPageNo = pNo->GetInteger(); - CPDF_Object* pObjNum = pLinearizationParams->GetObjectBy("O"); + CPDF_Object* pObjNum = pLinearizationParams->GetObjectFor("O"); if (ToNumber(pObjNum)) m_dwFirstPageObjNum = pObjNum->GetInteger(); } @@ -468,7 +468,7 @@ CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, int iPage, int nPagesToGo, int level) { - CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); + CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); if (!pKidList) return nPagesToGo == 0 ? pPages : nullptr; @@ -490,7 +490,7 @@ CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, m_PageList.SetAt(iPage - nPagesToGo, pKid->GetObjNum()); nPagesToGo--; } else { - int nPages = pKid->GetIntegerBy("Count"); + int nPages = pKid->GetIntegerFor("Count"); if (nPagesToGo < nPages) return FindPDFPage(pKid, iPage, nPagesToGo, level + 1); @@ -502,7 +502,7 @@ CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, CPDF_Dictionary* CPDF_Document::GetPagesDict() const { CPDF_Dictionary* pRoot = GetRoot(); - return pRoot ? pRoot->GetDictBy("Pages") : nullptr; + return pRoot ? pRoot->GetDictFor("Pages") : nullptr; } CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { @@ -550,14 +550,14 @@ int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode, return -1; } - CPDF_Array* pKidList = pNode->GetArrayBy("Kids"); + CPDF_Array* pKidList = pNode->GetArrayFor("Kids"); if (!pKidList) return -1; if (level >= FX_MAX_PAGE_LEVEL) return -1; - size_t count = pNode->GetIntegerBy("Count"); + size_t count = pNode->GetIntegerFor("Count"); if (count <= skip_count) { skip_count -= count; index += count; @@ -673,21 +673,21 @@ CPDF_Image* CPDF_Document::LoadImageF(CPDF_Object* pObj) { void CPDF_Document::CreateNewDoc() { ASSERT(!m_pRootDict && !m_pInfoDict); m_pRootDict = new CPDF_Dictionary; - m_pRootDict->SetAtName("Type", "Catalog"); + m_pRootDict->SetNameFor("Type", "Catalog"); int objnum = AddIndirectObject(m_pRootDict); CPDF_Dictionary* pPages = new CPDF_Dictionary; - pPages->SetAtName("Type", "Pages"); - pPages->SetAtNumber("Count", 0); - pPages->SetAt("Kids", new CPDF_Array); + pPages->SetNameFor("Type", "Pages"); + pPages->SetNumberFor("Count", 0); + pPages->SetFor("Kids", new CPDF_Array); objnum = AddIndirectObject(pPages); - m_pRootDict->SetAtReference("Pages", this, objnum); + m_pRootDict->SetReferenceFor("Pages", this, objnum); m_pInfoDict = new CPDF_Dictionary; AddIndirectObject(m_pInfoDict); } CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) { CPDF_Dictionary* pDict = new CPDF_Dictionary; - pDict->SetAtName("Type", "Page"); + pDict->SetNameFor("Type", "Page"); uint32_t dwObjNum = AddIndirectObject(pDict); if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) { ReleaseIndirectObject(dwObjNum); @@ -701,7 +701,7 @@ void CPDF_Document::DeletePage(int iPage) { if (!pPages) return; - int nPages = pPages->GetIntegerBy("Count"); + int nPages = pPages->GetIntegerFor("Count"); if (iPage < 0 || iPage >= nPages) return; @@ -730,7 +730,7 @@ size_t CPDF_Document::CalculateEncodingDict(int charset, if (i == FX_ArraySize(g_FX_CharsetUnicodes)) return i; CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary; - pEncodingDict->SetAtName("BaseEncoding", "WinAnsiEncoding"); + pEncodingDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); CPDF_Array* pArray = new CPDF_Array; pArray->AddInteger(128); const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; @@ -738,9 +738,9 @@ size_t CPDF_Document::CalculateEncodingDict(int charset, CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); pArray->AddName(name.IsEmpty() ? ".notdef" : name); } - pEncodingDict->SetAt("Differences", pArray); + pEncodingDict->SetFor("Differences", pArray); AddIndirectObject(pEncodingDict); - pBaseDict->SetAtReference("Encoding", this, pEncodingDict); + pBaseDict->SetReferenceFor("Encoding", this, pEncodingDict); return i; } @@ -759,7 +759,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { false, false, charset == FXFONT_SYMBOL_CHARSET); CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; - pBaseDict->SetAtName("Type", "Font"); + pBaseDict->SetNameFor("Type", "Font"); std::unique_ptr<CFX_UnicodeEncoding> pEncoding( new CFX_UnicodeEncoding(pFont)); CPDF_Dictionary* pFontDict = pBaseDict; @@ -772,7 +772,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { } if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { - pBaseDict->SetAtName("Encoding", "WinAnsiEncoding"); + pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); for (int charcode = 128; charcode <= 255; charcode++) { int glyph_index = pEncoding->GlyphFromCharCode(charcode); int char_width = pFont->GetGlyphWidth(glyph_index); @@ -836,33 +836,33 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { InsertWidthArray1(pFont, pEncoding.get(), 0x7e, 0x7e, pWidthArray); break; } - pBaseDict->SetAtName("Subtype", "Type0"); - pBaseDict->SetAtName("BaseFont", basefont); - pBaseDict->SetAtName("Encoding", cmap); - pFontDict->SetAt("W", pWidthArray); - pFontDict->SetAtName("Type", "Font"); - pFontDict->SetAtName("Subtype", "CIDFontType2"); - pFontDict->SetAtName("BaseFont", basefont); + pBaseDict->SetNameFor("Subtype", "Type0"); + pBaseDict->SetNameFor("BaseFont", basefont); + pBaseDict->SetNameFor("Encoding", cmap); + pFontDict->SetFor("W", pWidthArray); + pFontDict->SetNameFor("Type", "Font"); + pFontDict->SetNameFor("Subtype", "CIDFontType2"); + pFontDict->SetNameFor("BaseFont", basefont); CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary; - pCIDSysInfo->SetAtString("Registry", "Adobe"); - pCIDSysInfo->SetAtString("Ordering", ordering); - pCIDSysInfo->SetAtInteger("Supplement", supplement); - pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo); + pCIDSysInfo->SetStringFor("Registry", "Adobe"); + pCIDSysInfo->SetStringFor("Ordering", ordering); + pCIDSysInfo->SetIntegerFor("Supplement", supplement); + pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo); CPDF_Array* pArray = new CPDF_Array; - pBaseDict->SetAt("DescendantFonts", pArray); + pBaseDict->SetFor("DescendantFonts", pArray); AddIndirectObject(pFontDict); pArray->AddReference(this, pFontDict); } AddIndirectObject(pBaseDict); CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; - pFontDesc->SetAtName("Type", "FontDescriptor"); - pFontDesc->SetAtName("FontName", basefont); - pFontDesc->SetAtInteger("Flags", flags); - pFontDesc->SetAtInteger( + pFontDesc->SetNameFor("Type", "FontDescriptor"); + pFontDesc->SetNameFor("FontName", basefont); + pFontDesc->SetIntegerFor("Flags", flags); + pFontDesc->SetIntegerFor( "ItalicAngle", pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0); - pFontDesc->SetAtInteger("Ascent", pFont->GetAscent()); - pFontDesc->SetAtInteger("Descent", pFont->GetDescent()); + pFontDesc->SetIntegerFor("Ascent", pFont->GetAscent()); + pFontDesc->SetIntegerFor("Descent", pFont->GetDescent()); FX_RECT bbox; pFont->GetBBox(bbox); CPDF_Array* pBBox = new CPDF_Array; @@ -870,7 +870,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { pBBox->AddInteger(bbox.bottom); pBBox->AddInteger(bbox.right); pBBox->AddInteger(bbox.top); - pFontDesc->SetAt("FontBBox", pBBox); + pFontDesc->SetFor("FontBBox", pBBox); int32_t nStemV = 0; if (pFont->GetSubstFont()) { nStemV = pFont->GetSubstFont()->m_Weight / 5; @@ -886,9 +886,9 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { nStemV = width; } } - pFontDesc->SetAtInteger("StemV", nStemV); + pFontDesc->SetIntegerFor("StemV", nStemV); AddIndirectObject(pFontDesc); - pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); + pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); return LoadFont(pBaseDict); } @@ -951,13 +951,13 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, FX_Free(tm_buf); basefont.Replace(" ", ""); CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; - pBaseDict->SetAtName("Type", "Font"); + pBaseDict->SetNameFor("Type", "Font"); CPDF_Dictionary* pFontDict = pBaseDict; if (!bCJK) { if (pLogFont->lfCharSet == ANSI_CHARSET || pLogFont->lfCharSet == DEFAULT_CHARSET || pLogFont->lfCharSet == SYMBOL_CHARSET) { - pBaseDict->SetAtName("Encoding", "WinAnsiEncoding"); + pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); } else { CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); } @@ -1011,39 +1011,39 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, InsertWidthArray(hDC, 0x7e, 0x7e, pWidthArray); break; } - pBaseDict->SetAtName("Subtype", "Type0"); - pBaseDict->SetAtName("BaseFont", basefont); - pBaseDict->SetAtName("Encoding", cmap); - pFontDict->SetAt("W", pWidthArray); - pFontDict->SetAtName("Type", "Font"); - pFontDict->SetAtName("Subtype", "CIDFontType2"); - pFontDict->SetAtName("BaseFont", basefont); + pBaseDict->SetNameFor("Subtype", "Type0"); + pBaseDict->SetNameFor("BaseFont", basefont); + pBaseDict->SetNameFor("Encoding", cmap); + pFontDict->SetFor("W", pWidthArray); + pFontDict->SetNameFor("Type", "Font"); + pFontDict->SetNameFor("Subtype", "CIDFontType2"); + pFontDict->SetNameFor("BaseFont", basefont); CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary; - pCIDSysInfo->SetAtString("Registry", "Adobe"); - pCIDSysInfo->SetAtString("Ordering", ordering); - pCIDSysInfo->SetAtInteger("Supplement", supplement); - pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo); + pCIDSysInfo->SetStringFor("Registry", "Adobe"); + pCIDSysInfo->SetStringFor("Ordering", ordering); + pCIDSysInfo->SetIntegerFor("Supplement", supplement); + pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo); CPDF_Array* pArray = new CPDF_Array; - pBaseDict->SetAt("DescendantFonts", pArray); + pBaseDict->SetFor("DescendantFonts", pArray); AddIndirectObject(pFontDict); pArray->AddReference(this, pFontDict); } AddIndirectObject(pBaseDict); CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; - pFontDesc->SetAtName("Type", "FontDescriptor"); - pFontDesc->SetAtName("FontName", basefont); - pFontDesc->SetAtInteger("Flags", flags); + pFontDesc->SetNameFor("Type", "FontDescriptor"); + pFontDesc->SetNameFor("FontName", basefont); + pFontDesc->SetIntegerFor("Flags", flags); CPDF_Array* pBBox = new CPDF_Array; for (int i = 0; i < 4; i++) pBBox->AddInteger(bbox[i]); - pFontDesc->SetAt("FontBBox", pBBox); - pFontDesc->SetAtInteger("ItalicAngle", italicangle); - pFontDesc->SetAtInteger("Ascent", ascend); - pFontDesc->SetAtInteger("Descent", descend); - pFontDesc->SetAtInteger("CapHeight", capheight); - pFontDesc->SetAtInteger("StemV", pLogFont->lfWeight / 5); + pFontDesc->SetFor("FontBBox", pBBox); + pFontDesc->SetIntegerFor("ItalicAngle", italicangle); + pFontDesc->SetIntegerFor("Ascent", ascend); + pFontDesc->SetIntegerFor("Descent", descend); + pFontDesc->SetIntegerFor("CapHeight", capheight); + pFontDesc->SetIntegerFor("StemV", pLogFont->lfWeight / 5); AddIndirectObject(pFontDesc); - pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); + pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); hFont = SelectObject(hDC, hFont); DeleteObject(hFont); DeleteDC(hDC); diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp index 680939b186..b41d0527fd 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp @@ -455,7 +455,7 @@ bool CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { return false; CPDF_Dictionary* pDict = pHintStream->GetDict(); - CPDF_Object* pOffset = pDict ? pDict->GetObjectBy("S") : nullptr; + CPDF_Object* pOffset = pDict ? pDict->GetObjectFor("S") : nullptr; if (!pOffset || !pOffset->IsNumber()) return false; @@ -487,22 +487,22 @@ bool CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { } int CPDF_HintTables::GetEndOfFirstPageOffset() const { - CPDF_Object* pOffsetE = m_pLinearizedDict->GetDirectObjectBy("E"); + CPDF_Object* pOffsetE = m_pLinearizedDict->GetDirectObjectFor("E"); return pOffsetE ? pOffsetE->GetInteger() : -1; } int CPDF_HintTables::GetNumberOfPages() const { - CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectBy("N"); + CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectFor("N"); return pPageNum ? pPageNum->GetInteger() : 0; } int CPDF_HintTables::GetFirstPageObjectNumber() const { - CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectBy("O"); + CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectFor("O"); return pFirstPageObj ? pFirstPageObj->GetInteger() : -1; } int CPDF_HintTables::GetFirstPageNumber() const { - CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetDirectObjectBy("P"); + CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetDirectObjectFor("P"); return pFirstPageNum ? pFirstPageNum->GetInteger() : 0; } @@ -515,7 +515,7 @@ int CPDF_HintTables::ReadPrimaryHintStreamLength() const { } int CPDF_HintTables::ReadPrimaryHintStream(int index) const { - CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); + CPDF_Array* pRange = m_pLinearizedDict->GetArrayFor("H"); if (!pRange) return -1; diff --git a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp index ec982ab58a..5772043367 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp @@ -67,16 +67,16 @@ class PDFObjectsTest : public testing::Test { m_ArrayObj->InsertAt(1, new CPDF_Name("address")); // Dictionary object. m_DictObj = new CPDF_Dictionary; - m_DictObj->SetAt("bool", new CPDF_Boolean(false)); - m_DictObj->SetAt("num", new CPDF_Number(0.23f)); + m_DictObj->SetFor("bool", new CPDF_Boolean(false)); + m_DictObj->SetFor("num", new CPDF_Number(0.23f)); // Stream object. const char content[] = "abcdefghijklmnopqrstuvwxyz"; size_t buf_len = FX_ArraySize(content); uint8_t* buf = reinterpret_cast<uint8_t*>(malloc(buf_len)); memcpy(buf, content, buf_len); m_StreamDictObj = new CPDF_Dictionary; - m_StreamDictObj->SetAt("key1", new CPDF_String(L" test dict")); - m_StreamDictObj->SetAt("key2", new CPDF_Number(-1)); + m_StreamDictObj->SetFor("key1", new CPDF_String(L" test dict")); + m_StreamDictObj->SetFor("key2", new CPDF_Number(-1)); CPDF_Stream* stream_obj = new CPDF_Stream(buf, buf_len, m_StreamDictObj); // Null Object. CPDF_Null* null_obj = new CPDF_Null; @@ -136,7 +136,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->GetObjectBy(it->first))) + if (!Equal(it->second, dict2->GetObjectFor(it->first))) return false; } return true; @@ -559,7 +559,7 @@ TEST(PDFArrayTest, GetTypeAt) { char buf[33]; key.append(FXSYS_itoa(j, buf, 10)); int value = j + 200; - vals[i]->SetAt(key.c_str(), new CPDF_Number(value)); + vals[i]->SetFor(key.c_str(), new CPDF_Number(value)); } arr->InsertAt(i, vals[i]); } @@ -586,7 +586,7 @@ TEST(PDFArrayTest, GetTypeAt) { char buf[33]; key.append(FXSYS_itoa(j, buf, 10)); int value = j + 200; - vals[i]->SetAt(key.c_str(), new CPDF_Number(value)); + vals[i]->SetFor(key.c_str(), new CPDF_Number(value)); } uint8_t content[] = "content: this is a stream"; size_t data_size = FX_ArraySize(content); @@ -626,12 +626,12 @@ TEST(PDFArrayTest, GetTypeAt) { arr_val->AddNumber(2); arr->InsertAt(11, arr_val); CPDF_Dictionary* dict_val = new CPDF_Dictionary; - dict_val->SetAt("key1", new CPDF_String("Linda", false)); - dict_val->SetAt("key2", new CPDF_String("Zoe", false)); + dict_val->SetFor("key1", new CPDF_String("Linda", false)); + dict_val->SetFor("key2", new CPDF_String("Zoe", false)); arr->InsertAt(12, dict_val); CPDF_Dictionary* stream_dict = new CPDF_Dictionary; - stream_dict->SetAt("key1", new CPDF_String("John", false)); - stream_dict->SetAt("key2", new CPDF_String("King", false)); + stream_dict->SetFor("key1", new CPDF_String("John", false)); + stream_dict->SetFor("key2", new CPDF_String("King", false)); uint8_t data[] = "A stream for test"; // The data buffer will be owned by stream object, so it needs to be // dynamically allocated. @@ -769,9 +769,9 @@ TEST(PDFArrayTest, CloneDirectObject) { TEST(PDFDictionaryTest, CloneDirectObject) { CPDF_IndirectObjectHolder objects_holder; ScopedDict dict(new CPDF_Dictionary); - dict->SetAtReference("foo", &objects_holder, 1234); + dict->SetReferenceFor("foo", &objects_holder, 1234); ASSERT_EQ(1U, dict->GetCount()); - CPDF_Object* obj = dict->GetObjectBy("foo"); + CPDF_Object* obj = dict->GetObjectFor("foo"); ASSERT_TRUE(obj); EXPECT_TRUE(obj->IsReference()); @@ -781,7 +781,7 @@ TEST(PDFDictionaryTest, CloneDirectObject) { ScopedDict cloned_dict(cloned_dict_object->AsDictionary()); ASSERT_EQ(1U, cloned_dict->GetCount()); - CPDF_Object* cloned_obj = cloned_dict->GetObjectBy("foo"); + CPDF_Object* cloned_obj = cloned_dict->GetObjectFor("foo"); EXPECT_FALSE(cloned_obj); } @@ -791,7 +791,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { ScopedArray arr_obj(new CPDF_Array); // Dictionary object. CPDF_Dictionary* dict_obj = new CPDF_Dictionary; - dict_obj->SetAt("arr", arr_obj.get()); + dict_obj->SetFor("arr", arr_obj.get()); arr_obj->InsertAt(0, dict_obj); // Clone this object to see whether stack overflow will be triggered. @@ -803,7 +803,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { ASSERT_TRUE(cloned_dict); ASSERT_TRUE(cloned_dict->IsDictionary()); // Recursively referenced object is not cloned. - EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectBy("arr")); + EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectFor("arr")); } { CPDF_IndirectObjectHolder objects_holder; @@ -812,7 +812,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { CPDF_Array* arr_obj = new CPDF_Array; objects_holder.AddIndirectObject(dict_obj); EXPECT_EQ(1u, dict_obj->GetObjNum()); - dict_obj->SetAt("arr", arr_obj); + dict_obj->SetFor("arr", arr_obj); arr_obj->InsertAt(0, dict_obj, &objects_holder); CPDF_Object* elem0 = arr_obj->GetObjectAt(0); ASSERT_TRUE(elem0); @@ -824,7 +824,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { ScopedDict cloned_dict(ToDictionary(dict_obj->CloneDirectObject())); // Cloned object should be the same as the original. ASSERT_TRUE(cloned_dict); - CPDF_Object* cloned_arr = cloned_dict->GetObjectBy("arr"); + CPDF_Object* cloned_arr = cloned_dict->GetObjectFor("arr"); ASSERT_TRUE(cloned_arr); ASSERT_TRUE(cloned_arr->IsArray()); EXPECT_EQ(1u, cloned_arr->AsArray()->GetCount()); diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index 529e751f6c..51ef73cba2 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -37,11 +37,11 @@ uint32_t GetVarInt(const uint8_t* p, int32_t n) { } int32_t GetStreamNCount(CPDF_StreamAcc* pObjStream) { - return pObjStream->GetDict()->GetIntegerBy("N"); + return pObjStream->GetDict()->GetIntegerFor("N"); } int32_t GetStreamFirst(CPDF_StreamAcc* pObjStream) { - return pObjStream->GetDict()->GetIntegerBy("First"); + return pObjStream->GetDict()->GetIntegerFor("First"); } } // namespace @@ -231,7 +231,7 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, } if (m_pSecurityHandler && !m_pSecurityHandler->IsMetadataEncrypted()) { CPDF_Reference* pMetadata = - ToReference(m_pDocument->GetRoot()->GetObjectBy("Metadata")); + ToReference(m_pDocument->GetRoot()->GetObjectFor("Metadata")); if (pMetadata) m_pSyntax->m_MetadataObjnum = pMetadata->GetRefObjNum(); } @@ -244,7 +244,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() { if (!m_pTrailer) return FORMAT_ERROR; - CPDF_Object* pEncryptObj = m_pTrailer->GetObjectBy("Encrypt"); + CPDF_Object* pEncryptObj = m_pTrailer->GetObjectFor("Encrypt"); if (pEncryptObj) { if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) { SetEncryptDictionary(pEncryptDict); @@ -256,7 +256,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() { } if (m_pEncryptDict) { - CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter"); + CFX_ByteString filter = m_pEncryptDict->GetStringFor("Filter"); std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler; Error err = HANDLER_ERROR; if (filter == "Standard") { @@ -367,7 +367,7 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) { // SLOW ... XRefStreamList.insert(XRefStreamList.begin(), - pDict->GetIntegerBy("XRefStm")); + pDict->GetIntegerFor("XRefStm")); m_Trailers.Add(pDict.release()); } @@ -422,7 +422,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, // SLOW ... XRefStreamList.insert(XRefStreamList.begin(), - pDict->GetIntegerBy("XRefStm")); + pDict->GetIntegerFor("XRefStm")); m_Trailers.Add(pDict.release()); } @@ -751,11 +751,11 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { if (CPDF_Stream* pStream = ToStream(pObject)) { if (CPDF_Dictionary* pDict = pStream->GetDict()) { if ((pDict->KeyExist("Type")) && - (pDict->GetStringBy("Type") == "XRef" && + (pDict->GetStringFor("Type") == "XRef" && pDict->KeyExist("Size"))) { - CPDF_Object* pRoot = pDict->GetObjectBy("Root"); + CPDF_Object* pRoot = pDict->GetObjectFor("Root"); if (pRoot && pRoot->GetDict() && - pRoot->GetDict()->GetObjectBy("Pages")) { + pRoot->GetDict()->GetObjectFor("Pages")) { if (m_pTrailer) m_pTrailer->Release(); m_pTrailer = ToDictionary(pDict->Clone()); @@ -819,7 +819,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { if (CPDF_Dictionary* pTrailer = pStream ? pStream->GetDict() : pObj->AsDictionary()) { if (m_pTrailer) { - CPDF_Object* pRoot = pTrailer->GetObjectBy("Root"); + CPDF_Object* pRoot = pTrailer->GetObjectFor("Root"); CPDF_Reference* pRef = ToReference(pRoot); if (!pRoot || (pRef && IsValidObjectNumber(pRef->GetRefObjNum()) && @@ -832,10 +832,10 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { uint32_t dwObjNum = pElement ? pElement->GetObjNum() : 0; if (dwObjNum) { - m_pTrailer->SetAtReference(key, m_pDocument, - dwObjNum); + m_pTrailer->SetReferenceFor(key, m_pDocument, + dwObjNum); } else { - m_pTrailer->SetAt(key, pElement->Clone()); + m_pTrailer->SetFor(key, pElement->Clone()); } } } @@ -980,8 +980,8 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { return FALSE; CPDF_Dictionary* pDict = pStream->GetDict(); - *pos = pDict->GetIntegerBy("Prev"); - int32_t size = pDict->GetIntegerBy("Size"); + *pos = pDict->GetIntegerFor("Prev"); + int32_t size = pDict->GetIntegerFor("Size"); if (size < 0) { pStream->Release(); return FALSE; @@ -998,7 +998,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { } std::vector<std::pair<int32_t, int32_t>> arrIndex; - CPDF_Array* pArray = pDict->GetArrayBy("Index"); + CPDF_Array* pArray = pDict->GetArrayFor("Index"); if (pArray) { for (size_t i = 0; i < pArray->GetCount() / 2; i++) { CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2); @@ -1016,7 +1016,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { if (arrIndex.size() == 0) arrIndex.push_back(std::make_pair(0, size)); - pArray = pDict->GetArrayBy("W"); + pArray = pDict->GetArrayFor("W"); if (!pArray) { pStream->Release(); return FALSE; @@ -1107,26 +1107,26 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { } CPDF_Array* CPDF_Parser::GetIDArray() { - CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetObjectBy("ID") : nullptr; + CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetObjectFor("ID") : nullptr; if (!pID) return nullptr; if (CPDF_Reference* pRef = pID->AsReference()) { pID = ParseIndirectObject(nullptr, pRef->GetRefObjNum()); - m_pTrailer->SetAt("ID", pID); + m_pTrailer->SetFor("ID", pID); } return ToArray(pID); } uint32_t CPDF_Parser::GetRootObjNum() { CPDF_Reference* pRef = - ToReference(m_pTrailer ? m_pTrailer->GetObjectBy("Root") : nullptr); + ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Root") : nullptr); return pRef ? pRef->GetRefObjNum() : 0; } uint32_t CPDF_Parser::GetInfoObjNum() { CPDF_Reference* pRef = - ToReference(m_pTrailer ? m_pTrailer->GetObjectBy("Info") : nullptr); + ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Info") : nullptr); return pRef ? pRef->GetRefObjNum() : 0; } @@ -1446,7 +1446,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObjectAtByStrict( return nullptr; } - CPDF_Object* pObj = m_pSyntax->GetObjectByStrict(pObjList, objnum, gennum); + CPDF_Object* pObj = m_pSyntax->GetObjectForStrict(pObjList, objnum, gennum); if (pResultPos) *pResultPos = m_pSyntax->m_Pos; @@ -1470,7 +1470,7 @@ uint32_t CPDF_Parser::GetPermissions() const { return 0xFFFFFFFF; uint32_t dwPermission = m_pSecurityHandler->GetPermissions(); - if (m_pEncryptDict && m_pEncryptDict->GetStringBy("Filter") == "Standard") { + if (m_pEncryptDict && m_pEncryptDict->GetStringFor("Filter") == "Standard") { // See PDF Reference 1.7, page 123, table 3.20. dwPermission &= 0xFFFFFFFC; dwPermission |= 0xFFFFF0C0; @@ -1505,10 +1505,10 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, return FALSE; CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - if (pDict && pDict->GetObjectBy("Linearized")) { + if (pDict && pDict->GetObjectFor("Linearized")) { m_pSyntax->GetNextWord(nullptr); - CPDF_Object* pLen = pDict->GetObjectBy("L"); + CPDF_Object* pLen = pDict->GetObjectFor("L"); if (!pLen) { m_pLinearized->Release(); m_pLinearized = nullptr; @@ -1518,10 +1518,10 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, if (pLen->GetInteger() != (int)pFileAccess->GetSize()) return FALSE; - if (CPDF_Number* pNo = ToNumber(pDict->GetObjectBy("P"))) + if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P"))) m_dwFirstPageNo = pNo->GetInteger(); - if (CPDF_Number* pTable = ToNumber(pDict->GetObjectBy("T"))) + if (CPDF_Number* pTable = ToNumber(pDict->GetObjectFor("T"))) m_LastXRefOffset = pTable->GetInteger(); return TRUE; @@ -1606,7 +1606,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(IFX_FileRead* pFileAccess, if (m_pSecurityHandler && m_pSecurityHandler->IsMetadataEncrypted()) { if (CPDF_Reference* pMetadata = - ToReference(m_pDocument->GetRoot()->GetObjectBy("Metadata"))) + ToReference(m_pDocument->GetRoot()->GetObjectFor("Metadata"))) m_pSyntax->m_MetadataObjnum = pMetadata->GetRefObjNum(); } return SUCCESS; diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp index 65d3173613..bf18028d7a 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp @@ -29,7 +29,7 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt, int keylen, FX_BOOL bIgnoreMeta, CPDF_Array* pIdArray) { - int revision = pEncrypt->GetIntegerBy("R"); + int revision = pEncrypt->GetIntegerFor("R"); uint8_t passcode[32]; for (uint32_t i = 0; i < 32; i++) { passcode[i] = i < pass_size ? password[i] : defpasscode[i - pass_size]; @@ -37,16 +37,16 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt, uint8_t md5[100]; CRYPT_MD5Start(md5); CRYPT_MD5Update(md5, passcode, 32); - CFX_ByteString okey = pEncrypt->GetStringBy("O"); + CFX_ByteString okey = pEncrypt->GetStringFor("O"); CRYPT_MD5Update(md5, (uint8_t*)okey.c_str(), okey.GetLength()); - uint32_t perm = pEncrypt->GetIntegerBy("P"); + uint32_t perm = pEncrypt->GetIntegerFor("P"); CRYPT_MD5Update(md5, (uint8_t*)&perm, 4); if (pIdArray) { CFX_ByteString id = pIdArray->GetStringAt(0); CRYPT_MD5Update(md5, (uint8_t*)id.c_str(), id.GetLength()); } if (!bIgnoreMeta && revision >= 3 && - !pEncrypt->GetIntegerBy("EncryptMetadata", 1)) { + !pEncrypt->GetIntegerFor("EncryptMetadata", 1)) { uint32_t tag = (uint32_t)-1; CRYPT_MD5Update(md5, (uint8_t*)&tag, 4); } @@ -115,41 +115,41 @@ static FX_BOOL LoadCryptInfo(CPDF_Dictionary* pEncryptDict, const CFX_ByteString& name, int& cipher, int& keylen) { - int Version = pEncryptDict->GetIntegerBy("V"); + int Version = pEncryptDict->GetIntegerFor("V"); cipher = FXCIPHER_RC4; keylen = 0; if (Version >= 4) { - CPDF_Dictionary* pCryptFilters = pEncryptDict->GetDictBy("CF"); + CPDF_Dictionary* pCryptFilters = pEncryptDict->GetDictFor("CF"); if (!pCryptFilters) { return FALSE; } if (name == "Identity") { cipher = FXCIPHER_NONE; } else { - CPDF_Dictionary* pDefFilter = pCryptFilters->GetDictBy(name); + CPDF_Dictionary* pDefFilter = pCryptFilters->GetDictFor(name); if (!pDefFilter) { return FALSE; } int nKeyBits = 0; if (Version == 4) { - nKeyBits = pDefFilter->GetIntegerBy("Length", 0); + nKeyBits = pDefFilter->GetIntegerFor("Length", 0); if (nKeyBits == 0) { - nKeyBits = pEncryptDict->GetIntegerBy("Length", 128); + nKeyBits = pEncryptDict->GetIntegerFor("Length", 128); } } else { - nKeyBits = pEncryptDict->GetIntegerBy("Length", 256); + nKeyBits = pEncryptDict->GetIntegerFor("Length", 256); } if (nKeyBits < 40) { nKeyBits *= 8; } keylen = nKeyBits / 8; - CFX_ByteString cipher_name = pDefFilter->GetStringBy("CFM"); + CFX_ByteString cipher_name = pDefFilter->GetStringFor("CFM"); if (cipher_name == "AESV2" || cipher_name == "AESV3") { cipher = FXCIPHER_AES; } } } else { - keylen = Version > 1 ? pEncryptDict->GetIntegerBy("Length", 40) / 8 : 5; + keylen = Version > 1 ? pEncryptDict->GetIntegerFor("Length", 40) / 8 : 5; } if (keylen > 32 || keylen < 0) { return FALSE; @@ -159,14 +159,14 @@ static FX_BOOL LoadCryptInfo(CPDF_Dictionary* pEncryptDict, FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) { m_pEncryptDict = pEncryptDict; - m_Version = pEncryptDict->GetIntegerBy("V"); - m_Revision = pEncryptDict->GetIntegerBy("R"); - m_Permissions = pEncryptDict->GetIntegerBy("P", -1); + m_Version = pEncryptDict->GetIntegerFor("V"); + m_Revision = pEncryptDict->GetIntegerFor("R"); + m_Permissions = pEncryptDict->GetIntegerFor("P", -1); if (m_Version < 4) return LoadCryptInfo(pEncryptDict, CFX_ByteString(), m_Cipher, m_KeyLen); - CFX_ByteString stmf_name = pEncryptDict->GetStringBy("StmF"); - CFX_ByteString strf_name = pEncryptDict->GetStringBy("StrF"); + CFX_ByteString stmf_name = pEncryptDict->GetStringFor("StmF"); + CFX_ByteString strf_name = pEncryptDict->GetStringFor("StrF"); if (stmf_name != strf_name) return FALSE; @@ -178,15 +178,15 @@ FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, int& cipher, int& key_len) { m_pEncryptDict = pEncryptDict; - m_Version = pEncryptDict->GetIntegerBy("V"); - m_Revision = pEncryptDict->GetIntegerBy("R"); - m_Permissions = pEncryptDict->GetIntegerBy("P", -1); + m_Version = pEncryptDict->GetIntegerFor("V"); + m_Revision = pEncryptDict->GetIntegerFor("R"); + m_Permissions = pEncryptDict->GetIntegerFor("P", -1); CFX_ByteString strf_name; CFX_ByteString stmf_name; if (m_Version >= 4) { - stmf_name = pEncryptDict->GetStringBy("StmF"); - strf_name = pEncryptDict->GetStringBy("StrF"); + stmf_name = pEncryptDict->GetStringFor("StmF"); + strf_name = pEncryptDict->GetStringFor("StrF"); if (stmf_name != strf_name) return FALSE; } @@ -304,12 +304,12 @@ FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password, FX_BOOL bOwner, uint8_t* key) { CFX_ByteString okey = - m_pEncryptDict ? m_pEncryptDict->GetStringBy("O") : CFX_ByteString(); + m_pEncryptDict ? m_pEncryptDict->GetStringFor("O") : CFX_ByteString(); if (okey.GetLength() < 48) { return FALSE; } CFX_ByteString ukey = - m_pEncryptDict ? m_pEncryptDict->GetStringBy("U") : CFX_ByteString(); + m_pEncryptDict ? m_pEncryptDict->GetStringFor("U") : CFX_ByteString(); if (ukey.GetLength() < 48) { return FALSE; } @@ -347,7 +347,7 @@ FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password, CRYPT_SHA256Finish(sha, digest); } CFX_ByteString ekey = m_pEncryptDict - ? m_pEncryptDict->GetStringBy(bOwner ? "OE" : "UE") + ? m_pEncryptDict->GetStringFor(bOwner ? "OE" : "UE") : CFX_ByteString(); if (ekey.GetLength() < 32) { return FALSE; @@ -360,7 +360,7 @@ FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password, CRYPT_AESDecrypt(aes, key, ekey.raw_str(), 32); CRYPT_AESSetKey(aes, 16, key, 32, FALSE); CRYPT_AESSetIV(aes, iv); - CFX_ByteString perms = m_pEncryptDict->GetStringBy("Perms"); + CFX_ByteString perms = m_pEncryptDict->GetStringFor("Perms"); if (perms.IsEmpty()) { return FALSE; } @@ -413,7 +413,7 @@ FX_BOOL CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password, CalcEncryptKey(m_pEncryptDict, password, pass_size, key, key_len, bIgnoreEncryptMeta, m_pParser->GetIDArray()); CFX_ByteString ukey = - m_pEncryptDict ? m_pEncryptDict->GetStringBy("U") : CFX_ByteString(); + m_pEncryptDict ? m_pEncryptDict->GetStringFor("U") : CFX_ByteString(); if (ukey.GetLength() < 16) { return FALSE; } @@ -454,7 +454,7 @@ FX_BOOL CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password, CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass, uint32_t pass_size, int32_t key_len) { - CFX_ByteString okey = m_pEncryptDict->GetStringBy("O"); + CFX_ByteString okey = m_pEncryptDict->GetStringFor("O"); uint8_t passcode[32]; for (uint32_t i = 0; i < 32; i++) { passcode[i] = i < pass_size ? owner_pass[i] : defpasscode[i - pass_size]; @@ -511,7 +511,7 @@ FX_BOOL CPDF_SecurityHandler::CheckOwnerPassword(const uint8_t* password, } bool CPDF_SecurityHandler::IsMetadataEncrypted() const { - return m_pEncryptDict->GetBooleanBy("EncryptMetadata", true); + return m_pEncryptDict->GetBooleanFor("EncryptMetadata", true); } void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, @@ -543,7 +543,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, AES256_SetPassword(pEncryptDict, owner_pass, owner_size, TRUE, m_EncryptKey); AES256_SetPerms(pEncryptDict, m_Permissions, - pEncryptDict->GetBooleanBy("EncryptMetadata", true), + pEncryptDict->GetBooleanFor("EncryptMetadata", true), m_EncryptKey); } return; @@ -574,7 +574,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CRYPT_ArcFourCryptBlock(passcode, 32, tempkey, key_len); } } - pEncryptDict->SetAtString("O", CFX_ByteString(passcode, 32)); + pEncryptDict->SetStringFor("O", CFX_ByteString(passcode, 32)); } CalcEncryptKey(m_pEncryptDict, (uint8_t*)user_pass, user_size, m_EncryptKey, key_len, FALSE, pIdArray); @@ -582,7 +582,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, uint8_t tempbuf[32]; FXSYS_memcpy(tempbuf, defpasscode, 32); CRYPT_ArcFourCryptBlock(tempbuf, 32, m_EncryptKey, key_len); - pEncryptDict->SetAtString("U", CFX_ByteString(tempbuf, 32)); + pEncryptDict->SetStringFor("U", CFX_ByteString(tempbuf, 32)); } else { uint8_t md5[100]; CRYPT_MD5Start(md5); @@ -602,7 +602,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CRYPT_ArcFourCryptBlock(digest, 16, tempkey, key_len); } CRYPT_MD5Generate(digest, 16, digest + 16); - pEncryptDict->SetAtString("U", CFX_ByteString(digest, 32)); + pEncryptDict->SetStringFor("U", CFX_ByteString(digest, 32)); } } void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, @@ -634,7 +634,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, CRYPT_SHA1Update(sha, (uint8_t*)"hello", 5); uint8_t digest[20]; CRYPT_SHA1Finish(sha, digest); - CFX_ByteString ukey = pEncryptDict->GetStringBy("U"); + CFX_ByteString ukey = pEncryptDict->GetStringFor("U"); uint8_t digest1[48]; if (m_Revision >= 6) { Revision6_Hash(password, size, digest, bOwner ? ukey.raw_str() : nullptr, @@ -649,7 +649,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, CRYPT_SHA256Finish(sha, digest1); } FXSYS_memcpy(digest1 + 32, digest, 16); - pEncryptDict->SetAtString(bOwner ? "O" : "U", CFX_ByteString(digest1, 48)); + pEncryptDict->SetStringFor(bOwner ? "O" : "U", CFX_ByteString(digest1, 48)); if (m_Revision >= 6) { Revision6_Hash(password, size, digest + 8, bOwner ? ukey.raw_str() : nullptr, digest1); @@ -669,7 +669,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, CRYPT_AESSetIV(aes, iv); CRYPT_AESEncrypt(aes, digest1, key, 32); FX_Free(aes); - pEncryptDict->SetAtString(bOwner ? "OE" : "UE", CFX_ByteString(digest1, 32)); + pEncryptDict->SetStringFor(bOwner ? "OE" : "UE", CFX_ByteString(digest1, 32)); } void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict, uint32_t permissions, @@ -695,5 +695,5 @@ void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict, CRYPT_AESSetIV(aes, iv); CRYPT_AESEncrypt(aes, buf1, buf, 16); FX_Free(aes); - pEncryptDict->SetAtString("Perms", CFX_ByteString(buf1, 16)); + pEncryptDict->SetStringFor("Perms", CFX_ByteString(buf1, 16)); } diff --git a/core/fpdfapi/fpdf_parser/cpdf_stream.cpp b/core/fpdfapi/fpdf_parser/cpdf_stream.cpp index 58b9767dfb..e25180bedb 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_stream.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_stream.cpp @@ -70,7 +70,7 @@ void CPDF_Stream::InitStream(const uint8_t* pData, m_dwSize = size; if (m_pDict) - m_pDict->SetAtInteger("Length", size); + m_pDict->SetIntegerFor("Length", size); } CPDF_Object* CPDF_Stream::Clone() const { @@ -112,10 +112,10 @@ void CPDF_Stream::SetData(const uint8_t* pData, m_dwSize = size; if (!m_pDict) m_pDict = new CPDF_Dictionary; - m_pDict->SetAtInteger("Length", size); + m_pDict->SetIntegerFor("Length", size); if (!bCompressed) { - m_pDict->RemoveAt("Filter"); - m_pDict->RemoveAt("DecodeParms"); + m_pDict->RemoveFor("Filter"); + m_pDict->RemoveFor("DecodeParms"); } } @@ -137,7 +137,7 @@ void CPDF_Stream::InitStreamFromFile(IFX_FileRead* pFile, m_pFile = pFile; m_dwSize = (uint32_t)pFile->GetSize(); if (m_pDict) - m_pDict->SetAtInteger("Length", m_dwSize); + m_pDict->SetIntegerFor("Length", m_dwSize); } CFX_WideString CPDF_Stream::GetUnicodeText() const { diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index 0eeb4a1afa..4bfaf99ed9 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -469,7 +469,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, continue; CFX_ByteString keyNoSlash(key.raw_str() + 1, key.GetLength() - 1); - pDict->SetAt(keyNoSlash, pObj); + pDict->SetFor(keyNoSlash, pObj); } // Only when this is a signature dictionary and has contents, we reset the @@ -477,7 +477,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, if (pDict->IsSignatureDict() && dwSignValuePos) { CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos); m_Pos = dwSignValuePos; - pDict->SetAt("Contents", GetObject(pObjList, objnum, gennum, false)); + pDict->SetFor("Contents", GetObject(pObjList, objnum, gennum, false)); } FX_FILESIZE SavedPos = m_Pos; @@ -495,7 +495,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, return nullptr; } -CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( +CPDF_Object* CPDF_SyntaxParser::GetObjectForStrict( CPDF_IndirectObjectHolder* pObjList, uint32_t objnum, uint32_t gennum) { @@ -587,8 +587,8 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( } if (key.GetLength() > 1) { - pDict->SetAt(CFX_ByteString(key.c_str() + 1, key.GetLength() - 1), - obj.release()); + pDict->SetFor(CFX_ByteString(key.c_str() + 1, key.GetLength() - 1), + obj.release()); } } @@ -627,7 +627,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->GetObjectBy("Length"); + CPDF_Object* pLenObj = pDict->GetObjectFor("Length"); FX_FILESIZE len = -1; CPDF_Reference* pLenObjRef = ToReference(pLenObj); @@ -733,7 +733,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, pDict->Release(); return nullptr; } - pDict->SetAtInteger("Length", len); + pDict->SetIntegerFor("Length", len); } m_Pos = streamStartPos; } diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h index 63992a85ab..8ca7e33824 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h @@ -32,9 +32,9 @@ class CPDF_SyntaxParser { uint32_t objnum, uint32_t gennum, FX_BOOL bDecrypt); - CPDF_Object* GetObjectByStrict(CPDF_IndirectObjectHolder* pObjList, - uint32_t objnum, - uint32_t gennum); + CPDF_Object* GetObjectForStrict(CPDF_IndirectObjectHolder* pObjList, + uint32_t objnum, + uint32_t gennum); CFX_ByteString GetKeyword(); void ToNextLine(); diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 40ba362ad6..72a9518ca9 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -239,12 +239,12 @@ CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( int Columns = 1728; int Rows = 0; if (pParams) { - K = pParams->GetIntegerBy("K"); - EndOfLine = pParams->GetIntegerBy("EndOfLine"); - ByteAlign = pParams->GetIntegerBy("EncodedByteAlign"); - BlackIs1 = pParams->GetIntegerBy("BlackIs1"); - Columns = pParams->GetIntegerBy("Columns", 1728); - Rows = pParams->GetIntegerBy("Rows"); + K = pParams->GetIntegerFor("K"); + EndOfLine = pParams->GetIntegerFor("EndOfLine"); + ByteAlign = pParams->GetIntegerFor("EncodedByteAlign"); + BlackIs1 = pParams->GetIntegerFor("BlackIs1"); + Columns = pParams->GetIntegerFor("Columns", 1728); + Rows = pParams->GetIntegerFor("Rows"); if (Rows > USHRT_MAX) { Rows = 0; } @@ -290,10 +290,10 @@ CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( int predictor = 0; int Colors = 0, BitsPerComponent = 0, Columns = 0; if (pParams) { - predictor = pParams->GetIntegerBy("Predictor"); - Colors = pParams->GetIntegerBy("Colors", 1); - BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8); - Columns = pParams->GetIntegerBy("Columns", 1); + predictor = pParams->GetIntegerFor("Predictor"); + Colors = pParams->GetIntegerFor("Colors", 1); + BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8); + Columns = pParams->GetIntegerFor("Columns", 1); if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { return nullptr; } @@ -314,11 +314,11 @@ uint32_t FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, FX_BOOL bEarlyChange = TRUE; int Colors = 0, BitsPerComponent = 0, Columns = 0; if (pParams) { - predictor = pParams->GetIntegerBy("Predictor"); - bEarlyChange = pParams->GetIntegerBy("EarlyChange", 1); - Colors = pParams->GetIntegerBy("Colors", 1); - BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8); - Columns = pParams->GetIntegerBy("Columns", 1); + predictor = pParams->GetIntegerFor("Predictor"); + bEarlyChange = pParams->GetIntegerFor("EarlyChange", 1); + Colors = pParams->GetIntegerFor("Colors", 1); + BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8); + Columns = pParams->GetIntegerFor("Columns", 1); if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { return (uint32_t)-1; } @@ -337,12 +337,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->GetDirectObjectBy("Filter") : nullptr; + CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectFor("Filter") : nullptr; if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) return FALSE; CPDF_Object* pParams = - pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr; + pDict ? pDict->GetDirectObjectFor("DecodeParms") : nullptr; std::vector<std::pair<CFX_ByteString, CPDF_Object*>> DecoderArray; 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 6b1958298c..a9f20a9093 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_ByteString& key) { - CPDF_Number* pObj = ToNumber(pDict->GetObjectBy(key)); + CPDF_Number* pObj = ToNumber(pDict->GetObjectFor(key)); return pObj ? pObj->GetInteger() : 0; } diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h index be79737add..784d49714f 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h @@ -32,48 +32,48 @@ class CPDF_Dictionary : public CPDF_Object { const CPDF_Dictionary* AsDictionary() const override; size_t GetCount() const { return m_Map.size(); } - CPDF_Object* GetObjectBy(const CFX_ByteString& key) const; - CPDF_Object* GetDirectObjectBy(const CFX_ByteString& key) const; - CFX_ByteString GetStringBy(const CFX_ByteString& key) const; - CFX_ByteString GetStringBy(const CFX_ByteString& key, - const CFX_ByteString& default_str) const; - CFX_WideString GetUnicodeTextBy(const CFX_ByteString& key) const; - int GetIntegerBy(const CFX_ByteString& key) const; - int GetIntegerBy(const CFX_ByteString& key, int default_int) const; - bool GetBooleanBy(const CFX_ByteString& key, bool bDefault = false) const; - FX_FLOAT GetNumberBy(const CFX_ByteString& key) const; - CPDF_Dictionary* GetDictBy(const CFX_ByteString& key) const; - CPDF_Stream* GetStreamBy(const CFX_ByteString& key) const; - CPDF_Array* GetArrayBy(const CFX_ByteString& key) const; - CFX_FloatRect GetRectBy(const CFX_ByteString& key) const; - CFX_Matrix GetMatrixBy(const CFX_ByteString& key) const; - FX_FLOAT GetFloatBy(const CFX_ByteString& key) const { - return GetNumberBy(key); + CPDF_Object* GetObjectFor(const CFX_ByteString& key) const; + CPDF_Object* GetDirectObjectFor(const CFX_ByteString& key) const; + CFX_ByteString GetStringFor(const CFX_ByteString& key) const; + CFX_ByteString GetStringFor(const CFX_ByteString& key, + const CFX_ByteString& default_str) const; + CFX_WideString GetUnicodeTextFor(const CFX_ByteString& key) const; + int GetIntegerFor(const CFX_ByteString& key) const; + int GetIntegerFor(const CFX_ByteString& key, int default_int) const; + bool GetBooleanFor(const CFX_ByteString& key, bool bDefault = false) const; + FX_FLOAT GetNumberFor(const CFX_ByteString& key) const; + CPDF_Dictionary* GetDictFor(const CFX_ByteString& key) const; + CPDF_Stream* GetStreamFor(const CFX_ByteString& key) const; + CPDF_Array* GetArrayFor(const CFX_ByteString& key) const; + CFX_FloatRect GetRectFor(const CFX_ByteString& key) const; + CFX_Matrix GetMatrixFor(const CFX_ByteString& key) const; + FX_FLOAT GetFloatFor(const CFX_ByteString& key) const { + return GetNumberFor(key); } FX_BOOL KeyExist(const CFX_ByteString& key) const; bool IsSignatureDict() const; // Set* functions invalidate iterators for the element with the key |key|. - void SetAt(const CFX_ByteString& key, CPDF_Object* pObj); - void SetAtName(const CFX_ByteString& key, const CFX_ByteString& name); - void SetAtString(const CFX_ByteString& key, const CFX_ByteString& str); - void SetAtInteger(const CFX_ByteString& key, int i); - void SetAtNumber(const CFX_ByteString& key, FX_FLOAT f); - void SetAtReference(const CFX_ByteString& key, - CPDF_IndirectObjectHolder* pDoc, - uint32_t objnum); - void SetAtReference(const CFX_ByteString& key, - CPDF_IndirectObjectHolder* pDoc, - CPDF_Object* obj) { - SetAtReference(key, pDoc, obj->GetObjNum()); + void SetFor(const CFX_ByteString& key, CPDF_Object* pObj); + void SetNameFor(const CFX_ByteString& key, const CFX_ByteString& name); + void SetStringFor(const CFX_ByteString& key, const CFX_ByteString& str); + void SetIntegerFor(const CFX_ByteString& key, int i); + void SetNumberFor(const CFX_ByteString& key, FX_FLOAT f); + void SetReferenceFor(const CFX_ByteString& key, + CPDF_IndirectObjectHolder* pDoc, + uint32_t objnum); + void SetReferenceFor(const CFX_ByteString& key, + CPDF_IndirectObjectHolder* pDoc, + CPDF_Object* obj) { + SetReferenceFor(key, pDoc, obj->GetObjNum()); } - void SetAtRect(const CFX_ByteString& key, const CFX_FloatRect& rect); - void SetAtMatrix(const CFX_ByteString& key, const CFX_Matrix& matrix); - void SetAtBoolean(const CFX_ByteString& key, bool bValue); + void SetRectFor(const CFX_ByteString& key, const CFX_FloatRect& rect); + void SetMatrixFor(const CFX_ByteString& key, const CFX_Matrix& matrix); + void SetBooleanFor(const CFX_ByteString& key, bool bValue); // Invalidates iterators for the element with the key |key|. - void RemoveAt(const CFX_ByteString& key); + void RemoveFor(const CFX_ByteString& key); // Invalidates iterators for the element with the key |oldkey|. void ReplaceKey(const CFX_ByteString& oldkey, const CFX_ByteString& newkey); diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp index fbb0745506..59c8397f54 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp @@ -424,7 +424,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, if (pObj->IsForm()) { const CPDF_FormObject* pFormObj = pObj->AsForm(); if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { - pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); + pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); } } CPDF_RenderStatus status; @@ -440,7 +440,7 @@ FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictBy("OC"); + CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictFor("OC"); if (pOC && m_Options.m_pOCContext && !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { return TRUE; @@ -449,7 +449,7 @@ FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, matrix.Concat(*pObj2Device); CPDF_Dictionary* pResources = nullptr; if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { - pResources = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); + pResources = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); } CPDF_RenderStatus status; status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, @@ -707,7 +707,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, Transparency = pFormObj->m_pForm->m_Transparency; bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); if (pFormObj->m_pForm->m_pFormDict) { - pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); + pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); } } bool bTextClip = @@ -730,7 +730,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, ->GetImage() ->GetStream() ->GetDict() - ->GetDirectObjectBy("ColorSpace"); + ->GetDirectObjectFor("ColorSpace"); CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageResources); if (pColorSpace) { diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index e23cab3546..6b842198ed 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -444,7 +444,7 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { } if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { CPDF_Object* pFilters = - m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy( + m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor( "Filter"); if (pFilters) { if (pFilters->IsName()) { @@ -490,7 +490,7 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { } CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; CPDF_Object* pCSObj = - m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy( + m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor( "ColorSpace"); CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageResources); @@ -954,12 +954,12 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, if (!pSMaskDict) return nullptr; - CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G"); + CPDF_Stream* pGroup = pSMaskDict->GetStreamFor("G"); if (!pGroup) return nullptr; std::unique_ptr<CPDF_Function> pFunc; - CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectBy("TR"); + CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectFor("TR"); if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) pFunc = CPDF_Function::Load(pFuncObj); @@ -971,7 +971,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, form.ParseContent(nullptr, nullptr, nullptr); CFX_FxgeDevice bitmap_device; - FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha"; + FX_BOOL bLuminosity = pSMaskDict->GetStringFor("S") != "Alpha"; int width = pClipRect->right - pClipRect->left; int height = pClipRect->bottom - pClipRect->top; FXDIB_Format format; @@ -987,12 +987,12 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, CPDF_Object* pCSObj = nullptr; CPDF_ColorSpace* pCS = nullptr; if (bLuminosity) { - CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); + CPDF_Array* pBC = pSMaskDict->GetArrayFor("BC"); FX_ARGB back_color = 0xff000000; if (pBC) { CPDF_Dictionary* pDict = pGroup->GetDict(); - if (pDict && pDict->GetDictBy("Group")) - pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); + if (pDict && pDict->GetDictFor("Group")) + pCSObj = pDict->GetDictFor("Group")->GetDirectObjectFor("CS"); else pCSObj = nullptr; pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); @@ -1026,7 +1026,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, } CPDF_Dictionary* pFormResource = nullptr; if (form.m_pFormDict) { - pFormResource = form.m_pFormDict->GetDictBy("Resources"); + pFormResource = form.m_pFormDict->GetDictFor("Resources"); } CPDF_RenderOptions options; options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index f02c59a9af..20eaba7e63 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -155,8 +155,8 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, return FALSE; } m_pStream = pStream; - m_Width = m_pDict->GetIntegerBy("Width"); - m_Height = m_pDict->GetIntegerBy("Height"); + m_Width = m_pDict->GetIntegerFor("Width"); + m_Height = m_pDict->GetIntegerFor("Height"); if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension || m_Height > kMaxImageDimension) { return FALSE; @@ -277,8 +277,8 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, m_pStream = pStream; m_bStdCS = bStdCS; m_bHasMask = bHasMask; - m_Width = m_pDict->GetIntegerBy("Width"); - m_Height = m_pDict->GetIntegerBy("Height"); + m_Width = m_pDict->GetIntegerFor("Width"); + m_Height = m_pDict->GetIntegerFor("Height"); if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension || m_Height > kMaxImageDimension) { return 0; @@ -342,7 +342,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) { m_pJbig2Context.reset(new CCodec_Jbig2Context()); if (m_pStreamAcc->GetImageParam()) { CPDF_Stream* pGlobals = - m_pStreamAcc->GetImageParam()->GetStreamBy("JBIG2Globals"); + m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals"); if (pGlobals) { m_pGlobalStream.reset(new CPDF_StreamAcc); m_pGlobalStream->LoadAllData(pGlobals, FALSE); @@ -405,13 +405,13 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) { bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources) { - m_bpc_orig = m_pDict->GetIntegerBy("BitsPerComponent"); - if (m_pDict->GetIntegerBy("ImageMask")) + m_bpc_orig = m_pDict->GetIntegerFor("BitsPerComponent"); + if (m_pDict->GetIntegerFor("ImageMask")) m_bImageMask = TRUE; if (m_bImageMask || !m_pDict->KeyExist("ColorSpace")) { if (!m_bImageMask) { - CPDF_Object* pFilter = m_pDict->GetDirectObjectBy("Filter"); + CPDF_Object* pFilter = m_pDict->GetDirectObjectFor("Filter"); if (pFilter) { CFX_ByteString filter; if (pFilter->IsName()) { @@ -428,12 +428,12 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources, } m_bImageMask = TRUE; m_bpc = m_nComponents = 1; - CPDF_Array* pDecode = m_pDict->GetArrayBy("Decode"); + CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode"); m_bDefaultDecode = !pDecode || !pDecode->GetIntegerAt(0); return true; } - CPDF_Object* pCSObj = m_pDict->GetDirectObjectBy("ColorSpace"); + CPDF_Object* pCSObj = m_pDict->GetDirectObjectFor("ColorSpace"); if (!pCSObj) return false; @@ -469,7 +469,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, } DIB_COMP_DATA* pCompData = FX_Alloc(DIB_COMP_DATA, m_nComponents); int max_data = (1 << m_bpc) - 1; - CPDF_Array* pDecode = m_pDict->GetArrayBy("Decode"); + CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode"); if (pDecode) { for (uint32_t i = 0; i < m_nComponents; i++) { pCompData[i].m_DecodeMin = pDecode->GetNumberAt(i * 2); @@ -499,7 +499,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, } } if (!m_pDict->KeyExist("SMask")) { - CPDF_Object* pMask = m_pDict->GetDirectObjectBy("Mask"); + CPDF_Object* pMask = m_pDict->GetDirectObjectFor("Mask"); if (!pMask) { return pCompData; } @@ -551,7 +551,7 @@ int CPDF_DIBSource::CreateDecoder() { } else if (decoder == "DCTDecode") { m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( src_data, src_size, m_Width, m_Height, m_nComponents, - pParams ? pParams->GetIntegerBy("ColorTransform", 1) : 1)); + pParams ? pParams->GetIntegerFor("ColorTransform", 1) : 1)); if (!m_pDecoder) { bool bTransform = false; int comps; @@ -700,9 +700,9 @@ void CPDF_DIBSource::LoadJpxBitmap() { CPDF_DIBSource* CPDF_DIBSource::LoadMask(uint32_t& MatteColor) { MatteColor = 0xFFFFFFFF; - CPDF_Stream* pSoftMask = m_pDict->GetStreamBy("SMask"); + CPDF_Stream* pSoftMask = m_pDict->GetStreamFor("SMask"); if (pSoftMask) { - CPDF_Array* pMatte = pSoftMask->GetDict()->GetArrayBy("Matte"); + CPDF_Array* pMatte = pSoftMask->GetDict()->GetArrayFor("Matte"); if (pMatte && m_pColorSpace && m_pColorSpace->CountComponents() <= m_nComponents) { std::vector<FX_FLOAT> colors(m_nComponents); @@ -717,7 +717,7 @@ CPDF_DIBSource* CPDF_DIBSource::LoadMask(uint32_t& MatteColor) { return LoadMaskDIB(pSoftMask); } - if (CPDF_Stream* pStream = ToStream(m_pDict->GetDirectObjectBy("Mask"))) + if (CPDF_Stream* pStream = ToStream(m_pDict->GetDirectObjectFor("Mask"))) return LoadMaskDIB(pStream); return nullptr; @@ -725,9 +725,9 @@ CPDF_DIBSource* CPDF_DIBSource::LoadMask(uint32_t& MatteColor) { int CPDF_DIBSource::StratLoadMask() { m_MatteColor = 0XFFFFFFFF; - m_pMaskStream = m_pDict->GetStreamBy("SMask"); + m_pMaskStream = m_pDict->GetStreamFor("SMask"); if (m_pMaskStream) { - CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArrayBy("Matte"); + CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArrayFor("Matte"); if (pMatte && m_pColorSpace && m_pColorSpace->CountComponents() <= m_nComponents) { FX_FLOAT R, G, B; @@ -742,7 +742,7 @@ int CPDF_DIBSource::StratLoadMask() { return StartLoadMaskDIB(); } - m_pMaskStream = ToStream(m_pDict->GetDirectObjectBy("Mask")); + m_pMaskStream = ToStream(m_pDict->GetDirectObjectFor("Mask")); return m_pMaskStream ? StartLoadMaskDIB() : 1; } @@ -869,7 +869,7 @@ void CPDF_DIBSource::LoadPalette() { void CPDF_DIBSource::ValidateDictParam() { m_bpc = m_bpc_orig; - CPDF_Object* pFilter = m_pDict->GetDirectObjectBy("Filter"); + CPDF_Object* pFilter = m_pDict->GetDirectObjectFor("Filter"); if (pFilter) { if (pFilter->IsName()) { CFX_ByteString filter = pFilter->GetString(); diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 63c67cc013..e20138c8e0 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -46,7 +46,7 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap, CPDF_ColorSpace* pCS, int alpha) { ASSERT(pBitmap->GetFormat() == FXDIB_Argb); - CPDF_Array* pCoords = pDict->GetArrayBy("Coords"); + CPDF_Array* pCoords = pDict->GetArrayFor("Coords"); if (!pCoords) { return; } @@ -55,13 +55,13 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap, FX_FLOAT end_x = pCoords->GetNumberAt(2); FX_FLOAT end_y = pCoords->GetNumberAt(3); FX_FLOAT t_min = 0, t_max = 1.0f; - CPDF_Array* pArray = pDict->GetArrayBy("Domain"); + CPDF_Array* pArray = pDict->GetArrayFor("Domain"); if (pArray) { t_min = pArray->GetNumberAt(0); t_max = pArray->GetNumberAt(1); } FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; - pArray = pDict->GetArrayBy("Extend"); + pArray = pDict->GetArrayFor("Extend"); if (pArray) { bStartExtend = pArray->GetIntegerAt(0); bEndExtend = pArray->GetIntegerAt(1); @@ -127,7 +127,7 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, CPDF_ColorSpace* pCS, int alpha) { ASSERT(pBitmap->GetFormat() == FXDIB_Argb); - CPDF_Array* pCoords = pDict->GetArrayBy("Coords"); + CPDF_Array* pCoords = pDict->GetArrayFor("Coords"); if (!pCoords) { return; } @@ -140,13 +140,13 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, CFX_Matrix matrix; matrix.SetReverse(*pObject2Bitmap); FX_FLOAT t_min = 0, t_max = 1.0f; - CPDF_Array* pArray = pDict->GetArrayBy("Domain"); + CPDF_Array* pArray = pDict->GetArrayFor("Domain"); if (pArray) { t_min = pArray->GetNumberAt(0); t_max = pArray->GetNumberAt(1); } FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; - pArray = pDict->GetArrayBy("Extend"); + pArray = pDict->GetArrayFor("Extend"); if (pArray) { bStartExtend = pArray->GetIntegerAt(0); bEndExtend = pArray->GetIntegerAt(1); @@ -256,7 +256,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap, CPDF_ColorSpace* pCS, int alpha) { ASSERT(pBitmap->GetFormat() == FXDIB_Argb); - CPDF_Array* pDomain = pDict->GetArrayBy("Domain"); + CPDF_Array* pDomain = pDict->GetArrayFor("Domain"); FX_FLOAT xmin = 0, ymin = 0, xmax = 1.0f, ymax = 1.0f; if (pDomain) { xmin = pDomain->GetNumberAt(0); @@ -264,7 +264,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap, ymin = pDomain->GetNumberAt(2); ymax = pDomain->GetNumberAt(3); } - CFX_Matrix mtDomain2Target = pDict->GetMatrixBy("Matrix"); + CFX_Matrix mtDomain2Target = pDict->GetMatrixFor("Matrix"); CFX_Matrix matrix, reverse_matrix; matrix.SetReverse(*pObject2Bitmap); reverse_matrix.SetReverse(mtDomain2Target); @@ -450,7 +450,7 @@ void DrawLatticeGouraudShading( int alpha) { ASSERT(pBitmap->GetFormat() == FXDIB_Argb); - int row_verts = pShadingStream->GetDict()->GetIntegerBy("VerticesPerRow"); + int row_verts = pShadingStream->GetDict()->GetIntegerFor("VerticesPerRow"); if (row_verts < 2) return; @@ -855,7 +855,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, FX_ARGB background = 0; if (!pPattern->IsShadingObject() && pDict->KeyExist("Background")) { - CPDF_Array* pBackColor = pDict->GetArrayBy("Background"); + CPDF_Array* pBackColor = pDict->GetArrayFor("Background"); if (pBackColor && pBackColor->GetCount() >= pColorSpace->CountComponents()) { CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents()); @@ -868,7 +868,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, } } if (pDict->KeyExist("BBox")) { - CFX_FloatRect rect = pDict->GetRectBy("BBox"); + CFX_FloatRect rect = pDict->GetRectFor("BBox"); rect.Transform(pMatrix); clip_rect.Intersect(rect.GetOuterRect()); } @@ -1055,7 +1055,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_Dictionary* pFormResource = nullptr; if (pPattern->form()->m_pFormDict) - pFormResource = pPattern->form()->m_pFormDict->GetDictBy("Resources"); + pFormResource = pPattern->form()->m_pFormDict->GetDictFor("Resources"); for (int col = min_col; col <= max_col; col++) for (int row = min_row; row <= max_row; row++) { diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp index fef0bcdb79..265948f1d5 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -237,7 +237,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, CPDF_Dictionary* pFormResource = nullptr; if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { pFormResource = - pType3Char->m_pForm->m_pFormDict->GetDictBy("Resources"); + pType3Char->m_pForm->m_pFormDict->GetDictFor("Resources"); } if (fill_alpha == 255) { CPDF_RenderStatus status; |