| 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/fm2js/xfa_fm2jsapi.h" | 9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
| 10 #include "xfa/fxfa/parser/xfa_basic_imp.h" | 10 #include "xfa/fxfa/parser/xfa_basic_imp.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 CXFA_ScriptContext* CXFA_Document::GetScriptContext() { | 257 CXFA_ScriptContext* CXFA_Document::GetScriptContext() { |
| 258 if (!m_pScriptContext) | 258 if (!m_pScriptContext) |
| 259 m_pScriptContext = new CXFA_ScriptContext(this); | 259 m_pScriptContext = new CXFA_ScriptContext(this); |
| 260 return m_pScriptContext; | 260 return m_pScriptContext; |
| 261 } | 261 } |
| 262 XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( | 262 XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( |
| 263 CFX_WideString& wsTemplateNS) { | 263 CFX_WideString& wsTemplateNS) { |
| 264 CFX_WideStringC wsTemplateURIPrefix = | 264 CFX_WideStringC wsTemplateURIPrefix = |
| 265 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI; | 265 XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI; |
| 266 FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength(); | 266 FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength(); |
| 267 if (CFX_WideStringC(wsTemplateNS, wsTemplateNS.GetLength()) != | 267 if (CFX_WideStringC(wsTemplateNS.c_str(), wsTemplateNS.GetLength()) != |
| 268 wsTemplateURIPrefix) { | 268 wsTemplateURIPrefix) { |
| 269 return XFA_VERSION_UNKNOWN; | 269 return XFA_VERSION_UNKNOWN; |
| 270 } | 270 } |
| 271 FX_STRSIZE nDotPos = wsTemplateNS.Find('.', nPrefixLength); | 271 FX_STRSIZE nDotPos = wsTemplateNS.Find('.', nPrefixLength); |
| 272 if (nDotPos == (FX_STRSIZE)-1) { | 272 if (nDotPos == (FX_STRSIZE)-1) { |
| 273 return XFA_VERSION_UNKNOWN; | 273 return XFA_VERSION_UNKNOWN; |
| 274 } | 274 } |
| 275 int8_t iMajor = | 275 int8_t iMajor = FXSYS_wtoi( |
| 276 FXSYS_wtoi(wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength)); | 276 wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength).c_str()); |
| 277 int8_t iMinor = FXSYS_wtoi( | 277 int8_t iMinor = FXSYS_wtoi( |
| 278 wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2)); | 278 wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2) |
| 279 .c_str()); |
| 279 XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor); | 280 XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor); |
| 280 if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX) { | 281 if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX) { |
| 281 return XFA_VERSION_UNKNOWN; | 282 return XFA_VERSION_UNKNOWN; |
| 282 } | 283 } |
| 283 m_eCurVersionMode = eVersion; | 284 m_eCurVersionMode = eVersion; |
| 284 return eVersion; | 285 return eVersion; |
| 285 } | 286 } |
| 286 CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot, | 287 CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot, |
| 287 const CFX_WideStringC& wsID) { | 288 const CFX_WideStringC& wsID) { |
| 288 if (!pRoot || wsID.IsEmpty()) { | 289 if (!pRoot || wsID.IsEmpty()) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 CXFA_Node* pUseHrefNode = NULL; | 384 CXFA_Node* pUseHrefNode = NULL; |
| 384 sUseNodes.GetNextAssoc(pos, pUseHrefNode); | 385 sUseNodes.GetNextAssoc(pos, pUseHrefNode); |
| 385 CFX_WideString wsUseVal; | 386 CFX_WideString wsUseVal; |
| 386 CFX_WideStringC wsURI, wsID, wsSOM; | 387 CFX_WideStringC wsURI, wsID, wsSOM; |
| 387 if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) && | 388 if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) && |
| 388 !wsUseVal.IsEmpty()) { | 389 !wsUseVal.IsEmpty()) { |
| 389 FX_STRSIZE uSharpPos = wsUseVal.Find('#'); | 390 FX_STRSIZE uSharpPos = wsUseVal.Find('#'); |
| 390 if (uSharpPos < 0) { | 391 if (uSharpPos < 0) { |
| 391 wsURI = wsUseVal; | 392 wsURI = wsUseVal; |
| 392 } else { | 393 } else { |
| 393 wsURI = CFX_WideStringC((const FX_WCHAR*)wsUseVal, uSharpPos); | 394 wsURI = CFX_WideStringC(wsUseVal.c_str(), uSharpPos); |
| 394 FX_STRSIZE uLen = wsUseVal.GetLength(); | 395 FX_STRSIZE uLen = wsUseVal.GetLength(); |
| 395 if (uLen >= uSharpPos + 5 && | 396 if (uLen >= uSharpPos + 5 && |
| 396 CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos, 5) == | 397 CFX_WideStringC(wsUseVal.c_str() + uSharpPos, 5) == |
| 397 FX_WSTRC(L"#som(") && | 398 FX_WSTRC(L"#som(") && |
| 398 wsUseVal[uLen - 1] == ')') { | 399 wsUseVal[uLen - 1] == ')') { |
| 399 wsSOM = CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos + 5, | 400 wsSOM = CFX_WideStringC(wsUseVal.c_str() + uSharpPos + 5, |
| 400 uLen - 1 - uSharpPos - 5); | 401 uLen - 1 - uSharpPos - 5); |
| 401 } else { | 402 } else { |
| 402 wsID = CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos + 1, | 403 wsID = CFX_WideStringC(wsUseVal.c_str() + uSharpPos + 1, |
| 403 uLen - uSharpPos - 1); | 404 uLen - uSharpPos - 1); |
| 404 } | 405 } |
| 405 } | 406 } |
| 406 } else if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && | 407 } else if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && |
| 407 !wsUseVal.IsEmpty()) { | 408 !wsUseVal.IsEmpty()) { |
| 408 if (wsUseVal[0] == '#') { | 409 if (wsUseVal[0] == '#') { |
| 409 wsID = CFX_WideStringC((const FX_WCHAR*)wsUseVal + 1, | 410 wsID = CFX_WideStringC(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1); |
| 410 wsUseVal.GetLength() - 1); | |
| 411 } else { | 411 } else { |
| 412 wsSOM = | 412 wsSOM = CFX_WideStringC(wsUseVal.c_str(), wsUseVal.GetLength()); |
| 413 CFX_WideStringC((const FX_WCHAR*)wsUseVal, wsUseVal.GetLength()); | |
| 414 } | 413 } |
| 415 } | 414 } |
| 416 if (!wsURI.IsEmpty() && wsURI != FX_WSTRC(L".")) { | 415 if (!wsURI.IsEmpty() && wsURI != FX_WSTRC(L".")) { |
| 417 continue; | 416 continue; |
| 418 } | 417 } |
| 419 CXFA_Node* pProtoNode = NULL; | 418 CXFA_Node* pProtoNode = NULL; |
| 420 if (!wsSOM.IsEmpty()) { | 419 if (!wsSOM.IsEmpty()) { |
| 421 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 420 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
| 422 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | | 421 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | |
| 423 XFA_RESOLVENODE_Siblings; | 422 XFA_RESOLVENODE_Siblings; |
| 424 XFA_RESOLVENODE_RS resoveNodeRS; | 423 XFA_RESOLVENODE_RS resoveNodeRS; |
| 425 int32_t iRet = m_pScriptContext->ResolveObjects(pUseHrefNode, wsSOM, | 424 int32_t iRet = m_pScriptContext->ResolveObjects(pUseHrefNode, wsSOM, |
| 426 resoveNodeRS, dwFlag); | 425 resoveNodeRS, dwFlag); |
| 427 if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { | 426 if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { |
| 428 pProtoNode = resoveNodeRS.nodes[0]->AsNode(); | 427 pProtoNode = resoveNodeRS.nodes[0]->AsNode(); |
| 429 } | 428 } |
| 430 } else if (!wsID.IsEmpty()) { | 429 } else if (!wsID.IsEmpty()) { |
| 431 if (!mIDMap.Lookup( | 430 if (!mIDMap.Lookup( |
| 432 FX_HashCode_String_GetW(wsID.c_str(), wsID.GetLength()), | 431 FX_HashCode_String_GetW(wsID.c_str(), wsID.GetLength()), |
| 433 pProtoNode)) { | 432 pProtoNode)) { |
| 434 continue; | 433 continue; |
| 435 } | 434 } |
| 436 } | 435 } |
| 437 if (!pProtoNode) { | 436 if (!pProtoNode) { |
| 438 continue; | 437 continue; |
| 439 } | 438 } |
| 440 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); | 439 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); |
| 441 } | 440 } |
| 442 } | 441 } |
| OLD | NEW |