Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: fpdfsdk/fpdf_flatten.cpp

Issue 2489283003: Make AddIndirectObject() take a unique_ptr. (Closed)
Patch Set: Address review comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/formfiller/cba_fontmap.cpp ('k') | fpdfsdk/fpdf_transformpage.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdf_flatten.cpp
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index 1b93bb4d882b63ebb282925917af04112f94b3c9..b11e4a621d5099c16f2d1a8041c5a18140f4e736 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -172,12 +172,12 @@ CFX_FloatRect CalculateRect(std::vector<CFX_FloatRect>* pRectArray) {
uint32_t NewIndirectContentsStream(const CFX_ByteString& key,
CPDF_Document* pDocument) {
- CPDF_Stream* pNewContents = new CPDF_Stream(
+ CPDF_Stream* pNewContents = pDocument->NewIndirect<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 pDocument->AddIndirectObject(pNewContents);
+ return pNewContents->GetObjNum();
}
void SetPageContents(const CFX_ByteString& key,
@@ -197,7 +197,7 @@ void SetPageContents(const CFX_ByteString& key,
}
pPage->ConvertToIndirectObjectFor("Contents", pDocument);
if (!pContentsArray) {
- pContentsArray = new CPDF_Array;
+ pContentsArray = pDocument->NewIndirect<CPDF_Array>();
CPDF_StreamAcc acc;
acc.LoadAllData(pContentsStream);
CFX_ByteString sStream = "q\n";
@@ -206,8 +206,7 @@ void SetPageContents(const CFX_ByteString& key,
sStream = sStream + sBody + "\nQ";
pContentsStream->SetData(sStream.raw_str(), sStream.GetLength());
pContentsArray->AddReference(pDocument, pContentsStream->GetObjNum());
- pPage->SetReferenceFor("Contents", pDocument,
- pDocument->AddIndirectObject(pContentsArray));
+ pPage->SetReferenceFor("Contents", pDocument, pContentsArray);
}
if (!key.IsEmpty()) {
pContentsArray->AddReference(pDocument,
@@ -293,10 +292,10 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
pPageDict->SetFor("Resources", pRes);
}
- CPDF_Stream* pNewXObject = new CPDF_Stream(
+ CPDF_Stream* pNewXObject = pDocument->NewIndirect<CPDF_Stream>(
nullptr, 0, new CPDF_Dictionary(pDocument->GetByteStringPool()));
- uint32_t dwObjNum = pDocument->AddIndirectObject(pNewXObject);
+ uint32_t dwObjNum = pNewXObject->GetObjNum();
CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject");
if (!pPageXObject) {
pPageXObject = new CPDF_Dictionary(pDocument->GetByteStringPool());
@@ -383,7 +382,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
if (pObj->IsInline()) {
std::unique_ptr<CPDF_Object> pNew = pObj->Clone();
pObj = pNew.get();
- pDocument->AddIndirectObject(pNew.release());
+ pDocument->AddIndirectObject(std::move(pNew));
}
CPDF_Dictionary* pObjDic = pObj->GetDict();
« no previous file with comments | « fpdfsdk/formfiller/cba_fontmap.cpp ('k') | fpdfsdk/fpdf_transformpage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698