OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/parser/xfa_script_resolveprocessor.h" | 7 #include "xfa/fxfa/parser/xfa_script_resolveprocessor.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 CFX_WideString wsName = rnd.m_wsName; | 115 CFX_WideString wsName = rnd.m_wsName; |
116 CFX_WideString wsCondition = rnd.m_wsCondition; | 116 CFX_WideString wsCondition = rnd.m_wsCondition; |
117 int32_t iNameLen = wsName.GetLength(); | 117 int32_t iNameLen = wsName.GetLength(); |
118 if (iNameLen == 1) { | 118 if (iNameLen == 1) { |
119 nodes.Add(rnd.m_CurNode); | 119 nodes.Add(rnd.m_CurNode); |
120 return 1; | 120 return 1; |
121 } | 121 } |
122 if (rnd.m_nLevel > 0) { | 122 if (rnd.m_nLevel > 0) { |
123 return -1; | 123 return -1; |
124 } | 124 } |
125 uint32_t dwNameHash = | 125 uint32_t dwNameHash = FX_HashCode_GetW( |
126 FX_HashCode_String_GetW(wsName.c_str() + 1, iNameLen - 1); | 126 CFX_WideStringC(wsName.c_str() + 1, iNameLen - 1), false); |
127 if (dwNameHash == XFA_HASHCODE_Xfa) { | 127 if (dwNameHash == XFA_HASHCODE_Xfa) { |
128 nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); | 128 nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); |
129 } else { | 129 } else { |
130 CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); | 130 CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); |
131 if (pObjNode) { | 131 if (pObjNode) { |
132 rnd.m_Nodes.Add(pObjNode); | 132 rnd.m_Nodes.Add(pObjNode); |
133 } | 133 } |
134 } | 134 } |
135 if (rnd.m_Nodes.GetSize() > 0) { | 135 if (rnd.m_Nodes.GetSize() > 0) { |
136 XFA_ResolveNode_FilterCondition(rnd, wsCondition); | 136 XFA_ResolveNode_FilterCondition(rnd, wsCondition); |
137 } | 137 } |
138 return rnd.m_Nodes.GetSize(); | 138 return rnd.m_Nodes.GetSize(); |
139 } | 139 } |
140 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( | 140 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( |
141 CXFA_ResolveNodesData& rnd) { | 141 CXFA_ResolveNodesData& rnd) { |
142 if (rnd.m_nLevel > 0) { | 142 if (rnd.m_nLevel > 0) { |
143 return 0; | 143 return 0; |
144 } | 144 } |
145 CXFA_Node* datasets = | 145 CXFA_Node* datasets = |
146 ToNode(rnd.m_pSC->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); | 146 ToNode(rnd.m_pSC->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); |
147 if (!datasets) { | 147 if (!datasets) { |
148 return 0; | 148 return 0; |
149 } | 149 } |
150 CXFA_ResolveNodesData rndFind; | 150 CXFA_ResolveNodesData rndFind; |
151 rndFind.m_pSC = rnd.m_pSC; | 151 rndFind.m_pSC = rnd.m_pSC; |
152 rndFind.m_CurNode = datasets; | 152 rndFind.m_CurNode = datasets; |
153 rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); | 153 rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); |
154 rndFind.m_uHashName = FX_HashCode_String_GetW(rndFind.m_wsName.c_str(), | 154 rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false); |
155 rndFind.m_wsName.GetLength()); | |
156 rndFind.m_nLevel = rnd.m_nLevel + 1; | 155 rndFind.m_nLevel = rnd.m_nLevel + 1; |
157 rndFind.m_dwStyles = XFA_RESOLVENODE_Children; | 156 rndFind.m_dwStyles = XFA_RESOLVENODE_Children; |
158 rndFind.m_wsCondition = rnd.m_wsCondition; | 157 rndFind.m_wsCondition = rnd.m_wsCondition; |
159 XFA_ResolveNodes(rndFind); | 158 XFA_ResolveNodes(rndFind); |
160 if (rndFind.m_Nodes.GetSize() > 0) { | 159 if (rndFind.m_Nodes.GetSize() > 0) { |
161 rnd.m_Nodes.Append(rndFind.m_Nodes); | 160 rnd.m_Nodes.Append(rndFind.m_Nodes); |
162 rndFind.m_Nodes.RemoveAll(); | 161 rndFind.m_Nodes.RemoveAll(); |
163 } | 162 } |
164 return rnd.m_Nodes.GetSize(); | 163 return rnd.m_Nodes.GetSize(); |
165 } | 164 } |
166 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( | 165 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( |
167 CXFA_ResolveNodesData& rnd) { | 166 CXFA_ResolveNodesData& rnd) { |
168 CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); | 167 CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); |
169 CFX_WideString wsCondition = rnd.m_wsCondition; | 168 CFX_WideString wsCondition = rnd.m_wsCondition; |
170 CXFA_Node* curNode = ToNode(rnd.m_CurNode); | 169 CXFA_Node* curNode = ToNode(rnd.m_CurNode); |
171 if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsStringC())) { | 170 if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsStringC())) { |
172 return 1; | 171 return 1; |
173 } | 172 } |
174 CXFA_ResolveNodesData rndFind; | 173 CXFA_ResolveNodesData rndFind; |
175 rndFind.m_pSC = rnd.m_pSC; | 174 rndFind.m_pSC = rnd.m_pSC; |
176 rndFind.m_nLevel = rnd.m_nLevel + 1; | 175 rndFind.m_nLevel = rnd.m_nLevel + 1; |
177 rndFind.m_dwStyles = rnd.m_dwStyles; | 176 rndFind.m_dwStyles = rnd.m_dwStyles; |
178 rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName; | 177 rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName; |
179 rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes; | 178 rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes; |
180 rndFind.m_wsName = wsName; | 179 rndFind.m_wsName = wsName; |
181 rndFind.m_uHashName = FX_HashCode_String_GetW(rndFind.m_wsName.c_str(), | 180 rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false); |
182 rndFind.m_wsName.GetLength()); | |
183 rndFind.m_wsCondition = wsCondition; | 181 rndFind.m_wsCondition = wsCondition; |
184 rndFind.m_CurNode = curNode; | 182 rndFind.m_CurNode = curNode; |
185 XFA_ResolveNodes_Normal(rndFind); | 183 XFA_ResolveNodes_Normal(rndFind); |
186 if (rndFind.m_Nodes.GetSize() > 0) { | 184 if (rndFind.m_Nodes.GetSize() > 0) { |
187 if (wsCondition.GetLength() == 0 && rndFind.m_Nodes.Find(curNode) >= 0) { | 185 if (wsCondition.GetLength() == 0 && rndFind.m_Nodes.Find(curNode) >= 0) { |
188 rnd.m_Nodes.Add(curNode); | 186 rnd.m_Nodes.Add(curNode); |
189 } else { | 187 } else { |
190 rnd.m_Nodes.Append(rndFind.m_Nodes); | 188 rnd.m_Nodes.Append(rndFind.m_Nodes); |
191 rndFind.m_Nodes.RemoveAll(); | 189 rndFind.m_Nodes.RemoveAll(); |
192 } | 190 } |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } | 608 } |
611 if (stack.GetSize() > 0) { | 609 if (stack.GetSize() > 0) { |
612 return -1; | 610 return -1; |
613 } | 611 } |
614 wsName.ReleaseBuffer(nNameCount); | 612 wsName.ReleaseBuffer(nNameCount); |
615 wsName.TrimLeft(); | 613 wsName.TrimLeft(); |
616 wsName.TrimRight(); | 614 wsName.TrimRight(); |
617 wsCondition.ReleaseBuffer(nConditionCount); | 615 wsCondition.ReleaseBuffer(nConditionCount); |
618 wsCondition.TrimLeft(); | 616 wsCondition.TrimLeft(); |
619 wsCondition.TrimRight(); | 617 wsCondition.TrimRight(); |
620 rnd.m_uHashName = FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength()); | 618 rnd.m_uHashName = FX_HashCode_GetW(wsName.AsStringC(), false); |
621 return nStart; | 619 return nStart; |
622 } | 620 } |
623 void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( | 621 void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( |
624 int32_t iCurIndex, | 622 int32_t iCurIndex, |
625 CFX_WideString wsCondition, | 623 CFX_WideString wsCondition, |
626 int32_t iFoundCount, | 624 int32_t iFoundCount, |
627 CXFA_ResolveNodesData& rnd) { | 625 CXFA_ResolveNodesData& rnd) { |
628 CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; | 626 CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; |
629 int32_t iLen = wsCondition.GetLength(); | 627 int32_t iLen = wsCondition.GetLength(); |
630 FX_BOOL bRelative = FALSE; | 628 FX_BOOL bRelative = FALSE; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { | 817 if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { |
820 if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { | 818 if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { |
821 iIndex = 0; | 819 iIndex = 0; |
822 } else { | 820 } else { |
823 iIndex = iCount - 1; | 821 iIndex = iCount - 1; |
824 } | 822 } |
825 } else { | 823 } else { |
826 iIndex = iCount - 1; | 824 iIndex = iCount - 1; |
827 } | 825 } |
828 } | 826 } |
OLD | NEW |