summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfeditpage.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-18 16:22:41 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-18 16:22:41 -0800
commit0e606b5ecd6e45f74391f110cc1fe0cce0e80c64 (patch)
tree07c55fac710b191cf5d1d6595c63b90ca52e3cbb /fpdfsdk/fpdfeditpage.cpp
parent430ab8363e77c48b2c2435af4d289f85e2be1b96 (diff)
downloadpdfium-0e606b5ecd6e45f74391f110cc1fe0cce0e80c64.tar.xz
Make CPDF_Dictionary use unique pointers.chromium/2926
Some changes were required to match underlying ctors as invoked by the templated methods. Many release() calls go away, a few WrapUniques() are introduced to avoid going deeper into other code. Review-Url: https://codereview.chromium.org/2510223002
Diffstat (limited to 'fpdfsdk/fpdfeditpage.cpp')
-rw-r--r--fpdfsdk/fpdfeditpage.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index 847adac7ec..c864b82145 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -83,11 +83,9 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
CPDF_Dictionary* pInfoDict = nullptr;
pInfoDict = pDoc->GetInfo();
if (pInfoDict) {
- if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) {
- pInfoDict->SetFor("CreationDate",
- new CPDF_String(nullptr, DateStr, false));
- }
- pInfoDict->SetFor("Creator", new CPDF_String(L"PDFium"));
+ if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
+ pInfoDict->SetNewFor<CPDF_String>("CreationDate", DateStr, false);
+ pInfoDict->SetNewFor<CPDF_String>("Creator", L"PDFium");
}
return FPDFDocumentFromCPDFDocument(pDoc);
@@ -111,15 +109,13 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
if (!pPageDict)
return nullptr;
- CPDF_Array* pMediaBoxArray = new CPDF_Array;
+ CPDF_Array* pMediaBoxArray = pPageDict->SetNewFor<CPDF_Array>("MediaBox");
pMediaBoxArray->AddNew<CPDF_Number>(0);
pMediaBoxArray->AddNew<CPDF_Number>(0);
pMediaBoxArray->AddNew<CPDF_Number>(static_cast<FX_FLOAT>(width));
pMediaBoxArray->AddNew<CPDF_Number>(static_cast<FX_FLOAT>(height));
- pPageDict->SetFor("MediaBox", pMediaBoxArray);
- pPageDict->SetFor("Rotate", new CPDF_Number(0));
- pPageDict->SetFor("Resources",
- new CPDF_Dictionary(pDoc->GetByteStringPool()));
+ pPageDict->SetNewFor<CPDF_Number>("Rotate", 0);
+ pPageDict->SetNewFor<CPDF_Dictionary>("Resources");
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pPage =
@@ -296,10 +292,9 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
rect.Transform(&matrix);
CPDF_Array* pRectArray = pAnnot->GetAnnotDict()->GetArrayFor("Rect");
- if (!pRectArray) {
- pRectArray = new CPDF_Array;
- pAnnot->GetAnnotDict()->SetFor("Rect", pRectArray);
- }
+ if (!pRectArray)
+ pRectArray = pAnnot->GetAnnotDict()->SetNewFor<CPDF_Array>("Rect");
+
pRectArray->SetNewAt<CPDF_Number>(0, rect.left);
pRectArray->SetNewAt<CPDF_Number>(1, rect.bottom);
pRectArray->SetNewAt<CPDF_Number>(2, rect.right);
@@ -316,5 +311,5 @@ DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
CPDF_Dictionary* pDict = pPage->m_pFormDict;
rotate %= 4;
- pDict->SetFor("Rotate", new CPDF_Number(rotate * 90));
+ pDict->SetNewFor<CPDF_Number>("Rotate", rotate * 90);
}