summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_widget.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/cpdfsdk_widget.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/cpdfsdk_widget.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp21
1 files changed, 11 insertions, 10 deletions
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 <memory>
+#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<CPDF_String>("Name", "ImgA", false);
}
}
if (pRolloverIcon) {
if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) {
if (pImageDict->GetStringFor("Name").IsEmpty())
- pImageDict->SetStringFor("Name", "ImgB");
+ pImageDict->SetNewFor<CPDF_String>("Name", "ImgB", false);
}
}
if (pDownIcon) {
if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) {
if (pImageDict->GetStringFor("Name").IsEmpty())
- pImageDict->SetStringFor("Name", "ImgC");
+ pImageDict->SetNewFor<CPDF_String>("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<CPDF_Dictionary>("Resources");
- CPDF_Dictionary* pXObject = new CPDF_Dictionary(pDoc->GetByteStringPool());
- pXObject->SetReferenceFor(sImageAlias, pDoc, pImage->GetObjNum());
- pStreamResList->SetFor("XObject", pXObject);
+ CPDF_Dictionary* pXObject =
+ pStreamResList->SetNewFor<CPDF_Dictionary>("XObject");
+ pXObject->SetNewFor<CPDF_Reference>(sImageAlias, pDoc, pImage->GetObjNum());
}
void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) {