diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2018-06-11 18:19:57 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-11 18:19:57 +0000 |
commit | fb72726e51bfd0c7bfc61c9b354e2b60f46adac5 (patch) | |
tree | b2a763c74a07b081a4b176c18c42569e377d6fc8 /core/fpdfapi/parser/cpdf_document.cpp | |
parent | 5e873f5ce8e407c97e966b9708d2560e908112d3 (diff) | |
download | pdfium-fb72726e51bfd0c7bfc61c9b354e2b60f46adac5.tar.xz |
Implement CPDF_Object::MakeReference method.chromium/3456
Change-Id: I153747ef587a184eaef58ff09dbf8f214c9ddfb3
Reviewed-on: https://pdfium-review.googlesource.com/17230
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_document.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
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<CPDF_Name>("Type", "Pages"); pPages->SetNewFor<CPDF_Number>("Count", 0); pPages->SetNewFor<CPDF_Array>("Kids"); - m_pRootDict->SetNewFor<CPDF_Reference>("Pages", this, pPages->GetObjNum()); + m_pRootDict->SetFor("Pages", pPages->MakeReference(this)); m_pInfoDict = NewIndirect<CPDF_Dictionary>(); } @@ -545,9 +545,8 @@ bool CPDF_Document::InsertDeletePDFPage(CPDF_Dictionary* pPages, continue; } if (bInsert) { - pKidList->InsertNewAt<CPDF_Reference>(i, this, pPageDict->GetObjNum()); - pPageDict->SetNewFor<CPDF_Reference>("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<CPDF_Array>("Kids"); - pPagesList->AddNew<CPDF_Reference>(this, pPageDict->GetObjNum()); + pPagesList->Add(pPageDict->MakeReference(this)); pPages->SetNewFor<CPDF_Number>("Count", nPages + 1); - pPageDict->SetNewFor<CPDF_Reference>("Parent", this, pPages->GetObjNum()); + pPageDict->SetFor("Parent", pPages->MakeReference(this)); ResetTraversal(); } else { std::set<CPDF_Dictionary*> stack = {pPages}; @@ -647,8 +646,7 @@ size_t CPDF_Document::CalculateEncodingDict(int charset, ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); pArray->AddNew<CPDF_Name>(name.IsEmpty() ? ".notdef" : name); } - pBaseDict->SetNewFor<CPDF_Reference>("Encoding", this, - pEncodingDict->GetObjNum()); + pBaseDict->SetFor("Encoding", pEncodingDict->MakeReference(this)); return i; } @@ -715,7 +713,7 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK( pCIDSysInfo->SetNewFor<CPDF_Number>("Supplement", supplement); CPDF_Array* pArray = pBaseDict->SetNewFor<CPDF_Array>("DescendantFonts"); - pArray->AddNew<CPDF_Reference>(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<CPDF_Reference>("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<CPDF_Number>("CapHeight", capheight); - pFontDict->SetNewFor<CPDF_Reference>( - "FontDescriptor", this, - AddIndirectObject(std::move(pFontDesc))->GetObjNum()); + pFontDict->SetFor( + "FontDescriptor", + AddIndirectObject(std::move(pFontDesc))->MakeReference(this)); hFont = SelectObject(hDC, hFont); DeleteObject(hFont); DeleteDC(hDC); |