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