Make CPDF_Dictionary use unique pointers.

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
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index 847adac..c864b82 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -83,11 +83,9 @@
   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 @@
   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 @@
     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 @@
 
   CPDF_Dictionary* pDict = pPage->m_pFormDict;
   rotate %= 4;
-  pDict->SetFor("Rotate", new CPDF_Number(rotate * 90));
+  pDict->SetNewFor<CPDF_Number>("Rotate", rotate * 90);
 }