From c25a4219431c90a95233a08f25eecc921abbf3ed Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 14 Oct 2016 17:45:56 -0700 Subject: Revert "Update CPDF_IndirectObjectHolder APIs for unique objects." This reverts commit 3ba098595ae56b64eacc0c25ab76b89a4d78d920. TBR=thestig@chromium.org,weili@chromium.org Review URL: https://codereview.chromium.org/2424533003 . --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 22 ++++++++++++---------- core/fpdfapi/edit/fpdf_edit_create.cpp | 8 +++++--- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'core/fpdfapi/edit') diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 654b69ec4a..ad1ffaf687 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -52,9 +52,10 @@ void CPDF_PageContentGenerator::GenerateContent() { if (pContent) pPageDict->RemoveFor("Contents"); - CPDF_Stream* pStream = m_pDocument->AddIndirectStream(); + CPDF_Stream* pStream = new CPDF_Stream; pStream->SetData(buf.GetBuffer(), buf.GetLength()); - pPageDict->SetReferenceFor("Contents", m_pDocument, pStream); + pPageDict->SetReferenceFor("Contents", m_pDocument, + m_pDocument->AddIndirectObject(pStream)); } CFX_ByteString CPDF_PageContentGenerator::RealizeResource( @@ -62,9 +63,10 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( const CFX_ByteString& bsType) { if (!m_pPage->m_pResources) { m_pPage->m_pResources = - m_pDocument->AddIndirectDictionary(m_pDocument->GetByteStringPool()); - m_pPage->m_pFormDict->SetReferenceFor("Resources", m_pDocument, - m_pPage->m_pResources); + new CPDF_Dictionary(m_pDocument->GetByteStringPool()); + m_pPage->m_pFormDict->SetReferenceFor( + "Resources", m_pDocument, + m_pDocument->AddIndirectObject(m_pPage->m_pResources)); } CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictFor(bsType); if (!pResList) { @@ -80,9 +82,8 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( } idnum++; } - // TODO(tsepez): check |pResourceObj| ownership. - pResList->SetReferenceFor(name, m_pDocument, m_pDocument->AddIndirectObject( - UniqueObject(pResourceObj))); + pResList->SetReferenceFor(name, m_pDocument, + m_pDocument->AddIndirectObject(pResourceObj)); return name; } @@ -169,7 +170,8 @@ void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { contentStream.LoadAllData(pStream); ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); } - CPDF_Stream* pStream = m_pDocument->AddIndirectStream(); + CPDF_Stream* pStream = new CPDF_Stream; pStream->SetData(buf.GetBuffer(), buf.GetLength()); - m_pPage->m_pFormDict->SetReferenceFor("Contents", m_pDocument, pStream); + m_pPage->m_pFormDict->SetReferenceFor( + "Contents", m_pDocument, m_pDocument->AddIndirectObject(pStream)); } diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp index 5622b1dae7..fae2b14449 100644 --- a/core/fpdfapi/edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/edit/fpdf_edit_create.cpp @@ -1244,10 +1244,12 @@ int32_t CPDF_Creator::WriteOldIndirectObject(uint32_t objnum) { m_ObjectOffset[objnum] = 0; return 0; } - if (WriteIndirectObj(pObj)) + if (WriteIndirectObj(pObj)) { return -1; - if (!bExistInMap) - m_pDocument->DeleteIndirectObject(objnum); + } + if (!bExistInMap) { + m_pDocument->ReleaseIndirectObject(objnum); + } } else { uint8_t* pBuffer; uint32_t size; -- cgit v1.2.3