From fb72726e51bfd0c7bfc61c9b354e2b60f46adac5 Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Mon, 11 Jun 2018 18:19:57 +0000 Subject: Implement CPDF_Object::MakeReference method. Change-Id: I153747ef587a184eaef58ff09dbf8f214c9ddfb3 Reviewed-on: https://pdfium-review.googlesource.com/17230 Reviewed-by: Tom Sepez Commit-Queue: Art Snake --- core/fpdfapi/parser/cpdf_document.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'core/fpdfapi/parser/cpdf_document.cpp') diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index 59927bc250..b163cafbbb 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -513,7 +513,7 @@ void CPDF_Document::CreateNewDoc() { pPages->SetNewFor("Type", "Pages"); pPages->SetNewFor("Count", 0); pPages->SetNewFor("Kids"); - m_pRootDict->SetNewFor("Pages", this, pPages->GetObjNum()); + m_pRootDict->SetFor("Pages", pPages->MakeReference(this)); m_pInfoDict = NewIndirect(); } @@ -545,9 +545,8 @@ bool CPDF_Document::InsertDeletePDFPage(CPDF_Dictionary* pPages, continue; } if (bInsert) { - pKidList->InsertNewAt(i, this, pPageDict->GetObjNum()); - pPageDict->SetNewFor("Parent", this, - pPages->GetObjNum()); + pKidList->InsertAt(i, pPageDict->MakeReference(this)); + pPageDict->SetFor("Parent", pPages->MakeReference(this)); } else { pKidList->RemoveAt(i); } @@ -589,9 +588,9 @@ bool CPDF_Document::InsertNewPage(int iPage, CPDF_Dictionary* pPageDict) { CPDF_Array* pPagesList = pPages->GetArrayFor("Kids"); if (!pPagesList) pPagesList = pPages->SetNewFor("Kids"); - pPagesList->AddNew(this, pPageDict->GetObjNum()); + pPagesList->Add(pPageDict->MakeReference(this)); pPages->SetNewFor("Count", nPages + 1); - pPageDict->SetNewFor("Parent", this, pPages->GetObjNum()); + pPageDict->SetFor("Parent", pPages->MakeReference(this)); ResetTraversal(); } else { std::set stack = {pPages}; @@ -647,8 +646,7 @@ size_t CPDF_Document::CalculateEncodingDict(int charset, ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); pArray->AddNew(name.IsEmpty() ? ".notdef" : name); } - pBaseDict->SetNewFor("Encoding", this, - pEncodingDict->GetObjNum()); + pBaseDict->SetFor("Encoding", pEncodingDict->MakeReference(this)); return i; } @@ -715,7 +713,7 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK( pCIDSysInfo->SetNewFor("Supplement", supplement); CPDF_Array* pArray = pBaseDict->SetNewFor("DescendantFonts"); - pArray->AddNew(this, pFontDict->GetObjNum()); + pArray->Add(pFontDict->MakeReference(this)); return pFontDict; } @@ -796,8 +794,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) { CPDF_Dictionary* pFontDesc = ToDictionary(AddIndirectObject( CalculateFontDesc(this, basefont, flags, italicangle, pFont->GetAscent(), pFont->GetDescent(), std::move(pBBox), nStemV))); - pFontDict->SetNewFor("FontDescriptor", this, - pFontDesc->GetObjNum()); + pFontDict->SetFor("FontDescriptor", pFontDesc->MakeReference(this)); return LoadFont(pBaseDict); } @@ -889,9 +886,9 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, CalculateFontDesc(this, basefont, flags, italicangle, ascend, descend, std::move(pBBox), pLogFont->lfWeight / 5); pFontDesc->SetNewFor("CapHeight", capheight); - pFontDict->SetNewFor( - "FontDescriptor", this, - AddIndirectObject(std::move(pFontDesc))->GetObjNum()); + pFontDict->SetFor( + "FontDescriptor", + AddIndirectObject(std::move(pFontDesc))->MakeReference(this)); hFont = SelectObject(hDC, hFont); DeleteObject(hFont); DeleteDC(hDC); -- cgit v1.2.3