From 0fc6b25e738c311fd66aa9da8c56de50af5644d5 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Tue, 1 Mar 2016 16:29:41 -0800 Subject: Remove implicit conversions and some cleanup R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1751753002 . --- core/src/fpdfdoc/doc_bookmark.cpp | 17 +++++++++-------- core/src/fpdfdoc/doc_form.cpp | 11 +++++------ core/src/fpdfdoc/doc_formcontrol.cpp | 34 +++++++++++++++++----------------- core/src/fpdfdoc/doc_formfield.cpp | 7 +++---- core/src/fpdfdoc/doc_utils.cpp | 4 +++- 5 files changed, 37 insertions(+), 36 deletions(-) (limited to 'core/src') diff --git a/core/src/fpdfdoc/doc_bookmark.cpp b/core/src/fpdfdoc/doc_bookmark.cpp index 53e90c0ae1..d7e2e2fcab 100644 --- a/core/src/fpdfdoc/doc_bookmark.cpp +++ b/core/src/fpdfdoc/doc_bookmark.cpp @@ -11,23 +11,24 @@ CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( const CPDF_Bookmark& parent) const { - if (!parent.m_pDict) { + if (!parent.GetDict()) { CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDictBy("Outlines"); - if (!pRoot) { + if (!pRoot) return CPDF_Bookmark(); - } return CPDF_Bookmark(pRoot->GetDictBy("First")); } - return CPDF_Bookmark(parent.m_pDict->GetDictBy("First")); + return CPDF_Bookmark(parent.GetDict()->GetDictBy("First")); } + CPDF_Bookmark CPDF_BookmarkTree::GetNextSibling( const CPDF_Bookmark& bookmark) const { - if (!bookmark.m_pDict) { + if (!bookmark.GetDict()) return CPDF_Bookmark(); - } - CPDF_Dictionary* pNext = bookmark.m_pDict->GetDictBy("Next"); - return pNext == bookmark.m_pDict ? CPDF_Bookmark() : CPDF_Bookmark(pNext); + + CPDF_Dictionary* pNext = bookmark.GetDict()->GetDictBy("Next"); + return pNext == bookmark.GetDict() ? CPDF_Bookmark() : CPDF_Bookmark(pNext); } + FX_DWORD CPDF_Bookmark::GetColorRef() const { if (!m_pDict) { return 0; diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 5e333ea025..684d9122ad 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -836,14 +836,13 @@ void CPDF_InterForm::RemoveFormFont(CFX_ByteString csNameTag) { m_bUpdated = TRUE; RemoveInterFormFont(m_pFormDict, csNameTag); } + CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() { - CFX_ByteString csDA; - if (!m_pFormDict) { - return csDA; - } - csDA = m_pFormDict->GetStringBy("DA"); - return csDA; + if (!m_pFormDict) + return CPDF_DefaultAppearance(); + return CPDF_DefaultAppearance(m_pFormDict->GetStringBy("DA")); } + CPDF_Font* CPDF_InterForm::GetDefaultFormFont() { return GetDefaultInterFormFont(m_pFormDict, m_pDocument); } diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index 169e9d73b7..4cfd4527e2 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -246,27 +246,27 @@ CPDF_Action CPDF_FormControl::GetAction() { } return CPDF_Action(pObj->GetDict()); } + CPDF_AAction CPDF_FormControl::GetAdditionalAction() { - if (!m_pWidgetDict) { - return nullptr; - } - if (m_pWidgetDict->KeyExist("AA")) { - return m_pWidgetDict->GetDictBy("AA"); - } + if (!m_pWidgetDict) + return CPDF_AAction(); + + if (m_pWidgetDict->KeyExist("AA")) + return CPDF_AAction(m_pWidgetDict->GetDictBy("AA")); return m_pField->GetAdditionalAction(); } + CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { - if (!m_pWidgetDict) { - return CFX_ByteString(); - } - if (m_pWidgetDict->KeyExist("DA")) { - return m_pWidgetDict->GetStringBy("DA"); - } + if (!m_pWidgetDict) + return CPDF_DefaultAppearance(); + + if (m_pWidgetDict->KeyExist("DA")) + return CPDF_DefaultAppearance(m_pWidgetDict->GetStringBy("DA")); + CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); - if (!pObj) { - return m_pField->m_pForm->GetDefaultAppearance(); - } - return pObj->GetString(); + if (pObj) + return CPDF_DefaultAppearance(pObj->GetString()); + return m_pField->m_pForm->GetDefaultAppearance(); } CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { @@ -421,7 +421,7 @@ CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteStringC& csEntry) const { } CPDF_IconFit CPDF_ApSettings::GetIconFit() const { - return m_pDict ? m_pDict->GetDictBy("IF") : nullptr; + return CPDF_IconFit(m_pDict ? m_pDict->GetDictBy("IF") : nullptr); } int CPDF_ApSettings::GetTextPosition() const { diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 7f85aff4d3..a7cc484361 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -235,13 +235,12 @@ int CPDF_FormField::GetFieldType() { } return FIELDTYPE_UNKNOWN; } + CPDF_AAction CPDF_FormField::GetAdditionalAction() { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA"); - if (!pObj) { - return NULL; - } - return pObj->GetDict(); + return CPDF_AAction(pObj ? pObj->GetDict() : nullptr); } + CFX_WideString CPDF_FormField::GetAlternateName() { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU"); if (!pObj) { diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index db5db4ee89..67a9324251 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -615,17 +615,19 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { } pFonts->RemoveAt(csNameTag); } + CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument) { if (!pFormDict) { return NULL; } - CPDF_DefaultAppearance cDA = pFormDict->GetStringBy("DA"); + CPDF_DefaultAppearance cDA(pFormDict->GetStringBy("DA")); CFX_ByteString csFontNameTag; FX_FLOAT fFontSize; cDA.GetFont(csFontNameTag, fFontSize); return GetInterFormFont(pFormDict, pDocument, csFontNameTag); } + CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { if (!m_pDict) { return Always; -- cgit v1.2.3