diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-16 14:23:07 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-16 14:23:07 +0000 |
commit | 3f9549e7f00b649471c4d658bbfb6bf031b8f53e (patch) | |
tree | da0ec4380365c2b3a42b53c1ba291d7529646bd7 /xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | |
parent | ce7ccd5f638eff42c6c79da682061fa2c39b028f (diff) | |
download | pdfium-3f9549e7f00b649471c4d658bbfb6bf031b8f53e.tar.xz |
Convert TryNamespace to optional
This CL changes CJX_Node::TryNamespace to return a pdfium::Optional
instead of a bool with an out parameter.
Change-Id: I50ccb3544179108d156d763c25e03abab4306c19
Reviewed-on: https://pdfium-review.googlesource.com/18551
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/xfa_document_datamerger_imp.cpp')
-rw-r--r-- | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 4cf7601531..89a6500fa6 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -1052,12 +1052,11 @@ CXFA_Node* MaybeCreateDataNode(CXFA_Document* pDocument, if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) continue; - WideString wsNamespace; - if (!pDDGroupNode->JSNode()->TryNamespace(wsNamespace) || - wsNamespace != L"http://ns.adobe.com/data-description/") { + pdfium::Optional<WideString> ns = pDDGroupNode->JSNode()->TryNamespace(); + if (!ns || *ns != L"http://ns.adobe.com/data-description/") continue; - } } + CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName.AsStringView()); if (!pDDNode) @@ -1231,12 +1230,12 @@ void UpdateDataRelation(CXFA_Node* pDataNode, CXFA_Node* pDataDescriptionNode) { if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) continue; - WideString wsNamespace; - if (!pDDGroupNode->JSNode()->TryNamespace(wsNamespace) || - wsNamespace != L"http://ns.adobe.com/data-description/") { + pdfium::Optional<WideString> ns = + pDDGroupNode->JSNode()->TryNamespace(); + if (!ns || *ns != L"http://ns.adobe.com/data-description/") continue; - } } + CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(dwNameHash); if (!pDDNode) continue; @@ -1398,8 +1397,8 @@ void CXFA_Document::DoDataMerge() { pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode); } CXFA_Node *pDataRoot = nullptr, *pDDRoot = nullptr; - WideString wsDatasetsURI; - pDatasetsRoot->JSNode()->TryNamespace(wsDatasetsURI); + WideString wsDatasetsURI = + pDatasetsRoot->JSNode()->TryNamespace().value_or(WideString()); for (CXFA_Node* pChildNode = pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild); pChildNode; @@ -1407,16 +1406,19 @@ void CXFA_Document::DoDataMerge() { if (pChildNode->GetElementType() != XFA_Element::DataGroup) continue; - WideString wsNamespaceURI; if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) { - if (!pChildNode->JSNode()->TryNamespace(wsNamespaceURI)) + pdfium::Optional<WideString> namespaceURI = + pChildNode->JSNode()->TryNamespace(); + if (!namespaceURI) continue; - if (wsNamespaceURI == L"http://ns.adobe.com/data-description/") + if (*namespaceURI == L"http://ns.adobe.com/data-description/") pDDRoot = pChildNode; } else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) { - if (!pChildNode->JSNode()->TryNamespace(wsNamespaceURI)) + pdfium::Optional<WideString> namespaceURI = + pChildNode->JSNode()->TryNamespace(); + if (!namespaceURI) continue; - if (wsNamespaceURI == wsDatasetsURI) + if (*namespaceURI == wsDatasetsURI) pDataRoot = pChildNode; } if (pDataRoot && pDDRoot) |