summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_transformpage.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-10-14 16:59:10 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-14 16:59:10 -0700
commit3ba098595ae56b64eacc0c25ab76b89a4d78d920 (patch)
tree5c4db47295ea64cdf236c32ef7d5af5b8e7af232 /fpdfsdk/fpdf_transformpage.cpp
parent1d023881cd53485303c0fcc0b5878e700dc470fd (diff)
downloadpdfium-3ba098595ae56b64eacc0c25ab76b89a4d78d920.tar.xz
Update CPDF_IndirectObjectHolder APIs for unique objects.
Doing so highlights a few places where ownership is dubious. Add convenience functions to return an unowned reference to a newly-created indirect object. Review-Url: https://codereview.chromium.org/2419173002
Diffstat (limited to 'fpdfsdk/fpdf_transformpage.cpp')
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 47b6cec9ea..ce09da32a2 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -129,15 +129,13 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
if (!pDoc)
return FALSE;
- CPDF_Dictionary* pDic = new CPDF_Dictionary(pDoc->GetByteStringPool());
- CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
+ CPDF_Stream* pStream = pDoc->AddIndirectStream(
+ nullptr, 0, new CPDF_Dictionary(pDoc->GetByteStringPool()));
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->AddIndirectStream(
+ nullptr, 0, new CPDF_Dictionary(pDoc->GetByteStringPool()));
pEndStream->SetData((const uint8_t*)" Q", 2);
- pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = nullptr;
CPDF_Array* pArray = ToArray(pContentObj);
@@ -156,12 +154,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->AddIndirectArray();
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);
}
}
}
@@ -305,10 +302,9 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
if (!pDoc)
return;
- CPDF_Dictionary* pDic = new CPDF_Dictionary(pDoc->GetByteStringPool());
- CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
+ CPDF_Stream* pStream = pDoc->AddIndirectStream(
+ nullptr, 0, new CPDF_Dictionary(pDoc->GetByteStringPool()));
pStream->SetData(strClip.GetBuffer(), strClip.GetSize());
- pDoc->AddIndirectObject(pStream);
CPDF_Array* pContentArray = nullptr;
CPDF_Array* pArray = ToArray(pContentObj);
@@ -325,11 +321,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->AddReference(pDoc, pStream->GetObjNum());
- pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
- pPageDic->SetReferenceFor("Contents", pDoc,
- pDoc->AddIndirectObject(pContentArray));
+ pContentArray = pDoc->AddIndirectArray();
+ pContentArray->AddReference(pDoc, pStream);
+ pContentArray->AddReference(pDoc, pDirectObj);
+ pPageDic->SetReferenceFor("Contents", pDoc, pContentArray);
}
}
}