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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 CFX_WideString wsContentType; | 124 CFX_WideString wsContentType; |
125 CFX_WideString wsHref; | 125 CFX_WideString wsHref; |
126 if (image) { | 126 if (image) { |
127 image.GetContent(wsValue); | 127 image.GetContent(wsValue); |
128 image.GetContentType(wsContentType); | 128 image.GetContentType(wsContentType); |
129 image.GetHref(wsHref); | 129 image.GetHref(wsHref); |
130 } | 130 } |
131 CFDE_XMLElement* pXMLDataElement = | 131 CFDE_XMLElement* pXMLDataElement = |
132 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); | 132 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); |
133 FXSYS_assert(pXMLDataElement); | 133 FXSYS_assert(pXMLDataElement); |
134 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 134 pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(), |
| 135 wsFormatedValue); |
135 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 136 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
136 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); | 137 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); |
137 if (!wsHref.IsEmpty()) { | 138 if (!wsHref.IsEmpty()) { |
138 pXMLDataElement->SetString(FX_WSTRC(L"href"), wsHref); | 139 pXMLDataElement->SetString(FX_WSTRC(L"href"), wsHref); |
139 } | 140 } |
140 } break; | 141 } break; |
141 case XFA_ELEMENT_ChoiceList: | 142 case XFA_ELEMENT_ChoiceList: |
142 defValue.GetChildValueContent(wsValue); | 143 defValue.GetChildValueContent(wsValue); |
143 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 144 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
144 CFX_WideStringArray wsSelTextArray; | 145 CFX_WideStringArray wsSelTextArray; |
145 pWidgetData->GetSelectedItemsValue(wsSelTextArray); | 146 pWidgetData->GetSelectedItemsValue(wsSelTextArray); |
146 int32_t iSize = wsSelTextArray.GetSize(); | 147 int32_t iSize = wsSelTextArray.GetSize(); |
147 if (iSize >= 1) { | 148 if (iSize >= 1) { |
148 CXFA_Node* pValue = NULL; | 149 CXFA_Node* pValue = NULL; |
149 for (int32_t i = 0; i < iSize; i++) { | 150 for (int32_t i = 0; i < iSize; i++) { |
150 pValue = pDataNode->CreateSamePacketNode(XFA_ELEMENT_DataValue); | 151 pValue = pDataNode->CreateSamePacketNode(XFA_ELEMENT_DataValue); |
151 pValue->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"value")); | 152 pValue->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"value")); |
152 pValue->CreateXMLMappingNode(); | 153 pValue->CreateXMLMappingNode(); |
153 pDataNode->InsertChild(pValue); | 154 pDataNode->InsertChild(pValue); |
154 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); | 155 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); |
155 } | 156 } |
156 } else { | 157 } else { |
157 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); | 158 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); |
158 FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); | 159 FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); |
159 static_cast<CFDE_XMLElement*>(pXMLNode) | 160 static_cast<CFDE_XMLElement*>(pXMLNode) |
160 ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); | 161 ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); |
161 } | 162 } |
162 } else if (!wsValue.IsEmpty()) { | 163 } else if (!wsValue.IsEmpty()) { |
163 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 164 pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(), |
| 165 wsFormatedValue); |
164 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 166 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
165 } | 167 } |
166 break; | 168 break; |
167 case XFA_ELEMENT_CheckButton: | 169 case XFA_ELEMENT_CheckButton: |
168 defValue.GetChildValueContent(wsValue); | 170 defValue.GetChildValueContent(wsValue); |
169 if (wsValue.IsEmpty()) { | 171 if (wsValue.IsEmpty()) { |
170 break; | 172 break; |
171 } | 173 } |
172 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 174 pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(), |
| 175 wsFormatedValue); |
173 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 176 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
174 break; | 177 break; |
175 case XFA_ELEMENT_ExclGroup: { | 178 case XFA_ELEMENT_ExclGroup: { |
176 CXFA_Node* pChecked = NULL; | 179 CXFA_Node* pChecked = NULL; |
177 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 180 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
178 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 181 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
179 if (pChild->GetClassID() != XFA_ELEMENT_Field) { | 182 if (pChild->GetClassID() != XFA_ELEMENT_Field) { |
180 continue; | 183 continue; |
181 } | 184 } |
182 CXFA_Node* pValue = pChild->GetChild(0, XFA_ELEMENT_Value); | 185 CXFA_Node* pValue = pChild->GetChild(0, XFA_ELEMENT_Value); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 235 } |
233 } break; | 236 } break; |
234 case XFA_ELEMENT_NumericEdit: { | 237 case XFA_ELEMENT_NumericEdit: { |
235 defValue.GetChildValueContent(wsValue); | 238 defValue.GetChildValueContent(wsValue); |
236 if (wsValue.IsEmpty()) { | 239 if (wsValue.IsEmpty()) { |
237 break; | 240 break; |
238 } | 241 } |
239 CFX_WideString wsOutput; | 242 CFX_WideString wsOutput; |
240 pWidgetData->NormalizeNumStr(wsValue, wsOutput); | 243 pWidgetData->NormalizeNumStr(wsValue, wsOutput); |
241 wsValue = wsOutput; | 244 wsValue = wsOutput; |
242 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 245 pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(), |
| 246 wsFormatedValue); |
243 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 247 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
244 CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_ELEMENT_Value); | 248 CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_ELEMENT_Value); |
245 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue, | 249 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue, |
246 XFA_ELEMENT_Float); | 250 XFA_ELEMENT_Float); |
247 } break; | 251 } break; |
248 default: | 252 default: |
249 defValue.GetChildValueContent(wsValue); | 253 defValue.GetChildValueContent(wsValue); |
250 if (wsValue.IsEmpty()) { | 254 if (wsValue.IsEmpty()) { |
251 break; | 255 break; |
252 } | 256 } |
253 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 257 pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(), |
| 258 wsFormatedValue); |
254 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 259 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
255 break; | 260 break; |
256 } | 261 } |
257 } else { | 262 } else { |
258 CFX_WideString wsXMLValue; | 263 CFX_WideString wsXMLValue; |
259 pDataNode->TryContent(wsXMLValue); | 264 pDataNode->TryContent(wsXMLValue); |
260 CFX_WideString wsNormailizeValue; | 265 CFX_WideString wsNormailizeValue; |
261 pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormailizeValue); | 266 pWidgetData->GetNormalizeDataValue(wsXMLValue.AsWideStringC(), |
| 267 wsNormailizeValue); |
262 pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue); | 268 pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue); |
263 switch (eUIType) { | 269 switch (eUIType) { |
264 case XFA_ELEMENT_ImageEdit: { | 270 case XFA_ELEMENT_ImageEdit: { |
265 XFA_DataMerge_FormValueNode_SetChildContent( | 271 XFA_DataMerge_FormValueNode_SetChildContent( |
266 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Image); | 272 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Image); |
267 CXFA_Image image = defValue.GetImage(); | 273 CXFA_Image image = defValue.GetImage(); |
268 if (image) { | 274 if (image) { |
269 CFDE_XMLElement* pXMLDataElement = | 275 CFDE_XMLElement* pXMLDataElement = |
270 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); | 276 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); |
271 FXSYS_assert(pXMLDataElement); | 277 FXSYS_assert(pXMLDataElement); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } else { | 311 } else { |
306 XFA_DataMerge_FormValueNode_SetChildContent( | 312 XFA_DataMerge_FormValueNode_SetChildContent( |
307 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); | 313 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); |
308 } | 314 } |
309 break; | 315 break; |
310 case XFA_ELEMENT_CheckButton: | 316 case XFA_ELEMENT_CheckButton: |
311 XFA_DataMerge_FormValueNode_SetChildContent( | 317 XFA_DataMerge_FormValueNode_SetChildContent( |
312 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); | 318 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); |
313 break; | 319 break; |
314 case XFA_ELEMENT_ExclGroup: { | 320 case XFA_ELEMENT_ExclGroup: { |
315 pWidgetData->SetSelectedMemberByValue(wsNormailizeValue, bNotify, FALSE, | 321 pWidgetData->SetSelectedMemberByValue(wsNormailizeValue.AsWideStringC(), |
316 FALSE); | 322 bNotify, FALSE, FALSE); |
317 } break; | 323 } break; |
318 case XFA_ELEMENT_DateTimeEdit: | 324 case XFA_ELEMENT_DateTimeEdit: |
319 XFA_DataMerge_FormValueNode_SetChildContent( | 325 XFA_DataMerge_FormValueNode_SetChildContent( |
320 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_DateTime); | 326 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_DateTime); |
321 break; | 327 break; |
322 case XFA_ELEMENT_NumericEdit: { | 328 case XFA_ELEMENT_NumericEdit: { |
323 CFX_WideString wsPicture; | 329 CFX_WideString wsPicture; |
324 pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); | 330 pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); |
325 if (wsPicture.IsEmpty()) { | 331 if (wsPicture.IsEmpty()) { |
326 CFX_WideString wsOutput; | 332 CFX_WideString wsOutput; |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 } | 1429 } |
1424 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 1430 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); |
1425 } | 1431 } |
1426 XFA_DataMerge_ClearGlobalBinding(this); | 1432 XFA_DataMerge_ClearGlobalBinding(this); |
1427 if (bDoDataMerge) { | 1433 if (bDoDataMerge) { |
1428 DoDataMerge(); | 1434 DoDataMerge(); |
1429 } | 1435 } |
1430 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); | 1436 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); |
1431 pLayoutProcessor->SetForceReLayout(TRUE); | 1437 pLayoutProcessor->SetForceReLayout(TRUE); |
1432 } | 1438 } |
OLD | NEW |