From 6aec70bc09cb65b169fe6ca1af65e8929aeea43a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 23 Nov 2017 17:02:23 +0000 Subject: Cleanup CXFA_WidgetData This CL cleans up return values, out-params and changes simple methods to boolean checks where possible in CXFA_WidgetData. Change-Id: I29daa67993730f3e9d61cb6fdf918a886cc9120e Reviewed-on: https://pdfium-review.googlesource.com/19230 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 52 ++++++++++--------------- 1 file changed, 20 insertions(+), 32 deletions(-) (limited to 'xfa/fxfa/parser/xfa_document_datamerger_imp.cpp') diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 2a3494f276..b2df645ebc 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -127,7 +127,6 @@ void CreateDataBinding(CXFA_Node* pFormNode, pFormNode->JSNode()->GetProperty(0, XFA_Element::Value, true)); if (!bDataToForm) { WideString wsValue; - WideString wsFormattedValue; switch (eUIType) { case XFA_Element::ImageEdit: { CXFA_ImageData imageData = defValueData.GetImageData(); @@ -141,9 +140,9 @@ void CreateDataBinding(CXFA_Node* pFormNode, CFX_XMLElement* pXMLDataElement = static_cast(pDataNode->GetXMLMappingNode()); ASSERT(pXMLDataElement); - pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); - pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue, false, - false); + + pDataNode->JSNode()->SetAttributeValue( + wsValue, pWidgetData->GetFormatDataValue(wsValue), false, false); pDataNode->JSNode()->SetCData(XFA_Attribute::ContentType, wsContentType, false, false); if (!wsHref.IsEmpty()) @@ -153,7 +152,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, } case XFA_Element::ChoiceList: wsValue = defValueData.GetChildValueContent(); - if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { + if (pWidgetData->IsChoiceListMultiSelect()) { std::vector wsSelTextArray = pWidgetData->GetSelectedItemsValue(); if (!wsSelTextArray.empty()) { @@ -174,9 +173,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, L"dataGroup"); } } else if (!wsValue.IsEmpty()) { - pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); - pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue, - false, false); + pDataNode->JSNode()->SetAttributeValue( + wsValue, pWidgetData->GetFormatDataValue(wsValue), false, false); } break; case XFA_Element::CheckButton: @@ -184,9 +182,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (wsValue.IsEmpty()) break; - pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); - pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue, false, - false); + pDataNode->JSNode()->SetAttributeValue( + wsValue, pWidgetData->GetFormatDataValue(wsValue), false, false); break; case XFA_Element::ExclGroup: { CXFA_Node* pChecked = nullptr; @@ -214,9 +211,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, WideString wsContent = pText->JSNode()->GetContent(false); if (wsContent == wsValue) { pChecked = pChild; - wsFormattedValue = wsValue; - pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue, - false, false); + pDataNode->JSNode()->SetAttributeValue(wsValue, wsValue, false, + false); pFormNode->JSNode()->SetCData(XFA_Attribute::Value, wsContent, false, false); break; @@ -253,12 +249,9 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (wsValue.IsEmpty()) break; - WideString wsOutput; - pWidgetData->NormalizeNumStr(wsValue, wsOutput); - wsValue = wsOutput; - pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); - pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue, false, - false); + wsValue = pWidgetData->NormalizeNumStr(wsValue); + pDataNode->JSNode()->SetAttributeValue( + wsValue, pWidgetData->GetFormatDataValue(wsValue), false, false); CXFA_Node* pValue = pFormNode->JSNode()->GetProperty(0, XFA_Element::Value, true); FormValueNode_SetChildContent(pValue, wsValue, XFA_Element::Float); @@ -269,18 +262,15 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (wsValue.IsEmpty()) break; - pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); - pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue, false, - false); + pDataNode->JSNode()->SetAttributeValue( + wsValue, pWidgetData->GetFormatDataValue(wsValue), false, false); break; } return; } WideString wsXMLValue = pDataNode->JSNode()->GetContent(false); - - WideString wsNormalizeValue; - pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormalizeValue); + WideString wsNormalizeValue = pWidgetData->GetNormalizeDataValue(wsXMLValue); pDataNode->JSNode()->SetAttributeValue(wsNormalizeValue, wsXMLValue, false, false); @@ -309,7 +299,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, break; } case XFA_Element::ChoiceList: - if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { + if (pWidgetData->IsChoiceListMultiSelect()) { std::vector items = pDataNode->GetNodeList( XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties, XFA_Element::Unknown); @@ -352,11 +342,9 @@ void CreateDataBinding(CXFA_Node* pFormNode, case XFA_Element::NumericEdit: { WideString wsPicture = pWidgetData->GetPictureContent(XFA_VALUEPICTURE_DataBind); - if (wsPicture.IsEmpty()) { - WideString wsOutput; - pWidgetData->NormalizeNumStr(wsNormalizeValue, wsOutput); - wsNormalizeValue = wsOutput; - } + if (wsPicture.IsEmpty()) + wsNormalizeValue = pWidgetData->NormalizeNumStr(wsNormalizeValue); + FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, XFA_Element::Float); break; -- cgit v1.2.3