From 4c22dd5690cdec725389055bb7c07c300a4b6fe4 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 3 Apr 2018 19:10:51 +0000 Subject: Use Optional to determine if appearance stream as font This CL changes the CPDF_DefaultAppearance code to remove the HasFont method and change GetFont to return an Optional. This forces all the call sites to verify a font was returned correctly and removes the need for the duplicate appearance stream parsing. Bug: chromium:827430 Change-Id: If09e0a7d3f7dd63ad77b97a5a388127e4a02da61 Reviewed-on: https://pdfium-review.googlesource.com/29610 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- core/fpdfdoc/cpdf_formcontrol.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core/fpdfdoc/cpdf_formcontrol.cpp') diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index 384c35ea12..a78a24db9d 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -277,15 +277,15 @@ CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { float fFontSize; CPDF_DefaultAppearance cDA = GetDefaultAppearance(); - ByteString csFontNameTag = cDA.GetFont(&fFontSize); - if (csFontNameTag.IsEmpty()) + Optional csFontNameTag = cDA.GetFont(&fFontSize); + if (!csFontNameTag || csFontNameTag->IsEmpty()) return nullptr; CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict.Get(), "DR"); if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { CPDF_Dictionary* pFonts = pDict->GetDictFor("Font"); if (pFonts) { - CPDF_Dictionary* pElement = pFonts->GetDictFor(csFontNameTag); + CPDF_Dictionary* pElement = pFonts->GetDictFor(*csFontNameTag); if (pElement) { CPDF_Font* pFont = m_pField->GetForm()->GetDocument()->LoadFont(pElement); @@ -294,7 +294,7 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { } } } - if (CPDF_Font* pFormFont = m_pField->GetForm()->GetFormFont(csFontNameTag)) + if (CPDF_Font* pFormFont = m_pField->GetForm()->GetFormFont(*csFontNameTag)) return pFormFont; CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDictFor("P"); @@ -302,7 +302,7 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { CPDF_Dictionary* pFonts = pDict->GetDictFor("Font"); if (pFonts) { - CPDF_Dictionary* pElement = pFonts->GetDictFor(csFontNameTag); + CPDF_Dictionary* pElement = pFonts->GetDictFor(*csFontNameTag); if (pElement) { CPDF_Font* pFont = m_pField->GetForm()->GetDocument()->LoadFont(pElement); -- cgit v1.2.3