Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Side by Side Diff: xfa/fxfa/parser/xfa_script_resolveprocessor.cpp

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 18 matching lines...) Expand all
29 m_pNodeHelper = NULL; 29 m_pNodeHelper = NULL;
30 } 30 }
31 } 31 }
32 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) { 32 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) {
33 if (rnd.m_CurNode == NULL) { 33 if (rnd.m_CurNode == NULL) {
34 return -1; 34 return -1;
35 } 35 }
36 if (!rnd.m_CurNode->IsNode()) { 36 if (!rnd.m_CurNode->IsNode()) {
37 if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) { 37 if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) {
38 return XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd, 38 return XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd,
39 rnd.m_wsName.AsWideStringC()); 39 rnd.m_wsName.AsStringC());
40 } 40 }
41 return 0; 41 return 0;
42 } 42 }
43 if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) { 43 if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) {
44 return XFA_ResolveNodes_AnyChild(rnd); 44 return XFA_ResolveNodes_AnyChild(rnd);
45 } 45 }
46 FX_WCHAR wch = rnd.m_wsName.GetAt(0); 46 FX_WCHAR wch = rnd.m_wsName.GetAt(0);
47 switch (wch) { 47 switch (wch) {
48 case '$': 48 case '$':
49 return XFA_ResolveNodes_Dollar(rnd); 49 return XFA_ResolveNodes_Dollar(rnd);
(...skipping 14 matching lines...) Expand all
64 return 1; 64 return 1;
65 } else if (rnd.m_CurNode->GetClassID() == XFA_ELEMENT_Xfa) { 65 } else if (rnd.m_CurNode->GetClassID() == XFA_ELEMENT_Xfa) {
66 CXFA_Object* pObjNode = 66 CXFA_Object* pObjNode =
67 rnd.m_pSC->GetDocument()->GetXFAObject(rnd.m_uHashName); 67 rnd.m_pSC->GetDocument()->GetXFAObject(rnd.m_uHashName);
68 if (pObjNode) { 68 if (pObjNode) {
69 rnd.m_Nodes.Add(pObjNode); 69 rnd.m_Nodes.Add(pObjNode);
70 } else if (rnd.m_uHashName == XFA_HASHCODE_Xfa) { 70 } else if (rnd.m_uHashName == XFA_HASHCODE_Xfa) {
71 rnd.m_Nodes.Add(rnd.m_CurNode); 71 rnd.m_Nodes.Add(rnd.m_CurNode);
72 } else if ((rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) && 72 } else if ((rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) &&
73 XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd, 73 XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd,
74 rnd.m_wsName.AsWideStringC())) { 74 rnd.m_wsName.AsStringC())) {
75 return 1; 75 return 1;
76 } 76 }
77 if (rnd.m_Nodes.GetSize() > 0) { 77 if (rnd.m_Nodes.GetSize() > 0) {
78 XFA_ResolveNode_FilterCondition(rnd, rnd.m_wsCondition); 78 XFA_ResolveNode_FilterCondition(rnd, rnd.m_wsCondition);
79 } 79 }
80 return rnd.m_Nodes.GetSize(); 80 return rnd.m_Nodes.GetSize();
81 } 81 }
82 int32_t nRet = XFA_ResolveNodes_Normal(rnd); 82 int32_t nRet = XFA_ResolveNodes_Normal(rnd);
83 if (nRet < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa) { 83 if (nRet < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa) {
84 rnd.m_Nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); 84 rnd.m_Nodes.Add(rnd.m_pSC->GetDocument()->GetRoot());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.AsWideStringC())) { 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 =
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 } 326 }
327 XFA_ResolveNode_FilterCondition(rnd, wsCondition); 327 XFA_ResolveNode_FilterCondition(rnd, wsCondition);
328 if (nodes.GetSize() > 0) { 328 if (nodes.GetSize() > 0) {
329 return 1; 329 return 1;
330 } 330 }
331 return 0; 331 return 0;
332 } 332 }
333 } 333 }
334 if (dwStyles & XFA_RESOLVENODE_Attributes) { 334 if (dwStyles & XFA_RESOLVENODE_Attributes) {
335 if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsWideStringC())) { 335 if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsStringC())) {
336 return 1; 336 return 1;
337 } 337 }
338 } 338 }
339 if (dwStyles & XFA_RESOLVENODE_Properties) { 339 if (dwStyles & XFA_RESOLVENODE_Properties) {
340 for (int32_t i = 0; i < properties.GetSize(); i++) { 340 for (int32_t i = 0; i < properties.GetSize(); i++) {
341 CXFA_Node* childProperty = properties[i]; 341 CXFA_Node* childProperty = properties[i];
342 if (childProperty->IsUnnamed()) { 342 if (childProperty->IsUnnamed()) {
343 uint32_t uPropHash = childProperty->GetClassHashCode(); 343 uint32_t uPropHash = childProperty->GetClassHashCode();
344 if (uPropHash == uNameHash) { 344 if (uPropHash == uNameHash) {
345 nodes.Add(childProperty); 345 nodes.Add(childProperty);
(...skipping 14 matching lines...) Expand all
360 CXFA_Node* pProp = NULL; 360 CXFA_Node* pProp = NULL;
361 if (XFA_ELEMENT_Subform == curNode->GetClassID() && 361 if (XFA_ELEMENT_Subform == curNode->GetClassID() &&
362 XFA_HASHCODE_Occur == uNameHash) { 362 XFA_HASHCODE_Occur == uNameHash) {
363 CXFA_Node* pInstanceManager = 363 CXFA_Node* pInstanceManager =
364 curNode->AsNode()->GetInstanceMgrOfSubform(); 364 curNode->AsNode()->GetInstanceMgrOfSubform();
365 if (pInstanceManager) { 365 if (pInstanceManager) {
366 pProp = pInstanceManager->GetProperty(0, XFA_ELEMENT_Occur, TRUE); 366 pProp = pInstanceManager->GetProperty(0, XFA_ELEMENT_Occur, TRUE);
367 } 367 }
368 } else { 368 } else {
369 const XFA_ELEMENTINFO* pElement = 369 const XFA_ELEMENTINFO* pElement =
370 XFA_GetElementByName(wsName.AsWideStringC()); 370 XFA_GetElementByName(wsName.AsStringC());
371 if (pElement) { 371 if (pElement) {
372 pProp = curNode->AsNode()->GetProperty( 372 pProp = curNode->AsNode()->GetProperty(
373 0, pElement->eName, pElement->eName != XFA_ELEMENT_PageSet); 373 0, pElement->eName, pElement->eName != XFA_ELEMENT_PageSet);
374 } 374 }
375 } 375 }
376 if (pProp) { 376 if (pProp) {
377 nodes.Add(pProp); 377 nodes.Add(pProp);
378 return nodes.GetSize(); 378 return nodes.GetSize();
379 } 379 }
380 } 380 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } else { 706 } else {
707 return; 707 return;
708 } 708 }
709 709
710 CXFA_ScriptContext* pContext = rnd.m_pSC; 710 CXFA_ScriptContext* pContext = rnd.m_pSC;
711 wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3); 711 wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3);
712 for (int32_t i = iFoundCount - 1; i >= 0; i--) { 712 for (int32_t i = iFoundCount - 1; i >= 0; i--) {
713 CXFA_Object* node = findNodes[i]; 713 CXFA_Object* node = findNodes[i];
714 FX_BOOL bRet = FALSE; 714 FX_BOOL bRet = FALSE;
715 FXJSE_HVALUE pRetValue = FXJSE_Value_Create(rnd.m_pSC->GetRuntime()); 715 FXJSE_HVALUE pRetValue = FXJSE_Value_Create(rnd.m_pSC->GetRuntime());
716 bRet = pContext->RunScript(eLangType, wsExpression.AsWideStringC(), 716 bRet = pContext->RunScript(eLangType, wsExpression.AsStringC(), pRetValue,
717 pRetValue, node); 717 node);
718 if (!bRet || !FXJSE_Value_ToBoolean(pRetValue)) { 718 if (!bRet || !FXJSE_Value_ToBoolean(pRetValue)) {
719 findNodes.RemoveAt(i); 719 findNodes.RemoveAt(i);
720 } 720 }
721 FXJSE_Value_Release(pRetValue); 721 FXJSE_Value_Release(pRetValue);
722 } 722 }
723 } 723 }
724 724
725 void CXFA_ResolveProcessor::XFA_ResolveNode_FilterCondition( 725 void CXFA_ResolveProcessor::XFA_ResolveNode_FilterCondition(
726 CXFA_ResolveNodesData& rnd, 726 CXFA_ResolveNodesData& rnd,
727 CFX_WideString wsCondition) { 727 CFX_WideString wsCondition) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_nodehelper.cpp ('k') | xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698