diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-10-14 17:45:56 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-10-14 17:45:56 -0700 |
commit | c25a4219431c90a95233a08f25eecc921abbf3ed (patch) | |
tree | bd2ad923d527440785c19623fe2d19cc1a70a92d /fpdfsdk/fpdf_flatten.cpp | |
parent | 62f367348ff8ff1e64c6f52c1ee5f77c3a89edc1 (diff) | |
download | pdfium-c25a4219431c90a95233a08f25eecc921abbf3ed.tar.xz |
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 .
Diffstat (limited to 'fpdfsdk/fpdf_flatten.cpp')
-rw-r--r-- | fpdfsdk/fpdf_flatten.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp index 3a1135130e..abfc69b092 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp @@ -186,12 +186,12 @@ CFX_FloatRect CalculateRect(CPDF_RectArray* pRectArray) { uint32_t NewIndirectContentsStream(const CFX_ByteString& key, CPDF_Document* pDocument) { - CPDF_Stream* pNewContents = pDocument->AddIndirectStream( + CPDF_Stream* pNewContents = new CPDF_Stream( nullptr, 0, new CPDF_Dictionary(pDocument->GetByteStringPool())); CFX_ByteString sStream; sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); pNewContents->SetData(sStream.raw_str(), sStream.GetLength()); - return pNewContents->GetObjNum(); + return pDocument->AddIndirectObject(pNewContents); } void SetPageContents(const CFX_ByteString& key, @@ -211,15 +211,17 @@ void SetPageContents(const CFX_ByteString& key, } pPage->ConvertToIndirectObjectFor("Contents", pDocument); if (!pContentsArray) { - pContentsArray = pDocument->AddIndirectArray(); + pContentsArray = new CPDF_Array; CPDF_StreamAcc acc; acc.LoadAllData(pContentsStream); CFX_ByteString sStream = "q\n"; - CFX_ByteString sBody = CFX_ByteString(acc.GetData(), acc.GetSize()); + CFX_ByteString sBody = + CFX_ByteString((const FX_CHAR*)acc.GetData(), acc.GetSize()); sStream = sStream + sBody + "\nQ"; pContentsStream->SetData(sStream.raw_str(), sStream.GetLength()); pContentsArray->AddReference(pDocument, pContentsStream->GetObjNum()); - pPage->SetReferenceFor("Contents", pDocument, pContentsArray); + pPage->SetReferenceFor("Contents", pDocument, + pDocument->AddIndirectObject(pContentsArray)); } if (!key.IsEmpty()) { pContentsArray->AddReference(pDocument, @@ -316,10 +318,10 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { pPageDict->SetFor("Resources", pRes); } - CPDF_Stream* pNewXObject = pDocument->AddIndirectStream( + CPDF_Stream* pNewXObject = new CPDF_Stream( nullptr, 0, new CPDF_Dictionary(pDocument->GetByteStringPool())); - uint32_t dwObjNum = pNewXObject->GetObjNum(); + uint32_t dwObjNum = pDocument->AddIndirectObject(pNewXObject); CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject"); if (!pPageXObject) { pPageXObject = new CPDF_Dictionary(pDocument->GetByteStringPool()); @@ -424,10 +426,8 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { CFX_ByteString sFormName; sFormName.Format("F%d", i); - - // TODO(tsepez): check |pObj| ownership. pXObject->SetReferenceFor(sFormName, pDocument, - pDocument->AddIndirectObject(UniqueObject(pObj))); + pDocument->AddIndirectObject(pObj)); CPDF_StreamAcc acc; acc.LoadAllData(pNewXObject); |