diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-16 13:42:49 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-16 13:42:49 +0000 |
commit | b066704a22ba4f242567f508c12bf2545cbed9e1 (patch) | |
tree | b0ef12e2873bf7018d4b17a41b626428fb789923 /xfa/fxfa/parser/cxfa_imagedata.cpp | |
parent | 4011677aed8b258fcf87cf52b0d541ef04c832ff (diff) | |
download | pdfium-b066704a22ba4f242567f508c12bf2545cbed9e1.tar.xz |
Convert TryCData and TryContent to optionals
This CL changes the TryCData and TryContent to return
pdfium::Optional<WideString> values instead of returning a bool and
taking an out WideString.
Change-Id: I9c9d877803f9f1977191e12d6a907c29784c10b2
Reviewed-on: https://pdfium-review.googlesource.com/18510
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_imagedata.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_imagedata.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/xfa/fxfa/parser/cxfa_imagedata.cpp b/xfa/fxfa/parser/cxfa_imagedata.cpp index 7c5a06541a..2ad891d7ec 100644 --- a/xfa/fxfa/parser/cxfa_imagedata.cpp +++ b/xfa/fxfa/parser/cxfa_imagedata.cpp @@ -16,14 +16,26 @@ int32_t CXFA_ImageData::GetAspect() { } bool CXFA_ImageData::GetContentType(WideString& wsContentType) { - return m_pNode->JSNode()->TryCData(XFA_Attribute::ContentType, wsContentType, - true); + pdfium::Optional<WideString> content = + m_pNode->JSNode()->TryCData(XFA_Attribute::ContentType, true); + if (!content) + return false; + + wsContentType = *content; + return true; } bool CXFA_ImageData::GetHref(WideString& wsHref) { - if (m_bDefValue) - return m_pNode->JSNode()->TryCData(XFA_Attribute::Href, wsHref, true); - return m_pNode->JSNode()->GetAttribute(L"href", wsHref, true); + if (m_bDefValue) { + pdfium::Optional<WideString> ret = + m_pNode->JSNode()->TryCData(XFA_Attribute::Href, true); + if (!ret) + return false; + + wsHref = *ret; + return true; + } + return m_pNode->JSNode()->GetAttribute(XFA_Attribute::Href, wsHref, true); } XFA_ATTRIBUTEENUM CXFA_ImageData::GetTransferEncoding() { @@ -35,7 +47,12 @@ XFA_ATTRIBUTEENUM CXFA_ImageData::GetTransferEncoding() { } bool CXFA_ImageData::GetContent(WideString& wsText) { - return m_pNode->JSNode()->TryContent(wsText, false, true); + pdfium::Optional<WideString> ret = m_pNode->JSNode()->TryContent(false, true); + if (!ret) + return false; + + wsText = *ret; + return true; } bool CXFA_ImageData::SetContentType(const WideString& wsContentType) { |