summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-22 15:21:52 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-22 15:21:52 +0000
commitb9509d740966e16a94dc456c634b3f1005e8be95 (patch)
treef6f1834ab3a768579bfe1c60c5bdecf0a6134eda /xfa/fxfa
parent98a245c0d8ee3e403fbb13d90872239948d82abf (diff)
downloadpdfium-b9509d740966e16a94dc456c634b3f1005e8be95.tar.xz
Add GetLowerCaseElementAttributeOrDefault() helper function.
CXFA_TextParser::GetEmbeddedObj() does the same thing twice in a row. Change-Id: Ia46a0a697ff667b2884cea82258399889dbb5dc6 Reviewed-on: https://pdfium-review.googlesource.com/40775 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index b2b47474bf..3084783a83 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -41,6 +41,18 @@ enum class TabStopStatus {
Location,
};
+WideString GetLowerCaseElementAttributeOrDefault(
+ const CFX_XMLElement* pElement,
+ const WideString& wsName,
+ const WideString& wsDefaultValue) {
+ WideString ws = pElement->GetAttribute(wsName);
+ if (ws.IsEmpty())
+ ws = wsDefaultValue;
+ else
+ ws.MakeLower();
+ return ws;
+}
+
} // namespace
CXFA_TextParser::CXFA_TextParser()
@@ -512,19 +524,13 @@ Optional<WideString> CXFA_TextParser::GetEmbeddedObj(
if (wsAttr[0] == L'#')
wsAttr.Delete(0);
- WideString ws = pElement->GetAttribute(L"xfa:embedType");
- if (ws.IsEmpty())
- ws = L"som";
- else
- ws.MakeLower();
+ WideString ws =
+ GetLowerCaseElementAttributeOrDefault(pElement, L"xfa:embedType", L"som");
if (ws != L"uri")
return {};
- ws = pElement->GetAttribute(L"xfa:embedMode");
- if (ws.IsEmpty())
- ws = L"formatted";
- else
- ws.MakeLower();
+ ws = GetLowerCaseElementAttributeOrDefault(pElement, L"xfa:embedMode",
+ L"formatted");
if (ws != L"raw" && ws != L"formatted")
return {};