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

Side by Side Diff: xfa/fxfa/parser/cxfa_nodehelper.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_nodehelper.h ('k') | xfa/fxfa/parser/cxfa_nodelist.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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/cxfa_nodehelper.h" 7 #include "xfa/fxfa/parser/cxfa_nodehelper.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 #include "xfa/fxfa/parser/cxfa_document.h" 10 #include "xfa/fxfa/parser/cxfa_document.h"
11 #include "xfa/fxfa/parser/cxfa_scriptcontext.h" 11 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
12 #include "xfa/fxfa/parser/xfa_localemgr.h" 12 #include "xfa/fxfa/parser/xfa_localemgr.h"
13 #include "xfa/fxfa/parser/xfa_object.h" 13 #include "xfa/fxfa/parser/xfa_object.h"
14 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" 14 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
15 #include "xfa/fxfa/parser/xfa_utils.h" 15 #include "xfa/fxfa/parser/xfa_utils.h"
16 16
17 CXFA_NodeHelper::CXFA_NodeHelper() 17 CXFA_NodeHelper::CXFA_NodeHelper()
18 : m_eLastCreateType(XFA_Element::DataValue), 18 : m_eLastCreateType(XFA_Element::DataValue),
19 m_pCreateParent(nullptr), 19 m_pCreateParent(nullptr),
20 m_iCreateCount(0), 20 m_iCreateCount(0),
21 m_iCreateFlag(XFA_RESOLVENODE_RSTYPE_CreateNodeOne), 21 m_iCreateFlag(XFA_RESOLVENODE_RSTYPE_CreateNodeOne),
22 m_iCurAllStart(-1), 22 m_iCurAllStart(-1),
23 m_pAllStartParent(nullptr) {} 23 m_pAllStartParent(nullptr) {}
24 24
25 CXFA_NodeHelper::~CXFA_NodeHelper() {} 25 CXFA_NodeHelper::~CXFA_NodeHelper() {}
26 26
27 CXFA_Node* CXFA_NodeHelper::ResolveNodes_GetOneChild(CXFA_Node* parent, 27 CXFA_Node* CXFA_NodeHelper::ResolveNodes_GetOneChild(CXFA_Node* parent,
28 const FX_WCHAR* pwsName, 28 const FX_WCHAR* pwsName,
29 FX_BOOL bIsClassName) { 29 bool bIsClassName) {
30 if (!parent) { 30 if (!parent) {
31 return nullptr; 31 return nullptr;
32 } 32 }
33 CXFA_NodeArray siblings; 33 CXFA_NodeArray siblings;
34 uint32_t uNameHash = FX_HashCode_GetW(CFX_WideStringC(pwsName), false); 34 uint32_t uNameHash = FX_HashCode_GetW(CFX_WideStringC(pwsName), false);
35 NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName); 35 NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName);
36 if (siblings.GetSize() == 0) { 36 if (siblings.GetSize() == 0) {
37 return nullptr; 37 return nullptr;
38 } 38 }
39 return siblings[0]; 39 return siblings[0];
40 } 40 }
41 41
42 int32_t CXFA_NodeHelper::CountSiblings(CXFA_Node* pNode, 42 int32_t CXFA_NodeHelper::CountSiblings(CXFA_Node* pNode,
43 XFA_LOGIC_TYPE eLogicType, 43 XFA_LOGIC_TYPE eLogicType,
44 CXFA_NodeArray* pSiblings, 44 CXFA_NodeArray* pSiblings,
45 FX_BOOL bIsClassName) { 45 bool bIsClassName) {
46 if (!pNode) 46 if (!pNode)
47 return 0; 47 return 0;
48 CXFA_Node* parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent); 48 CXFA_Node* parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent);
49 if (!parent) 49 if (!parent)
50 return 0; 50 return 0;
51 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( 51 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(
52 parent->GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); 52 parent->GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN);
53 if (!pProperty && eLogicType == XFA_LOGIC_Transparent) { 53 if (!pProperty && eLogicType == XFA_LOGIC_Transparent) {
54 parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent); 54 parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent);
55 if (!parent) { 55 if (!parent) {
56 return 0; 56 return 0;
57 } 57 }
58 } 58 }
59 if (bIsClassName) { 59 if (bIsClassName) {
60 return NodeAcc_TraverseSiblings(parent, pNode->GetClassHashCode(), 60 return NodeAcc_TraverseSiblings(parent, pNode->GetClassHashCode(),
61 pSiblings, eLogicType, bIsClassName); 61 pSiblings, eLogicType, bIsClassName);
62 } else { 62 } else {
63 return NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings, 63 return NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings,
64 eLogicType, bIsClassName); 64 eLogicType, bIsClassName);
65 } 65 }
66 } 66 }
67 67
68 int32_t CXFA_NodeHelper::NodeAcc_TraverseAnySiblings(CXFA_Node* parent, 68 int32_t CXFA_NodeHelper::NodeAcc_TraverseAnySiblings(CXFA_Node* parent,
69 uint32_t dNameHash, 69 uint32_t dNameHash,
70 CXFA_NodeArray* pSiblings, 70 CXFA_NodeArray* pSiblings,
71 FX_BOOL bIsClassName) { 71 bool bIsClassName) {
72 if (!parent || !pSiblings) { 72 if (!parent || !pSiblings) {
73 return 0; 73 return 0;
74 } 74 }
75 int32_t nCount = 0; 75 int32_t nCount = 0;
76 int32_t i = 0; 76 int32_t i = 0;
77 CXFA_NodeArray properties; 77 CXFA_NodeArray properties;
78 parent->GetNodeList(properties, XFA_NODEFILTER_Properties); 78 parent->GetNodeList(properties, XFA_NODEFILTER_Properties);
79 int32_t nProperties = properties.GetSize(); 79 int32_t nProperties = properties.GetSize();
80 for (i = 0; i < nProperties; ++i) { 80 for (i = 0; i < nProperties; ++i) {
81 CXFA_Node* child = properties[i]; 81 CXFA_Node* child = properties[i];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 nCount += 122 nCount +=
123 NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName); 123 NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName);
124 } 124 }
125 return nCount; 125 return nCount;
126 } 126 }
127 127
128 int32_t CXFA_NodeHelper::NodeAcc_TraverseSiblings(CXFA_Node* parent, 128 int32_t CXFA_NodeHelper::NodeAcc_TraverseSiblings(CXFA_Node* parent,
129 uint32_t dNameHash, 129 uint32_t dNameHash,
130 CXFA_NodeArray* pSiblings, 130 CXFA_NodeArray* pSiblings,
131 XFA_LOGIC_TYPE eLogicType, 131 XFA_LOGIC_TYPE eLogicType,
132 FX_BOOL bIsClassName, 132 bool bIsClassName,
133 FX_BOOL bIsFindProperty) { 133 bool bIsFindProperty) {
134 if (!parent || !pSiblings) { 134 if (!parent || !pSiblings) {
135 return 0; 135 return 0;
136 } 136 }
137 int32_t nCount = 0; 137 int32_t nCount = 0;
138 int32_t i = 0; 138 int32_t i = 0;
139 if (bIsFindProperty) { 139 if (bIsFindProperty) {
140 CXFA_NodeArray properties; 140 CXFA_NodeArray properties;
141 parent->GetNodeList(properties, XFA_NODEFILTER_Properties); 141 parent->GetNodeList(properties, XFA_NODEFILTER_Properties);
142 int32_t nProperties = properties.GetSize(); 142 int32_t nProperties = properties.GetSize();
143 for (i = 0; i < nProperties; ++i) { 143 for (i = 0; i < nProperties; ++i) {
144 CXFA_Node* child = properties[i]; 144 CXFA_Node* child = properties[i];
145 if (bIsClassName) { 145 if (bIsClassName) {
146 if (child->GetClassHashCode() == dNameHash) { 146 if (child->GetClassHashCode() == dNameHash) {
147 pSiblings->Add(child); 147 pSiblings->Add(child);
148 nCount++; 148 nCount++;
149 } 149 }
150 } else { 150 } else {
151 if (child->GetNameHash() == dNameHash) { 151 if (child->GetNameHash() == dNameHash) {
152 if (child->GetElementType() != XFA_Element::PageSet && 152 if (child->GetElementType() != XFA_Element::PageSet &&
153 child->GetElementType() != XFA_Element::Extras && 153 child->GetElementType() != XFA_Element::Extras &&
154 child->GetElementType() != XFA_Element::Items) { 154 child->GetElementType() != XFA_Element::Items) {
155 pSiblings->Add(child); 155 pSiblings->Add(child);
156 nCount++; 156 nCount++;
157 } 157 }
158 } 158 }
159 } 159 }
160 if (child->IsUnnamed() && 160 if (child->IsUnnamed() &&
161 child->GetElementType() == XFA_Element::PageSet) { 161 child->GetElementType() == XFA_Element::PageSet) {
162 nCount += NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, 162 nCount += NodeAcc_TraverseSiblings(child, dNameHash, pSiblings,
163 eLogicType, bIsClassName, FALSE); 163 eLogicType, bIsClassName, false);
164 } 164 }
165 } 165 }
166 if (nCount > 0) { 166 if (nCount > 0) {
167 return nCount; 167 return nCount;
168 } 168 }
169 } 169 }
170 CXFA_NodeArray children; 170 CXFA_NodeArray children;
171 parent->GetNodeList(children, XFA_NODEFILTER_Children); 171 parent->GetNodeList(children, XFA_NODEFILTER_Children);
172 int32_t nChildren = children.GetSize(); 172 int32_t nChildren = children.GetSize();
173 for (i = 0; i < nChildren; i++) { 173 for (i = 0; i < nChildren; i++) {
(...skipping 15 matching lines...) Expand all
189 } 189 }
190 nCount++; 190 nCount++;
191 } 191 }
192 } 192 }
193 if (eLogicType == XFA_LOGIC_NoTransparent) { 193 if (eLogicType == XFA_LOGIC_NoTransparent) {
194 continue; 194 continue;
195 } 195 }
196 if (NodeIsTransparent(child) && 196 if (NodeIsTransparent(child) &&
197 child->GetElementType() != XFA_Element::PageSet) { 197 child->GetElementType() != XFA_Element::PageSet) {
198 nCount += NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, 198 nCount += NodeAcc_TraverseSiblings(child, dNameHash, pSiblings,
199 eLogicType, bIsClassName, FALSE); 199 eLogicType, bIsClassName, false);
200 } 200 }
201 } 201 }
202 return nCount; 202 return nCount;
203 } 203 }
204 204
205 CXFA_Node* CXFA_NodeHelper::ResolveNodes_GetParent(CXFA_Node* pNode, 205 CXFA_Node* CXFA_NodeHelper::ResolveNodes_GetParent(CXFA_Node* pNode,
206 XFA_LOGIC_TYPE eLogicType) { 206 XFA_LOGIC_TYPE eLogicType) {
207 if (!pNode) { 207 if (!pNode) {
208 return nullptr; 208 return nullptr;
209 } 209 }
210 if (eLogicType == XFA_LOGIC_NoTransparent) { 210 if (eLogicType == XFA_LOGIC_NoTransparent) {
211 return pNode->GetNodeItem(XFA_NODEITEM_Parent); 211 return pNode->GetNodeItem(XFA_NODEITEM_Parent);
212 } 212 }
213 CXFA_Node* parent; 213 CXFA_Node* parent;
214 CXFA_Node* node = pNode; 214 CXFA_Node* node = pNode;
215 while (TRUE) { 215 while (true) {
216 parent = ResolveNodes_GetParent(node); 216 parent = ResolveNodes_GetParent(node);
217 if (!parent) { 217 if (!parent) {
218 break; 218 break;
219 } 219 }
220 XFA_Element parentType = parent->GetElementType(); 220 XFA_Element parentType = parent->GetElementType();
221 if ((!parent->IsUnnamed() && parentType != XFA_Element::SubformSet) || 221 if ((!parent->IsUnnamed() && parentType != XFA_Element::SubformSet) ||
222 parentType == XFA_Element::Variables) { 222 parentType == XFA_Element::Variables) {
223 break; 223 break;
224 } 224 }
225 node = parent; 225 node = parent;
226 } 226 }
227 return parent; 227 return parent;
228 } 228 }
229 229
230 int32_t CXFA_NodeHelper::GetIndex(CXFA_Node* pNode, 230 int32_t CXFA_NodeHelper::GetIndex(CXFA_Node* pNode,
231 XFA_LOGIC_TYPE eLogicType, 231 XFA_LOGIC_TYPE eLogicType,
232 FX_BOOL bIsProperty, 232 bool bIsProperty,
233 FX_BOOL bIsClassIndex) { 233 bool bIsClassIndex) {
234 CXFA_Node* parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent); 234 CXFA_Node* parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent);
235 if (!parent) { 235 if (!parent) {
236 return 0; 236 return 0;
237 } 237 }
238 if (!bIsProperty && eLogicType == XFA_LOGIC_Transparent) { 238 if (!bIsProperty && eLogicType == XFA_LOGIC_Transparent) {
239 parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent); 239 parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent);
240 if (!parent) { 240 if (!parent) {
241 return 0; 241 return 0;
242 } 242 }
243 } 243 }
244 uint32_t dwHashName = pNode->GetNameHash(); 244 uint32_t dwHashName = pNode->GetNameHash();
245 if (bIsClassIndex) { 245 if (bIsClassIndex) {
246 dwHashName = pNode->GetClassHashCode(); 246 dwHashName = pNode->GetClassHashCode();
247 } 247 }
248 CXFA_NodeArray siblings; 248 CXFA_NodeArray siblings;
249 int32_t iSize = NodeAcc_TraverseSiblings(parent, dwHashName, &siblings, 249 int32_t iSize = NodeAcc_TraverseSiblings(parent, dwHashName, &siblings,
250 eLogicType, bIsClassIndex); 250 eLogicType, bIsClassIndex);
251 for (int32_t i = 0; i < iSize; ++i) { 251 for (int32_t i = 0; i < iSize; ++i) {
252 CXFA_Node* child = siblings[i]; 252 CXFA_Node* child = siblings[i];
253 if (child == pNode) { 253 if (child == pNode) {
254 return i; 254 return i;
255 } 255 }
256 } 256 }
257 return 0; 257 return 0;
258 } 258 }
259 259
260 void CXFA_NodeHelper::GetNameExpression(CXFA_Node* refNode, 260 void CXFA_NodeHelper::GetNameExpression(CXFA_Node* refNode,
261 CFX_WideString& wsName, 261 CFX_WideString& wsName,
262 FX_BOOL bIsAllPath, 262 bool bIsAllPath,
263 XFA_LOGIC_TYPE eLogicType) { 263 XFA_LOGIC_TYPE eLogicType) {
264 wsName.clear(); 264 wsName.clear();
265 if (bIsAllPath) { 265 if (bIsAllPath) {
266 GetNameExpression(refNode, wsName, FALSE, eLogicType); 266 GetNameExpression(refNode, wsName, false, eLogicType);
267 CFX_WideString wsParent; 267 CFX_WideString wsParent;
268 CXFA_Node* parent = 268 CXFA_Node* parent =
269 ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); 269 ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent);
270 while (parent) { 270 while (parent) {
271 GetNameExpression(parent, wsParent, FALSE, eLogicType); 271 GetNameExpression(parent, wsParent, false, eLogicType);
272 wsParent += L"."; 272 wsParent += L".";
273 wsParent += wsName; 273 wsParent += wsName;
274 wsName = wsParent; 274 wsName = wsParent;
275 parent = ResolveNodes_GetParent(parent, XFA_LOGIC_NoTransparent); 275 parent = ResolveNodes_GetParent(parent, XFA_LOGIC_NoTransparent);
276 } 276 }
277 return; 277 return;
278 } 278 }
279 279
280 CFX_WideString ws; 280 CFX_WideString ws;
281 FX_BOOL bIsProperty = NodeIsProperty(refNode); 281 bool bIsProperty = NodeIsProperty(refNode);
282 if (refNode->IsUnnamed() || 282 if (refNode->IsUnnamed() ||
283 (bIsProperty && refNode->GetElementType() != XFA_Element::PageSet)) { 283 (bIsProperty && refNode->GetElementType() != XFA_Element::PageSet)) {
284 ws = refNode->GetClassName(); 284 ws = refNode->GetClassName();
285 wsName.Format(L"#%s[%d]", ws.c_str(), 285 wsName.Format(L"#%s[%d]", ws.c_str(),
286 GetIndex(refNode, eLogicType, bIsProperty, TRUE)); 286 GetIndex(refNode, eLogicType, bIsProperty, true));
287 return; 287 return;
288 } 288 }
289 ws = refNode->GetCData(XFA_ATTRIBUTE_Name); 289 ws = refNode->GetCData(XFA_ATTRIBUTE_Name);
290 ws.Replace(L".", L"\\."); 290 ws.Replace(L".", L"\\.");
291 wsName.Format(L"%s[%d]", ws.c_str(), 291 wsName.Format(L"%s[%d]", ws.c_str(),
292 GetIndex(refNode, eLogicType, bIsProperty, FALSE)); 292 GetIndex(refNode, eLogicType, bIsProperty, false));
293 } 293 }
294 294
295 FX_BOOL CXFA_NodeHelper::NodeIsTransparent(CXFA_Node* refNode) { 295 bool CXFA_NodeHelper::NodeIsTransparent(CXFA_Node* refNode) {
296 if (!refNode) { 296 if (!refNode) {
297 return FALSE; 297 return false;
298 } 298 }
299 XFA_Element refNodeType = refNode->GetElementType(); 299 XFA_Element refNodeType = refNode->GetElementType();
300 if ((refNode->IsUnnamed() && refNode->IsContainerNode()) || 300 if ((refNode->IsUnnamed() && refNode->IsContainerNode()) ||
301 refNodeType == XFA_Element::SubformSet || 301 refNodeType == XFA_Element::SubformSet ||
302 refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto) { 302 refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto) {
303 return TRUE; 303 return true;
304 } 304 }
305 return FALSE; 305 return false;
306 } 306 }
307 307
308 FX_BOOL CXFA_NodeHelper::CreateNode_ForCondition(CFX_WideString& wsCondition) { 308 bool CXFA_NodeHelper::CreateNode_ForCondition(CFX_WideString& wsCondition) {
309 int32_t iLen = wsCondition.GetLength(); 309 int32_t iLen = wsCondition.GetLength();
310 CFX_WideString wsIndex(L"0"); 310 CFX_WideString wsIndex(L"0");
311 FX_BOOL bAll = FALSE; 311 bool bAll = false;
312 if (iLen == 0) { 312 if (iLen == 0) {
313 m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; 313 m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne;
314 return FALSE; 314 return false;
315 } 315 }
316 if (wsCondition.GetAt(0) == '[') { 316 if (wsCondition.GetAt(0) == '[') {
317 int32_t i = 1; 317 int32_t i = 1;
318 for (; i < iLen; ++i) { 318 for (; i < iLen; ++i) {
319 FX_WCHAR ch = wsCondition[i]; 319 FX_WCHAR ch = wsCondition[i];
320 if (ch == ' ') { 320 if (ch == ' ') {
321 continue; 321 continue;
322 } 322 }
323 if (ch == '+' || ch == '-') { 323 if (ch == '+' || ch == '-') {
324 break; 324 break;
325 } else if (ch == '*') { 325 } else if (ch == '*') {
326 bAll = TRUE; 326 bAll = true;
327 break; 327 break;
328 } else { 328 } else {
329 break; 329 break;
330 } 330 }
331 } 331 }
332 if (bAll) { 332 if (bAll) {
333 wsIndex = FX_WSTRC(L"1"); 333 wsIndex = FX_WSTRC(L"1");
334 m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; 334 m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll;
335 } else { 335 } else {
336 m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; 336 m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne;
337 wsIndex = wsCondition.Mid(i, iLen - 1 - i); 337 wsIndex = wsCondition.Mid(i, iLen - 1 - i);
338 } 338 }
339 int32_t iIndex = wsIndex.GetInteger(); 339 int32_t iIndex = wsIndex.GetInteger();
340 m_iCreateCount = iIndex; 340 m_iCreateCount = iIndex;
341 return TRUE; 341 return true;
342 } 342 }
343 return FALSE; 343 return false;
344 } 344 }
345 345
346 FX_BOOL CXFA_NodeHelper::ResolveNodes_CreateNode( 346 bool CXFA_NodeHelper::ResolveNodes_CreateNode(
347 CFX_WideString wsName, 347 CFX_WideString wsName,
348 CFX_WideString wsCondition, 348 CFX_WideString wsCondition,
349 FX_BOOL bLastNode, 349 bool bLastNode,
350 CXFA_ScriptContext* pScriptContext) { 350 CXFA_ScriptContext* pScriptContext) {
351 if (!m_pCreateParent) { 351 if (!m_pCreateParent) {
352 return FALSE; 352 return false;
353 } 353 }
354 FX_BOOL bIsClassName = FALSE; 354 bool bIsClassName = false;
355 FX_BOOL bResult = FALSE; 355 bool bResult = false;
356 if (wsName.GetAt(0) == '!') { 356 if (wsName.GetAt(0) == '!') {
357 wsName = wsName.Right(wsName.GetLength() - 1); 357 wsName = wsName.Right(wsName.GetLength() - 1);
358 m_pCreateParent = ToNode( 358 m_pCreateParent = ToNode(
359 pScriptContext->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); 359 pScriptContext->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets));
360 } 360 }
361 if (wsName.GetAt(0) == '#') { 361 if (wsName.GetAt(0) == '#') {
362 bIsClassName = TRUE; 362 bIsClassName = true;
363 wsName = wsName.Right(wsName.GetLength() - 1); 363 wsName = wsName.Right(wsName.GetLength() - 1);
364 } 364 }
365 if (m_iCreateCount == 0) { 365 if (m_iCreateCount == 0) {
366 CreateNode_ForCondition(wsCondition); 366 CreateNode_ForCondition(wsCondition);
367 } 367 }
368 if (bIsClassName) { 368 if (bIsClassName) {
369 XFA_Element eType = XFA_GetElementTypeForName(wsName.AsStringC()); 369 XFA_Element eType = XFA_GetElementTypeForName(wsName.AsStringC());
370 if (eType == XFA_Element::Unknown) 370 if (eType == XFA_Element::Unknown)
371 return FALSE; 371 return false;
372 372
373 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { 373 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) {
374 CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eType); 374 CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eType);
375 if (pNewNode) { 375 if (pNewNode) {
376 m_pCreateParent->InsertChild(pNewNode); 376 m_pCreateParent->InsertChild(pNewNode);
377 if (iIndex == m_iCreateCount - 1) { 377 if (iIndex == m_iCreateCount - 1) {
378 m_pCreateParent = pNewNode; 378 m_pCreateParent = pNewNode;
379 } 379 }
380 bResult = TRUE; 380 bResult = true;
381 } 381 }
382 } 382 }
383 } else { 383 } else {
384 XFA_Element eClassType = XFA_Element::DataGroup; 384 XFA_Element eClassType = XFA_Element::DataGroup;
385 if (bLastNode) { 385 if (bLastNode) {
386 eClassType = m_eLastCreateType; 386 eClassType = m_eLastCreateType;
387 } 387 }
388 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { 388 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) {
389 CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType); 389 CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType);
390 if (pNewNode) { 390 if (pNewNode) {
391 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName.AsStringC()); 391 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName.AsStringC());
392 pNewNode->CreateXMLMappingNode(); 392 pNewNode->CreateXMLMappingNode();
393 m_pCreateParent->InsertChild(pNewNode); 393 m_pCreateParent->InsertChild(pNewNode);
394 if (iIndex == m_iCreateCount - 1) { 394 if (iIndex == m_iCreateCount - 1) {
395 m_pCreateParent = pNewNode; 395 m_pCreateParent = pNewNode;
396 } 396 }
397 bResult = TRUE; 397 bResult = true;
398 } 398 }
399 } 399 }
400 } 400 }
401 if (!bResult) { 401 if (!bResult) {
402 m_pCreateParent = nullptr; 402 m_pCreateParent = nullptr;
403 } 403 }
404 return bResult; 404 return bResult;
405 } 405 }
406 406
407 void CXFA_NodeHelper::SetCreateNodeType(CXFA_Node* refNode) { 407 void CXFA_NodeHelper::SetCreateNodeType(CXFA_Node* refNode) {
408 if (!refNode) { 408 if (!refNode) {
409 return; 409 return;
410 } 410 }
411 if (refNode->GetElementType() == XFA_Element::Subform) { 411 if (refNode->GetElementType() == XFA_Element::Subform) {
412 m_eLastCreateType = XFA_Element::DataGroup; 412 m_eLastCreateType = XFA_Element::DataGroup;
413 } else if (refNode->GetElementType() == XFA_Element::Field) { 413 } else if (refNode->GetElementType() == XFA_Element::Field) {
414 m_eLastCreateType = XFA_FieldIsMultiListBox(refNode) 414 m_eLastCreateType = XFA_FieldIsMultiListBox(refNode)
415 ? XFA_Element::DataGroup 415 ? XFA_Element::DataGroup
416 : XFA_Element::DataValue; 416 : XFA_Element::DataValue;
417 } else if (refNode->GetElementType() == XFA_Element::ExclGroup) { 417 } else if (refNode->GetElementType() == XFA_Element::ExclGroup) {
418 m_eLastCreateType = XFA_Element::DataValue; 418 m_eLastCreateType = XFA_Element::DataValue;
419 } 419 }
420 } 420 }
421 421
422 FX_BOOL CXFA_NodeHelper::NodeIsProperty(CXFA_Node* refNode) { 422 bool CXFA_NodeHelper::NodeIsProperty(CXFA_Node* refNode) {
423 CXFA_Node* parent = ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); 423 CXFA_Node* parent = ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent);
424 return parent && refNode && 424 return parent && refNode &&
425 XFA_GetPropertyOfElement(parent->GetElementType(), 425 XFA_GetPropertyOfElement(parent->GetElementType(),
426 refNode->GetElementType(), 426 refNode->GetElementType(),
427 XFA_XDPPACKET_UNKNOWN); 427 XFA_XDPPACKET_UNKNOWN);
428 } 428 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_nodehelper.h ('k') | xfa/fxfa/parser/cxfa_nodelist.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698