Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1215)

Unified Diff: fpdfsdk/formfiller/cba_fontmap.cpp

Issue 2510223002: Make CPDF_Dictionary use unique pointers. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/cpdfsdk_widget.cpp ('k') | fpdfsdk/fpdf_flatten.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/formfiller/cba_fontmap.cpp
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index fd9304befc8e478237c6c71d9742f6d91389447e..83e45791e20f7f7a5a4eaa317be4a840829970f3 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());
}
}
}
« no previous file with comments | « fpdfsdk/cpdfsdk_widget.cpp ('k') | fpdfsdk/fpdf_flatten.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698