From 0e606b5ecd6e45f74391f110cc1fe0cce0e80c64 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 18 Nov 2016 16:22:41 -0800 Subject: 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 --- fpdfsdk/cpdfsdk_widget.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'fpdfsdk/cpdfsdk_widget.cpp') diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index b1c3379ac9..108690665c 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -8,9 +8,12 @@ #include +#include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_document.h" +#include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfapi/parser/cpdf_stream.h" +#include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfdoc/cpdf_defaultappearance.h" #include "core/fpdfdoc/cpdf_formcontrol.h" #include "core/fpdfdoc/cpdf_formfield.h" @@ -966,21 +969,21 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() { if (pNormalIcon) { if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) { if (pImageDict->GetStringFor("Name").IsEmpty()) - pImageDict->SetStringFor("Name", "ImgA"); + pImageDict->SetNewFor("Name", "ImgA", false); } } if (pRolloverIcon) { if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) { if (pImageDict->GetStringFor("Name").IsEmpty()) - pImageDict->SetStringFor("Name", "ImgB"); + pImageDict->SetNewFor("Name", "ImgB", false); } } if (pDownIcon) { if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { if (pImageDict->GetStringFor("Name").IsEmpty()) - pImageDict->SetStringFor("Name", "ImgC"); + pImageDict->SetNewFor("Name", "ImgC", false); } } @@ -1804,14 +1807,12 @@ void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); - if (!pStreamResList) { - pStreamResList = new CPDF_Dictionary(pDoc->GetByteStringPool()); - pStreamDict->SetFor("Resources", pStreamResList); - } + if (!pStreamResList) + pStreamResList = pStreamDict->SetNewFor("Resources"); - CPDF_Dictionary* pXObject = new CPDF_Dictionary(pDoc->GetByteStringPool()); - pXObject->SetReferenceFor(sImageAlias, pDoc, pImage->GetObjNum()); - pStreamResList->SetFor("XObject", pXObject); + CPDF_Dictionary* pXObject = + pStreamResList->SetNewFor("XObject"); + pXObject->SetNewFor(sImageAlias, pDoc, pImage->GetObjNum()); } void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { -- cgit v1.2.3