| Index: fpdfsdk/fpdfppo.cpp
|
| diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
|
| index 915de1ad0730f8726865dbc031c0d55f4912a2f2..4e06856455caa7c432c700f9472c19e4c9f316d3 100644
|
| --- a/fpdfsdk/fpdfppo.cpp
|
| +++ b/fpdfsdk/fpdfppo.cpp
|
| @@ -8,6 +8,7 @@
|
|
|
| #include <map>
|
| #include <memory>
|
| +#include <utility>
|
| #include <vector>
|
|
|
| #include "core/fpdfapi/parser/cpdf_array.h"
|
| @@ -64,7 +65,7 @@ bool CopyInheritable(CPDF_Dictionary* pCurPageDict,
|
| if (!pInheritable)
|
| return false;
|
|
|
| - pCurPageDict->SetFor(key, pInheritable->Clone().release());
|
| + pCurPageDict->SetFor(key, pInheritable->Clone());
|
| return true;
|
| }
|
|
|
| @@ -158,31 +159,30 @@ bool CPDF_PageOrganizer::PDFDocInit() {
|
| if (!pDocInfoDict)
|
| return false;
|
|
|
| - CFX_ByteString producerstr;
|
| - producerstr.Format("PDFium");
|
| - pDocInfoDict->SetFor("Producer",
|
| - new CPDF_String(nullptr, producerstr, false));
|
| + pDocInfoDict->SetNewFor<CPDF_String>("Producer", "PDFium", false);
|
|
|
| CFX_ByteString cbRootType = pNewRoot->GetStringFor("Type", "");
|
| if (cbRootType.IsEmpty())
|
| - pNewRoot->SetFor("Type", new CPDF_Name(nullptr, "Catalog"));
|
| + pNewRoot->SetNewFor<CPDF_Name>("Type", "Catalog");
|
|
|
| CPDF_Object* pElement = pNewRoot->GetObjectFor("Pages");
|
| CPDF_Dictionary* pNewPages =
|
| pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
|
| if (!pNewPages) {
|
| pNewPages = m_pDestPDFDoc->NewIndirect<CPDF_Dictionary>();
|
| - pNewRoot->SetReferenceFor("Pages", m_pDestPDFDoc, pNewPages);
|
| + pNewRoot->SetNewFor<CPDF_Reference>("Pages", m_pDestPDFDoc,
|
| + pNewPages->GetObjNum());
|
| }
|
|
|
| CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", "");
|
| if (cbPageType.IsEmpty())
|
| - pNewPages->SetFor("Type", new CPDF_Name(nullptr, "Pages"));
|
| + pNewPages->SetNewFor<CPDF_Name>("Type", "Pages");
|
|
|
| if (!pNewPages->GetArrayFor("Kids")) {
|
| - pNewPages->SetIntegerFor("Count", 0);
|
| - pNewPages->SetReferenceFor("Kids", m_pDestPDFDoc,
|
| - m_pDestPDFDoc->NewIndirect<CPDF_Array>());
|
| + pNewPages->SetNewFor<CPDF_Number>("Count", 0);
|
| + pNewPages->SetNewFor<CPDF_Reference>(
|
| + "Kids", m_pDestPDFDoc,
|
| + m_pDestPDFDoc->NewIndirect<CPDF_Array>()->GetObjNum());
|
| }
|
|
|
| return true;
|
| @@ -202,11 +202,11 @@ bool CPDF_PageOrganizer::ExportPage(const std::vector<uint16_t>& pageNums,
|
| // Clone the page dictionary
|
| for (const auto& it : *pSrcPageDict) {
|
| const CFX_ByteString& cbSrcKeyStr = it.first;
|
| - CPDF_Object* pObj = it.second;
|
| if (cbSrcKeyStr == "Type" || cbSrcKeyStr == "Parent")
|
| continue;
|
|
|
| - pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone().release());
|
| + CPDF_Object* pObj = it.second.get();
|
| + pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone());
|
| }
|
|
|
| // inheritable item
|
| @@ -217,15 +217,14 @@ bool CPDF_PageOrganizer::ExportPage(const std::vector<uint16_t>& pageNums,
|
| CPDF_Object* pInheritable =
|
| PageDictGetInheritableTag(pSrcPageDict, "CropBox");
|
| if (pInheritable) {
|
| - pCurPageDict->SetFor("MediaBox", pInheritable->Clone().release());
|
| + pCurPageDict->SetFor("MediaBox", pInheritable->Clone());
|
| } else {
|
| // Make the default size to be letter size (8.5'x11')
|
| - CPDF_Array* pArray = new CPDF_Array;
|
| + CPDF_Array* pArray = pCurPageDict->SetNewFor<CPDF_Array>("MediaBox");
|
| pArray->AddNew<CPDF_Number>(0);
|
| pArray->AddNew<CPDF_Number>(0);
|
| pArray->AddNew<CPDF_Number>(612);
|
| pArray->AddNew<CPDF_Number>(792);
|
| - pCurPageDict->SetFor("MediaBox", pArray);
|
| }
|
| }
|
|
|
| @@ -265,7 +264,7 @@ bool CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
|
| auto it = pDict->begin();
|
| while (it != pDict->end()) {
|
| const CFX_ByteString& key = it->first;
|
| - CPDF_Object* pNextObj = it->second;
|
| + CPDF_Object* pNextObj = it->second.get();
|
| ++it;
|
| if (key == "Parent" || key == "Prev" || key == "First")
|
| continue;
|
| @@ -386,7 +385,6 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc,
|
| if (!pDstDict)
|
| return false;
|
|
|
| - pDstDict->SetFor("ViewerPreferences",
|
| - pSrcDict->CloneDirectObject().release());
|
| + pDstDict->SetFor("ViewerPreferences", pSrcDict->CloneDirectObject());
|
| return true;
|
| }
|
|
|