summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_transformpage.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-15 11:33:44 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-15 11:33:44 -0800
commit70c4afd5c3c5c44cd24f814423a23a6ef05bba02 (patch)
treecbe593d0b6c0bfc6fd5038bf60a77a94e49c69c9 /fpdfsdk/fpdf_transformpage.cpp
parentf16f6b8b52277348f5d571b7641bb0bbd5239589 (diff)
downloadpdfium-70c4afd5c3c5c44cd24f814423a23a6ef05bba02.tar.xz
Make AddIndirectObject() take a unique_ptr.
Add convenience routines to create and add object in one step. Review-Url: https://codereview.chromium.org/2489283003
Diffstat (limited to 'fpdfsdk/fpdf_transformpage.cpp')
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 63a46dfe7a..76be4de092 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -130,14 +130,13 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
return false;
CPDF_Dictionary* pDic = new CPDF_Dictionary(pDoc->GetByteStringPool());
- CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
+ CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize());
- pDoc->AddIndirectObject(pStream);
+
pDic = new CPDF_Dictionary(pDoc->GetByteStringPool());
- CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic);
+ CPDF_Stream* pEndStream = pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDic);
pEndStream->SetData((const uint8_t*)" Q", 2);
- pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = nullptr;
CPDF_Array* pArray = ToArray(pContentObj);
@@ -156,12 +155,11 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream->GetObjNum());
} else if (pDirectObj->IsStream()) {
- pContentArray = new CPDF_Array();
+ pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
pContentArray->AddReference(pDoc, pEndStream->GetObjNum());
- pPageDic->SetReferenceFor("Contents", pDoc,
- pDoc->AddIndirectObject(pContentArray));
+ pPageDic->SetReferenceFor("Contents", pDoc, pContentArray);
}
}
}
@@ -306,9 +304,8 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
return;
CPDF_Dictionary* pDic = new CPDF_Dictionary(pDoc->GetByteStringPool());
- CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
+ CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDic);
pStream->SetData(strClip.GetBuffer(), strClip.GetSize());
- pDoc->AddIndirectObject(pStream);
CPDF_Array* pContentArray = nullptr;
CPDF_Array* pArray = ToArray(pContentObj);
@@ -325,11 +322,10 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
} else if (pDirectObj->IsStream()) {
- pContentArray = new CPDF_Array();
+ pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
- pPageDic->SetReferenceFor("Contents", pDoc,
- pDoc->AddIndirectObject(pContentArray));
+ pPageDic->SetReferenceFor("Contents", pDoc, pContentArray);
}
}
}