summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_textparser.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-26 19:34:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-26 19:34:26 +0000
commitc9171e16d9d4477501d326d8d456fdc03e0f832e (patch)
tree89a91af4803e820b2e7f8c6e9901915c3415d72c /xfa/fxfa/cxfa_textparser.cpp
parentea360af9048e7083107f9e27f8967351df241f70 (diff)
downloadpdfium-c9171e16d9d4477501d326d8d456fdc03e0f832e.tar.xz
Use moar ToXMLElement() in place of static_cast<>.
Introduces checks in a few new places, but mainly just consolidates checking/casting logic. Change-Id: I634a03060d254db099972c6978249992367e146c Reviewed-on: https://pdfium-review.googlesource.com/38900 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_textparser.cpp')
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index f0a6dd2af1..c60b774051 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -276,18 +276,18 @@ bool CXFA_TextParser::TagValidate(const WideString& wsName) const {
std::unique_ptr<CXFA_TextParser::TagProvider> CXFA_TextParser::ParseTagInfo(
CFX_XMLNode* pXMLNode) {
auto tagProvider = pdfium::MakeUnique<TagProvider>();
-
- WideString wsName;
- if (pXMLNode->GetType() == FX_XMLNODE_Element) {
- CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
- wsName = pXMLElement->GetLocalTagName();
+ CFX_XMLElement* pXMLElement = ToXMLElement(pXMLNode);
+ if (pXMLElement) {
+ WideString wsName = pXMLElement->GetLocalTagName();
tagProvider->SetTagName(wsName);
tagProvider->m_bTagAvailable = TagValidate(wsName);
-
WideString wsValue = pXMLElement->GetAttribute(L"style");
if (!wsValue.IsEmpty())
tagProvider->SetAttribute(L"style", wsValue);
- } else if (pXMLNode->GetType() == FX_XMLNODE_Text) {
+
+ return tagProvider;
+ }
+ if (pXMLNode->GetType() == FX_XMLNODE_Text) {
tagProvider->m_bTagAvailable = true;
tagProvider->m_bContent = true;
}
@@ -502,38 +502,38 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
if (!pXMLNode)
return false;
- bool bRet = false;
- if (pXMLNode->GetType() == FX_XMLNODE_Element) {
- CFX_XMLElement* pElement = static_cast<CFX_XMLElement*>(pXMLNode);
- WideString wsAttr = pElement->GetAttribute(L"xfa:embed");
- if (wsAttr.IsEmpty())
- return false;
- if (wsAttr[0] == L'#')
- wsAttr.Delete(0);
-
- WideString ws = pElement->GetAttribute(L"xfa:embedType");
- if (ws.IsEmpty())
- ws = L"som";
- else
- ws.MakeLower();
+ CFX_XMLElement* pElement = ToXMLElement(pXMLNode);
+ if (!pElement)
+ return false;
+
+ WideString wsAttr = pElement->GetAttribute(L"xfa:embed");
+ if (wsAttr.IsEmpty())
+ return false;
- bool bURI = (ws == L"uri");
- if (!bURI && ws != L"som")
- return false;
+ if (wsAttr[0] == L'#')
+ wsAttr.Delete(0);
- ws = pElement->GetAttribute(L"xfa:embedMode");
- if (ws.IsEmpty())
- ws = L"formatted";
- else
- ws.MakeLower();
+ WideString ws = pElement->GetAttribute(L"xfa:embedType");
+ if (ws.IsEmpty())
+ ws = L"som";
+ else
+ ws.MakeLower();
- bool bRaw = (ws == L"raw");
- if (!bRaw && ws != L"formatted")
- return false;
+ bool bURI = (ws == L"uri");
+ if (!bURI && ws != L"som")
+ return false;
- bRet = pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue);
- }
- return bRet;
+ ws = pElement->GetAttribute(L"xfa:embedMode");
+ if (ws.IsEmpty())
+ ws = L"formatted";
+ else
+ ws.MakeLower();
+
+ bool bRaw = (ws == L"raw");
+ if (!bRaw && ws != L"formatted")
+ return false;
+
+ return pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue);
}
CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap(