| 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_object.h" | 7 #include "xfa/fxfa/parser/xfa_object.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
| 12 #include "third_party/base/stl_util.h" | 12 #include "third_party/base/stl_util.h" |
| 13 #include "xfa/fde/xml/fde_xml_imp.h" | 13 #include "xfa/fde/xml/fde_xml_imp.h" |
| 14 #include "xfa/fgas/crt/fgas_codepage.h" | 14 #include "xfa/fgas/crt/fgas_codepage.h" |
| 15 #include "xfa/fgas/crt/fgas_system.h" | 15 #include "xfa/fgas/crt/fgas_system.h" |
| 16 #include "xfa/fxfa/app/xfa_ffnotify.h" | 16 #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 17 #include "xfa/fxfa/parser/cxfa_occur.h" | 17 #include "xfa/fxfa/parser/cxfa_occur.h" |
| 18 #include "xfa/fxfa/parser/xfa_basic_imp.h" | 18 #include "xfa/fxfa/parser/xfa_basic_imp.h" |
| 19 #include "xfa/fxfa/parser/xfa_doclayout.h" | 19 #include "xfa/fxfa/parser/xfa_doclayout.h" |
| 20 #include "xfa/fxfa/parser/xfa_document.h" | 20 #include "xfa/fxfa/parser/xfa_document.h" |
| 21 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 21 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
| 22 #include "xfa/fxfa/parser/xfa_localemgr.h" | 22 #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 23 #include "xfa/fxfa/parser/xfa_parser.h" | 23 #include "xfa/fxfa/parser/xfa_parser.h" |
| 24 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 24 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
| 25 #include "xfa/fxfa/parser/xfa_script.h" | 25 #include "xfa/fxfa/parser/xfa_script.h" |
| 26 #include "xfa/fxfa/parser/xfa_script_imp.h" | 26 #include "xfa/fxfa/parser/xfa_script_imp.h" |
| 27 #include "xfa/fxfa/parser/xfa_utils.h" | 27 #include "xfa/fxfa/parser/xfa_utils.h" |
| 28 #include "xfa/fxjse/cfxjse_arguments.h" | 28 #include "xfa/fxjse/cfxjse_arguments.h" |
| 29 | 29 |
| 30 namespace { |
| 31 |
| 32 void XFA_DeleteWideString(void* pData) { |
| 33 delete static_cast<CFX_WideString*>(pData); |
| 34 } |
| 35 |
| 36 void XFA_CopyWideString(void*& pData) { |
| 37 if (pData) { |
| 38 CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); |
| 39 pData = pNewData; |
| 40 } |
| 41 } |
| 42 |
| 43 XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {XFA_DeleteWideString, |
| 44 XFA_CopyWideString}; |
| 45 |
| 46 XFA_OBJECTTYPE XFA_GetElementObjectType(XFA_ELEMENT eElement) { |
| 47 return static_cast<XFA_OBJECTTYPE>(XFA_GetElementByID(eElement)->eObjectType); |
| 48 } |
| 49 |
| 50 void XFA_DataNodeDeleteBindItem(void* pData) { |
| 51 delete static_cast<CXFA_NodeArray*>(pData); |
| 52 } |
| 53 |
| 54 XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { |
| 55 XFA_DataNodeDeleteBindItem, nullptr}; |
| 56 |
| 57 } // namespace |
| 58 |
| 30 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, uint32_t uFlags) | 59 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, uint32_t uFlags) |
| 31 : m_pDocument(pDocument), m_uFlags(uFlags) {} | 60 : m_pDocument(pDocument), m_uFlags(uFlags) {} |
| 61 |
| 32 void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { | 62 void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { |
| 33 wsName = XFA_GetElementByID(GetClassID())->pName; | 63 wsName = XFA_GetElementByID(GetClassID())->pName; |
| 34 } | 64 } |
| 65 |
| 35 uint32_t CXFA_Object::GetClassHashCode() const { | 66 uint32_t CXFA_Object::GetClassHashCode() const { |
| 36 return XFA_GetElementByID(GetClassID())->uHash; | 67 return XFA_GetElementByID(GetClassID())->uHash; |
| 37 } | 68 } |
| 69 |
| 38 XFA_ELEMENT CXFA_Object::GetClassID() const { | 70 XFA_ELEMENT CXFA_Object::GetClassID() const { |
| 39 if (IsNode()) { | 71 if (IsNode()) |
| 40 return AsNode()->GetClassID(); | 72 return AsNode()->GetClassID(); |
| 41 } | 73 if (IsOrdinaryObject()) |
| 42 if (IsOrdinaryObject()) { | |
| 43 return AsOrdinaryObject()->GetClassID(); | 74 return AsOrdinaryObject()->GetClassID(); |
| 44 } | 75 if (IsNodeList()) |
| 45 if (IsNodeList()) { | |
| 46 return AsNodeList()->GetClassID(); | 76 return AsNodeList()->GetClassID(); |
| 47 } | 77 if (IsOrdinaryList()) |
| 48 if (IsOrdinaryList()) { | |
| 49 return XFA_ELEMENT_List; | 78 return XFA_ELEMENT_List; |
| 50 } | |
| 51 ASSERT(FALSE); | 79 ASSERT(FALSE); |
| 52 return (XFA_ELEMENT)0; | 80 return (XFA_ELEMENT)0; |
| 53 } | 81 } |
| 82 |
| 54 void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, | 83 void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, |
| 55 FX_BOOL bSetting, | 84 FX_BOOL bSetting, |
| 56 XFA_ATTRIBUTE eAttribute) { | 85 XFA_ATTRIBUTE eAttribute) { |
| 57 if (!bSetting) { | 86 if (!bSetting) { |
| 58 CFX_WideStringC className; | 87 CFX_WideStringC className; |
| 59 GetClassName(className); | 88 GetClassName(className); |
| 60 FXJSE_Value_SetUTF8String( | 89 FXJSE_Value_SetUTF8String( |
| 61 pValue, | 90 pValue, |
| 62 FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); | 91 FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); |
| 63 } else { | 92 } else { |
| 64 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 93 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 65 } | 94 } |
| 66 } | 95 } |
| 96 |
| 67 void CXFA_Object::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 97 void CXFA_Object::ThrowScriptErrorMessage(int32_t iStringID, ...) { |
| 68 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 98 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 69 ASSERT(pAppProvider); | 99 ASSERT(pAppProvider); |
| 70 CFX_WideString wsFormat; | 100 CFX_WideString wsFormat; |
| 71 pAppProvider->LoadString(iStringID, wsFormat); | 101 pAppProvider->LoadString(iStringID, wsFormat); |
| 72 CFX_WideString wsMessage; | 102 CFX_WideString wsMessage; |
| 73 va_list arg_ptr; | 103 va_list arg_ptr; |
| 74 va_start(arg_ptr, iStringID); | 104 va_start(arg_ptr, iStringID); |
| 75 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 105 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 76 va_end(arg_ptr); | 106 va_end(arg_ptr); |
| 77 FXJSE_ThrowMessage( | 107 FXJSE_ThrowMessage( |
| 78 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 108 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 79 } | 109 } |
| 80 | 110 |
| 81 static void XFA_DeleteWideString(void* pData) { | |
| 82 delete static_cast<CFX_WideString*>(pData); | |
| 83 } | |
| 84 | |
| 85 static void XFA_CopyWideString(void*& pData) { | |
| 86 if (pData) { | |
| 87 CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); | |
| 88 pData = pNewData; | |
| 89 } | |
| 90 } | |
| 91 static XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = { | |
| 92 XFA_DeleteWideString, XFA_CopyWideString}; | |
| 93 static XFA_OBJECTTYPE XFA_GetElementObjectType(XFA_ELEMENT eElement) { | |
| 94 return (XFA_OBJECTTYPE)XFA_GetElementByID(eElement)->eObjectType; | |
| 95 } | |
| 96 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, | 111 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, |
| 97 uint16_t ePacket, | 112 uint16_t ePacket, |
| 98 XFA_ELEMENT eElement) | 113 XFA_ELEMENT eElement) |
| 99 : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), | 114 : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), |
| 100 m_pNext(nullptr), | 115 m_pNext(nullptr), |
| 101 m_pChild(nullptr), | 116 m_pChild(nullptr), |
| 102 m_pLastChild(nullptr), | 117 m_pLastChild(nullptr), |
| 103 m_pParent(nullptr), | 118 m_pParent(nullptr), |
| 104 m_pXMLNode(nullptr), | 119 m_pXMLNode(nullptr), |
| 105 m_eNodeClass(eElement), | 120 m_eNodeClass(eElement), |
| 106 m_ePacket(ePacket), | 121 m_ePacket(ePacket), |
| 107 m_dwNameHash(0), | 122 m_dwNameHash(0), |
| 108 m_pAuxNode(nullptr), | 123 m_pAuxNode(nullptr), |
| 109 m_pMapModuleData(nullptr) { | 124 m_pMapModuleData(nullptr) { |
| 110 ASSERT(m_pDocument); | 125 ASSERT(m_pDocument); |
| 111 } | 126 } |
| 127 |
| 112 CXFA_Node::~CXFA_Node() { | 128 CXFA_Node::~CXFA_Node() { |
| 113 ASSERT(m_pParent == NULL); | 129 ASSERT(!m_pParent); |
| 114 RemoveMapModuleKey(); | 130 RemoveMapModuleKey(); |
| 115 CXFA_Node *pNext, *pNode = m_pChild; | 131 CXFA_Node* pNode = m_pChild; |
| 116 while (pNode) { | 132 while (pNode) { |
| 117 pNext = pNode->m_pNext; | 133 CXFA_Node* pNext = pNode->m_pNext; |
| 118 pNode->m_pParent = NULL; | 134 pNode->m_pParent = nullptr; |
| 119 delete pNode; | 135 delete pNode; |
| 120 pNode = pNext; | 136 pNode = pNext; |
| 121 } | 137 } |
| 122 if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) { | 138 if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) |
| 123 m_pXMLNode->Release(); | 139 m_pXMLNode->Release(); |
| 124 } | |
| 125 } | 140 } |
| 141 |
| 126 CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { | 142 CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { |
| 127 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); | 143 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); |
| 128 CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_eNodeClass); | 144 CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_eNodeClass); |
| 129 if (!pClone) { | 145 if (!pClone) |
| 130 return NULL; | 146 return nullptr; |
| 131 } | 147 |
| 132 MergeAllData(pClone); | 148 MergeAllData(pClone); |
| 133 pClone->UpdateNameHash(); | 149 pClone->UpdateNameHash(); |
| 134 if (IsNeedSavingXMLNode()) { | 150 if (IsNeedSavingXMLNode()) { |
| 135 CFDE_XMLNode* pCloneXML = NULL; | 151 CFDE_XMLNode* pCloneXML = nullptr; |
| 136 if (IsAttributeInXML()) { | 152 if (IsAttributeInXML()) { |
| 137 CFX_WideString wsName; | 153 CFX_WideString wsName; |
| 138 GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); | 154 GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); |
| 139 CFDE_XMLElement* pCloneXMLElement = new CFDE_XMLElement(wsName); | 155 CFDE_XMLElement* pCloneXMLElement = new CFDE_XMLElement(wsName); |
| 140 CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); | 156 CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); |
| 141 if (!wsValue.IsEmpty()) { | 157 if (!wsValue.IsEmpty()) { |
| 142 pCloneXMLElement->SetTextData(CFX_WideString(wsValue)); | 158 pCloneXMLElement->SetTextData(CFX_WideString(wsValue)); |
| 143 } | 159 } |
| 144 pCloneXML = pCloneXMLElement; | 160 pCloneXML = pCloneXMLElement; |
| 145 pCloneXMLElement = NULL; | 161 pCloneXMLElement = nullptr; |
| 146 pClone->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); | 162 pClone->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); |
| 147 } else { | 163 } else { |
| 148 pCloneXML = m_pXMLNode->Clone(FALSE); | 164 pCloneXML = m_pXMLNode->Clone(FALSE); |
| 149 } | 165 } |
| 150 pClone->SetXMLMappingNode(pCloneXML); | 166 pClone->SetXMLMappingNode(pCloneXML); |
| 151 pClone->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); | 167 pClone->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); |
| 152 } | 168 } |
| 153 if (bRecursive) { | 169 if (bRecursive) { |
| 154 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; | 170 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; |
| 155 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 171 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 156 pClone->InsertChild(pChild->Clone(bRecursive)); | 172 pClone->InsertChild(pChild->Clone(bRecursive)); |
| 157 } | 173 } |
| 158 } | 174 } |
| 159 pClone->SetFlag(XFA_NODEFLAG_Initialized, true); | 175 pClone->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 160 pClone->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 176 pClone->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); |
| 161 return pClone; | 177 return pClone; |
| 162 } | 178 } |
| 179 |
| 163 CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem) const { | 180 CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem) const { |
| 164 switch (eItem) { | 181 switch (eItem) { |
| 165 case XFA_NODEITEM_NextSibling: | 182 case XFA_NODEITEM_NextSibling: |
| 166 return m_pNext; | 183 return m_pNext; |
| 167 case XFA_NODEITEM_FirstChild: | 184 case XFA_NODEITEM_FirstChild: |
| 168 return m_pChild; | 185 return m_pChild; |
| 169 case XFA_NODEITEM_Parent: | 186 case XFA_NODEITEM_Parent: |
| 170 return m_pParent; | 187 return m_pParent; |
| 171 case XFA_NODEITEM_PrevSibling: | 188 case XFA_NODEITEM_PrevSibling: |
| 172 if (m_pParent) { | 189 if (m_pParent) { |
| 173 CXFA_Node* pSibling = m_pParent->m_pChild; | 190 CXFA_Node* pSibling = m_pParent->m_pChild; |
| 174 CXFA_Node* pPrev = NULL; | 191 CXFA_Node* pPrev = nullptr; |
| 175 while (pSibling && pSibling != this) { | 192 while (pSibling && pSibling != this) { |
| 176 pPrev = pSibling; | 193 pPrev = pSibling; |
| 177 pSibling = pSibling->m_pNext; | 194 pSibling = pSibling->m_pNext; |
| 178 } | 195 } |
| 179 return pPrev; | 196 return pPrev; |
| 180 } | 197 } |
| 181 return NULL; | 198 return nullptr; |
| 182 default: | 199 default: |
| 183 break; | 200 break; |
| 184 } | 201 } |
| 185 return NULL; | 202 return nullptr; |
| 186 } | 203 } |
| 204 |
| 187 CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem, | 205 CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem, |
| 188 XFA_OBJECTTYPE eType) const { | 206 XFA_OBJECTTYPE eType) const { |
| 189 CXFA_Node* pNode = NULL; | 207 CXFA_Node* pNode = nullptr; |
| 190 switch (eItem) { | 208 switch (eItem) { |
| 191 case XFA_NODEITEM_NextSibling: | 209 case XFA_NODEITEM_NextSibling: |
| 192 pNode = m_pNext; | 210 pNode = m_pNext; |
| 193 if (eType != XFA_OBJECTTYPEMASK) { | 211 if (eType != XFA_OBJECTTYPEMASK) { |
| 194 while (pNode && pNode->GetObjectType() != eType) { | 212 while (pNode && pNode->GetObjectType() != eType) |
| 195 pNode = pNode->m_pNext; | 213 pNode = pNode->m_pNext; |
| 196 } | |
| 197 } | 214 } |
| 198 break; | 215 break; |
| 199 case XFA_NODEITEM_FirstChild: | 216 case XFA_NODEITEM_FirstChild: |
| 200 pNode = m_pChild; | 217 pNode = m_pChild; |
| 201 if (eType != XFA_OBJECTTYPEMASK) { | 218 if (eType != XFA_OBJECTTYPEMASK) { |
| 202 while (pNode && pNode->GetObjectType() != eType) { | 219 while (pNode && pNode->GetObjectType() != eType) |
| 203 pNode = pNode->m_pNext; | 220 pNode = pNode->m_pNext; |
| 204 } | |
| 205 } | 221 } |
| 206 break; | 222 break; |
| 207 case XFA_NODEITEM_Parent: | 223 case XFA_NODEITEM_Parent: |
| 208 pNode = m_pParent; | 224 pNode = m_pParent; |
| 209 if (eType != XFA_OBJECTTYPEMASK) { | 225 if (eType != XFA_OBJECTTYPEMASK) { |
| 210 while (pNode && pNode->GetObjectType() != eType) { | 226 while (pNode && pNode->GetObjectType() != eType) |
| 211 pNode = pNode->m_pParent; | 227 pNode = pNode->m_pParent; |
| 212 } | |
| 213 } | 228 } |
| 214 break; | 229 break; |
| 215 case XFA_NODEITEM_PrevSibling: | 230 case XFA_NODEITEM_PrevSibling: |
| 216 if (m_pParent) { | 231 if (m_pParent) { |
| 217 CXFA_Node* pSibling = m_pParent->m_pChild; | 232 CXFA_Node* pSibling = m_pParent->m_pChild; |
| 218 while (pSibling && pSibling != this) { | 233 while (pSibling && pSibling != this) { |
| 219 if (eType == XFA_OBJECTTYPEMASK || | 234 if (eType == XFA_OBJECTTYPEMASK || |
| 220 eType == pSibling->GetObjectType()) { | 235 eType == pSibling->GetObjectType()) { |
| 221 pNode = pSibling; | 236 pNode = pSibling; |
| 222 } | 237 } |
| 223 pSibling = pSibling->m_pNext; | 238 pSibling = pSibling->m_pNext; |
| 224 } | 239 } |
| 225 } | 240 } |
| 226 break; | 241 break; |
| 227 default: | 242 default: |
| 228 break; | 243 break; |
| 229 } | 244 } |
| 230 return pNode; | 245 return pNode; |
| 231 } | 246 } |
| 247 |
| 232 int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes, | 248 int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes, |
| 233 uint32_t dwTypeFilter, | 249 uint32_t dwTypeFilter, |
| 234 XFA_ELEMENT eElementFilter, | 250 XFA_ELEMENT eElementFilter, |
| 235 int32_t iLevel) { | 251 int32_t iLevel) { |
| 236 if (--iLevel < 0) { | 252 if (--iLevel < 0) { |
| 237 return nodes.GetSize(); | 253 return nodes.GetSize(); |
| 238 } | 254 } |
| 239 if (eElementFilter != XFA_ELEMENT_UNKNOWN) { | 255 if (eElementFilter != XFA_ELEMENT_UNKNOWN) { |
| 240 CXFA_Node* pChild = m_pChild; | 256 CXFA_Node* pChild = m_pChild; |
| 241 while (pChild) { | 257 while (pChild) { |
| 242 if (pChild->GetClassID() == eElementFilter) { | 258 if (pChild->GetClassID() == eElementFilter) { |
| 243 nodes.Add(pChild); | 259 nodes.Add(pChild); |
| 244 if (iLevel > 0) { | 260 if (iLevel > 0) { |
| 245 GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); | 261 GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); |
| 246 } | 262 } |
| 247 } | 263 } |
| 248 pChild = pChild->m_pNext; | 264 pChild = pChild->m_pNext; |
| 249 } | 265 } |
| 250 } else if (dwTypeFilter == | 266 } else if (dwTypeFilter == |
| 251 (XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties)) { | 267 (XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties)) { |
| 252 CXFA_Node* pChild = m_pChild; | 268 CXFA_Node* pChild = m_pChild; |
| 253 while (pChild) { | 269 while (pChild) { |
| 254 nodes.Add(pChild); | 270 nodes.Add(pChild); |
| 255 if (iLevel > 0) { | 271 if (iLevel > 0) { |
| 256 GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); | 272 GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); |
| 257 } | 273 } |
| 258 pChild = pChild->m_pNext; | 274 pChild = pChild->m_pNext; |
| 259 } | 275 } |
| 260 } else if (dwTypeFilter != 0) { | 276 } else if (dwTypeFilter != 0) { |
| 261 FX_BOOL bFilterChildren = (dwTypeFilter & XFA_NODEFILTER_Children) != 0; | 277 bool bFilterChildren = !!(dwTypeFilter & XFA_NODEFILTER_Children); |
| 262 FX_BOOL bFilterProperties = (dwTypeFilter & XFA_NODEFILTER_Properties) != 0; | 278 bool bFilterProperties = !!(dwTypeFilter & XFA_NODEFILTER_Properties); |
| 263 FX_BOOL bFilterOneOfProperties = | 279 bool bFilterOneOfProperties = |
| 264 (dwTypeFilter & XFA_NODEFILTER_OneOfProperty) != 0; | 280 !!(dwTypeFilter & XFA_NODEFILTER_OneOfProperty); |
| 265 CXFA_Node* pChild = m_pChild; | 281 CXFA_Node* pChild = m_pChild; |
| 266 while (pChild) { | 282 while (pChild) { |
| 267 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( | 283 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( |
| 268 GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); | 284 GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); |
| 269 if (pProperty) { | 285 if (pProperty) { |
| 270 if (bFilterProperties) { | 286 if (bFilterProperties) { |
| 271 nodes.Add(pChild); | 287 nodes.Add(pChild); |
| 272 } else if (bFilterOneOfProperties && | 288 } else if (bFilterOneOfProperties && |
| 273 (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { | 289 (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { |
| 274 nodes.Add(pChild); | 290 nodes.Add(pChild); |
| 275 } else if (bFilterChildren && | 291 } else if (bFilterChildren && |
| 276 (pChild->GetClassID() == XFA_ELEMENT_Variables || | 292 (pChild->GetClassID() == XFA_ELEMENT_Variables || |
| 277 pChild->GetClassID() == XFA_ELEMENT_PageSet)) { | 293 pChild->GetClassID() == XFA_ELEMENT_PageSet)) { |
| 278 nodes.Add(pChild); | 294 nodes.Add(pChild); |
| 279 } | 295 } |
| 280 } else { | 296 } else if (bFilterChildren) { |
| 281 if (bFilterChildren) { | 297 nodes.Add(pChild); |
| 282 nodes.Add(pChild); | |
| 283 } | |
| 284 } | 298 } |
| 285 pChild = pChild->m_pNext; | 299 pChild = pChild->m_pNext; |
| 286 } | 300 } |
| 287 if (bFilterOneOfProperties && nodes.GetSize() < 1) { | 301 if (bFilterOneOfProperties && nodes.GetSize() < 1) { |
| 288 int32_t iProperties = 0; | 302 int32_t iProperties = 0; |
| 289 const XFA_PROPERTY* pProperty = | 303 const XFA_PROPERTY* pProperty = |
| 290 XFA_GetElementProperties(GetClassID(), iProperties); | 304 XFA_GetElementProperties(GetClassID(), iProperties); |
| 291 if (pProperty == NULL || iProperties < 1) { | 305 if (!pProperty || iProperties < 1) |
| 292 return 0; | 306 return 0; |
| 293 } | |
| 294 for (int32_t i = 0; i < iProperties; i++) { | 307 for (int32_t i = 0; i < iProperties; i++) { |
| 295 if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) { | 308 if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) { |
| 296 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); | 309 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); |
| 297 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID()); | 310 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID()); |
| 298 CXFA_Node* pNewNode = | 311 CXFA_Node* pNewNode = |
| 299 pFactory->CreateNode(pPacket, (XFA_ELEMENT)pProperty[i].eName); | 312 pFactory->CreateNode(pPacket, (XFA_ELEMENT)pProperty[i].eName); |
| 300 if (!pNewNode) { | 313 if (!pNewNode) |
| 301 break; | 314 break; |
| 302 } | 315 InsertChild(pNewNode, nullptr); |
| 303 InsertChild(pNewNode, NULL); | |
| 304 pNewNode->SetFlag(XFA_NODEFLAG_Initialized, true); | 316 pNewNode->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 305 nodes.Add(pNewNode); | 317 nodes.Add(pNewNode); |
| 306 break; | 318 break; |
| 307 } | 319 } |
| 308 } | 320 } |
| 309 } | 321 } |
| 310 } | 322 } |
| 311 return nodes.GetSize(); | 323 return nodes.GetSize(); |
| 312 } | 324 } |
| 325 |
| 313 CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_ELEMENT eElement, | 326 CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_ELEMENT eElement, |
| 314 uint32_t dwFlags) { | 327 uint32_t dwFlags) { |
| 315 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); | 328 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); |
| 316 CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eElement); | 329 CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eElement); |
| 317 pNode->SetFlag(dwFlags, true); | 330 pNode->SetFlag(dwFlags, true); |
| 318 return pNode; | 331 return pNode; |
| 319 } | 332 } |
| 333 |
| 320 CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) { | 334 CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) { |
| 321 ASSERT(m_ePacket == XFA_XDPPACKET_Template); | 335 ASSERT(m_ePacket == XFA_XDPPACKET_Template); |
| 322 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); | 336 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); |
| 323 CXFA_Node* pClone = pFactory->CreateNode(XFA_XDPPACKET_Form, m_eNodeClass); | 337 CXFA_Node* pClone = pFactory->CreateNode(XFA_XDPPACKET_Form, m_eNodeClass); |
| 324 if (!pClone) { | 338 if (!pClone) |
| 325 return NULL; | 339 return nullptr; |
| 326 } | 340 |
| 327 pClone->SetTemplateNode(this); | 341 pClone->SetTemplateNode(this); |
| 328 pClone->UpdateNameHash(); | 342 pClone->UpdateNameHash(); |
| 329 pClone->SetXMLMappingNode(GetXMLMappingNode()); | 343 pClone->SetXMLMappingNode(GetXMLMappingNode()); |
| 330 if (bRecursive) { | 344 if (bRecursive) { |
| 331 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; | 345 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; |
| 332 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 346 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 333 pClone->InsertChild(pChild->CloneTemplateToForm(bRecursive)); | 347 pClone->InsertChild(pChild->CloneTemplateToForm(bRecursive)); |
| 334 } | 348 } |
| 335 } | 349 } |
| 336 pClone->SetFlag(XFA_NODEFLAG_Initialized, true); | 350 pClone->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 337 return pClone; | 351 return pClone; |
| 338 } | 352 } |
| 339 | 353 |
| 340 CXFA_Node* CXFA_Node::GetTemplateNode() const { | 354 CXFA_Node* CXFA_Node::GetTemplateNode() const { |
| 341 return m_pAuxNode; | 355 return m_pAuxNode; |
| 342 } | 356 } |
| 343 | 357 |
| 344 void CXFA_Node::SetTemplateNode(CXFA_Node* pTemplateNode) { | 358 void CXFA_Node::SetTemplateNode(CXFA_Node* pTemplateNode) { |
| 345 m_pAuxNode = pTemplateNode; | 359 m_pAuxNode = pTemplateNode; |
| 346 } | 360 } |
| 361 |
| 347 CXFA_Node* CXFA_Node::GetBindData() { | 362 CXFA_Node* CXFA_Node::GetBindData() { |
| 348 ASSERT(GetPacketID() == XFA_XDPPACKET_Form); | 363 ASSERT(GetPacketID() == XFA_XDPPACKET_Form); |
| 349 return static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); | 364 return static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); |
| 350 } | 365 } |
| 366 |
| 351 int32_t CXFA_Node::GetBindItems(CXFA_NodeArray& formItems) { | 367 int32_t CXFA_Node::GetBindItems(CXFA_NodeArray& formItems) { |
| 352 if (m_uFlags & XFA_NODEFLAG_BindFormItems) { | 368 if (m_uFlags & XFA_NODEFLAG_BindFormItems) { |
| 353 CXFA_NodeArray* pItems = NULL; | 369 CXFA_NodeArray* pItems = nullptr; |
| 354 TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); | 370 TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); |
| 355 formItems.Copy(*pItems); | 371 formItems.Copy(*pItems); |
| 356 return formItems.GetSize(); | 372 return formItems.GetSize(); |
| 357 } | 373 } |
| 358 CXFA_Node* pFormNode = | 374 CXFA_Node* pFormNode = |
| 359 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); | 375 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); |
| 360 if (pFormNode) { | 376 if (pFormNode) |
| 361 formItems.Add(pFormNode); | 377 formItems.Add(pFormNode); |
| 362 } | |
| 363 return formItems.GetSize(); | 378 return formItems.GetSize(); |
| 364 } | 379 } |
| 365 | 380 |
| 366 static void XFA_DataNodeDeleteBindItem(void* pData) { | |
| 367 delete static_cast<CXFA_NodeArray*>(pData); | |
| 368 } | |
| 369 | |
| 370 static XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { | |
| 371 XFA_DataNodeDeleteBindItem, NULL}; | |
| 372 int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { | 381 int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { |
| 373 ASSERT(pFormNode); | 382 ASSERT(pFormNode); |
| 374 if (m_uFlags & XFA_NODEFLAG_BindFormItems) { | 383 if (m_uFlags & XFA_NODEFLAG_BindFormItems) { |
| 375 CXFA_NodeArray* pItems = NULL; | 384 CXFA_NodeArray* pItems = nullptr; |
| 376 TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); | 385 TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); |
| 377 ASSERT(pItems); | 386 ASSERT(pItems); |
| 378 if (pItems->Find(pFormNode) < 0) { | 387 if (pItems->Find(pFormNode) < 0) { |
| 379 pItems->Add(pFormNode); | 388 pItems->Add(pFormNode); |
| 380 } | 389 } |
| 381 return pItems->GetSize(); | 390 return pItems->GetSize(); |
| 382 } | 391 } |
| 383 CXFA_Node* pOldFormItem = | 392 CXFA_Node* pOldFormItem = |
| 384 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); | 393 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); |
| 385 if (!pOldFormItem) { | 394 if (!pOldFormItem) { |
| 386 SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode); | 395 SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode); |
| 387 return 1; | 396 return 1; |
| 388 } else if (pOldFormItem == pFormNode) { | 397 } else if (pOldFormItem == pFormNode) { |
| 389 return 1; | 398 return 1; |
| 390 } | 399 } |
| 391 CXFA_NodeArray* pItems = new CXFA_NodeArray; | 400 CXFA_NodeArray* pItems = new CXFA_NodeArray; |
| 392 SetObject(XFA_ATTRIBUTE_BindingNode, pItems, &deleteBindItemCallBack); | 401 SetObject(XFA_ATTRIBUTE_BindingNode, pItems, &deleteBindItemCallBack); |
| 393 pItems->Add(pOldFormItem); | 402 pItems->Add(pOldFormItem); |
| 394 pItems->Add(pFormNode); | 403 pItems->Add(pFormNode); |
| 395 m_uFlags |= XFA_NODEFLAG_BindFormItems; | 404 m_uFlags |= XFA_NODEFLAG_BindFormItems; |
| 396 return 2; | 405 return 2; |
| 397 } | 406 } |
| 407 |
| 398 int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) { | 408 int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) { |
| 399 if (m_uFlags & XFA_NODEFLAG_BindFormItems) { | 409 if (m_uFlags & XFA_NODEFLAG_BindFormItems) { |
| 400 CXFA_NodeArray* pItems = NULL; | 410 CXFA_NodeArray* pItems = nullptr; |
| 401 TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); | 411 TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); |
| 402 ASSERT(pItems); | 412 ASSERT(pItems); |
| 403 int32_t iIndex = pItems->Find(pFormNode); | 413 int32_t iIndex = pItems->Find(pFormNode); |
| 404 int32_t iCount = pItems->GetSize(); | 414 int32_t iCount = pItems->GetSize(); |
| 405 if (iIndex >= 0) { | 415 if (iIndex >= 0) { |
| 406 if (iIndex != iCount - 1) { | 416 if (iIndex != iCount - 1) |
| 407 pItems->SetAt(iIndex, pItems->GetAt(iCount - 1)); | 417 pItems->SetAt(iIndex, pItems->GetAt(iCount - 1)); |
| 408 } | |
| 409 pItems->RemoveAt(iCount - 1); | 418 pItems->RemoveAt(iCount - 1); |
| 410 if (iCount == 2) { | 419 if (iCount == 2) { |
| 411 CXFA_Node* pLastFormNode = pItems->GetAt(0); | 420 CXFA_Node* pLastFormNode = pItems->GetAt(0); |
| 412 SetObject(XFA_ATTRIBUTE_BindingNode, pLastFormNode); | 421 SetObject(XFA_ATTRIBUTE_BindingNode, pLastFormNode); |
| 413 m_uFlags &= ~XFA_NODEFLAG_BindFormItems; | 422 m_uFlags &= ~XFA_NODEFLAG_BindFormItems; |
| 414 } | 423 } |
| 415 iCount--; | 424 iCount--; |
| 416 } | 425 } |
| 417 return iCount; | 426 return iCount; |
| 418 } | 427 } |
| 419 CXFA_Node* pOldFormItem = | 428 CXFA_Node* pOldFormItem = |
| 420 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); | 429 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); |
| 421 if (pOldFormItem == pFormNode) { | 430 if (pOldFormItem == pFormNode) { |
| 422 SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 431 SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); |
| 423 pOldFormItem = NULL; | 432 pOldFormItem = nullptr; |
| 424 } | 433 } |
| 425 return pOldFormItem == NULL ? 0 : 1; | 434 return pOldFormItem ? 1 : 0; |
| 426 } | 435 } |
| 436 |
| 427 FX_BOOL CXFA_Node::HasBindItem() { | 437 FX_BOOL CXFA_Node::HasBindItem() { |
| 428 return (GetPacketID() == XFA_XDPPACKET_Datasets) && | 438 return GetPacketID() == XFA_XDPPACKET_Datasets && |
| 429 GetObject(XFA_ATTRIBUTE_BindingNode) != NULL; | 439 GetObject(XFA_ATTRIBUTE_BindingNode); |
| 430 } | 440 } |
| 441 |
| 431 CXFA_WidgetData* CXFA_Node::GetWidgetData() { | 442 CXFA_WidgetData* CXFA_Node::GetWidgetData() { |
| 432 return (CXFA_WidgetData*)GetObject(XFA_ATTRIBUTE_WidgetData); | 443 return (CXFA_WidgetData*)GetObject(XFA_ATTRIBUTE_WidgetData); |
| 433 } | 444 } |
| 445 |
| 434 CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() { | 446 CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() { |
| 435 if (GetPacketID() != XFA_XDPPACKET_Form) { | 447 if (GetPacketID() != XFA_XDPPACKET_Form) |
| 436 return NULL; | 448 return nullptr; |
| 437 } | |
| 438 XFA_ELEMENT classID = GetClassID(); | 449 XFA_ELEMENT classID = GetClassID(); |
| 439 if (classID == XFA_ELEMENT_ExclGroup) { | 450 if (classID == XFA_ELEMENT_ExclGroup) |
| 440 return NULL; | 451 return nullptr; |
| 441 } | |
| 442 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); | 452 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); |
| 443 if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_ExclGroup) { | 453 if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_ExclGroup) |
| 444 return NULL; | 454 return nullptr; |
| 445 } | 455 |
| 446 if (classID == XFA_ELEMENT_Field) { | 456 if (classID == XFA_ELEMENT_Field) { |
| 447 CXFA_WidgetData* pFieldWidgetData = GetWidgetData(); | 457 CXFA_WidgetData* pFieldWidgetData = GetWidgetData(); |
| 448 if (pFieldWidgetData && | 458 if (pFieldWidgetData && |
| 449 pFieldWidgetData->GetChoiceListOpen() == | 459 pFieldWidgetData->GetChoiceListOpen() == |
| 450 XFA_ATTRIBUTEENUM_MultiSelect) { | 460 XFA_ATTRIBUTEENUM_MultiSelect) { |
| 451 return NULL; | 461 return nullptr; |
| 452 } else { | 462 } else { |
| 453 CFX_WideString wsPicture; | 463 CFX_WideString wsPicture; |
| 454 if (pFieldWidgetData) { | 464 if (pFieldWidgetData) { |
| 455 pFieldWidgetData->GetPictureContent(wsPicture, | 465 pFieldWidgetData->GetPictureContent(wsPicture, |
| 456 XFA_VALUEPICTURE_DataBind); | 466 XFA_VALUEPICTURE_DataBind); |
| 457 } | 467 } |
| 458 if (!wsPicture.IsEmpty()) { | 468 if (!wsPicture.IsEmpty()) |
| 459 return pFieldWidgetData; | 469 return pFieldWidgetData; |
| 460 } | |
| 461 CXFA_Node* pDataNode = GetBindData(); | 470 CXFA_Node* pDataNode = GetBindData(); |
| 462 if (!pDataNode) { | 471 if (!pDataNode) |
| 463 return NULL; | 472 return nullptr; |
| 464 } | 473 pFieldWidgetData = nullptr; |
| 465 pFieldWidgetData = NULL; | |
| 466 CXFA_NodeArray formNodes; | 474 CXFA_NodeArray formNodes; |
| 467 pDataNode->GetBindItems(formNodes); | 475 pDataNode->GetBindItems(formNodes); |
| 468 for (int32_t i = 0; i < formNodes.GetSize(); i++) { | 476 for (int32_t i = 0; i < formNodes.GetSize(); i++) { |
| 469 CXFA_Node* pFormNode = formNodes.GetAt(i); | 477 CXFA_Node* pFormNode = formNodes.GetAt(i); |
| 470 if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { | 478 if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) |
| 471 continue; | 479 continue; |
| 472 } | |
| 473 pFieldWidgetData = pFormNode->GetWidgetData(); | 480 pFieldWidgetData = pFormNode->GetWidgetData(); |
| 474 if (pFieldWidgetData) { | 481 if (pFieldWidgetData) { |
| 475 pFieldWidgetData->GetPictureContent(wsPicture, | 482 pFieldWidgetData->GetPictureContent(wsPicture, |
| 476 XFA_VALUEPICTURE_DataBind); | 483 XFA_VALUEPICTURE_DataBind); |
| 477 } | 484 } |
| 478 if (!wsPicture.IsEmpty()) { | 485 if (!wsPicture.IsEmpty()) |
| 479 break; | 486 break; |
| 480 } | 487 pFieldWidgetData = nullptr; |
| 481 pFieldWidgetData = NULL; | |
| 482 } | 488 } |
| 483 return pFieldWidgetData; | 489 return pFieldWidgetData; |
| 484 } | 490 } |
| 485 } | 491 } |
| 486 CXFA_Node* pGrandNode = | 492 CXFA_Node* pGrandNode = |
| 487 pParentNode ? pParentNode->GetNodeItem(XFA_NODEITEM_Parent) : NULL; | 493 pParentNode ? pParentNode->GetNodeItem(XFA_NODEITEM_Parent) : nullptr; |
| 488 CXFA_Node* pValueNode = | 494 CXFA_Node* pValueNode = |
| 489 (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_Value) | 495 (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_Value) |
| 490 ? pParentNode | 496 ? pParentNode |
| 491 : NULL; | 497 : nullptr; |
| 492 if (!pValueNode) { | 498 if (!pValueNode) { |
| 493 pValueNode = (pGrandNode && pGrandNode->GetClassID() == XFA_ELEMENT_Value) | 499 pValueNode = (pGrandNode && pGrandNode->GetClassID() == XFA_ELEMENT_Value) |
| 494 ? pGrandNode | 500 ? pGrandNode |
| 495 : NULL; | 501 : nullptr; |
| 496 } | 502 } |
| 497 CXFA_Node* pParentOfValueNode = | 503 CXFA_Node* pParentOfValueNode = |
| 498 pValueNode ? pValueNode->GetNodeItem(XFA_NODEITEM_Parent) : NULL; | 504 pValueNode ? pValueNode->GetNodeItem(XFA_NODEITEM_Parent) : nullptr; |
| 499 return pParentOfValueNode ? pParentOfValueNode->GetContainerWidgetData() | 505 return pParentOfValueNode ? pParentOfValueNode->GetContainerWidgetData() |
| 500 : NULL; | 506 : nullptr; |
| 501 } | 507 } |
| 508 |
| 502 FX_BOOL CXFA_Node::GetLocaleName(CFX_WideString& wsLocaleName) { | 509 FX_BOOL CXFA_Node::GetLocaleName(CFX_WideString& wsLocaleName) { |
| 503 CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode(); | 510 CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode(); |
| 504 CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform); | 511 CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform); |
| 505 ASSERT(pTopSubform); | 512 ASSERT(pTopSubform); |
| 506 CXFA_Node* pLocaleNode = this; | 513 CXFA_Node* pLocaleNode = this; |
| 507 FX_BOOL bLocale = FALSE; | 514 FX_BOOL bLocale = FALSE; |
| 508 do { | 515 do { |
| 509 bLocale = pLocaleNode->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); | 516 bLocale = pLocaleNode->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); |
| 510 if (!bLocale) { | 517 if (!bLocale) { |
| 511 pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent); | 518 pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 512 } | 519 } |
| 513 } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale); | 520 } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale); |
| 514 if (bLocale) { | 521 if (bLocale) |
| 515 return bLocale; | 522 return TRUE; |
| 516 } | |
| 517 CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); | 523 CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); |
| 518 wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig); | 524 wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig); |
| 519 if (!wsLocaleName.IsEmpty()) { | 525 if (!wsLocaleName.IsEmpty()) |
| 520 bLocale = TRUE; | 526 return TRUE; |
| 521 } | 527 if (pTopSubform && |
| 522 if (bLocale) { | 528 pTopSubform->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE)) { |
| 523 return bLocale; | 529 return TRUE; |
| 524 } | |
| 525 if (pTopSubform) { | |
| 526 bLocale = pTopSubform->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); | |
| 527 } | |
| 528 if (bLocale) { | |
| 529 return bLocale; | |
| 530 } | 530 } |
| 531 IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale(); | 531 IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale(); |
| 532 if (pLocale) { | 532 if (pLocale) { |
| 533 wsLocaleName = pLocale->GetName(); | 533 wsLocaleName = pLocale->GetName(); |
| 534 bLocale = TRUE; | 534 return TRUE; |
| 535 } | 535 } |
| 536 return bLocale; | 536 return FALSE; |
| 537 } | 537 } |
| 538 |
| 538 XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { | 539 XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { |
| 539 XFA_ELEMENT eElement = GetClassID(); | 540 XFA_ELEMENT eElement = GetClassID(); |
| 540 CXFA_Node* pKeep = GetFirstChildByClass(XFA_ELEMENT_Keep); | 541 CXFA_Node* pKeep = GetFirstChildByClass(XFA_ELEMENT_Keep); |
| 541 XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout); | 542 XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout); |
| 542 if (pKeep) { | 543 if (pKeep) { |
| 543 XFA_ATTRIBUTEENUM eIntact; | 544 XFA_ATTRIBUTEENUM eIntact; |
| 544 if (pKeep->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, FALSE)) { | 545 if (pKeep->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, FALSE)) { |
| 545 if (eIntact == XFA_ATTRIBUTEENUM_None && | 546 if (eIntact == XFA_ATTRIBUTEENUM_None && |
| 546 eLayoutType == XFA_ATTRIBUTEENUM_Row && | 547 eLayoutType == XFA_ATTRIBUTEENUM_Row && |
| 547 m_pDocument->GetCurVersionMode() < XFA_VERSION_208) { | 548 m_pDocument->GetCurVersionMode() < XFA_VERSION_208) { |
| 548 CXFA_Node* pPreviewRow = | 549 CXFA_Node* pPreviewRow = |
| 549 GetNodeItem(XFA_NODEITEM_PrevSibling, XFA_OBJECTTYPE_ContainerNode); | 550 GetNodeItem(XFA_NODEITEM_PrevSibling, XFA_OBJECTTYPE_ContainerNode); |
| 550 if (pPreviewRow && | 551 if (pPreviewRow && |
| 551 pPreviewRow->GetEnum(XFA_ATTRIBUTE_Layout) == | 552 pPreviewRow->GetEnum(XFA_ATTRIBUTE_Layout) == |
| 552 XFA_ATTRIBUTEENUM_Row) { | 553 XFA_ATTRIBUTEENUM_Row) { |
| 553 XFA_ATTRIBUTEENUM eValue; | 554 XFA_ATTRIBUTEENUM eValue; |
| 554 if (pKeep->TryEnum(XFA_ATTRIBUTE_Previous, eValue, FALSE)) { | 555 if (pKeep->TryEnum(XFA_ATTRIBUTE_Previous, eValue, FALSE) && |
| 555 if (eValue == XFA_ATTRIBUTEENUM_ContentArea || | 556 (eValue == XFA_ATTRIBUTEENUM_ContentArea || |
| 556 eValue == XFA_ATTRIBUTEENUM_PageArea) { | 557 eValue == XFA_ATTRIBUTEENUM_PageArea)) { |
| 557 return XFA_ATTRIBUTEENUM_ContentArea; | 558 return XFA_ATTRIBUTEENUM_ContentArea; |
| 558 } | |
| 559 } | 559 } |
| 560 CXFA_Node* pKeep = | 560 CXFA_Node* pNode = |
| 561 pPreviewRow->GetFirstChildByClass(XFA_ELEMENT_Keep); | 561 pPreviewRow->GetFirstChildByClass(XFA_ELEMENT_Keep); |
| 562 if (pKeep) { | 562 if (pNode && pNode->TryEnum(XFA_ATTRIBUTE_Next, eValue, FALSE) && |
| 563 if (pKeep->TryEnum(XFA_ATTRIBUTE_Next, eValue, FALSE)) { | 563 (eValue == XFA_ATTRIBUTEENUM_ContentArea || |
| 564 if (eValue == XFA_ATTRIBUTEENUM_ContentArea || | 564 eValue == XFA_ATTRIBUTEENUM_PageArea)) { |
| 565 eValue == XFA_ATTRIBUTEENUM_PageArea) { | 565 return XFA_ATTRIBUTEENUM_ContentArea; |
| 566 return XFA_ATTRIBUTEENUM_ContentArea; | |
| 567 } | |
| 568 } | |
| 569 } | 566 } |
| 570 } | 567 } |
| 571 } | 568 } |
| 572 return eIntact; | 569 return eIntact; |
| 573 } | 570 } |
| 574 } | 571 } |
| 575 switch (eElement) { | 572 switch (eElement) { |
| 576 case XFA_ELEMENT_Subform: | 573 case XFA_ELEMENT_Subform: |
| 577 switch (eLayoutType) { | 574 switch (eLayoutType) { |
| 578 case XFA_ATTRIBUTEENUM_Position: | 575 case XFA_ATTRIBUTEENUM_Position: |
| 579 case XFA_ATTRIBUTEENUM_Row: | 576 case XFA_ATTRIBUTEENUM_Row: |
| 580 return XFA_ATTRIBUTEENUM_ContentArea; | 577 return XFA_ATTRIBUTEENUM_ContentArea; |
| 581 case XFA_ATTRIBUTEENUM_Tb: | 578 case XFA_ATTRIBUTEENUM_Tb: |
| 582 case XFA_ATTRIBUTEENUM_Table: | 579 case XFA_ATTRIBUTEENUM_Table: |
| 583 case XFA_ATTRIBUTEENUM_Lr_tb: | 580 case XFA_ATTRIBUTEENUM_Lr_tb: |
| 584 case XFA_ATTRIBUTEENUM_Rl_tb: | 581 case XFA_ATTRIBUTEENUM_Rl_tb: |
| 585 return XFA_ATTRIBUTEENUM_None; | 582 return XFA_ATTRIBUTEENUM_None; |
| 586 default: | 583 default: |
| 587 break; | 584 break; |
| 588 } | 585 } |
| 589 break; | 586 break; |
| 590 case XFA_ELEMENT_Field: { | 587 case XFA_ELEMENT_Field: { |
| 591 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); | 588 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); |
| 592 if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_PageArea) { | 589 if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_PageArea) |
| 593 return XFA_ATTRIBUTEENUM_ContentArea; | 590 return XFA_ATTRIBUTEENUM_ContentArea; |
| 594 } | |
| 595 if (pParentNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { | 591 if (pParentNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { |
| 596 XFA_ATTRIBUTEENUM eParLayout = | 592 XFA_ATTRIBUTEENUM eParLayout = |
| 597 pParentNode->GetEnum(XFA_ATTRIBUTE_Layout); | 593 pParentNode->GetEnum(XFA_ATTRIBUTE_Layout); |
| 598 if (eParLayout == XFA_ATTRIBUTEENUM_Position || | 594 if (eParLayout == XFA_ATTRIBUTEENUM_Position || |
| 599 eParLayout == XFA_ATTRIBUTEENUM_Row || | 595 eParLayout == XFA_ATTRIBUTEENUM_Row || |
| 600 eParLayout == XFA_ATTRIBUTEENUM_Table) { | 596 eParLayout == XFA_ATTRIBUTEENUM_Table) { |
| 601 return XFA_ATTRIBUTEENUM_None; | 597 return XFA_ATTRIBUTEENUM_None; |
| 602 } | 598 } |
| 603 XFA_VERSION version = m_pDocument->GetCurVersionMode(); | 599 XFA_VERSION version = m_pDocument->GetCurVersionMode(); |
| 604 if (eParLayout == XFA_ATTRIBUTEENUM_Tb && version < XFA_VERSION_208) { | 600 if (eParLayout == XFA_ATTRIBUTEENUM_Tb && version < XFA_VERSION_208) { |
| 605 CXFA_Measurement measureH; | 601 CXFA_Measurement measureH; |
| 606 if (TryMeasure(XFA_ATTRIBUTE_H, measureH, FALSE)) { | 602 if (TryMeasure(XFA_ATTRIBUTE_H, measureH, FALSE)) |
| 607 return XFA_ATTRIBUTEENUM_ContentArea; | 603 return XFA_ATTRIBUTEENUM_ContentArea; |
| 608 } | |
| 609 } | 604 } |
| 610 return XFA_ATTRIBUTEENUM_None; | 605 return XFA_ATTRIBUTEENUM_None; |
| 611 } | 606 } |
| 612 return XFA_ATTRIBUTEENUM_ContentArea; | 607 return XFA_ATTRIBUTEENUM_ContentArea; |
| 613 } | 608 } |
| 614 case XFA_ELEMENT_Draw: | 609 case XFA_ELEMENT_Draw: |
| 615 return XFA_ATTRIBUTEENUM_ContentArea; | 610 return XFA_ATTRIBUTEENUM_ContentArea; |
| 616 default: | 611 default: |
| 617 break; | 612 break; |
| 618 } | 613 } |
| 619 return XFA_ATTRIBUTEENUM_None; | 614 return XFA_ATTRIBUTEENUM_None; |
| 620 } | 615 } |
| 616 |
| 621 CXFA_Node* CXFA_Node::GetDataDescriptionNode() { | 617 CXFA_Node* CXFA_Node::GetDataDescriptionNode() { |
| 622 if (m_ePacket == XFA_XDPPACKET_Datasets) { | 618 if (m_ePacket == XFA_XDPPACKET_Datasets) |
| 623 return m_pAuxNode; | 619 return m_pAuxNode; |
| 624 } | 620 return nullptr; |
| 625 return NULL; | |
| 626 } | 621 } |
| 622 |
| 627 void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) { | 623 void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) { |
| 628 ASSERT(m_ePacket == XFA_XDPPACKET_Datasets); | 624 ASSERT(m_ePacket == XFA_XDPPACKET_Datasets); |
| 629 m_pAuxNode = pDataDescriptionNode; | 625 m_pAuxNode = pDataDescriptionNode; |
| 630 } | 626 } |
| 627 |
| 631 void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { | 628 void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { |
| 632 int32_t iLength = pArguments->GetLength(); | 629 int32_t iLength = pArguments->GetLength(); |
| 633 if (iLength != 1) { | 630 if (iLength != 1) { |
| 634 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resolveNode"); | 631 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resolveNode"); |
| 635 return; | 632 return; |
| 636 } | 633 } |
| 637 CFX_WideString wsExpression = | 634 CFX_WideString wsExpression = |
| 638 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 635 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 639 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 636 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 640 if (!pScriptContext) { | 637 if (!pScriptContext) |
| 641 return; | 638 return; |
| 642 } | |
| 643 CXFA_Node* refNode = this; | 639 CXFA_Node* refNode = this; |
| 644 if (refNode->GetClassID() == XFA_ELEMENT_Xfa) { | 640 if (refNode->GetClassID() == XFA_ELEMENT_Xfa) |
| 645 refNode = ToNode(pScriptContext->GetThisObject()); | 641 refNode = ToNode(pScriptContext->GetThisObject()); |
| 646 } | |
| 647 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 642 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
| 648 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | | 643 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | |
| 649 XFA_RESOLVENODE_Siblings; | 644 XFA_RESOLVENODE_Siblings; |
| 650 XFA_RESOLVENODE_RS resoveNodeRS; | 645 XFA_RESOLVENODE_RS resoveNodeRS; |
| 651 int32_t iRet = pScriptContext->ResolveObjects( | 646 int32_t iRet = pScriptContext->ResolveObjects( |
| 652 refNode, wsExpression.AsStringC(), resoveNodeRS, dwFlag); | 647 refNode, wsExpression.AsStringC(), resoveNodeRS, dwFlag); |
| 653 if (iRet < 1) { | 648 if (iRet < 1) |
| 654 return FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 649 return FXJSE_Value_SetNull(pArguments->GetReturnValue()); |
| 655 } | |
| 656 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 650 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 657 CXFA_Object* pNode = resoveNodeRS.nodes[0]; | 651 CXFA_Object* pNode = resoveNodeRS.nodes[0]; |
| 658 FXJSE_Value_Set(pArguments->GetReturnValue(), | 652 FXJSE_Value_Set(pArguments->GetReturnValue(), |
| 659 pScriptContext->GetJSValueFromMap(pNode)); | 653 pScriptContext->GetJSValueFromMap(pNode)); |
| 660 } else { | 654 } else { |
| 661 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = | 655 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = |
| 662 resoveNodeRS.pScriptAttribute; | 656 resoveNodeRS.pScriptAttribute; |
| 663 if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) { | 657 if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) { |
| 664 std::unique_ptr<CFXJSE_Value> pValue( | 658 std::unique_ptr<CFXJSE_Value> pValue( |
| 665 new CFXJSE_Value(pScriptContext->GetRuntime())); | 659 new CFXJSE_Value(pScriptContext->GetRuntime())); |
| 666 (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))( | 660 (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))( |
| 667 pValue.get(), FALSE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); | 661 pValue.get(), FALSE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); |
| 668 FXJSE_Value_Set(pArguments->GetReturnValue(), pValue.get()); | 662 FXJSE_Value_Set(pArguments->GetReturnValue(), pValue.get()); |
| 669 } else { | 663 } else { |
| 670 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 664 FXJSE_Value_SetNull(pArguments->GetReturnValue()); |
| 671 } | 665 } |
| 672 } | 666 } |
| 673 } | 667 } |
| 668 |
| 674 void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { | 669 void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { |
| 675 int32_t iLength = pArguments->GetLength(); | 670 int32_t iLength = pArguments->GetLength(); |
| 676 if (iLength != 1) { | 671 if (iLength != 1) { |
| 677 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 672 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 678 L"resolveNodes"); | 673 L"resolveNodes"); |
| 679 return; | 674 return; |
| 680 } | 675 } |
| 681 CFX_WideString wsExpression = | 676 CFX_WideString wsExpression = |
| 682 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 677 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 683 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 678 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 684 if (!pValue) { | 679 if (!pValue) |
| 685 return; | 680 return; |
| 686 } | |
| 687 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 681 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
| 688 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | | 682 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | |
| 689 XFA_RESOLVENODE_Siblings; | 683 XFA_RESOLVENODE_Siblings; |
| 690 CXFA_Node* refNode = this; | 684 CXFA_Node* refNode = this; |
| 691 if (refNode->GetClassID() == XFA_ELEMENT_Xfa) { | 685 if (refNode->GetClassID() == XFA_ELEMENT_Xfa) |
| 692 refNode = ToNode(m_pDocument->GetScriptContext()->GetThisObject()); | 686 refNode = ToNode(m_pDocument->GetScriptContext()->GetThisObject()); |
| 693 } | |
| 694 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode); | 687 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode); |
| 695 } | 688 } |
| 689 |
| 696 void CXFA_Node::Script_Som_ResolveNodeList(CFXJSE_Value* pValue, | 690 void CXFA_Node::Script_Som_ResolveNodeList(CFXJSE_Value* pValue, |
| 697 CFX_WideString wsExpression, | 691 CFX_WideString wsExpression, |
| 698 uint32_t dwFlag, | 692 uint32_t dwFlag, |
| 699 CXFA_Node* refNode) { | 693 CXFA_Node* refNode) { |
| 700 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 694 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 701 if (!pScriptContext) { | 695 if (!pScriptContext) |
| 702 return; | 696 return; |
| 703 } | |
| 704 XFA_RESOLVENODE_RS resoveNodeRS; | 697 XFA_RESOLVENODE_RS resoveNodeRS; |
| 705 if (refNode == NULL) { | 698 if (!refNode) |
| 706 refNode = this; | 699 refNode = this; |
| 707 } | |
| 708 pScriptContext->ResolveObjects(refNode, wsExpression.AsStringC(), | 700 pScriptContext->ResolveObjects(refNode, wsExpression.AsStringC(), |
| 709 resoveNodeRS, dwFlag); | 701 resoveNodeRS, dwFlag); |
| 710 CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(m_pDocument); | 702 CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(m_pDocument); |
| 711 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 703 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 712 for (int32_t i = 0; i < resoveNodeRS.nodes.GetSize(); i++) { | 704 for (int32_t i = 0; i < resoveNodeRS.nodes.GetSize(); i++) { |
| 713 if (resoveNodeRS.nodes[i]->IsNode()) | 705 if (resoveNodeRS.nodes[i]->IsNode()) |
| 714 pNodeList->Append(resoveNodeRS.nodes[i]->AsNode()); | 706 pNodeList->Append(resoveNodeRS.nodes[i]->AsNode()); |
| 715 } | 707 } |
| 716 } else { | 708 } else { |
| 717 CXFA_ValueArray valueArray(pScriptContext->GetRuntime()); | 709 CXFA_ValueArray valueArray(pScriptContext->GetRuntime()); |
| 718 if (resoveNodeRS.GetAttributeResult(valueArray) > 0) { | 710 if (resoveNodeRS.GetAttributeResult(valueArray) > 0) { |
| 719 CXFA_ObjArray objectArray; | 711 CXFA_ObjArray objectArray; |
| 720 valueArray.GetAttributeObject(objectArray); | 712 valueArray.GetAttributeObject(objectArray); |
| 721 for (int32_t i = 0; i < objectArray.GetSize(); i++) { | 713 for (int32_t i = 0; i < objectArray.GetSize(); i++) { |
| 722 if (objectArray[i]->IsNode()) | 714 if (objectArray[i]->IsNode()) |
| 723 pNodeList->Append(objectArray[i]->AsNode()); | 715 pNodeList->Append(objectArray[i]->AsNode()); |
| 724 } | 716 } |
| 725 } | 717 } |
| 726 } | 718 } |
| 727 FXJSE_Value_SetObject(pValue, (CXFA_Object*)pNodeList, | 719 FXJSE_Value_SetObject(pValue, (CXFA_Object*)pNodeList, |
| 728 pScriptContext->GetJseNormalClass()); | 720 pScriptContext->GetJseNormalClass()); |
| 729 } | 721 } |
| 722 |
| 730 void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue, | 723 void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue, |
| 731 FX_BOOL bSetting, | 724 FX_BOOL bSetting, |
| 732 XFA_ATTRIBUTE eAttribute) { | 725 XFA_ATTRIBUTE eAttribute) { |
| 733 if (bSetting) { | 726 if (bSetting) { |
| 734 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 727 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 735 } else { | 728 } else { |
| 736 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; | 729 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; |
| 737 CFX_WideString wsName; | 730 CFX_WideString wsName; |
| 738 GetAttribute(XFA_ATTRIBUTE_Name, wsName); | 731 GetAttribute(XFA_ATTRIBUTE_Name, wsName); |
| 739 CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]"); | 732 CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]"); |
| 740 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); | 733 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); |
| 741 } | 734 } |
| 742 } | 735 } |
| 736 |
| 743 void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue, | 737 void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue, |
| 744 FX_BOOL bSetting, | 738 FX_BOOL bSetting, |
| 745 XFA_ATTRIBUTE eAttribute) { | 739 XFA_ATTRIBUTE eAttribute) { |
| 746 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 740 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 747 if (!pScriptContext) { | 741 if (!pScriptContext) |
| 748 return; | 742 return; |
| 749 } | |
| 750 if (bSetting) { | 743 if (bSetting) { |
| 751 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 744 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 752 ASSERT(pAppProvider); | 745 ASSERT(pAppProvider); |
| 753 CFX_WideString wsMessage; | 746 CFX_WideString wsMessage; |
| 754 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); | 747 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); |
| 755 FXJSE_ThrowMessage( | 748 FXJSE_ThrowMessage( |
| 756 "", | 749 "", |
| 757 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 750 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 758 } else { | 751 } else { |
| 759 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); | 752 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); |
| 760 FXJSE_Value_SetObject(pValue, (CXFA_Object*)pNodeList, | 753 FXJSE_Value_SetObject(pValue, (CXFA_Object*)pNodeList, |
| 761 pScriptContext->GetJseNormalClass()); | 754 pScriptContext->GetJseNormalClass()); |
| 762 } | 755 } |
| 763 } | 756 } |
| 757 |
| 764 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, | 758 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, |
| 765 FX_BOOL bSetting, | 759 FX_BOOL bSetting, |
| 766 XFA_ATTRIBUTE eAttribute) { | 760 XFA_ATTRIBUTE eAttribute) { |
| 767 if (bSetting) { | 761 if (bSetting) { |
| 768 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 762 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 769 } else { | 763 } else { |
| 770 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; | 764 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; |
| 771 CFX_WideStringC wsName; | 765 CFX_WideStringC wsName; |
| 772 GetClassName(wsName); | 766 GetClassName(wsName); |
| 773 CFX_WideString wsExpression = FX_WSTRC(L"#") + wsName + FX_WSTRC(L"[*]"); | 767 CFX_WideString wsExpression = FX_WSTRC(L"#") + wsName + FX_WSTRC(L"[*]"); |
| 774 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); | 768 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); |
| 775 } | 769 } |
| 776 } | 770 } |
| 771 |
| 777 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, | 772 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, |
| 778 FX_BOOL bSetting, | 773 FX_BOOL bSetting, |
| 779 XFA_ATTRIBUTE eAttribute) { | 774 XFA_ATTRIBUTE eAttribute) { |
| 780 if (bSetting) { | 775 if (bSetting) { |
| 781 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 776 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 782 } else { | 777 } else { |
| 783 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); | 778 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); |
| 784 if (pParent) { | 779 if (pParent) { |
| 785 FXJSE_Value_Set( | 780 FXJSE_Value_Set( |
| 786 pValue, m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent)); | 781 pValue, m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent)); |
| 787 } else { | 782 } else { |
| 788 FXJSE_Value_SetNull(pValue); | 783 FXJSE_Value_SetNull(pValue); |
| 789 } | 784 } |
| 790 } | 785 } |
| 791 } | 786 } |
| 787 |
| 792 void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue, | 788 void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue, |
| 793 FX_BOOL bSetting, | 789 FX_BOOL bSetting, |
| 794 XFA_ATTRIBUTE eAttribute) { | 790 XFA_ATTRIBUTE eAttribute) { |
| 795 if (bSetting) { | 791 if (bSetting) |
| 796 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 792 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 797 } else { | 793 else |
| 798 FXJSE_Value_SetInteger(pValue, GetNodeSameNameIndex()); | 794 FXJSE_Value_SetInteger(pValue, GetNodeSameNameIndex()); |
| 799 } | |
| 800 } | 795 } |
| 796 |
| 801 void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, | 797 void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, |
| 802 FX_BOOL bSetting, | 798 FX_BOOL bSetting, |
| 803 XFA_ATTRIBUTE eAttribute) { | 799 XFA_ATTRIBUTE eAttribute) { |
| 804 if (bSetting) { | 800 if (bSetting) |
| 805 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 801 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 806 } else { | 802 else |
| 807 FXJSE_Value_SetInteger(pValue, GetNodeSameClassIndex()); | 803 FXJSE_Value_SetInteger(pValue, GetNodeSameClassIndex()); |
| 808 } | |
| 809 } | 804 } |
| 805 |
| 810 void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, | 806 void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, |
| 811 FX_BOOL bSetting, | 807 FX_BOOL bSetting, |
| 812 XFA_ATTRIBUTE eAttribute) { | 808 XFA_ATTRIBUTE eAttribute) { |
| 813 if (bSetting) { | 809 if (bSetting) { |
| 814 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 810 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 815 } else { | 811 } else { |
| 816 CFX_WideString wsSOMExpression; | 812 CFX_WideString wsSOMExpression; |
| 817 GetSOMExpression(wsSOMExpression); | 813 GetSOMExpression(wsSOMExpression); |
| 818 FXJSE_Value_SetUTF8String(pValue, | 814 FXJSE_Value_SetUTF8String(pValue, |
| 819 FX_UTF8Encode(wsSOMExpression).AsStringC()); | 815 FX_UTF8Encode(wsSOMExpression).AsStringC()); |
| 820 } | 816 } |
| 821 } | 817 } |
| 818 |
| 822 void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { | 819 void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { |
| 823 int32_t iLength = pArguments->GetLength(); | 820 int32_t iLength = pArguments->GetLength(); |
| 824 if (iLength != 1) { | 821 if (iLength != 1) { |
| 825 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"applyXSL"); | 822 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"applyXSL"); |
| 826 return; | 823 return; |
| 827 } | 824 } |
| 828 CFX_WideString wsExpression = | 825 CFX_WideString wsExpression = |
| 829 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 826 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 830 // TODO(weili): check whether we need to implement this, pdfium:501. | 827 // TODO(weili): check whether we need to implement this, pdfium:501. |
| 831 // For now, just put the variables here to avoid unused variable warning. | 828 // For now, just put the variables here to avoid unused variable warning. |
| 832 (void)wsExpression; | 829 (void)wsExpression; |
| 833 } | 830 } |
| 834 | 831 |
| 835 void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) { | 832 void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) { |
| 836 int32_t iLength = pArguments->GetLength(); | 833 int32_t iLength = pArguments->GetLength(); |
| 837 if (iLength < 1 || iLength > 3) { | 834 if (iLength < 1 || iLength > 3) { |
| 838 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"assignNode"); | 835 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"assignNode"); |
| 839 return; | 836 return; |
| 840 } | 837 } |
| 841 CFX_WideString wsExpression; | 838 CFX_WideString wsExpression; |
| 842 CFX_WideString wsValue; | 839 CFX_WideString wsValue; |
| 843 int32_t iAction = 0; | 840 int32_t iAction = 0; |
| 844 if (iLength >= 1) { | 841 wsExpression = |
| 845 wsExpression = | 842 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 846 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | |
| 847 } | |
| 848 if (iLength >= 2) { | 843 if (iLength >= 2) { |
| 849 wsValue = | 844 wsValue = |
| 850 CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC()); | 845 CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC()); |
| 851 } | 846 } |
| 852 if (iLength >= 3) | 847 if (iLength >= 3) |
| 853 iAction = pArguments->GetInt32(2); | 848 iAction = pArguments->GetInt32(2); |
| 854 // TODO(weili): check whether we need to implement this, pdfium:501. | 849 // TODO(weili): check whether we need to implement this, pdfium:501. |
| 855 // For now, just put the variables here to avoid unused variable warning. | 850 // For now, just put the variables here to avoid unused variable warning. |
| 856 (void)wsExpression; | 851 (void)wsExpression; |
| 857 (void)wsValue; | 852 (void)wsValue; |
| 858 (void)iAction; | 853 (void)iAction; |
| 859 } | 854 } |
| 860 | 855 |
| 861 void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { | 856 void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { |
| 862 int32_t iLength = pArguments->GetLength(); | 857 int32_t iLength = pArguments->GetLength(); |
| 863 if (iLength != 1) { | 858 if (iLength != 1) { |
| 864 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clone"); | 859 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clone"); |
| 865 return; | 860 return; |
| 866 } | 861 } |
| 867 FX_BOOL bClone = TRUE; | 862 bool bClone = !!pArguments->GetInt32(0); |
| 868 bClone = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; | |
| 869 CXFA_Node* pCloneNode = Clone(bClone); | 863 CXFA_Node* pCloneNode = Clone(bClone); |
| 870 FXJSE_Value_Set( | 864 FXJSE_Value_Set( |
| 871 pArguments->GetReturnValue(), | 865 pArguments->GetReturnValue(), |
| 872 m_pDocument->GetScriptContext()->GetJSValueFromMap(pCloneNode)); | 866 m_pDocument->GetScriptContext()->GetJSValueFromMap(pCloneNode)); |
| 873 } | 867 } |
| 868 |
| 874 void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { | 869 void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { |
| 875 int32_t iLength = pArguments->GetLength(); | 870 int32_t iLength = pArguments->GetLength(); |
| 876 if (iLength != 1) { | 871 if (iLength != 1) { |
| 877 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 872 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 878 L"getAttribute"); | 873 L"getAttribute"); |
| 879 return; | 874 return; |
| 880 } | 875 } |
| 881 CFX_WideString wsExpression = | 876 CFX_WideString wsExpression = |
| 882 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 877 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 883 CFX_WideString wsValue; | 878 CFX_WideString wsValue; |
| 884 GetAttribute(wsExpression.AsStringC(), wsValue); | 879 GetAttribute(wsExpression.AsStringC(), wsValue); |
| 885 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 880 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
| 886 if (pValue) { | 881 if (pValue) |
| 887 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); | 882 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); |
| 888 } | |
| 889 } | 883 } |
| 884 |
| 890 void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { | 885 void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { |
| 891 int32_t iLength = pArguments->GetLength(); | 886 int32_t iLength = pArguments->GetLength(); |
| 892 if (iLength < 1 || iLength > 2) { | 887 if (iLength < 1 || iLength > 2) { |
| 893 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); | 888 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); |
| 894 return; | 889 return; |
| 895 } | 890 } |
| 896 CFX_WideString wsExpression; | 891 CFX_WideString wsExpression; |
| 897 int32_t iValue = 0; | 892 int32_t iValue = 0; |
| 898 if (iLength >= 1) { | 893 wsExpression = |
| 899 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); | 894 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 900 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); | 895 if (iLength >= 2) |
| 901 } | |
| 902 if (iLength >= 2) { | |
| 903 iValue = pArguments->GetInt32(1); | 896 iValue = pArguments->GetInt32(1); |
| 904 } | |
| 905 const XFA_ELEMENTINFO* pElementInfo = | 897 const XFA_ELEMENTINFO* pElementInfo = |
| 906 XFA_GetElementByName(wsExpression.AsStringC()); | 898 XFA_GetElementByName(wsExpression.AsStringC()); |
| 907 CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); | 899 CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); |
| 908 FXJSE_Value_Set(pArguments->GetReturnValue(), | 900 FXJSE_Value_Set(pArguments->GetReturnValue(), |
| 909 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | 901 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); |
| 910 } | 902 } |
| 911 | 903 |
| 912 void CXFA_Node::Script_NodeClass_IsPropertySpecified( | 904 void CXFA_Node::Script_NodeClass_IsPropertySpecified( |
| 913 CFXJSE_Arguments* pArguments) { | 905 CFXJSE_Arguments* pArguments) { |
| 914 int32_t iLength = pArguments->GetLength(); | 906 int32_t iLength = pArguments->GetLength(); |
| 915 if (iLength < 1 || iLength > 3) { | 907 if (iLength < 1 || iLength > 3) { |
| 916 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 908 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 917 L"isPropertySpecified"); | 909 L"isPropertySpecified"); |
| 918 return; | 910 return; |
| 919 } | 911 } |
| 920 CFX_WideString wsExpression; | 912 CFX_WideString wsExpression; |
| 921 FX_BOOL bParent = TRUE; | 913 bool bParent = true; |
| 922 int32_t iIndex = 0; | 914 int32_t iIndex = 0; |
| 923 if (iLength >= 1) { | 915 wsExpression = |
| 924 wsExpression = | 916 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 925 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | |
| 926 } | |
| 927 if (iLength >= 2) | 917 if (iLength >= 2) |
| 928 bParent = !!pArguments->GetInt32(1) ? TRUE : FALSE; | 918 bParent = !!pArguments->GetInt32(1); |
| 929 if (iLength >= 3) | 919 if (iLength >= 3) |
| 930 iIndex = pArguments->GetInt32(2); | 920 iIndex = pArguments->GetInt32(2); |
| 931 FX_BOOL bHas = FALSE; | 921 FX_BOOL bHas = FALSE; |
| 932 const XFA_ATTRIBUTEINFO* pAttributeInfo = | 922 const XFA_ATTRIBUTEINFO* pAttributeInfo = |
| 933 XFA_GetAttributeByName(wsExpression.AsStringC()); | 923 XFA_GetAttributeByName(wsExpression.AsStringC()); |
| 934 CFX_WideString wsValue; | 924 CFX_WideString wsValue; |
| 935 if (pAttributeInfo) | 925 if (pAttributeInfo) |
| 936 bHas = HasAttribute(pAttributeInfo->eName); | 926 bHas = HasAttribute(pAttributeInfo->eName); |
| 937 if (!bHas) { | 927 if (!bHas) { |
| 938 const XFA_ELEMENTINFO* pElementInfo = | 928 const XFA_ELEMENTINFO* pElementInfo = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 950 FXJSE_Value_SetBoolean(pValue, bHas); | 940 FXJSE_Value_SetBoolean(pValue, bHas); |
| 951 } | 941 } |
| 952 | 942 |
| 953 void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { | 943 void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { |
| 954 int32_t iLength = pArguments->GetLength(); | 944 int32_t iLength = pArguments->GetLength(); |
| 955 if (iLength < 1 || iLength > 3) { | 945 if (iLength < 1 || iLength > 3) { |
| 956 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"loadXML"); | 946 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"loadXML"); |
| 957 return; | 947 return; |
| 958 } | 948 } |
| 959 CFX_WideString wsExpression; | 949 CFX_WideString wsExpression; |
| 960 FX_BOOL bIgnoreRoot = TRUE; | 950 bool bIgnoreRoot = true; |
| 961 FX_BOOL bOverwrite = 0; | 951 bool bOverwrite = 0; |
| 962 if (iLength >= 1) { | 952 wsExpression = |
| 963 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); | 953 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 964 wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); | 954 if (wsExpression.IsEmpty()) |
| 965 if (wsExpression.IsEmpty()) { | |
| 966 return; | |
| 967 } | |
| 968 } | |
| 969 if (iLength >= 2) { | |
| 970 bIgnoreRoot = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; | |
| 971 } | |
| 972 if (iLength >= 3) { | |
| 973 bOverwrite = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; | |
| 974 } | |
| 975 IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument); | |
| 976 if (!pParser) { | |
| 977 return; | 955 return; |
| 978 } | 956 if (iLength >= 2) |
| 979 CFDE_XMLNode* pXMLNode = NULL; | 957 bIgnoreRoot = !!pArguments->GetInt32(1); |
| 980 int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL); | 958 if (iLength >= 3) |
| 981 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) { | 959 bOverwrite = !!pArguments->GetInt32(2); |
| 982 pParser->Release(); | 960 std::unique_ptr<IXFA_Parser, ReleaseDeleter<IXFA_Parser>> pParser( |
| 983 pParser = NULL; | 961 IXFA_Parser::Create(m_pDocument)); |
| 962 if (!pParser) |
| 984 return; | 963 return; |
| 985 } | 964 CFDE_XMLNode* pXMLNode = nullptr; |
| 965 int32_t iParserStatus = |
| 966 pParser->ParseXMLData(wsExpression, pXMLNode, nullptr); |
| 967 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) |
| 968 return; |
| 986 if (bIgnoreRoot && | 969 if (bIgnoreRoot && |
| 987 (pXMLNode->GetType() != FDE_XMLNODE_Element || | 970 (pXMLNode->GetType() != FDE_XMLNODE_Element || |
| 988 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) { | 971 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) { |
| 989 bIgnoreRoot = FALSE; | 972 bIgnoreRoot = false; |
| 990 } | 973 } |
| 991 CXFA_Node* pFakeRoot = Clone(FALSE); | 974 CXFA_Node* pFakeRoot = Clone(FALSE); |
| 992 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); | 975 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); |
| 993 if (!wsContentType.IsEmpty()) { | 976 if (!wsContentType.IsEmpty()) { |
| 994 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, | 977 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, |
| 995 CFX_WideString(wsContentType)); | 978 CFX_WideString(wsContentType)); |
| 996 } | 979 } |
| 997 CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); | 980 CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); |
| 998 if (!pFakeXMLRoot) { | 981 if (!pFakeXMLRoot) { |
| 999 CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); | 982 CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); |
| 1000 pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : NULL; | 983 pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : nullptr; |
| 1001 } | 984 } |
| 1002 if (!pFakeXMLRoot) { | 985 if (!pFakeXMLRoot) { |
| 1003 CFX_WideStringC wsClassName; | 986 CFX_WideStringC wsClassName; |
| 1004 GetClassName(wsClassName); | 987 GetClassName(wsClassName); |
| 1005 pFakeXMLRoot = new CFDE_XMLElement(CFX_WideString(wsClassName)); | 988 pFakeXMLRoot = new CFDE_XMLElement(CFX_WideString(wsClassName)); |
| 1006 } | 989 } |
| 1007 if (bIgnoreRoot) { | 990 if (bIgnoreRoot) { |
| 1008 CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); | 991 CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); |
| 1009 while (pXMLChild) { | 992 while (pXMLChild) { |
| 1010 CFDE_XMLNode* pXMLSibling = | 993 CFDE_XMLNode* pXMLSibling = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1038 CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); | 1021 CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 1039 RemoveChild(pChild); | 1022 RemoveChild(pChild); |
| 1040 pFakeRoot->InsertChild(pChild); | 1023 pFakeRoot->InsertChild(pChild); |
| 1041 pChild = pItem; | 1024 pChild = pItem; |
| 1042 } | 1025 } |
| 1043 if (GetPacketID() == XFA_XDPPACKET_Form && | 1026 if (GetPacketID() == XFA_XDPPACKET_Form && |
| 1044 GetClassID() == XFA_ELEMENT_ExData) { | 1027 GetClassID() == XFA_ELEMENT_ExData) { |
| 1045 CFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); | 1028 CFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); |
| 1046 SetXMLMappingNode(pFakeXMLRoot); | 1029 SetXMLMappingNode(pFakeXMLRoot); |
| 1047 SetFlag(XFA_NODEFLAG_OwnXMLNode, false); | 1030 SetFlag(XFA_NODEFLAG_OwnXMLNode, false); |
| 1048 if (pTempXMLNode && | 1031 if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFDE_XMLNode::Parent)) { |
| 1049 pTempXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL) { | |
| 1050 pFakeXMLRoot = pTempXMLNode; | 1032 pFakeXMLRoot = pTempXMLNode; |
| 1051 } else { | 1033 } else { |
| 1052 pFakeXMLRoot = NULL; | 1034 pFakeXMLRoot = nullptr; |
| 1053 } | 1035 } |
| 1054 } | 1036 } |
| 1055 MoveBufferMapData(pFakeRoot, this, XFA_CalcData, TRUE); | 1037 MoveBufferMapData(pFakeRoot, this, XFA_CalcData, TRUE); |
| 1056 } else { | 1038 } else { |
| 1057 CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); | 1039 CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 1058 while (pChild) { | 1040 while (pChild) { |
| 1059 CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); | 1041 CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 1060 pFakeRoot->RemoveChild(pChild); | 1042 pFakeRoot->RemoveChild(pChild); |
| 1061 InsertChild(pChild); | 1043 InsertChild(pChild); |
| 1062 pChild->SetFlag(XFA_NODEFLAG_Initialized, true); | 1044 pChild->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 1063 pChild = pItem; | 1045 pChild = pItem; |
| 1064 } | 1046 } |
| 1065 } | 1047 } |
| 1066 if (pFakeXMLRoot) { | 1048 if (pFakeXMLRoot) { |
| 1067 pFakeRoot->SetXMLMappingNode(pFakeXMLRoot); | 1049 pFakeRoot->SetXMLMappingNode(pFakeXMLRoot); |
| 1068 pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); | 1050 pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); |
| 1069 } | 1051 } |
| 1070 pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false); | 1052 pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false); |
| 1071 } else { | 1053 } else { |
| 1072 if (pFakeXMLRoot) { | 1054 if (pFakeXMLRoot) { |
| 1073 pFakeXMLRoot->Release(); | 1055 pFakeXMLRoot->Release(); |
| 1074 pFakeXMLRoot = NULL; | 1056 pFakeXMLRoot = nullptr; |
| 1075 } | 1057 } |
| 1076 } | 1058 } |
| 1077 pParser->Release(); | |
| 1078 pParser = NULL; | |
| 1079 } | 1059 } |
| 1060 |
| 1080 void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { | 1061 void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { |
| 1062 // TODO(weili): Check whether we need to implement this, pdfium:501. |
| 1081 } | 1063 } |
| 1082 | 1064 |
| 1083 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { | 1065 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { |
| 1084 int32_t iLength = pArguments->GetLength(); | 1066 int32_t iLength = pArguments->GetLength(); |
| 1085 if (iLength < 0 || iLength > 1) { | 1067 if (iLength < 0 || iLength > 1) { |
| 1086 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); | 1068 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); |
| 1087 return; | 1069 return; |
| 1088 } | 1070 } |
| 1089 FX_BOOL bPrettyMode = FALSE; | 1071 bool bPrettyMode = false; |
| 1090 if (iLength == 1) { | 1072 if (iLength == 1) { |
| 1091 if (pArguments->GetUTF8String(0) != "pretty") { | 1073 if (pArguments->GetUTF8String(0) != "pretty") { |
| 1092 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 1074 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 1093 return; | 1075 return; |
| 1094 } | 1076 } |
| 1095 bPrettyMode = TRUE; | 1077 bPrettyMode = true; |
| 1096 } | 1078 } |
| 1097 CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | 1079 CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
| 1098 if (GetPacketID() == XFA_XDPPACKET_Form || | 1080 if (GetPacketID() == XFA_XDPPACKET_Form || |
| 1099 GetPacketID() == XFA_XDPPACKET_Datasets) { | 1081 GetPacketID() == XFA_XDPPACKET_Datasets) { |
| 1100 CFDE_XMLNode* pElement = nullptr; | 1082 CFDE_XMLNode* pElement = nullptr; |
| 1101 if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 1083 if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
| 1102 pElement = GetXMLMappingNode(); | 1084 pElement = GetXMLMappingNode(); |
| 1103 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { | 1085 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { |
| 1104 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); | 1086 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); |
| 1105 return; | 1087 return; |
| 1106 } | 1088 } |
| 1107 XFA_DataExporter_DealWithDataGroupNode(this); | 1089 XFA_DataExporter_DealWithDataGroupNode(this); |
| 1108 } | 1090 } |
| 1109 std::unique_ptr<IFX_MemoryStream> pMemoryStream( | 1091 std::unique_ptr<IFX_MemoryStream, ReleaseDeleter<IFX_MemoryStream>> |
| 1110 FX_CreateMemoryStream(TRUE)); | 1092 pMemoryStream(FX_CreateMemoryStream(TRUE)); |
| 1111 std::unique_ptr<IFX_Stream> pStream(IFX_Stream::CreateStream( | 1093 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> pStream( |
| 1112 (IFX_FileWrite*)pMemoryStream.get(), | 1094 IFX_Stream::CreateStream( |
| 1113 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append)); | 1095 static_cast<IFX_FileWrite*>(pMemoryStream.get()), |
| 1096 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | |
| 1097 FX_STREAMACCESS_Append)); |
| 1114 if (!pStream) { | 1098 if (!pStream) { |
| 1115 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); | 1099 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); |
| 1116 return; | 1100 return; |
| 1117 } | 1101 } |
| 1118 pStream->SetCodePage(FX_CODEPAGE_UTF8); | 1102 pStream->SetCodePage(FX_CODEPAGE_UTF8); |
| 1119 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength()); | 1103 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength()); |
| 1120 if (GetPacketID() == XFA_XDPPACKET_Form) | 1104 if (GetPacketID() == XFA_XDPPACKET_Form) |
| 1121 XFA_DataExporter_RegenerateFormFile(this, pStream.get(), NULL, TRUE); | 1105 XFA_DataExporter_RegenerateFormFile(this, pStream.get(), nullptr, TRUE); |
| 1122 else | 1106 else |
| 1123 pElement->SaveXMLNode(pStream.get()); | 1107 pElement->SaveXMLNode(pStream.get()); |
| 1124 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. | 1108 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. |
| 1125 // For now, just put it here to avoid unused variable warning. | 1109 // For now, just put it here to avoid unused variable warning. |
| 1126 (void)bPrettyMode; | 1110 (void)bPrettyMode; |
| 1127 FXJSE_Value_SetUTF8String( | 1111 FXJSE_Value_SetUTF8String( |
| 1128 pArguments->GetReturnValue(), | 1112 pArguments->GetReturnValue(), |
| 1129 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); | 1113 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); |
| 1130 return; | 1114 return; |
| 1131 } | 1115 } |
| 1132 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); | 1116 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); |
| 1133 } | 1117 } |
| 1134 | 1118 |
| 1135 void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { | 1119 void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { |
| 1136 int32_t iLength = pArguments->GetLength(); | 1120 int32_t iLength = pArguments->GetLength(); |
| 1137 if (iLength != 2) { | 1121 if (iLength != 2) { |
| 1138 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1122 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1139 L"setAttribute"); | 1123 L"setAttribute"); |
| 1140 return; | 1124 return; |
| 1141 } | 1125 } |
| 1142 CFX_WideString wsAttributeValue = | 1126 CFX_WideString wsAttributeValue = |
| 1143 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 1127 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
| 1144 CFX_WideString wsAttribute = | 1128 CFX_WideString wsAttribute = |
| 1145 CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC()); | 1129 CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC()); |
| 1146 SetAttribute(wsAttribute.AsStringC(), wsAttributeValue.AsStringC(), TRUE); | 1130 SetAttribute(wsAttribute.AsStringC(), wsAttributeValue.AsStringC(), true); |
| 1147 } | 1131 } |
| 1148 | 1132 |
| 1149 void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) { | 1133 void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) { |
| 1150 int32_t iLength = pArguments->GetLength(); | 1134 int32_t iLength = pArguments->GetLength(); |
| 1151 if (iLength != 1 && iLength != 2) { | 1135 if (iLength != 1 && iLength != 2) { |
| 1152 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setElement"); | 1136 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setElement"); |
| 1153 return; | 1137 return; |
| 1154 } | 1138 } |
| 1155 CXFA_Node* pNode = nullptr; | 1139 CXFA_Node* pNode = nullptr; |
| 1156 CFX_WideString wsName; | 1140 CFX_WideString wsName; |
| 1157 if (iLength >= 1) | 1141 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
| 1158 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 1142 if (iLength == 2) |
| 1159 if (iLength >= 2) { | |
| 1160 wsName = CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC()); | 1143 wsName = CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC()); |
| 1161 } | |
| 1162 // TODO(weili): check whether we need to implement this, pdfium:501. | 1144 // TODO(weili): check whether we need to implement this, pdfium:501. |
| 1163 // For now, just put the variables here to avoid unused variable warning. | 1145 // For now, just put the variables here to avoid unused variable warning. |
| 1164 (void)pNode; | 1146 (void)pNode; |
| 1165 (void)wsName; | 1147 (void)wsName; |
| 1166 } | 1148 } |
| 1167 | 1149 |
| 1168 void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, | 1150 void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, |
| 1169 FX_BOOL bSetting, | 1151 FX_BOOL bSetting, |
| 1170 XFA_ATTRIBUTE eAttribute) { | 1152 XFA_ATTRIBUTE eAttribute) { |
| 1171 if (bSetting) { | 1153 if (bSetting) { |
| 1172 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 1154 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 1173 } else { | 1155 } else { |
| 1174 CFX_WideString wsNameSpace; | 1156 CFX_WideString wsNameSpace; |
| 1175 TryNamespace(wsNameSpace); | 1157 TryNamespace(wsNameSpace); |
| 1176 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsNameSpace).AsStringC()); | 1158 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsNameSpace).AsStringC()); |
| 1177 } | 1159 } |
| 1178 } | 1160 } |
| 1161 |
| 1179 void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, | 1162 void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, |
| 1180 FX_BOOL bSetting, | 1163 FX_BOOL bSetting, |
| 1181 XFA_ATTRIBUTE eAttribute) { | 1164 XFA_ATTRIBUTE eAttribute) { |
| 1182 if (bSetting) { | 1165 if (bSetting) { |
| 1183 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 1166 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 1184 } else { | 1167 } else { |
| 1185 FXJSE_Value_Set(pValue, m_pDocument->GetScriptContext()->GetJSValueFromMap( | 1168 FXJSE_Value_Set(pValue, m_pDocument->GetScriptContext()->GetJSValueFromMap( |
| 1186 GetModelNode())); | 1169 GetModelNode())); |
| 1187 } | 1170 } |
| 1188 } | 1171 } |
| 1172 |
| 1189 void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, | 1173 void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, |
| 1190 FX_BOOL bSetting, | 1174 FX_BOOL bSetting, |
| 1191 XFA_ATTRIBUTE eAttribute) { | 1175 XFA_ATTRIBUTE eAttribute) { |
| 1192 if (bSetting) { | 1176 if (bSetting) |
| 1193 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 1177 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 1194 } else { | 1178 else |
| 1195 FXJSE_Value_SetBoolean(pValue, IsContainerNode()); | 1179 FXJSE_Value_SetBoolean(pValue, IsContainerNode()); |
| 1196 } | |
| 1197 } | 1180 } |
| 1181 |
| 1198 void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, | 1182 void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, |
| 1199 FX_BOOL bSetting, | 1183 FX_BOOL bSetting, |
| 1200 XFA_ATTRIBUTE eAttribute) { | 1184 XFA_ATTRIBUTE eAttribute) { |
| 1201 if (bSetting) { | 1185 if (bSetting) { |
| 1202 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 1186 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 1203 } else { | 1187 } else { |
| 1204 if (GetClassID() == XFA_ELEMENT_Subform) { | 1188 if (GetClassID() == XFA_ELEMENT_Subform) { |
| 1205 FXJSE_Value_SetBoolean(pValue, FALSE); | 1189 FXJSE_Value_SetBoolean(pValue, FALSE); |
| 1206 return; | 1190 return; |
| 1207 } | 1191 } |
| 1208 CFX_WideString strValue; | 1192 CFX_WideString strValue; |
| 1209 FXJSE_Value_SetBoolean(pValue, !TryContent(strValue) || strValue.IsEmpty()); | 1193 FXJSE_Value_SetBoolean(pValue, !TryContent(strValue) || strValue.IsEmpty()); |
| 1210 } | 1194 } |
| 1211 } | 1195 } |
| 1196 |
| 1212 void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, | 1197 void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, |
| 1213 FX_BOOL bSetting, | 1198 FX_BOOL bSetting, |
| 1214 XFA_ATTRIBUTE eAttribute) { | 1199 XFA_ATTRIBUTE eAttribute) { |
| 1215 if (bSetting) { | 1200 if (bSetting) { |
| 1216 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); | 1201 ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| 1217 } else { | 1202 } else { |
| 1218 CXFA_NodeArray properts; | 1203 CXFA_NodeArray properts; |
| 1219 int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty); | 1204 int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty); |
| 1220 if (iSize > 0) { | 1205 if (iSize > 0) { |
| 1221 FXJSE_Value_Set( | 1206 FXJSE_Value_Set( |
| 1222 pValue, | 1207 pValue, |
| 1223 m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0])); | 1208 m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0])); |
| 1224 } | 1209 } |
| 1225 } | 1210 } |
| 1226 } | 1211 } |
| 1212 |
| 1227 void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} | 1213 void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} |
| 1228 void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { | 1214 void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { |
| 1229 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); | 1215 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); |
| 1230 FXJSE_Value_SetObject(pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, | 1216 FXJSE_Value_SetObject(pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, |
| 1231 m_pDocument->GetScriptContext()->GetJseNormalClass()); | 1217 m_pDocument->GetScriptContext()->GetJseNormalClass()); |
| 1232 } | 1218 } |
| 1233 void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { | 1219 void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { |
| 1234 } | 1220 } |
| 1235 void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { | 1221 void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { |
| 1236 Script_Template_CreateNode(pArguments); | 1222 Script_Template_CreateNode(pArguments); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 CXFA_Node* pProtoRoot = | 1452 CXFA_Node* pProtoRoot = |
| 1467 pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Subform) | 1453 pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Subform) |
| 1468 ->GetFirstChildByClass(XFA_ELEMENT_Proto); | 1454 ->GetFirstChildByClass(XFA_ELEMENT_Proto); |
| 1469 if (!wsUseVal.IsEmpty()) { | 1455 if (!wsUseVal.IsEmpty()) { |
| 1470 if (wsUseVal[0] == '#') { | 1456 if (wsUseVal[0] == '#') { |
| 1471 wsID = CFX_WideString(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1); | 1457 wsID = CFX_WideString(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1); |
| 1472 } else { | 1458 } else { |
| 1473 wsSOM = wsUseVal; | 1459 wsSOM = wsUseVal; |
| 1474 } | 1460 } |
| 1475 } | 1461 } |
| 1476 CXFA_Node* pProtoNode = NULL; | 1462 CXFA_Node* pProtoNode = nullptr; |
| 1477 if (!wsSOM.IsEmpty()) { | 1463 if (!wsSOM.IsEmpty()) { |
| 1478 uint32_t dwFlag = XFA_RESOLVENODE_Children | | 1464 uint32_t dwFlag = XFA_RESOLVENODE_Children | |
| 1479 XFA_RESOLVENODE_Attributes | | 1465 XFA_RESOLVENODE_Attributes | |
| 1480 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | | 1466 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | |
| 1481 XFA_RESOLVENODE_Siblings; | 1467 XFA_RESOLVENODE_Siblings; |
| 1482 XFA_RESOLVENODE_RS resoveNodeRS; | 1468 XFA_RESOLVENODE_RS resoveNodeRS; |
| 1483 int32_t iRet = m_pDocument->GetScriptContext()->ResolveObjects( | 1469 int32_t iRet = m_pDocument->GetScriptContext()->ResolveObjects( |
| 1484 pProtoRoot, wsSOM.AsStringC(), resoveNodeRS, dwFlag); | 1470 pProtoRoot, wsSOM.AsStringC(), resoveNodeRS, dwFlag); |
| 1485 if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { | 1471 if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { |
| 1486 pProtoNode = resoveNodeRS.nodes[0]->AsNode(); | 1472 pProtoNode = resoveNodeRS.nodes[0]->AsNode(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 Script_Boolean_Value(pValue, bSetting, eAttribute); | 1630 Script_Boolean_Value(pValue, bSetting, eAttribute); |
| 1645 return; | 1631 return; |
| 1646 } | 1632 } |
| 1647 if (bSetting) { | 1633 if (bSetting) { |
| 1648 CFX_ByteString newValue; | 1634 CFX_ByteString newValue; |
| 1649 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) { | 1635 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) { |
| 1650 FXJSE_Value_ToUTF8String(pValue, newValue); | 1636 FXJSE_Value_ToUTF8String(pValue, newValue); |
| 1651 } | 1637 } |
| 1652 CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC()); | 1638 CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC()); |
| 1653 CFX_WideString wsFormatValue(wsNewValue); | 1639 CFX_WideString wsFormatValue(wsNewValue); |
| 1654 CXFA_WidgetData* pContainerWidgetData = NULL; | 1640 CXFA_WidgetData* pContainerWidgetData = nullptr; |
| 1655 if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 1641 if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
| 1656 CXFA_NodeArray formNodes; | 1642 CXFA_NodeArray formNodes; |
| 1657 GetBindItems(formNodes); | 1643 GetBindItems(formNodes); |
| 1658 CFX_WideString wsPicture; | 1644 CFX_WideString wsPicture; |
| 1659 for (int32_t i = 0; i < formNodes.GetSize(); i++) { | 1645 for (int32_t i = 0; i < formNodes.GetSize(); i++) { |
| 1660 CXFA_Node* pFormNode = formNodes.GetAt(i); | 1646 CXFA_Node* pFormNode = formNodes.GetAt(i); |
| 1661 if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { | 1647 if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { |
| 1662 continue; | 1648 continue; |
| 1663 } | 1649 } |
| 1664 pContainerWidgetData = pFormNode->GetContainerWidgetData(); | 1650 pContainerWidgetData = pFormNode->GetContainerWidgetData(); |
| 1665 if (pContainerWidgetData) { | 1651 if (pContainerWidgetData) { |
| 1666 pContainerWidgetData->GetPictureContent(wsPicture, | 1652 pContainerWidgetData->GetPictureContent(wsPicture, |
| 1667 XFA_VALUEPICTURE_DataBind); | 1653 XFA_VALUEPICTURE_DataBind); |
| 1668 } | 1654 } |
| 1669 if (!wsPicture.IsEmpty()) { | 1655 if (!wsPicture.IsEmpty()) { |
| 1670 break; | 1656 break; |
| 1671 } | 1657 } |
| 1672 pContainerWidgetData = NULL; | 1658 pContainerWidgetData = nullptr; |
| 1673 } | 1659 } |
| 1674 } else if (GetPacketID() == XFA_XDPPACKET_Form) { | 1660 } else if (GetPacketID() == XFA_XDPPACKET_Form) { |
| 1675 pContainerWidgetData = GetContainerWidgetData(); | 1661 pContainerWidgetData = GetContainerWidgetData(); |
| 1676 } | 1662 } |
| 1677 if (pContainerWidgetData) { | 1663 if (pContainerWidgetData) { |
| 1678 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); | 1664 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); |
| 1679 } | 1665 } |
| 1680 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); | 1666 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); |
| 1681 } else { | 1667 } else { |
| 1682 CFX_WideString content = GetScriptContent(TRUE); | 1668 CFX_WideString content = GetScriptContent(TRUE); |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 } | 2479 } |
| 2494 if ((eCurType != XFA_ELEMENT_Subform) && | 2480 if ((eCurType != XFA_ELEMENT_Subform) && |
| 2495 (eCurType != XFA_ELEMENT_SubformSet)) { | 2481 (eCurType != XFA_ELEMENT_SubformSet)) { |
| 2496 continue; | 2482 continue; |
| 2497 } | 2483 } |
| 2498 if (iCount == 0) { | 2484 if (iCount == 0) { |
| 2499 CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); | 2485 CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); |
| 2500 CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); | 2486 CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); |
| 2501 if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || | 2487 if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || |
| 2502 wsInstName.Mid(1) != wsName) { | 2488 wsInstName.Mid(1) != wsName) { |
| 2503 return NULL; | 2489 return nullptr; |
| 2504 } | 2490 } |
| 2505 dwNameHash = pNode->GetNameHash(); | 2491 dwNameHash = pNode->GetNameHash(); |
| 2506 } | 2492 } |
| 2507 if (dwNameHash != pNode->GetNameHash()) { | 2493 if (dwNameHash != pNode->GetNameHash()) { |
| 2508 break; | 2494 break; |
| 2509 } | 2495 } |
| 2510 iCount++; | 2496 iCount++; |
| 2511 if (iCount > iIndex) { | 2497 if (iCount > iIndex) { |
| 2512 return pNode; | 2498 return pNode; |
| 2513 } | 2499 } |
| 2514 } | 2500 } |
| 2515 return NULL; | 2501 return nullptr; |
| 2516 } | 2502 } |
| 2517 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, | 2503 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, |
| 2518 FX_BOOL bSetting, | 2504 FX_BOOL bSetting, |
| 2519 XFA_ATTRIBUTE eAttribute) { | 2505 XFA_ATTRIBUTE eAttribute) { |
| 2520 if (bSetting) { | 2506 if (bSetting) { |
| 2521 int32_t iTo = FXJSE_Value_ToInteger(pValue); | 2507 int32_t iTo = FXJSE_Value_ToInteger(pValue); |
| 2522 int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); | 2508 int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); |
| 2523 CXFA_Node* pManagerNode = NULL; | 2509 CXFA_Node* pManagerNode = nullptr; |
| 2524 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2510 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
| 2525 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2511 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
| 2526 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { | 2512 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { |
| 2527 pManagerNode = pNode; | 2513 pManagerNode = pNode; |
| 2528 break; | 2514 break; |
| 2529 } | 2515 } |
| 2530 } | 2516 } |
| 2531 if (pManagerNode) { | 2517 if (pManagerNode) { |
| 2532 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); | 2518 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); |
| 2533 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2519 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2547 } | 2533 } |
| 2548 } else { | 2534 } else { |
| 2549 FXJSE_Value_SetInteger(pValue, Subform_and_SubformSet_InstanceIndex()); | 2535 FXJSE_Value_SetInteger(pValue, Subform_and_SubformSet_InstanceIndex()); |
| 2550 } | 2536 } |
| 2551 } | 2537 } |
| 2552 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, | 2538 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, |
| 2553 FX_BOOL bSetting, | 2539 FX_BOOL bSetting, |
| 2554 XFA_ATTRIBUTE eAttribute) { | 2540 XFA_ATTRIBUTE eAttribute) { |
| 2555 if (!bSetting) { | 2541 if (!bSetting) { |
| 2556 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); | 2542 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); |
| 2557 CXFA_Node* pInstanceMgr = NULL; | 2543 CXFA_Node* pInstanceMgr = nullptr; |
| 2558 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2544 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
| 2559 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2545 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
| 2560 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { | 2546 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { |
| 2561 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); | 2547 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); |
| 2562 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && | 2548 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && |
| 2563 wsInstMgrName.Mid(1) == wsName) { | 2549 wsInstMgrName.Mid(1) == wsName) { |
| 2564 pInstanceMgr = pNode; | 2550 pInstanceMgr = pNode; |
| 2565 } | 2551 } |
| 2566 break; | 2552 break; |
| 2567 } | 2553 } |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3046 CXFA_Node* pDataNode = pFormNode->GetBindData(); | 3032 CXFA_Node* pDataNode = pFormNode->GetBindData(); |
| 3047 if (!pDataNode) { | 3033 if (!pDataNode) { |
| 3048 continue; | 3034 continue; |
| 3049 } | 3035 } |
| 3050 if (pDataNode->RemoveBindItem(pFormNode) == 0) { | 3036 if (pDataNode->RemoveBindItem(pFormNode) == 0) { |
| 3051 if (CXFA_Node* pDataParent = | 3037 if (CXFA_Node* pDataParent = |
| 3052 pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) { | 3038 pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) { |
| 3053 pDataParent->RemoveChild(pDataNode); | 3039 pDataParent->RemoveChild(pDataNode); |
| 3054 } | 3040 } |
| 3055 } | 3041 } |
| 3056 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 3042 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); |
| 3057 } | 3043 } |
| 3058 } | 3044 } |
| 3059 static CXFA_Node* XFA_ScriptInstanceManager_CreateInstance( | 3045 static CXFA_Node* XFA_ScriptInstanceManager_CreateInstance( |
| 3060 CXFA_Node* pInstMgrNode, | 3046 CXFA_Node* pInstMgrNode, |
| 3061 FX_BOOL bDataMerge) { | 3047 FX_BOOL bDataMerge) { |
| 3062 CXFA_Document* pDocument = pInstMgrNode->GetDocument(); | 3048 CXFA_Document* pDocument = pInstMgrNode->GetDocument(); |
| 3063 CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode(); | 3049 CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode(); |
| 3064 CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent); | 3050 CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 3065 CXFA_Node* pDataScope = NULL; | 3051 CXFA_Node* pDataScope = nullptr; |
| 3066 for (CXFA_Node* pRootBoundNode = pFormParent; | 3052 for (CXFA_Node* pRootBoundNode = pFormParent; |
| 3067 pRootBoundNode && | 3053 pRootBoundNode && |
| 3068 pRootBoundNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode; | 3054 pRootBoundNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode; |
| 3069 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { | 3055 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { |
| 3070 pDataScope = pRootBoundNode->GetBindData(); | 3056 pDataScope = pRootBoundNode->GetBindData(); |
| 3071 if (pDataScope) { | 3057 if (pDataScope) { |
| 3072 break; | 3058 break; |
| 3073 } | 3059 } |
| 3074 } | 3060 } |
| 3075 if (!pDataScope) { | 3061 if (!pDataScope) { |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3712 XFA_KEYTYPE_Element); | 3698 XFA_KEYTYPE_Element); |
| 3713 } | 3699 } |
| 3714 FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { | 3700 FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { |
| 3715 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3701 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 3716 return HasMapModuleKey(pKey, bCanInherit); | 3702 return HasMapModuleKey(pKey, bCanInherit); |
| 3717 } | 3703 } |
| 3718 FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, | 3704 FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, |
| 3719 const CFX_WideStringC& wsValue, | 3705 const CFX_WideStringC& wsValue, |
| 3720 bool bNotify) { | 3706 bool bNotify) { |
| 3721 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); | 3707 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); |
| 3722 if (pAttr == NULL) { | 3708 if (!pAttr) |
| 3723 return FALSE; | 3709 return FALSE; |
| 3724 } | 3710 |
| 3725 XFA_ATTRIBUTETYPE eType = pAttr->eType; | 3711 XFA_ATTRIBUTETYPE eType = pAttr->eType; |
| 3726 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { | 3712 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { |
| 3727 const XFA_NOTSUREATTRIBUTE* pNotsure = | 3713 const XFA_NOTSUREATTRIBUTE* pNotsure = |
| 3728 XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); | 3714 XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); |
| 3729 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; | 3715 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; |
| 3730 } | 3716 } |
| 3731 switch (eType) { | 3717 switch (eType) { |
| 3732 case XFA_ATTRIBUTETYPE_Enum: { | 3718 case XFA_ATTRIBUTETYPE_Enum: { |
| 3733 const XFA_ATTRIBUTEENUMINFO* pEnum = XFA_GetAttributeEnumByName(wsValue); | 3719 const XFA_ATTRIBUTEENUMINFO* pEnum = XFA_GetAttributeEnumByName(wsValue); |
| 3734 return SetEnum(pAttr->eName, | 3720 return SetEnum(pAttr->eName, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3749 return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify); | 3735 return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify); |
| 3750 default: | 3736 default: |
| 3751 break; | 3737 break; |
| 3752 } | 3738 } |
| 3753 return FALSE; | 3739 return FALSE; |
| 3754 } | 3740 } |
| 3755 FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr, | 3741 FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr, |
| 3756 CFX_WideString& wsValue, | 3742 CFX_WideString& wsValue, |
| 3757 FX_BOOL bUseDefault) { | 3743 FX_BOOL bUseDefault) { |
| 3758 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); | 3744 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); |
| 3759 if (pAttr == NULL) { | 3745 if (!pAttr) { |
| 3760 return FALSE; | 3746 return FALSE; |
| 3761 } | 3747 } |
| 3762 XFA_ATTRIBUTETYPE eType = pAttr->eType; | 3748 XFA_ATTRIBUTETYPE eType = pAttr->eType; |
| 3763 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { | 3749 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { |
| 3764 const XFA_NOTSUREATTRIBUTE* pNotsure = | 3750 const XFA_NOTSUREATTRIBUTE* pNotsure = |
| 3765 XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); | 3751 XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); |
| 3766 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; | 3752 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; |
| 3767 } | 3753 } |
| 3768 switch (eType) { | 3754 switch (eType) { |
| 3769 case XFA_ATTRIBUTETYPE_Enum: { | 3755 case XFA_ATTRIBUTETYPE_Enum: { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3837 return TRUE; | 3823 return TRUE; |
| 3838 } | 3824 } |
| 3839 FX_BOOL CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) { | 3825 FX_BOOL CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) { |
| 3840 void* pKey = XFA_GetMapKey_Custom(wsAttr); | 3826 void* pKey = XFA_GetMapKey_Custom(wsAttr); |
| 3841 RemoveMapModuleKey(pKey); | 3827 RemoveMapModuleKey(pKey); |
| 3842 return TRUE; | 3828 return TRUE; |
| 3843 } | 3829 } |
| 3844 FX_BOOL CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr, | 3830 FX_BOOL CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr, |
| 3845 FX_BOOL& bValue, | 3831 FX_BOOL& bValue, |
| 3846 FX_BOOL bUseDefault) { | 3832 FX_BOOL bUseDefault) { |
| 3847 void* pValue = NULL; | 3833 void* pValue = nullptr; |
| 3848 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue)) { | 3834 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue)) |
| 3849 return FALSE; | 3835 return FALSE; |
| 3850 } | |
| 3851 bValue = (FX_BOOL)(uintptr_t)pValue; | 3836 bValue = (FX_BOOL)(uintptr_t)pValue; |
| 3852 return TRUE; | 3837 return TRUE; |
| 3853 } | 3838 } |
| 3854 FX_BOOL CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr, | 3839 FX_BOOL CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr, |
| 3855 int32_t& iValue, | 3840 int32_t& iValue, |
| 3856 FX_BOOL bUseDefault) { | 3841 FX_BOOL bUseDefault) { |
| 3857 void* pValue = NULL; | 3842 void* pValue = nullptr; |
| 3858 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue)) { | 3843 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue)) |
| 3859 return FALSE; | 3844 return FALSE; |
| 3860 } | |
| 3861 iValue = (int32_t)(uintptr_t)pValue; | 3845 iValue = (int32_t)(uintptr_t)pValue; |
| 3862 return TRUE; | 3846 return TRUE; |
| 3863 } | 3847 } |
| 3864 FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, | 3848 FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, |
| 3865 XFA_ATTRIBUTEENUM& eValue, | 3849 XFA_ATTRIBUTEENUM& eValue, |
| 3866 FX_BOOL bUseDefault) { | 3850 FX_BOOL bUseDefault) { |
| 3867 void* pValue = NULL; | 3851 void* pValue = nullptr; |
| 3868 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) { | 3852 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) |
| 3869 return FALSE; | 3853 return FALSE; |
| 3870 } | |
| 3871 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; | 3854 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; |
| 3872 return TRUE; | 3855 return TRUE; |
| 3873 } | 3856 } |
| 3874 | 3857 |
| 3875 FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, | 3858 FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, |
| 3876 CXFA_Measurement mValue, | 3859 CXFA_Measurement mValue, |
| 3877 bool bNotify) { | 3860 bool bNotify) { |
| 3878 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 3861 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 3879 OnChanging(eAttr, bNotify); | 3862 OnChanging(eAttr, bNotify); |
| 3880 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); | 3863 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4041 } else { | 4024 } else { |
| 4042 CFX_WideStringC wsValueC; | 4025 CFX_WideStringC wsValueC; |
| 4043 if (GetMapModuleString(pKey, wsValueC)) { | 4026 if (GetMapModuleString(pKey, wsValueC)) { |
| 4044 wsValue = wsValueC; | 4027 wsValue = wsValueC; |
| 4045 return TRUE; | 4028 return TRUE; |
| 4046 } | 4029 } |
| 4047 } | 4030 } |
| 4048 if (!bUseDefault) { | 4031 if (!bUseDefault) { |
| 4049 return FALSE; | 4032 return FALSE; |
| 4050 } | 4033 } |
| 4051 void* pValue = NULL; | 4034 void* pValue = nullptr; |
| 4052 if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, | 4035 if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, |
| 4053 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { | 4036 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { |
| 4054 wsValue = (const FX_WCHAR*)pValue; | 4037 wsValue = (const FX_WCHAR*)pValue; |
| 4055 return TRUE; | 4038 return TRUE; |
| 4056 } | 4039 } |
| 4057 return FALSE; | 4040 return FALSE; |
| 4058 } | 4041 } |
| 4059 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, | 4042 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, |
| 4060 CFX_WideStringC& wsValue, | 4043 CFX_WideStringC& wsValue, |
| 4061 FX_BOOL bUseDefault, | 4044 FX_BOOL bUseDefault, |
| 4062 FX_BOOL bProto) { | 4045 FX_BOOL bProto) { |
| 4063 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4046 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 4064 if (eAttr == XFA_ATTRIBUTE_Value) { | 4047 if (eAttr == XFA_ATTRIBUTE_Value) { |
| 4065 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); | 4048 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); |
| 4066 if (pStr) { | 4049 if (pStr) { |
| 4067 wsValue = pStr->AsStringC(); | 4050 wsValue = pStr->AsStringC(); |
| 4068 return TRUE; | 4051 return TRUE; |
| 4069 } | 4052 } |
| 4070 } else { | 4053 } else { |
| 4071 if (GetMapModuleString(pKey, wsValue)) { | 4054 if (GetMapModuleString(pKey, wsValue)) { |
| 4072 return TRUE; | 4055 return TRUE; |
| 4073 } | 4056 } |
| 4074 } | 4057 } |
| 4075 if (!bUseDefault) { | 4058 if (!bUseDefault) { |
| 4076 return FALSE; | 4059 return FALSE; |
| 4077 } | 4060 } |
| 4078 void* pValue = NULL; | 4061 void* pValue = nullptr; |
| 4079 if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, | 4062 if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, |
| 4080 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { | 4063 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { |
| 4081 wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue; | 4064 wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue; |
| 4082 return TRUE; | 4065 return TRUE; |
| 4083 } | 4066 } |
| 4084 return FALSE; | 4067 return FALSE; |
| 4085 } | 4068 } |
| 4086 FX_BOOL CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr, | 4069 FX_BOOL CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr, |
| 4087 void* pData, | 4070 void* pData, |
| 4088 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { | 4071 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { |
| 4089 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4072 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 4090 return SetUserData(pKey, pData, pCallbackInfo); | 4073 return SetUserData(pKey, pData, pCallbackInfo); |
| 4091 } | 4074 } |
| 4092 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { | 4075 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { |
| 4093 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4076 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 4094 pData = GetUserData(pKey); | 4077 pData = GetUserData(pKey); |
| 4095 return pData != NULL; | 4078 return pData != nullptr; |
| 4096 } | 4079 } |
| 4097 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, | 4080 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, |
| 4098 XFA_ATTRIBUTETYPE eType, | 4081 XFA_ATTRIBUTETYPE eType, |
| 4099 void* pValue, | 4082 void* pValue, |
| 4100 bool bNotify) { | 4083 bool bNotify) { |
| 4101 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); | 4084 void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| 4102 OnChanging(eAttr, bNotify); | 4085 OnChanging(eAttr, bNotify); |
| 4103 SetMapModuleValue(pKey, pValue); | 4086 SetMapModuleValue(pKey, pValue); |
| 4104 OnChanged(eAttr, bNotify, FALSE); | 4087 OnChanged(eAttr, bNotify, FALSE); |
| 4105 if (IsNeedSavingXMLNode()) { | 4088 if (IsNeedSavingXMLNode()) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4138 return TRUE; | 4121 return TRUE; |
| 4139 } | 4122 } |
| 4140 if (!bUseDefault) { | 4123 if (!bUseDefault) { |
| 4141 return FALSE; | 4124 return FALSE; |
| 4142 } | 4125 } |
| 4143 return XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, eType, | 4126 return XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, eType, |
| 4144 m_ePacket); | 4127 m_ePacket); |
| 4145 } | 4128 } |
| 4146 static void XFA_DefaultFreeData(void* pData) {} | 4129 static void XFA_DefaultFreeData(void* pData) {} |
| 4147 static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = { | 4130 static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = { |
| 4148 XFA_DefaultFreeData, NULL}; | 4131 XFA_DefaultFreeData, nullptr}; |
| 4149 FX_BOOL CXFA_Node::SetUserData(void* pKey, | 4132 FX_BOOL CXFA_Node::SetUserData(void* pKey, |
| 4150 void* pData, | 4133 void* pData, |
| 4151 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { | 4134 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { |
| 4152 SetMapModuleBuffer(pKey, &pData, sizeof(void*), | 4135 SetMapModuleBuffer(pKey, &pData, sizeof(void*), |
| 4153 pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); | 4136 pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); |
| 4154 return TRUE; | 4137 return TRUE; |
| 4155 } | 4138 } |
| 4156 FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { | 4139 FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { |
| 4157 int32_t iBytes = 0; | 4140 int32_t iBytes = 0; |
| 4158 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { | 4141 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { |
| 4159 return FALSE; | 4142 return FALSE; |
| 4160 } | 4143 } |
| 4161 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); | 4144 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); |
| 4162 } | 4145 } |
| 4163 FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, | 4146 FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, |
| 4164 const CFX_WideString& wsXMLValue, | 4147 const CFX_WideString& wsXMLValue, |
| 4165 bool bNotify, | 4148 bool bNotify, |
| 4166 FX_BOOL bScriptModify, | 4149 FX_BOOL bScriptModify, |
| 4167 FX_BOOL bSyncData) { | 4150 FX_BOOL bSyncData) { |
| 4168 CXFA_Node* pNode = NULL; | 4151 CXFA_Node* pNode = nullptr; |
| 4169 CXFA_Node* pBindNode = NULL; | 4152 CXFA_Node* pBindNode = nullptr; |
| 4170 switch (GetObjectType()) { | 4153 switch (GetObjectType()) { |
| 4171 case XFA_OBJECTTYPE_ContainerNode: { | 4154 case XFA_OBJECTTYPE_ContainerNode: { |
| 4172 if (XFA_FieldIsMultiListBox(this)) { | 4155 if (XFA_FieldIsMultiListBox(this)) { |
| 4173 CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value); | 4156 CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value); |
| 4174 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); | 4157 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 4175 ASSERT(pChildValue); | 4158 ASSERT(pChildValue); |
| 4176 pChildValue->SetCData(XFA_ATTRIBUTE_ContentType, L"text/xml"); | 4159 pChildValue->SetCData(XFA_ATTRIBUTE_ContentType, L"text/xml"); |
| 4177 pChildValue->SetScriptContent(wsContent, wsContent, bNotify, | 4160 pChildValue->SetScriptContent(wsContent, wsContent, bNotify, |
| 4178 bScriptModify, FALSE); | 4161 bScriptModify, FALSE); |
| 4179 CXFA_Node* pBind = GetBindData(); | 4162 CXFA_Node* pBind = GetBindData(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4202 while (CXFA_Node* pChildNode = | 4185 while (CXFA_Node* pChildNode = |
| 4203 pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { | 4186 pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { |
| 4204 pBind->RemoveChild(pChildNode); | 4187 pBind->RemoveChild(pChildNode); |
| 4205 } | 4188 } |
| 4206 } else { | 4189 } else { |
| 4207 CXFA_NodeArray valueNodes; | 4190 CXFA_NodeArray valueNodes; |
| 4208 int32_t iDatas = pBind->GetNodeList( | 4191 int32_t iDatas = pBind->GetNodeList( |
| 4209 valueNodes, XFA_NODEFILTER_Children, XFA_ELEMENT_DataValue); | 4192 valueNodes, XFA_NODEFILTER_Children, XFA_ELEMENT_DataValue); |
| 4210 if (iDatas < iSize) { | 4193 if (iDatas < iSize) { |
| 4211 int32_t iAddNodes = iSize - iDatas; | 4194 int32_t iAddNodes = iSize - iDatas; |
| 4212 CXFA_Node* pValueNodes = NULL; | 4195 CXFA_Node* pValueNodes = nullptr; |
| 4213 while (iAddNodes-- > 0) { | 4196 while (iAddNodes-- > 0) { |
| 4214 pValueNodes = | 4197 pValueNodes = |
| 4215 pBind->CreateSamePacketNode(XFA_ELEMENT_DataValue); | 4198 pBind->CreateSamePacketNode(XFA_ELEMENT_DataValue); |
| 4216 pValueNodes->SetCData(XFA_ATTRIBUTE_Name, L"value"); | 4199 pValueNodes->SetCData(XFA_ATTRIBUTE_Name, L"value"); |
| 4217 pValueNodes->CreateXMLMappingNode(); | 4200 pValueNodes->CreateXMLMappingNode(); |
| 4218 pBind->InsertChild(pValueNodes); | 4201 pBind->InsertChild(pValueNodes); |
| 4219 } | 4202 } |
| 4220 pValueNodes = NULL; | 4203 pValueNodes = nullptr; |
| 4221 } else if (iDatas > iSize) { | 4204 } else if (iDatas > iSize) { |
| 4222 int32_t iDelNodes = iDatas - iSize; | 4205 int32_t iDelNodes = iDatas - iSize; |
| 4223 while (iDelNodes-- > 0) { | 4206 while (iDelNodes-- > 0) { |
| 4224 pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild)); | 4207 pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild)); |
| 4225 } | 4208 } |
| 4226 } | 4209 } |
| 4227 int32_t i = 0; | 4210 int32_t i = 0; |
| 4228 for (CXFA_Node* pValueNode = | 4211 for (CXFA_Node* pValueNode = |
| 4229 pBind->GetNodeItem(XFA_NODEITEM_FirstChild); | 4212 pBind->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 4230 pValueNode; pValueNode = pValueNode->GetNodeItem( | 4213 pValueNode; pValueNode = pValueNode->GetNodeItem( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4262 CXFA_NodeArray nodeArray; | 4245 CXFA_NodeArray nodeArray; |
| 4263 pBindNode->GetBindItems(nodeArray); | 4246 pBindNode->GetBindItems(nodeArray); |
| 4264 for (int32_t i = 0; i < nodeArray.GetSize(); i++) { | 4247 for (int32_t i = 0; i < nodeArray.GetSize(); i++) { |
| 4265 CXFA_Node* pNode = nodeArray[i]; | 4248 CXFA_Node* pNode = nodeArray[i]; |
| 4266 if (pNode == this) { | 4249 if (pNode == this) { |
| 4267 continue; | 4250 continue; |
| 4268 } | 4251 } |
| 4269 pNode->SetScriptContent(wsContent, wsContent, bNotify, true, FALSE); | 4252 pNode->SetScriptContent(wsContent, wsContent, bNotify, true, FALSE); |
| 4270 } | 4253 } |
| 4271 } | 4254 } |
| 4272 pBindNode = NULL; | 4255 pBindNode = nullptr; |
| 4273 break; | 4256 break; |
| 4274 } | 4257 } |
| 4275 case XFA_OBJECTTYPE_ContentNode: { | 4258 case XFA_OBJECTTYPE_ContentNode: { |
| 4276 CFX_WideString wsContentType; | 4259 CFX_WideString wsContentType; |
| 4277 if (GetClassID() == XFA_ELEMENT_ExData) { | 4260 if (GetClassID() == XFA_ELEMENT_ExData) { |
| 4278 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); | 4261 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); |
| 4279 if (wsContentType == FX_WSTRC(L"text/html")) { | 4262 if (wsContentType == FX_WSTRC(L"text/html")) { |
| 4280 wsContentType = FX_WSTRC(L""); | 4263 wsContentType = FX_WSTRC(L""); |
| 4281 SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType.AsStringC()); | 4264 SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType.AsStringC()); |
| 4282 } | 4265 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4347 CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { | 4330 CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { |
| 4348 CFX_WideString wsContent; | 4331 CFX_WideString wsContent; |
| 4349 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); | 4332 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); |
| 4350 } | 4333 } |
| 4351 CFX_WideString CXFA_Node::GetContent() { | 4334 CFX_WideString CXFA_Node::GetContent() { |
| 4352 return GetScriptContent(); | 4335 return GetScriptContent(); |
| 4353 } | 4336 } |
| 4354 FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, | 4337 FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, |
| 4355 FX_BOOL bScriptModify, | 4338 FX_BOOL bScriptModify, |
| 4356 FX_BOOL bProto) { | 4339 FX_BOOL bProto) { |
| 4357 CXFA_Node* pNode = NULL; | 4340 CXFA_Node* pNode = nullptr; |
| 4358 switch (GetObjectType()) { | 4341 switch (GetObjectType()) { |
| 4359 case XFA_OBJECTTYPE_ContainerNode: | 4342 case XFA_OBJECTTYPE_ContainerNode: |
| 4360 if (GetClassID() == XFA_ELEMENT_ExclGroup) { | 4343 if (GetClassID() == XFA_ELEMENT_ExclGroup) { |
| 4361 pNode = this; | 4344 pNode = this; |
| 4362 } else { | 4345 } else { |
| 4363 CXFA_Node* pValue = GetChild(0, XFA_ELEMENT_Value); | 4346 CXFA_Node* pValue = GetChild(0, XFA_ELEMENT_Value); |
| 4364 if (!pValue) { | 4347 if (!pValue) { |
| 4365 return FALSE; | 4348 return FALSE; |
| 4366 } | 4349 } |
| 4367 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); | 4350 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4468 return pModelNode->TryNamespace(wsNamespace); | 4451 return pModelNode->TryNamespace(wsNamespace); |
| 4469 } | 4452 } |
| 4470 } | 4453 } |
| 4471 CXFA_Node* CXFA_Node::GetProperty(int32_t index, | 4454 CXFA_Node* CXFA_Node::GetProperty(int32_t index, |
| 4472 XFA_ELEMENT eProperty, | 4455 XFA_ELEMENT eProperty, |
| 4473 FX_BOOL bCreateProperty) { | 4456 FX_BOOL bCreateProperty) { |
| 4474 XFA_ELEMENT eElement = GetClassID(); | 4457 XFA_ELEMENT eElement = GetClassID(); |
| 4475 uint32_t dwPacket = GetPacketID(); | 4458 uint32_t dwPacket = GetPacketID(); |
| 4476 const XFA_PROPERTY* pProperty = | 4459 const XFA_PROPERTY* pProperty = |
| 4477 XFA_GetPropertyOfElement(eElement, eProperty, dwPacket); | 4460 XFA_GetPropertyOfElement(eElement, eProperty, dwPacket); |
| 4478 if (pProperty == NULL || index >= pProperty->uOccur) { | 4461 if (!pProperty || index >= pProperty->uOccur) |
| 4479 return NULL; | 4462 return nullptr; |
| 4480 } | 4463 |
| 4481 CXFA_Node* pNode = m_pChild; | 4464 CXFA_Node* pNode = m_pChild; |
| 4482 int32_t iCount = 0; | 4465 int32_t iCount = 0; |
| 4483 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4466 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 4484 if (pNode->GetClassID() == eProperty) { | 4467 if (pNode->GetClassID() == eProperty) { |
| 4485 iCount++; | 4468 iCount++; |
| 4486 if (iCount > index) { | 4469 if (iCount > index) { |
| 4487 return pNode; | 4470 return pNode; |
| 4488 } | 4471 } |
| 4489 } | 4472 } |
| 4490 } | 4473 } |
| 4491 if (!bCreateProperty) { | 4474 if (!bCreateProperty) |
| 4492 return NULL; | 4475 return nullptr; |
| 4493 } | 4476 |
| 4494 if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) { | 4477 if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) { |
| 4495 pNode = m_pChild; | 4478 pNode = m_pChild; |
| 4496 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4479 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 4497 const XFA_PROPERTY* pExistProperty = | 4480 const XFA_PROPERTY* pExistProperty = |
| 4498 XFA_GetPropertyOfElement(eElement, pNode->GetClassID(), dwPacket); | 4481 XFA_GetPropertyOfElement(eElement, pNode->GetClassID(), dwPacket); |
| 4499 if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { | 4482 if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) |
| 4500 return NULL; | 4483 return nullptr; |
| 4501 } | |
| 4502 } | 4484 } |
| 4503 } | 4485 } |
| 4504 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); | 4486 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); |
| 4505 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket); | 4487 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket); |
| 4506 CXFA_Node* pNewNode = nullptr; | 4488 CXFA_Node* pNewNode = nullptr; |
| 4507 for (; iCount <= index; iCount++) { | 4489 for (; iCount <= index; iCount++) { |
| 4508 pNewNode = pFactory->CreateNode(pPacket, eProperty); | 4490 pNewNode = pFactory->CreateNode(pPacket, eProperty); |
| 4509 if (!pNewNode) { | 4491 if (!pNewNode) |
| 4510 return NULL; | 4492 return nullptr; |
| 4511 } | |
| 4512 InsertChild(pNewNode, nullptr); | 4493 InsertChild(pNewNode, nullptr); |
| 4513 pNewNode->SetFlag(XFA_NODEFLAG_Initialized, true); | 4494 pNewNode->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 4514 } | 4495 } |
| 4515 return pNewNode; | 4496 return pNewNode; |
| 4516 } | 4497 } |
| 4517 int32_t CXFA_Node::CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild) { | 4498 int32_t CXFA_Node::CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild) { |
| 4518 CXFA_Node* pNode = m_pChild; | 4499 CXFA_Node* pNode = m_pChild; |
| 4519 int32_t iCount = 0; | 4500 int32_t iCount = 0; |
| 4520 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4501 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 4521 if (pNode->GetClassID() == eElement || eElement == XFA_ELEMENT_UNKNOWN) { | 4502 if (pNode->GetClassID() == eElement || eElement == XFA_ELEMENT_UNKNOWN) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4545 if (pProperty) { | 4526 if (pProperty) { |
| 4546 continue; | 4527 continue; |
| 4547 } | 4528 } |
| 4548 } | 4529 } |
| 4549 iCount++; | 4530 iCount++; |
| 4550 if (iCount > index) { | 4531 if (iCount > index) { |
| 4551 return pNode; | 4532 return pNode; |
| 4552 } | 4533 } |
| 4553 } | 4534 } |
| 4554 } | 4535 } |
| 4555 return NULL; | 4536 return nullptr; |
| 4556 } | 4537 } |
| 4557 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { | 4538 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { |
| 4558 ASSERT(!pNode->m_pNext); | 4539 ASSERT(!pNode->m_pNext); |
| 4559 pNode->m_pParent = this; | 4540 pNode->m_pParent = this; |
| 4560 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); | 4541 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); |
| 4561 ASSERT(ret); | 4542 ASSERT(ret); |
| 4562 (void)ret; // Avoid unused variable warning. | 4543 (void)ret; // Avoid unused variable warning. |
| 4563 | 4544 |
| 4564 if (m_pChild == NULL || index == 0) { | 4545 if (!m_pChild || index == 0) { |
| 4565 if (index > 0) { | 4546 if (index > 0) { |
| 4566 return -1; | 4547 return -1; |
| 4567 } | 4548 } |
| 4568 pNode->m_pNext = m_pChild; | 4549 pNode->m_pNext = m_pChild; |
| 4569 m_pChild = pNode; | 4550 m_pChild = pNode; |
| 4570 index = 0; | 4551 index = 0; |
| 4571 } else if (index < 0) { | 4552 } else if (index < 0) { |
| 4572 m_pLastChild->m_pNext = pNode; | 4553 m_pLastChild->m_pNext = pNode; |
| 4573 } else { | 4554 } else { |
| 4574 CXFA_Node* pPrev = m_pChild; | 4555 CXFA_Node* pPrev = m_pChild; |
| 4575 int32_t iCount = 0; | 4556 int32_t iCount = 0; |
| 4576 while (++iCount != index && pPrev->m_pNext) { | 4557 while (++iCount != index && pPrev->m_pNext) { |
| 4577 pPrev = pPrev->m_pNext; | 4558 pPrev = pPrev->m_pNext; |
| 4578 } | 4559 } |
| 4579 if (index > 0 && index != iCount) { | 4560 if (index > 0 && index != iCount) { |
| 4580 return -1; | 4561 return -1; |
| 4581 } | 4562 } |
| 4582 pNode->m_pNext = pPrev->m_pNext; | 4563 pNode->m_pNext = pPrev->m_pNext; |
| 4583 pPrev->m_pNext = pNode; | 4564 pPrev->m_pNext = pNode; |
| 4584 index = iCount; | 4565 index = iCount; |
| 4585 } | 4566 } |
| 4586 if (pNode->m_pNext == NULL) { | 4567 if (!pNode->m_pNext) { |
| 4587 m_pLastChild = pNode; | 4568 m_pLastChild = pNode; |
| 4588 } | 4569 } |
| 4589 ASSERT(m_pLastChild); | 4570 ASSERT(m_pLastChild); |
| 4590 ASSERT(m_pLastChild->m_pNext == NULL); | 4571 ASSERT(!m_pLastChild->m_pNext); |
| 4591 pNode->ClearFlag(XFA_NODEFLAG_HasRemoved); | 4572 pNode->ClearFlag(XFA_NODEFLAG_HasRemoved); |
| 4592 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4573 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 4593 if (pNotify) | 4574 if (pNotify) |
| 4594 pNotify->OnChildAdded(this); | 4575 pNotify->OnChildAdded(this); |
| 4595 | 4576 |
| 4596 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4577 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
| 4597 ASSERT(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); | 4578 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); |
| 4598 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); | 4579 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); |
| 4599 pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode); | 4580 pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode); |
| 4600 } | 4581 } |
| 4601 return index; | 4582 return index; |
| 4602 } | 4583 } |
| 4603 | 4584 |
| 4604 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { | 4585 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { |
| 4605 if (!pNode || pNode->m_pParent || | 4586 if (!pNode || pNode->m_pParent || |
| 4606 (pBeforeNode && pBeforeNode->m_pParent != this)) { | 4587 (pBeforeNode && pBeforeNode->m_pParent != this)) { |
| 4607 ASSERT(false); | 4588 ASSERT(false); |
| 4608 return FALSE; | 4589 return FALSE; |
| 4609 } | 4590 } |
| 4610 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); | 4591 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); |
| 4611 ASSERT(ret); | 4592 ASSERT(ret); |
| 4612 (void)ret; // Avoid unused variable warning. | 4593 (void)ret; // Avoid unused variable warning. |
| 4613 | 4594 |
| 4614 int32_t nIndex = -1; | 4595 int32_t nIndex = -1; |
| 4615 pNode->m_pParent = this; | 4596 pNode->m_pParent = this; |
| 4616 if (m_pChild == NULL || pBeforeNode == m_pChild) { | 4597 if (!m_pChild || pBeforeNode == m_pChild) { |
| 4617 pNode->m_pNext = m_pChild; | 4598 pNode->m_pNext = m_pChild; |
| 4618 m_pChild = pNode; | 4599 m_pChild = pNode; |
| 4619 nIndex = 0; | 4600 nIndex = 0; |
| 4620 } else if (!pBeforeNode) { | 4601 } else if (!pBeforeNode) { |
| 4621 pNode->m_pNext = m_pLastChild->m_pNext; | 4602 pNode->m_pNext = m_pLastChild->m_pNext; |
| 4622 m_pLastChild->m_pNext = pNode; | 4603 m_pLastChild->m_pNext = pNode; |
| 4623 } else { | 4604 } else { |
| 4624 nIndex = 1; | 4605 nIndex = 1; |
| 4625 CXFA_Node* pPrev = m_pChild; | 4606 CXFA_Node* pPrev = m_pChild; |
| 4626 while (pPrev->m_pNext != pBeforeNode) { | 4607 while (pPrev->m_pNext != pBeforeNode) { |
| 4627 pPrev = pPrev->m_pNext; | 4608 pPrev = pPrev->m_pNext; |
| 4628 nIndex++; | 4609 nIndex++; |
| 4629 } | 4610 } |
| 4630 pNode->m_pNext = pPrev->m_pNext; | 4611 pNode->m_pNext = pPrev->m_pNext; |
| 4631 pPrev->m_pNext = pNode; | 4612 pPrev->m_pNext = pNode; |
| 4632 } | 4613 } |
| 4633 if (pNode->m_pNext == NULL) { | 4614 if (!pNode->m_pNext) { |
| 4634 m_pLastChild = pNode; | 4615 m_pLastChild = pNode; |
| 4635 } | 4616 } |
| 4636 ASSERT(m_pLastChild); | 4617 ASSERT(m_pLastChild); |
| 4637 ASSERT(m_pLastChild->m_pNext == NULL); | 4618 ASSERT(!m_pLastChild->m_pNext); |
| 4638 pNode->ClearFlag(XFA_NODEFLAG_HasRemoved); | 4619 pNode->ClearFlag(XFA_NODEFLAG_HasRemoved); |
| 4639 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 4620 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 4640 if (pNotify) | 4621 if (pNotify) |
| 4641 pNotify->OnChildAdded(this); | 4622 pNotify->OnChildAdded(this); |
| 4642 | 4623 |
| 4643 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4624 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
| 4644 ASSERT(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); | 4625 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); |
| 4645 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); | 4626 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); |
| 4646 pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode); | 4627 pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode); |
| 4647 } | 4628 } |
| 4648 return TRUE; | 4629 return TRUE; |
| 4649 } | 4630 } |
| 4650 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { | 4631 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { |
| 4651 if (!m_pParent) { | 4632 if (!m_pParent) { |
| 4652 return NULL; | 4633 return nullptr; |
| 4653 } | 4634 } |
| 4654 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; | 4635 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; |
| 4655 pSibling = pSibling->m_pNext) { | 4636 pSibling = pSibling->m_pNext) { |
| 4656 if (pSibling->m_pNext == this) { | 4637 if (pSibling->m_pNext == this) { |
| 4657 return pSibling; | 4638 return pSibling; |
| 4658 } | 4639 } |
| 4659 } | 4640 } |
| 4660 return NULL; | 4641 return nullptr; |
| 4661 } | 4642 } |
| 4662 FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { | 4643 FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { |
| 4663 if (pNode == NULL || pNode->m_pParent != this) { | 4644 if (!pNode || pNode->m_pParent != this) { |
| 4664 ASSERT(FALSE); | 4645 ASSERT(FALSE); |
| 4665 return FALSE; | 4646 return FALSE; |
| 4666 } | 4647 } |
| 4667 if (m_pChild == pNode) { | 4648 if (m_pChild == pNode) { |
| 4668 m_pChild = pNode->m_pNext; | 4649 m_pChild = pNode->m_pNext; |
| 4669 if (m_pLastChild == pNode) { | 4650 if (m_pLastChild == pNode) { |
| 4670 m_pLastChild = pNode->m_pNext; | 4651 m_pLastChild = pNode->m_pNext; |
| 4671 } | 4652 } |
| 4672 pNode->m_pNext = NULL; | 4653 pNode->m_pNext = nullptr; |
| 4673 pNode->m_pParent = NULL; | 4654 pNode->m_pParent = nullptr; |
| 4674 } else { | 4655 } else { |
| 4675 CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling(); | 4656 CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling(); |
| 4676 pPrev->m_pNext = pNode->m_pNext; | 4657 pPrev->m_pNext = pNode->m_pNext; |
| 4677 if (m_pLastChild == pNode) { | 4658 if (m_pLastChild == pNode) { |
| 4678 m_pLastChild = pNode->m_pNext ? pNode->m_pNext : pPrev; | 4659 m_pLastChild = pNode->m_pNext ? pNode->m_pNext : pPrev; |
| 4679 } | 4660 } |
| 4680 pNode->m_pNext = NULL; | 4661 pNode->m_pNext = nullptr; |
| 4681 pNode->m_pParent = NULL; | 4662 pNode->m_pParent = nullptr; |
| 4682 } | 4663 } |
| 4683 ASSERT(m_pLastChild == NULL || m_pLastChild->m_pNext == NULL); | 4664 ASSERT(!m_pLastChild || !m_pLastChild->m_pNext); |
| 4684 OnRemoved(bNotify); | 4665 OnRemoved(bNotify); |
| 4685 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, true); | 4666 pNode->SetFlag(XFA_NODEFLAG_HasRemoved, true); |
| 4686 m_pDocument->AddPurgeNode(pNode); | 4667 m_pDocument->AddPurgeNode(pNode); |
| 4687 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4668 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
| 4688 if (pNode->IsAttributeInXML()) { | 4669 if (pNode->IsAttributeInXML()) { |
| 4689 ASSERT(pNode->m_pXMLNode == m_pXMLNode && | 4670 ASSERT(pNode->m_pXMLNode == m_pXMLNode && |
| 4690 m_pXMLNode->GetType() == FDE_XMLNODE_Element); | 4671 m_pXMLNode->GetType() == FDE_XMLNODE_Element); |
| 4691 if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { | 4672 if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { |
| 4692 CFDE_XMLElement* pXMLElement = | 4673 CFDE_XMLElement* pXMLElement = |
| 4693 static_cast<CFDE_XMLElement*>(pNode->m_pXMLNode); | 4674 static_cast<CFDE_XMLElement*>(pNode->m_pXMLNode); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4714 CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { | 4695 CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { |
| 4715 return GetFirstChildByName(FX_HashCode_GetW(wsName, false)); | 4696 return GetFirstChildByName(FX_HashCode_GetW(wsName, false)); |
| 4716 } | 4697 } |
| 4717 CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const { | 4698 CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const { |
| 4718 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; | 4699 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; |
| 4719 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4700 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 4720 if (pNode->GetNameHash() == dwNameHash) { | 4701 if (pNode->GetNameHash() == dwNameHash) { |
| 4721 return pNode; | 4702 return pNode; |
| 4722 } | 4703 } |
| 4723 } | 4704 } |
| 4724 return NULL; | 4705 return nullptr; |
| 4725 } | 4706 } |
| 4726 CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_ELEMENT eElement) const { | 4707 CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_ELEMENT eElement) const { |
| 4727 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; | 4708 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; |
| 4728 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4709 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 4729 if (pNode->GetClassID() == eElement) { | 4710 if (pNode->GetClassID() == eElement) { |
| 4730 return pNode; | 4711 return pNode; |
| 4731 } | 4712 } |
| 4732 } | 4713 } |
| 4733 return NULL; | 4714 return nullptr; |
| 4734 } | 4715 } |
| 4735 CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const { | 4716 CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const { |
| 4736 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; | 4717 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; |
| 4737 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4718 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 4738 if (pNode->GetNameHash() == dwNameHash) { | 4719 if (pNode->GetNameHash() == dwNameHash) { |
| 4739 return pNode; | 4720 return pNode; |
| 4740 } | 4721 } |
| 4741 } | 4722 } |
| 4742 return NULL; | 4723 return nullptr; |
| 4743 } | 4724 } |
| 4744 CXFA_Node* CXFA_Node::GetNextSameNameSibling( | 4725 CXFA_Node* CXFA_Node::GetNextSameNameSibling( |
| 4745 const CFX_WideStringC& wsNodeName) const { | 4726 const CFX_WideStringC& wsNodeName) const { |
| 4746 return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false)); | 4727 return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false)); |
| 4747 } | 4728 } |
| 4748 CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_ELEMENT eElement) const { | 4729 CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_ELEMENT eElement) const { |
| 4749 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; | 4730 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; |
| 4750 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 4731 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 4751 if (pNode->GetClassID() == eElement) { | 4732 if (pNode->GetClassID() == eElement) { |
| 4752 return pNode; | 4733 return pNode; |
| 4753 } | 4734 } |
| 4754 } | 4735 } |
| 4755 return NULL; | 4736 return nullptr; |
| 4756 } | 4737 } |
| 4757 int32_t CXFA_Node::GetNodeSameNameIndex() const { | 4738 int32_t CXFA_Node::GetNodeSameNameIndex() const { |
| 4758 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 4739 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 4759 if (!pScriptContext) { | 4740 if (!pScriptContext) { |
| 4760 return -1; | 4741 return -1; |
| 4761 } | 4742 } |
| 4762 return pScriptContext->GetIndexByName(const_cast<CXFA_Node*>(this)); | 4743 return pScriptContext->GetIndexByName(const_cast<CXFA_Node*>(this)); |
| 4763 } | 4744 } |
| 4764 int32_t CXFA_Node::GetNodeSameClassIndex() const { | 4745 int32_t CXFA_Node::GetNodeSameClassIndex() const { |
| 4765 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 4746 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 4766 if (!pScriptContext) { | 4747 if (!pScriptContext) { |
| 4767 return -1; | 4748 return -1; |
| 4768 } | 4749 } |
| 4769 return pScriptContext->GetIndexByClassName(const_cast<CXFA_Node*>(this)); | 4750 return pScriptContext->GetIndexByClassName(const_cast<CXFA_Node*>(this)); |
| 4770 } | 4751 } |
| 4771 void CXFA_Node::GetSOMExpression(CFX_WideString& wsSOMExpression) { | 4752 void CXFA_Node::GetSOMExpression(CFX_WideString& wsSOMExpression) { |
| 4772 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); | 4753 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); |
| 4773 if (!pScriptContext) { | 4754 if (!pScriptContext) { |
| 4774 return; | 4755 return; |
| 4775 } | 4756 } |
| 4776 pScriptContext->GetSomExpression(this, wsSOMExpression); | 4757 pScriptContext->GetSomExpression(this, wsSOMExpression); |
| 4777 } | 4758 } |
| 4778 CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { | 4759 CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { |
| 4779 CXFA_Node* pInstanceMgr = NULL; | 4760 CXFA_Node* pInstanceMgr = nullptr; |
| 4780 if (m_ePacket == XFA_XDPPACKET_Form) { | 4761 if (m_ePacket == XFA_XDPPACKET_Form) { |
| 4781 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); | 4762 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); |
| 4782 if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_Area) { | 4763 if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_Area) { |
| 4783 return pInstanceMgr; | 4764 return pInstanceMgr; |
| 4784 } | 4765 } |
| 4785 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 4766 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
| 4786 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 4767 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
| 4787 XFA_ELEMENT eType = pNode->GetClassID(); | 4768 XFA_ELEMENT eType = pNode->GetClassID(); |
| 4788 if ((eType == XFA_ELEMENT_Subform || eType == XFA_ELEMENT_SubformSet) && | 4769 if ((eType == XFA_ELEMENT_Subform || eType == XFA_ELEMENT_SubformSet) && |
| 4789 pNode->m_dwNameHash != m_dwNameHash) { | 4770 pNode->m_dwNameHash != m_dwNameHash) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4965 | 4946 |
| 4966 FX_BOOL CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) { | 4947 FX_BOOL CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) { |
| 4967 CXFA_Node* pNode = this; | 4948 CXFA_Node* pNode = this; |
| 4968 while (pNode) { | 4949 while (pNode) { |
| 4969 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); | 4950 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); |
| 4970 if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) { | 4951 if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) { |
| 4971 return TRUE; | 4952 return TRUE; |
| 4972 } | 4953 } |
| 4973 pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets | 4954 pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets |
| 4974 ? pNode->GetTemplateNode() | 4955 ? pNode->GetTemplateNode() |
| 4975 : NULL; | 4956 : nullptr; |
| 4976 } | 4957 } |
| 4977 return FALSE; | 4958 return FALSE; |
| 4978 } | 4959 } |
| 4979 void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) { | 4960 void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) { |
| 4980 SetMapModuleBuffer(pKey, (void*)wsValue.c_str(), | 4961 SetMapModuleBuffer(pKey, (void*)wsValue.c_str(), |
| 4981 wsValue.GetLength() * sizeof(FX_WCHAR)); | 4962 wsValue.GetLength() * sizeof(FX_WCHAR)); |
| 4982 } | 4963 } |
| 4983 FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) { | 4964 FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) { |
| 4984 void* pValue; | 4965 void* pValue; |
| 4985 int32_t iBytes; | 4966 int32_t iBytes; |
| 4986 if (!GetMapModuleBuffer(pKey, pValue, iBytes)) { | 4967 if (!GetMapModuleBuffer(pKey, pValue, iBytes)) { |
| 4987 return FALSE; | 4968 return FALSE; |
| 4988 } | 4969 } |
| 4989 wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR)); | 4970 wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR)); |
| 4990 return TRUE; | 4971 return TRUE; |
| 4991 } | 4972 } |
| 4992 void CXFA_Node::SetMapModuleBuffer( | 4973 void CXFA_Node::SetMapModuleBuffer( |
| 4993 void* pKey, | 4974 void* pKey, |
| 4994 void* pValue, | 4975 void* pValue, |
| 4995 int32_t iBytes, | 4976 int32_t iBytes, |
| 4996 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { | 4977 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { |
| 4997 XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); | 4978 XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); |
| 4998 XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey]; | 4979 XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey]; |
| 4999 if (pBuffer == NULL) { | 4980 if (!pBuffer) { |
| 5000 pBuffer = | 4981 pBuffer = |
| 5001 (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes); | 4982 (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes); |
| 5002 } else if (pBuffer->iBytes != iBytes) { | 4983 } else if (pBuffer->iBytes != iBytes) { |
| 5003 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 4984 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
| 5004 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 4985 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
| 5005 } | 4986 } |
| 5006 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer, | 4987 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer, |
| 5007 sizeof(XFA_MAPDATABLOCK) + iBytes); | 4988 sizeof(XFA_MAPDATABLOCK) + iBytes); |
| 5008 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 4989 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
| 5009 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 4990 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
| 5010 } | 4991 } |
| 5011 if (pBuffer == NULL) { | 4992 if (!pBuffer) |
| 5012 return; | 4993 return; |
| 5013 } | 4994 |
| 5014 pBuffer->pCallbackInfo = pCallbackInfo; | 4995 pBuffer->pCallbackInfo = pCallbackInfo; |
| 5015 pBuffer->iBytes = iBytes; | 4996 pBuffer->iBytes = iBytes; |
| 5016 FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes); | 4997 FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes); |
| 5017 } | 4998 } |
| 5018 FX_BOOL CXFA_Node::GetMapModuleBuffer(void* pKey, | 4999 FX_BOOL CXFA_Node::GetMapModuleBuffer(void* pKey, |
| 5019 void*& pValue, | 5000 void*& pValue, |
| 5020 int32_t& iBytes, | 5001 int32_t& iBytes, |
| 5021 FX_BOOL bProtoAlso) const { | 5002 FX_BOOL bProtoAlso) const { |
| 5022 XFA_MAPDATABLOCK* pBuffer = NULL; | 5003 XFA_MAPDATABLOCK* pBuffer = nullptr; |
| 5023 const CXFA_Node* pNode = this; | 5004 const CXFA_Node* pNode = this; |
| 5024 while (pNode) { | 5005 while (pNode) { |
| 5025 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); | 5006 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); |
| 5026 if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) { | 5007 if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) { |
| 5027 break; | 5008 break; |
| 5028 } | 5009 } |
| 5029 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) | 5010 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) |
| 5030 ? pNode->GetTemplateNode() | 5011 ? pNode->GetTemplateNode() |
| 5031 : NULL; | 5012 : nullptr; |
| 5032 } | 5013 } |
| 5033 if (pBuffer == NULL) { | 5014 if (!pBuffer) { |
| 5034 return FALSE; | 5015 return FALSE; |
| 5035 } | 5016 } |
| 5036 pValue = pBuffer->GetData(); | 5017 pValue = pBuffer->GetData(); |
| 5037 iBytes = pBuffer->iBytes; | 5018 iBytes = pBuffer->iBytes; |
| 5038 return TRUE; | 5019 return TRUE; |
| 5039 } | 5020 } |
| 5040 FX_BOOL CXFA_Node::HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso) { | 5021 FX_BOOL CXFA_Node::HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso) { |
| 5041 CXFA_Node* pNode = this; | 5022 CXFA_Node* pNode = this; |
| 5042 while (pNode) { | 5023 while (pNode) { |
| 5043 void* pVal; | 5024 void* pVal; |
| 5044 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); | 5025 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); |
| 5045 if (pModule && | 5026 if (pModule && |
| 5046 (pModule->m_ValueMap.Lookup(pKey, pVal) || | 5027 (pModule->m_ValueMap.Lookup(pKey, pVal) || |
| 5047 pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) { | 5028 pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) { |
| 5048 return TRUE; | 5029 return TRUE; |
| 5049 } | 5030 } |
| 5050 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) | 5031 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) |
| 5051 ? pNode->GetTemplateNode() | 5032 ? pNode->GetTemplateNode() |
| 5052 : NULL; | 5033 : nullptr; |
| 5053 } | 5034 } |
| 5054 return FALSE; | 5035 return FALSE; |
| 5055 } | 5036 } |
| 5056 void CXFA_Node::RemoveMapModuleKey(void* pKey) { | 5037 void CXFA_Node::RemoveMapModuleKey(void* pKey) { |
| 5057 XFA_MAPMODULEDATA* pModule = GetMapModuleData(); | 5038 XFA_MAPMODULEDATA* pModule = GetMapModuleData(); |
| 5058 if (!pModule) | 5039 if (!pModule) |
| 5059 return; | 5040 return; |
| 5060 | 5041 |
| 5061 if (pKey) { | 5042 if (pKey) { |
| 5062 XFA_MAPDATABLOCK* pBuffer = NULL; | 5043 XFA_MAPDATABLOCK* pBuffer = nullptr; |
| 5063 pModule->m_BufferMap.Lookup(pKey, pBuffer); | 5044 pModule->m_BufferMap.Lookup(pKey, pBuffer); |
| 5064 if (pBuffer) { | 5045 if (pBuffer) { |
| 5065 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 5046 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
| 5066 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 5047 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
| 5067 } | 5048 } |
| 5068 FX_Free(pBuffer); | 5049 FX_Free(pBuffer); |
| 5069 } | 5050 } |
| 5070 pModule->m_BufferMap.RemoveKey(pKey); | 5051 pModule->m_BufferMap.RemoveKey(pKey); |
| 5071 pModule->m_ValueMap.RemoveKey(pKey); | 5052 pModule->m_ValueMap.RemoveKey(pKey); |
| 5072 } else { | 5053 } else { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5112 continue; | 5093 continue; |
| 5113 } | 5094 } |
| 5114 if (pSrcBuffer->pCallbackInfo && pSrcBuffer->pCallbackInfo->pFree && | 5095 if (pSrcBuffer->pCallbackInfo && pSrcBuffer->pCallbackInfo->pFree && |
| 5115 !pSrcBuffer->pCallbackInfo->pCopy) { | 5096 !pSrcBuffer->pCallbackInfo->pCopy) { |
| 5116 if (pBuffer) { | 5097 if (pBuffer) { |
| 5117 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 5098 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
| 5118 pDstModuleData->m_BufferMap.RemoveKey(pKey); | 5099 pDstModuleData->m_BufferMap.RemoveKey(pKey); |
| 5119 } | 5100 } |
| 5120 continue; | 5101 continue; |
| 5121 } | 5102 } |
| 5122 if (pBuffer == NULL) { | 5103 if (!pBuffer) { |
| 5123 pBuffer = (XFA_MAPDATABLOCK*)FX_Alloc( | 5104 pBuffer = (XFA_MAPDATABLOCK*)FX_Alloc( |
| 5124 uint8_t, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); | 5105 uint8_t, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); |
| 5125 } else if (pBuffer->iBytes != pSrcBuffer->iBytes) { | 5106 } else if (pBuffer->iBytes != pSrcBuffer->iBytes) { |
| 5126 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 5107 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
| 5127 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 5108 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
| 5128 } | 5109 } |
| 5129 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc( | 5110 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc( |
| 5130 uint8_t, pBuffer, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); | 5111 uint8_t, pBuffer, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); |
| 5131 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { | 5112 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { |
| 5132 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); | 5113 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); |
| 5133 } | 5114 } |
| 5134 if (pBuffer == NULL) { | 5115 if (!pBuffer) { |
| 5135 continue; | 5116 continue; |
| 5136 } | 5117 } |
| 5137 pBuffer->pCallbackInfo = pSrcBuffer->pCallbackInfo; | 5118 pBuffer->pCallbackInfo = pSrcBuffer->pCallbackInfo; |
| 5138 pBuffer->iBytes = pSrcBuffer->iBytes; | 5119 pBuffer->iBytes = pSrcBuffer->iBytes; |
| 5139 FXSYS_memcpy(pBuffer->GetData(), pSrcBuffer->GetData(), pSrcBuffer->iBytes); | 5120 FXSYS_memcpy(pBuffer->GetData(), pSrcBuffer->GetData(), pSrcBuffer->iBytes); |
| 5140 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) { | 5121 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) { |
| 5141 pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData()); | 5122 pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData()); |
| 5142 } | 5123 } |
| 5143 } | 5124 } |
| 5144 } | 5125 } |
| 5145 void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { | 5126 void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { |
| 5146 if (!pDstModule) { | 5127 if (!pDstModule) { |
| 5147 return; | 5128 return; |
| 5148 } | 5129 } |
| 5149 FX_BOOL bNeedMove = TRUE; | 5130 FX_BOOL bNeedMove = TRUE; |
| 5150 if (!pKey) { | 5131 if (!pKey) { |
| 5151 bNeedMove = FALSE; | 5132 bNeedMove = FALSE; |
| 5152 } | 5133 } |
| 5153 if (pDstModule->GetClassID() != GetClassID()) { | 5134 if (pDstModule->GetClassID() != GetClassID()) { |
| 5154 bNeedMove = FALSE; | 5135 bNeedMove = FALSE; |
| 5155 } | 5136 } |
| 5156 XFA_MAPMODULEDATA* pSrcModuleData = NULL; | 5137 XFA_MAPMODULEDATA* pSrcModuleData = nullptr; |
| 5157 XFA_MAPMODULEDATA* pDstModuleData = NULL; | 5138 XFA_MAPMODULEDATA* pDstModuleData = nullptr; |
| 5158 if (bNeedMove) { | 5139 if (bNeedMove) { |
| 5159 pSrcModuleData = GetMapModuleData(); | 5140 pSrcModuleData = GetMapModuleData(); |
| 5160 if (!pSrcModuleData) { | 5141 if (!pSrcModuleData) { |
| 5161 bNeedMove = FALSE; | 5142 bNeedMove = FALSE; |
| 5162 } | 5143 } |
| 5163 pDstModuleData = pDstModule->CreateMapModuleData(); | 5144 pDstModuleData = pDstModule->CreateMapModuleData(); |
| 5164 } | 5145 } |
| 5165 if (bNeedMove) { | 5146 if (bNeedMove) { |
| 5166 void* pBufferBlockData = pSrcModuleData->m_BufferMap.GetValueAt(pKey); | 5147 void* pBufferBlockData = pSrcModuleData->m_BufferMap.GetValueAt(pKey); |
| 5167 if (pBufferBlockData) { | 5148 if (pBufferBlockData) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5204 m_pDocument->GetScriptContext()->CacheList(this); | 5185 m_pDocument->GetScriptContext()->CacheList(this); |
| 5205 } | 5186 } |
| 5206 CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { | 5187 CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { |
| 5207 uint32_t dwHashCode = FX_HashCode_GetW(wsName, false); | 5188 uint32_t dwHashCode = FX_HashCode_GetW(wsName, false); |
| 5208 int32_t iCount = GetLength(); | 5189 int32_t iCount = GetLength(); |
| 5209 for (int32_t i = 0; i < iCount; i++) { | 5190 for (int32_t i = 0; i < iCount; i++) { |
| 5210 CXFA_Node* ret = Item(i); | 5191 CXFA_Node* ret = Item(i); |
| 5211 if (dwHashCode == ret->GetNameHash()) | 5192 if (dwHashCode == ret->GetNameHash()) |
| 5212 return ret; | 5193 return ret; |
| 5213 } | 5194 } |
| 5214 return NULL; | 5195 return nullptr; |
| 5215 } | 5196 } |
| 5216 void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) { | 5197 void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) { |
| 5217 int32_t argc = pArguments->GetLength(); | 5198 int32_t argc = pArguments->GetLength(); |
| 5218 if (argc == 1) { | 5199 if (argc == 1) { |
| 5219 CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 5200 CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
| 5220 if (pNode) { | 5201 if (pNode) { |
| 5221 Append(pNode); | 5202 Append(pNode); |
| 5222 } else { | 5203 } else { |
| 5223 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 5204 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 5224 } | 5205 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5302 } | 5283 } |
| 5303 int32_t CXFA_ArrayNodeList::GetLength() { | 5284 int32_t CXFA_ArrayNodeList::GetLength() { |
| 5304 return m_array.GetSize(); | 5285 return m_array.GetSize(); |
| 5305 } | 5286 } |
| 5306 FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { | 5287 FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { |
| 5307 m_array.Add(pNode); | 5288 m_array.Add(pNode); |
| 5308 return TRUE; | 5289 return TRUE; |
| 5309 } | 5290 } |
| 5310 FX_BOOL CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, | 5291 FX_BOOL CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, |
| 5311 CXFA_Node* pBeforeNode) { | 5292 CXFA_Node* pBeforeNode) { |
| 5312 if (pBeforeNode == NULL) { | 5293 if (!pBeforeNode) { |
| 5313 m_array.Add(pNewNode); | 5294 m_array.Add(pNewNode); |
| 5314 } else { | 5295 } else { |
| 5315 int32_t iSize = m_array.GetSize(); | 5296 int32_t iSize = m_array.GetSize(); |
| 5316 for (int32_t i = 0; i < iSize; ++i) { | 5297 for (int32_t i = 0; i < iSize; ++i) { |
| 5317 if (m_array[i] == pBeforeNode) { | 5298 if (m_array[i] == pBeforeNode) { |
| 5318 m_array.InsertAt(i, pNewNode); | 5299 m_array.InsertAt(i, pNewNode); |
| 5319 break; | 5300 break; |
| 5320 } | 5301 } |
| 5321 } | 5302 } |
| 5322 } | 5303 } |
| 5323 return TRUE; | 5304 return TRUE; |
| 5324 } | 5305 } |
| 5325 FX_BOOL CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { | 5306 FX_BOOL CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { |
| 5326 int32_t iSize = m_array.GetSize(); | 5307 int32_t iSize = m_array.GetSize(); |
| 5327 for (int32_t i = 0; i < iSize; ++i) { | 5308 for (int32_t i = 0; i < iSize; ++i) { |
| 5328 if (m_array[i] == pNode) { | 5309 if (m_array[i] == pNode) { |
| 5329 m_array.RemoveAt(i); | 5310 m_array.RemoveAt(i); |
| 5330 break; | 5311 break; |
| 5331 } | 5312 } |
| 5332 } | 5313 } |
| 5333 return TRUE; | 5314 return TRUE; |
| 5334 } | 5315 } |
| 5335 CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) { | 5316 CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) { |
| 5336 int32_t iSize = m_array.GetSize(); | 5317 int32_t iSize = m_array.GetSize(); |
| 5337 if (iIndex >= 0 && iIndex < iSize) { | 5318 if (iIndex >= 0 && iIndex < iSize) { |
| 5338 return m_array[iIndex]; | 5319 return m_array[iIndex]; |
| 5339 } | 5320 } |
| 5340 return NULL; | 5321 return nullptr; |
| 5341 } | 5322 } |
| 5342 CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, | 5323 CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, |
| 5343 CXFA_Node* pAttachNode) | 5324 CXFA_Node* pAttachNode) |
| 5344 : CXFA_NodeList(pDocument) { | 5325 : CXFA_NodeList(pDocument) { |
| 5345 m_pAttachNode = pAttachNode; | 5326 m_pAttachNode = pAttachNode; |
| 5346 } | 5327 } |
| 5347 int32_t CXFA_AttachNodeList::GetLength() { | 5328 int32_t CXFA_AttachNodeList::GetLength() { |
| 5348 return m_pAttachNode->CountChildren( | 5329 return m_pAttachNode->CountChildren( |
| 5349 XFA_ELEMENT_UNKNOWN, m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5330 XFA_ELEMENT_UNKNOWN, m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
| 5350 } | 5331 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5364 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5345 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
| 5365 } | 5346 } |
| 5366 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5347 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
| 5367 return m_pAttachNode->RemoveChild(pNode); | 5348 return m_pAttachNode->RemoveChild(pNode); |
| 5368 } | 5349 } |
| 5369 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5350 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
| 5370 return m_pAttachNode->GetChild( | 5351 return m_pAttachNode->GetChild( |
| 5371 iIndex, XFA_ELEMENT_UNKNOWN, | 5352 iIndex, XFA_ELEMENT_UNKNOWN, |
| 5372 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5353 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
| 5373 } | 5354 } |
| OLD | NEW |