From d4f4ce4b9c35db40d2dc3720ba07a83cff1b547d Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 22 Aug 2018 14:38:30 +0000 Subject: Simplify GetEmbeddedObj() methods. Change-Id: I976a8841f1519310cbf934103336dc050a7c293d Reviewed-on: https://pdfium-review.googlesource.com/40773 Reviewed-by: Ryan Harrison Commit-Queue: Ryan Harrison --- xfa/fxfa/cxfa_textparser.cpp | 16 ++++++---------- xfa/fxfa/cxfa_textparser.h | 4 ++-- xfa/fxfa/cxfa_textprovider.cpp | 6 ++---- xfa/fxfa/cxfa_textprovider.h | 4 +--- 4 files changed, 11 insertions(+), 19 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index 0d1c52fab7..b2b47474bf 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -496,12 +496,12 @@ float CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider, } Optional CXFA_TextParser::GetEmbeddedObj( - CXFA_TextProvider* pTextProvider, - CFX_XMLNode* pXMLNode) { + const CXFA_TextProvider* pTextProvider, + const CFX_XMLNode* pXMLNode) { if (!pXMLNode) return {}; - CFX_XMLElement* pElement = ToXMLElement(pXMLNode); + const CFX_XMLElement* pElement = ToXMLElement(pXMLNode); if (!pElement) return {}; @@ -517,9 +517,7 @@ Optional CXFA_TextParser::GetEmbeddedObj( ws = L"som"; else ws.MakeLower(); - - bool bURI = (ws == L"uri"); - if (!bURI && ws != L"som") + if (ws != L"uri") return {}; ws = pElement->GetAttribute(L"xfa:embedMode"); @@ -527,12 +525,10 @@ Optional CXFA_TextParser::GetEmbeddedObj( ws = L"formatted"; else ws.MakeLower(); - - bool bRaw = (ws == L"raw"); - if (!bRaw && ws != L"formatted") + if (ws != L"raw" && ws != L"formatted") return {}; - return pTextProvider->GetEmbeddedObj(bURI, bRaw, wsAttr); + return pTextProvider->GetEmbeddedObj(wsAttr); } CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( diff --git a/xfa/fxfa/cxfa_textparser.h b/xfa/fxfa/cxfa_textparser.h index 591606074e..70c153bfab 100644 --- a/xfa/fxfa/cxfa_textparser.h +++ b/xfa/fxfa/cxfa_textparser.h @@ -80,8 +80,8 @@ class CXFA_TextParser { bool bFirst, float fVerScale) const; - Optional GetEmbeddedObj(CXFA_TextProvider* pTextProvider, - CFX_XMLNode* pXMLNode); + Optional GetEmbeddedObj(const CXFA_TextProvider* pTextProvider, + const CFX_XMLNode* pXMLNode); CXFA_TextParseContext* GetParseContextFromMap(CFX_XMLNode* pXMLNode); protected: diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp index b46bf345f9..53a70a2f65 100644 --- a/xfa/fxfa/cxfa_textprovider.cpp +++ b/xfa/fxfa/cxfa_textprovider.cpp @@ -137,10 +137,8 @@ bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() const { } Optional CXFA_TextProvider::GetEmbeddedObj( - bool bURI, - bool bRaw, - const WideString& wsAttr) { - if (m_eType != XFA_TEXTPROVIDERTYPE_Text || !bURI) + const WideString& wsAttr) const { + if (m_eType != XFA_TEXTPROVIDERTYPE_Text) return {}; CXFA_Node* pParent = m_pNode->GetParent(); diff --git a/xfa/fxfa/cxfa_textprovider.h b/xfa/fxfa/cxfa_textprovider.h index d6f00056f0..eb16fe227b 100644 --- a/xfa/fxfa/cxfa_textprovider.h +++ b/xfa/fxfa/cxfa_textprovider.h @@ -35,9 +35,7 @@ class CXFA_TextProvider { CXFA_Para* GetParaIfExists(); CXFA_Font* GetFontIfExists(); bool IsCheckButtonAndAutoWidth() const; - Optional GetEmbeddedObj(bool bURI, - bool bRaw, - const WideString& wsAttr); + Optional GetEmbeddedObj(const WideString& wsAttr) const; private: CXFA_Node* m_pNode; // Raw, this class owned by tree node. -- cgit v1.2.3