Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: xfa/fxfa/parser/cxfa_widgetdata.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/cxfa_widgetdata.h ('k') | xfa/fxfa/parser/cxfa_xml_parser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/cxfa_widgetdata.h" 7 #include "xfa/fxfa/parser/cxfa_widgetdata.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 #include "xfa/fxbarcode/BC_Library.h" 10 #include "xfa/fxbarcode/BC_Library.h"
11 #include "xfa/fxfa/app/xfa_ffnotify.h" 11 #include "xfa/fxfa/app/xfa_ffnotify.h"
12 #include "xfa/fxfa/parser/cxfa_document.h" 12 #include "xfa/fxfa/parser/cxfa_document.h"
13 #include "xfa/fxfa/parser/cxfa_event.h" 13 #include "xfa/fxfa/parser/cxfa_event.h"
14 #include "xfa/fxfa/parser/cxfa_measurement.h" 14 #include "xfa/fxfa/parser/cxfa_measurement.h"
15 #include "xfa/fxfa/parser/xfa_localevalue.h" 15 #include "xfa/fxfa/parser/xfa_localevalue.h"
16 #include "xfa/fxfa/parser/xfa_object.h" 16 #include "xfa/fxfa/parser/xfa_object.h"
17 17
18 namespace { 18 namespace {
19 19
20 FX_FLOAT GetEdgeThickness(const CXFA_StrokeArray& strokes, 20 FX_FLOAT GetEdgeThickness(const CXFA_StrokeArray& strokes,
21 FX_BOOL b3DStyle, 21 bool b3DStyle,
22 int32_t nIndex) { 22 int32_t nIndex) {
23 FX_FLOAT fThickness = 0; 23 FX_FLOAT fThickness = 0;
24 24
25 if (strokes[nIndex * 2 + 1].GetPresence() == XFA_ATTRIBUTEENUM_Visible) { 25 if (strokes[nIndex * 2 + 1].GetPresence() == XFA_ATTRIBUTEENUM_Visible) {
26 if (nIndex == 0) 26 if (nIndex == 0)
27 fThickness += 2.5f; 27 fThickness += 2.5f;
28 28
29 fThickness += strokes[nIndex * 2 + 1].GetThickness() * (b3DStyle ? 4 : 2); 29 fThickness += strokes[nIndex * 2 + 1].GetThickness() * (b3DStyle ? 4 : 2);
30 } 30 }
31 return fThickness; 31 return fThickness;
32 } 32 }
33 33
34 FX_BOOL SplitDateTime(const CFX_WideString& wsDateTime, 34 bool SplitDateTime(const CFX_WideString& wsDateTime,
35 CFX_WideString& wsDate, 35 CFX_WideString& wsDate,
36 CFX_WideString& wsTime) { 36 CFX_WideString& wsTime) {
37 wsDate = L""; 37 wsDate = L"";
38 wsTime = L""; 38 wsTime = L"";
39 if (wsDateTime.IsEmpty()) 39 if (wsDateTime.IsEmpty())
40 return FALSE; 40 return false;
41 41
42 int nSplitIndex = -1; 42 int nSplitIndex = -1;
43 nSplitIndex = wsDateTime.Find('T'); 43 nSplitIndex = wsDateTime.Find('T');
44 if (nSplitIndex < 0) 44 if (nSplitIndex < 0)
45 nSplitIndex = wsDateTime.Find(' '); 45 nSplitIndex = wsDateTime.Find(' ');
46 if (nSplitIndex < 0) 46 if (nSplitIndex < 0)
47 return FALSE; 47 return false;
48 48
49 wsDate = wsDateTime.Left(nSplitIndex); 49 wsDate = wsDateTime.Left(nSplitIndex);
50 if (!wsDate.IsEmpty()) { 50 if (!wsDate.IsEmpty()) {
51 int32_t iCount = wsDate.GetLength(); 51 int32_t iCount = wsDate.GetLength();
52 int32_t i = 0; 52 int32_t i = 0;
53 for (i = 0; i < iCount; i++) { 53 for (i = 0; i < iCount; i++) {
54 if (wsDate[i] >= '0' && wsDate[i] <= '9') 54 if (wsDate[i] >= '0' && wsDate[i] <= '9')
55 break; 55 break;
56 } 56 }
57 if (i == iCount) 57 if (i == iCount)
58 return FALSE; 58 return false;
59 } 59 }
60 wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); 60 wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1);
61 if (!wsTime.IsEmpty()) { 61 if (!wsTime.IsEmpty()) {
62 int32_t iCount = wsTime.GetLength(); 62 int32_t iCount = wsTime.GetLength();
63 int32_t i = 0; 63 int32_t i = 0;
64 for (i = 0; i < iCount; i++) { 64 for (i = 0; i < iCount; i++) {
65 if (wsTime[i] >= '0' && wsTime[i] <= '9') 65 if (wsTime[i] >= '0' && wsTime[i] <= '9')
66 break; 66 break;
67 } 67 }
68 if (i == iCount) 68 if (i == iCount)
69 return FALSE; 69 return false;
70 } 70 }
71 return TRUE; 71 return true;
72 } 72 }
73 73
74 CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { 74 CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
75 XFA_Element eType = pNode->GetElementType(); 75 XFA_Element eType = pNode->GetElementType();
76 eWidgetType = eType; 76 eWidgetType = eType;
77 if (eType != XFA_Element::Field && eType != XFA_Element::Draw) 77 if (eType != XFA_Element::Field && eType != XFA_Element::Draw)
78 return nullptr; 78 return nullptr;
79 79
80 eWidgetType = XFA_Element::Unknown; 80 eWidgetType = XFA_Element::Unknown;
81 XFA_Element eUIType = XFA_Element::Unknown; 81 XFA_Element eUIType = XFA_Element::Unknown;
82 CXFA_Value defValue(pNode->GetProperty(0, XFA_Element::Value, TRUE)); 82 CXFA_Value defValue(pNode->GetProperty(0, XFA_Element::Value, true));
83 XFA_Element eValueType = defValue.GetChildValueClassID(); 83 XFA_Element eValueType = defValue.GetChildValueClassID();
84 switch (eValueType) { 84 switch (eValueType) {
85 case XFA_Element::Boolean: 85 case XFA_Element::Boolean:
86 eUIType = XFA_Element::CheckButton; 86 eUIType = XFA_Element::CheckButton;
87 break; 87 break;
88 case XFA_Element::Integer: 88 case XFA_Element::Integer:
89 case XFA_Element::Decimal: 89 case XFA_Element::Decimal:
90 case XFA_Element::Float: 90 case XFA_Element::Float:
91 eUIType = XFA_Element::NumericEdit; 91 eUIType = XFA_Element::NumericEdit;
92 break; 92 break;
(...skipping 15 matching lines...) Expand all
108 case XFA_Element::Line: 108 case XFA_Element::Line:
109 case XFA_Element::Rectangle: 109 case XFA_Element::Rectangle:
110 eUIType = XFA_Element::DefaultUi; 110 eUIType = XFA_Element::DefaultUi;
111 eWidgetType = eValueType; 111 eWidgetType = eValueType;
112 break; 112 break;
113 default: 113 default:
114 break; 114 break;
115 } 115 }
116 116
117 CXFA_Node* pUIChild = nullptr; 117 CXFA_Node* pUIChild = nullptr;
118 CXFA_Node* pUI = pNode->GetProperty(0, XFA_Element::Ui, TRUE); 118 CXFA_Node* pUI = pNode->GetProperty(0, XFA_Element::Ui, true);
119 CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild); 119 CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild);
120 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 120 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
121 XFA_Element eChildType = pChild->GetElementType(); 121 XFA_Element eChildType = pChild->GetElementType();
122 if (eChildType == XFA_Element::Extras || 122 if (eChildType == XFA_Element::Extras ||
123 eChildType == XFA_Element::Picture) { 123 eChildType == XFA_Element::Picture) {
124 continue; 124 continue;
125 } 125 }
126 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( 126 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(
127 XFA_Element::Ui, eChildType, XFA_XDPPACKET_Form); 127 XFA_Element::Ui, eChildType, XFA_XDPPACKET_Form);
128 if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { 128 if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) {
(...skipping 24 matching lines...) Expand all
153 eWidgetType = 153 eWidgetType =
154 pUIChild ? pUIChild->GetElementType() 154 pUIChild ? pUIChild->GetElementType()
155 : (eUIType == XFA_Element::Unknown ? XFA_Element::TextEdit 155 : (eUIType == XFA_Element::Unknown ? XFA_Element::TextEdit
156 : eUIType); 156 : eUIType);
157 } 157 }
158 } 158 }
159 159
160 if (!pUIChild) { 160 if (!pUIChild) {
161 if (eUIType == XFA_Element::Unknown) { 161 if (eUIType == XFA_Element::Unknown) {
162 eUIType = XFA_Element::TextEdit; 162 eUIType = XFA_Element::TextEdit;
163 defValue.GetNode()->GetProperty(0, XFA_Element::Text, TRUE); 163 defValue.GetNode()->GetProperty(0, XFA_Element::Text, true);
164 } 164 }
165 return pUI->GetProperty(0, eUIType, TRUE); 165 return pUI->GetProperty(0, eUIType, true);
166 } 166 }
167 167
168 if (eUIType != XFA_Element::Unknown) 168 if (eUIType != XFA_Element::Unknown)
169 return pUIChild; 169 return pUIChild;
170 170
171 switch (pUIChild->GetElementType()) { 171 switch (pUIChild->GetElementType()) {
172 case XFA_Element::CheckButton: { 172 case XFA_Element::CheckButton: {
173 eValueType = XFA_Element::Text; 173 eValueType = XFA_Element::Text;
174 if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items)) { 174 if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items)) {
175 if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown)) 175 if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown))
(...skipping 19 matching lines...) Expand all
195 } 195 }
196 case XFA_Element::Barcode: 196 case XFA_Element::Barcode:
197 case XFA_Element::Button: 197 case XFA_Element::Button:
198 case XFA_Element::PasswordEdit: 198 case XFA_Element::PasswordEdit:
199 case XFA_Element::Signature: 199 case XFA_Element::Signature:
200 case XFA_Element::TextEdit: 200 case XFA_Element::TextEdit:
201 default: 201 default:
202 eValueType = XFA_Element::Text; 202 eValueType = XFA_Element::Text;
203 break; 203 break;
204 } 204 }
205 defValue.GetNode()->GetProperty(0, eValueType, TRUE); 205 defValue.GetNode()->GetProperty(0, eValueType, true);
206 206
207 return pUIChild; 207 return pUIChild;
208 } 208 }
209 209
210 XFA_ATTRIBUTEENUM GetAttributeDefaultValue_Enum(XFA_Element eElement, 210 XFA_ATTRIBUTEENUM GetAttributeDefaultValue_Enum(XFA_Element eElement,
211 XFA_ATTRIBUTE eAttribute, 211 XFA_ATTRIBUTE eAttribute,
212 uint32_t dwPacket) { 212 uint32_t dwPacket) {
213 void* pValue; 213 void* pValue;
214 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 214 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
215 XFA_ATTRIBUTETYPE_Enum, dwPacket)) { 215 XFA_ATTRIBUTETYPE_Enum, dwPacket)) {
216 return (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; 216 return (XFA_ATTRIBUTEENUM)(uintptr_t)pValue;
217 } 217 }
218 return XFA_ATTRIBUTEENUM_Unknown; 218 return XFA_ATTRIBUTEENUM_Unknown;
219 } 219 }
220 220
221 CFX_WideStringC GetAttributeDefaultValue_Cdata(XFA_Element eElement, 221 CFX_WideStringC GetAttributeDefaultValue_Cdata(XFA_Element eElement,
222 XFA_ATTRIBUTE eAttribute, 222 XFA_ATTRIBUTE eAttribute,
223 uint32_t dwPacket) { 223 uint32_t dwPacket) {
224 void* pValue; 224 void* pValue;
225 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 225 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
226 XFA_ATTRIBUTETYPE_Cdata, dwPacket)) { 226 XFA_ATTRIBUTETYPE_Cdata, dwPacket)) {
227 return (const FX_WCHAR*)pValue; 227 return (const FX_WCHAR*)pValue;
228 } 228 }
229 return nullptr; 229 return nullptr;
230 } 230 }
231 231
232 FX_BOOL GetAttributeDefaultValue_Boolean(XFA_Element eElement, 232 bool GetAttributeDefaultValue_Boolean(XFA_Element eElement,
233 XFA_ATTRIBUTE eAttribute, 233 XFA_ATTRIBUTE eAttribute,
234 uint32_t dwPacket) { 234 uint32_t dwPacket) {
235 void* pValue; 235 void* pValue;
236 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, 236 if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
237 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) { 237 XFA_ATTRIBUTETYPE_Boolean, dwPacket)) {
238 return !!pValue; 238 return !!pValue;
239 } 239 }
240 return FALSE; 240 return false;
241 } 241 }
242 242
243 } // namespace 243 } // namespace
244 244
245 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode) 245 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode)
246 : CXFA_Data(pNode), 246 : CXFA_Data(pNode),
247 m_bIsNull(TRUE), 247 m_bIsNull(true),
248 m_bPreNull(TRUE), 248 m_bPreNull(true),
249 m_pUiChildNode(nullptr), 249 m_pUiChildNode(nullptr),
250 m_eUIType(XFA_Element::Unknown) {} 250 m_eUIType(XFA_Element::Unknown) {}
251 251
252 CXFA_Node* CXFA_WidgetData::GetUIChild() { 252 CXFA_Node* CXFA_WidgetData::GetUIChild() {
253 if (m_eUIType == XFA_Element::Unknown) 253 if (m_eUIType == XFA_Element::Unknown)
254 m_pUiChildNode = CreateUIChild(m_pNode, m_eUIType); 254 m_pUiChildNode = CreateUIChild(m_pNode, m_eUIType);
255 255
256 return m_pUiChildNode; 256 return m_pUiChildNode;
257 } 257 }
258 258
259 XFA_Element CXFA_WidgetData::GetUIType() { 259 XFA_Element CXFA_WidgetData::GetUIType() {
260 GetUIChild(); 260 GetUIChild();
261 return m_eUIType; 261 return m_eUIType;
262 } 262 }
263 263
264 CFX_WideString CXFA_WidgetData::GetRawValue() { 264 CFX_WideString CXFA_WidgetData::GetRawValue() {
265 return m_pNode->GetContent(); 265 return m_pNode->GetContent();
266 } 266 }
267 267
268 int32_t CXFA_WidgetData::GetAccess(FX_BOOL bTemplate) { 268 int32_t CXFA_WidgetData::GetAccess(bool bTemplate) {
269 if (bTemplate) { 269 if (bTemplate) {
270 CXFA_Node* pNode = m_pNode->GetTemplateNode(); 270 CXFA_Node* pNode = m_pNode->GetTemplateNode();
271 if (pNode) 271 if (pNode)
272 return pNode->GetEnum(XFA_ATTRIBUTE_Access); 272 return pNode->GetEnum(XFA_ATTRIBUTE_Access);
273 return XFA_ATTRIBUTEENUM_Open; 273 return XFA_ATTRIBUTEENUM_Open;
274 } 274 }
275 CXFA_Node* pNode = m_pNode; 275 CXFA_Node* pNode = m_pNode;
276 while (pNode) { 276 while (pNode) {
277 int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access); 277 int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access);
278 if (iAcc != XFA_ATTRIBUTEENUM_Open) 278 if (iAcc != XFA_ATTRIBUTEENUM_Open)
279 return iAcc; 279 return iAcc;
280 280
281 pNode = 281 pNode =
282 pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); 282 pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
283 } 283 }
284 return XFA_ATTRIBUTEENUM_Open; 284 return XFA_ATTRIBUTEENUM_Open;
285 } 285 }
286 286
287 int32_t CXFA_WidgetData::GetRotate() { 287 int32_t CXFA_WidgetData::GetRotate() {
288 CXFA_Measurement ms; 288 CXFA_Measurement ms;
289 if (!m_pNode->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, FALSE)) 289 if (!m_pNode->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, false))
290 return 0; 290 return 0;
291 291
292 int32_t iRotate = FXSYS_round(ms.GetValue()); 292 int32_t iRotate = FXSYS_round(ms.GetValue());
293 iRotate = XFA_MapRotation(iRotate); 293 iRotate = XFA_MapRotation(iRotate);
294 return iRotate / 90 * 90; 294 return iRotate / 90 * 90;
295 } 295 }
296 296
297 CXFA_Border CXFA_WidgetData::GetBorder(FX_BOOL bModified) { 297 CXFA_Border CXFA_WidgetData::GetBorder(bool bModified) {
298 return CXFA_Border(m_pNode->GetProperty(0, XFA_Element::Border, bModified)); 298 return CXFA_Border(m_pNode->GetProperty(0, XFA_Element::Border, bModified));
299 } 299 }
300 300
301 CXFA_Caption CXFA_WidgetData::GetCaption(FX_BOOL bModified) { 301 CXFA_Caption CXFA_WidgetData::GetCaption(bool bModified) {
302 return CXFA_Caption(m_pNode->GetProperty(0, XFA_Element::Caption, bModified)); 302 return CXFA_Caption(m_pNode->GetProperty(0, XFA_Element::Caption, bModified));
303 } 303 }
304 304
305 CXFA_Font CXFA_WidgetData::GetFont(FX_BOOL bModified) { 305 CXFA_Font CXFA_WidgetData::GetFont(bool bModified) {
306 return CXFA_Font(m_pNode->GetProperty(0, XFA_Element::Font, bModified)); 306 return CXFA_Font(m_pNode->GetProperty(0, XFA_Element::Font, bModified));
307 } 307 }
308 308
309 CXFA_Margin CXFA_WidgetData::GetMargin(FX_BOOL bModified) { 309 CXFA_Margin CXFA_WidgetData::GetMargin(bool bModified) {
310 return CXFA_Margin(m_pNode->GetProperty(0, XFA_Element::Margin, bModified)); 310 return CXFA_Margin(m_pNode->GetProperty(0, XFA_Element::Margin, bModified));
311 } 311 }
312 312
313 CXFA_Para CXFA_WidgetData::GetPara(FX_BOOL bModified) { 313 CXFA_Para CXFA_WidgetData::GetPara(bool bModified) {
314 return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, bModified)); 314 return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, bModified));
315 } 315 }
316 316
317 void CXFA_WidgetData::GetEventList(CXFA_NodeArray& events) { 317 void CXFA_WidgetData::GetEventList(CXFA_NodeArray& events) {
318 m_pNode->GetNodeList(events, 0, XFA_Element::Event); 318 m_pNode->GetNodeList(events, 0, XFA_Element::Event);
319 } 319 }
320 320
321 int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity, 321 int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
322 CXFA_NodeArray& events, 322 CXFA_NodeArray& events,
323 FX_BOOL bIsFormReady) { 323 bool bIsFormReady) {
324 CXFA_NodeArray allEvents; 324 CXFA_NodeArray allEvents;
325 GetEventList(allEvents); 325 GetEventList(allEvents);
326 int32_t iCount = allEvents.GetSize(); 326 int32_t iCount = allEvents.GetSize();
327 for (int32_t i = 0; i < iCount; i++) { 327 for (int32_t i = 0; i < iCount; i++) {
328 CXFA_Event event(allEvents[i]); 328 CXFA_Event event(allEvents[i]);
329 if (event.GetActivity() == iActivity) { 329 if (event.GetActivity() == iActivity) {
330 if (iActivity == XFA_ATTRIBUTEENUM_Ready) { 330 if (iActivity == XFA_ATTRIBUTEENUM_Ready) {
331 CFX_WideStringC wsRef; 331 CFX_WideStringC wsRef;
332 event.GetRef(wsRef); 332 event.GetRef(wsRef);
333 if (bIsFormReady) { 333 if (bIsFormReady) {
334 if (wsRef == CFX_WideStringC(L"$form")) 334 if (wsRef == CFX_WideStringC(L"$form"))
335 events.Add(allEvents[i]); 335 events.Add(allEvents[i]);
336 } else { 336 } else {
337 if (wsRef == CFX_WideStringC(L"$layout")) 337 if (wsRef == CFX_WideStringC(L"$layout"))
338 events.Add(allEvents[i]); 338 events.Add(allEvents[i]);
339 } 339 }
340 } else { 340 } else {
341 events.Add(allEvents[i]); 341 events.Add(allEvents[i]);
342 } 342 }
343 } 343 }
344 } 344 }
345 return events.GetSize(); 345 return events.GetSize();
346 } 346 }
347 347
348 CXFA_Value CXFA_WidgetData::GetDefaultValue(FX_BOOL bModified) { 348 CXFA_Value CXFA_WidgetData::GetDefaultValue(bool bModified) {
349 CXFA_Node* pTemNode = m_pNode->GetTemplateNode(); 349 CXFA_Node* pTemNode = m_pNode->GetTemplateNode();
350 return CXFA_Value( 350 return CXFA_Value(
351 pTemNode ? pTemNode->GetProperty(0, XFA_Element::Value, bModified) 351 pTemNode ? pTemNode->GetProperty(0, XFA_Element::Value, bModified)
352 : nullptr); 352 : nullptr);
353 } 353 }
354 354
355 CXFA_Value CXFA_WidgetData::GetFormValue(FX_BOOL bModified) { 355 CXFA_Value CXFA_WidgetData::GetFormValue(bool bModified) {
356 return CXFA_Value(m_pNode->GetProperty(0, XFA_Element::Value, bModified)); 356 return CXFA_Value(m_pNode->GetProperty(0, XFA_Element::Value, bModified));
357 } 357 }
358 358
359 CXFA_Calculate CXFA_WidgetData::GetCalculate(FX_BOOL bModified) { 359 CXFA_Calculate CXFA_WidgetData::GetCalculate(bool bModified) {
360 return CXFA_Calculate( 360 return CXFA_Calculate(
361 m_pNode->GetProperty(0, XFA_Element::Calculate, bModified)); 361 m_pNode->GetProperty(0, XFA_Element::Calculate, bModified));
362 } 362 }
363 363
364 CXFA_Validate CXFA_WidgetData::GetValidate(FX_BOOL bModified) { 364 CXFA_Validate CXFA_WidgetData::GetValidate(bool bModified) {
365 return CXFA_Validate( 365 return CXFA_Validate(
366 m_pNode->GetProperty(0, XFA_Element::Validate, bModified)); 366 m_pNode->GetProperty(0, XFA_Element::Validate, bModified));
367 } 367 }
368 368
369 CXFA_Bind CXFA_WidgetData::GetBind(FX_BOOL bModified) { 369 CXFA_Bind CXFA_WidgetData::GetBind(bool bModified) {
370 return CXFA_Bind(m_pNode->GetProperty(0, XFA_Element::Bind, bModified)); 370 return CXFA_Bind(m_pNode->GetProperty(0, XFA_Element::Bind, bModified));
371 } 371 }
372 372
373 CXFA_Assist CXFA_WidgetData::GetAssist(FX_BOOL bModified) { 373 CXFA_Assist CXFA_WidgetData::GetAssist(bool bModified) {
374 return CXFA_Assist(m_pNode->GetProperty(0, XFA_Element::Assist, bModified)); 374 return CXFA_Assist(m_pNode->GetProperty(0, XFA_Element::Assist, bModified));
375 } 375 }
376 376
377 FX_BOOL CXFA_WidgetData::GetWidth(FX_FLOAT& fWidth) { 377 bool CXFA_WidgetData::GetWidth(FX_FLOAT& fWidth) {
378 return TryMeasure(XFA_ATTRIBUTE_W, fWidth); 378 return TryMeasure(XFA_ATTRIBUTE_W, fWidth);
379 } 379 }
380 380
381 FX_BOOL CXFA_WidgetData::GetHeight(FX_FLOAT& fHeight) { 381 bool CXFA_WidgetData::GetHeight(FX_FLOAT& fHeight) {
382 return TryMeasure(XFA_ATTRIBUTE_H, fHeight); 382 return TryMeasure(XFA_ATTRIBUTE_H, fHeight);
383 } 383 }
384 384
385 FX_BOOL CXFA_WidgetData::GetMinWidth(FX_FLOAT& fMinWidth) { 385 bool CXFA_WidgetData::GetMinWidth(FX_FLOAT& fMinWidth) {
386 return TryMeasure(XFA_ATTRIBUTE_MinW, fMinWidth); 386 return TryMeasure(XFA_ATTRIBUTE_MinW, fMinWidth);
387 } 387 }
388 388
389 FX_BOOL CXFA_WidgetData::GetMinHeight(FX_FLOAT& fMinHeight) { 389 bool CXFA_WidgetData::GetMinHeight(FX_FLOAT& fMinHeight) {
390 return TryMeasure(XFA_ATTRIBUTE_MinH, fMinHeight); 390 return TryMeasure(XFA_ATTRIBUTE_MinH, fMinHeight);
391 } 391 }
392 392
393 FX_BOOL CXFA_WidgetData::GetMaxWidth(FX_FLOAT& fMaxWidth) { 393 bool CXFA_WidgetData::GetMaxWidth(FX_FLOAT& fMaxWidth) {
394 return TryMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth); 394 return TryMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth);
395 } 395 }
396 396
397 FX_BOOL CXFA_WidgetData::GetMaxHeight(FX_FLOAT& fMaxHeight) { 397 bool CXFA_WidgetData::GetMaxHeight(FX_FLOAT& fMaxHeight) {
398 return TryMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); 398 return TryMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight);
399 } 399 }
400 400
401 CXFA_Border CXFA_WidgetData::GetUIBorder(FX_BOOL bModified) { 401 CXFA_Border CXFA_WidgetData::GetUIBorder(bool bModified) {
402 CXFA_Node* pUIChild = GetUIChild(); 402 CXFA_Node* pUIChild = GetUIChild();
403 return CXFA_Border( 403 return CXFA_Border(
404 pUIChild ? pUIChild->GetProperty(0, XFA_Element::Border, bModified) 404 pUIChild ? pUIChild->GetProperty(0, XFA_Element::Border, bModified)
405 : nullptr); 405 : nullptr);
406 } 406 }
407 407
408 CXFA_Margin CXFA_WidgetData::GetUIMargin(FX_BOOL bModified) { 408 CXFA_Margin CXFA_WidgetData::GetUIMargin(bool bModified) {
409 CXFA_Node* pUIChild = GetUIChild(); 409 CXFA_Node* pUIChild = GetUIChild();
410 return CXFA_Margin( 410 return CXFA_Margin(
411 pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, bModified) 411 pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, bModified)
412 : nullptr); 412 : nullptr);
413 } 413 }
414 414
415 void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) { 415 void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) {
416 rtUIMargin.Reset(); 416 rtUIMargin.Reset();
417 CXFA_Margin mgUI = GetUIMargin(); 417 CXFA_Margin mgUI = GetUIMargin();
418 if (!mgUI) 418 if (!mgUI)
419 return; 419 return;
420 420
421 CXFA_Border border = GetUIBorder(); 421 CXFA_Border border = GetUIBorder();
422 if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible) 422 if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
423 return; 423 return;
424 424
425 FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; 425 FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset;
426 FX_BOOL bLeft = mgUI.GetLeftInset(fLeftInset); 426 bool bLeft = mgUI.GetLeftInset(fLeftInset);
427 FX_BOOL bTop = mgUI.GetTopInset(fTopInset); 427 bool bTop = mgUI.GetTopInset(fTopInset);
428 FX_BOOL bRight = mgUI.GetRightInset(fRightInset); 428 bool bRight = mgUI.GetRightInset(fRightInset);
429 FX_BOOL bBottom = mgUI.GetBottomInset(fBottomInset); 429 bool bBottom = mgUI.GetBottomInset(fBottomInset);
430 if (border) { 430 if (border) {
431 FX_BOOL bVisible = FALSE; 431 bool bVisible = false;
432 FX_FLOAT fThickness = 0; 432 FX_FLOAT fThickness = 0;
433 border.Get3DStyle(bVisible, fThickness); 433 border.Get3DStyle(bVisible, fThickness);
434 if (!bLeft || !bTop || !bRight || !bBottom) { 434 if (!bLeft || !bTop || !bRight || !bBottom) {
435 CXFA_StrokeArray strokes; 435 CXFA_StrokeArray strokes;
436 border.GetStrokes(strokes); 436 border.GetStrokes(strokes);
437 if (!bTop) 437 if (!bTop)
438 fTopInset = GetEdgeThickness(strokes, bVisible, 0); 438 fTopInset = GetEdgeThickness(strokes, bVisible, 0);
439 if (!bRight) 439 if (!bRight)
440 fRightInset = GetEdgeThickness(strokes, bVisible, 1); 440 fRightInset = GetEdgeThickness(strokes, bVisible, 1);
441 if (!bBottom) 441 if (!bBottom)
442 fBottomInset = GetEdgeThickness(strokes, bVisible, 2); 442 fBottomInset = GetEdgeThickness(strokes, bVisible, 2);
443 if (!bLeft) 443 if (!bLeft)
444 fLeftInset = GetEdgeThickness(strokes, bVisible, 3); 444 fLeftInset = GetEdgeThickness(strokes, bVisible, 3);
445 } 445 }
446 } 446 }
447 rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset); 447 rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset);
448 } 448 }
449 449
450 int32_t CXFA_WidgetData::GetButtonHighlight() { 450 int32_t CXFA_WidgetData::GetButtonHighlight() {
451 CXFA_Node* pUIChild = GetUIChild(); 451 CXFA_Node* pUIChild = GetUIChild();
452 if (pUIChild) 452 if (pUIChild)
453 return pUIChild->GetEnum(XFA_ATTRIBUTE_Highlight); 453 return pUIChild->GetEnum(XFA_ATTRIBUTE_Highlight);
454 return GetAttributeDefaultValue_Enum( 454 return GetAttributeDefaultValue_Enum(
455 XFA_Element::Button, XFA_ATTRIBUTE_Highlight, XFA_XDPPACKET_Form); 455 XFA_Element::Button, XFA_ATTRIBUTE_Highlight, XFA_XDPPACKET_Form);
456 } 456 }
457 457
458 FX_BOOL CXFA_WidgetData::GetButtonRollover(CFX_WideString& wsRollover, 458 bool CXFA_WidgetData::GetButtonRollover(CFX_WideString& wsRollover,
459 FX_BOOL& bRichText) { 459 bool& bRichText) {
460 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items)) { 460 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items)) {
461 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 461 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
462 while (pText) { 462 while (pText) {
463 CFX_WideStringC wsName; 463 CFX_WideStringC wsName;
464 pText->TryCData(XFA_ATTRIBUTE_Name, wsName); 464 pText->TryCData(XFA_ATTRIBUTE_Name, wsName);
465 if (wsName == FX_WSTRC(L"rollover")) { 465 if (wsName == FX_WSTRC(L"rollover")) {
466 pText->TryContent(wsRollover); 466 pText->TryContent(wsRollover);
467 bRichText = pText->GetElementType() == XFA_Element::ExData; 467 bRichText = pText->GetElementType() == XFA_Element::ExData;
468 return !wsRollover.IsEmpty(); 468 return !wsRollover.IsEmpty();
469 } 469 }
470 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); 470 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
471 } 471 }
472 } 472 }
473 return FALSE; 473 return false;
474 } 474 }
475 475
476 FX_BOOL CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown, 476 bool CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown, bool& bRichText) {
477 FX_BOOL& bRichText) {
478 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items)) { 477 if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items)) {
479 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 478 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
480 while (pText) { 479 while (pText) {
481 CFX_WideStringC wsName; 480 CFX_WideStringC wsName;
482 pText->TryCData(XFA_ATTRIBUTE_Name, wsName); 481 pText->TryCData(XFA_ATTRIBUTE_Name, wsName);
483 if (wsName == FX_WSTRC(L"down")) { 482 if (wsName == FX_WSTRC(L"down")) {
484 pText->TryContent(wsDown); 483 pText->TryContent(wsDown);
485 bRichText = pText->GetElementType() == XFA_Element::ExData; 484 bRichText = pText->GetElementType() == XFA_Element::ExData;
486 return !wsDown.IsEmpty(); 485 return !wsDown.IsEmpty();
487 } 486 }
488 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); 487 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
489 } 488 }
490 } 489 }
491 return FALSE; 490 return false;
492 } 491 }
493 492
494 int32_t CXFA_WidgetData::GetCheckButtonShape() { 493 int32_t CXFA_WidgetData::GetCheckButtonShape() {
495 CXFA_Node* pUIChild = GetUIChild(); 494 CXFA_Node* pUIChild = GetUIChild();
496 if (pUIChild) 495 if (pUIChild)
497 return pUIChild->GetEnum(XFA_ATTRIBUTE_Shape); 496 return pUIChild->GetEnum(XFA_ATTRIBUTE_Shape);
498 return GetAttributeDefaultValue_Enum(XFA_Element::CheckButton, 497 return GetAttributeDefaultValue_Enum(XFA_Element::CheckButton,
499 XFA_ATTRIBUTE_Shape, XFA_XDPPACKET_Form); 498 XFA_ATTRIBUTE_Shape, XFA_XDPPACKET_Form);
500 } 499 }
501 500
502 int32_t CXFA_WidgetData::GetCheckButtonMark() { 501 int32_t CXFA_WidgetData::GetCheckButtonMark() {
503 CXFA_Node* pUIChild = GetUIChild(); 502 CXFA_Node* pUIChild = GetUIChild();
504 if (pUIChild) 503 if (pUIChild)
505 return pUIChild->GetEnum(XFA_ATTRIBUTE_Mark); 504 return pUIChild->GetEnum(XFA_ATTRIBUTE_Mark);
506 return GetAttributeDefaultValue_Enum(XFA_Element::CheckButton, 505 return GetAttributeDefaultValue_Enum(XFA_Element::CheckButton,
507 XFA_ATTRIBUTE_Mark, XFA_XDPPACKET_Form); 506 XFA_ATTRIBUTE_Mark, XFA_XDPPACKET_Form);
508 } 507 }
509 508
510 FX_BOOL CXFA_WidgetData::IsRadioButton() { 509 bool CXFA_WidgetData::IsRadioButton() {
511 if (CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent)) 510 if (CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent))
512 return pParent->GetElementType() == XFA_Element::ExclGroup; 511 return pParent->GetElementType() == XFA_Element::ExclGroup;
513 return FALSE; 512 return false;
514 } 513 }
515 514
516 FX_FLOAT CXFA_WidgetData::GetCheckButtonSize() { 515 FX_FLOAT CXFA_WidgetData::GetCheckButtonSize() {
517 CXFA_Node* pUIChild = GetUIChild(); 516 CXFA_Node* pUIChild = GetUIChild();
518 if (pUIChild) 517 if (pUIChild)
519 return pUIChild->GetMeasure(XFA_ATTRIBUTE_Size).ToUnit(XFA_UNIT_Pt); 518 return pUIChild->GetMeasure(XFA_ATTRIBUTE_Size).ToUnit(XFA_UNIT_Pt);
520 return XFA_GetAttributeDefaultValue_Measure( 519 return XFA_GetAttributeDefaultValue_Measure(
521 XFA_Element::CheckButton, XFA_ATTRIBUTE_Size, XFA_XDPPACKET_Form) 520 XFA_Element::CheckButton, XFA_ATTRIBUTE_Size, XFA_XDPPACKET_Form)
522 .ToUnit(XFA_UNIT_Pt); 521 .ToUnit(XFA_UNIT_Pt);
523 } 522 }
524 523
525 FX_BOOL CXFA_WidgetData::IsAllowNeutral() { 524 bool CXFA_WidgetData::IsAllowNeutral() {
526 CXFA_Node* pUIChild = GetUIChild(); 525 CXFA_Node* pUIChild = GetUIChild();
527 if (pUIChild) 526 if (pUIChild)
528 return pUIChild->GetBoolean(XFA_ATTRIBUTE_AllowNeutral); 527 return pUIChild->GetBoolean(XFA_ATTRIBUTE_AllowNeutral);
529 return GetAttributeDefaultValue_Boolean( 528 return GetAttributeDefaultValue_Boolean(
530 XFA_Element::CheckButton, XFA_ATTRIBUTE_AllowNeutral, XFA_XDPPACKET_Form); 529 XFA_Element::CheckButton, XFA_ATTRIBUTE_AllowNeutral, XFA_XDPPACKET_Form);
531 } 530 }
532 531
533 XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() { 532 XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
534 CFX_WideString wsValue = GetRawValue(); 533 CFX_WideString wsValue = GetRawValue();
535 if (wsValue.IsEmpty()) 534 if (wsValue.IsEmpty())
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 CXFA_WidgetData widgetData(pNode); 640 CXFA_WidgetData widgetData(pNode);
642 widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify); 641 widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify);
643 return pNode; 642 return pNode;
644 } 643 }
645 } 644 }
646 return nullptr; 645 return nullptr;
647 } 646 }
648 647
649 void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue, 648 void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
650 bool bNotify, 649 bool bNotify,
651 FX_BOOL bScriptModify, 650 bool bScriptModify,
652 FX_BOOL bSyncData) { 651 bool bSyncData) {
653 CFX_WideString wsExclGroup; 652 CFX_WideString wsExclGroup;
654 for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode; 653 for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
655 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 654 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
656 if (pNode->GetElementType() != XFA_Element::Field) 655 if (pNode->GetElementType() != XFA_Element::Field)
657 continue; 656 continue;
658 657
659 CXFA_Node* pItem = pNode->GetChild(0, XFA_Element::Items); 658 CXFA_Node* pItem = pNode->GetChild(0, XFA_Element::Items);
660 if (!pItem) 659 if (!pItem)
661 continue; 660 continue;
662 661
663 CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); 662 CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
664 if (!pItemchild) 663 if (!pItemchild)
665 continue; 664 continue;
666 665
667 CFX_WideString wsChildValue = pItemchild->GetContent(); 666 CFX_WideString wsChildValue = pItemchild->GetContent();
668 if (wsValue != wsChildValue) { 667 if (wsValue != wsChildValue) {
669 pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); 668 pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling);
670 if (pItemchild) 669 if (pItemchild)
671 wsChildValue = pItemchild->GetContent(); 670 wsChildValue = pItemchild->GetContent();
672 else 671 else
673 wsChildValue.clear(); 672 wsChildValue.clear();
674 } else { 673 } else {
675 wsExclGroup = wsValue; 674 wsExclGroup = wsValue;
676 } 675 }
677 pNode->SetContent(wsChildValue, wsChildValue, bNotify, bScriptModify, 676 pNode->SetContent(wsChildValue, wsChildValue, bNotify, bScriptModify,
678 FALSE); 677 false);
679 } 678 }
680 if (m_pNode) { 679 if (m_pNode) {
681 m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify, 680 m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify,
682 bSyncData); 681 bSyncData);
683 } 682 }
684 } 683 }
685 684
686 CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() { 685 CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() {
687 CXFA_Node* pExcl = GetNode(); 686 CXFA_Node* pExcl = GetNode();
688 if (!pExcl) 687 if (!pExcl)
(...skipping 23 matching lines...) Expand all
712 } 711 }
713 712
714 int32_t CXFA_WidgetData::GetChoiceListCommitOn() { 713 int32_t CXFA_WidgetData::GetChoiceListCommitOn() {
715 CXFA_Node* pUIChild = GetUIChild(); 714 CXFA_Node* pUIChild = GetUIChild();
716 if (pUIChild) 715 if (pUIChild)
717 return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn); 716 return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn);
718 return GetAttributeDefaultValue_Enum( 717 return GetAttributeDefaultValue_Enum(
719 XFA_Element::ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form); 718 XFA_Element::ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form);
720 } 719 }
721 720
722 FX_BOOL CXFA_WidgetData::IsChoiceListAllowTextEntry() { 721 bool CXFA_WidgetData::IsChoiceListAllowTextEntry() {
723 CXFA_Node* pUIChild = GetUIChild(); 722 CXFA_Node* pUIChild = GetUIChild();
724 if (pUIChild) 723 if (pUIChild)
725 return pUIChild->GetBoolean(XFA_ATTRIBUTE_TextEntry); 724 return pUIChild->GetBoolean(XFA_ATTRIBUTE_TextEntry);
726 return GetAttributeDefaultValue_Boolean( 725 return GetAttributeDefaultValue_Boolean(
727 XFA_Element::ChoiceList, XFA_ATTRIBUTE_TextEntry, XFA_XDPPACKET_Form); 726 XFA_Element::ChoiceList, XFA_ATTRIBUTE_TextEntry, XFA_XDPPACKET_Form);
728 } 727 }
729 728
730 int32_t CXFA_WidgetData::GetChoiceListOpen() { 729 int32_t CXFA_WidgetData::GetChoiceListOpen() {
731 CXFA_Node* pUIChild = GetUIChild(); 730 CXFA_Node* pUIChild = GetUIChild();
732 if (pUIChild) 731 if (pUIChild)
733 return pUIChild->GetEnum(XFA_ATTRIBUTE_Open); 732 return pUIChild->GetEnum(XFA_ATTRIBUTE_Open);
734 return GetAttributeDefaultValue_Enum(XFA_Element::ChoiceList, 733 return GetAttributeDefaultValue_Enum(XFA_Element::ChoiceList,
735 XFA_ATTRIBUTE_Open, XFA_XDPPACKET_Form); 734 XFA_ATTRIBUTE_Open, XFA_XDPPACKET_Form);
736 } 735 }
737 736
738 FX_BOOL CXFA_WidgetData::IsListBox() { 737 bool CXFA_WidgetData::IsListBox() {
739 int32_t iOpenMode = GetChoiceListOpen(); 738 int32_t iOpenMode = GetChoiceListOpen();
740 return (iOpenMode == XFA_ATTRIBUTEENUM_Always || 739 return (iOpenMode == XFA_ATTRIBUTEENUM_Always ||
741 iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect); 740 iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect);
742 } 741 }
743 742
744 int32_t CXFA_WidgetData::CountChoiceListItems(FX_BOOL bSaveValue) { 743 int32_t CXFA_WidgetData::CountChoiceListItems(bool bSaveValue) {
745 CXFA_NodeArray pItems; 744 CXFA_NodeArray pItems;
746 CXFA_Node* pItem = nullptr; 745 CXFA_Node* pItem = nullptr;
747 int32_t iCount = 0; 746 int32_t iCount = 0;
748 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 747 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
749 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 748 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
750 if (pNode->GetElementType() != XFA_Element::Items) 749 if (pNode->GetElementType() != XFA_Element::Items)
751 continue; 750 continue;
752 751
753 iCount++; 752 iCount++;
754 pItems.Add(pNode); 753 pItems.Add(pNode);
755 if (iCount == 2) 754 if (iCount == 2)
756 break; 755 break;
757 } 756 }
758 if (iCount == 0) 757 if (iCount == 0)
759 return 0; 758 return 0;
760 759
761 pItem = pItems[0]; 760 pItem = pItems[0];
762 if (iCount > 1) { 761 if (iCount > 1) {
763 FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save); 762 bool bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save);
764 FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save); 763 bool bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save);
765 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) 764 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
766 pItem = pItems[1]; 765 pItem = pItems[1];
767 } 766 }
768 pItems.RemoveAll(); 767 pItems.RemoveAll();
769 return pItem->CountChildren(XFA_Element::Unknown); 768 return pItem->CountChildren(XFA_Element::Unknown);
770 } 769 }
771 770
772 FX_BOOL CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText, 771 bool CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText,
773 int32_t nIndex, 772 int32_t nIndex,
774 FX_BOOL bSaveValue) { 773 bool bSaveValue) {
775 wsText.clear(); 774 wsText.clear();
776 CXFA_NodeArray pItemsArray; 775 CXFA_NodeArray pItemsArray;
777 CXFA_Node* pItems = nullptr; 776 CXFA_Node* pItems = nullptr;
778 int32_t iCount = 0; 777 int32_t iCount = 0;
779 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 778 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
780 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 779 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
781 if (pNode->GetElementType() != XFA_Element::Items) 780 if (pNode->GetElementType() != XFA_Element::Items)
782 continue; 781 continue;
783 782
784 iCount++; 783 iCount++;
785 pItemsArray.Add(pNode); 784 pItemsArray.Add(pNode);
786 if (iCount == 2) 785 if (iCount == 2)
787 break; 786 break;
788 } 787 }
789 if (iCount == 0) 788 if (iCount == 0)
790 return FALSE; 789 return false;
791 790
792 pItems = pItemsArray[0]; 791 pItems = pItemsArray[0];
793 if (iCount > 1) { 792 if (iCount > 1) {
794 FX_BOOL bItemOneHasSave = pItemsArray[0]->GetBoolean(XFA_ATTRIBUTE_Save); 793 bool bItemOneHasSave = pItemsArray[0]->GetBoolean(XFA_ATTRIBUTE_Save);
795 FX_BOOL bItemTwoHasSave = pItemsArray[1]->GetBoolean(XFA_ATTRIBUTE_Save); 794 bool bItemTwoHasSave = pItemsArray[1]->GetBoolean(XFA_ATTRIBUTE_Save);
796 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) 795 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
797 pItems = pItemsArray[1]; 796 pItems = pItemsArray[1];
798 } 797 }
799 if (pItems) { 798 if (pItems) {
800 CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_Element::Unknown); 799 CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_Element::Unknown);
801 if (pItem) { 800 if (pItem) {
802 pItem->TryContent(wsText); 801 pItem->TryContent(wsText);
803 return TRUE; 802 return true;
804 } 803 }
805 } 804 }
806 return FALSE; 805 return false;
807 } 806 }
808 807
809 void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray, 808 void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray,
810 FX_BOOL bSaveValue) { 809 bool bSaveValue) {
811 CXFA_NodeArray pItems; 810 CXFA_NodeArray pItems;
812 CXFA_Node* pItem = nullptr; 811 CXFA_Node* pItem = nullptr;
813 int32_t iCount = 0; 812 int32_t iCount = 0;
814 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 813 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
815 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 814 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
816 if (pNode->GetElementType() != XFA_Element::Items) 815 if (pNode->GetElementType() != XFA_Element::Items)
817 continue; 816 continue;
818 817
819 iCount++; 818 iCount++;
820 pItems.Add(pNode); 819 pItems.Add(pNode);
821 if (iCount == 2) 820 if (iCount == 2)
822 break; 821 break;
823 } 822 }
824 if (iCount == 0) 823 if (iCount == 0)
825 return; 824 return;
826 825
827 pItem = pItems[0]; 826 pItem = pItems[0];
828 if (iCount > 1) { 827 if (iCount > 1) {
829 FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save); 828 bool bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save);
830 FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save); 829 bool bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save);
831 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) 830 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
832 pItem = pItems[1]; 831 pItem = pItems[1];
833 } 832 }
834 pItems.RemoveAll(); 833 pItems.RemoveAll();
835 pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); 834 pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
836 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) 835 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling))
837 pNode->TryContent(wsTextArray.Add()); 836 pNode->TryContent(wsTextArray.Add());
838 } 837 }
839 838
840 int32_t CXFA_WidgetData::CountSelectedItems() { 839 int32_t CXFA_WidgetData::CountSelectedItems() {
841 CFX_WideStringArray wsValueArray; 840 CFX_WideStringArray wsValueArray;
842 GetSelectedItemsValue(wsValueArray); 841 GetSelectedItemsValue(wsValueArray);
843 if (IsListBox() || !IsChoiceListAllowTextEntry()) 842 if (IsListBox() || !IsChoiceListAllowTextEntry())
844 return wsValueArray.GetSize(); 843 return wsValueArray.GetSize();
845 844
846 int32_t iSelected = 0; 845 int32_t iSelected = 0;
847 CFX_WideStringArray wsSaveTextArray; 846 CFX_WideStringArray wsSaveTextArray;
848 GetChoiceListItems(wsSaveTextArray, TRUE); 847 GetChoiceListItems(wsSaveTextArray, true);
849 int32_t iValues = wsValueArray.GetSize(); 848 int32_t iValues = wsValueArray.GetSize();
850 for (int32_t i = 0; i < iValues; i++) { 849 for (int32_t i = 0; i < iValues; i++) {
851 int32_t iSaves = wsSaveTextArray.GetSize(); 850 int32_t iSaves = wsSaveTextArray.GetSize();
852 for (int32_t j = 0; j < iSaves; j++) { 851 for (int32_t j = 0; j < iSaves; j++) {
853 if (wsValueArray[i] == wsSaveTextArray[j]) { 852 if (wsValueArray[i] == wsSaveTextArray[j]) {
854 iSelected++; 853 iSelected++;
855 break; 854 break;
856 } 855 }
857 } 856 }
858 } 857 }
859 return iSelected; 858 return iSelected;
860 } 859 }
861 860
862 int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) { 861 int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) {
863 CFX_WideStringArray wsValueArray; 862 CFX_WideStringArray wsValueArray;
864 GetSelectedItemsValue(wsValueArray); 863 GetSelectedItemsValue(wsValueArray);
865 CFX_WideStringArray wsSaveTextArray; 864 CFX_WideStringArray wsSaveTextArray;
866 GetChoiceListItems(wsSaveTextArray, TRUE); 865 GetChoiceListItems(wsSaveTextArray, true);
867 int32_t iSaves = wsSaveTextArray.GetSize(); 866 int32_t iSaves = wsSaveTextArray.GetSize();
868 for (int32_t j = 0; j < iSaves; j++) { 867 for (int32_t j = 0; j < iSaves; j++) {
869 if (wsValueArray[nIndex] == wsSaveTextArray[j]) 868 if (wsValueArray[nIndex] == wsSaveTextArray[j])
870 return j; 869 return j;
871 } 870 }
872 return -1; 871 return -1;
873 } 872 }
874 873
875 void CXFA_WidgetData::GetSelectedItems(CFX_Int32Array& iSelArray) { 874 void CXFA_WidgetData::GetSelectedItems(CFX_Int32Array& iSelArray) {
876 CFX_WideStringArray wsValueArray; 875 CFX_WideStringArray wsValueArray;
877 GetSelectedItemsValue(wsValueArray); 876 GetSelectedItemsValue(wsValueArray);
878 int32_t iValues = wsValueArray.GetSize(); 877 int32_t iValues = wsValueArray.GetSize();
879 if (iValues < 1) 878 if (iValues < 1)
880 return; 879 return;
881 880
882 CFX_WideStringArray wsSaveTextArray; 881 CFX_WideStringArray wsSaveTextArray;
883 GetChoiceListItems(wsSaveTextArray, TRUE); 882 GetChoiceListItems(wsSaveTextArray, true);
884 int32_t iSaves = wsSaveTextArray.GetSize(); 883 int32_t iSaves = wsSaveTextArray.GetSize();
885 for (int32_t i = 0; i < iValues; i++) { 884 for (int32_t i = 0; i < iValues; i++) {
886 for (int32_t j = 0; j < iSaves; j++) { 885 for (int32_t j = 0; j < iSaves; j++) {
887 if (wsValueArray[i] == wsSaveTextArray[j]) { 886 if (wsValueArray[i] == wsSaveTextArray[j]) {
888 iSelArray.Add(j); 887 iSelArray.Add(j);
889 break; 888 break;
890 } 889 }
891 } 890 }
892 } 891 }
893 } 892 }
(...skipping 16 matching lines...) Expand all
910 iEnd = wsValue.Find(L'\n', iStart); 909 iEnd = wsValue.Find(L'\n', iStart);
911 if (iEnd < 0) 910 if (iEnd < 0)
912 wsSelTextArray.Add(wsValue.Mid(iStart, iLength - iStart)); 911 wsSelTextArray.Add(wsValue.Mid(iStart, iLength - iStart));
913 } 912 }
914 } 913 }
915 } else { 914 } else {
916 wsSelTextArray.Add(wsValue); 915 wsSelTextArray.Add(wsValue);
917 } 916 }
918 } 917 }
919 918
920 FX_BOOL CXFA_WidgetData::GetItemState(int32_t nIndex) { 919 bool CXFA_WidgetData::GetItemState(int32_t nIndex) {
921 if (nIndex < 0) 920 if (nIndex < 0)
922 return FALSE; 921 return false;
923 922
924 CFX_WideStringArray wsSaveTextArray; 923 CFX_WideStringArray wsSaveTextArray;
925 GetChoiceListItems(wsSaveTextArray, TRUE); 924 GetChoiceListItems(wsSaveTextArray, true);
926 if (wsSaveTextArray.GetSize() <= nIndex) 925 if (wsSaveTextArray.GetSize() <= nIndex)
927 return FALSE; 926 return false;
928 927
929 CFX_WideStringArray wsValueArray; 928 CFX_WideStringArray wsValueArray;
930 GetSelectedItemsValue(wsValueArray); 929 GetSelectedItemsValue(wsValueArray);
931 int32_t iValues = wsValueArray.GetSize(); 930 int32_t iValues = wsValueArray.GetSize();
932 for (int32_t j = 0; j < iValues; j++) { 931 for (int32_t j = 0; j < iValues; j++) {
933 if (wsValueArray[j] == wsSaveTextArray[nIndex]) 932 if (wsValueArray[j] == wsSaveTextArray[nIndex])
934 return TRUE; 933 return true;
935 } 934 }
936 return FALSE; 935 return false;
937 } 936 }
938 937
939 void CXFA_WidgetData::SetItemState(int32_t nIndex, 938 void CXFA_WidgetData::SetItemState(int32_t nIndex,
940 FX_BOOL bSelected, 939 bool bSelected,
941 bool bNotify, 940 bool bNotify,
942 FX_BOOL bScriptModify, 941 bool bScriptModify,
943 FX_BOOL bSyncData) { 942 bool bSyncData) {
944 if (nIndex < 0) 943 if (nIndex < 0)
945 return; 944 return;
946 945
947 CFX_WideStringArray wsSaveTextArray; 946 CFX_WideStringArray wsSaveTextArray;
948 GetChoiceListItems(wsSaveTextArray, TRUE); 947 GetChoiceListItems(wsSaveTextArray, true);
949 if (wsSaveTextArray.GetSize() <= nIndex) 948 if (wsSaveTextArray.GetSize() <= nIndex)
950 return; 949 return;
951 950
952 int32_t iSel = -1; 951 int32_t iSel = -1;
953 CFX_WideStringArray wsValueArray; 952 CFX_WideStringArray wsValueArray;
954 GetSelectedItemsValue(wsValueArray); 953 GetSelectedItemsValue(wsValueArray);
955 int32_t iValues = wsValueArray.GetSize(); 954 int32_t iValues = wsValueArray.GetSize();
956 for (int32_t j = 0; j < iValues; j++) { 955 for (int32_t j = 0; j < iValues; j++) {
957 if (wsValueArray[j] == wsSaveTextArray[nIndex]) { 956 if (wsValueArray[j] == wsSaveTextArray[nIndex]) {
958 iSel = j; 957 iSel = j;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 } 991 }
993 } else if (iSel >= 0) { 992 } else if (iSel >= 0) {
994 m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify, 993 m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify,
995 bScriptModify, bSyncData); 994 bScriptModify, bSyncData);
996 } 995 }
997 } 996 }
998 } 997 }
999 998
1000 void CXFA_WidgetData::SetSelectedItems(CFX_Int32Array& iSelArray, 999 void CXFA_WidgetData::SetSelectedItems(CFX_Int32Array& iSelArray,
1001 bool bNotify, 1000 bool bNotify,
1002 FX_BOOL bScriptModify, 1001 bool bScriptModify,
1003 FX_BOOL bSyncData) { 1002 bool bSyncData) {
1004 CFX_WideString wsValue; 1003 CFX_WideString wsValue;
1005 int32_t iSize = iSelArray.GetSize(); 1004 int32_t iSize = iSelArray.GetSize();
1006 if (iSize >= 1) { 1005 if (iSize >= 1) {
1007 CFX_WideStringArray wsSaveTextArray; 1006 CFX_WideStringArray wsSaveTextArray;
1008 GetChoiceListItems(wsSaveTextArray, TRUE); 1007 GetChoiceListItems(wsSaveTextArray, true);
1009 CFX_WideString wsItemValue; 1008 CFX_WideString wsItemValue;
1010 for (int32_t i = 0; i < iSize; i++) { 1009 for (int32_t i = 0; i < iSize; i++) {
1011 wsItemValue = (iSize == 1) 1010 wsItemValue = (iSize == 1)
1012 ? wsSaveTextArray[iSelArray[i]] 1011 ? wsSaveTextArray[iSelArray[i]]
1013 : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n"); 1012 : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n");
1014 wsValue += wsItemValue; 1013 wsValue += wsItemValue;
1015 } 1014 }
1016 } 1015 }
1017 CFX_WideString wsFormat(wsValue); 1016 CFX_WideString wsFormat(wsValue);
1018 if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) 1017 if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect)
1019 GetFormatDataValue(wsValue, wsFormat); 1018 GetFormatDataValue(wsValue, wsFormat);
1020 1019
1021 m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData); 1020 m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData);
1022 } 1021 }
1023 1022
1024 void CXFA_WidgetData::ClearAllSelections() { 1023 void CXFA_WidgetData::ClearAllSelections() {
1025 CXFA_Node* pBind = m_pNode->GetBindData(); 1024 CXFA_Node* pBind = m_pNode->GetBindData();
1026 if (!pBind || GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) { 1025 if (!pBind || GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) {
1027 SyncValue(CFX_WideString(), false); 1026 SyncValue(CFX_WideString(), false);
1028 return; 1027 return;
1029 } 1028 }
1030 1029
1031 while (CXFA_Node* pChildNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) 1030 while (CXFA_Node* pChildNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild))
1032 pBind->RemoveChild(pChildNode); 1031 pBind->RemoveChild(pChildNode);
1033 } 1032 }
1034 1033
1035 void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel, 1034 void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
1036 const CFX_WideString& wsValue, 1035 const CFX_WideString& wsValue,
1037 int32_t nIndex, 1036 int32_t nIndex,
1038 FX_BOOL bNotify) { 1037 bool bNotify) {
1039 CFX_WideString wsNewValue(wsValue); 1038 CFX_WideString wsNewValue(wsValue);
1040 if (wsNewValue.IsEmpty()) 1039 if (wsNewValue.IsEmpty())
1041 wsNewValue = wsLabel; 1040 wsNewValue = wsLabel;
1042 1041
1043 CXFA_NodeArray listitems; 1042 CXFA_NodeArray listitems;
1044 int32_t iCount = 0; 1043 int32_t iCount = 0;
1045 CXFA_Node* pItemNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1044 CXFA_Node* pItemNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1046 for (; pItemNode; 1045 for (; pItemNode;
1047 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1046 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1048 if (pItemNode->GetElementType() != XFA_Element::Items) 1047 if (pItemNode->GetElementType() != XFA_Element::Items)
1049 continue; 1048 continue;
1050 1049
1051 listitems.Add(pItemNode); 1050 listitems.Add(pItemNode);
1052 iCount++; 1051 iCount++;
1053 } 1052 }
1054 if (iCount < 1) { 1053 if (iCount < 1) {
1055 CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_Element::Items); 1054 CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_Element::Items);
1056 m_pNode->InsertChild(-1, pItems); 1055 m_pNode->InsertChild(-1, pItems);
1057 InsertListTextItem(pItems, wsLabel, nIndex); 1056 InsertListTextItem(pItems, wsLabel, nIndex);
1058 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_Element::Items); 1057 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_Element::Items);
1059 m_pNode->InsertChild(-1, pSaveItems); 1058 m_pNode->InsertChild(-1, pSaveItems);
1060 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); 1059 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, true);
1061 InsertListTextItem(pSaveItems, wsNewValue, nIndex); 1060 InsertListTextItem(pSaveItems, wsNewValue, nIndex);
1062 } else if (iCount > 1) { 1061 } else if (iCount > 1) {
1063 for (int32_t i = 0; i < 2; i++) { 1062 for (int32_t i = 0; i < 2; i++) {
1064 CXFA_Node* pNode = listitems[i]; 1063 CXFA_Node* pNode = listitems[i];
1065 FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save); 1064 bool bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save);
1066 if (bHasSave) 1065 if (bHasSave)
1067 InsertListTextItem(pNode, wsNewValue, nIndex); 1066 InsertListTextItem(pNode, wsNewValue, nIndex);
1068 else 1067 else
1069 InsertListTextItem(pNode, wsLabel, nIndex); 1068 InsertListTextItem(pNode, wsLabel, nIndex);
1070 } 1069 }
1071 } else { 1070 } else {
1072 CXFA_Node* pNode = listitems[0]; 1071 CXFA_Node* pNode = listitems[0];
1073 pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); 1072 pNode->SetBoolean(XFA_ATTRIBUTE_Save, false);
1074 pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); 1073 pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible);
1075 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_Element::Items); 1074 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_Element::Items);
1076 m_pNode->InsertChild(-1, pSaveItems); 1075 m_pNode->InsertChild(-1, pSaveItems);
1077 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); 1076 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, true);
1078 pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); 1077 pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden);
1079 listitems.RemoveAll(); 1078 listitems.RemoveAll();
1080 CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1079 CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1081 int32_t i = 0; 1080 int32_t i = 0;
1082 while (pListNode) { 1081 while (pListNode) {
1083 CFX_WideString wsOldValue; 1082 CFX_WideString wsOldValue;
1084 pListNode->TryContent(wsOldValue); 1083 pListNode->TryContent(wsOldValue);
1085 InsertListTextItem(pSaveItems, wsOldValue, i); 1084 InsertListTextItem(pSaveItems, wsOldValue, i);
1086 i++; 1085 i++;
1087 pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); 1086 pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling);
(...skipping 17 matching lines...) Expand all
1105 if (pItems->GetElementType() != XFA_Element::Items) 1104 if (pItems->GetElementType() != XFA_Element::Items)
1106 continue; 1105 continue;
1107 1106
1108 iCount++; 1107 iCount++;
1109 listitems.Add(pItems); 1108 listitems.Add(pItems);
1110 } 1109 }
1111 if (iCount <= 1) { 1110 if (iCount <= 1) {
1112 wsLabel = wsValue; 1111 wsLabel = wsValue;
1113 } else { 1112 } else {
1114 CXFA_Node* pLabelItems = listitems[0]; 1113 CXFA_Node* pLabelItems = listitems[0];
1115 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); 1114 bool bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save);
1116 CXFA_Node* pSaveItems = nullptr; 1115 CXFA_Node* pSaveItems = nullptr;
1117 if (bSave) { 1116 if (bSave) {
1118 pSaveItems = pLabelItems; 1117 pSaveItems = pLabelItems;
1119 pLabelItems = listitems[1]; 1118 pLabelItems = listitems[1];
1120 } else { 1119 } else {
1121 pSaveItems = listitems[1]; 1120 pSaveItems = listitems[1];
1122 } 1121 }
1123 iCount = 0; 1122 iCount = 0;
1124 int32_t iSearch = -1; 1123 int32_t iSearch = -1;
1125 CFX_WideString wsContent; 1124 CFX_WideString wsContent;
(...skipping 25 matching lines...) Expand all
1151 if (pItems->GetElementType() != XFA_Element::Items) 1150 if (pItems->GetElementType() != XFA_Element::Items)
1152 continue; 1151 continue;
1153 1152
1154 iCount++; 1153 iCount++;
1155 listitems.Add(pItems); 1154 listitems.Add(pItems);
1156 } 1155 }
1157 if (iCount <= 1) { 1156 if (iCount <= 1) {
1158 wsValue = wsLabel; 1157 wsValue = wsLabel;
1159 } else { 1158 } else {
1160 CXFA_Node* pLabelItems = listitems[0]; 1159 CXFA_Node* pLabelItems = listitems[0];
1161 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); 1160 bool bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save);
1162 CXFA_Node* pSaveItems = nullptr; 1161 CXFA_Node* pSaveItems = nullptr;
1163 if (bSave) { 1162 if (bSave) {
1164 pSaveItems = pLabelItems; 1163 pSaveItems = pLabelItems;
1165 pLabelItems = listitems[1]; 1164 pLabelItems = listitems[1];
1166 } else { 1165 } else {
1167 pSaveItems = listitems[1]; 1166 pSaveItems = listitems[1];
1168 } 1167 }
1169 iCount = 0; 1168 iCount = 0;
1170 int32_t iSearch = -1; 1169 int32_t iSearch = -1;
1171 CFX_WideString wsContent; 1170 CFX_WideString wsContent;
1172 CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); 1171 CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild);
1173 for (; pChildItem; 1172 for (; pChildItem;
1174 pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1173 pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1175 pChildItem->TryContent(wsContent); 1174 pChildItem->TryContent(wsContent);
1176 if (wsContent == wsLabel) { 1175 if (wsContent == wsLabel) {
1177 iSearch = iCount; 1176 iSearch = iCount;
1178 break; 1177 break;
1179 } 1178 }
1180 iCount++; 1179 iCount++;
1181 } 1180 }
1182 if (iSearch < 0) 1181 if (iSearch < 0)
1183 return; 1182 return;
1184 if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_Element::Unknown)) 1183 if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_Element::Unknown))
1185 pText->TryContent(wsValue); 1184 pText->TryContent(wsValue);
1186 } 1185 }
1187 } 1186 }
1188 1187
1189 FX_BOOL CXFA_WidgetData::DeleteItem(int32_t nIndex, 1188 bool CXFA_WidgetData::DeleteItem(int32_t nIndex,
1190 FX_BOOL bNotify, 1189 bool bNotify,
1191 FX_BOOL bScriptModify, 1190 bool bScriptModify,
1192 FX_BOOL bSyncData) { 1191 bool bSyncData) {
1193 FX_BOOL bSetValue = FALSE; 1192 bool bSetValue = false;
1194 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1193 CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1195 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1194 for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1196 if (pItems->GetElementType() != XFA_Element::Items) 1195 if (pItems->GetElementType() != XFA_Element::Items)
1197 continue; 1196 continue;
1198 1197
1199 if (nIndex < 0) { 1198 if (nIndex < 0) {
1200 while (CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild)) { 1199 while (CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild)) {
1201 pItems->RemoveChild(pNode); 1200 pItems->RemoveChild(pNode);
1202 } 1201 }
1203 } else { 1202 } else {
1204 if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) { 1203 if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) {
1205 SetItemState(nIndex, FALSE, true, bScriptModify, bSyncData); 1204 SetItemState(nIndex, false, true, bScriptModify, bSyncData);
1206 bSetValue = TRUE; 1205 bSetValue = true;
1207 } 1206 }
1208 int32_t i = 0; 1207 int32_t i = 0;
1209 CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); 1208 CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
1210 while (pNode) { 1209 while (pNode) {
1211 if (i == nIndex) { 1210 if (i == nIndex) {
1212 pItems->RemoveChild(pNode); 1211 pItems->RemoveChild(pNode);
1213 break; 1212 break;
1214 } 1213 }
1215 i++; 1214 i++;
1216 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); 1215 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling);
1217 } 1216 }
1218 } 1217 }
1219 } 1218 }
1220 if (bNotify) 1219 if (bNotify)
1221 m_pNode->GetDocument()->GetNotify()->OnWidgetListItemRemoved(this, nIndex); 1220 m_pNode->GetDocument()->GetNotify()->OnWidgetListItemRemoved(this, nIndex);
1222 return TRUE; 1221 return true;
1223 } 1222 }
1224 1223
1225 int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() { 1224 int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() {
1226 CXFA_Node* pUIChild = GetUIChild(); 1225 CXFA_Node* pUIChild = GetUIChild();
1227 if (pUIChild) 1226 if (pUIChild)
1228 return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy); 1227 return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy);
1229 return XFA_ATTRIBUTEENUM_Auto; 1228 return XFA_ATTRIBUTEENUM_Auto;
1230 } 1229 }
1231 1230
1232 int32_t CXFA_WidgetData::GetNumberOfCells() { 1231 int32_t CXFA_WidgetData::GetNumberOfCells() {
1233 CXFA_Node* pUIChild = GetUIChild(); 1232 CXFA_Node* pUIChild = GetUIChild();
1234 if (!pUIChild) 1233 if (!pUIChild)
1235 return -1; 1234 return -1;
1236 if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_Element::Comb)) 1235 if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_Element::Comb))
1237 return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells); 1236 return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells);
1238 return -1; 1237 return -1;
1239 } 1238 }
1240 1239
1241 CFX_WideString CXFA_WidgetData::GetBarcodeType() { 1240 CFX_WideString CXFA_WidgetData::GetBarcodeType() {
1242 CXFA_Node* pUIChild = GetUIChild(); 1241 CXFA_Node* pUIChild = GetUIChild();
1243 return pUIChild ? CFX_WideString(pUIChild->GetCData(XFA_ATTRIBUTE_Type)) 1242 return pUIChild ? CFX_WideString(pUIChild->GetCData(XFA_ATTRIBUTE_Type))
1244 : CFX_WideString(); 1243 : CFX_WideString();
1245 } 1244 }
1246 1245
1247 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { 1246 bool CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) {
1248 CXFA_Node* pUIChild = GetUIChild(); 1247 CXFA_Node* pUIChild = GetUIChild();
1249 CFX_WideString wsCharEncoding; 1248 CFX_WideString wsCharEncoding;
1250 if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) { 1249 if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) {
1251 if (wsCharEncoding.CompareNoCase(L"UTF-16")) { 1250 if (wsCharEncoding.CompareNoCase(L"UTF-16")) {
1252 val = CHAR_ENCODING_UNICODE; 1251 val = CHAR_ENCODING_UNICODE;
1253 return TRUE; 1252 return true;
1254 } 1253 }
1255 if (wsCharEncoding.CompareNoCase(L"UTF-8")) { 1254 if (wsCharEncoding.CompareNoCase(L"UTF-8")) {
1256 val = CHAR_ENCODING_UTF8; 1255 val = CHAR_ENCODING_UTF8;
1257 return TRUE; 1256 return true;
1258 } 1257 }
1259 } 1258 }
1260 return FALSE; 1259 return false;
1261 } 1260 }
1262 1261
1263 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(FX_BOOL& val) { 1262 bool CXFA_WidgetData::GetBarcodeAttribute_Checksum(bool& val) {
1264 CXFA_Node* pUIChild = GetUIChild(); 1263 CXFA_Node* pUIChild = GetUIChild();
1265 XFA_ATTRIBUTEENUM eChecksum; 1264 XFA_ATTRIBUTEENUM eChecksum;
1266 if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) { 1265 if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) {
1267 switch (eChecksum) { 1266 switch (eChecksum) {
1268 case XFA_ATTRIBUTEENUM_None: 1267 case XFA_ATTRIBUTEENUM_None:
1269 val = false; 1268 val = false;
1270 return TRUE; 1269 return true;
1271 case XFA_ATTRIBUTEENUM_Auto: 1270 case XFA_ATTRIBUTEENUM_Auto:
1272 val = true; 1271 val = true;
1273 return TRUE; 1272 return true;
1274 case XFA_ATTRIBUTEENUM_1mod10: 1273 case XFA_ATTRIBUTEENUM_1mod10:
1275 break; 1274 break;
1276 case XFA_ATTRIBUTEENUM_1mod10_1mod11: 1275 case XFA_ATTRIBUTEENUM_1mod10_1mod11:
1277 break; 1276 break;
1278 case XFA_ATTRIBUTEENUM_2mod10: 1277 case XFA_ATTRIBUTEENUM_2mod10:
1279 break; 1278 break;
1280 default: 1279 default:
1281 break; 1280 break;
1282 } 1281 }
1283 } 1282 }
1284 return FALSE; 1283 return false;
1285 } 1284 }
1286 1285
1287 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t& val) { 1286 bool CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t& val) {
1288 CXFA_Node* pUIChild = GetUIChild(); 1287 CXFA_Node* pUIChild = GetUIChild();
1289 CFX_WideString wsDataLength; 1288 CFX_WideString wsDataLength;
1290 if (pUIChild->TryCData(XFA_ATTRIBUTE_DataLength, wsDataLength)) { 1289 if (pUIChild->TryCData(XFA_ATTRIBUTE_DataLength, wsDataLength)) {
1291 val = FXSYS_wtoi(wsDataLength.c_str()); 1290 val = FXSYS_wtoi(wsDataLength.c_str());
1292 return TRUE; 1291 return true;
1293 } 1292 }
1294 return FALSE; 1293 return false;
1295 } 1294 }
1296 1295
1297 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) { 1296 bool CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) {
1298 CXFA_Node* pUIChild = GetUIChild(); 1297 CXFA_Node* pUIChild = GetUIChild();
1299 CFX_WideStringC wsStartEndChar; 1298 CFX_WideStringC wsStartEndChar;
1300 if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) { 1299 if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) {
1301 if (wsStartEndChar.GetLength()) { 1300 if (wsStartEndChar.GetLength()) {
1302 val = (FX_CHAR)wsStartEndChar.GetAt(0); 1301 val = (FX_CHAR)wsStartEndChar.GetAt(0);
1303 return TRUE; 1302 return true;
1304 } 1303 }
1305 } 1304 }
1306 return FALSE; 1305 return false;
1307 } 1306 }
1308 1307
1309 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) { 1308 bool CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) {
1310 CXFA_Node* pUIChild = GetUIChild(); 1309 CXFA_Node* pUIChild = GetUIChild();
1311 CFX_WideStringC wsStartEndChar; 1310 CFX_WideStringC wsStartEndChar;
1312 if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) { 1311 if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) {
1313 if (wsStartEndChar.GetLength()) { 1312 if (wsStartEndChar.GetLength()) {
1314 val = (FX_CHAR)wsStartEndChar.GetAt(0); 1313 val = (FX_CHAR)wsStartEndChar.GetAt(0);
1315 return TRUE; 1314 return true;
1316 } 1315 }
1317 } 1316 }
1318 return FALSE; 1317 return false;
1319 } 1318 }
1320 1319
1321 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t& val) { 1320 bool CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t& val) {
1322 CXFA_Node* pUIChild = GetUIChild(); 1321 CXFA_Node* pUIChild = GetUIChild();
1323 CFX_WideString wsECLevel; 1322 CFX_WideString wsECLevel;
1324 if (pUIChild->TryCData(XFA_ATTRIBUTE_ErrorCorrectionLevel, wsECLevel)) { 1323 if (pUIChild->TryCData(XFA_ATTRIBUTE_ErrorCorrectionLevel, wsECLevel)) {
1325 val = FXSYS_wtoi(wsECLevel.c_str()); 1324 val = FXSYS_wtoi(wsECLevel.c_str());
1326 return TRUE; 1325 return true;
1327 } 1326 }
1328 return FALSE; 1327 return false;
1329 } 1328 }
1330 1329
1331 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) { 1330 bool CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) {
1332 CXFA_Node* pUIChild = GetUIChild(); 1331 CXFA_Node* pUIChild = GetUIChild();
1333 CXFA_Measurement mModuleWidthHeight; 1332 CXFA_Measurement mModuleWidthHeight;
1334 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleWidth, mModuleWidthHeight)) { 1333 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleWidth, mModuleWidthHeight)) {
1335 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); 1334 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt);
1336 return TRUE; 1335 return true;
1337 } 1336 }
1338 return FALSE; 1337 return false;
1339 } 1338 }
1340 1339
1341 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) { 1340 bool CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) {
1342 CXFA_Node* pUIChild = GetUIChild(); 1341 CXFA_Node* pUIChild = GetUIChild();
1343 CXFA_Measurement mModuleWidthHeight; 1342 CXFA_Measurement mModuleWidthHeight;
1344 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleHeight, mModuleWidthHeight)) { 1343 if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleHeight, mModuleWidthHeight)) {
1345 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); 1344 val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt);
1346 return TRUE; 1345 return true;
1347 } 1346 }
1348 return FALSE; 1347 return false;
1349 } 1348 }
1350 1349
1351 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(FX_BOOL& val) { 1350 bool CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(bool& val) {
1352 CXFA_Node* pUIChild = GetUIChild(); 1351 CXFA_Node* pUIChild = GetUIChild();
1353 FX_BOOL bPrintCheckDigit; 1352 bool bPrintCheckDigit;
1354 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit, bPrintCheckDigit)) { 1353 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit, bPrintCheckDigit)) {
1355 val = bPrintCheckDigit; 1354 val = bPrintCheckDigit;
1356 return TRUE; 1355 return true;
1357 } 1356 }
1358 return FALSE; 1357 return false;
1359 } 1358 }
1360 1359
1361 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) { 1360 bool CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) {
1362 CXFA_Node* pUIChild = GetUIChild(); 1361 CXFA_Node* pUIChild = GetUIChild();
1363 XFA_ATTRIBUTEENUM eTextLocation; 1362 XFA_ATTRIBUTEENUM eTextLocation;
1364 if (pUIChild->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) { 1363 if (pUIChild->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) {
1365 switch (eTextLocation) { 1364 switch (eTextLocation) {
1366 case XFA_ATTRIBUTEENUM_None: 1365 case XFA_ATTRIBUTEENUM_None:
1367 val = BC_TEXT_LOC_NONE; 1366 val = BC_TEXT_LOC_NONE;
1368 return TRUE; 1367 return true;
1369 case XFA_ATTRIBUTEENUM_Above: 1368 case XFA_ATTRIBUTEENUM_Above:
1370 val = BC_TEXT_LOC_ABOVE; 1369 val = BC_TEXT_LOC_ABOVE;
1371 return TRUE; 1370 return true;
1372 case XFA_ATTRIBUTEENUM_Below: 1371 case XFA_ATTRIBUTEENUM_Below:
1373 val = BC_TEXT_LOC_BELOW; 1372 val = BC_TEXT_LOC_BELOW;
1374 return TRUE; 1373 return true;
1375 case XFA_ATTRIBUTEENUM_AboveEmbedded: 1374 case XFA_ATTRIBUTEENUM_AboveEmbedded:
1376 val = BC_TEXT_LOC_ABOVEEMBED; 1375 val = BC_TEXT_LOC_ABOVEEMBED;
1377 return TRUE; 1376 return true;
1378 case XFA_ATTRIBUTEENUM_BelowEmbedded: 1377 case XFA_ATTRIBUTEENUM_BelowEmbedded:
1379 val = BC_TEXT_LOC_BELOWEMBED; 1378 val = BC_TEXT_LOC_BELOWEMBED;
1380 return TRUE; 1379 return true;
1381 default: 1380 default:
1382 break; 1381 break;
1383 } 1382 }
1384 } 1383 }
1385 return FALSE; 1384 return false;
1386 } 1385 }
1387 1386
1388 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Truncate(FX_BOOL& val) { 1387 bool CXFA_WidgetData::GetBarcodeAttribute_Truncate(bool& val) {
1389 CXFA_Node* pUIChild = GetUIChild(); 1388 CXFA_Node* pUIChild = GetUIChild();
1390 FX_BOOL bTruncate; 1389 bool bTruncate;
1391 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate)) { 1390 if (pUIChild->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate)) {
1392 val = bTruncate; 1391 val = bTruncate;
1393 return TRUE; 1392 return true;
1394 } 1393 }
1395 return FALSE; 1394 return false;
1396 } 1395 }
1397 1396
1398 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) { 1397 bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) {
1399 CXFA_Node* pUIChild = GetUIChild(); 1398 CXFA_Node* pUIChild = GetUIChild();
1400 CFX_WideString wsWideNarrowRatio; 1399 CFX_WideString wsWideNarrowRatio;
1401 if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) { 1400 if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) {
1402 FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':'); 1401 FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':');
1403 FX_FLOAT fRatio = 0; 1402 FX_FLOAT fRatio = 0;
1404 if (ptPos >= 0) { 1403 if (ptPos >= 0) {
1405 fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio.c_str()); 1404 fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio.c_str());
1406 } else { 1405 } else {
1407 int32_t fA, fB; 1406 int32_t fA, fB;
1408 fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos).c_str()); 1407 fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos).c_str());
1409 fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1).c_str()); 1408 fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1).c_str());
1410 if (fB) 1409 if (fB)
1411 fRatio = (FX_FLOAT)fA / fB; 1410 fRatio = (FX_FLOAT)fA / fB;
1412 } 1411 }
1413 val = fRatio; 1412 val = fRatio;
1414 return TRUE; 1413 return true;
1415 } 1414 }
1416 return FALSE; 1415 return false;
1417 } 1416 }
1418 1417
1419 void CXFA_WidgetData::GetPasswordChar(CFX_WideString& wsPassWord) { 1418 void CXFA_WidgetData::GetPasswordChar(CFX_WideString& wsPassWord) {
1420 CXFA_Node* pUIChild = GetUIChild(); 1419 CXFA_Node* pUIChild = GetUIChild();
1421 if (pUIChild) { 1420 if (pUIChild) {
1422 pUIChild->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord); 1421 pUIChild->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord);
1423 } else { 1422 } else {
1424 wsPassWord = GetAttributeDefaultValue_Cdata(XFA_Element::PasswordEdit, 1423 wsPassWord = GetAttributeDefaultValue_Cdata(XFA_Element::PasswordEdit,
1425 XFA_ATTRIBUTE_PasswordChar, 1424 XFA_ATTRIBUTE_PasswordChar,
1426 XFA_XDPPACKET_Form); 1425 XFA_XDPPACKET_Form);
1427 } 1426 }
1428 } 1427 }
1429 1428
1430 FX_BOOL CXFA_WidgetData::IsMultiLine() { 1429 bool CXFA_WidgetData::IsMultiLine() {
1431 CXFA_Node* pUIChild = GetUIChild(); 1430 CXFA_Node* pUIChild = GetUIChild();
1432 if (pUIChild) 1431 if (pUIChild)
1433 return pUIChild->GetBoolean(XFA_ATTRIBUTE_MultiLine); 1432 return pUIChild->GetBoolean(XFA_ATTRIBUTE_MultiLine);
1434 return GetAttributeDefaultValue_Boolean( 1433 return GetAttributeDefaultValue_Boolean(
1435 XFA_Element::TextEdit, XFA_ATTRIBUTE_MultiLine, XFA_XDPPACKET_Form); 1434 XFA_Element::TextEdit, XFA_ATTRIBUTE_MultiLine, XFA_XDPPACKET_Form);
1436 } 1435 }
1437 1436
1438 int32_t CXFA_WidgetData::GetVerticalScrollPolicy() { 1437 int32_t CXFA_WidgetData::GetVerticalScrollPolicy() {
1439 CXFA_Node* pUIChild = GetUIChild(); 1438 CXFA_Node* pUIChild = GetUIChild();
1440 if (pUIChild) 1439 if (pUIChild)
(...skipping 15 matching lines...) Expand all
1456 return iMax < 0 ? 0 : iMax; 1455 return iMax < 0 ? 0 : iMax;
1457 } 1456 }
1458 default: 1457 default:
1459 break; 1458 break;
1460 } 1459 }
1461 } 1460 }
1462 } 1461 }
1463 return 0; 1462 return 0;
1464 } 1463 }
1465 1464
1466 FX_BOOL CXFA_WidgetData::GetFracDigits(int32_t& iFracDigits) { 1465 bool CXFA_WidgetData::GetFracDigits(int32_t& iFracDigits) {
1467 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value)) { 1466 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value)) {
1468 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal)) 1467 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal))
1469 return pChild->TryInteger(XFA_ATTRIBUTE_FracDigits, iFracDigits); 1468 return pChild->TryInteger(XFA_ATTRIBUTE_FracDigits, iFracDigits);
1470 } 1469 }
1471 iFracDigits = -1; 1470 iFracDigits = -1;
1472 return FALSE; 1471 return false;
1473 } 1472 }
1474 1473
1475 FX_BOOL CXFA_WidgetData::GetLeadDigits(int32_t& iLeadDigits) { 1474 bool CXFA_WidgetData::GetLeadDigits(int32_t& iLeadDigits) {
1476 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value)) { 1475 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value)) {
1477 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal)) 1476 if (CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal))
1478 return pChild->TryInteger(XFA_ATTRIBUTE_LeadDigits, iLeadDigits); 1477 return pChild->TryInteger(XFA_ATTRIBUTE_LeadDigits, iLeadDigits);
1479 } 1478 }
1480 iLeadDigits = -1; 1479 iLeadDigits = -1;
1481 return FALSE; 1480 return false;
1482 } 1481 }
1483 1482
1484 FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue, 1483 bool CXFA_WidgetData::SetValue(const CFX_WideString& wsValue,
1485 XFA_VALUEPICTURE eValueType) { 1484 XFA_VALUEPICTURE eValueType) {
1486 if (wsValue.IsEmpty()) { 1485 if (wsValue.IsEmpty()) {
1487 SyncValue(wsValue, true); 1486 SyncValue(wsValue, true);
1488 return TRUE; 1487 return true;
1489 } 1488 }
1490 m_bPreNull = m_bIsNull; 1489 m_bPreNull = m_bIsNull;
1491 m_bIsNull = FALSE; 1490 m_bIsNull = false;
1492 CFX_WideString wsNewText(wsValue); 1491 CFX_WideString wsNewText(wsValue);
1493 CFX_WideString wsPicture; 1492 CFX_WideString wsPicture;
1494 GetPictureContent(wsPicture, eValueType); 1493 GetPictureContent(wsPicture, eValueType);
1495 FX_BOOL bValidate = TRUE; 1494 bool bValidate = true;
1496 FX_BOOL bSyncData = FALSE; 1495 bool bSyncData = false;
1497 CXFA_Node* pNode = GetUIChild(); 1496 CXFA_Node* pNode = GetUIChild();
1498 if (!pNode) 1497 if (!pNode)
1499 return TRUE; 1498 return true;
1500 1499
1501 XFA_Element eType = pNode->GetElementType(); 1500 XFA_Element eType = pNode->GetElementType();
1502 if (!wsPicture.IsEmpty()) { 1501 if (!wsPicture.IsEmpty()) {
1503 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); 1502 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr();
1504 IFX_Locale* pLocale = GetLocal(); 1503 IFX_Locale* pLocale = GetLocal();
1505 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 1504 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
1506 bValidate = 1505 bValidate =
1507 widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture); 1506 widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture);
1508 if (bValidate) { 1507 if (bValidate) {
1509 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, 1508 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText,
1510 wsPicture, pLocale, pLocalMgr); 1509 wsPicture, pLocale, pLocalMgr);
1511 wsNewText = widgetValue.GetValue(); 1510 wsNewText = widgetValue.GetValue();
1512 if (eType == XFA_Element::NumericEdit) { 1511 if (eType == XFA_Element::NumericEdit) {
1513 int32_t iLeadDigits = 0; 1512 int32_t iLeadDigits = 0;
1514 int32_t iFracDigits = 0; 1513 int32_t iFracDigits = 0;
1515 GetLeadDigits(iLeadDigits); 1514 GetLeadDigits(iLeadDigits);
1516 GetFracDigits(iFracDigits); 1515 GetFracDigits(iFracDigits);
1517 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits); 1516 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits);
1518 } 1517 }
1519 bSyncData = TRUE; 1518 bSyncData = true;
1520 } 1519 }
1521 } else { 1520 } else {
1522 if (eType == XFA_Element::NumericEdit) { 1521 if (eType == XFA_Element::NumericEdit) {
1523 if (wsNewText != FX_WSTRC(L"0")) { 1522 if (wsNewText != FX_WSTRC(L"0")) {
1524 int32_t iLeadDigits = 0; 1523 int32_t iLeadDigits = 0;
1525 int32_t iFracDigits = 0; 1524 int32_t iFracDigits = 0;
1526 GetLeadDigits(iLeadDigits); 1525 GetLeadDigits(iLeadDigits);
1527 GetFracDigits(iFracDigits); 1526 GetFracDigits(iFracDigits);
1528 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits); 1527 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits);
1529 } 1528 }
1530 bSyncData = TRUE; 1529 bSyncData = true;
1531 } 1530 }
1532 } 1531 }
1533 if (eType != XFA_Element::NumericEdit || bSyncData) 1532 if (eType != XFA_Element::NumericEdit || bSyncData)
1534 SyncValue(wsNewText, true); 1533 SyncValue(wsNewText, true);
1535 1534
1536 return bValidate; 1535 return bValidate;
1537 } 1536 }
1538 1537
1539 FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture, 1538 bool CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
1540 XFA_VALUEPICTURE ePicture) { 1539 XFA_VALUEPICTURE ePicture) {
1541 if (ePicture == XFA_VALUEPICTURE_Raw) 1540 if (ePicture == XFA_VALUEPICTURE_Raw)
1542 return FALSE; 1541 return false;
1543 1542
1544 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 1543 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
1545 switch (ePicture) { 1544 switch (ePicture) {
1546 case XFA_VALUEPICTURE_Display: { 1545 case XFA_VALUEPICTURE_Display: {
1547 if (CXFA_Node* pFormat = m_pNode->GetChild(0, XFA_Element::Format)) { 1546 if (CXFA_Node* pFormat = m_pNode->GetChild(0, XFA_Element::Format)) {
1548 if (CXFA_Node* pPicture = pFormat->GetChild(0, XFA_Element::Picture)) { 1547 if (CXFA_Node* pPicture = pFormat->GetChild(0, XFA_Element::Picture)) {
1549 if (pPicture->TryContent(wsPicture)) 1548 if (pPicture->TryContent(wsPicture))
1550 return TRUE; 1549 return true;
1551 } 1550 }
1552 } 1551 }
1553 CFX_WideString wsDataPicture, wsTimePicture; 1552 CFX_WideString wsDataPicture, wsTimePicture;
1554 IFX_Locale* pLocale = GetLocal(); 1553 IFX_Locale* pLocale = GetLocal();
1555 if (!pLocale) 1554 if (!pLocale)
1556 return FALSE; 1555 return false;
1557 1556
1558 uint32_t dwType = widgetValue.GetType(); 1557 uint32_t dwType = widgetValue.GetType();
1559 switch (dwType) { 1558 switch (dwType) {
1560 case XFA_VT_DATE: 1559 case XFA_VT_DATE:
1561 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 1560 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
1562 wsPicture); 1561 wsPicture);
1563 break; 1562 break;
1564 case XFA_VT_TIME: 1563 case XFA_VT_TIME:
1565 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 1564 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
1566 wsPicture); 1565 wsPicture);
1567 break; 1566 break;
1568 case XFA_VT_DATETIME: 1567 case XFA_VT_DATETIME:
1569 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 1568 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
1570 wsDataPicture); 1569 wsDataPicture);
1571 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, 1570 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium,
1572 wsTimePicture); 1571 wsTimePicture);
1573 wsPicture = wsDataPicture + FX_WSTRC(L"T") + wsTimePicture; 1572 wsPicture = wsDataPicture + FX_WSTRC(L"T") + wsTimePicture;
1574 break; 1573 break;
1575 case XFA_VT_DECIMAL: 1574 case XFA_VT_DECIMAL:
1576 case XFA_VT_FLOAT: 1575 case XFA_VT_FLOAT:
1577 break; 1576 break;
1578 default: 1577 default:
1579 break; 1578 break;
1580 } 1579 }
1581 return TRUE; 1580 return true;
1582 } 1581 }
1583 1582
1584 case XFA_VALUEPICTURE_Edit: { 1583 case XFA_VALUEPICTURE_Edit: {
1585 CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui); 1584 CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui);
1586 if (pUI) { 1585 if (pUI) {
1587 if (CXFA_Node* pPicture = pUI->GetChild(0, XFA_Element::Picture)) { 1586 if (CXFA_Node* pPicture = pUI->GetChild(0, XFA_Element::Picture)) {
1588 if (pPicture->TryContent(wsPicture)) 1587 if (pPicture->TryContent(wsPicture))
1589 return TRUE; 1588 return true;
1590 } 1589 }
1591 } 1590 }
1592 { 1591 {
1593 CFX_WideString wsDataPicture, wsTimePicture; 1592 CFX_WideString wsDataPicture, wsTimePicture;
1594 IFX_Locale* pLocale = GetLocal(); 1593 IFX_Locale* pLocale = GetLocal();
1595 if (!pLocale) { 1594 if (!pLocale) {
1596 return FALSE; 1595 return false;
1597 } 1596 }
1598 uint32_t dwType = widgetValue.GetType(); 1597 uint32_t dwType = widgetValue.GetType();
1599 switch (dwType) { 1598 switch (dwType) {
1600 case XFA_VT_DATE: 1599 case XFA_VT_DATE:
1601 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 1600 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
1602 wsPicture); 1601 wsPicture);
1603 break; 1602 break;
1604 case XFA_VT_TIME: 1603 case XFA_VT_TIME:
1605 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 1604 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
1606 wsPicture); 1605 wsPicture);
1607 break; 1606 break;
1608 case XFA_VT_DATETIME: 1607 case XFA_VT_DATETIME:
1609 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 1608 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
1610 wsDataPicture); 1609 wsDataPicture);
1611 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, 1610 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short,
1612 wsTimePicture); 1611 wsTimePicture);
1613 wsPicture = wsDataPicture + L"T" + wsTimePicture; 1612 wsPicture = wsDataPicture + L"T" + wsTimePicture;
1614 break; 1613 break;
1615 default: 1614 default:
1616 break; 1615 break;
1617 } 1616 }
1618 } 1617 }
1619 return TRUE; 1618 return true;
1620 } 1619 }
1621 case XFA_VALUEPICTURE_DataBind: { 1620 case XFA_VALUEPICTURE_DataBind: {
1622 if (CXFA_Bind bind = GetBind()) { 1621 if (CXFA_Bind bind = GetBind()) {
1623 bind.GetPicture(wsPicture); 1622 bind.GetPicture(wsPicture);
1624 return TRUE; 1623 return true;
1625 } 1624 }
1626 break; 1625 break;
1627 } 1626 }
1628 default: 1627 default:
1629 break; 1628 break;
1630 } 1629 }
1631 return FALSE; 1630 return false;
1632 } 1631 }
1633 1632
1634 IFX_Locale* CXFA_WidgetData::GetLocal() { 1633 IFX_Locale* CXFA_WidgetData::GetLocal() {
1635 if (!m_pNode) 1634 if (!m_pNode)
1636 return nullptr; 1635 return nullptr;
1637 1636
1638 CFX_WideString wsLocaleName; 1637 CFX_WideString wsLocaleName;
1639 if (!m_pNode->GetLocaleName(wsLocaleName)) 1638 if (!m_pNode->GetLocaleName(wsLocaleName))
1640 return nullptr; 1639 return nullptr;
1641 if (wsLocaleName == FX_WSTRC(L"ambient")) 1640 if (wsLocaleName == FX_WSTRC(L"ambient"))
1642 return m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); 1641 return m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale();
1643 return m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName); 1642 return m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName);
1644 } 1643 }
1645 1644
1646 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, 1645 bool CXFA_WidgetData::GetValue(CFX_WideString& wsValue,
1647 XFA_VALUEPICTURE eValueType) { 1646 XFA_VALUEPICTURE eValueType) {
1648 wsValue = m_pNode->GetContent(); 1647 wsValue = m_pNode->GetContent();
1649 1648
1650 if (eValueType == XFA_VALUEPICTURE_Display) 1649 if (eValueType == XFA_VALUEPICTURE_Display)
1651 GetItemLabel(wsValue.AsStringC(), wsValue); 1650 GetItemLabel(wsValue.AsStringC(), wsValue);
1652 1651
1653 CFX_WideString wsPicture; 1652 CFX_WideString wsPicture;
1654 GetPictureContent(wsPicture, eValueType); 1653 GetPictureContent(wsPicture, eValueType);
1655 CXFA_Node* pNode = GetUIChild(); 1654 CXFA_Node* pNode = GetUIChild();
1656 if (!pNode) 1655 if (!pNode)
1657 return TRUE; 1656 return true;
1658 1657
1659 switch (GetUIChild()->GetElementType()) { 1658 switch (GetUIChild()->GetElementType()) {
1660 case XFA_Element::ChoiceList: { 1659 case XFA_Element::ChoiceList: {
1661 if (eValueType == XFA_VALUEPICTURE_Display) { 1660 if (eValueType == XFA_VALUEPICTURE_Display) {
1662 int32_t iSelItemIndex = GetSelectedItem(0); 1661 int32_t iSelItemIndex = GetSelectedItem(0);
1663 if (iSelItemIndex >= 0) { 1662 if (iSelItemIndex >= 0) {
1664 GetChoiceListItem(wsValue, iSelItemIndex); 1663 GetChoiceListItem(wsValue, iSelItemIndex);
1665 wsPicture.clear(); 1664 wsPicture.clear();
1666 } 1665 }
1667 } 1666 }
1668 } break; 1667 } break;
1669 case XFA_Element::NumericEdit: 1668 case XFA_Element::NumericEdit:
1670 if (eValueType != XFA_VALUEPICTURE_Raw && wsPicture.IsEmpty()) { 1669 if (eValueType != XFA_VALUEPICTURE_Raw && wsPicture.IsEmpty()) {
1671 IFX_Locale* pLocale = GetLocal(); 1670 IFX_Locale* pLocale = GetLocal();
1672 if (eValueType == XFA_VALUEPICTURE_Display && pLocale) { 1671 if (eValueType == XFA_VALUEPICTURE_Display && pLocale) {
1673 CFX_WideString wsOutput; 1672 CFX_WideString wsOutput;
1674 NormalizeNumStr(wsValue, wsOutput); 1673 NormalizeNumStr(wsValue, wsOutput);
1675 FormatNumStr(wsOutput, pLocale, wsOutput); 1674 FormatNumStr(wsOutput, pLocale, wsOutput);
1676 wsValue = wsOutput; 1675 wsValue = wsOutput;
1677 } 1676 }
1678 } 1677 }
1679 break; 1678 break;
1680 default: 1679 default:
1681 break; 1680 break;
1682 } 1681 }
1683 if (wsPicture.IsEmpty()) 1682 if (wsPicture.IsEmpty())
1684 return TRUE; 1683 return true;
1685 1684
1686 if (IFX_Locale* pLocale = GetLocal()) { 1685 if (IFX_Locale* pLocale = GetLocal()) {
1687 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 1686 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
1688 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); 1687 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr();
1689 switch (widgetValue.GetType()) { 1688 switch (widgetValue.GetType()) {
1690 case XFA_VT_DATE: { 1689 case XFA_VT_DATE: {
1691 CFX_WideString wsDate, wsTime; 1690 CFX_WideString wsDate, wsTime;
1692 if (SplitDateTime(wsValue, wsDate, wsTime)) { 1691 if (SplitDateTime(wsValue, wsDate, wsTime)) {
1693 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); 1692 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr);
1694 if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) 1693 if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType))
1695 return TRUE; 1694 return true;
1696 } 1695 }
1697 break; 1696 break;
1698 } 1697 }
1699 case XFA_VT_TIME: { 1698 case XFA_VT_TIME: {
1700 CFX_WideString wsDate, wsTime; 1699 CFX_WideString wsDate, wsTime;
1701 if (SplitDateTime(wsValue, wsDate, wsTime)) { 1700 if (SplitDateTime(wsValue, wsDate, wsTime)) {
1702 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); 1701 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr);
1703 if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) 1702 if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType))
1704 return TRUE; 1703 return true;
1705 } 1704 }
1706 break; 1705 break;
1707 } 1706 }
1708 default: 1707 default:
1709 break; 1708 break;
1710 } 1709 }
1711 widgetValue.FormatPatterns(wsValue, wsPicture, pLocale, eValueType); 1710 widgetValue.FormatPatterns(wsValue, wsPicture, pLocale, eValueType);
1712 } 1711 }
1713 return TRUE; 1712 return true;
1714 } 1713 }
1715 1714
1716 FX_BOOL CXFA_WidgetData::GetNormalizeDataValue( 1715 bool CXFA_WidgetData::GetNormalizeDataValue(const CFX_WideString& wsValue,
1717 const CFX_WideString& wsValue, 1716 CFX_WideString& wsNormalizeValue) {
1718 CFX_WideString& wsNormalizeValue) {
1719 wsNormalizeValue = wsValue; 1717 wsNormalizeValue = wsValue;
1720 if (wsValue.IsEmpty()) 1718 if (wsValue.IsEmpty())
1721 return TRUE; 1719 return true;
1722 1720
1723 CFX_WideString wsPicture; 1721 CFX_WideString wsPicture;
1724 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); 1722 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind);
1725 if (wsPicture.IsEmpty()) 1723 if (wsPicture.IsEmpty())
1726 return TRUE; 1724 return true;
1727 1725
1728 ASSERT(GetNode()); 1726 ASSERT(GetNode());
1729 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); 1727 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr();
1730 IFX_Locale* pLocale = GetLocal(); 1728 IFX_Locale* pLocale = GetLocal();
1731 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); 1729 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
1732 if (widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture)) { 1730 if (widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture)) {
1733 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNormalizeValue, 1731 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNormalizeValue,
1734 wsPicture, pLocale, pLocalMgr); 1732 wsPicture, pLocale, pLocalMgr);
1735 wsNormalizeValue = widgetValue.GetValue(); 1733 wsNormalizeValue = widgetValue.GetValue();
1736 return TRUE; 1734 return true;
1737 } 1735 }
1738 return FALSE; 1736 return false;
1739 } 1737 }
1740 1738
1741 FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideString& wsValue, 1739 bool CXFA_WidgetData::GetFormatDataValue(const CFX_WideString& wsValue,
1742 CFX_WideString& wsFormattedValue) { 1740 CFX_WideString& wsFormattedValue) {
1743 wsFormattedValue = wsValue; 1741 wsFormattedValue = wsValue;
1744 if (wsValue.IsEmpty()) 1742 if (wsValue.IsEmpty())
1745 return TRUE; 1743 return true;
1746 1744
1747 CFX_WideString wsPicture; 1745 CFX_WideString wsPicture;
1748 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); 1746 GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind);
1749 if (wsPicture.IsEmpty()) 1747 if (wsPicture.IsEmpty())
1750 return TRUE; 1748 return true;
1751 1749
1752 if (IFX_Locale* pLocale = GetLocal()) { 1750 if (IFX_Locale* pLocale = GetLocal()) {
1753 ASSERT(GetNode()); 1751 ASSERT(GetNode());
1754 CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_Element::Value); 1752 CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_Element::Value);
1755 if (!pNodeValue) 1753 if (!pNodeValue)
1756 return FALSE; 1754 return false;
1757 1755
1758 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); 1756 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild);
1759 if (!pValueChild) 1757 if (!pValueChild)
1760 return FALSE; 1758 return false;
1761 1759
1762 int32_t iVTType = XFA_VT_NULL; 1760 int32_t iVTType = XFA_VT_NULL;
1763 switch (pValueChild->GetElementType()) { 1761 switch (pValueChild->GetElementType()) {
1764 case XFA_Element::Decimal: 1762 case XFA_Element::Decimal:
1765 iVTType = XFA_VT_DECIMAL; 1763 iVTType = XFA_VT_DECIMAL;
1766 break; 1764 break;
1767 case XFA_Element::Float: 1765 case XFA_Element::Float:
1768 iVTType = XFA_VT_FLOAT; 1766 iVTType = XFA_VT_FLOAT;
1769 break; 1767 break;
1770 case XFA_Element::Date: 1768 case XFA_Element::Date:
(...skipping 20 matching lines...) Expand all
1791 } 1789 }
1792 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); 1790 CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr();
1793 CXFA_LocaleValue widgetValue(iVTType, wsValue, pLocalMgr); 1791 CXFA_LocaleValue widgetValue(iVTType, wsValue, pLocalMgr);
1794 switch (widgetValue.GetType()) { 1792 switch (widgetValue.GetType()) {
1795 case XFA_VT_DATE: { 1793 case XFA_VT_DATE: {
1796 CFX_WideString wsDate, wsTime; 1794 CFX_WideString wsDate, wsTime;
1797 if (SplitDateTime(wsValue, wsDate, wsTime)) { 1795 if (SplitDateTime(wsValue, wsDate, wsTime)) {
1798 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); 1796 CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr);
1799 if (date.FormatPatterns(wsFormattedValue, wsPicture, pLocale, 1797 if (date.FormatPatterns(wsFormattedValue, wsPicture, pLocale,
1800 XFA_VALUEPICTURE_DataBind)) { 1798 XFA_VALUEPICTURE_DataBind)) {
1801 return TRUE; 1799 return true;
1802 } 1800 }
1803 } 1801 }
1804 break; 1802 break;
1805 } 1803 }
1806 case XFA_VT_TIME: { 1804 case XFA_VT_TIME: {
1807 CFX_WideString wsDate, wsTime; 1805 CFX_WideString wsDate, wsTime;
1808 if (SplitDateTime(wsValue, wsDate, wsTime)) { 1806 if (SplitDateTime(wsValue, wsDate, wsTime)) {
1809 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); 1807 CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr);
1810 if (time.FormatPatterns(wsFormattedValue, wsPicture, pLocale, 1808 if (time.FormatPatterns(wsFormattedValue, wsPicture, pLocale,
1811 XFA_VALUEPICTURE_DataBind)) { 1809 XFA_VALUEPICTURE_DataBind)) {
1812 return TRUE; 1810 return true;
1813 } 1811 }
1814 } 1812 }
1815 break; 1813 break;
1816 } 1814 }
1817 default: 1815 default:
1818 break; 1816 break;
1819 } 1817 }
1820 widgetValue.FormatPatterns(wsFormattedValue, wsPicture, pLocale, 1818 widgetValue.FormatPatterns(wsFormattedValue, wsPicture, pLocale,
1821 XFA_VALUEPICTURE_DataBind); 1819 XFA_VALUEPICTURE_DataBind);
1822 } 1820 }
1823 return FALSE; 1821 return false;
1824 } 1822 }
1825 1823
1826 void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue, 1824 void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue,
1827 CFX_WideString& wsOutput) { 1825 CFX_WideString& wsOutput) {
1828 if (wsValue.IsEmpty()) 1826 if (wsValue.IsEmpty())
1829 return; 1827 return;
1830 1828
1831 wsOutput = wsValue; 1829 wsOutput = wsValue;
1832 wsOutput.TrimLeft('0'); 1830 wsOutput.TrimLeft('0');
1833 int32_t dot_index = wsOutput.Find('.'); 1831 int32_t dot_index = wsOutput.Find('.');
1834 int32_t iFracDigits = 0; 1832 int32_t iFracDigits = 0;
1835 if (!wsOutput.IsEmpty() && dot_index >= 0 && 1833 if (!wsOutput.IsEmpty() && dot_index >= 0 &&
1836 (!GetFracDigits(iFracDigits) || iFracDigits != -1)) { 1834 (!GetFracDigits(iFracDigits) || iFracDigits != -1)) {
1837 wsOutput.TrimRight(L"0"); 1835 wsOutput.TrimRight(L"0");
1838 wsOutput.TrimRight(L"."); 1836 wsOutput.TrimRight(L".");
1839 } 1837 }
1840 if (wsOutput.IsEmpty() || wsOutput[0] == '.') 1838 if (wsOutput.IsEmpty() || wsOutput[0] == '.')
1841 wsOutput.Insert(0, '0'); 1839 wsOutput.Insert(0, '0');
1842 } 1840 }
1843 1841
1844 void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue, 1842 void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
1845 IFX_Locale* pLocale, 1843 IFX_Locale* pLocale,
1846 CFX_WideString& wsOutput) { 1844 CFX_WideString& wsOutput) {
1847 if (wsValue.IsEmpty()) 1845 if (wsValue.IsEmpty())
1848 return; 1846 return;
1849 1847
1850 CFX_WideString wsSrcNum = wsValue; 1848 CFX_WideString wsSrcNum = wsValue;
1851 CFX_WideString wsGroupSymbol; 1849 CFX_WideString wsGroupSymbol;
1852 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); 1850 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol);
1853 FX_BOOL bNeg = FALSE; 1851 bool bNeg = false;
1854 if (wsSrcNum[0] == '-') { 1852 if (wsSrcNum[0] == '-') {
1855 bNeg = TRUE; 1853 bNeg = true;
1856 wsSrcNum.Delete(0, 1); 1854 wsSrcNum.Delete(0, 1);
1857 } 1855 }
1858 int32_t len = wsSrcNum.GetLength(); 1856 int32_t len = wsSrcNum.GetLength();
1859 int32_t dot_index = wsSrcNum.Find('.'); 1857 int32_t dot_index = wsSrcNum.Find('.');
1860 if (dot_index == -1) 1858 if (dot_index == -1)
1861 dot_index = len; 1859 dot_index = len;
1862 1860
1863 int32_t cc = dot_index - 1; 1861 int32_t cc = dot_index - 1;
1864 if (cc >= 0) { 1862 if (cc >= 0) {
1865 int nPos = dot_index % 3; 1863 int nPos = dot_index % 3;
(...skipping 28 matching lines...) Expand all
1894 pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue); 1892 pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue);
1895 1893
1896 m_pNode->SetContent(wsValue, wsFormatValue, bNotify); 1894 m_pNode->SetContent(wsValue, wsFormatValue, bNotify);
1897 } 1895 }
1898 1896
1899 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, 1897 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems,
1900 const CFX_WideString& wsText, 1898 const CFX_WideString& wsText,
1901 int32_t nIndex) { 1899 int32_t nIndex) {
1902 CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_Element::Text); 1900 CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_Element::Text);
1903 pItems->InsertChild(nIndex, pText); 1901 pItems->InsertChild(nIndex, pText);
1904 pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE); 1902 pText->SetContent(wsText, wsText, false, false, false);
1905 } 1903 }
1906 1904
1907 CFX_WideString CXFA_WidgetData::NumericLimit(const CFX_WideString& wsValue, 1905 CFX_WideString CXFA_WidgetData::NumericLimit(const CFX_WideString& wsValue,
1908 int32_t iLead, 1906 int32_t iLead,
1909 int32_t iTread) const { 1907 int32_t iTread) const {
1910 if ((iLead == -1) && (iTread == -1)) 1908 if ((iLead == -1) && (iTread == -1))
1911 return wsValue; 1909 return wsValue;
1912 1910
1913 CFX_WideString wsRet; 1911 CFX_WideString wsRet;
1914 int32_t iLead_ = 0, iTread_ = -1; 1912 int32_t iLead_ = 0, iTread_ = -1;
(...skipping 25 matching lines...) Expand all
1940 } 1938 }
1941 } 1939 }
1942 } else if (wc == L'.') { 1940 } else if (wc == L'.') {
1943 iTread_ = 0; 1941 iTread_ = 0;
1944 iLead = -1; 1942 iLead = -1;
1945 } 1943 }
1946 wsRet += wc; 1944 wsRet += wc;
1947 } 1945 }
1948 return wsRet; 1946 return wsRet;
1949 } 1947 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_widgetdata.h ('k') | xfa/fxfa/parser/cxfa_xml_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698