summaryrefslogtreecommitdiff
path: root/fpdfsdk/formfiller/cba_fontmap.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-21 19:10:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-21 19:10:19 -0700
commitbb577af2f17467a55c04fbff21a8f0ec1016601a (patch)
tree5a5321b1aff1bcc6ee6dc19928aa729a4ddc9a3d /fpdfsdk/formfiller/cba_fontmap.cpp
parent7149abce42b211ad3c0eaa39a340825acd41a1ec (diff)
downloadpdfium-bb577af2f17467a55c04fbff21a8f0ec1016601a.tar.xz
Remove some objnum locals with AddIndirectObject
Also, it's idempotent, so simplify some logic in callers to not care if objnum is zero. The alternate forms are rarely used, using the objnum form makes it clear that SetReferenceFor() can't possibly register the object as a side-effect. Review-Url: https://codereview.chromium.org/2361713002
Diffstat (limited to 'fpdfsdk/formfiller/cba_fontmap.cpp')
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index fe690f23d5..04d6a72ec5 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -154,7 +154,6 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
return;
CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP");
-
if (!pAPDict) {
pAPDict = new CPDF_Dictionary;
m_pAnnotDict->SetFor("AP", pAPDict);
@@ -168,12 +167,11 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType);
if (!pStream) {
pStream = new CPDF_Stream;
- int32_t objnum = m_pDocument->AddIndirectObject(pStream);
- pAPDict->SetReferenceFor(m_sAPType, m_pDocument, objnum);
+ pAPDict->SetReferenceFor(m_sAPType, m_pDocument,
+ m_pDocument->AddIndirectObject(pStream));
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
-
if (!pStreamDict) {
pStreamDict = new CPDF_Dictionary;
pStream->InitStream(nullptr, 0, pStreamDict);
@@ -185,17 +183,16 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
pStreamResList = new CPDF_Dictionary();
pStreamDict->SetFor("Resources", pStreamResList);
}
-
- if (pStreamResList) {
- CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font");
- if (!pStreamResFontList) {
- pStreamResFontList = new CPDF_Dictionary;
- int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
- pStreamResList->SetReferenceFor("Font", m_pDocument, objnum);
- }
- if (!pStreamResFontList->KeyExist(sAlias))
- pStreamResFontList->SetReferenceFor(sAlias, m_pDocument,
- pFont->GetFontDict());
+ CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font");
+ if (!pStreamResFontList) {
+ pStreamResFontList = new CPDF_Dictionary;
+ pStreamResList->SetReferenceFor(
+ "Font", m_pDocument,
+ m_pDocument->AddIndirectObject(pStreamResFontList));
+ }
+ if (!pStreamResFontList->KeyExist(sAlias)) {
+ pStreamResFontList->SetReferenceFor(sAlias, m_pDocument,
+ pFont->GetFontDict()->GetObjNum());
}
}
}