From c4a2b7518949df00651aa3513c93079f1968441e Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 7 Apr 2017 13:56:13 -0700 Subject: Cleanup string passing in core/fpdf* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return strings where possible. Add missing consts to strings passed by ref. Convert non-const cases to pointers. Rename a few methods to be clearer. Change-Id: I86569bc1744f539e6dd67fc73649b272c016328c Reviewed-on: https://pdfium-review.googlesource.com/3951 Commit-Queue: Tom Sepez Reviewed-by: Nicolás Peña --- core/fpdfdoc/cpvt_fontmap.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'core/fpdfdoc/cpvt_fontmap.cpp') diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index 283f60011b..17ce673fde 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -25,25 +25,23 @@ CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, CPVT_FontMap::~CPVT_FontMap() {} -void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, - const CPDF_Dictionary* pResDict, - CPDF_Font*& pSysFont, - CFX_ByteString& sSysFontAlias) { +CPDF_Font* CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, + const CPDF_Dictionary* pResDict, + CFX_ByteString* sSysFontAlias) { if (!pDoc || !pResDict) - return; + return nullptr; - CFX_ByteString sFontAlias; CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictFor("AcroForm"); CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias); if (!pPDFFont) - return; + return nullptr; CPDF_Dictionary* pFontList = pResDict->GetDictFor("Font"); - if (pFontList && !pFontList->KeyExist(sSysFontAlias)) { - pFontList->SetNewFor(sSysFontAlias, pDoc, + if (pFontList && !pFontList->KeyExist(*sSysFontAlias)) { + pFontList->SetNewFor(*sSysFontAlias, pDoc, pPDFFont->GetFontDict()->GetObjNum()); } - pSysFont = pPDFFont; + return pPDFFont; } CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) { @@ -52,8 +50,8 @@ CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) { return m_pDefFont; case 1: if (!m_pSysFont) { - GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, - m_sSysFontAlias); + m_pSysFont = + GetAnnotSysPDFFont(m_pDocument, m_pResDict, &m_sSysFontAlias); } return m_pSysFont; default: @@ -67,12 +65,12 @@ CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) { return m_sDefFontAlias; case 1: if (!m_pSysFont) { - GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, - m_sSysFontAlias); + m_pSysFont = + GetAnnotSysPDFFont(m_pDocument, m_pResDict, &m_sSysFontAlias); } return m_sSysFontAlias; default: - return ""; + return CFX_ByteString(); } } -- cgit v1.2.3