| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" | 7 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 #include "xfa/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 XFA_Element eType = pFormNode->GetElementType(); | 118 XFA_Element eType = pFormNode->GetElementType(); |
| 119 if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) | 119 if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) |
| 120 return; | 120 return; |
| 121 | 121 |
| 122 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); | 122 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); |
| 123 ASSERT(pWidgetData); | 123 ASSERT(pWidgetData); |
| 124 XFA_Element eUIType = pWidgetData->GetUIType(); | 124 XFA_Element eUIType = pWidgetData->GetUIType(); |
| 125 CXFA_Value defValue(pFormNode->GetProperty(0, XFA_Element::Value)); | 125 CXFA_Value defValue(pFormNode->GetProperty(0, XFA_Element::Value)); |
| 126 if (!bDataToForm) { | 126 if (!bDataToForm) { |
| 127 CFX_WideString wsValue; | 127 CFX_WideString wsValue; |
| 128 CFX_WideString wsFormatedValue; | 128 CFX_WideString wsFormattedValue; |
| 129 switch (eUIType) { | 129 switch (eUIType) { |
| 130 case XFA_Element::ImageEdit: { | 130 case XFA_Element::ImageEdit: { |
| 131 CXFA_Image image = defValue.GetImage(); | 131 CXFA_Image image = defValue.GetImage(); |
| 132 CFX_WideString wsContentType; | 132 CFX_WideString wsContentType; |
| 133 CFX_WideString wsHref; | 133 CFX_WideString wsHref; |
| 134 if (image) { | 134 if (image) { |
| 135 image.GetContent(wsValue); | 135 image.GetContent(wsValue); |
| 136 image.GetContentType(wsContentType); | 136 image.GetContentType(wsContentType); |
| 137 image.GetHref(wsHref); | 137 image.GetHref(wsHref); |
| 138 } | 138 } |
| 139 CFDE_XMLElement* pXMLDataElement = | 139 CFDE_XMLElement* pXMLDataElement = |
| 140 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); | 140 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); |
| 141 ASSERT(pXMLDataElement); | 141 ASSERT(pXMLDataElement); |
| 142 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 142 pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); |
| 143 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 143 pDataNode->SetAttributeValue(wsValue, wsFormattedValue); |
| 144 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); | 144 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); |
| 145 if (!wsHref.IsEmpty()) | 145 if (!wsHref.IsEmpty()) |
| 146 pXMLDataElement->SetString(L"href", wsHref); | 146 pXMLDataElement->SetString(L"href", wsHref); |
| 147 | 147 |
| 148 break; | 148 break; |
| 149 } | 149 } |
| 150 case XFA_Element::ChoiceList: | 150 case XFA_Element::ChoiceList: |
| 151 defValue.GetChildValueContent(wsValue); | 151 defValue.GetChildValueContent(wsValue); |
| 152 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 152 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
| 153 CFX_WideStringArray wsSelTextArray; | 153 CFX_WideStringArray wsSelTextArray; |
| 154 pWidgetData->GetSelectedItemsValue(wsSelTextArray); | 154 pWidgetData->GetSelectedItemsValue(wsSelTextArray); |
| 155 int32_t iSize = wsSelTextArray.GetSize(); | 155 int32_t iSize = wsSelTextArray.GetSize(); |
| 156 if (iSize >= 1) { | 156 if (iSize >= 1) { |
| 157 CXFA_Node* pValue = nullptr; | 157 CXFA_Node* pValue = nullptr; |
| 158 for (int32_t i = 0; i < iSize; i++) { | 158 for (int32_t i = 0; i < iSize; i++) { |
| 159 pValue = pDataNode->CreateSamePacketNode(XFA_Element::DataValue); | 159 pValue = pDataNode->CreateSamePacketNode(XFA_Element::DataValue); |
| 160 pValue->SetCData(XFA_ATTRIBUTE_Name, L"value"); | 160 pValue->SetCData(XFA_ATTRIBUTE_Name, L"value"); |
| 161 pValue->CreateXMLMappingNode(); | 161 pValue->CreateXMLMappingNode(); |
| 162 pDataNode->InsertChild(pValue); | 162 pDataNode->InsertChild(pValue); |
| 163 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); | 163 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); |
| 164 } | 164 } |
| 165 } else { | 165 } else { |
| 166 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); | 166 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); |
| 167 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); | 167 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); |
| 168 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", | 168 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", |
| 169 L"dataGroup"); | 169 L"dataGroup"); |
| 170 } | 170 } |
| 171 } else if (!wsValue.IsEmpty()) { | 171 } else if (!wsValue.IsEmpty()) { |
| 172 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 172 pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); |
| 173 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 173 pDataNode->SetAttributeValue(wsValue, wsFormattedValue); |
| 174 } | 174 } |
| 175 break; | 175 break; |
| 176 case XFA_Element::CheckButton: | 176 case XFA_Element::CheckButton: |
| 177 defValue.GetChildValueContent(wsValue); | 177 defValue.GetChildValueContent(wsValue); |
| 178 if (wsValue.IsEmpty()) | 178 if (wsValue.IsEmpty()) |
| 179 break; | 179 break; |
| 180 | 180 |
| 181 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 181 pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); |
| 182 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 182 pDataNode->SetAttributeValue(wsValue, wsFormattedValue); |
| 183 break; | 183 break; |
| 184 case XFA_Element::ExclGroup: { | 184 case XFA_Element::ExclGroup: { |
| 185 CXFA_Node* pChecked = nullptr; | 185 CXFA_Node* pChecked = nullptr; |
| 186 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 186 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 187 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 187 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 188 if (pChild->GetElementType() != XFA_Element::Field) | 188 if (pChild->GetElementType() != XFA_Element::Field) |
| 189 continue; | 189 continue; |
| 190 | 190 |
| 191 CXFA_Node* pValue = pChild->GetChild(0, XFA_Element::Value); | 191 CXFA_Node* pValue = pChild->GetChild(0, XFA_Element::Value); |
| 192 if (!pValue) | 192 if (!pValue) |
| 193 continue; | 193 continue; |
| 194 | 194 |
| 195 CXFA_Value valueChild(pValue); | 195 CXFA_Value valueChild(pValue); |
| 196 valueChild.GetChildValueContent(wsValue); | 196 valueChild.GetChildValueContent(wsValue); |
| 197 if (wsValue.IsEmpty()) | 197 if (wsValue.IsEmpty()) |
| 198 continue; | 198 continue; |
| 199 | 199 |
| 200 CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); | 200 CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); |
| 201 if (!pItems) | 201 if (!pItems) |
| 202 continue; | 202 continue; |
| 203 | 203 |
| 204 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | 204 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 205 if (!pText) | 205 if (!pText) |
| 206 continue; | 206 continue; |
| 207 | 207 |
| 208 CFX_WideString wsContent; | 208 CFX_WideString wsContent; |
| 209 if (pText->TryContent(wsContent) && (wsContent == wsValue)) { | 209 if (pText->TryContent(wsContent) && (wsContent == wsValue)) { |
| 210 pChecked = pChild; | 210 pChecked = pChild; |
| 211 wsFormatedValue = wsValue; | 211 wsFormattedValue = wsValue; |
| 212 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 212 pDataNode->SetAttributeValue(wsValue, wsFormattedValue); |
| 213 pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); | 213 pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); |
| 214 break; | 214 break; |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 if (!pChecked) | 217 if (!pChecked) |
| 218 break; | 218 break; |
| 219 | 219 |
| 220 pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 220 pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 221 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 221 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 222 if (pChild == pChecked) | 222 if (pChild == pChecked) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 240 break; | 240 break; |
| 241 } | 241 } |
| 242 case XFA_Element::NumericEdit: { | 242 case XFA_Element::NumericEdit: { |
| 243 defValue.GetChildValueContent(wsValue); | 243 defValue.GetChildValueContent(wsValue); |
| 244 if (wsValue.IsEmpty()) | 244 if (wsValue.IsEmpty()) |
| 245 break; | 245 break; |
| 246 | 246 |
| 247 CFX_WideString wsOutput; | 247 CFX_WideString wsOutput; |
| 248 pWidgetData->NormalizeNumStr(wsValue, wsOutput); | 248 pWidgetData->NormalizeNumStr(wsValue, wsOutput); |
| 249 wsValue = wsOutput; | 249 wsValue = wsOutput; |
| 250 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 250 pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); |
| 251 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 251 pDataNode->SetAttributeValue(wsValue, wsFormattedValue); |
| 252 CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_Element::Value); | 252 CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_Element::Value); |
| 253 FormValueNode_SetChildContent(pValue, wsValue, XFA_Element::Float); | 253 FormValueNode_SetChildContent(pValue, wsValue, XFA_Element::Float); |
| 254 break; | 254 break; |
| 255 } | 255 } |
| 256 default: | 256 default: |
| 257 defValue.GetChildValueContent(wsValue); | 257 defValue.GetChildValueContent(wsValue); |
| 258 if (wsValue.IsEmpty()) | 258 if (wsValue.IsEmpty()) |
| 259 break; | 259 break; |
| 260 | 260 |
| 261 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 261 pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); |
| 262 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 262 pDataNode->SetAttributeValue(wsValue, wsFormattedValue); |
| 263 break; | 263 break; |
| 264 } | 264 } |
| 265 return; | 265 return; |
| 266 } | 266 } |
| 267 | 267 |
| 268 CFX_WideString wsXMLValue; | 268 CFX_WideString wsXMLValue; |
| 269 pDataNode->TryContent(wsXMLValue); | 269 pDataNode->TryContent(wsXMLValue); |
| 270 CFX_WideString wsNormalizeValue; | 270 CFX_WideString wsNormalizeValue; |
| 271 pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormalizeValue); | 271 pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormalizeValue); |
| 272 pDataNode->SetAttributeValue(wsNormalizeValue, wsXMLValue); | 272 pDataNode->SetAttributeValue(wsNormalizeValue, wsXMLValue); |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 pFormRoot->RemoveChild(pNode); | 1520 pFormRoot->RemoveChild(pNode); |
| 1521 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); | 1521 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); |
| 1522 } | 1522 } |
| 1523 m_rgGlobalBinding.RemoveAll(); | 1523 m_rgGlobalBinding.RemoveAll(); |
| 1524 if (bDoDataMerge) | 1524 if (bDoDataMerge) |
| 1525 DoDataMerge(); | 1525 DoDataMerge(); |
| 1526 | 1526 |
| 1527 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); | 1527 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); |
| 1528 pLayoutProcessor->SetForceReLayout(TRUE); | 1528 pLayoutProcessor->SetForceReLayout(TRUE); |
| 1529 } | 1529 } |
| OLD | NEW |