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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { | 54 XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { |
55 XFA_DataNodeDeleteBindItem, nullptr}; | 55 XFA_DataNodeDeleteBindItem, nullptr}; |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, uint32_t uFlags) | 59 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, uint32_t uFlags) |
60 : m_pDocument(pDocument), m_uFlags(uFlags) {} | 60 : m_pDocument(pDocument), m_uFlags(uFlags) {} |
61 | 61 |
| 62 CXFA_Object::~CXFA_Object() {} |
| 63 |
62 void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { | 64 void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { |
63 wsName = XFA_GetElementByID(GetClassID())->pName; | 65 wsName = XFA_GetElementByID(GetClassID())->pName; |
64 } | 66 } |
65 | 67 |
66 uint32_t CXFA_Object::GetClassHashCode() const { | 68 uint32_t CXFA_Object::GetClassHashCode() const { |
67 return XFA_GetElementByID(GetClassID())->uHash; | 69 return XFA_GetElementByID(GetClassID())->uHash; |
68 } | 70 } |
69 | 71 |
70 XFA_ELEMENT CXFA_Object::GetClassID() const { | 72 XFA_ELEMENT CXFA_Object::GetClassID() const { |
71 if (IsNode()) | 73 if (IsNode()) |
(...skipping 28 matching lines...) Expand all Loading... |
100 pAppProvider->LoadString(iStringID, wsFormat); | 102 pAppProvider->LoadString(iStringID, wsFormat); |
101 CFX_WideString wsMessage; | 103 CFX_WideString wsMessage; |
102 va_list arg_ptr; | 104 va_list arg_ptr; |
103 va_start(arg_ptr, iStringID); | 105 va_start(arg_ptr, iStringID); |
104 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 106 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
105 va_end(arg_ptr); | 107 va_end(arg_ptr); |
106 FXJSE_ThrowMessage( | 108 FXJSE_ThrowMessage( |
107 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 109 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
108 } | 110 } |
109 | 111 |
| 112 XFA_MAPMODULEDATA::XFA_MAPMODULEDATA() {} |
| 113 |
| 114 XFA_MAPMODULEDATA::~XFA_MAPMODULEDATA() {} |
| 115 |
110 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, | 116 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, |
111 uint16_t ePacket, | 117 uint16_t ePacket, |
112 XFA_ELEMENT eElement) | 118 XFA_ELEMENT eElement) |
113 : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), | 119 : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), |
114 m_pNext(nullptr), | 120 m_pNext(nullptr), |
115 m_pChild(nullptr), | 121 m_pChild(nullptr), |
116 m_pLastChild(nullptr), | 122 m_pLastChild(nullptr), |
117 m_pParent(nullptr), | 123 m_pParent(nullptr), |
118 m_pXMLNode(nullptr), | 124 m_pXMLNode(nullptr), |
119 m_eNodeClass(eElement), | 125 m_eNodeClass(eElement), |
(...skipping 4957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5077 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); | 5083 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); |
5078 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); | 5084 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); |
5079 for (; pSrcChild && pDstChild; | 5085 for (; pSrcChild && pDstChild; |
5080 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), | 5086 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), |
5081 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 5087 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
5082 MoveBufferMapData(pSrcChild, pDstChild, pKey, TRUE); | 5088 MoveBufferMapData(pSrcChild, pDstChild, pKey, TRUE); |
5083 } | 5089 } |
5084 } | 5090 } |
5085 pSrcModule->MoveBufferMapData(pDstModule, pKey); | 5091 pSrcModule->MoveBufferMapData(pDstModule, pKey); |
5086 } | 5092 } |
| 5093 |
| 5094 CXFA_OrdinaryObject::CXFA_OrdinaryObject(CXFA_Document* pDocument, |
| 5095 XFA_ELEMENT eElement) |
| 5096 : CXFA_Object(pDocument, XFA_OBJECTTYPE_OrdinaryObject), m_uScriptHash(0) { |
| 5097 m_eNodeClass = eElement; |
| 5098 } |
| 5099 |
| 5100 CXFA_OrdinaryObject::~CXFA_OrdinaryObject() {} |
| 5101 |
| 5102 XFA_ELEMENT CXFA_OrdinaryObject::GetClassID() const { |
| 5103 return m_eNodeClass; |
| 5104 } |
| 5105 |
| 5106 uint32_t CXFA_OrdinaryObject::GetScriptObjHash() const { |
| 5107 return m_uScriptHash; |
| 5108 } |
| 5109 |
| 5110 CXFA_ThisProxy::CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode) |
| 5111 : CXFA_Object(pThisNode->GetDocument(), XFA_OBJECTTYPE_VariablesThis), |
| 5112 m_pThisNode(NULL), |
| 5113 m_pScriptNode(NULL) { |
| 5114 m_pThisNode = pThisNode; |
| 5115 m_pScriptNode = pScriptNode; |
| 5116 } |
| 5117 |
| 5118 CXFA_ThisProxy::~CXFA_ThisProxy() {} |
| 5119 |
| 5120 CXFA_Node* CXFA_ThisProxy::GetThisNode() const { |
| 5121 return m_pThisNode; |
| 5122 } |
| 5123 |
| 5124 CXFA_Node* CXFA_ThisProxy::GetScriptNode() const { |
| 5125 return m_pScriptNode; |
| 5126 } |
| 5127 |
5087 CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) | 5128 CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) |
5088 : CXFA_Object(pDocument, XFA_OBJECTTYPE_NodeList) { | 5129 : CXFA_Object(pDocument, XFA_OBJECTTYPE_NodeList) { |
5089 m_pDocument->GetScriptContext()->AddToCacheList( | 5130 m_pDocument->GetScriptContext()->AddToCacheList( |
5090 std::unique_ptr<CXFA_NodeList>(this)); | 5131 std::unique_ptr<CXFA_NodeList>(this)); |
5091 } | 5132 } |
| 5133 CXFA_NodeList::~CXFA_NodeList() {} |
| 5134 XFA_ELEMENT CXFA_NodeList::GetClassID() const { |
| 5135 return XFA_ELEMENT_NodeList; |
| 5136 } |
5092 CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { | 5137 CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { |
5093 uint32_t dwHashCode = FX_HashCode_GetW(wsName, false); | 5138 uint32_t dwHashCode = FX_HashCode_GetW(wsName, false); |
5094 int32_t iCount = GetLength(); | 5139 int32_t iCount = GetLength(); |
5095 for (int32_t i = 0; i < iCount; i++) { | 5140 for (int32_t i = 0; i < iCount; i++) { |
5096 CXFA_Node* ret = Item(i); | 5141 CXFA_Node* ret = Item(i); |
5097 if (dwHashCode == ret->GetNameHash()) | 5142 if (dwHashCode == ret->GetNameHash()) |
5098 return ret; | 5143 return ret; |
5099 } | 5144 } |
5100 return nullptr; | 5145 return nullptr; |
5101 } | 5146 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5173 FX_BOOL bSetting, | 5218 FX_BOOL bSetting, |
5174 XFA_ATTRIBUTE eAttribute) { | 5219 XFA_ATTRIBUTE eAttribute) { |
5175 if (!bSetting) { | 5220 if (!bSetting) { |
5176 pValue->SetInteger(GetLength()); | 5221 pValue->SetInteger(GetLength()); |
5177 } else { | 5222 } else { |
5178 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 5223 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
5179 } | 5224 } |
5180 } | 5225 } |
5181 CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) | 5226 CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) |
5182 : CXFA_NodeList(pDocument) {} | 5227 : CXFA_NodeList(pDocument) {} |
| 5228 |
| 5229 CXFA_ArrayNodeList::~CXFA_ArrayNodeList() {} |
| 5230 |
5183 void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { | 5231 void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { |
5184 if (srcArray.GetSize() > 0) { | 5232 if (srcArray.GetSize() > 0) { |
5185 m_array.Copy(srcArray); | 5233 m_array.Copy(srcArray); |
5186 } | 5234 } |
5187 } | 5235 } |
5188 int32_t CXFA_ArrayNodeList::GetLength() { | 5236 int32_t CXFA_ArrayNodeList::GetLength() { |
5189 return m_array.GetSize(); | 5237 return m_array.GetSize(); |
5190 } | 5238 } |
5191 FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { | 5239 FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { |
5192 m_array.Add(pNode); | 5240 m_array.Add(pNode); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5249 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5297 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
5250 } | 5298 } |
5251 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5299 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
5252 return m_pAttachNode->RemoveChild(pNode); | 5300 return m_pAttachNode->RemoveChild(pNode); |
5253 } | 5301 } |
5254 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5302 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
5255 return m_pAttachNode->GetChild( | 5303 return m_pAttachNode->GetChild( |
5256 iIndex, XFA_ELEMENT_UNKNOWN, | 5304 iIndex, XFA_ELEMENT_UNKNOWN, |
5257 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5305 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
5258 } | 5306 } |
OLD | NEW |