summaryrefslogtreecommitdiff
path: root/fpdfsdk/formfiller
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/formfiller
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/formfiller')
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index fd9304befc..83e45791e2 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -9,6 +9,7 @@
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_document.h"
+#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_simple_parser.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
@@ -119,11 +120,10 @@ CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
CPDF_Font* pFind = nullptr;
for (const auto& it : *pFonts) {
const CFX_ByteString& csKey = it.first;
- CPDF_Object* pObj = it.second;
- if (!pObj)
+ if (!it.second)
continue;
- CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
+ CPDF_Dictionary* pElement = ToDictionary(it.second->GetDirect());
if (!pElement)
continue;
if (pElement->GetStringFor("Type") != "Font")
@@ -154,10 +154,8 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
return;
CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP");
- if (!pAPDict) {
- pAPDict = new CPDF_Dictionary(m_pDocument->GetByteStringPool());
- m_pAnnotDict->SetFor("AP", pAPDict);
- }
+ if (!pAPDict)
+ pAPDict = m_pAnnotDict->SetNewFor<CPDF_Dictionary>("AP");
// to avoid checkbox and radiobutton
CPDF_Object* pObject = pAPDict->GetObjectFor(m_sAPType);
@@ -167,7 +165,8 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType);
if (!pStream) {
pStream = m_pDocument->NewIndirect<CPDF_Stream>();
- pAPDict->SetReferenceFor(m_sAPType, m_pDocument, pStream);
+ pAPDict->SetNewFor<CPDF_Reference>(m_sAPType, m_pDocument,
+ pStream->GetObjNum());
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
@@ -178,18 +177,17 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
if (pStreamDict) {
CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources");
- if (!pStreamResList) {
- pStreamResList = new CPDF_Dictionary(m_pDocument->GetByteStringPool());
- pStreamDict->SetFor("Resources", pStreamResList);
- }
+ if (!pStreamResList)
+ pStreamResList = pStreamDict->SetNewFor<CPDF_Dictionary>("Resources");
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font");
if (!pStreamResFontList) {
pStreamResFontList = m_pDocument->NewIndirect<CPDF_Dictionary>();
- pStreamResList->SetReferenceFor("Font", m_pDocument, pStreamResFontList);
+ pStreamResList->SetNewFor<CPDF_Reference>(
+ "Font", m_pDocument, pStreamResFontList->GetObjNum());
}
if (!pStreamResFontList->KeyExist(sAlias)) {
- pStreamResFontList->SetReferenceFor(sAlias, m_pDocument,
- pFont->GetFontDict()->GetObjNum());
+ pStreamResFontList->SetNewFor<CPDF_Reference>(
+ sAlias, m_pDocument, pFont->GetFontDict()->GetObjNum());
}
}
}