diff options
97 files changed, 1334 insertions, 1330 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; diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp index c2d77cf083..588c4c38df 100644 --- a/core/fpdfdoc/cpdf_aaction.cpp +++ b/core/fpdfdoc/cpdf_aaction.cpp @@ -19,6 +19,6 @@ FX_BOOL CPDF_AAction::ActionExist(AActionType eType) const { } CPDF_Action CPDF_AAction::GetAction(AActionType eType) const { - return m_pDict ? CPDF_Action(m_pDict->GetDictBy(g_sAATypes[eType])) + return m_pDict ? CPDF_Action(m_pDict->GetDictFor(g_sAATypes[eType])) : CPDF_Action(); } diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp index 86fc20ef2f..0255392cf7 100644 --- a/core/fpdfdoc/cpdf_action.cpp +++ b/core/fpdfdoc/cpdf_action.cpp @@ -25,11 +25,11 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { if (!m_pDict) return CPDF_Dest(); - CFX_ByteString type = m_pDict->GetStringBy("S"); + CFX_ByteString type = m_pDict->GetStringFor("S"); if (type != "GoTo" && type != "GoToR") return CPDF_Dest(); - CPDF_Object* pDest = m_pDict->GetDirectObjectBy("D"); + CPDF_Object* pDest = m_pDict->GetDirectObjectFor("D"); if (!pDest) return CPDF_Dest(); if (pDest->IsString() || pDest->IsName()) { @@ -46,7 +46,7 @@ CPDF_Action::ActionType CPDF_Action::GetType() const { if (!m_pDict) return Unknown; - CFX_ByteString csType = m_pDict->GetStringBy("S"); + CFX_ByteString csType = m_pDict->GetStringFor("S"); if (csType.IsEmpty()) return Unknown; @@ -58,20 +58,20 @@ CPDF_Action::ActionType CPDF_Action::GetType() const { } CFX_WideString CPDF_Action::GetFilePath() const { - CFX_ByteString type = m_pDict->GetStringBy("S"); + CFX_ByteString type = m_pDict->GetStringFor("S"); if (type != "GoToR" && type != "Launch" && type != "SubmitForm" && type != "ImportData") { return CFX_WideString(); } - CPDF_Object* pFile = m_pDict->GetDirectObjectBy("F"); + CPDF_Object* pFile = m_pDict->GetDirectObjectFor("F"); CFX_WideString path; if (!pFile) { if (type == "Launch") { - CPDF_Dictionary* pWinDict = m_pDict->GetDictBy("Win"); + CPDF_Dictionary* pWinDict = m_pDict->GetDictFor("Win"); if (pWinDict) { return CFX_WideString::FromLocal( - pWinDict->GetStringBy("F").AsStringC()); + pWinDict->GetStringFor("F").AsStringC()); } } return path; @@ -86,15 +86,15 @@ CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const { CFX_ByteString csURI; if (!m_pDict) return csURI; - if (m_pDict->GetStringBy("S") != "URI") + if (m_pDict->GetStringFor("S") != "URI") return csURI; - csURI = m_pDict->GetStringBy("URI"); + csURI = m_pDict->GetStringFor("URI"); CPDF_Dictionary* pRoot = pDoc->GetRoot(); - CPDF_Dictionary* pURI = pRoot->GetDictBy("URI"); + CPDF_Dictionary* pURI = pRoot->GetDictFor("URI"); if (pURI) { if (csURI.Find(":", 0) < 1) - csURI = pURI->GetStringBy("Base") + csURI; + csURI = pURI->GetStringFor("Base") + csURI; } return csURI; } @@ -104,7 +104,7 @@ CFX_WideString CPDF_Action::GetJavaScript() const { if (!m_pDict) return csJS; - CPDF_Object* pJS = m_pDict->GetDirectObjectBy("JS"); + CPDF_Object* pJS = m_pDict->GetDirectObjectFor("JS"); return pJS ? pJS->GetUnicodeText() : csJS; } @@ -112,7 +112,7 @@ size_t CPDF_Action::GetSubActionsCount() const { if (!m_pDict || !m_pDict->KeyExist("Next")) return 0; - CPDF_Object* pNext = m_pDict->GetDirectObjectBy("Next"); + CPDF_Object* pNext = m_pDict->GetDirectObjectFor("Next"); if (!pNext) return 0; if (pNext->IsDictionary()) @@ -126,7 +126,7 @@ CPDF_Action CPDF_Action::GetSubAction(size_t iIndex) const { if (!m_pDict || !m_pDict->KeyExist("Next")) return CPDF_Action(); - CPDF_Object* pNext = m_pDict->GetDirectObjectBy("Next"); + CPDF_Object* pNext = m_pDict->GetDirectObjectFor("Next"); if (CPDF_Dictionary* pDict = ToDictionary(pNext)) { if (iIndex == 0) return CPDF_Action(pDict); diff --git a/core/fpdfdoc/cpdf_actionfields.cpp b/core/fpdfdoc/cpdf_actionfields.cpp index 1ad1eb4673..438c67c7e8 100644 --- a/core/fpdfdoc/cpdf_actionfields.cpp +++ b/core/fpdfdoc/cpdf_actionfields.cpp @@ -18,12 +18,12 @@ size_t CPDF_ActionFields::GetFieldsCount() const { if (!pDict) return 0; - CFX_ByteString csType = pDict->GetStringBy("S"); + CFX_ByteString csType = pDict->GetStringFor("S"); CPDF_Object* pFields = nullptr; if (csType == "Hide") - pFields = pDict->GetDirectObjectBy("T"); + pFields = pDict->GetDirectObjectFor("T"); else - pFields = pDict->GetArrayBy("Fields"); + pFields = pDict->GetArrayFor("Fields"); if (!pFields) return 0; @@ -45,12 +45,12 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const { if (!pDict) return fields; - CFX_ByteString csType = pDict->GetStringBy("S"); + CFX_ByteString csType = pDict->GetStringFor("S"); CPDF_Object* pFields; if (csType == "Hide") - pFields = pDict->GetDirectObjectBy("T"); + pFields = pDict->GetDirectObjectFor("T"); else - pFields = pDict->GetArrayBy("Fields"); + pFields = pDict->GetArrayFor("Fields"); if (!pFields) return fields; @@ -75,12 +75,12 @@ CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const { if (!pDict) return nullptr; - CFX_ByteString csType = pDict->GetStringBy("S"); + CFX_ByteString csType = pDict->GetStringFor("S"); CPDF_Object* pFields = nullptr; if (csType == "Hide") - pFields = pDict->GetDirectObjectBy("T"); + pFields = pDict->GetDirectObjectFor("T"); else - pFields = pDict->GetArrayBy("Fields"); + pFields = pDict->GetArrayFor("Fields"); if (!pFields) return nullptr; diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 0cc3596a4d..bee96a62ff 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -39,7 +39,7 @@ CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, m_pDocument(pDocument), m_bOpenState(false), m_pPopupAnnot(nullptr) { - m_nSubtype = StringToAnnotSubtype(m_pAnnotDict->GetStringBy("Subtype")); + m_nSubtype = StringToAnnotSubtype(m_pAnnotDict->GetStringFor("Subtype")); GenerateAPIfNeeded(); } @@ -95,18 +95,18 @@ CFX_FloatRect CPDF_Annot::GetRect() const { if (!m_pAnnotDict) return CFX_FloatRect(); - CFX_FloatRect rect = m_pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = m_pAnnotDict->GetRectFor("Rect"); rect.Normalize(); return rect; } uint32_t CPDF_Annot::GetFlags() const { - return m_pAnnotDict->GetIntegerBy("F"); + return m_pAnnotDict->GetIntegerFor("F"); } CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::AppearanceMode mode) { - CPDF_Dictionary* pAP = pAnnotDict->GetDictBy("AP"); + CPDF_Dictionary* pAP = pAnnotDict->GetDictFor("AP"); if (!pAP) { return nullptr; } @@ -118,26 +118,26 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, if (!pAP->KeyExist(ap_entry)) ap_entry = "N"; - CPDF_Object* psub = pAP->GetDirectObjectBy(ap_entry); + CPDF_Object* psub = pAP->GetDirectObjectFor(ap_entry); if (!psub) return nullptr; if (CPDF_Stream* pStream = psub->AsStream()) return pStream; if (CPDF_Dictionary* pDict = psub->AsDictionary()) { - CFX_ByteString as = pAnnotDict->GetStringBy("AS"); + CFX_ByteString as = pAnnotDict->GetStringFor("AS"); if (as.IsEmpty()) { - CFX_ByteString value = pAnnotDict->GetStringBy("V"); + CFX_ByteString value = pAnnotDict->GetStringFor("V"); if (value.IsEmpty()) { - CPDF_Dictionary* pParentDict = pAnnotDict->GetDictBy("Parent"); - value = pParentDict ? pParentDict->GetStringBy("V") : CFX_ByteString(); + CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent"); + value = pParentDict ? pParentDict->GetStringFor("V") : CFX_ByteString(); } if (value.IsEmpty() || !pDict->KeyExist(value)) as = "Off"; else as = value; } - return pDict->GetStreamBy(as); + return pDict->GetStreamFor(as); } return nullptr; } @@ -167,8 +167,8 @@ static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage, if (!pForm) { return nullptr; } - CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectBy("BBox"); - CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); + CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectFor("BBox"); + CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixFor("Matrix"); form_matrix.TransformRect(form_bbox); matrix.MatchRect(pAnnot->GetRect(), form_bbox); matrix.Concat(*pUser2Device); @@ -177,7 +177,7 @@ static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage, // Static. bool CPDF_Annot::IsAnnotationHidden(CPDF_Dictionary* pAnnotDict) { - return !!(pAnnotDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN); + return !!(pAnnotDict->GetIntegerFor("F") & ANNOTFLAG_HIDDEN); } // Static. @@ -366,12 +366,12 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) { return; } - CPDF_Dictionary* pBS = m_pAnnotDict->GetDictBy("BS"); + CPDF_Dictionary* pBS = m_pAnnotDict->GetDictFor("BS"); char style_char; FX_FLOAT width; CPDF_Array* pDashArray = nullptr; if (!pBS) { - CPDF_Array* pBorderArray = m_pAnnotDict->GetArrayBy("Border"); + CPDF_Array* pBorderArray = m_pAnnotDict->GetArrayFor("Border"); style_char = 'S'; if (pBorderArray) { width = pBorderArray->GetNumberAt(2); @@ -397,15 +397,15 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, width = 1; } } else { - CFX_ByteString style = pBS->GetStringBy("S"); - pDashArray = pBS->GetArrayBy("D"); + CFX_ByteString style = pBS->GetStringFor("S"); + pDashArray = pBS->GetArrayFor("D"); style_char = style[1]; - width = pBS->GetNumberBy("W"); + width = pBS->GetNumberFor("W"); } if (width <= 0) { return; } - CPDF_Array* pColor = m_pAnnotDict->GetArrayBy("C"); + CPDF_Array* pColor = m_pAnnotDict->GetArrayFor("C"); uint32_t argb = 0xff000000; if (pColor) { int R = (int32_t)(pColor->GetNumberAt(0) * 255); diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 31c8542daa..8ab99e55d2 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -26,23 +26,23 @@ std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot, // TODO(jaepark): We shouldn't strip BOM for some strings and not for others. // See pdfium:593. - CFX_WideString sContents = pParentDict->GetUnicodeTextBy("Contents"); + CFX_WideString sContents = pParentDict->GetUnicodeTextFor("Contents"); if (sContents.IsEmpty()) return std::unique_ptr<CPDF_Annot>(); CPDF_Dictionary* pAnnotDict = new CPDF_Dictionary; - pAnnotDict->SetAtName("Type", "Annot"); - pAnnotDict->SetAtName("Subtype", "Popup"); - pAnnotDict->SetAtString("T", pParentDict->GetStringBy("T")); - pAnnotDict->SetAtString("Contents", sContents.UTF8Encode()); + pAnnotDict->SetNameFor("Type", "Annot"); + pAnnotDict->SetNameFor("Subtype", "Popup"); + pAnnotDict->SetStringFor("T", pParentDict->GetStringFor("T")); + pAnnotDict->SetStringFor("Contents", sContents.UTF8Encode()); - CFX_FloatRect rect = pParentDict->GetRectBy("Rect"); + CFX_FloatRect rect = pParentDict->GetRectFor("Rect"); rect.Normalize(); CFX_FloatRect popupRect(0, 0, 200, 200); popupRect.Translate(rect.left, rect.bottom - popupRect.Height()); - pAnnotDict->SetAtRect("Rect", popupRect); - pAnnotDict->SetAtInteger("F", 0); + pAnnotDict->SetRectFor("Rect", popupRect); + pAnnotDict->SetIntegerFor("F", 0); std::unique_ptr<CPDF_Annot> pPopupAnnot( new CPDF_Annot(pAnnotDict, pDocument, true)); @@ -57,14 +57,14 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) if (!pPage->m_pFormDict) return; - CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots"); + CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayFor("Annots"); if (!pAnnots) return; CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); - CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); + CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); FX_BOOL bRegenerateAP = - pAcroForm && pAcroForm->GetBooleanBy("NeedAppearances"); + pAcroForm && pAcroForm->GetBooleanFor("NeedAppearances"); for (size_t i = 0; i < pAnnots->GetCount(); ++i) { CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i)); if (!pDict) @@ -81,12 +81,12 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) // Skip creating Popup annotation in the PDF document since PDFium provides // its own Popup annotations. - if (pDict->GetStringBy("Subtype") == "Popup") + if (pDict->GetStringFor("Subtype") == "Popup") continue; m_AnnotList.push_back( std::unique_ptr<CPDF_Annot>(new CPDF_Annot(pDict, m_pDocument, false))); - if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" && + if (bRegenerateAP && pDict->GetStringFor("Subtype") == "Widget" && CPDF_InterForm::IsUpdateAPEnabled()) { FPDF_GenerateAP(m_pDocument, pDict); } @@ -130,7 +130,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, CPDF_OCContext* pOCContext = pOptions->m_pOCContext; CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict(); if (pOCContext && pAnnotDict && - !pOCContext->CheckOCGVisible(pAnnotDict->GetDictBy("OC"))) { + !pOCContext->CheckOCGVisible(pAnnotDict->GetDictFor("OC"))) { continue; } } diff --git a/core/fpdfdoc/cpdf_apsettings.cpp b/core/fpdfdoc/cpdf_apsettings.cpp index f2a802b445..3715e8ab89 100644 --- a/core/fpdfdoc/cpdf_apsettings.cpp +++ b/core/fpdfdoc/cpdf_apsettings.cpp @@ -17,7 +17,7 @@ bool CPDF_ApSettings::HasMKEntry(const CFX_ByteString& csEntry) const { } int CPDF_ApSettings::GetRotation() const { - return m_pDict ? m_pDict->GetIntegerBy("R") : 0; + return m_pDict ? m_pDict->GetIntegerFor("R") : 0; } FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, @@ -26,7 +26,7 @@ FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, if (!m_pDict) return 0; - CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry); + CPDF_Array* pEntry = m_pDict->GetArrayFor(csEntry); if (!pEntry) return 0; @@ -64,7 +64,7 @@ FX_FLOAT CPDF_ApSettings::GetOriginalColor( if (!m_pDict) return 0; - CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry); + CPDF_Array* pEntry = m_pDict->GetArrayFor(csEntry); return pEntry ? pEntry->GetNumberAt(index) : 0; } @@ -78,7 +78,7 @@ void CPDF_ApSettings::GetOriginalColor(int& iColorType, if (!m_pDict) return; - CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry); + CPDF_Array* pEntry = m_pDict->GetArrayFor(csEntry); if (!pEntry) return; @@ -102,18 +102,18 @@ void CPDF_ApSettings::GetOriginalColor(int& iColorType, CFX_WideString CPDF_ApSettings::GetCaption( const CFX_ByteString& csEntry) const { - return m_pDict ? m_pDict->GetUnicodeTextBy(csEntry) : CFX_WideString(); + return m_pDict ? m_pDict->GetUnicodeTextFor(csEntry) : CFX_WideString(); } CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteString& csEntry) const { - return m_pDict ? m_pDict->GetStreamBy(csEntry) : nullptr; + return m_pDict ? m_pDict->GetStreamFor(csEntry) : nullptr; } CPDF_IconFit CPDF_ApSettings::GetIconFit() const { - return CPDF_IconFit(m_pDict ? m_pDict->GetDictBy("IF") : nullptr); + return CPDF_IconFit(m_pDict ? m_pDict->GetDictFor("IF") : nullptr); } int CPDF_ApSettings::GetTextPosition() const { - return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION) + return m_pDict ? m_pDict->GetIntegerFor("TP", TEXTPOS_CAPTION) : TEXTPOS_CAPTION; } diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp index c9a2199750..de9832d233 100644 --- a/core/fpdfdoc/cpdf_bookmark.cpp +++ b/core/fpdfdoc/cpdf_bookmark.cpp @@ -15,7 +15,7 @@ uint32_t CPDF_Bookmark::GetColorRef() const { if (!m_pDict) return FXSYS_RGB(0, 0, 0); - CPDF_Array* pColor = m_pDict->GetArrayBy("C"); + CPDF_Array* pColor = m_pDict->GetArrayFor("C"); if (!pColor) return FXSYS_RGB(0, 0, 0); @@ -26,14 +26,14 @@ uint32_t CPDF_Bookmark::GetColorRef() const { } uint32_t CPDF_Bookmark::GetFontStyle() const { - return m_pDict ? m_pDict->GetIntegerBy("F") : 0; + return m_pDict ? m_pDict->GetIntegerFor("F") : 0; } CFX_WideString CPDF_Bookmark::GetTitle() const { if (!m_pDict) return CFX_WideString(); - CPDF_String* pString = ToString(m_pDict->GetDirectObjectBy("Title")); + CPDF_String* pString = ToString(m_pDict->GetDirectObjectFor("Title")); if (!pString) return CFX_WideString(); @@ -54,7 +54,7 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { if (!m_pDict) return CPDF_Dest(); - CPDF_Object* pDest = m_pDict->GetDirectObjectBy("Dest"); + CPDF_Object* pDest = m_pDict->GetDirectObjectFor("Dest"); if (!pDest) return CPDF_Dest(); if (pDest->IsString() || pDest->IsName()) { @@ -67,5 +67,5 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { } CPDF_Action CPDF_Bookmark::GetAction() const { - return m_pDict ? CPDF_Action(m_pDict->GetDictBy("A")) : CPDF_Action(); + return m_pDict ? CPDF_Action(m_pDict->GetDictFor("A")) : CPDF_Action(); } diff --git a/core/fpdfdoc/cpdf_bookmarktree.cpp b/core/fpdfdoc/cpdf_bookmarktree.cpp index 5ebb317a06..c10fabb240 100644 --- a/core/fpdfdoc/cpdf_bookmarktree.cpp +++ b/core/fpdfdoc/cpdf_bookmarktree.cpp @@ -12,14 +12,14 @@ CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( const CPDF_Bookmark& parent) const { CPDF_Dictionary* pParentDict = parent.GetDict(); if (pParentDict) - return CPDF_Bookmark(pParentDict->GetDictBy("First")); + return CPDF_Bookmark(pParentDict->GetDictFor("First")); CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); if (!pRoot) return CPDF_Bookmark(); - CPDF_Dictionary* pOutlines = pRoot->GetDictBy("Outlines"); - return pOutlines ? CPDF_Bookmark(pOutlines->GetDictBy("First")) + CPDF_Dictionary* pOutlines = pRoot->GetDictFor("Outlines"); + return pOutlines ? CPDF_Bookmark(pOutlines->GetDictFor("First")) : CPDF_Bookmark(); } @@ -29,6 +29,6 @@ CPDF_Bookmark CPDF_BookmarkTree::GetNextSibling( if (!pDict) return CPDF_Bookmark(); - CPDF_Dictionary* pNext = pDict->GetDictBy("Next"); + CPDF_Dictionary* pNext = pDict->GetDictFor("Next"); return pNext == pDict ? CPDF_Bookmark() : CPDF_Bookmark(pNext); } diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp index 2084606629..3176eb51af 100644 --- a/core/fpdfdoc/cpdf_filespec.cpp +++ b/core/fpdfdoc/cpdf_filespec.cpp @@ -80,23 +80,23 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) { bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const { if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { - *csFileName = pDict->GetUnicodeTextBy("UF"); + *csFileName = pDict->GetUnicodeTextFor("UF"); if (csFileName->IsEmpty()) { *csFileName = - CFX_WideString::FromLocal(pDict->GetStringBy("F").AsStringC()); + CFX_WideString::FromLocal(pDict->GetStringFor("F").AsStringC()); } - if (pDict->GetStringBy("FS") == "URL") + if (pDict->GetStringFor("FS") == "URL") return true; if (csFileName->IsEmpty()) { if (pDict->KeyExist("DOS")) { *csFileName = - CFX_WideString::FromLocal(pDict->GetStringBy("DOS").AsStringC()); + CFX_WideString::FromLocal(pDict->GetStringFor("DOS").AsStringC()); } else if (pDict->KeyExist("Mac")) { *csFileName = - CFX_WideString::FromLocal(pDict->GetStringBy("Mac").AsStringC()); + CFX_WideString::FromLocal(pDict->GetStringFor("Mac").AsStringC()); } else if (pDict->KeyExist("Unix")) { *csFileName = - CFX_WideString::FromLocal(pDict->GetStringBy("Unix").AsStringC()); + CFX_WideString::FromLocal(pDict->GetStringFor("Unix").AsStringC()); } else { return false; } @@ -112,7 +112,7 @@ bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const { CPDF_FileSpec::CPDF_FileSpec() { m_pObj = new CPDF_Dictionary; - m_pObj->AsDictionary()->SetAtName("Type", "Filespec"); + m_pObj->AsDictionary()->SetNameFor("Type", "Filespec"); } CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) { @@ -161,7 +161,7 @@ void CPDF_FileSpec::SetFileName(const CFX_WideStringC& wsFileName) { if (m_pObj->IsString()) { m_pObj->SetString(CFX_ByteString::FromUnicode(wsStr)); } else if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { - pDict->SetAtString("F", CFX_ByteString::FromUnicode(wsStr)); - pDict->SetAtString("UF", PDF_EncodeText(wsStr)); + pDict->SetStringFor("F", CFX_ByteString::FromUnicode(wsStr)); + pDict->SetStringFor("UF", PDF_EncodeText(wsStr)); } } diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp index 0843f3045b..f63c388478 100644 --- a/core/fpdfdoc/cpdf_filespec_unittest.cpp +++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp @@ -109,13 +109,13 @@ TEST(cpdf_filespec, GetFileName) { CPDF_FileSpec file_spec(dict_obj.get()); CFX_WideString file_name; for (int i = 0; i < 5; ++i) { - dict_obj->SetAt(keywords[i], new CPDF_String(test_data[i].input)); + dict_obj->SetFor(keywords[i], new CPDF_String(test_data[i].input)); EXPECT_TRUE(file_spec.GetFileName(&file_name)); EXPECT_TRUE(file_name == test_data[i].expected); } // With all the former fields and 'FS' field suggests 'URL' type. - dict_obj->SetAtString("FS", "URL"); + dict_obj->SetStringFor("FS", "URL"); EXPECT_TRUE(file_spec.GetFileName(&file_name)); // Url string is not decoded. EXPECT_TRUE(file_name == test_data[4].input); @@ -159,9 +159,9 @@ TEST(cpdf_filespec, SetFileName) { CPDF_FileSpec file_spec2(dict_obj.get()); file_spec2.SetFileName(test_data.input); // Check internal object value. - file_name = dict_obj->GetUnicodeTextBy("F"); + file_name = dict_obj->GetUnicodeTextFor("F"); EXPECT_TRUE(file_name == test_data.expected); - file_name = dict_obj->GetUnicodeTextBy("UF"); + file_name = dict_obj->GetUnicodeTextFor("UF"); EXPECT_TRUE(file_name == test_data.expected); // Check we can get the file name back. EXPECT_TRUE(file_spec2.GetFileName(&file_name)); diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index 9d134842fa..c633d0c187 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -35,11 +35,11 @@ CFX_ByteString CPDF_FormControl::GetOnStateName() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); CFX_ByteString csOn; - CPDF_Dictionary* pAP = m_pWidgetDict->GetDictBy("AP"); + CPDF_Dictionary* pAP = m_pWidgetDict->GetDictFor("AP"); if (!pAP) return csOn; - CPDF_Dictionary* pN = pAP->GetDictBy("N"); + CPDF_Dictionary* pN = pAP->GetDictFor("N"); if (!pN) return csOn; @@ -59,11 +59,11 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { else if (csValue == "Off") csValue = "Yes"; - CFX_ByteString csAS = m_pWidgetDict->GetStringBy("AS", "Off"); + CFX_ByteString csAS = m_pWidgetDict->GetStringFor("AS", "Off"); if (csAS != "Off") - m_pWidgetDict->SetAtName("AS", csValue); + m_pWidgetDict->SetNameFor("AS", csValue); - CPDF_Dictionary* pAP = m_pWidgetDict->GetDictBy("AP"); + CPDF_Dictionary* pAP = m_pWidgetDict->GetDictFor("AP"); if (!pAP) return; @@ -129,7 +129,7 @@ bool CPDF_FormControl::IsChecked() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); CFX_ByteString csOn = GetOnStateName(); - CFX_ByteString csAS = m_pWidgetDict->GetStringBy("AS"); + CFX_ByteString csAS = m_pWidgetDict->GetStringFor("AS"); return csAS == csOn; } @@ -149,13 +149,13 @@ void CPDF_FormControl::CheckControl(FX_BOOL bChecked) { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); CFX_ByteString csOn = GetOnStateName(); - CFX_ByteString csOldAS = m_pWidgetDict->GetStringBy("AS", "Off"); + CFX_ByteString csOldAS = m_pWidgetDict->GetStringFor("AS", "Off"); CFX_ByteString csAS = "Off"; if (bChecked) csAS = csOn; if (csOldAS == csAS) return; - m_pWidgetDict->SetAtName("AS", csAS); + m_pWidgetDict->SetNameFor("AS", csAS); } void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, @@ -163,22 +163,22 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, CPDF_Page* pPage, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions) { - if (m_pWidgetDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN) + if (m_pWidgetDict->GetIntegerFor("F") & ANNOTFLAG_HIDDEN) return; CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode); if (!pStream) return; - CFX_FloatRect form_bbox = pStream->GetDict()->GetRectBy("BBox"); - CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixBy("Matrix"); + CFX_FloatRect form_bbox = pStream->GetDict()->GetRectFor("BBox"); + CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixFor("Matrix"); form_matrix.TransformRect(form_bbox); - CFX_FloatRect arect = m_pWidgetDict->GetRectBy("Rect"); + CFX_FloatRect arect = m_pWidgetDict->GetRectFor("Rect"); CFX_Matrix matrix; matrix.MatchRect(arect, form_bbox); matrix.Concat(*pMatrix); CPDF_Form form(m_pField->m_pForm->m_pDocument, - m_pField->m_pForm->m_pFormDict->GetDictBy("DR"), pStream); + m_pField->m_pForm->m_pFormDict->GetDictFor("DR"), pStream); form.ParseContent(nullptr, nullptr, nullptr); CPDF_RenderContext context(pPage); context.AppendLayer(&form, &matrix); @@ -189,7 +189,7 @@ CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() { if (!m_pWidgetDict) return Invert; - CFX_ByteString csH = m_pWidgetDict->GetStringBy("H", "I"); + CFX_ByteString csH = m_pWidgetDict->GetStringFor("H", "I"); for (size_t i = 0; i < FX_ArraySize(g_sHighlightingMode); ++i) { if (csH == g_sHighlightingMode[i]) return static_cast<HighlightingMode>(i); @@ -198,7 +198,7 @@ CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() { } CPDF_ApSettings CPDF_FormControl::GetMK() const { - return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictBy("MK") + return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictFor("MK") : nullptr); } @@ -247,7 +247,7 @@ CPDF_Action CPDF_FormControl::GetAction() { return CPDF_Action(); if (m_pWidgetDict->KeyExist("A")) - return CPDF_Action(m_pWidgetDict->GetDictBy("A")); + return CPDF_Action(m_pWidgetDict->GetDictFor("A")); CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "A"); if (!pObj) @@ -261,7 +261,7 @@ CPDF_AAction CPDF_FormControl::GetAdditionalAction() { return CPDF_AAction(); if (m_pWidgetDict->KeyExist("AA")) - return CPDF_AAction(m_pWidgetDict->GetDictBy("AA")); + return CPDF_AAction(m_pWidgetDict->GetDictFor("AA")); return m_pField->GetAdditionalAction(); } @@ -270,7 +270,7 @@ CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { return CPDF_DefaultAppearance(); if (m_pWidgetDict->KeyExist("DA")) - return CPDF_DefaultAppearance(m_pWidgetDict->GetStringBy("DA")); + return CPDF_DefaultAppearance(m_pWidgetDict->GetStringFor("DA")); CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); if (pObj) @@ -288,9 +288,9 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { - CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDict->GetDictFor("Font"); if (pFonts) { - CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); + CPDF_Dictionary* pElement = pFonts->GetDictFor(csFontNameTag); if (pElement) { CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); if (pFont) @@ -301,12 +301,12 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag)) return pFormFont; - CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDictBy("P"); + CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDictFor("P"); pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { - CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDict->GetDictFor("Font"); if (pFonts) { - CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); + CPDF_Dictionary* pElement = pFonts->GetDictFor(csFontNameTag); if (pElement) { CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); if (pFont) @@ -321,7 +321,7 @@ int CPDF_FormControl::GetControlAlignment() { if (!m_pWidgetDict) return 0; if (m_pWidgetDict->KeyExist("Q")) - return m_pWidgetDict->GetIntegerBy("Q", 0); + return m_pWidgetDict->GetIntegerFor("Q", 0); CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); if (pObj) diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 8d7d0b4dc0..cbce1aaf69 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -56,11 +56,11 @@ CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, if (!pFieldDict) return nullptr; - CPDF_Object* pAttr = pFieldDict->GetDirectObjectBy(name); + CPDF_Object* pAttr = pFieldDict->GetDirectObjectFor(name); if (pAttr) return pAttr; - CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); + CPDF_Dictionary* pParent = pFieldDict->GetDictFor("Parent"); if (!pParent) return nullptr; return FPDF_GetFieldAttr(pParent, name, nLevel + 1); @@ -72,14 +72,14 @@ CFX_WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) { CPDF_Dictionary* pLevel = pFieldDict; while (pLevel) { visited.insert(pLevel); - CFX_WideString short_name = pLevel->GetUnicodeTextBy("T"); + CFX_WideString short_name = pLevel->GetUnicodeTextFor("T"); if (!short_name.IsEmpty()) { if (full_name.IsEmpty()) full_name = short_name; else full_name = short_name + L"." + full_name; } - pLevel = pLevel->GetDictBy("Parent"); + pLevel = pLevel->GetDictFor("Parent"); if (pdfium::ContainsKey(visited, pLevel)) break; } @@ -223,14 +223,14 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { if (!pClone) return FALSE; - m_pDict->SetAt("V", pClone); + m_pDict->SetFor("V", pClone); if (pRV) { CPDF_Object* pCloneR = pDV->Clone(); - m_pDict->SetAt("RV", pCloneR); + m_pDict->SetFor("RV", pCloneR); } } else { - m_pDict->RemoveAt("V"); - m_pDict->RemoveAt("RV"); + m_pDict->RemoveFor("V"); + m_pDict->RemoveFor("RV"); } if (bNotify) NotifyAfterValueChange(); @@ -364,12 +364,12 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, int iIndex = FindOptionValue(csValue); if (iIndex < 0) { CFX_ByteString bsEncodeText = PDF_EncodeText(csValue); - m_pDict->SetAtString(bDefault ? "DV" : "V", bsEncodeText); + m_pDict->SetStringFor(bDefault ? "DV" : "V", bsEncodeText); if (m_Type == RichText && !bDefault) - m_pDict->SetAtString("RV", bsEncodeText); - m_pDict->RemoveAt("I"); + m_pDict->SetStringFor("RV", bsEncodeText); + m_pDict->RemoveFor("I"); } else { - m_pDict->SetAtString(bDefault ? "DV" : "V", PDF_EncodeText(csValue)); + m_pDict->SetStringFor(bDefault ? "DV" : "V", PDF_EncodeText(csValue)); if (!bDefault) { ClearSelection(); SetItemSelection(iIndex, TRUE); @@ -419,7 +419,7 @@ int CPDF_FormField::GetMaxLen() const { CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; if (pWidgetDict->KeyExist("MaxLen")) - return pWidgetDict->GetIntegerBy("MaxLen"); + return pWidgetDict->GetIntegerFor("MaxLen"); } return 0; } @@ -486,8 +486,8 @@ FX_BOOL CPDF_FormField::ClearSelection(FX_BOOL bNotify) { if (!NotifyListOrComboBoxBeforeChange(csValue)) return FALSE; } - m_pDict->RemoveAt("V"); - m_pDict->RemoveAt("I"); + m_pDict->RemoveFor("V"); + m_pDict->RemoveFor("I"); if (bNotify) NotifyListOrComboBoxAfterChange(); return TRUE; @@ -551,7 +551,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, if (GetType() == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & kFormListMultiSelect)) { - m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); + m_pDict->SetStringFor("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { @@ -560,13 +560,13 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, pArray->AddString(PDF_EncodeText(opt_value)); } } - m_pDict->SetAt("V", pArray); + m_pDict->SetFor("V", pArray); } } else { - m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); + m_pDict->SetStringFor("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; pI->AddInteger(index); - m_pDict->SetAt("I", pI); + m_pDict->SetFor("I", pI); } } else { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); @@ -575,7 +575,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, SelectOption(index, FALSE); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) - m_pDict->RemoveAt("V"); + m_pDict->RemoveFor("V"); } else if (pValue->IsArray()) { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { @@ -587,11 +587,11 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, if (pArray->GetCount() < 1) pArray->Release(); else - m_pDict->SetAt("V", pArray); + m_pDict->SetFor("V", pArray); } } else { - m_pDict->RemoveAt("V"); - m_pDict->RemoveAt("I"); + m_pDict->RemoveFor("V"); + m_pDict->RemoveFor("I"); } } } @@ -683,7 +683,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, CPDF_Array* pOpt = ToArray(pValue); if (!pOpt) { pOpt = new CPDF_Array; - m_pDict->SetAt("Opt", pOpt); + m_pDict->SetFor("Opt", pOpt); } int iCount = pdfium::base::checked_cast<int, size_t>(pOpt->GetCount()); @@ -710,11 +710,11 @@ FX_BOOL CPDF_FormField::ClearOptions(FX_BOOL bNotify) { return FALSE; } - m_pDict->RemoveAt("Opt"); - m_pDict->RemoveAt("V"); - m_pDict->RemoveAt("DV"); - m_pDict->RemoveAt("I"); - m_pDict->RemoveAt("TI"); + m_pDict->RemoveFor("Opt"); + m_pDict->RemoveFor("V"); + m_pDict->RemoveFor("DV"); + m_pDict->RemoveFor("I"); + m_pDict->RemoveFor("TI"); if (bNotify) NotifyListOrComboBoxAfterChange(); @@ -760,19 +760,19 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pDict, "Opt"); if (!ToArray(pOpt)) { if (bChecked) { - m_pDict->SetAtName("V", csBExport); + m_pDict->SetNameFor("V", csBExport); } else { CFX_ByteString csV; CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V"); if (pV) csV = pV->GetString(); if (csV == csBExport) - m_pDict->SetAtName("V", "Off"); + m_pDict->SetNameFor("V", "Off"); } } else if (bChecked) { CFX_ByteString csIndex; csIndex.Format("%d", iControlIndex); - m_pDict->SetAtName("V", csIndex); + m_pDict->SetNameFor("V", csIndex); } if (bNotify && m_pForm->m_pFormNotify) m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); @@ -850,13 +850,13 @@ FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) const { FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, FX_BOOL bSelected, FX_BOOL bNotify) { - CPDF_Array* pArray = m_pDict->GetArrayBy("I"); + CPDF_Array* pArray = m_pDict->GetArrayFor("I"); if (!pArray) { if (!bSelected) return TRUE; pArray = new CPDF_Array; - m_pDict->SetAt("I", pArray); + m_pDict->SetFor("I", pArray); } FX_BOOL bReturn = FALSE; @@ -895,7 +895,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, pArray->AddInteger(iOptIndex); if (pArray->IsEmpty()) - m_pDict->RemoveAt("I"); + m_pDict->RemoveFor("I"); } if (bNotify) NotifyListOrComboBoxAfterChange(); @@ -913,7 +913,7 @@ FX_BOOL CPDF_FormField::ClearSelectedOptions(FX_BOOL bNotify) { if (!NotifyListOrComboBoxBeforeChange(csValue)) return FALSE; } - m_pDict->RemoveAt("I"); + m_pDict->RemoveFor("I"); if (bNotify) NotifyListOrComboBoxAfterChange(); @@ -930,23 +930,23 @@ void CPDF_FormField::LoadDA() { DA = pObj->GetString(); if (DA.IsEmpty()) - DA = pFormDict->GetStringBy("DA"); + DA = pFormDict->GetStringFor("DA"); if (DA.IsEmpty()) return; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return; - CPDF_Dictionary* pFont = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFont = pDR->GetDictFor("Font"); if (!pFont) return; CPDF_SimpleParser syntax(DA.AsStringC()); syntax.FindTagParamFromStart("Tf", 2); CFX_ByteString font_name(syntax.GetWord()); - CPDF_Dictionary* pFontDict = pFont->GetDictBy(font_name); + CPDF_Dictionary* pFontDict = pFont->GetDictFor(font_name); if (!pFontDict) return; diff --git a/core/fpdfdoc/cpdf_formfield_unittest.cpp b/core/fpdfdoc/cpdf_formfield_unittest.cpp index 33a21185cd..7677f45284 100644 --- a/core/fpdfdoc/cpdf_formfield_unittest.cpp +++ b/core/fpdfdoc/cpdf_formfield_unittest.cpp @@ -14,31 +14,31 @@ TEST(cpdf_formfield, FPDF_GetFullName) { CPDF_IndirectObjectHolder obj_holder; CPDF_Dictionary* root = new CPDF_Dictionary; obj_holder.AddIndirectObject(root); - root->SetAtName("T", "foo"); + root->SetNameFor("T", "foo"); name = FPDF_GetFullName(root); EXPECT_STREQ("foo", name.UTF8Encode().c_str()); CPDF_Dictionary* dict1 = new CPDF_Dictionary; obj_holder.AddIndirectObject(dict1); - dict1->SetAtName("T", "bar"); - root->SetAtReference("Parent", &obj_holder, dict1); + dict1->SetNameFor("T", "bar"); + root->SetReferenceFor("Parent", &obj_holder, dict1); name = FPDF_GetFullName(root); EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str()); CPDF_Dictionary* dict2 = new CPDF_Dictionary; obj_holder.AddIndirectObject(dict2); - dict1->SetAt("Parent", dict2); + dict1->SetFor("Parent", dict2); name = FPDF_GetFullName(root); EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str()); CPDF_Dictionary* dict3 = new CPDF_Dictionary; obj_holder.AddIndirectObject(dict3); - dict3->SetAtName("T", "qux"); - dict2->SetAtReference("Parent", &obj_holder, dict3); + dict3->SetNameFor("T", "qux"); + dict2->SetReferenceFor("Parent", &obj_holder, dict3); name = FPDF_GetFullName(root); EXPECT_STREQ("qux.bar.foo", name.UTF8Encode().c_str()); - dict3->SetAtReference("Parent", &obj_holder, root); + dict3->SetReferenceFor("Parent", &obj_holder, root); name = FPDF_GetFullName(root); EXPECT_STREQ("qux.bar.foo", name.UTF8Encode().c_str()); name = FPDF_GetFullName(dict1); diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp index 3b3a09a54b..d86c4d918d 100644 --- a/core/fpdfdoc/cpdf_iconfit.cpp +++ b/core/fpdfdoc/cpdf_iconfit.cpp @@ -14,7 +14,7 @@ CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { if (!m_pDict) return Always; - CFX_ByteString csSW = m_pDict->GetStringBy("SW", "A"); + CFX_ByteString csSW = m_pDict->GetStringFor("SW", "A"); if (csSW == "B") return Bigger; if (csSW == "S") @@ -25,7 +25,7 @@ CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { } FX_BOOL CPDF_IconFit::IsProportionalScale() { - return m_pDict ? m_pDict->GetStringBy("S", "P") != "A" : TRUE; + return m_pDict ? m_pDict->GetStringFor("S", "P") != "A" : TRUE; } void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { @@ -33,7 +33,7 @@ void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { if (!m_pDict) return; - CPDF_Array* pA = m_pDict->GetArrayBy("A"); + CPDF_Array* pA = m_pDict->GetArrayFor("A"); if (pA) { uint32_t dwCount = pA->GetCount(); if (dwCount > 0) @@ -44,5 +44,5 @@ void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { } bool CPDF_IconFit::GetFittingBounds() { - return m_pDict ? m_pDict->GetBooleanBy("FB") : false; + return m_pDict ? m_pDict->GetBooleanFor("FB") : false; } diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 0ebf4460cf..196eeccfba 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -36,7 +36,7 @@ const struct SupportFieldEncoding { CFX_WideString GetFieldValue(const CPDF_Dictionary& pFieldDict, const CFX_ByteString& bsEncoding) { - const CFX_ByteString csBValue = pFieldDict.GetStringBy("V"); + const CFX_ByteString csBValue = pFieldDict.GetStringFor("V"); for (const auto& encoding : g_fieldEncoding) { if (bsEncoding == encoding.m_name) return CFX_WideString::FromCodePage(csBValue.AsStringC(), @@ -61,7 +61,7 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { pFormDict = new CPDF_Dictionary; uint32_t dwObjNum = pDocument->AddIndirectObject(pFormDict); CPDF_Dictionary* pRoot = pDocument->GetRoot(); - pRoot->SetAtReference("AcroForm", pDocument, dwObjNum); + pRoot->SetReferenceFor("AcroForm", pDocument, dwObjNum); } CFX_ByteString csDA; @@ -94,18 +94,18 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { csDA += "0 g"; if (!pFormDict->KeyExist("DA")) - pFormDict->SetAtString("DA", csDA); + pFormDict->SetStringFor("DA", csDA); } uint32_t CountFonts(CPDF_Dictionary* pFormDict) { if (!pFormDict) return 0; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return 0; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return 0; @@ -116,7 +116,7 @@ uint32_t CountFonts(CPDF_Dictionary* pFormDict) { continue; if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) { - if (pDirect->GetStringBy("Type") == "Font") + if (pDirect->GetStringFor("Type") == "Font") dwCount++; } } @@ -130,11 +130,11 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, if (!pFormDict) return nullptr; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return nullptr; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return nullptr; @@ -148,7 +148,7 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); if (!pElement) continue; - if (pElement->GetStringBy("Type") != "Font") + if (pElement->GetStringFor("Type") != "Font") continue; if (dwCount == index) { csNameTag = csKey; @@ -166,19 +166,19 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, if (!pFormDict || csAlias.IsEmpty()) return nullptr; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return nullptr; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return nullptr; - CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias); + CPDF_Dictionary* pElement = pFonts->GetDictFor(csAlias); if (!pElement) return nullptr; - if (pElement->GetStringBy("Type") == "Font") + if (pElement->GetStringFor("Type") == "Font") return pDocument->LoadFont(pElement); return nullptr; } @@ -190,11 +190,11 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, if (!pFormDict || csFontName.IsEmpty()) return nullptr; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return nullptr; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return nullptr; @@ -207,7 +207,7 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); if (!pElement) continue; - if (pElement->GetStringBy("Type") != "Font") + if (pElement->GetStringFor("Type") != "Font") continue; CPDF_Font* pFind = pDocument->LoadFont(pElement); @@ -232,11 +232,11 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, if (!pFormDict) return nullptr; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return nullptr; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return nullptr; @@ -249,7 +249,7 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); if (!pElement) continue; - if (pElement->GetStringBy("Type") != "Font") + if (pElement->GetStringFor("Type") != "Font") continue; CPDF_Font* pFind = pDocument->LoadFont(pElement); if (!pFind) @@ -272,7 +272,7 @@ CPDF_Font* GetDefaultFont(CPDF_Dictionary* pFormDict, if (!pFormDict) return nullptr; - CPDF_DefaultAppearance cDA(pFormDict->GetStringBy("DA")); + CPDF_DefaultAppearance cDA(pFormDict->GetStringFor("DA")); CFX_ByteString csFontNameTag; FX_FLOAT fFontSize; cDA.GetFont(csFontNameTag, fFontSize); @@ -285,11 +285,11 @@ FX_BOOL FindFont(CPDF_Dictionary* pFormDict, if (!pFormDict || !pFont) return FALSE; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return FALSE; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return FALSE; @@ -302,7 +302,7 @@ FX_BOOL FindFont(CPDF_Dictionary* pFormDict, CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); if (!pElement) continue; - if (pElement->GetStringBy("Type") != "Font") + if (pElement->GetStringFor("Type") != "Font") continue; if (pFont->GetFontDict() == pElement) { csNameTag = csKey; @@ -336,11 +336,11 @@ FX_BOOL FindFont(CPDF_Dictionary* pFormDict, if (!pFormDict) return FALSE; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return FALSE; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return FALSE; if (csFontName.GetLength() > 0) @@ -355,7 +355,7 @@ FX_BOOL FindFont(CPDF_Dictionary* pFormDict, CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); if (!pElement) continue; - if (pElement->GetStringBy("Type") != "Font") + if (pElement->GetStringFor("Type") != "Font") continue; pFont = pDocument->LoadFont(pElement); @@ -390,15 +390,15 @@ void AddFont(CPDF_Dictionary*& pFormDict, if (!pFormDict) InitDict(pFormDict, pDocument); - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) { pDR = new CPDF_Dictionary; - pFormDict->SetAt("DR", pDR); + pFormDict->SetFor("DR", pDR); } - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) { pFonts = new CPDF_Dictionary; - pDR->SetAt("Font", pFonts); + pDR->SetFor("Font", pFonts); } if (csNameTag.IsEmpty()) csNameTag = pFont->GetBaseFont(); @@ -406,7 +406,7 @@ void AddFont(CPDF_Dictionary*& pFormDict, csNameTag.Remove(' '); csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag.c_str()); - pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict()); + pFonts->SetReferenceFor(csNameTag, pDocument, pFont->GetFontDict()); } CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, @@ -442,24 +442,24 @@ void RemoveFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) { if (!FindFont(pFormDict, pFont, csTag)) return; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); - pFonts->RemoveAt(csTag); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); + pFonts->RemoveFor(csTag); } void RemoveFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { if (!pFormDict || csNameTag.IsEmpty()) return; - CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDR = pFormDict->GetDictFor("DR"); if (!pDR) return; - CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return; - pFonts->RemoveAt(csNameTag); + pFonts->RemoveFor(csNameTag); } class CFieldNameExtractor { @@ -815,11 +815,11 @@ CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument) if (!pRoot) return; - m_pFormDict = pRoot->GetDictBy("AcroForm"); + m_pFormDict = pRoot->GetDictFor("AcroForm"); if (!m_pFormDict) return; - CPDF_Array* pFields = m_pFormDict->GetArrayBy("Fields"); + CPDF_Array* pFields = m_pFormDict->GetArrayFor("Fields"); if (!pFields) return; @@ -880,7 +880,7 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName( if (!pResDict) return csTmp; - CPDF_Dictionary* pDict = pResDict->GetDictBy(csType); + CPDF_Dictionary* pDict = pResDict->GetDictFor(csType); if (!pDict) return csTmp; @@ -1131,7 +1131,7 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y, int* z_order) const { - CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots"); + CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayFor("Annots"); if (!pAnnotList) return nullptr; @@ -1164,14 +1164,14 @@ CPDF_FormControl* CPDF_InterForm::GetControlByDict( } FX_BOOL CPDF_InterForm::NeedConstructAP() const { - return m_pFormDict && m_pFormDict->GetBooleanBy("NeedAppearances"); + return m_pFormDict && m_pFormDict->GetBooleanFor("NeedAppearances"); } int CPDF_InterForm::CountFieldsInCalculationOrder() { if (!m_pFormDict) return 0; - CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO"); + CPDF_Array* pArray = m_pFormDict->GetArrayFor("CO"); return pArray ? pArray->GetCount() : 0; } @@ -1179,7 +1179,7 @@ CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { if (!m_pFormDict || index < 0) return nullptr; - CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO"); + CPDF_Array* pArray = m_pFormDict->GetArrayFor("CO"); if (!pArray) return nullptr; @@ -1191,7 +1191,7 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { if (!m_pFormDict || !pField) return -1; - CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO"); + CPDF_Array* pArray = m_pFormDict->GetArrayFor("CO"); if (!pArray) return -1; @@ -1266,7 +1266,7 @@ void CPDF_InterForm::RemoveFormFont(CFX_ByteString csNameTag) { CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() { if (!m_pFormDict) return CPDF_DefaultAppearance(); - return CPDF_DefaultAppearance(m_pFormDict->GetStringBy("DA")); + return CPDF_DefaultAppearance(m_pFormDict->GetStringFor("DA")); } CPDF_Font* CPDF_InterForm::GetDefaultFormFont() { @@ -1274,7 +1274,7 @@ CPDF_Font* CPDF_InterForm::GetDefaultFormFont() { } int CPDF_InterForm::GetFormAlignment() { - return m_pFormDict ? m_pFormDict->GetIntegerBy("Q", 0) : 0; + return m_pFormDict ? m_pFormDict->GetIntegerFor("Q", 0) : 0; } bool CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields, @@ -1321,7 +1321,7 @@ void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { return; uint32_t dwParentObjNum = pFieldDict->GetObjNum(); - CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); + CPDF_Array* pKids = pFieldDict->GetArrayFor("Kids"); if (!pKids) { AddTerminalField(pFieldDict); return; @@ -1345,7 +1345,7 @@ void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { } FX_BOOL CPDF_InterForm::HasXFAForm() const { - return m_pFormDict && m_pFormDict->GetArrayBy("XFA"); + return m_pFormDict && m_pFormDict->GetArrayFor("XFA"); } void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { @@ -1353,13 +1353,13 @@ void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { if (!pPageDict) return; - CPDF_Array* pAnnots = pPageDict->GetArrayBy("Annots"); + CPDF_Array* pAnnots = pPageDict->GetArrayFor("Annots"); if (!pAnnots) return; for (size_t i = 0; i < pAnnots->GetCount(); i++) { CPDF_Dictionary* pAnnot = pAnnots->GetDictAt(i); - if (pAnnot && pAnnot->GetStringBy("Subtype") == "Widget") + if (pAnnot && pAnnot->GetStringFor("Subtype") == "Widget") LoadField(pAnnot); } } @@ -1378,48 +1378,48 @@ CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { if (!pField) { CPDF_Dictionary* pParent = pFieldDict; if (!pFieldDict->KeyExist("T") && - pFieldDict->GetStringBy("Subtype") == "Widget") { - pParent = pFieldDict->GetDictBy("Parent"); + pFieldDict->GetStringFor("Subtype") == "Widget") { + pParent = pFieldDict->GetDictFor("Parent"); if (!pParent) pParent = pFieldDict; } if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) { if (pFieldDict->KeyExist("FT")) { - CPDF_Object* pFTValue = pFieldDict->GetDirectObjectBy("FT"); + CPDF_Object* pFTValue = pFieldDict->GetDirectObjectFor("FT"); if (pFTValue) - pParent->SetAt("FT", pFTValue->Clone()); + pParent->SetFor("FT", pFTValue->Clone()); } if (pFieldDict->KeyExist("Ff")) { - CPDF_Object* pFfValue = pFieldDict->GetDirectObjectBy("Ff"); + CPDF_Object* pFfValue = pFieldDict->GetDirectObjectFor("Ff"); if (pFfValue) - pParent->SetAt("Ff", pFfValue->Clone()); + pParent->SetFor("Ff", pFfValue->Clone()); } } pField = new CPDF_FormField(this, pParent); - CPDF_Object* pTObj = pDict->GetObjectBy("T"); + CPDF_Object* pTObj = pDict->GetObjectFor("T"); if (ToReference(pTObj)) { CPDF_Object* pClone = pTObj->CloneDirectObject(); if (pClone) - pDict->SetAt("T", pClone); + pDict->SetFor("T", pClone); else - pDict->SetAtName("T", ""); + pDict->SetNameFor("T", ""); } m_pFieldTree->SetField(csWName, pField); } - CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); + CPDF_Array* pKids = pFieldDict->GetArrayFor("Kids"); if (!pKids) { - if (pFieldDict->GetStringBy("Subtype") == "Widget") + if (pFieldDict->GetStringFor("Subtype") == "Widget") AddControl(pField, pFieldDict); } else { for (size_t i = 0; i < pKids->GetCount(); i++) { CPDF_Dictionary* pKid = pKids->GetDictAt(i); if (!pKid) continue; - if (pKid->GetStringBy("Subtype") != "Widget") + if (pKid->GetStringFor("Subtype") != "Widget") continue; AddControl(pField, pKid); @@ -1464,7 +1464,7 @@ CPDF_FormField* CPDF_InterForm::CheckRequiredFields( bFind = pdfium::ContainsValue(*fields, pField); if (bIncludeOrExclude == bFind) { CPDF_Dictionary* pFieldDict = pField->m_pDict; - if ((dwFlags & 0x02) != 0 && pFieldDict->GetStringBy("V").IsEmpty()) + if ((dwFlags & 0x02) != 0 && pFieldDict->GetStringFor("V").IsEmpty()) return pField; } } @@ -1489,21 +1489,21 @@ CFDF_Document* CPDF_InterForm::ExportToFDF( if (!pDoc) return nullptr; - CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF"); + CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictFor("FDF"); if (!pdf_path.IsEmpty()) { if (bSimpleFileSpec) { CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path); - pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath)); - pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath)); + pMainDict->SetStringFor("F", CFX_ByteString::FromUnicode(wsFilePath)); + pMainDict->SetStringFor("UF", PDF_EncodeText(wsFilePath)); } else { CPDF_FileSpec filespec; filespec.SetFileName(pdf_path); - pMainDict->SetAt("F", filespec.GetObj()); + pMainDict->SetFor("F", filespec.GetObj()); } } CPDF_Array* pFields = new CPDF_Array; - pMainDict->SetAt("Fields", pFields); + pMainDict->SetFor("Fields", pFields); int nCount = m_pFieldTree->m_Root.CountFields(); for (int i = 0; i < nCount; i++) { CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); @@ -1515,25 +1515,25 @@ CFDF_Document* CPDF_InterForm::ExportToFDF( continue; if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField)) { - if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringBy("V").IsEmpty()) + if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringFor("V").IsEmpty()) continue; CFX_WideString fullname = FPDF_GetFullName(pField->GetFieldDict()); CPDF_Dictionary* pFieldDict = new CPDF_Dictionary; - pFieldDict->SetAt("T", new CPDF_String(fullname)); + pFieldDict->SetFor("T", new CPDF_String(fullname)); if (pField->GetType() == CPDF_FormField::CheckBox || pField->GetType() == CPDF_FormField::RadioButton) { CFX_WideString csExport = pField->GetCheckValue(FALSE); CFX_ByteString csBExport = PDF_EncodeText(csExport); CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); if (pOpt) - pFieldDict->SetAtString("V", csBExport); + pFieldDict->SetStringFor("V", csBExport); else - pFieldDict->SetAtName("V", csBExport); + pFieldDict->SetNameFor("V", csBExport); } else { CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); if (pV) - pFieldDict->SetAt("V", pV->CloneDirectObject()); + pFieldDict->SetFor("V", pV->CloneDirectObject()); } pFields->Add(pFieldDict); } @@ -1549,8 +1549,8 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, if (!parent_name.IsEmpty()) name = parent_name + L"."; - name += pFieldDict->GetUnicodeTextBy("T"); - CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); + name += pFieldDict->GetUnicodeTextFor("T"); + CPDF_Array* pKids = pFieldDict->GetArrayFor("Kids"); if (pKids) { for (size_t i = 0; i < pKids->GetCount(); i++) { CPDF_Dictionary* pKid = pKids->GetDictAt(i); @@ -1585,8 +1585,8 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, CPDF_FormField::Type eType = pField->GetType(); if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && pFieldDict->KeyExist("Opt")) { - pField->m_pDict->SetAt( - "Opt", pFieldDict->GetDirectObjectBy("Opt")->CloneDirectObject()); + pField->m_pDict->SetFor( + "Opt", pFieldDict->GetDirectObjectFor("Opt")->CloneDirectObject()); } if (bNotify && m_pFormNotify) { @@ -1604,15 +1604,15 @@ FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, if (!pFDF) return FALSE; - CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictBy("FDF"); + CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF"); if (!pMainDict) return FALSE; - CPDF_Array* pFields = pMainDict->GetArrayBy("Fields"); + CPDF_Array* pFields = pMainDict->GetArrayFor("Fields"); if (!pFields) return FALSE; - m_bsEncoding = pMainDict->GetStringBy("Encoding"); + m_bsEncoding = pMainDict->GetStringFor("Encoding"); if (bNotify && m_pFormNotify && m_pFormNotify->BeforeFormImportData(this) < 0) return FALSE; diff --git a/core/fpdfdoc/cpdf_link.cpp b/core/fpdfdoc/cpdf_link.cpp index 4859881198..b92b3cf45f 100644 --- a/core/fpdfdoc/cpdf_link.cpp +++ b/core/fpdfdoc/cpdf_link.cpp @@ -10,11 +10,11 @@ #include "core/fpdfdoc/include/cpdf_nametree.h" CFX_FloatRect CPDF_Link::GetRect() { - return m_pDict->GetRectBy("Rect"); + return m_pDict->GetRectFor("Rect"); } CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) { - CPDF_Object* pDest = m_pDict->GetDirectObjectBy("Dest"); + CPDF_Object* pDest = m_pDict->GetDirectObjectFor("Dest"); if (!pDest) return CPDF_Dest(); @@ -28,5 +28,5 @@ CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) { } CPDF_Action CPDF_Link::GetAction() { - return CPDF_Action(m_pDict->GetDictBy("A")); + return CPDF_Action(m_pDict->GetDictFor("A")); } diff --git a/core/fpdfdoc/cpdf_linklist.cpp b/core/fpdfdoc/cpdf_linklist.cpp index 5ef8f39da6..d9a10ef3e2 100644 --- a/core/fpdfdoc/cpdf_linklist.cpp +++ b/core/fpdfdoc/cpdf_linklist.cpp @@ -57,13 +57,13 @@ CPDF_Link CPDF_LinkList::GetLinkAtPoint(CPDF_Page* pPage, void CPDF_LinkList::LoadPageLinks(CPDF_Page* pPage, std::vector<CPDF_Dictionary*>* pList) { - CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots"); + CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayFor("Annots"); if (!pAnnotList) return; for (size_t i = 0; i < pAnnotList->GetCount(); ++i) { CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(i); - bool add_link = (pAnnot && pAnnot->GetStringBy("Subtype") == "Link"); + bool add_link = (pAnnot && pAnnot->GetStringFor("Subtype") == "Link"); // Add non-links as nullptrs to preserve z-order. pList->push_back(add_link ? pAnnot : nullptr); } diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp index b53da07652..ee6647f07f 100644 --- a/core/fpdfdoc/cpdf_metadata.cpp +++ b/core/fpdfdoc/cpdf_metadata.cpp @@ -16,7 +16,7 @@ CPDF_Metadata::CPDF_Metadata(CPDF_Document* pDoc) { if (!pRoot) return; - CPDF_Stream* pStream = pRoot->GetStreamBy("Metadata"); + CPDF_Stream* pStream = pRoot->GetStreamFor("Metadata"); if (!pStream) return; diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp index e046b6bf1a..a18ea217ae 100644 --- a/core/fpdfdoc/cpdf_nametree.cpp +++ b/core/fpdfdoc/cpdf_nametree.cpp @@ -22,7 +22,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, if (nLevel > nMaxRecursion) return nullptr; - CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); + CPDF_Array* pLimits = pNode->GetArrayFor("Limits"); if (pLimits) { CFX_ByteString csLeft = pLimits->GetStringAt(0); CFX_ByteString csRight = pLimits->GetStringAt(1); @@ -37,7 +37,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, } } - CPDF_Array* pNames = pNode->GetArrayBy("Names"); + CPDF_Array* pNames = pNode->GetArrayFor("Names"); if (pNames) { size_t dwCount = pNames->GetCount() / 2; for (size_t i = 0; i < dwCount; i++) { @@ -58,7 +58,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, return nullptr; } - CPDF_Array* pKids = pNode->GetArrayBy("Kids"); + CPDF_Array* pKids = pNode->GetArrayFor("Kids"); if (!pKids) return nullptr; @@ -84,7 +84,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, if (nLevel > nMaxRecursion) return nullptr; - CPDF_Array* pNames = pNode->GetArrayBy("Names"); + CPDF_Array* pNames = pNode->GetArrayFor("Names"); if (pNames) { size_t nCount = pNames->GetCount() / 2; if (nIndex >= nCurIndex + nCount) { @@ -96,7 +96,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, csName = pNames->GetStringAt((nIndex - nCurIndex) * 2); return pNames->GetDirectObjectAt((nIndex - nCurIndex) * 2 + 1); } - CPDF_Array* pKids = pNode->GetArrayBy("Kids"); + CPDF_Array* pKids = pNode->GetArrayFor("Kids"); if (!pKids) return nullptr; for (size_t i = 0; i < pKids->GetCount(); i++) { @@ -115,11 +115,11 @@ size_t CountNames(CPDF_Dictionary* pNode, int nLevel = 0) { if (nLevel > nMaxRecursion) return 0; - CPDF_Array* pNames = pNode->GetArrayBy("Names"); + CPDF_Array* pNames = pNode->GetArrayFor("Names"); if (pNames) return pNames->GetCount() / 2; - CPDF_Array* pKids = pNode->GetArrayBy("Kids"); + CPDF_Array* pKids = pNode->GetArrayFor("Kids"); if (!pKids) return 0; @@ -143,11 +143,11 @@ CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc, if (!pRoot) return; - CPDF_Dictionary* pNames = pRoot->GetDictBy("Names"); + CPDF_Dictionary* pNames = pRoot->GetDictFor("Names"); if (!pNames) return; - m_pRoot = pNames->GetDictBy(category); + m_pRoot = pNames->GetDictFor(category); } size_t CPDF_NameTree::GetCount() const { @@ -183,16 +183,16 @@ CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName) { CPDF_Object* pValue = LookupValue(sName); if (!pValue) { - CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests"); + CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictFor("Dests"); if (!pDests) return nullptr; - pValue = pDests->GetDirectObjectBy(sName); + pValue = pDests->GetDirectObjectFor(sName); } if (!pValue) return nullptr; if (CPDF_Array* pArray = pValue->AsArray()) return pArray; if (CPDF_Dictionary* pDict = pValue->AsDictionary()) - return pDict->GetArrayBy("D"); + return pDict->GetArrayFor("D"); return nullptr; } diff --git a/core/fpdfdoc/cpdf_numbertree.cpp b/core/fpdfdoc/cpdf_numbertree.cpp index 9e2881f414..36d18c2d19 100644 --- a/core/fpdfdoc/cpdf_numbertree.cpp +++ b/core/fpdfdoc/cpdf_numbertree.cpp @@ -12,12 +12,12 @@ namespace { CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { - CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); + CPDF_Array* pLimits = pNode->GetArrayFor("Limits"); if (pLimits && (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { return nullptr; } - CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); + CPDF_Array* pNumbers = pNode->GetArrayFor("Nums"); if (pNumbers) { for (size_t i = 0; i < pNumbers->GetCount() / 2; i++) { int index = pNumbers->GetIntegerAt(i * 2); @@ -29,7 +29,7 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { return nullptr; } - CPDF_Array* pKids = pNode->GetArrayBy("Kids"); + CPDF_Array* pKids = pNode->GetArrayFor("Kids"); if (!pKids) return nullptr; diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp index e641286ff0..b04c2bdcbb 100644 --- a/core/fpdfdoc/cpdf_occontext.cpp +++ b/core/fpdfdoc/cpdf_occontext.cpp @@ -26,7 +26,7 @@ int32_t FindGroup(const CPDF_Array* pArray, const CPDF_Dictionary* pGroupDict) { bool HasIntent(const CPDF_Dictionary* pDict, const CFX_ByteStringC& csElement, const CFX_ByteStringC& csDef) { - CPDF_Object* pIntent = pDict->GetDirectObjectBy("Intent"); + CPDF_Object* pIntent = pDict->GetDirectObjectFor("Intent"); if (!pIntent) return csElement == csDef; @@ -46,19 +46,19 @@ bool HasIntent(const CPDF_Dictionary* pDict, CPDF_Dictionary* GetConfig(CPDF_Document* pDoc, const CPDF_Dictionary* pOCGDict) { ASSERT(pOCGDict); - CPDF_Dictionary* pOCProperties = pDoc->GetRoot()->GetDictBy("OCProperties"); + CPDF_Dictionary* pOCProperties = pDoc->GetRoot()->GetDictFor("OCProperties"); if (!pOCProperties) return nullptr; - CPDF_Array* pOCGs = pOCProperties->GetArrayBy("OCGs"); + CPDF_Array* pOCGs = pOCProperties->GetArrayFor("OCGs"); if (!pOCGs) return nullptr; if (FindGroup(pOCGs, pOCGDict) < 0) return nullptr; - CPDF_Dictionary* pConfig = pOCProperties->GetDictBy("D"); - CPDF_Array* pConfigs = pOCProperties->GetArrayBy("Configs"); + CPDF_Dictionary* pConfig = pOCProperties->GetDictFor("D"); + CPDF_Array* pConfigs = pOCProperties->GetArrayFor("Configs"); if (!pConfigs) return pConfig; @@ -105,18 +105,18 @@ bool CPDF_OCContext::LoadOCGStateFromConfig( if (!pConfig) return true; - bool bState = pConfig->GetStringBy("BaseState", "ON") != "OFF"; - CPDF_Array* pArray = pConfig->GetArrayBy("ON"); + bool bState = pConfig->GetStringFor("BaseState", "ON") != "OFF"; + CPDF_Array* pArray = pConfig->GetArrayFor("ON"); if (pArray) { if (FindGroup(pArray, pOCGDict) >= 0) bState = true; } - pArray = pConfig->GetArrayBy("OFF"); + pArray = pConfig->GetArrayFor("OFF"); if (pArray) { if (FindGroup(pArray, pOCGDict) >= 0) bState = false; } - pArray = pConfig->GetArrayBy("AS"); + pArray = pConfig->GetArrayFor("AS"); if (!pArray) return bState; @@ -126,21 +126,21 @@ bool CPDF_OCContext::LoadOCGStateFromConfig( if (!pUsage) continue; - if (pUsage->GetStringBy("Event", "View") != csConfig) + if (pUsage->GetStringFor("Event", "View") != csConfig) continue; - CPDF_Array* pOCGs = pUsage->GetArrayBy("OCGs"); + CPDF_Array* pOCGs = pUsage->GetArrayFor("OCGs"); if (!pOCGs) continue; if (FindGroup(pOCGs, pOCGDict) < 0) continue; - CPDF_Dictionary* pState = pUsage->GetDictBy(csConfig); + CPDF_Dictionary* pState = pUsage->GetDictFor(csConfig); if (!pState) continue; - bState = pState->GetStringBy(csFind) != "OFF"; + bState = pState->GetStringFor(csFind) != "OFF"; } return bState; } @@ -150,18 +150,18 @@ bool CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const { return true; CFX_ByteString csState = GetUsageTypeString(m_eUsageType); - CPDF_Dictionary* pUsage = pOCGDict->GetDictBy("Usage"); + CPDF_Dictionary* pUsage = pOCGDict->GetDictFor("Usage"); if (pUsage) { - CPDF_Dictionary* pState = pUsage->GetDictBy(csState); + CPDF_Dictionary* pState = pUsage->GetDictFor(csState); if (pState) { CFX_ByteString csFind = csState + "State"; if (pState->KeyExist(csFind)) - return pState->GetStringBy(csFind) != "OFF"; + return pState->GetStringFor(csFind) != "OFF"; } if (csState != "View") { - pState = pUsage->GetDictBy("View"); + pState = pUsage->GetDictFor("View"); if (pState && pState->KeyExist("ViewState")) - return pState->GetStringBy("ViewState") != "OFF"; + return pState->GetStringFor("ViewState") != "OFF"; } } return LoadOCGStateFromConfig(csState, pOCGDict); @@ -237,12 +237,12 @@ bool CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, int nLevel) { } bool CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict) { - CPDF_Array* pVE = pOCMDDict->GetArrayBy("VE"); + CPDF_Array* pVE = pOCMDDict->GetArrayFor("VE"); if (pVE) return GetOCGVE(pVE, 0); - CFX_ByteString csP = pOCMDDict->GetStringBy("P", "AnyOn"); - CPDF_Object* pOCGObj = pOCMDDict->GetDirectObjectBy("OCGs"); + CFX_ByteString csP = pOCMDDict->GetStringFor("P", "AnyOn"); + CPDF_Object* pOCGObj = pOCMDDict->GetDirectObjectFor("OCGs"); if (!pOCGObj) return true; @@ -272,7 +272,7 @@ bool CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary* pOCGDict) { if (!pOCGDict) return true; - CFX_ByteString csType = pOCGDict->GetStringBy("Type", "OCG"); + CFX_ByteString csType = pOCGDict->GetStringFor("Type", "OCG"); if (csType == "OCG") return GetOCGVisible(pOCGDict); return LoadOCMDState(pOCGDict); diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp index 4b888b9a61..2f02e84bf3 100644 --- a/core/fpdfdoc/cpdf_pagelabel.cpp +++ b/core/fpdfdoc/cpdf_pagelabel.cpp @@ -84,7 +84,7 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { if (!pPDFRoot) return wsLabel; - CPDF_Dictionary* pLabels = pPDFRoot->GetDictBy("PageLabels"); + CPDF_Dictionary* pLabels = pPDFRoot->GetDictFor("PageLabels"); CPDF_NumberTree numberTree(pLabels); CPDF_Object* pValue = nullptr; int n = nPage; @@ -99,10 +99,10 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { pValue = pValue->GetDirect(); if (CPDF_Dictionary* pLabel = pValue->AsDictionary()) { if (pLabel->KeyExist("P")) - wsLabel += pLabel->GetUnicodeTextBy("P"); + wsLabel += pLabel->GetUnicodeTextFor("P"); - CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", ""); - int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1); + CFX_ByteString bsNumberingStyle = pLabel->GetStringFor("S", ""); + int nLabelNum = nPage - n + pLabel->GetIntegerFor("St", 1); CFX_WideString wsNumPortion = GetLabelNumPortion(nLabelNum, bsNumberingStyle); wsLabel += wsNumPortion; diff --git a/core/fpdfdoc/cpdf_viewerpreferences.cpp b/core/fpdfdoc/cpdf_viewerpreferences.cpp index 4951e5ff5d..0dc55aad74 100644 --- a/core/fpdfdoc/cpdf_viewerpreferences.cpp +++ b/core/fpdfdoc/cpdf_viewerpreferences.cpp @@ -15,30 +15,30 @@ CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {} FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const { CPDF_Dictionary* pDict = GetViewerPreferences(); - return pDict ? pDict->GetStringBy("Direction") == "R2L" : FALSE; + return pDict ? pDict->GetStringFor("Direction") == "R2L" : FALSE; } FX_BOOL CPDF_ViewerPreferences::PrintScaling() const { CPDF_Dictionary* pDict = GetViewerPreferences(); - return pDict ? pDict->GetStringBy("PrintScaling") != "None" : TRUE; + return pDict ? pDict->GetStringFor("PrintScaling") != "None" : TRUE; } int32_t CPDF_ViewerPreferences::NumCopies() const { CPDF_Dictionary* pDict = GetViewerPreferences(); - return pDict ? pDict->GetIntegerBy("NumCopies") : 1; + return pDict ? pDict->GetIntegerFor("NumCopies") : 1; } CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const { CPDF_Dictionary* pDict = GetViewerPreferences(); - return pDict ? pDict->GetArrayBy("PrintPageRange") : nullptr; + return pDict ? pDict->GetArrayFor("PrintPageRange") : nullptr; } CFX_ByteString CPDF_ViewerPreferences::Duplex() const { CPDF_Dictionary* pDict = GetViewerPreferences(); - return pDict ? pDict->GetStringBy("Duplex") : CFX_ByteString("None"); + return pDict ? pDict->GetStringFor("Duplex") : CFX_ByteString("None"); } CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const { CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - return pDict ? pDict->GetDictBy("ViewerPreferences") : nullptr; + return pDict ? pDict->GetDictFor("ViewerPreferences") : nullptr; } diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index ea4aad96d3..7eff694d81 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -32,14 +32,14 @@ void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, return; CFX_ByteString sFontAlias; - CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictBy("AcroForm"); + CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictFor("AcroForm"); CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias); if (!pPDFFont) return; - if (CPDF_Dictionary* pFontList = pResDict->GetDictBy("Font")) { + if (CPDF_Dictionary* pFontList = pResDict->GetDictFor("Font")) { if (!pFontList->KeyExist(sSysFontAlias)) - pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->GetFontDict()); + pFontList->SetReferenceFor(sSysFontAlias, pDoc, pPDFFont->GetFontDict()); } pSysFont = pPDFFont; } diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index dbfcdbffed..decc408c33 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -25,7 +25,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, const int32_t& nWidgetType) { CPDF_Dictionary* pFormDict = nullptr; if (CPDF_Dictionary* pRootDict = pDoc->GetRoot()) - pFormDict = pRootDict->GetDictBy("AcroForm"); + pFormDict = pRootDict->GetDictFor("AcroForm"); if (!pFormDict) return false; @@ -33,7 +33,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) DA = pDAObj->GetString(); if (DA.IsEmpty()) - DA = pFormDict->GetStringBy("DA"); + DA = pFormDict->GetStringFor("DA"); if (DA.IsEmpty()) return false; @@ -46,32 +46,32 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, FX_FLOAT fFontSize = FX_atof(syntax.GetWord()); CPVT_Color crText = CPVT_Color::ParseColor(DA); - CPDF_Dictionary* pDRDict = pFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDRDict = pFormDict->GetDictFor("DR"); if (!pDRDict) return false; - CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"); + CPDF_Dictionary* pDRFontDict = pDRDict->GetDictFor("Font"); if (!pDRFontDict) return false; - CPDF_Dictionary* pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1)); + CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(sFontName.Mid(1)); if (!pFontDict) { pFontDict = new CPDF_Dictionary; - pFontDict->SetAtName("Type", "Font"); - pFontDict->SetAtName("Subtype", "Type1"); - pFontDict->SetAtName("BaseFont", "Helvetica"); - pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); + pFontDict->SetNameFor("Type", "Font"); + pFontDict->SetNameFor("Subtype", "Type1"); + pFontDict->SetNameFor("BaseFont", "Helvetica"); + pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); pDoc->AddIndirectObject(pFontDict); - pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); + pDRFontDict->SetReferenceFor(sFontName.Mid(1), pDoc, pFontDict); } CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); if (!pDefFont) return false; - CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rcAnnot = pAnnotDict->GetRectFor("Rect"); int32_t nRotate = 0; - if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) - nRotate = pMKDict->GetIntegerBy("R"); + if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictFor("MK")) + nRotate = pMKDict->GetIntegerFor("R"); CFX_FloatRect rcBBox; CFX_Matrix matrix; @@ -102,15 +102,15 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, FX_FLOAT fBorderWidth = 1; CPVT_Dash dsBorder(3, 0, 0); CPVT_Color crLeftTop, crRightBottom; - if (CPDF_Dictionary* pBSDict = pAnnotDict->GetDictBy("BS")) { + if (CPDF_Dictionary* pBSDict = pAnnotDict->GetDictFor("BS")) { if (pBSDict->KeyExist("W")) - fBorderWidth = pBSDict->GetNumberBy("W"); + fBorderWidth = pBSDict->GetNumberFor("W"); - if (CPDF_Array* pArray = pBSDict->GetArrayBy("D")) { + if (CPDF_Array* pArray = pBSDict->GetArrayFor("D")) { dsBorder = CPVT_Dash(pArray->GetIntegerAt(0), pArray->GetIntegerAt(1), pArray->GetIntegerAt(2)); } - switch (pBSDict->GetStringBy("S").GetAt(0)) { + switch (pBSDict->GetStringFor("S").GetAt(0)) { case 'S': nBorderStyle = BorderStyle::SOLID; break; @@ -135,10 +135,10 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, } } CPVT_Color crBorder, crBG; - if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) { - if (CPDF_Array* pArray = pMKDict->GetArrayBy("BC")) + if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictFor("MK")) { + if (CPDF_Array* pArray = pMKDict->GetArrayFor("BC")) crBorder = CPVT_Color::ParseColor(*pArray); - if (CPDF_Array* pArray = pMKDict->GetArrayBy("BG")) + if (CPDF_Array* pArray = pMKDict->GetArrayFor("BG")) crBG = CPVT_Color::ParseColor(*pArray); } CFX_ByteTextBuf sAppStream; @@ -159,33 +159,33 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, CFX_FloatRect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); rcBody.Normalize(); - CPDF_Dictionary* pAPDict = pAnnotDict->GetDictBy("AP"); + CPDF_Dictionary* pAPDict = pAnnotDict->GetDictFor("AP"); if (!pAPDict) { pAPDict = new CPDF_Dictionary; - pAnnotDict->SetAt("AP", pAPDict); + pAnnotDict->SetFor("AP", pAPDict); } - CPDF_Stream* pNormalStream = pAPDict->GetStreamBy("N"); + CPDF_Stream* pNormalStream = pAPDict->GetStreamFor("N"); if (!pNormalStream) { pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); int32_t objnum = pDoc->AddIndirectObject(pNormalStream); - pAnnotDict->GetDictBy("AP")->SetAtReference("N", pDoc, objnum); + pAnnotDict->GetDictFor("AP")->SetReferenceFor("N", pDoc, objnum); } CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); if (pStreamDict) { - pStreamDict->SetAtMatrix("Matrix", matrix); - pStreamDict->SetAtRect("BBox", rcBBox); - CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); + pStreamDict->SetMatrixFor("Matrix", matrix); + pStreamDict->SetRectFor("BBox", rcBBox); + CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); if (pStreamResList) { - CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); + CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); if (!pStreamResFontList) { pStreamResFontList = new CPDF_Dictionary; - pStreamResList->SetAt("Font", pStreamResFontList); + pStreamResList->SetFor("Font", pStreamResFontList); } if (!pStreamResFontList->KeyExist(sFontName)) - pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); + pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict); } else { - pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); - pStreamResList = pStreamDict->GetDictBy("Resources"); + pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone()); + pStreamResList = pStreamDict->GetDictFor("Resources"); } } switch (nWidgetType) { @@ -205,7 +205,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, ? FPDF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger() : 0; CPVT_FontMap map( - pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr, + pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr, pDefFont, sFontName.Right(sFontName.GetLength() - 1)); CPDF_VariableText::Provider prd(&map); CPDF_VariableText vt; @@ -266,7 +266,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString(); CPVT_FontMap map( - pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr, + pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr, pDefFont, sFontName.Right(sFontName.GetLength() - 1)); CPDF_VariableText::Provider prd(&map); CPDF_VariableText vt; @@ -336,7 +336,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, } break; case 2: { CPVT_FontMap map( - pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr, + pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr, pDefFont, sFontName.Right(sFontName.GetLength() - 1)); CPDF_VariableText::Provider prd(&map); CPDF_Array* pOpts = ToArray(FPDF_GetFieldAttr(pAnnotDict, "Opt")); @@ -422,20 +422,21 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, FALSE); pStreamDict = pNormalStream->GetDict(); if (pStreamDict) { - pStreamDict->SetAtMatrix("Matrix", matrix); - pStreamDict->SetAtRect("BBox", rcBBox); - CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); + pStreamDict->SetMatrixFor("Matrix", matrix); + pStreamDict->SetRectFor("BBox", rcBBox); + CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); if (pStreamResList) { - CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); + CPDF_Dictionary* pStreamResFontList = + pStreamResList->GetDictFor("Font"); if (!pStreamResFontList) { pStreamResFontList = new CPDF_Dictionary; - pStreamResList->SetAt("Font", pStreamResFontList); + pStreamResList->SetFor("Font", pStreamResFontList); } if (!pStreamResFontList->KeyExist(sFontName)) - pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); + pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict); } else { - pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); - pStreamResList = pStreamDict->GetDictBy("Resources"); + pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone()); + pStreamResList = pStreamDict->GetDictFor("Resources"); } } } @@ -454,12 +455,12 @@ CFX_ByteString GetColorStringWithDefault(CPDF_Array* pColor, } FX_FLOAT GetBorderWidth(const CPDF_Dictionary& pAnnotDict) { - if (CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictBy("BS")) { + if (CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictFor("BS")) { if (pBorderStyleDict->KeyExist("W")) - return pBorderStyleDict->GetNumberBy("W"); + return pBorderStyleDict->GetNumberFor("W"); } - if (CPDF_Array* pBorderArray = pAnnotDict.GetArrayBy("Border")) { + if (CPDF_Array* pBorderArray = pAnnotDict.GetArrayFor("Border")) { if (pBorderArray->GetCount() > 2) return pBorderArray->GetNumberAt(2); } @@ -468,12 +469,12 @@ FX_FLOAT GetBorderWidth(const CPDF_Dictionary& pAnnotDict) { } CPDF_Array* GetDashArray(const CPDF_Dictionary& pAnnotDict) { - if (CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictBy("BS")) { - if (pBorderStyleDict->GetStringBy("S") == "D") - return pBorderStyleDict->GetArrayBy("D"); + if (CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictFor("BS")) { + if (pBorderStyleDict->GetStringFor("S") == "D") + return pBorderStyleDict->GetArrayFor("D"); } - if (CPDF_Array* pBorderArray = pAnnotDict.GetArrayBy("Border")) { + if (CPDF_Array* pBorderArray = pAnnotDict.GetArrayFor("Border")) { if (pBorderArray->GetCount() == 4) return pBorderArray->GetArrayAt(3); } @@ -502,15 +503,15 @@ CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc, const CPDF_Dictionary& pAnnotDict, CPDF_Font* pDefFont, const CFX_ByteString& sFontName) { - CFX_WideString swValue(pAnnotDict.GetUnicodeTextBy("T")); + CFX_WideString swValue(pAnnotDict.GetUnicodeTextFor("T")); swValue += L'\n'; - swValue += pAnnotDict.GetUnicodeTextBy("Contents"); + swValue += pAnnotDict.GetUnicodeTextFor("Contents"); CPVT_FontMap map(pDoc, nullptr, pDefFont, sFontName); CPDF_VariableText::Provider prd(&map); CPDF_VariableText vt; vt.SetProvider(&prd); - vt.SetPlateRect(pAnnotDict.GetRectBy("Rect")); + vt.SetPlateRect(pAnnotDict.GetRectFor("Rect")); vt.SetFontSize(12); vt.SetAutoReturn(TRUE); vt.SetMultiLine(TRUE); @@ -538,17 +539,17 @@ CPDF_Dictionary* GenerateExtGStateDict(const CPDF_Dictionary& pAnnotDict, const CFX_ByteString& sExtGSDictName, const CFX_ByteString& sBlendMode) { CPDF_Dictionary* pGSDict = new CPDF_Dictionary; - pGSDict->SetAtString("Type", "ExtGState"); + pGSDict->SetStringFor("Type", "ExtGState"); FX_FLOAT fOpacity = - pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberBy("CA") : 1; - pGSDict->SetAtNumber("CA", fOpacity); - pGSDict->SetAtNumber("ca", fOpacity); - pGSDict->SetAtBoolean("AIS", false); - pGSDict->SetAtString("BM", sBlendMode); + pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberFor("CA") : 1; + pGSDict->SetNumberFor("CA", fOpacity); + pGSDict->SetNumberFor("ca", fOpacity); + pGSDict->SetBooleanFor("AIS", false); + pGSDict->SetStringFor("BM", sBlendMode); CPDF_Dictionary* pExtGStateDict = new CPDF_Dictionary; - pExtGStateDict->SetAt(sExtGSDictName, pGSDict); + pExtGStateDict->SetFor(sExtGSDictName, pGSDict); return pExtGStateDict; } @@ -556,14 +557,14 @@ CPDF_Dictionary* GenerateExtGStateDict(const CPDF_Dictionary& pAnnotDict, CPDF_Dictionary* GenerateResourceFontDict(CPDF_Document* pDoc, const CFX_ByteString& sFontDictName) { CPDF_Dictionary* pFontDict = new CPDF_Dictionary; - pFontDict->SetAtName("Type", "Font"); - pFontDict->SetAtName("Subtype", "Type1"); - pFontDict->SetAtName("BaseFont", "Helvetica"); - pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); + pFontDict->SetNameFor("Type", "Font"); + pFontDict->SetNameFor("Subtype", "Type1"); + pFontDict->SetNameFor("BaseFont", "Helvetica"); + pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); pDoc->AddIndirectObject(pFontDict); CPDF_Dictionary* pResourceFontDict = new CPDF_Dictionary; - pResourceFontDict->SetAtReference(sFontDictName, pDoc, pFontDict); + pResourceFontDict->SetReferenceFor(sFontDictName, pDoc, pFontDict); return pResourceFontDict; } @@ -573,10 +574,10 @@ CPDF_Dictionary* GenerateResourceDict(CPDF_Dictionary* pExtGStateDict, CPDF_Dictionary* pResourceFontDict) { CPDF_Dictionary* pResourceDict = new CPDF_Dictionary; if (pExtGStateDict) - pResourceDict->SetAt("ExtGState", pExtGStateDict); + pResourceDict->SetFor("ExtGState", pExtGStateDict); if (pResourceFontDict) - pResourceDict->SetAt("Font", pResourceFontDict); + pResourceDict->SetFor("Font", pResourceFontDict); return pResourceDict; } @@ -587,24 +588,24 @@ void GenerateAndSetAPDict(CPDF_Document* pDoc, const CFX_ByteTextBuf& sAppStream, CPDF_Dictionary* pResourceDict) { CPDF_Dictionary* pAPDict = new CPDF_Dictionary; - pAnnotDict->SetAt("AP", pAPDict); + pAnnotDict->SetFor("AP", pAPDict); CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); int32_t objnum = pDoc->AddIndirectObject(pNormalStream); - pAnnotDict->GetDictBy("AP")->SetAtReference("N", pDoc, objnum); + pAnnotDict->GetDictFor("AP")->SetReferenceFor("N", pDoc, objnum); pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE, FALSE); CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); - pStreamDict->SetAtInteger("FormType", 1); - pStreamDict->SetAtString("Subtype", "Form"); - pStreamDict->SetAtMatrix("Matrix", CFX_Matrix()); + pStreamDict->SetIntegerFor("FormType", 1); + pStreamDict->SetStringFor("Subtype", "Form"); + pStreamDict->SetMatrixFor("Matrix", CFX_Matrix()); - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); - pStreamDict->SetAtRect("BBox", rect); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); + pStreamDict->SetRectFor("BBox", rect); - pStreamDict->SetAt("Resources", pResourceDict); + pStreamDict->SetFor("Resources", pResourceDict); } CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { @@ -666,7 +667,7 @@ CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { } // namespace bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - if (!pAnnotDict || pAnnotDict->GetStringBy("Subtype") != "Widget") + if (!pAnnotDict || pAnnotDict->GetStringFor("Subtype") != "Widget") return false; CFX_ByteString field_type = FPDF_GetFieldAttr(pAnnotDict, "FT")->GetString(); @@ -684,9 +685,9 @@ bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { if (field_type == "Btn") { if (!(flags & (1 << 16))) { if (!pAnnotDict->KeyExist("AS")) { - if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDictBy("Parent")) { + if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent")) { if (pParentDict->KeyExist("AS")) { - pAnnotDict->SetAtString("AS", pParentDict->GetStringBy("AS")); + pAnnotDict->SetStringFor("AS", pParentDict->GetStringFor("AS")); } } } @@ -719,12 +720,12 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC"); + CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC"); sAppStream << GetColorStringWithDefault(pInteriorColor, CPVT_Color(CPVT_Color::kTransparent), PaintOperation::FILL); - sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), + sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); @@ -736,7 +737,7 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, sAppStream << GetDashPatternString(*pAnnotDict); } - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Normalize(); if (bIsStrokeRect) { @@ -792,11 +793,11 @@ bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), + sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), PaintOperation::FILL); - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Normalize(); sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " @@ -821,7 +822,7 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, if (!bIsStroke) return false; - CPDF_Array* pInkList = pAnnotDict->GetArrayBy("InkList"); + CPDF_Array* pInkList = pAnnotDict->GetArrayFor("InkList"); if (!pInkList || pInkList->IsEmpty()) return false; @@ -829,7 +830,7 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), + sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); @@ -838,9 +839,9 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, // Set inflated rect as a new rect because paths near the border with large // width should not be clipped to the original rect. - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Inflate(fBorderWidth / 2, fBorderWidth / 2); - pAnnotDict->SetAtRect("Rect", rect); + pAnnotDict->SetRectFor("Rect", rect); for (size_t i = 0; i < pInkList->GetCount(); i++) { CPDF_Array* pInkCoordList = pInkList->GetArrayAt(i); @@ -872,11 +873,11 @@ bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); const FX_FLOAT fNoteLength = 20; CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength, rect.bottom + fNoteLength); - pAnnotDict->SetAtRect("Rect", noteRect); + pAnnotDict->SetRectFor("Rect", noteRect); sAppStream << GenerateTextSymbolAP(noteRect); @@ -894,11 +895,11 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), + sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Normalize(); FX_FLOAT fLineWidth = 1.0; @@ -928,7 +929,7 @@ bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, const FX_FLOAT fBorderWidth = 1; sAppStream << fBorderWidth << " w\n"; - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Normalize(); rect.Deflate(fBorderWidth / 2, fBorderWidth / 2); @@ -958,12 +959,12 @@ bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC"); + CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC"); sAppStream << GetColorStringWithDefault(pInteriorColor, CPVT_Color(CPVT_Color::kTransparent), PaintOperation::FILL); - sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), + sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); @@ -975,7 +976,7 @@ bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, sAppStream << GetDashPatternString(*pAnnotDict); } - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Normalize(); if (bIsStrokeRect) { @@ -1005,11 +1006,11 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), + sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Normalize(); FX_FLOAT fLineWidth = 1.0; @@ -1053,11 +1054,11 @@ bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, CFX_ByteString sExtGSDictName = "GS"; sAppStream << "/" << sExtGSDictName << " gs "; - sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), + sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"), CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); rect.Normalize(); FX_FLOAT fLineWidth = 1.0; diff --git a/core/fpdfdoc/doc_tagged.cpp b/core/fpdfdoc/doc_tagged.cpp index 80a296af60..6b60e97e9a 100644 --- a/core/fpdfdoc/doc_tagged.cpp +++ b/core/fpdfdoc/doc_tagged.cpp @@ -21,8 +21,8 @@ const int nMaxRecursion = 32; bool IsTagged(const CPDF_Document* pDoc) { CPDF_Dictionary* pCatalog = pDoc->GetRoot(); - CPDF_Dictionary* pMarkInfo = pCatalog->GetDictBy("MarkInfo"); - return pMarkInfo && pMarkInfo->GetIntegerBy("Marked"); + CPDF_Dictionary* pMarkInfo = pCatalog->GetDictFor("MarkInfo"); + return pMarkInfo && pMarkInfo->GetIntegerFor("Marked"); } } // namespace @@ -49,8 +49,8 @@ IPDF_StructTree* IPDF_StructTree::LoadDoc(const CPDF_Document* pDoc) { } CPDF_StructTreeImpl::CPDF_StructTreeImpl(const CPDF_Document* pDoc) - : m_pTreeRoot(pDoc->GetRoot()->GetDictBy("StructTreeRoot")), - m_pRoleMap(m_pTreeRoot ? m_pTreeRoot->GetDictBy("RoleMap") : nullptr), + : m_pTreeRoot(pDoc->GetRoot()->GetDictFor("StructTreeRoot")), + m_pRoleMap(m_pTreeRoot ? m_pTreeRoot->GetDictFor("RoleMap") : nullptr), m_pPage(nullptr) {} CPDF_StructTreeImpl::~CPDF_StructTreeImpl() {} @@ -68,7 +68,7 @@ void CPDF_StructTreeImpl::LoadDocTree() { if (!m_pTreeRoot) return; - CPDF_Object* pKids = m_pTreeRoot->GetDirectObjectBy("K"); + CPDF_Object* pKids = m_pTreeRoot->GetDirectObjectFor("K"); if (!pKids) return; @@ -93,7 +93,7 @@ void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict) { if (!m_pTreeRoot) return; - CPDF_Object* pKids = m_pTreeRoot->GetDirectObjectBy("K"); + CPDF_Object* pKids = m_pTreeRoot->GetDirectObjectFor("K"); if (!pKids) return; @@ -107,12 +107,12 @@ void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict) { m_Kids.clear(); m_Kids.resize(dwKids); - CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDictBy("ParentTree"); + CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDictFor("ParentTree"); if (!pParentTree) return; CPDF_NumberTree parent_tree(pParentTree); - int parents_id = pPageDict->GetIntegerBy("StructParents", -1); + int parents_id = pPageDict->GetIntegerFor("StructParents", -1); if (parents_id < 0) return; @@ -141,8 +141,8 @@ CPDF_StructElementImpl* CPDF_StructTreeImpl::AddPageNode( CPDF_StructElementImpl* pElement = new CPDF_StructElementImpl(this, nullptr, pDict); map[pDict] = pElement; - CPDF_Dictionary* pParent = pDict->GetDictBy("P"); - if (!pParent || pParent->GetStringBy("Type") == "StructTreeRoot") { + CPDF_Dictionary* pParent = pDict->GetDictFor("P"); + if (!pParent || pParent->GetStringFor("Type") == "StructTreeRoot") { if (!AddTopLevelNode(pDict, pElement)) { pElement->Release(); map.erase(pDict); @@ -168,7 +168,7 @@ CPDF_StructElementImpl* CPDF_StructTreeImpl::AddPageNode( } FX_BOOL CPDF_StructTreeImpl::AddTopLevelNode(CPDF_Dictionary* pDict, CPDF_StructElementImpl* pElement) { - CPDF_Object* pObj = m_pTreeRoot->GetDirectObjectBy("K"); + CPDF_Object* pObj = m_pTreeRoot->GetDirectObjectFor("K"); if (!pObj) return FALSE; @@ -199,9 +199,9 @@ CPDF_StructElementImpl::CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, m_pTree(pTree), m_pParent(pParent), m_pDict(pDict), - m_Type(pDict->GetStringBy("S")) { + m_Type(pDict->GetStringFor("S")) { if (pTree->m_pRoleMap) { - CFX_ByteString mapped = pTree->m_pRoleMap->GetStringBy(m_Type); + CFX_ByteString mapped = pTree->m_pRoleMap->GetStringFor(m_Type); if (!mapped.IsEmpty()) m_Type = mapped; } @@ -249,12 +249,12 @@ void CPDF_StructElementImpl::Release() { } } void CPDF_StructElementImpl::LoadKids(CPDF_Dictionary* pDict) { - CPDF_Object* pObj = pDict->GetObjectBy("Pg"); + CPDF_Object* pObj = pDict->GetObjectFor("Pg"); uint32_t PageObjNum = 0; if (CPDF_Reference* pRef = ToReference(pObj)) PageObjNum = pRef->GetRefObjNum(); - CPDF_Object* pKids = pDict->GetDirectObjectBy("K"); + CPDF_Object* pKids = pDict->GetDirectObjectFor("K"); if (!pKids) return; @@ -291,28 +291,28 @@ void CPDF_StructElementImpl::LoadKid(uint32_t PageObjNum, if (!pKidDict) return; - if (CPDF_Reference* pRef = ToReference(pKidDict->GetObjectBy("Pg"))) + if (CPDF_Reference* pRef = ToReference(pKidDict->GetObjectFor("Pg"))) PageObjNum = pRef->GetRefObjNum(); - CFX_ByteString type = pKidDict->GetStringBy("Type"); + CFX_ByteString type = pKidDict->GetStringFor("Type"); if (type == "MCR") { if (m_pTree->m_pPage && m_pTree->m_pPage->GetObjNum() != PageObjNum) { return; } pKid->m_Type = CPDF_StructKid::StreamContent; - if (CPDF_Reference* pRef = ToReference(pKidDict->GetObjectBy("Stm"))) { + if (CPDF_Reference* pRef = ToReference(pKidDict->GetObjectFor("Stm"))) { pKid->m_StreamContent.m_RefObjNum = pRef->GetRefObjNum(); } else { pKid->m_StreamContent.m_RefObjNum = 0; } pKid->m_StreamContent.m_PageObjNum = PageObjNum; - pKid->m_StreamContent.m_ContentId = pKidDict->GetIntegerBy("MCID"); + pKid->m_StreamContent.m_ContentId = pKidDict->GetIntegerFor("MCID"); } else if (type == "OBJR") { if (m_pTree->m_pPage && m_pTree->m_pPage->GetObjNum() != PageObjNum) { return; } pKid->m_Type = CPDF_StructKid::Object; - if (CPDF_Reference* pObj = ToReference(pKidDict->GetObjectBy("Obj"))) { + if (CPDF_Reference* pObj = ToReference(pKidDict->GetObjectFor("Obj"))) { pKid->m_Object.m_RefObjNum = pObj->GetRefObjNum(); } else { pKid->m_Object.m_RefObjNum = 0; @@ -350,7 +350,7 @@ static CPDF_Dictionary* FindAttrDict(CPDF_Object* pAttrs, return pDict; } } - if (pDict && pDict->GetStringBy("O") == owner) + if (pDict && pDict->GetStringFor("O") == owner) return pDict; return nullptr; } @@ -371,37 +371,37 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, } return m_pParent->GetAttr(owner, name, TRUE, fLevel + 1); } - CPDF_Object* pA = m_pDict->GetDirectObjectBy("A"); + CPDF_Object* pA = m_pDict->GetDirectObjectFor("A"); if (pA) { CPDF_Dictionary* pAttrDict = FindAttrDict(pA, owner); if (pAttrDict) { - CPDF_Object* pAttr = pAttrDict->GetDirectObjectBy(CFX_ByteString(name)); + CPDF_Object* pAttr = pAttrDict->GetDirectObjectFor(CFX_ByteString(name)); if (pAttr) { return pAttr; } } } - CPDF_Object* pC = m_pDict->GetDirectObjectBy("C"); + CPDF_Object* pC = m_pDict->GetDirectObjectFor("C"); if (!pC) return nullptr; - CPDF_Dictionary* pClassMap = m_pTree->m_pTreeRoot->GetDictBy("ClassMap"); + CPDF_Dictionary* pClassMap = m_pTree->m_pTreeRoot->GetDictFor("ClassMap"); if (!pClassMap) return nullptr; if (CPDF_Array* pArray = pC->AsArray()) { for (uint32_t i = 0; i < pArray->GetCount(); i++) { CFX_ByteString class_name = pArray->GetStringAt(i); - CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); - if (pClassDict && pClassDict->GetStringBy("O") == owner) - return pClassDict->GetDirectObjectBy(CFX_ByteString(name)); + CPDF_Dictionary* pClassDict = pClassMap->GetDictFor(class_name); + if (pClassDict && pClassDict->GetStringFor("O") == owner) + return pClassDict->GetDirectObjectFor(CFX_ByteString(name)); } return nullptr; } CFX_ByteString class_name = pC->GetString(); - CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); - if (pClassDict && pClassDict->GetStringBy("O") == owner) - return pClassDict->GetDirectObjectBy(CFX_ByteString(name)); + CPDF_Dictionary* pClassDict = pClassMap->GetDictFor(class_name); + if (pClassDict && pClassDict->GetStringFor("O") == owner) + return pClassDict->GetDirectObjectFor(CFX_ByteString(name)); return nullptr; } CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, diff --git a/core/fpdfdoc/include/cpdf_action.h b/core/fpdfdoc/include/cpdf_action.h index 90e33015e7..0b095e4a66 100644 --- a/core/fpdfdoc/include/cpdf_action.h +++ b/core/fpdfdoc/include/cpdf_action.h @@ -45,9 +45,9 @@ class CPDF_Action { CPDF_Dest GetDest(CPDF_Document* pDoc) const; CFX_WideString GetFilePath() const; CFX_ByteString GetURI(CPDF_Document* pDoc) const; - bool GetHideStatus() const { return m_pDict->GetBooleanBy("H", true); } - CFX_ByteString GetNamedAction() const { return m_pDict->GetStringBy("N"); } - uint32_t GetFlags() const { return m_pDict->GetIntegerBy("Flags"); } + bool GetHideStatus() const { return m_pDict->GetBooleanFor("H", true); } + CFX_ByteString GetNamedAction() const { return m_pDict->GetStringFor("N"); } + uint32_t GetFlags() const { return m_pDict->GetIntegerFor("Flags"); } CFX_WideString GetJavaScript() const; size_t GetSubActionsCount() const; CPDF_Action GetSubAction(size_t iIndex) const; diff --git a/core/fpdfdoc/include/cpdf_formcontrol.h b/core/fpdfdoc/include/cpdf_formcontrol.h index cf246bd878..c73318f49e 100644 --- a/core/fpdfdoc/include/cpdf_formcontrol.h +++ b/core/fpdfdoc/include/cpdf_formcontrol.h @@ -50,7 +50,7 @@ class CPDF_FormControl { CPDF_InterForm* GetInterForm() const { return m_pForm; } CPDF_FormField* GetField() const { return m_pField; } CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } - CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectBy("Rect"); } + CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectFor("Rect"); } void DrawControl(CFX_RenderDevice* pDevice, CFX_Matrix* pMatrix, diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index cb60c452bf..c691d4b3a0 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -822,7 +822,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { continue; pDict = item.GetParam(); CPDF_String* temp = - ToString(pDict ? pDict->GetObjectBy("ActualText") : nullptr); + ToString(pDict ? pDict->GetObjectFor("ActualText") : nullptr); if (temp) { bExist = true; actText = temp->GetUnicodeText(); @@ -884,7 +884,7 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { continue; pDict = item.GetParam(); if (pDict) - actText = pDict->GetUnicodeTextBy("ActualText"); + actText = pDict->GetUnicodeTextFor("ActualText"); } FX_STRSIZE nItems = actText.GetLength(); if (nItems < 1) diff --git a/core/fxge/dib/fx_dib_engine_unittest.cpp b/core/fxge/dib/fx_dib_engine_unittest.cpp index d185adf49d..4b4063b7e5 100644 --- a/core/fxge/dib/fx_dib_engine_unittest.cpp +++ b/core/fxge/dib/fx_dib_engine_unittest.cpp @@ -17,8 +17,8 @@ TEST(CStretchEngine, OverflowInCtor) { FX_RECT clip_rect; std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> dict_obj( new CPDF_Dictionary); - dict_obj->SetAt("Width", new CPDF_Number(71000)); - dict_obj->SetAt("Height", new CPDF_Number(12500)); + dict_obj->SetFor("Width", new CPDF_Number(71000)); + dict_obj->SetFor("Height", new CPDF_Number(12500)); std::unique_ptr<CPDF_Stream, ReleaseDeleter<CPDF_Stream>> stream( new CPDF_Stream(nullptr, 0, dict_obj.release())); CPDF_DIBSource dib_source; diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index fd4f73972f..d2e4abce92 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -1231,7 +1231,7 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, if (nFuncs != 1) // TODO(caryclark) remove this restriction return false; CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict(); - CPDF_Array* pCoords = pDict->GetArrayBy("Coords"); + CPDF_Array* pCoords = pDict->GetArrayFor("Coords"); if (!pCoords) return true; // TODO(caryclark) Respect Domain[0], Domain[1]. (Don't know what they do @@ -1261,7 +1261,7 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, return false; } } - CPDF_Array* pArray = pDict->GetArrayBy("Extend"); + CPDF_Array* pArray = pDict->GetArrayFor("Extend"); bool clipStart = !pArray || !pArray->GetIntegerAt(0); bool clipEnd = !pArray || !pArray->GetIntegerAt(1); SkPaint paint; diff --git a/fpdfsdk/cba_annotiterator.cpp b/fpdfsdk/cba_annotiterator.cpp index 51ee54beca..feca9fc55b 100644 --- a/fpdfsdk/cba_annotiterator.cpp +++ b/fpdfsdk/cba_annotiterator.cpp @@ -28,7 +28,7 @@ CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, m_pPageView(pPageView), m_nAnnotSubtype(nAnnotSubtype) { CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); - CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetStringBy("Tabs"); + CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetStringFor("Tabs"); if (sTabs == "R") m_eTabOrder = ROW; else if (sTabs == "C") diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp index 443ee05bb6..f808b8412b 100644 --- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp +++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp @@ -63,8 +63,8 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); CPDFSDK_DateTime curTime; - pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); - pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); + pPDFAnnot->GetAnnotDict()->SetStringFor("M", curTime.ToPDFDateTimeString()); + pPDFAnnot->GetAnnotDict()->SetNumberFor("F", 0); GetAnnotHandler(pAnnot)->OnCreate(pAnnot); } diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 48daaf9d08..e023ae79f1 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -37,7 +37,7 @@ void CPDFSDK_BAAnnot::SetRect(const CFX_FloatRect& rect) { ASSERT(rect.right - rect.left >= GetMinWidth()); ASSERT(rect.top - rect.bottom >= GetMinHeight()); - m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect); + m_pAnnot->GetAnnotDict()->SetRectFor("Rect", rect); } CFX_FloatRect CPDFSDK_BAAnnot::GetRect() const { @@ -57,11 +57,11 @@ void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, } FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid() { - return !!m_pAnnot->GetAnnotDict()->GetDictBy("AP"); + return !!m_pAnnot->GetAnnotDict()->GetDictFor("AP"); } FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { - CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); + CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); if (!pAP) return FALSE; @@ -75,7 +75,7 @@ FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { ap_entry = "N"; // Get the AP stream or subdirectory - CPDF_Object* psub = pAP->GetDirectObjectBy(ap_entry); + CPDF_Object* psub = pAP->GetDirectObjectFor(ap_entry); return !!psub; } @@ -91,25 +91,25 @@ void CPDFSDK_BAAnnot::ClearCachedAP() { void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) { if (sContents.IsEmpty()) - m_pAnnot->GetAnnotDict()->RemoveAt("Contents"); + m_pAnnot->GetAnnotDict()->RemoveFor("Contents"); else - m_pAnnot->GetAnnotDict()->SetAtString("Contents", - PDF_EncodeText(sContents)); + m_pAnnot->GetAnnotDict()->SetStringFor("Contents", + PDF_EncodeText(sContents)); } CFX_WideString CPDFSDK_BAAnnot::GetContents() const { - return m_pAnnot->GetAnnotDict()->GetUnicodeTextBy("Contents"); + return m_pAnnot->GetAnnotDict()->GetUnicodeTextFor("Contents"); } void CPDFSDK_BAAnnot::SetAnnotName(const CFX_WideString& sName) { if (sName.IsEmpty()) - m_pAnnot->GetAnnotDict()->RemoveAt("NM"); + m_pAnnot->GetAnnotDict()->RemoveFor("NM"); else - m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName)); + m_pAnnot->GetAnnotDict()->SetStringFor("NM", PDF_EncodeText(sName)); } CFX_WideString CPDFSDK_BAAnnot::GetAnnotName() const { - return m_pAnnot->GetAnnotDict()->GetUnicodeTextBy("NM"); + return m_pAnnot->GetAnnotDict()->GetUnicodeTextFor("NM"); } void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st) { @@ -117,14 +117,14 @@ void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st) { CFX_ByteString str = dt.ToPDFDateTimeString(); if (str.IsEmpty()) - m_pAnnot->GetAnnotDict()->RemoveAt("M"); + m_pAnnot->GetAnnotDict()->RemoveFor("M"); else - m_pAnnot->GetAnnotDict()->SetAtString("M", str); + m_pAnnot->GetAnnotDict()->SetStringFor("M", str); } FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const { FX_SYSTEMTIME systime; - CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetStringBy("M"); + CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetStringFor("M"); CPDFSDK_DateTime dt(str); dt.ToSystemTime(systime); @@ -133,82 +133,82 @@ FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const { } void CPDFSDK_BAAnnot::SetFlags(uint32_t nFlags) { - m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags); + m_pAnnot->GetAnnotDict()->SetIntegerFor("F", nFlags); } uint32_t CPDFSDK_BAAnnot::GetFlags() const { - return m_pAnnot->GetAnnotDict()->GetIntegerBy("F"); + return m_pAnnot->GetAnnotDict()->GetIntegerFor("F"); } void CPDFSDK_BAAnnot::SetAppState(const CFX_ByteString& str) { if (str.IsEmpty()) - m_pAnnot->GetAnnotDict()->RemoveAt("AS"); + m_pAnnot->GetAnnotDict()->RemoveFor("AS"); else - m_pAnnot->GetAnnotDict()->SetAtString("AS", str); + m_pAnnot->GetAnnotDict()->SetStringFor("AS", str); } CFX_ByteString CPDFSDK_BAAnnot::GetAppState() const { - return m_pAnnot->GetAnnotDict()->GetStringBy("AS"); + return m_pAnnot->GetAnnotDict()->GetStringFor("AS"); } void CPDFSDK_BAAnnot::SetStructParent(int key) { - m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key); + m_pAnnot->GetAnnotDict()->SetIntegerFor("StructParent", key); } int CPDFSDK_BAAnnot::GetStructParent() const { - return m_pAnnot->GetAnnotDict()->GetIntegerBy("StructParent"); + return m_pAnnot->GetAnnotDict()->GetIntegerFor("StructParent"); } // border void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) { - CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border"); + CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border"); if (pBorder) { pBorder->SetAt(2, new CPDF_Number(nWidth)); } else { - CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); + CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); if (!pBSDict) { pBSDict = new CPDF_Dictionary; - m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); + m_pAnnot->GetAnnotDict()->SetFor("BS", pBSDict); } - pBSDict->SetAtInteger("W", nWidth); + pBSDict->SetIntegerFor("W", nWidth); } } int CPDFSDK_BAAnnot::GetBorderWidth() const { - if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border")) { + if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border")) { return pBorder->GetIntegerAt(2); } - if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS")) { - return pBSDict->GetIntegerBy("W", 1); + if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS")) { + return pBSDict->GetIntegerFor("W", 1); } return 1; } void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) { - CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); + CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); if (!pBSDict) { pBSDict = new CPDF_Dictionary; - m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); + m_pAnnot->GetAnnotDict()->SetFor("BS", pBSDict); } switch (nStyle) { case BorderStyle::SOLID: - pBSDict->SetAtName("S", "S"); + pBSDict->SetNameFor("S", "S"); break; case BorderStyle::DASH: - pBSDict->SetAtName("S", "D"); + pBSDict->SetNameFor("S", "D"); break; case BorderStyle::BEVELED: - pBSDict->SetAtName("S", "B"); + pBSDict->SetNameFor("S", "B"); break; case BorderStyle::INSET: - pBSDict->SetAtName("S", "I"); + pBSDict->SetNameFor("S", "I"); break; case BorderStyle::UNDERLINE: - pBSDict->SetAtName("S", "U"); + pBSDict->SetNameFor("S", "U"); break; default: break; @@ -216,9 +216,9 @@ void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) { } BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const { - CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); + CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); if (pBSDict) { - CFX_ByteString sBorderStyle = pBSDict->GetStringBy("S", "S"); + CFX_ByteString sBorderStyle = pBSDict->GetStringFor("S", "S"); if (sBorderStyle == "S") return BorderStyle::SOLID; if (sBorderStyle == "D") @@ -231,7 +231,7 @@ BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const { return BorderStyle::UNDERLINE; } - CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border"); + CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border"); if (pBorder) { if (pBorder->GetCount() >= 4) { CPDF_Array* pDP = pBorder->GetArrayAt(3); @@ -248,15 +248,15 @@ void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); - m_pAnnot->GetAnnotDict()->SetAt("C", pArray); + m_pAnnot->GetAnnotDict()->SetFor("C", pArray); } void CPDFSDK_BAAnnot::RemoveColor() { - m_pAnnot->GetAnnotDict()->RemoveAt("C"); + m_pAnnot->GetAnnotDict()->RemoveFor("C"); } FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { - if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayBy("C")) { + if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayFor("C")) { size_t nCount = pEntry->GetCount(); if (nCount == 1) { FX_FLOAT g = pEntry->GetNumberAt(0) * 255; @@ -296,11 +296,11 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, const CFX_Matrix& matrix, const CFX_ByteString& sContents, const CFX_ByteString& sAPState) { - CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); + CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); if (!pAPDict) { pAPDict = new CPDF_Dictionary; - m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict); + m_pAnnot->GetAnnotDict()->SetFor("AP", pAPDict); } CPDF_Stream* pStream = nullptr; @@ -308,36 +308,36 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, if (sAPState.IsEmpty()) { pParentDict = pAPDict; - pStream = pAPDict->GetStreamBy(sAPType); + pStream = pAPDict->GetStreamFor(sAPType); } else { - CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictBy(sAPType); + CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictFor(sAPType); if (!pAPTypeDict) { pAPTypeDict = new CPDF_Dictionary; - pAPDict->SetAt(sAPType, pAPTypeDict); + pAPDict->SetFor(sAPType, pAPTypeDict); } pParentDict = pAPTypeDict; - pStream = pAPTypeDict->GetStreamBy(sAPState); + pStream = pAPTypeDict->GetStreamFor(sAPState); } if (!pStream) { pStream = new CPDF_Stream(nullptr, 0, nullptr); CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); int32_t objnum = pDoc->AddIndirectObject(pStream); - pParentDict->SetAtReference(sAPType, pDoc, objnum); + pParentDict->SetReferenceFor(sAPType, pDoc, objnum); } CPDF_Dictionary* pStreamDict = pStream->GetDict(); if (!pStreamDict) { pStreamDict = new CPDF_Dictionary; - pStreamDict->SetAtName("Type", "XObject"); - pStreamDict->SetAtName("Subtype", "Form"); - pStreamDict->SetAtInteger("FormType", 1); + pStreamDict->SetNameFor("Type", "XObject"); + pStreamDict->SetNameFor("Subtype", "Form"); + pStreamDict->SetIntegerFor("FormType", 1); pStream->InitStream(nullptr, 0, pStreamDict); } if (pStreamDict) { - pStreamDict->SetAtMatrix("Matrix", matrix); - pStreamDict->SetAtRect("BBox", rcBBox); + pStreamDict->SetMatrixFor("Matrix", matrix); + pStreamDict->SetRectFor("BBox", rcBBox); } pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, @@ -351,36 +351,36 @@ FX_BOOL CPDFSDK_BAAnnot::IsVisible() const { } CPDF_Action CPDFSDK_BAAnnot::GetAction() const { - return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictBy("A")); + return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); } void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { ASSERT(action.GetDict()); - if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("A")) { + if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictFor("A")) { CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); CPDF_Dictionary* pDict = action.GetDict(); if (pDict && pDict->GetObjNum() == 0) { pDoc->AddIndirectObject(pDict); } - m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetObjNum()); + m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc, pDict->GetObjNum()); } } void CPDFSDK_BAAnnot::RemoveAction() { - m_pAnnot->GetAnnotDict()->RemoveAt("A"); + m_pAnnot->GetAnnotDict()->RemoveFor("A"); } CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { - return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictBy("AA")); + return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA")); } void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) { - if (aa.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("AA")) - m_pAnnot->GetAnnotDict()->SetAt("AA", aa.GetDict()); + if (aa.GetDict() != m_pAnnot->GetAnnotDict()->GetDictFor("AA")) + m_pAnnot->GetAnnotDict()->SetFor("AA", aa.GetDict()); } void CPDFSDK_BAAnnot::RemoveAAction() { - m_pAnnot->GetAnnotDict()->RemoveAt("AA"); + m_pAnnot->GetAnnotDict()->RemoveFor("AA"); } CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { diff --git a/fpdfsdk/cpdfsdk_document.cpp b/fpdfsdk/cpdfsdk_document.cpp index fc09e8a796..339aeab8c6 100644 --- a/fpdfsdk/cpdfsdk_document.cpp +++ b/fpdfsdk/cpdfsdk_document.cpp @@ -103,9 +103,9 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction() { if (!pRoot) return FALSE; - CPDF_Object* pOpenAction = pRoot->GetDictBy("OpenAction"); + CPDF_Object* pOpenAction = pRoot->GetDictFor("OpenAction"); if (!pOpenAction) - pOpenAction = pRoot->GetArrayBy("OpenAction"); + pOpenAction = pRoot->GetArrayFor("OpenAction"); if (!pOpenAction) return FALSE; diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 12def4ca28..e9fb5b4de0 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -100,7 +100,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl, CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); CPDFSDK_PageView* pPage = nullptr; - if (CPDF_Dictionary* pPageDict = pControlDict->GetDictBy("P")) { + if (CPDF_Dictionary* pPageDict = pControlDict->GetDictFor("P")) { int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum()); if (nPageIndex >= 0) pPage = m_pDocument->GetPageView(nPageIndex); @@ -147,7 +147,7 @@ int CPDFSDK_InterForm::GetPageIndexByAnnotDict( for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { - if (CPDF_Array* pAnnots = pPageDict->GetArrayBy("Annots")) { + if (CPDF_Array* pAnnots = pPageDict->GetArrayFor("Annots")) { for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { CPDF_Object* pDict = pAnnots->GetDirectObjectAt(j); if (pAnnotDict == pDict) @@ -484,11 +484,11 @@ FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, if (!pFDF) return TRUE; - CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictBy("FDF"); + CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF"); if (!pMainDict) return FALSE; - CPDF_Array* pFields = pMainDict->GetArrayBy("Fields"); + CPDF_Array* pFields = pMainDict->GetArrayFor("Fields"); if (!pFields) return FALSE; @@ -498,9 +498,9 @@ FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, if (!pField) continue; CFX_WideString name; - name = pField->GetUnicodeTextBy("T"); + name = pField->GetUnicodeTextFor("T"); CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); - CFX_ByteString csBValue = pField->GetStringBy("V"); + CFX_ByteString csBValue = pField->GetStringFor("V"); CFX_WideString csWValue = PDF_DecodeText(csBValue); CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index 7fed794d28..a342e017e4 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -231,7 +231,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { #endif // PDF_ENABLE_XFA CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { - return pDict ? AddAnnot(pDict->GetStringBy("Subtype").c_str(), pDict) + return pDict ? AddAnnot(pDict->GetStringFor("Subtype").c_str(), pDict) : nullptr; } diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index 3519b06843..9bc18fae04 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -455,7 +455,7 @@ void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( CPDF_Annot::AppearanceMode mode) { - CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); + CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); if (!pAP) return FALSE; @@ -469,7 +469,7 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( ap_entry = "N"; // Get the AP stream or subdirectory - CPDF_Object* psub = pAP->GetDirectObjectBy(ap_entry); + CPDF_Object* psub = pAP->GetDirectObjectFor(ap_entry); if (!psub) return FALSE; @@ -484,7 +484,7 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( case FIELDTYPE_CHECKBOX: case FIELDTYPE_RADIOBUTTON: if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { - return !!pSubDict->GetStreamBy(GetAppState()); + return !!pSubDict->GetStreamFor(GetAppState()); } return FALSE; } @@ -970,22 +970,22 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() { if (pNormalIcon) { if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) { - if (pImageDict->GetStringBy("Name").IsEmpty()) - pImageDict->SetAtString("Name", "ImgA"); + if (pImageDict->GetStringFor("Name").IsEmpty()) + pImageDict->SetStringFor("Name", "ImgA"); } } if (pRolloverIcon) { if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) { - if (pImageDict->GetStringBy("Name").IsEmpty()) - pImageDict->SetAtString("Name", "ImgB"); + if (pImageDict->GetStringFor("Name").IsEmpty()) + pImageDict->SetStringFor("Name", "ImgB"); } } if (pDownIcon) { if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { - if (pImageDict->GetStringBy("Name").IsEmpty()) - pImageDict->SetAtString("Name", "ImgC"); + if (pImageDict->GetStringFor("Name").IsEmpty()) + pImageDict->SetStringFor("Name", "ImgC"); } } @@ -1810,33 +1810,33 @@ void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); ASSERT(pDoc); - CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); - CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType); + CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); + CPDF_Stream* pStream = pAPDict->GetStreamFor(sAPType); CPDF_Dictionary* pStreamDict = pStream->GetDict(); CFX_ByteString sImageAlias = "IMG"; if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { - sImageAlias = pImageDict->GetStringBy("Name"); + sImageAlias = pImageDict->GetStringFor("Name"); if (sImageAlias.IsEmpty()) sImageAlias = "IMG"; } - CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); + CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); if (!pStreamResList) { pStreamResList = new CPDF_Dictionary(); - pStreamDict->SetAt("Resources", pStreamResList); + pStreamDict->SetFor("Resources", pStreamResList); } if (pStreamResList) { CPDF_Dictionary* pXObject = new CPDF_Dictionary; - pXObject->SetAtReference(sImageAlias, pDoc, pImage); - pStreamResList->SetAt("XObject", pXObject); + pXObject->SetReferenceFor(sImageAlias, pDoc, pImage); + pStreamResList->SetFor("XObject", pXObject); } } void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { - if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) - pAPDict->RemoveAt(sAPType); + if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) + pAPDict->RemoveFor(sAPType); } FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 575f6c3145..8a981690f1 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -82,7 +82,7 @@ void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t nCharset) { - if (m_pAnnotDict->GetStringBy("Subtype") != "Widget") + if (m_pAnnotDict->GetStringFor("Subtype") != "Widget") return nullptr; CPDF_Document* pDocument = GetDocument(); @@ -90,11 +90,11 @@ CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, if (!pRootDict) return nullptr; - CPDF_Dictionary* pAcroFormDict = pRootDict->GetDictBy("AcroForm"); + CPDF_Dictionary* pAcroFormDict = pRootDict->GetDictFor("AcroForm"); if (!pAcroFormDict) return nullptr; - CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR"); + CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictFor("DR"); if (!pDRDict) return nullptr; @@ -111,7 +111,7 @@ CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, if (!pResDict) return nullptr; - CPDF_Dictionary* pFonts = pResDict->GetDictBy("Font"); + CPDF_Dictionary* pFonts = pResDict->GetDictFor("Font"); if (!pFonts) return nullptr; @@ -126,7 +126,7 @@ CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); if (!pElement) continue; - if (pElement->GetStringBy("Type") != "Font") + if (pElement->GetStringFor("Type") != "Font") continue; CPDF_Font* pFont = pDocument->LoadFont(pElement); @@ -153,23 +153,23 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, if (!pFont) return; - CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP"); + CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP"); if (!pAPDict) { pAPDict = new CPDF_Dictionary; - m_pAnnotDict->SetAt("AP", pAPDict); + m_pAnnotDict->SetFor("AP", pAPDict); } // to avoid checkbox and radiobutton - CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType); + CPDF_Object* pObject = pAPDict->GetObjectFor(m_sAPType); if (ToDictionary(pObject)) return; - CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType); + CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType); if (!pStream) { pStream = new CPDF_Stream(nullptr, 0, nullptr); int32_t objnum = m_pDocument->AddIndirectObject(pStream); - pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); + pAPDict->SetReferenceFor(m_sAPType, m_pDocument, objnum); } CPDF_Dictionary* pStreamDict = pStream->GetDict(); @@ -180,32 +180,32 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, } if (pStreamDict) { - CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); + CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); if (!pStreamResList) { pStreamResList = new CPDF_Dictionary(); - pStreamDict->SetAt("Resources", pStreamResList); + pStreamDict->SetFor("Resources", pStreamResList); } if (pStreamResList) { - CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); + CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); if (!pStreamResFontList) { pStreamResFontList = new CPDF_Dictionary; int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList); - pStreamResList->SetAtReference("Font", m_pDocument, objnum); + pStreamResList->SetReferenceFor("Font", m_pDocument, objnum); } if (!pStreamResFontList->KeyExist(sAlias)) - pStreamResFontList->SetAtReference(sAlias, m_pDocument, - pFont->GetFontDict()); + pStreamResFontList->SetReferenceFor(sAlias, m_pDocument, + pFont->GetFontDict()); } } } CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { CPDF_Dictionary* pAcroFormDict = nullptr; - const bool bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget"); + const bool bWidget = (m_pAnnotDict->GetStringFor("Subtype") == "Widget"); if (bWidget) { if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot()) - pAcroFormDict = pRootDict->GetDictBy("AcroForm"); + pAcroFormDict = pRootDict->GetDictFor("AcroForm"); } CFX_ByteString sDA; @@ -228,20 +228,20 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { sAlias = PDF_NameDecode(sFontName).Mid(1); CPDF_Dictionary* pFontDict = nullptr; - if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) { - if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) { + if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP")) { + if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictFor("N")) { if (CPDF_Dictionary* pNormalResDict = - pNormalDict->GetDictBy("Resources")) { - if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDictBy("Font")) - pFontDict = pResFontDict->GetDictBy(sAlias); + pNormalDict->GetDictFor("Resources")) { + if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDictFor("Font")) + pFontDict = pResFontDict->GetDictFor(sAlias); } } } if (bWidget && !pFontDict && pAcroFormDict) { - if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR")) { - if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) - pFontDict = pDRFontDict->GetDictBy(sAlias); + if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictFor("DR")) { + if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictFor("Font")) + pFontDict = pDRFontDict->GetDictFor(sAlias); } } diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp index 46bc7e57a4..cfa76b5f86 100644 --- a/fpdfsdk/fpdf_ext.cpp +++ b/fpdfsdk/fpdf_ext.cpp @@ -53,7 +53,7 @@ void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); CFX_ByteString cbString; if (pAnnotDict->KeyExist("IT")) - cbString = pAnnotDict->GetStringBy("IT"); + cbString = pAnnotDict->GetStringFor("IT"); if (cbString.Compare("Img") != 0) FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA); } else if (nAnnotSubtype == CPDF_Annot::Subtype::MOVIE) { @@ -68,7 +68,7 @@ void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); CFX_ByteString cbString; if (pAnnotDict->KeyExist("FT")) - cbString = pAnnotDict->GetStringBy("FT"); + cbString = pAnnotDict->GetStringFor("FT"); if (cbString.Compare("Sig") == 0) FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG); } @@ -133,14 +133,14 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) { return; } if (pRootDict->KeyExist("Names")) { - CPDF_Dictionary* pNameDict = pRootDict->GetDictBy("Names"); + CPDF_Dictionary* pNameDict = pRootDict->GetDictFor("Names"); if (pNameDict && pNameDict->KeyExist("EmbeddedFiles")) { FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT); return; } if (pNameDict && pNameDict->KeyExist("JavaScript")) { - CPDF_Dictionary* pJSDict = pNameDict->GetDictBy("JavaScript"); - CPDF_Array* pArray = pJSDict ? pJSDict->GetArrayBy("Names") : nullptr; + CPDF_Dictionary* pJSDict = pNameDict->GetDictFor("JavaScript"); + CPDF_Array* pArray = pJSDict ? pJSDict->GetArrayFor("Names") : nullptr; if (pArray) { for (size_t i = 0; i < pArray->GetCount(); i++) { CFX_ByteString cbStr = pArray->GetStringAt(i); @@ -177,7 +177,7 @@ DLLEXPORT int STDCALL FPDFDoc_GetPageMode(FPDF_DOCUMENT document) { if (!pRoot) return PAGEMODE_UNKNOWN; - CPDF_Object* pName = pRoot->GetObjectBy("PageMode"); + CPDF_Object* pName = pRoot->GetObjectFor("PageMode"); if (!pName) return PAGEMODE_USENONE; diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp index 5b97341765..de6baf1f01 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp @@ -55,7 +55,7 @@ void GetContentsRect(CPDF_Document* pDoc, rc.right = pPageObject->m_Right; rc.bottom = pPageObject->m_Bottom; rc.top = pPageObject->m_Top; - if (IsValiableRect(rc, pDict->GetRectBy("MediaBox"))) + if (IsValiableRect(rc, pDict->GetRectFor("MediaBox"))) pRectArray->Add(rc); } } @@ -68,11 +68,11 @@ void ParserStream(CPDF_Dictionary* pPageDic, return; CFX_FloatRect rect; if (pStream->KeyExist("Rect")) - rect = pStream->GetRectBy("Rect"); + rect = pStream->GetRectFor("Rect"); else if (pStream->KeyExist("BBox")) - rect = pStream->GetRectBy("BBox"); + rect = pStream->GetRectFor("BBox"); - if (IsValiableRect(rect, pPageDic->GetRectBy("MediaBox"))) + if (IsValiableRect(rect, pPageDic->GetRectFor("MediaBox"))) pRectArray->Add(rect); pObjectArray->Add(pStream); @@ -87,7 +87,7 @@ int ParserAnnots(CPDF_Document* pSourceDoc, return FLATTEN_FAIL; GetContentsRect(pSourceDoc, pPageDic, pRectArray); - CPDF_Array* pAnnots = pPageDic->GetArrayBy("Annots"); + CPDF_Array* pAnnots = pPageDic->GetArrayFor("Annots"); if (!pAnnots) return FLATTEN_NOTHINGTODO; @@ -97,11 +97,11 @@ int ParserAnnots(CPDF_Document* pSourceDoc, if (!pAnnotDic) continue; - CFX_ByteString sSubtype = pAnnotDic->GetStringBy("Subtype"); + CFX_ByteString sSubtype = pAnnotDic->GetStringFor("Subtype"); if (sSubtype == "Popup") continue; - int nAnnotFlag = pAnnotDic->GetIntegerBy("F"); + int nAnnotFlag = pAnnotDic->GetIntegerFor("F"); if (nAnnotFlag & ANNOTFLAG_HIDDEN) continue; @@ -185,9 +185,9 @@ CFX_FloatRect CalculateRect(CPDF_RectArray* pRectArray) { void SetPageContents(CFX_ByteString key, CPDF_Dictionary* pPage, CPDF_Document* pDocument) { - CPDF_Object* pContentsObj = pPage->GetStreamBy("Contents"); + CPDF_Object* pContentsObj = pPage->GetStreamFor("Contents"); if (!pContentsObj) { - pContentsObj = pPage->GetArrayBy("Contents"); + pContentsObj = pPage->GetArrayFor("Contents"); } if (!pContentsObj) { @@ -195,8 +195,8 @@ void SetPageContents(CFX_ByteString key, if (!key.IsEmpty()) { CPDF_Stream* pNewContents = new CPDF_Stream(nullptr, 0, new CPDF_Dictionary); - pPage->SetAtReference("Contents", pDocument, - pDocument->AddIndirectObject(pNewContents)); + pPage->SetReferenceFor("Contents", pDocument, + pDocument->AddIndirectObject(pNewContents)); CFX_ByteString sStream; sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); @@ -236,7 +236,7 @@ void SetPageContents(CFX_ByteString key, return; uint32_t dwObjNum = pDocument->AddIndirectObject(pContentsArray); - pPage->SetAtReference("Contents", pDocument, dwObjNum); + pPage->SetReferenceFor("Contents", pDocument, dwObjNum); if (!key.IsEmpty()) { CPDF_Stream* pNewContents = @@ -330,10 +330,10 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { CFX_FloatRect rcOriginalCB; CFX_FloatRect rcMerger = CalculateRect(&RectArray); - CFX_FloatRect rcOriginalMB = pPageDict->GetRectBy("MediaBox"); + CFX_FloatRect rcOriginalMB = pPageDict->GetRectFor("MediaBox"); if (pPageDict->KeyExist("CropBox")) - rcOriginalMB = pPageDict->GetRectBy("CropBox"); + rcOriginalMB = pPageDict->GetRectFor("CropBox"); if (rcOriginalMB.IsEmpty()) { rcOriginalMB = CFX_FloatRect(0.0f, 0.0f, 612.0f, 792.0f); @@ -349,7 +349,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { : rcMerger.bottom; if (pPageDict->KeyExist("ArtBox")) - rcOriginalCB = pPageDict->GetRectBy("ArtBox"); + rcOriginalCB = pPageDict->GetRectFor("ArtBox"); else rcOriginalCB = rcOriginalMB; @@ -359,7 +359,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { pMediaBox->Add(new CPDF_Number(rcOriginalMB.bottom)); pMediaBox->Add(new CPDF_Number(rcOriginalMB.right)); pMediaBox->Add(new CPDF_Number(rcOriginalMB.top)); - pPageDict->SetAt("MediaBox", pMediaBox); + pPageDict->SetFor("MediaBox", pMediaBox); } if (!rcOriginalCB.IsEmpty()) { @@ -368,21 +368,21 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { pCropBox->Add(new CPDF_Number(rcOriginalCB.bottom)); pCropBox->Add(new CPDF_Number(rcOriginalCB.right)); pCropBox->Add(new CPDF_Number(rcOriginalCB.top)); - pPageDict->SetAt("ArtBox", pCropBox); + pPageDict->SetFor("ArtBox", pCropBox); } - CPDF_Dictionary* pRes = pPageDict->GetDictBy("Resources"); + CPDF_Dictionary* pRes = pPageDict->GetDictFor("Resources"); if (!pRes) { pRes = new CPDF_Dictionary; - pPageDict->SetAt("Resources", pRes); + pPageDict->SetFor("Resources", pRes); } CPDF_Stream* pNewXObject = new CPDF_Stream(nullptr, 0, new CPDF_Dictionary); uint32_t dwObjNum = pDocument->AddIndirectObject(pNewXObject); - CPDF_Dictionary* pPageXObject = pRes->GetDictBy("XObject"); + CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject"); if (!pPageXObject) { pPageXObject = new CPDF_Dictionary; - pRes->SetAt("XObject", pPageXObject); + pRes->SetFor("XObject", pPageXObject); } CFX_ByteString key = ""; @@ -403,16 +403,16 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { CPDF_Dictionary* pNewXORes = nullptr; if (!key.IsEmpty()) { - pPageXObject->SetAtReference(key, pDocument, dwObjNum); + pPageXObject->SetReferenceFor(key, pDocument, dwObjNum); CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict(); pNewXORes = new CPDF_Dictionary; - pNewOXbjectDic->SetAt("Resources", pNewXORes); - pNewOXbjectDic->SetAtName("Type", "XObject"); - pNewOXbjectDic->SetAtName("Subtype", "Form"); - pNewOXbjectDic->SetAtInteger("FormType", 1); - pNewOXbjectDic->SetAtName("Name", "FRM"); - CFX_FloatRect rcBBox = pPageDict->GetRectBy("ArtBox"); - pNewOXbjectDic->SetAtRect("BBox", rcBBox); + pNewOXbjectDic->SetFor("Resources", pNewXORes); + pNewOXbjectDic->SetNameFor("Type", "XObject"); + pNewOXbjectDic->SetNameFor("Subtype", "Form"); + pNewOXbjectDic->SetIntegerFor("FormType", 1); + pNewOXbjectDic->SetNameFor("Name", "FRM"); + CFX_FloatRect rcBBox = pPageDict->GetRectFor("ArtBox"); + pNewOXbjectDic->SetRectFor("BBox", rcBBox); } for (int i = 0; i < nStreams; i++) { @@ -420,22 +420,22 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { if (!pAnnotDic) continue; - CFX_FloatRect rcAnnot = pAnnotDic->GetRectBy("Rect"); + CFX_FloatRect rcAnnot = pAnnotDic->GetRectFor("Rect"); rcAnnot.Normalize(); - CFX_ByteString sAnnotState = pAnnotDic->GetStringBy("AS"); - CPDF_Dictionary* pAnnotAP = pAnnotDic->GetDictBy("AP"); + CFX_ByteString sAnnotState = pAnnotDic->GetStringFor("AS"); + CPDF_Dictionary* pAnnotAP = pAnnotDic->GetDictFor("AP"); if (!pAnnotAP) continue; - CPDF_Stream* pAPStream = pAnnotAP->GetStreamBy("N"); + CPDF_Stream* pAPStream = pAnnotAP->GetStreamFor("N"); if (!pAPStream) { - CPDF_Dictionary* pAPDic = pAnnotAP->GetDictBy("N"); + CPDF_Dictionary* pAPDic = pAnnotAP->GetDictFor("N"); if (!pAPDic) continue; if (!sAnnotState.IsEmpty()) { - pAPStream = pAPDic->GetStreamBy(sAnnotState); + pAPStream = pAPDic->GetStreamFor(sAnnotState); } else { auto it = pAPDic->begin(); if (it != pAPDic->end()) { @@ -454,13 +454,13 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { continue; CPDF_Dictionary* pAPDic = pAPStream->GetDict(); - CFX_Matrix matrix = pAPDic->GetMatrixBy("Matrix"); + CFX_Matrix matrix = pAPDic->GetMatrixFor("Matrix"); CFX_FloatRect rcStream; if (pAPDic->KeyExist("Rect")) - rcStream = pAPDic->GetRectBy("Rect"); + rcStream = pAPDic->GetRectFor("Rect"); else if (pAPDic->KeyExist("BBox")) - rcStream = pAPDic->GetRectBy("BBox"); + rcStream = pAPDic->GetRectFor("BBox"); if (rcStream.IsEmpty()) continue; @@ -470,21 +470,21 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { if (pObj) { CPDF_Dictionary* pObjDic = pObj->GetDict(); if (pObjDic) { - pObjDic->SetAtName("Type", "XObject"); - pObjDic->SetAtName("Subtype", "Form"); + pObjDic->SetNameFor("Type", "XObject"); + pObjDic->SetNameFor("Subtype", "Form"); } } - CPDF_Dictionary* pXObject = pNewXORes->GetDictBy("XObject"); + CPDF_Dictionary* pXObject = pNewXORes->GetDictFor("XObject"); if (!pXObject) { pXObject = new CPDF_Dictionary; - pNewXORes->SetAt("XObject", pXObject); + pNewXORes->SetFor("XObject", pXObject); } CFX_ByteString sFormName; sFormName.Format("F%d", i); uint32_t dwStreamObjNum = pDocument->AddIndirectObject(pObj); - pXObject->SetAtReference(sFormName, pDocument, dwStreamObjNum); + pXObject->SetReferenceFor(sFormName, pDocument, dwStreamObjNum); CPDF_StreamAcc acc; acc.LoadAllData(pNewXObject); @@ -508,7 +508,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { sStream += sTemp; pNewXObject->SetData(sStream.raw_str(), sStream.GetLength(), FALSE, FALSE); } - pPageDict->RemoveAt("Annots"); + pPageDict->RemoveFor("Annots"); ObjectArray.RemoveAll(); RectArray.RemoveAll(); diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index c77ece7b9d..7b2bf73871 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -31,7 +31,7 @@ void SetBoundingBox(CPDF_Page* page, pBoundingBoxArray->Add(new CPDF_Number(bottom)); pBoundingBoxArray->Add(new CPDF_Number(right)); pBoundingBoxArray->Add(new CPDF_Number(top)); - page->m_pFormDict->SetAt(key, pBoundingBoxArray); + page->m_pFormDict->SetFor(key, pBoundingBoxArray); } bool GetBoundingBox(CPDF_Page* page, @@ -40,7 +40,7 @@ bool GetBoundingBox(CPDF_Page* page, float* bottom, float* right, float* top) { - CPDF_Array* pArray = page->m_pFormDict->GetArrayBy(key); + CPDF_Array* pArray = page->m_pFormDict->GetArrayFor(key); if (!pArray) return false; @@ -119,9 +119,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, CPDF_Dictionary* pPageDic = pPage->m_pFormDict; CPDF_Object* pContentObj = - pPageDic ? pPageDic->GetObjectBy("Contents") : nullptr; + pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr; if (!pContentObj) - pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; + pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr; if (!pContentObj) return FALSE; @@ -159,16 +159,16 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, pContentArray->AddReference(pDoc, pStream->GetObjNum()); pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); pContentArray->AddReference(pDoc, pEndStream); - pPageDic->SetAtReference("Contents", pDoc, - pDoc->AddIndirectObject(pContentArray)); + pPageDic->SetReferenceFor("Contents", pDoc, + pDoc->AddIndirectObject(pContentArray)); } } } // Need to transform the patterns as well. - CPDF_Dictionary* pRes = pPageDic->GetDictBy("Resources"); + CPDF_Dictionary* pRes = pPageDic->GetDictFor("Resources"); if (pRes) { - CPDF_Dictionary* pPattenDict = pRes->GetDictBy("Pattern"); + CPDF_Dictionary* pPattenDict = pRes->GetDictFor("Pattern"); if (pPattenDict) { for (const auto& it : *pPattenDict) { CPDF_Object* pObj = it.second; @@ -183,10 +183,10 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, else continue; - CFX_Matrix m = pDict->GetMatrixBy("Matrix"); + CFX_Matrix m = pDict->GetMatrixFor("Matrix"); CFX_Matrix t = *(CFX_Matrix*)matrix; m.Concat(t); - pDict->SetAtMatrix("Matrix", m); + pDict->SetMatrixFor("Matrix", m); } } } @@ -277,9 +277,9 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, CPDF_Dictionary* pPageDic = pPage->m_pFormDict; CPDF_Object* pContentObj = - pPageDic ? pPageDic->GetObjectBy("Contents") : nullptr; + pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr; if (!pContentObj) - pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; + pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr; if (!pContentObj) return; @@ -326,8 +326,8 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, pContentArray = new CPDF_Array(); pContentArray->AddReference(pDoc, pStream->GetObjNum()); pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); - pPageDic->SetAtReference("Contents", pDoc, - pDoc->AddIndirectObject(pContentArray)); + pPageDic->SetReferenceFor("Contents", pDoc, + pDoc->AddIndirectObject(pContentArray)); } } } diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp index de80c4c773..f22f73743e 100644 --- a/fpdfsdk/fpdfdoc.cpp +++ b/fpdfsdk/fpdfdoc.cpp @@ -276,7 +276,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!pPage || !pPage->m_pFormDict) return FALSE; - CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots"); + CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayFor("Annots"); if (!pAnnots) return FALSE; for (size_t i = *startPos; i < pAnnots->GetCount(); i++) { @@ -284,7 +284,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, ToDictionary(static_cast<CPDF_Object*>(pAnnots->GetDirectObjectAt(i))); if (!pDict) continue; - if (pDict->GetStringBy("Subtype") == "Link") { + if (pDict->GetStringFor("Subtype") == "Link") { *startPos = static_cast<int>(i + 1); *linkAnnot = static_cast<FPDF_LINK>(pDict); return TRUE; @@ -299,7 +299,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, return FALSE; CPDF_Dictionary* pAnnotDict = ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); - CFX_FloatRect rt = pAnnotDict->GetRectBy("Rect"); + CFX_FloatRect rt = pAnnotDict->GetRectFor("Rect"); rect->left = rt.left; rect->bottom = rt.bottom; rect->right = rt.right; @@ -312,7 +312,7 @@ DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) { return 0; CPDF_Dictionary* pAnnotDict = ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); - CPDF_Array* pArray = pAnnotDict->GetArrayBy("QuadPoints"); + CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); if (!pArray) return 0; return static_cast<int>(pArray->GetCount() / 8); @@ -325,7 +325,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, return FALSE; CPDF_Dictionary* pAnnotDict = ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); - CPDF_Array* pArray = pAnnotDict->GetArrayBy("QuadPoints"); + CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); if (pArray) { if (quadIndex < 0 || static_cast<size_t>(quadIndex) >= pArray->GetCount() / 8 || @@ -356,7 +356,7 @@ DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, CPDF_Dictionary* pInfo = pDoc->GetInfo(); if (!pInfo) return 0; - CFX_WideString text = pInfo->GetUnicodeTextBy(tag); + CFX_WideString text = pInfo->GetUnicodeTextFor(tag); // Use UTF-16LE encoding CFX_ByteString encodedText = text.UTF16LE_Encode(); unsigned long len = encodedText.GetLength(); diff --git a/fpdfsdk/fpdfdoc_unittest.cpp b/fpdfsdk/fpdfdoc_unittest.cpp index a555e961f3..5bda8da928 100644 --- a/fpdfsdk/fpdfdoc_unittest.cpp +++ b/fpdfsdk/fpdfdoc_unittest.cpp @@ -104,7 +104,7 @@ TEST_F(PDFDocTest, FindBookmark) { } { // Empty bookmark tree. - m_pRootObj->SetAt("Outlines", new CPDF_Dictionary()); + m_pRootObj->SetFor("Outlines", new CPDF_Dictionary()); std::unique_ptr<unsigned short, pdfium::FreeDeleter> title = GetFPDFWideString(L""); EXPECT_EQ(nullptr, FPDFBookmark_Find(m_pDoc.get(), title.get())); @@ -116,27 +116,27 @@ TEST_F(PDFDocTest, FindBookmark) { // Check on a regular bookmark tree. auto bookmarks = CreateDictObjs(3); - bookmarks[1].obj->SetAt("Title", new CPDF_String(L"Chapter 1")); - bookmarks[1].obj->SetAt( + bookmarks[1].obj->SetFor("Title", new CPDF_String(L"Chapter 1")); + bookmarks[1].obj->SetFor( "Parent", new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); - bookmarks[1].obj->SetAt( + bookmarks[1].obj->SetFor( "Next", new CPDF_Reference(m_pIndirectObjs, bookmarks[2].num)); - bookmarks[2].obj->SetAt("Title", new CPDF_String(L"Chapter 2")); - bookmarks[2].obj->SetAt( + bookmarks[2].obj->SetFor("Title", new CPDF_String(L"Chapter 2")); + bookmarks[2].obj->SetFor( "Parent", new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); - bookmarks[2].obj->SetAt( + bookmarks[2].obj->SetFor( "Prev", new CPDF_Reference(m_pIndirectObjs, bookmarks[1].num)); - bookmarks[0].obj->SetAt("Type", new CPDF_Name("Outlines")); - bookmarks[0].obj->SetAt("Count", new CPDF_Number(2)); - bookmarks[0].obj->SetAt( + bookmarks[0].obj->SetFor("Type", new CPDF_Name("Outlines")); + bookmarks[0].obj->SetFor("Count", new CPDF_Number(2)); + bookmarks[0].obj->SetFor( "First", new CPDF_Reference(m_pIndirectObjs, bookmarks[1].num)); - bookmarks[0].obj->SetAt( + bookmarks[0].obj->SetFor( "Last", new CPDF_Reference(m_pIndirectObjs, bookmarks[2].num)); - m_pRootObj->SetAt("Outlines", - new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); + m_pRootObj->SetFor("Outlines", + new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); // Title with no match. std::unique_ptr<unsigned short, pdfium::FreeDeleter> title = @@ -159,27 +159,27 @@ TEST_F(PDFDocTest, FindBookmark) { // Circular bookmarks in depth. auto bookmarks = CreateDictObjs(3); - bookmarks[1].obj->SetAt("Title", new CPDF_String(L"Chapter 1")); - bookmarks[1].obj->SetAt( + bookmarks[1].obj->SetFor("Title", new CPDF_String(L"Chapter 1")); + bookmarks[1].obj->SetFor( "Parent", new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); - bookmarks[1].obj->SetAt( + bookmarks[1].obj->SetFor( "First", new CPDF_Reference(m_pIndirectObjs, bookmarks[2].num)); - bookmarks[2].obj->SetAt("Title", new CPDF_String(L"Chapter 2")); - bookmarks[2].obj->SetAt( + bookmarks[2].obj->SetFor("Title", new CPDF_String(L"Chapter 2")); + bookmarks[2].obj->SetFor( "Parent", new CPDF_Reference(m_pIndirectObjs, bookmarks[1].num)); - bookmarks[2].obj->SetAt( + bookmarks[2].obj->SetFor( "First", new CPDF_Reference(m_pIndirectObjs, bookmarks[1].num)); - bookmarks[0].obj->SetAt("Type", new CPDF_Name("Outlines")); - bookmarks[0].obj->SetAt("Count", new CPDF_Number(2)); - bookmarks[0].obj->SetAt( + bookmarks[0].obj->SetFor("Type", new CPDF_Name("Outlines")); + bookmarks[0].obj->SetFor("Count", new CPDF_Number(2)); + bookmarks[0].obj->SetFor( "First", new CPDF_Reference(m_pIndirectObjs, bookmarks[1].num)); - bookmarks[0].obj->SetAt( + bookmarks[0].obj->SetFor( "Last", new CPDF_Reference(m_pIndirectObjs, bookmarks[2].num)); - m_pRootObj->SetAt("Outlines", - new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); + m_pRootObj->SetFor("Outlines", + new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); // Title with no match. std::unique_ptr<unsigned short, pdfium::FreeDeleter> title = @@ -194,33 +194,33 @@ TEST_F(PDFDocTest, FindBookmark) { // Circular bookmarks in breadth. auto bookmarks = CreateDictObjs(4); - bookmarks[1].obj->SetAt("Title", new CPDF_String(L"Chapter 1")); - bookmarks[1].obj->SetAt( + bookmarks[1].obj->SetFor("Title", new CPDF_String(L"Chapter 1")); + bookmarks[1].obj->SetFor( "Parent", new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); - bookmarks[1].obj->SetAt( + bookmarks[1].obj->SetFor( "Next", new CPDF_Reference(m_pIndirectObjs, bookmarks[2].num)); - bookmarks[2].obj->SetAt("Title", new CPDF_String(L"Chapter 2")); - bookmarks[2].obj->SetAt( + bookmarks[2].obj->SetFor("Title", new CPDF_String(L"Chapter 2")); + bookmarks[2].obj->SetFor( "Parent", new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); - bookmarks[2].obj->SetAt( + bookmarks[2].obj->SetFor( "Next", new CPDF_Reference(m_pIndirectObjs, bookmarks[3].num)); - bookmarks[3].obj->SetAt("Title", new CPDF_String(L"Chapter 3")); - bookmarks[3].obj->SetAt( + bookmarks[3].obj->SetFor("Title", new CPDF_String(L"Chapter 3")); + bookmarks[3].obj->SetFor( "Parent", new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); - bookmarks[3].obj->SetAt( + bookmarks[3].obj->SetFor( "Next", new CPDF_Reference(m_pIndirectObjs, bookmarks[1].num)); - bookmarks[0].obj->SetAt("Type", new CPDF_Name("Outlines")); - bookmarks[0].obj->SetAt("Count", new CPDF_Number(2)); - bookmarks[0].obj->SetAt( + bookmarks[0].obj->SetFor("Type", new CPDF_Name("Outlines")); + bookmarks[0].obj->SetFor("Count", new CPDF_Number(2)); + bookmarks[0].obj->SetFor( "First", new CPDF_Reference(m_pIndirectObjs, bookmarks[1].num)); - bookmarks[0].obj->SetAt( + bookmarks[0].obj->SetFor( "Last", new CPDF_Reference(m_pIndirectObjs, bookmarks[2].num)); - m_pRootObj->SetAt("Outlines", - new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); + m_pRootObj->SetFor("Outlines", + new CPDF_Reference(m_pIndirectObjs, bookmarks[0].num)); // Title with no match. std::unique_ptr<unsigned short, pdfium::FreeDeleter> title = diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp index 0b677be691..e3777d4f84 100644 --- a/fpdfsdk/fpdfeditpage.cpp +++ b/fpdfsdk/fpdfeditpage.cpp @@ -57,7 +57,7 @@ bool IsPageObject(CPDF_Page* pPage) { if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")) return false; - CPDF_Object* pObject = pPage->m_pFormDict->GetObjectBy("Type")->GetDirect(); + CPDF_Object* pObject = pPage->m_pFormDict->GetObjectFor("Type")->GetDirect(); return pObject && !pObject->GetString().Compare("Page"); } @@ -85,8 +85,8 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() { pInfoDict = pDoc->GetInfo(); if (pInfoDict) { if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) - pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr, FALSE)); - pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); + pInfoDict->SetFor("CreationDate", new CPDF_String(DateStr, FALSE)); + pInfoDict->SetFor("Creator", new CPDF_String(L"PDFium")); } return FPDFDocumentFromCPDFDocument(pDoc); @@ -116,9 +116,9 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); - pPageDict->SetAt("MediaBox", pMediaBoxArray); - pPageDict->SetAt("Rotate", new CPDF_Number(0)); - pPageDict->SetAt("Resources", new CPDF_Dictionary); + pPageDict->SetFor("MediaBox", pMediaBoxArray); + pPageDict->SetFor("Rotate", new CPDF_Number(0)); + pPageDict->SetFor("Resources", new CPDF_Dictionary); #ifdef PDF_ENABLE_XFA CPDFXFA_Page* pPage = @@ -140,13 +140,13 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) { CPDF_Dictionary* pDict = pPage->m_pFormDict; while (pDict) { if (pDict->KeyExist("Rotate")) { - CPDF_Object* pRotateObj = pDict->GetObjectBy("Rotate")->GetDirect(); + CPDF_Object* pRotateObj = pDict->GetObjectFor("Rotate")->GetDirect(); return pRotateObj ? pRotateObj->GetInteger() / 90 : 0; } if (!pDict->KeyExist("Parent")) break; - pDict = ToDictionary(pDict->GetObjectBy("Parent")->GetDirect()); + pDict = ToDictionary(pDict->GetObjectFor("Parent")->GetDirect()); } return 0; @@ -294,14 +294,14 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, CFX_Matrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, (FX_FLOAT)e, (FX_FLOAT)f); rect.Transform(&matrix); - CPDF_Array* pRectArray = pAnnot->GetAnnotDict()->GetArrayBy("Rect"); + CPDF_Array* pRectArray = pAnnot->GetAnnotDict()->GetArrayFor("Rect"); if (!pRectArray) pRectArray = new CPDF_Array; pRectArray->SetAt(0, new CPDF_Number(rect.left)); pRectArray->SetAt(1, new CPDF_Number(rect.bottom)); pRectArray->SetAt(2, new CPDF_Number(rect.right)); pRectArray->SetAt(3, new CPDF_Number(rect.top)); - pAnnot->GetAnnotDict()->SetAt("Rect", pRectArray); + pAnnot->GetAnnotDict()->SetFor("Rect", pRectArray); // Transform AP's rectangle // To Do @@ -315,5 +315,5 @@ DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { CPDF_Dictionary* pDict = pPage->m_pFormDict; rotate %= 4; - pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); + pDict->SetFor("Rotate", new CPDF_Number(rotate * 90)); } diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index bf44b5ea55..7e4ce36f5f 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -685,7 +685,7 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, if (!pDic) return; - CPDF_AAction aa(pDic->GetDictBy("AA")); + CPDF_AAction aa(pDic->GetDictFor("AA")); if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) { CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType); CPDFSDK_ActionHandler* pActionHandler = @@ -716,7 +716,7 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, CPDFSDK_Environment* pEnv = pSDKDoc->GetEnv(); CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict; - CPDF_AAction aa(pPageDict->GetDictBy("AA")); + CPDF_AAction aa(pPageDict->GetDictFor("AA")); if (FPDFPAGE_AACTION_OPEN == aaType) { if (aa.ActionExist(CPDF_AAction::OpenPage)) { CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp index 3432fb6e6e..8ed8384c24 100644 --- a/fpdfsdk/fpdfppo.cpp +++ b/fpdfsdk/fpdfppo.cpp @@ -60,33 +60,33 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc, CFX_ByteString producerstr; producerstr.Format("PDFium"); - DInfoDict->SetAt("Producer", new CPDF_String(producerstr, FALSE)); + DInfoDict->SetFor("Producer", new CPDF_String(producerstr, FALSE)); - CFX_ByteString cbRootType = pNewRoot->GetStringBy("Type", ""); + CFX_ByteString cbRootType = pNewRoot->GetStringFor("Type", ""); if (cbRootType.IsEmpty()) - pNewRoot->SetAt("Type", new CPDF_Name("Catalog")); + pNewRoot->SetFor("Type", new CPDF_Name("Catalog")); - CPDF_Object* pElement = pNewRoot->GetObjectBy("Pages"); + CPDF_Object* pElement = pNewRoot->GetObjectFor("Pages"); CPDF_Dictionary* pNewPages = pElement ? ToDictionary(pElement->GetDirect()) : nullptr; if (!pNewPages) { pNewPages = new CPDF_Dictionary; uint32_t NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages); - pNewRoot->SetAt("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON)); + pNewRoot->SetFor("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON)); } - CFX_ByteString cbPageType = pNewPages->GetStringBy("Type", ""); + CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", ""); if (cbPageType == "") { - pNewPages->SetAt("Type", new CPDF_Name("Pages")); + pNewPages->SetFor("Type", new CPDF_Name("Pages")); } - CPDF_Array* pKeysArray = pNewPages->GetArrayBy("Kids"); + CPDF_Array* pKeysArray = pNewPages->GetArrayFor("Kids"); if (!pKeysArray) { CPDF_Array* pNewKids = new CPDF_Array; uint32_t Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids); - pNewPages->SetAt("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum)); - pNewPages->SetAt("Count", new CPDF_Number(0)); + pNewPages->SetFor("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum)); + pNewPages->SetFor("Count", new CPDF_Number(0)); } return TRUE; @@ -111,8 +111,8 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, CPDF_Object* pObj = it.second; if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) { if (pCurPageDict->KeyExist(cbSrcKeyStr)) - pCurPageDict->RemoveAt(cbSrcKeyStr); - pCurPageDict->SetAt(cbSrcKeyStr, pObj->Clone()); + pCurPageDict->RemoveFor(cbSrcKeyStr); + pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone()); } } @@ -126,7 +126,7 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, // if not exists,we take the letter size. pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); if (pInheritable) { - pCurPageDict->SetAt("MediaBox", pInheritable->Clone()); + pCurPageDict->SetFor("MediaBox", pInheritable->Clone()); } else { // Make the default size to be letter size (8.5'x11') CPDF_Array* pArray = new CPDF_Array; @@ -134,10 +134,10 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, pArray->AddNumber(0); pArray->AddNumber(612); pArray->AddNumber(792); - pCurPageDict->SetAt("MediaBox", pArray); + pCurPageDict->SetFor("MediaBox", pArray); } } else { - pCurPageDict->SetAt("MediaBox", pInheritable->Clone()); + pCurPageDict->SetFor("MediaBox", pInheritable->Clone()); } } // 2 Resources //required @@ -145,19 +145,19 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources"); if (!pInheritable) return FALSE; - pCurPageDict->SetAt("Resources", pInheritable->Clone()); + pCurPageDict->SetFor("Resources", pInheritable->Clone()); } // 3 CropBox //Optional if (!pCurPageDict->KeyExist("CropBox")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); if (pInheritable) - pCurPageDict->SetAt("CropBox", pInheritable->Clone()); + pCurPageDict->SetFor("CropBox", pInheritable->Clone()); } // 4 Rotate //Optional if (!pCurPageDict->KeyExist("Rotate")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate"); if (pInheritable) - pCurPageDict->SetAt("Rotate", pInheritable->Clone()); + pCurPageDict->SetFor("Rotate", pInheritable->Clone()); } // Update the reference @@ -181,25 +181,26 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type")) return nullptr; - CPDF_Object* pType = pDict->GetObjectBy("Type")->GetDirect(); + CPDF_Object* pType = pDict->GetObjectFor("Type")->GetDirect(); if (!ToName(pType)) return nullptr; if (pType->GetString().Compare("Page")) return nullptr; - CPDF_Dictionary* pp = ToDictionary(pDict->GetObjectBy("Parent")->GetDirect()); + CPDF_Dictionary* pp = + ToDictionary(pDict->GetObjectFor("Parent")->GetDirect()); if (!pp) return nullptr; if (pDict->KeyExist(bsSrcTag)) - return pDict->GetObjectBy(bsSrcTag); + return pDict->GetObjectFor(bsSrcTag); while (pp) { if (pp->KeyExist(bsSrcTag)) - return pp->GetObjectBy(bsSrcTag); + return pp->GetObjectFor(bsSrcTag); if (!pp->KeyExist("Parent")) break; - pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect()); + pp = ToDictionary(pp->GetObjectFor("Parent")->GetDirect()); } return nullptr; } @@ -228,7 +229,7 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, if (!pNextObj) return FALSE; if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) - pDict->RemoveAt(key); + pDict->RemoveFor(key); } break; } @@ -285,7 +286,7 @@ uint32_t CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc, if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) { if (pDictClone->KeyExist("Type")) { - CFX_ByteString strType = pDictClone->GetStringBy("Type"); + CFX_ByteString strType = pDictClone->GetStringFor("Type"); if (!FXSYS_stricmp(strType.c_str(), "Pages")) { pDictClone->Release(); return 4; @@ -394,7 +395,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, return FALSE; CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot(); - pSrcDict = pSrcDict->GetDictBy("ViewerPreferences"); + pSrcDict = pSrcDict->GetDictFor("ViewerPreferences"); if (!pSrcDict) return FALSE; @@ -402,6 +403,6 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, if (!pDstDict) return FALSE; - pDstDict->SetAt("ViewerPreferences", pSrcDict->CloneDirectObject()); + pDstDict->SetFor("ViewerPreferences", pSrcDict->CloneDirectObject()); return TRUE; } diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index 81cc913004..243ba2a817 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -100,11 +100,11 @@ bool SaveXFADocumentData(CPDFXFA_Document* pDocument, if (!pRoot) return false; - CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); + CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); if (!pAcroForm) return false; - CPDF_Object* pXFA = pAcroForm->GetObjectBy("XFA"); + CPDF_Object* pXFA = pAcroForm->GetObjectFor("XFA"); if (!pXFA) return true; diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 76540fc283..9f3ca0f9e8 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -396,15 +396,15 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, if (!pRoot) return FALSE; - CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); + CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); if (!pAcroForm) return FALSE; - CPDF_Object* pXFA = pAcroForm->GetObjectBy("XFA"); + CPDF_Object* pXFA = pAcroForm->GetObjectFor("XFA"); if (!pXFA) return FALSE; - bool bDynamicXFA = pRoot->GetBooleanBy("NeedsRendering", false); + bool bDynamicXFA = pRoot->GetBooleanFor("NeedsRendering", false); *docType = bDynamicXFA ? DOCTYPE_DYNAMIC_XFA : DOCTYPE_STATIC_XFA; return TRUE; } @@ -519,7 +519,7 @@ DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) { return -1; CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); - return pDict ? pDict->GetIntegerBy("R") : -1; + return pDict ? pDict->GetIntegerFor("R") : -1; } DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) { @@ -991,7 +991,7 @@ DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document) { CPDF_NameTree nameTree(pDoc, "Dests"); pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount(); - CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests"); + CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests"); if (pDest) count += pDest->GetCount(); @@ -1090,7 +1090,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, CPDF_NameTree nameTree(pDoc, "Dests"); int count = nameTree.GetCount(); if (index >= count) { - CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests"); + CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests"); if (!pDest) return nullptr; @@ -1116,7 +1116,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, if (!pDestObj) return nullptr; if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { - pDestObj = pDict->GetArrayBy("D"); + pDestObj = pDict->GetArrayFor("D"); if (!pDestObj) return nullptr; } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 17e94ff8e2..3bf116e64a 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -386,7 +386,7 @@ void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, if (!pInfoDict) return; - CFX_ByteString csTitle = pInfoDict->GetStringBy("Title"); + CFX_ByteString csTitle = pInfoDict->GetStringFor("Title"); wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); csTitle.ReleaseBuffer(csTitle.GetLength()); } @@ -397,7 +397,7 @@ void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc, return; if (CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo()) - pInfoDict->SetAt("Title", new CPDF_String(wsTitle)); + pInfoDict->SetFor("Title", new CPDF_String(wsTitle)); } void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, @@ -447,11 +447,11 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, if (!pRoot) return; - CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); + CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); if (!pAcroForm) return; - CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); + CPDF_Array* pArray = ToArray(pAcroForm->GetObjectFor("XFA")); if (!pArray) return; @@ -748,13 +748,13 @@ FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, return FALSE; } - CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); + CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); if (!pAcroForm) { fileStream.Flush(); return FALSE; } - CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); + CPDF_Array* pArray = ToArray(pAcroForm->GetObjectFor("XFA")); if (!pArray) { fileStream.Flush(); return FALSE; diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index d1b6148776..8935037ec8 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -784,15 +784,16 @@ FX_BOOL Document::info(IJS_Context* cc, if (!pDictionary) return FALSE; - CFX_WideString cwAuthor = pDictionary->GetUnicodeTextBy("Author"); - CFX_WideString cwTitle = pDictionary->GetUnicodeTextBy("Title"); - CFX_WideString cwSubject = pDictionary->GetUnicodeTextBy("Subject"); - CFX_WideString cwKeywords = pDictionary->GetUnicodeTextBy("Keywords"); - CFX_WideString cwCreator = pDictionary->GetUnicodeTextBy("Creator"); - CFX_WideString cwProducer = pDictionary->GetUnicodeTextBy("Producer"); - CFX_WideString cwCreationDate = pDictionary->GetUnicodeTextBy("CreationDate"); - CFX_WideString cwModDate = pDictionary->GetUnicodeTextBy("ModDate"); - CFX_WideString cwTrapped = pDictionary->GetUnicodeTextBy("Trapped"); + CFX_WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author"); + CFX_WideString cwTitle = pDictionary->GetUnicodeTextFor("Title"); + CFX_WideString cwSubject = pDictionary->GetUnicodeTextFor("Subject"); + CFX_WideString cwKeywords = pDictionary->GetUnicodeTextFor("Keywords"); + CFX_WideString cwCreator = pDictionary->GetUnicodeTextFor("Creator"); + CFX_WideString cwProducer = pDictionary->GetUnicodeTextFor("Producer"); + CFX_WideString cwCreationDate = + pDictionary->GetUnicodeTextFor("CreationDate"); + CFX_WideString cwModDate = pDictionary->GetUnicodeTextFor("ModDate"); + CFX_WideString cwTrapped = pDictionary->GetUnicodeTextFor("Trapped"); CJS_Context* pContext = (CJS_Context*)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); @@ -838,7 +839,7 @@ FX_BOOL Document::getPropertyInternal(IJS_Context* cc, return FALSE; if (vp.IsGetting()) { - vp << pDictionary->GetUnicodeTextBy(propName); + vp << pDictionary->GetUnicodeTextFor(propName); } else { if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) { sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION); @@ -846,7 +847,7 @@ FX_BOOL Document::getPropertyInternal(IJS_Context* cc, } CFX_WideString csProperty; vp >> csProperty; - pDictionary->SetAtString(propName, PDF_EncodeText(csProperty)); + pDictionary->SetStringFor(propName, PDF_EncodeText(csProperty)); m_pDocument->SetChangeMark(); } return TRUE; diff --git a/fpdfsdk/pdfwindow/PWL_Icon.cpp b/fpdfsdk/pdfwindow/PWL_Icon.cpp index 6689aa644e..65dde8c76e 100644 --- a/fpdfsdk/pdfwindow/PWL_Icon.cpp +++ b/fpdfsdk/pdfwindow/PWL_Icon.cpp @@ -63,7 +63,7 @@ void CPWL_Image::GetImageSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) { if (m_pPDFStream) { if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) { - CFX_FloatRect rect = pDict->GetRectBy("BBox"); + CFX_FloatRect rect = pDict->GetRectFor("BBox"); fWidth = rect.right - rect.left; fHeight = rect.top - rect.bottom; @@ -74,7 +74,7 @@ void CPWL_Image::GetImageSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) { CFX_Matrix CPWL_Image::GetImageMatrix() { if (m_pPDFStream) { if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) { - return pDict->GetMatrixBy("Matrix"); + return pDict->GetMatrixFor("Matrix"); } } @@ -87,7 +87,7 @@ CFX_ByteString CPWL_Image::GetImageAlias() { if (m_pPDFStream) { if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) { - return pDict->GetStringBy("Name"); + return pDict->GetStringFor("Name"); } } @@ -135,7 +135,7 @@ void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { fLeft = 0.0f; fBottom = 0.0f; CPDF_Array* pA = m_pIconFit->GetDict() - ? m_pIconFit->GetDict()->GetArrayBy("A") + ? m_pIconFit->GetDict()->GetArrayFor("A") : nullptr; if (pA) { size_t dwCount = pA->GetCount(); diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 14c4f2d2b4..48631cd6b6 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -303,11 +303,11 @@ FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { if (!pRoot) return FALSE; - CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); + CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); if (!pAcroForm) return FALSE; - CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectBy("XFA"); + CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectFor("XFA"); if (!pElementXFA) return FALSE; @@ -387,11 +387,11 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, if (!pRoot) return nullptr; - CPDF_Dictionary* pNames = pRoot->GetDictBy("Names"); + CPDF_Dictionary* pNames = pRoot->GetDictFor("Names"); if (!pNames) return nullptr; - CPDF_Dictionary* pXFAImages = pNames->GetDictBy("XFAImages"); + CPDF_Dictionary* pXFAImages = pNames->GetDictFor("XFAImages"); if (!pXFAImages) return nullptr; diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp index d191ce3537..3a478038f6 100644 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -1838,11 +1838,11 @@ CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, return nullptr; } CPDF_Dictionary* pFontSetDict = - pDoc->GetRoot()->GetDictBy("AcroForm")->GetDictBy("DR"); + pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR"); if (!pFontSetDict) { return nullptr; } - pFontSetDict = pFontSetDict->GetDictBy("Font"); + pFontSetDict = pFontSetDict->GetDictFor("Font"); if (!pFontSetDict) { return nullptr; } @@ -1856,7 +1856,7 @@ CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, continue; } CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect()); - if (!pFontDict || pFontDict->GetStringBy("Type") != "Font") { + if (!pFontDict || pFontDict->GetStringFor("Type") != "Font") { return nullptr; } CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 4afcb32e6f..0d735a1b9b 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -5572,8 +5572,8 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), resoveNodeRS, TRUE, szName.IsEmpty()); } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && - GetObjectByName(pThis, argAccessor.get(), - bsAccessorName.AsStringC())) { + GetObjectForName(pThis, argAccessor.get(), + bsAccessorName.AsStringC())) { iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), resoveNodeRS, TRUE, szName.IsEmpty()); } @@ -5710,8 +5710,8 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), resoveNodeRS, FALSE); } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && - GetObjectByName(pThis, argAccessor.get(), - bsAccessorName.AsStringC())) { + GetObjectForName(pThis, argAccessor.get(), + bsAccessorName.AsStringC())) { iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), resoveNodeRS, FALSE); } @@ -6203,7 +6203,7 @@ void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, } // static -FX_BOOL CXFA_FM2JSContext::GetObjectByName( +FX_BOOL CXFA_FM2JSContext::GetObjectForName( CFXJSE_Value* pThis, CFXJSE_Value* accessorValue, const CFX_ByteStringC& szAccessorName) { diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h index 1483cbc707..5f87b60f90 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h @@ -412,9 +412,9 @@ class CXFA_FM2JSContext : public CFXJSE_HostObject { int32_t iIndexValue, bool bIsStar, CFX_ByteString& szSomExp); - static FX_BOOL GetObjectByName(CFXJSE_Value* pThis, - CFXJSE_Value* accessorValue, - const CFX_ByteStringC& szAccessorName); + static FX_BOOL GetObjectForName(CFXJSE_Value* pThis, + CFXJSE_Value* accessorValue, + const CFX_ByteStringC& szAccessorName); static int32_t ResolveObjects(CFXJSE_Value* pThis, CFXJSE_Value* pParentValue, const CFX_ByteStringC& bsSomExp, |