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 "core/fxcrt/include/fx_ext.h" | 7 #include "core/fxcrt/include/fx_ext.h" |
8 #include "xfa/fxfa/app/xfa_ffnotify.h" | 8 #include "xfa/fxfa/app/xfa_ffnotify.h" |
9 #include "xfa/fxfa/parser/xfa_basic_imp.h" | 9 #include "xfa/fxfa/parser/xfa_basic_imp.h" |
10 #include "xfa/fxfa/parser/xfa_doclayout.h" | 10 #include "xfa/fxfa/parser/xfa_doclayout.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) { | 81 CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) { |
82 switch (dwNodeNameHash) { | 82 switch (dwNodeNameHash) { |
83 case XFA_HASHCODE_Data: { | 83 case XFA_HASHCODE_Data: { |
84 CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); | 84 CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); |
85 if (!pDatasetsNode) { | 85 if (!pDatasetsNode) { |
86 return NULL; | 86 return NULL; |
87 } | 87 } |
88 for (CXFA_Node* pDatasetsChild = | 88 for (CXFA_Node* pDatasetsChild = |
89 pDatasetsNode->GetFirstChildByClass(XFA_ELEMENT_DataGroup); | 89 pDatasetsNode->GetFirstChildByClass(XFA_Element::DataGroup); |
90 pDatasetsChild; | 90 pDatasetsChild; |
91 pDatasetsChild = | 91 pDatasetsChild = pDatasetsChild->GetNextSameClassSibling( |
92 pDatasetsChild->GetNextSameClassSibling(XFA_ELEMENT_DataGroup)) { | 92 XFA_Element::DataGroup)) { |
93 if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data) { | 93 if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data) { |
94 continue; | 94 continue; |
95 } | 95 } |
96 CFX_WideString wsNamespaceURI; | 96 CFX_WideString wsNamespaceURI; |
97 if (!pDatasetsChild->TryNamespace(wsNamespaceURI)) { | 97 if (!pDatasetsChild->TryNamespace(wsNamespaceURI)) { |
98 continue; | 98 continue; |
99 } | 99 } |
100 CFX_WideString wsDatasetsURI; | 100 CFX_WideString wsDatasetsURI; |
101 if (!pDatasetsNode->TryNamespace(wsDatasetsURI)) { | 101 if (!pDatasetsNode->TryNamespace(wsDatasetsURI)) { |
102 continue; | 102 continue; |
103 } | 103 } |
104 if (wsNamespaceURI == wsDatasetsURI) { | 104 if (wsNamespaceURI == wsDatasetsURI) { |
105 return pDatasetsChild; | 105 return pDatasetsChild; |
106 } | 106 } |
107 } | 107 } |
108 } | 108 } |
109 return NULL; | 109 return NULL; |
110 case XFA_HASHCODE_Record: { | 110 case XFA_HASHCODE_Record: { |
111 CXFA_Node* pData = ToNode(GetXFAObject(XFA_HASHCODE_Data)); | 111 CXFA_Node* pData = ToNode(GetXFAObject(XFA_HASHCODE_Data)); |
112 return pData ? pData->GetFirstChildByClass(XFA_ELEMENT_DataGroup) : NULL; | 112 return pData ? pData->GetFirstChildByClass(XFA_Element::DataGroup) : NULL; |
113 } | 113 } |
114 case XFA_HASHCODE_DataWindow: { | 114 case XFA_HASHCODE_DataWindow: { |
115 if (m_pScriptDataWindow == NULL) { | 115 if (m_pScriptDataWindow == NULL) { |
116 m_pScriptDataWindow = new CScript_DataWindow(this); | 116 m_pScriptDataWindow = new CScript_DataWindow(this); |
117 } | 117 } |
118 return m_pScriptDataWindow; | 118 return m_pScriptDataWindow; |
119 } | 119 } |
120 case XFA_HASHCODE_Event: { | 120 case XFA_HASHCODE_Event: { |
121 if (m_pScriptEvent == NULL) { | 121 if (m_pScriptEvent == NULL) { |
122 m_pScriptEvent = new CScript_EventPseudoModel(this); | 122 m_pScriptEvent = new CScript_EventPseudoModel(this); |
(...skipping 21 matching lines...) Expand all Loading... |
144 case XFA_HASHCODE_Layout: { | 144 case XFA_HASHCODE_Layout: { |
145 if (m_pScriptLayout == NULL) { | 145 if (m_pScriptLayout == NULL) { |
146 m_pScriptLayout = new CScript_LayoutPseudoModel(this); | 146 m_pScriptLayout = new CScript_LayoutPseudoModel(this); |
147 } | 147 } |
148 return m_pScriptLayout; | 148 return m_pScriptLayout; |
149 } | 149 } |
150 default: | 150 default: |
151 return m_pRootNode->GetFirstChildByName(dwNodeNameHash); | 151 return m_pRootNode->GetFirstChildByName(dwNodeNameHash); |
152 } | 152 } |
153 } | 153 } |
154 CXFA_Node* CXFA_Document::CreateNode(uint32_t dwPacket, XFA_ELEMENT eElement) { | 154 CXFA_Node* CXFA_Document::CreateNode(uint32_t dwPacket, XFA_Element eElement) { |
155 return CreateNode(XFA_GetPacketByID(dwPacket), eElement); | 155 return CreateNode(XFA_GetPacketByID(dwPacket), eElement); |
156 } | 156 } |
157 | 157 |
158 CXFA_Node* CXFA_Document::CreateNode(const XFA_PACKETINFO* pPacket, | 158 CXFA_Node* CXFA_Document::CreateNode(const XFA_PACKETINFO* pPacket, |
159 XFA_ELEMENT eElement) { | 159 XFA_Element eElement) { |
160 if (!pPacket) | 160 if (!pPacket) |
161 return nullptr; | 161 return nullptr; |
162 | 162 |
163 const XFA_ELEMENTINFO* pElement = XFA_GetElementByID(eElement); | 163 const XFA_ELEMENTINFO* pElement = XFA_GetElementByID(eElement); |
164 if (pElement && (pElement->dwPackets & pPacket->eName)) { | 164 if (pElement && (pElement->dwPackets & pPacket->eName)) { |
165 CXFA_Node* pNode = new CXFA_Node(this, pPacket->eName, pElement->eName); | 165 CXFA_Node* pNode = new CXFA_Node(this, pPacket->eName, pElement->eName); |
166 AddPurgeNode(pNode); | 166 AddPurgeNode(pNode); |
167 return pNode; | 167 return pNode; |
168 } | 168 } |
169 | 169 |
(...skipping 24 matching lines...) Expand all Loading... |
194 } | 194 } |
195 FX_BOOL CXFA_Document::IsInteractive() { | 195 FX_BOOL CXFA_Document::IsInteractive() { |
196 if (m_dwDocFlags & XFA_DOCFLAG_HasInteractive) { | 196 if (m_dwDocFlags & XFA_DOCFLAG_HasInteractive) { |
197 return !!(m_dwDocFlags & XFA_DOCFLAG_Interactive); | 197 return !!(m_dwDocFlags & XFA_DOCFLAG_Interactive); |
198 } | 198 } |
199 CXFA_Node* pConfig = ToNode(GetXFAObject(XFA_HASHCODE_Config)); | 199 CXFA_Node* pConfig = ToNode(GetXFAObject(XFA_HASHCODE_Config)); |
200 if (!pConfig) { | 200 if (!pConfig) { |
201 return FALSE; | 201 return FALSE; |
202 } | 202 } |
203 CFX_WideString wsInteractive; | 203 CFX_WideString wsInteractive; |
204 CXFA_Node* pPresent = pConfig->GetFirstChildByClass(XFA_ELEMENT_Present); | 204 CXFA_Node* pPresent = pConfig->GetFirstChildByClass(XFA_Element::Present); |
205 if (!pPresent) { | 205 if (!pPresent) { |
206 return FALSE; | 206 return FALSE; |
207 } | 207 } |
208 CXFA_Node* pPDF = pPresent->GetFirstChildByClass(XFA_ELEMENT_Pdf); | 208 CXFA_Node* pPDF = pPresent->GetFirstChildByClass(XFA_Element::Pdf); |
209 if (!pPDF) { | 209 if (!pPDF) { |
210 return FALSE; | 210 return FALSE; |
211 } | 211 } |
212 CXFA_Node* pInteractive = pPDF->GetChild(0, XFA_ELEMENT_Interactive); | 212 CXFA_Node* pInteractive = pPDF->GetChild(0, XFA_Element::Interactive); |
213 if (pInteractive) { | 213 if (pInteractive) { |
214 m_dwDocFlags |= XFA_DOCFLAG_HasInteractive; | 214 m_dwDocFlags |= XFA_DOCFLAG_HasInteractive; |
215 if (pInteractive->TryContent(wsInteractive) && | 215 if (pInteractive->TryContent(wsInteractive) && |
216 wsInteractive == FX_WSTRC(L"1")) { | 216 wsInteractive == FX_WSTRC(L"1")) { |
217 m_dwDocFlags |= XFA_DOCFLAG_Interactive; | 217 m_dwDocFlags |= XFA_DOCFLAG_Interactive; |
218 return TRUE; | 218 return TRUE; |
219 } | 219 } |
220 } | 220 } |
221 return FALSE; | 221 return FALSE; |
222 } | 222 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 if (!mIDMap.Lookup(FX_HashCode_GetW(wsID, false), pProtoNode)) { | 407 if (!mIDMap.Lookup(FX_HashCode_GetW(wsID, false), pProtoNode)) { |
408 continue; | 408 continue; |
409 } | 409 } |
410 } | 410 } |
411 if (!pProtoNode) { | 411 if (!pProtoNode) { |
412 continue; | 412 continue; |
413 } | 413 } |
414 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); | 414 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); |
415 } | 415 } |
416 } | 416 } |
OLD | NEW |