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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 CXFA_ResolveNodesData& rnd) { | 89 CXFA_ResolveNodesData& rnd) { |
90 CFX_WideString wsName = rnd.m_wsName; | 90 CFX_WideString wsName = rnd.m_wsName; |
91 CFX_WideString wsCondition = rnd.m_wsCondition; | 91 CFX_WideString wsCondition = rnd.m_wsCondition; |
92 CXFA_Node* findNode = NULL; | 92 CXFA_Node* findNode = NULL; |
93 CXFA_NodeArray siblings; | 93 CXFA_NodeArray siblings; |
94 FX_BOOL bClassName = FALSE; | 94 FX_BOOL bClassName = FALSE; |
95 if (wsName.GetAt(0) == '#') { | 95 if (wsName.GetAt(0) == '#') { |
96 bClassName = TRUE; | 96 bClassName = TRUE; |
97 wsName = wsName.Right(wsName.GetLength() - 1); | 97 wsName = wsName.Right(wsName.GetLength() - 1); |
98 } | 98 } |
99 findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild(ToNode(rnd.m_CurNode), | 99 findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild( |
100 wsName, bClassName); | 100 ToNode(rnd.m_CurNode), wsName.c_str(), bClassName); |
101 if (findNode == NULL) { | 101 if (findNode == NULL) { |
102 return 0; | 102 return 0; |
103 } | 103 } |
104 if (wsCondition.IsEmpty()) { | 104 if (wsCondition.IsEmpty()) { |
105 rnd.m_Nodes.Add(findNode); | 105 rnd.m_Nodes.Add(findNode); |
106 return rnd.m_Nodes.GetSize(); | 106 return rnd.m_Nodes.GetSize(); |
107 } | 107 } |
108 m_pNodeHelper->XFA_CountSiblings(findNode, XFA_LOGIC_Transparent, | 108 m_pNodeHelper->XFA_CountSiblings(findNode, XFA_LOGIC_Transparent, |
109 (CXFA_NodeArray*)&rnd.m_Nodes, bClassName); | 109 (CXFA_NodeArray*)&rnd.m_Nodes, bClassName); |
110 XFA_ResolveNode_FilterCondition(rnd, wsCondition); | 110 XFA_ResolveNode_FilterCondition(rnd, wsCondition); |
111 return rnd.m_Nodes.GetSize(); | 111 return rnd.m_Nodes.GetSize(); |
112 } | 112 } |
113 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar( | 113 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar( |
114 CXFA_ResolveNodesData& rnd) { | 114 CXFA_ResolveNodesData& rnd) { |
115 CXFA_ObjArray& nodes = rnd.m_Nodes; | 115 CXFA_ObjArray& nodes = rnd.m_Nodes; |
116 CFX_WideString wsName = rnd.m_wsName; | 116 CFX_WideString wsName = rnd.m_wsName; |
117 CFX_WideString wsCondition = rnd.m_wsCondition; | 117 CFX_WideString wsCondition = rnd.m_wsCondition; |
118 int32_t iNameLen = wsName.GetLength(); | 118 int32_t iNameLen = wsName.GetLength(); |
119 if (iNameLen == 1) { | 119 if (iNameLen == 1) { |
120 nodes.Add(rnd.m_CurNode); | 120 nodes.Add(rnd.m_CurNode); |
121 return 1; | 121 return 1; |
122 } | 122 } |
123 if (rnd.m_nLevel > 0) { | 123 if (rnd.m_nLevel > 0) { |
124 return -1; | 124 return -1; |
125 } | 125 } |
126 uint32_t dwNameHash = | 126 uint32_t dwNameHash = |
127 FX_HashCode_String_GetW((const FX_WCHAR*)wsName + 1, iNameLen - 1); | 127 FX_HashCode_String_GetW(wsName.c_str() + 1, iNameLen - 1); |
128 if (dwNameHash == XFA_HASHCODE_Xfa) { | 128 if (dwNameHash == XFA_HASHCODE_Xfa) { |
129 nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); | 129 nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); |
130 } else { | 130 } else { |
131 CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); | 131 CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); |
132 if (pObjNode) { | 132 if (pObjNode) { |
133 rnd.m_Nodes.Add(pObjNode); | 133 rnd.m_Nodes.Add(pObjNode); |
134 } | 134 } |
135 } | 135 } |
136 if (rnd.m_Nodes.GetSize() > 0) { | 136 if (rnd.m_Nodes.GetSize() > 0) { |
137 XFA_ResolveNode_FilterCondition(rnd, wsCondition); | 137 XFA_ResolveNode_FilterCondition(rnd, wsCondition); |
138 } | 138 } |
139 return rnd.m_Nodes.GetSize(); | 139 return rnd.m_Nodes.GetSize(); |
140 } | 140 } |
141 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( | 141 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( |
142 CXFA_ResolveNodesData& rnd) { | 142 CXFA_ResolveNodesData& rnd) { |
143 if (rnd.m_nLevel > 0) { | 143 if (rnd.m_nLevel > 0) { |
144 return 0; | 144 return 0; |
145 } | 145 } |
146 CXFA_Node* datasets = | 146 CXFA_Node* datasets = |
147 ToNode(rnd.m_pSC->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); | 147 ToNode(rnd.m_pSC->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); |
148 if (!datasets) { | 148 if (!datasets) { |
149 return 0; | 149 return 0; |
150 } | 150 } |
151 CXFA_ResolveNodesData rndFind; | 151 CXFA_ResolveNodesData rndFind; |
152 rndFind.m_pSC = rnd.m_pSC; | 152 rndFind.m_pSC = rnd.m_pSC; |
153 rndFind.m_CurNode = datasets; | 153 rndFind.m_CurNode = datasets; |
154 rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); | 154 rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); |
155 rndFind.m_uHashName = | 155 rndFind.m_uHashName = FX_HashCode_String_GetW(rndFind.m_wsName.c_str(), |
156 FX_HashCode_String_GetW(rndFind.m_wsName, rndFind.m_wsName.GetLength()); | 156 rndFind.m_wsName.GetLength()); |
157 rndFind.m_nLevel = rnd.m_nLevel + 1; | 157 rndFind.m_nLevel = rnd.m_nLevel + 1; |
158 rndFind.m_dwStyles = XFA_RESOLVENODE_Children; | 158 rndFind.m_dwStyles = XFA_RESOLVENODE_Children; |
159 rndFind.m_wsCondition = rnd.m_wsCondition; | 159 rndFind.m_wsCondition = rnd.m_wsCondition; |
160 XFA_ResolveNodes(rndFind); | 160 XFA_ResolveNodes(rndFind); |
161 if (rndFind.m_Nodes.GetSize() > 0) { | 161 if (rndFind.m_Nodes.GetSize() > 0) { |
162 rnd.m_Nodes.Append(rndFind.m_Nodes); | 162 rnd.m_Nodes.Append(rndFind.m_Nodes); |
163 rndFind.m_Nodes.RemoveAll(); | 163 rndFind.m_Nodes.RemoveAll(); |
164 } | 164 } |
165 return rnd.m_Nodes.GetSize(); | 165 return rnd.m_Nodes.GetSize(); |
166 } | 166 } |
167 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( | 167 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( |
168 CXFA_ResolveNodesData& rnd) { | 168 CXFA_ResolveNodesData& rnd) { |
169 CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); | 169 CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); |
170 CFX_WideString wsCondition = rnd.m_wsCondition; | 170 CFX_WideString wsCondition = rnd.m_wsCondition; |
171 CXFA_Node* curNode = ToNode(rnd.m_CurNode); | 171 CXFA_Node* curNode = ToNode(rnd.m_CurNode); |
172 if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsStringC())) { | 172 if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsStringC())) { |
173 return 1; | 173 return 1; |
174 } | 174 } |
175 CXFA_ResolveNodesData rndFind; | 175 CXFA_ResolveNodesData rndFind; |
176 rndFind.m_pSC = rnd.m_pSC; | 176 rndFind.m_pSC = rnd.m_pSC; |
177 rndFind.m_nLevel = rnd.m_nLevel + 1; | 177 rndFind.m_nLevel = rnd.m_nLevel + 1; |
178 rndFind.m_dwStyles = rnd.m_dwStyles; | 178 rndFind.m_dwStyles = rnd.m_dwStyles; |
179 rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName; | 179 rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName; |
180 rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes; | 180 rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes; |
181 rndFind.m_wsName = wsName; | 181 rndFind.m_wsName = wsName; |
182 rndFind.m_uHashName = | 182 rndFind.m_uHashName = FX_HashCode_String_GetW(rndFind.m_wsName.c_str(), |
183 FX_HashCode_String_GetW(rndFind.m_wsName, rndFind.m_wsName.GetLength()); | 183 rndFind.m_wsName.GetLength()); |
184 rndFind.m_wsCondition = wsCondition; | 184 rndFind.m_wsCondition = wsCondition; |
185 rndFind.m_CurNode = curNode; | 185 rndFind.m_CurNode = curNode; |
186 XFA_ResolveNodes_Normal(rndFind); | 186 XFA_ResolveNodes_Normal(rndFind); |
187 if (rndFind.m_Nodes.GetSize() > 0) { | 187 if (rndFind.m_Nodes.GetSize() > 0) { |
188 if (wsCondition.GetLength() == 0 && rndFind.m_Nodes.Find(curNode) >= 0) { | 188 if (wsCondition.GetLength() == 0 && rndFind.m_Nodes.Find(curNode) >= 0) { |
189 rnd.m_Nodes.Add(curNode); | 189 rnd.m_Nodes.Add(curNode); |
190 } else { | 190 } else { |
191 rnd.m_Nodes.Append(rndFind.m_Nodes); | 191 rnd.m_Nodes.Append(rndFind.m_Nodes); |
192 rndFind.m_Nodes.RemoveAll(); | 192 rndFind.m_Nodes.RemoveAll(); |
193 } | 193 } |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 611 } |
612 if (stack.GetSize() > 0) { | 612 if (stack.GetSize() > 0) { |
613 return -1; | 613 return -1; |
614 } | 614 } |
615 wsName.ReleaseBuffer(nNameCount); | 615 wsName.ReleaseBuffer(nNameCount); |
616 wsName.TrimLeft(); | 616 wsName.TrimLeft(); |
617 wsName.TrimRight(); | 617 wsName.TrimRight(); |
618 wsCondition.ReleaseBuffer(nConditionCount); | 618 wsCondition.ReleaseBuffer(nConditionCount); |
619 wsCondition.TrimLeft(); | 619 wsCondition.TrimLeft(); |
620 wsCondition.TrimRight(); | 620 wsCondition.TrimRight(); |
621 rnd.m_uHashName = FX_HashCode_String_GetW(wsName, wsName.GetLength()); | 621 rnd.m_uHashName = FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength()); |
622 return nStart; | 622 return nStart; |
623 } | 623 } |
624 void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( | 624 void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( |
625 int32_t iCurIndex, | 625 int32_t iCurIndex, |
626 CFX_WideString wsCondition, | 626 CFX_WideString wsCondition, |
627 int32_t iFoundCount, | 627 int32_t iFoundCount, |
628 CXFA_ResolveNodesData& rnd) { | 628 CXFA_ResolveNodesData& rnd) { |
629 CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; | 629 CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; |
630 int32_t iLen = wsCondition.GetLength(); | 630 int32_t iLen = wsCondition.GetLength(); |
631 FX_BOOL bRelative = FALSE; | 631 FX_BOOL bRelative = FALSE; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { | 820 if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { |
821 if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { | 821 if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { |
822 iIndex = 0; | 822 iIndex = 0; |
823 } else { | 823 } else { |
824 iIndex = iCount - 1; | 824 iIndex = iCount - 1; |
825 } | 825 } |
826 } else { | 826 } else { |
827 iIndex = iCount - 1; | 827 iIndex = iCount - 1; |
828 } | 828 } |
829 } | 829 } |
OLD | NEW |