summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-26 15:14:35 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-27 19:53:13 +0000
commit6e72b2ecdb95f000dede3c80e0c32496c0b27a18 (patch)
tree36350bea8b8ee81449693f8667c62fff1cedbcea /core/fpdfdoc
parent827db14d7f3d0085253b686587717361ffbcad1b (diff)
downloadpdfium-6e72b2ecdb95f000dede3c80e0c32496c0b27a18.tar.xz
Remove more |new|s, part 2
Change-Id: I13b43ceafc6a35bcc1e366546a4a408ea01fe4ab Reviewed-on: https://pdfium-review.googlesource.com/4534 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_bookmark.cpp5
-rw-r--r--core/fpdfdoc/cpdf_filespec.cpp7
-rw-r--r--core/fpdfdoc/cpdf_filespec.h6
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp10
4 files changed, 16 insertions, 12 deletions
diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp
index ba1e18c46d..8ca5d128f5 100644
--- a/core/fpdfdoc/cpdf_bookmark.cpp
+++ b/core/fpdfdoc/cpdf_bookmark.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfdoc/cpdf_bookmark.h"
#include <memory>
+#include <vector>
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_string.h"
@@ -44,12 +45,12 @@ CFX_WideString CPDF_Bookmark::GetTitle() const {
if (!len)
return CFX_WideString();
- std::unique_ptr<wchar_t[]> buf(new wchar_t[len]);
+ std::vector<wchar_t> buf(len);
for (int i = 0; i < len; i++) {
wchar_t w = title[i];
buf[i] = w > 0x20 ? w : 0x20;
}
- return CFX_WideString(buf.get(), len);
+ return CFX_WideString(buf.data(), len);
}
CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const {
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index 086515b9a8..7fe8ec8c03 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -112,10 +112,9 @@ bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const {
return true;
}
-CPDF_FileSpec::CPDF_FileSpec(const CFX_WeakPtr<CFX_ByteStringPool>& pPool) {
- m_pObj = new CPDF_Dictionary(pPool);
- m_pObj->AsDictionary()->SetNewFor<CPDF_Name>("Type", "Filespec");
-}
+CPDF_FileSpec::CPDF_FileSpec(CPDF_Object* pObj) : m_pObj(pObj) {}
+
+CPDF_FileSpec::~CPDF_FileSpec() {}
CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) {
if (filepath.GetLength() <= 1)
diff --git a/core/fpdfdoc/cpdf_filespec.h b/core/fpdfdoc/cpdf_filespec.h
index 6266c37a47..ea002f0e22 100644
--- a/core/fpdfdoc/cpdf_filespec.h
+++ b/core/fpdfdoc/cpdf_filespec.h
@@ -15,8 +15,8 @@ class CPDF_Object;
class CPDF_FileSpec {
public:
- explicit CPDF_FileSpec(const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
- explicit CPDF_FileSpec(CPDF_Object* pObj) : m_pObj(pObj) {}
+ explicit CPDF_FileSpec(CPDF_Object* pObj);
+ ~CPDF_FileSpec();
// Convert a platform dependent file name into pdf format.
static CFX_WideString EncodeFileName(const CFX_WideStringC& filepath);
@@ -31,7 +31,7 @@ class CPDF_FileSpec {
void SetFileName(const CFX_WideStringC& wsFileName);
private:
- CPDF_Object* m_pObj;
+ CPDF_Object* const m_pObj; // not owned.
};
#endif // CORE_FPDFDOC_CPDF_FILESPEC_H_
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index dad25aa037..f498617b27 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -23,6 +23,7 @@
#include "core/fxcrt/fx_codepage.h"
#include "core/fxge/cfx_substfont.h"
#include "core/fxge/fx_font.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -633,7 +634,7 @@ uint8_t CPDF_InterForm::GetNativeCharSet() {
CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument)
: m_pDocument(pDocument),
m_pFormDict(nullptr),
- m_pFieldTree(new CFieldTree),
+ m_pFieldTree(pdfium::MakeUnique<CFieldTree>()),
m_pFormNotify(nullptr) {
CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
if (!pRoot)
@@ -1198,9 +1199,12 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
pMainDict->SetNewFor<CPDF_String>("UF", PDF_EncodeText(wsFilePath),
false);
} else {
- CPDF_FileSpec filespec(pDoc->GetByteStringPool());
+ auto pNewDict =
+ pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool());
+ pNewDict->SetNewFor<CPDF_Name>("Type", "Filespec");
+ CPDF_FileSpec filespec(pNewDict.get());
filespec.SetFileName(pdf_path);
- pMainDict->SetFor("F", pdfium::WrapUnique(filespec.GetObj()));
+ pMainDict->SetFor("F", std::move(pNewDict));
}
}