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/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 5554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5565 } | 5565 } |
5566 | 5566 |
5567 XFA_RESOLVENODE_RS resoveNodeRS; | 5567 XFA_RESOLVENODE_RS resoveNodeRS; |
5568 int32_t iRet = 0; | 5568 int32_t iRet = 0; |
5569 CFX_ByteString bsAccessorName = args.GetUTF8String(1); | 5569 CFX_ByteString bsAccessorName = args.GetUTF8String(1); |
5570 if (argAccessor->IsObject() || | 5570 if (argAccessor->IsObject() || |
5571 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { | 5571 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { |
5572 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5572 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
5573 resoveNodeRS, TRUE, szName.IsEmpty()); | 5573 resoveNodeRS, TRUE, szName.IsEmpty()); |
5574 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && | 5574 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && |
5575 GetObjectByName(pThis, argAccessor.get(), | 5575 GetObjectForName(pThis, argAccessor.get(), |
5576 bsAccessorName.AsStringC())) { | 5576 bsAccessorName.AsStringC())) { |
5577 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5577 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
5578 resoveNodeRS, TRUE, szName.IsEmpty()); | 5578 resoveNodeRS, TRUE, szName.IsEmpty()); |
5579 } | 5579 } |
5580 if (iRet < 1) { | 5580 if (iRet < 1) { |
5581 CFX_WideString wsPropertyName = | 5581 CFX_WideString wsPropertyName = |
5582 CFX_WideString::FromUTF8(szName.AsStringC()); | 5582 CFX_WideString::FromUTF8(szName.AsStringC()); |
5583 CFX_WideString wsSomExpression = | 5583 CFX_WideString wsSomExpression = |
5584 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 5584 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
5585 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 5585 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
5586 wsPropertyName.c_str(), wsSomExpression.c_str()); | 5586 wsPropertyName.c_str(), wsSomExpression.c_str()); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5703 } | 5703 } |
5704 | 5704 |
5705 XFA_RESOLVENODE_RS resoveNodeRS; | 5705 XFA_RESOLVENODE_RS resoveNodeRS; |
5706 int32_t iRet = 0; | 5706 int32_t iRet = 0; |
5707 CFX_ByteString bsAccessorName = args.GetUTF8String(1); | 5707 CFX_ByteString bsAccessorName = args.GetUTF8String(1); |
5708 if (argAccessor->IsObject() || | 5708 if (argAccessor->IsObject() || |
5709 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { | 5709 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { |
5710 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5710 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
5711 resoveNodeRS, FALSE); | 5711 resoveNodeRS, FALSE); |
5712 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && | 5712 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && |
5713 GetObjectByName(pThis, argAccessor.get(), | 5713 GetObjectForName(pThis, argAccessor.get(), |
5714 bsAccessorName.AsStringC())) { | 5714 bsAccessorName.AsStringC())) { |
5715 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5715 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
5716 resoveNodeRS, FALSE); | 5716 resoveNodeRS, FALSE); |
5717 } | 5717 } |
5718 if (iRet < 1) { | 5718 if (iRet < 1) { |
5719 CFX_WideString wsPropertyName = | 5719 CFX_WideString wsPropertyName = |
5720 CFX_WideString::FromUTF8(szName.AsStringC()); | 5720 CFX_WideString::FromUTF8(szName.AsStringC()); |
5721 CFX_WideString wsSomExpression = | 5721 CFX_WideString wsSomExpression = |
5722 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 5722 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
5723 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 5723 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
5724 wsPropertyName.c_str(), wsSomExpression.c_str()); | 5724 wsPropertyName.c_str(), wsSomExpression.c_str()); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6196 szSomExp += "]"; | 6196 szSomExp += "]"; |
6197 } else { | 6197 } else { |
6198 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); | 6198 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); |
6199 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; | 6199 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; |
6200 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6200 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
6201 szSomExp += "]"; | 6201 szSomExp += "]"; |
6202 } | 6202 } |
6203 } | 6203 } |
6204 | 6204 |
6205 // static | 6205 // static |
6206 FX_BOOL CXFA_FM2JSContext::GetObjectByName( | 6206 FX_BOOL CXFA_FM2JSContext::GetObjectForName( |
6207 CFXJSE_Value* pThis, | 6207 CFXJSE_Value* pThis, |
6208 CFXJSE_Value* accessorValue, | 6208 CFXJSE_Value* accessorValue, |
6209 const CFX_ByteStringC& szAccessorName) { | 6209 const CFX_ByteStringC& szAccessorName) { |
6210 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); | 6210 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); |
6211 if (!pDoc) | 6211 if (!pDoc) |
6212 return FALSE; | 6212 return FALSE; |
6213 | 6213 |
6214 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6214 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6215 XFA_RESOLVENODE_RS resoveNodeRS; | 6215 XFA_RESOLVENODE_RS resoveNodeRS; |
6216 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6216 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6518 CFX_WideString wsFormat; | 6518 CFX_WideString wsFormat; |
6519 pAppProvider->LoadString(iStringID, wsFormat); | 6519 pAppProvider->LoadString(iStringID, wsFormat); |
6520 CFX_WideString wsMessage; | 6520 CFX_WideString wsMessage; |
6521 va_list arg_ptr; | 6521 va_list arg_ptr; |
6522 va_start(arg_ptr, iStringID); | 6522 va_start(arg_ptr, iStringID); |
6523 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6523 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
6524 va_end(arg_ptr); | 6524 va_end(arg_ptr); |
6525 FXJSE_ThrowMessage( | 6525 FXJSE_ThrowMessage( |
6526 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6526 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
6527 } | 6527 } |
OLD | NEW |