diff options
-rw-r--r-- | core/fxcrt/xml/cfx_xmlelement.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textparser.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textparser.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textprovider.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textprovider.h | 4 |
5 files changed, 17 insertions, 19 deletions
diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h index 0d3468aba4..394866042c 100644 --- a/core/fxcrt/xml/cfx_xmlelement.h +++ b/core/fxcrt/xml/cfx_xmlelement.h @@ -60,4 +60,10 @@ inline CFX_XMLElement* ToXMLElement(CFX_XMLNode* pNode) { : nullptr; } +inline const CFX_XMLElement* ToXMLElement(const CFX_XMLNode* pNode) { + return pNode && pNode->GetType() == FX_XMLNODE_Element + ? static_cast<const CFX_XMLElement*>(pNode) + : nullptr; +} + #endif // CORE_FXCRT_XML_CFX_XMLELEMENT_H_ 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<WideString> 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<WideString> 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<WideString> 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<WideString> GetEmbeddedObj(CXFA_TextProvider* pTextProvider, - CFX_XMLNode* pXMLNode); + Optional<WideString> 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<WideString> 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<WideString> GetEmbeddedObj(bool bURI, - bool bRaw, - const WideString& wsAttr); + Optional<WideString> GetEmbeddedObj(const WideString& wsAttr) const; private: CXFA_Node* m_pNode; // Raw, this class owned by tree node. |