From 366e1c47335717b73d14b804020291758c8afc38 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Sat, 13 Jun 2015 01:01:06 -0700 Subject: Merge to XFA: Remove unneeded checks in CPDF_DocPageData::GetFontFileStreamAcc(). The input cannot be null. Same for CPDF_Document::LoadFontFile(). Also set the contract for CPDF_Document::LoadFont() and adjust callers accordingly. Also remove unused CPDF_Document::FindFont(). R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1184673002. (cherry picked from commit 1972b16849fedfda675eacd5c8594b54dbd1264d) Review URL: https://codereview.chromium.org/1181393002. --- core/src/fpdfdoc/doc_formcontrol.cpp | 47 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'core/src/fpdfdoc/doc_formcontrol.cpp') diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index bedd301600..7fa17b8ffa 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -286,44 +286,51 @@ CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() return pObj->GetString(); } } + CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { CPDF_DefaultAppearance cDA = GetDefaultAppearance(); CFX_ByteString csFontNameTag; FX_FLOAT fFontSize; cDA.GetFont(csFontNameTag, fFontSize); - if (csFontNameTag.IsEmpty()) { - return NULL; - } + if (csFontNameTag.IsEmpty()) + return nullptr; + CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); - if (pObj != NULL && pObj->GetType() == PDFOBJ_DICTIONARY) { + if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font"); - if (pFonts != NULL) { - CPDF_Dictionary *pElement = pFonts->GetDict(csFontNameTag); - CPDF_Font *pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); - if (pFont != NULL) { - return pFont; + if (pFonts) { + CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag); + if (pElement) { + CPDF_Font* pFont = + m_pField->m_pForm->m_pDocument->LoadFont(pElement); + if (pFont) { + return pFont; + } } } } - CPDF_Font *pFont = m_pField->m_pForm->GetFormFont(csFontNameTag); - if (pFont != NULL) { - return pFont; - } + if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag)) + return pFormFont; + CPDF_Dictionary *pPageDict = m_pWidgetDict->GetDict("P"); pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); - if (pObj != NULL && pObj->GetType() == PDFOBJ_DICTIONARY) { + if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font"); - if (pFonts != NULL) { - CPDF_Dictionary *pElement = pFonts->GetDict(csFontNameTag); - CPDF_Font *pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); - if (pFont != NULL) { - return pFont; + if (pFonts) { + CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag); + if (pElement) { + CPDF_Font* pFont = + m_pField->m_pForm->m_pDocument->LoadFont(pElement); + if (pFont) { + return pFont; + } } } } - return NULL; + return nullptr; } + int CPDF_FormControl::GetControlAlignment() { if (m_pWidgetDict == NULL) { -- cgit v1.2.3