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 |
11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
12 #include "xfa/fgas/localization/fgas_locale.h" | 12 #include "xfa/fgas/localization/fgas_locale.h" |
| 13 #include "xfa/fxfa/app/xfa_ffnotify.h" |
13 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 14 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
14 #include "xfa/fxfa/parser/xfa_document.h" | 15 #include "xfa/fxfa/parser/xfa_document.h" |
15 #include "xfa/fxfa/parser/xfa_localevalue.h" | 16 #include "xfa/fxfa/parser/xfa_localevalue.h" |
16 #include "xfa/fxfa/parser/xfa_parser.h" | 17 #include "xfa/fxfa/parser/xfa_parser.h" |
| 18 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
| 19 #include "xfa/fxfa/parser/xfa_script_imp.h" |
17 #include "xfa/fxjse/cfxjse_arguments.h" | 20 #include "xfa/fxjse/cfxjse_arguments.h" |
18 | 21 |
19 #define FINANCIAL_PRECISION 0.00000001 | 22 #define FINANCIAL_PRECISION 0.00000001 |
20 | 23 |
21 namespace { | 24 namespace { |
22 | 25 |
23 struct XFA_FMHtmlReserveCode { | 26 struct XFA_FMHtmlReserveCode { |
24 uint32_t m_uCode; | 27 uint32_t m_uCode; |
25 const FX_WCHAR* m_htmlReserve; | 28 const FX_WCHAR* m_htmlReserve; |
26 }; | 29 }; |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 XFA_VT_TIME, | 1592 XFA_VT_TIME, |
1590 CFX_WideString::FromUTF8(timeString, timeString.GetLength()), | 1593 CFX_WideString::FromUTF8(timeString, timeString.GetLength()), |
1591 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 1594 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
1592 if (timeValue.IsValid()) { | 1595 if (timeValue.IsValid()) { |
1593 CFX_Unitime uniTime = timeValue.GetTime(); | 1596 CFX_Unitime uniTime = timeValue.GetTime(); |
1594 int32_t hour = uniTime.GetHour(); | 1597 int32_t hour = uniTime.GetHour(); |
1595 int32_t min = uniTime.GetMinute(); | 1598 int32_t min = uniTime.GetMinute(); |
1596 int32_t second = uniTime.GetSecond(); | 1599 int32_t second = uniTime.GetSecond(); |
1597 int32_t milSecond = uniTime.GetMillisecond(); | 1600 int32_t milSecond = uniTime.GetMillisecond(); |
1598 int32_t mins = hour * 60 + min; | 1601 int32_t mins = hour * 60 + min; |
1599 IXFA_TimeZoneProvider* pProvider = IXFA_TimeZoneProvider::Get(); | 1602 CXFA_TimeZoneProvider* pProvider = CXFA_TimeZoneProvider::Get(); |
1600 if (pProvider) { | 1603 if (pProvider) { |
1601 FX_TIMEZONE tz; | 1604 FX_TIMEZONE tz; |
1602 pProvider->GetTimeZone(tz); | 1605 pProvider->GetTimeZone(tz); |
1603 mins -= (tz.tzHour * 60); | 1606 mins -= (tz.tzHour * 60); |
1604 while (mins > 1440) { | 1607 while (mins > 1440) { |
1605 mins -= 1440; | 1608 mins -= 1440; |
1606 } | 1609 } |
1607 while (mins < 0) { | 1610 while (mins < 0) { |
1608 mins += 1440; | 1611 mins += 1440; |
1609 } | 1612 } |
(...skipping 5218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6828 FXJSE_HOBJECT hThis, | 6831 FXJSE_HOBJECT hThis, |
6829 FXJSE_HVALUE accessorValue, | 6832 FXJSE_HVALUE accessorValue, |
6830 const CFX_ByteStringC& szAccessorName) { | 6833 const CFX_ByteStringC& szAccessorName) { |
6831 FX_BOOL bFlags = FALSE; | 6834 FX_BOOL bFlags = FALSE; |
6832 CXFA_FM2JSContext* pContext = | 6835 CXFA_FM2JSContext* pContext = |
6833 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6836 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
6834 CXFA_Document* pDoc = pContext->GetDocument(); | 6837 CXFA_Document* pDoc = pContext->GetDocument(); |
6835 if (!pDoc) { | 6838 if (!pDoc) { |
6836 return bFlags; | 6839 return bFlags; |
6837 } | 6840 } |
6838 IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6841 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6839 XFA_RESOLVENODE_RS resoveNodeRS; | 6842 XFA_RESOLVENODE_RS resoveNodeRS; |
6840 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6843 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
6841 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6844 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
6842 int32_t iRet = pScriptContext->ResolveObjects( | 6845 int32_t iRet = pScriptContext->ResolveObjects( |
6843 pScriptContext->GetThisObject(), | 6846 pScriptContext->GetThisObject(), |
6844 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), | 6847 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), |
6845 szAccessorName.GetLength()), | 6848 szAccessorName.GetLength()), |
6846 resoveNodeRS, dwFlags); | 6849 resoveNodeRS, dwFlags); |
6847 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6850 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
6848 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6851 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
(...skipping 10 matching lines...) Expand all Loading... |
6859 FX_BOOL bHasNoResolveName) { | 6862 FX_BOOL bHasNoResolveName) { |
6860 CFX_WideString wsSomExpression = | 6863 CFX_WideString wsSomExpression = |
6861 CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); | 6864 CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); |
6862 int32_t iRet = -1; | 6865 int32_t iRet = -1; |
6863 CXFA_FM2JSContext* pContext = | 6866 CXFA_FM2JSContext* pContext = |
6864 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6867 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
6865 CXFA_Document* pDoc = pContext->GetDocument(); | 6868 CXFA_Document* pDoc = pContext->GetDocument(); |
6866 if (!pDoc) { | 6869 if (!pDoc) { |
6867 return iRet; | 6870 return iRet; |
6868 } | 6871 } |
6869 IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6872 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6870 CXFA_Object* pNode = NULL; | 6873 CXFA_Object* pNode = NULL; |
6871 uint32_t dFlags = 0UL; | 6874 uint32_t dFlags = 0UL; |
6872 if (bdotAccessor) { | 6875 if (bdotAccessor) { |
6873 if (FXJSE_Value_IsNull(hRefValue)) { | 6876 if (FXJSE_Value_IsNull(hRefValue)) { |
6874 pNode = pScriptContext->GetThisObject(); | 6877 pNode = pScriptContext->GetThisObject(); |
6875 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6878 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
6876 } else { | 6879 } else { |
6877 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); | 6880 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); |
6878 FXSYS_assert(pNode); | 6881 FXSYS_assert(pNode); |
6879 if (bHasNoResolveName) { | 6882 if (bHasNoResolveName) { |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7215 FXSYS_assert(pAppProvider); | 7218 FXSYS_assert(pAppProvider); |
7216 CFX_WideString wsFormat; | 7219 CFX_WideString wsFormat; |
7217 pAppProvider->LoadString(iStringID, wsFormat); | 7220 pAppProvider->LoadString(iStringID, wsFormat); |
7218 CFX_WideString wsMessage; | 7221 CFX_WideString wsMessage; |
7219 va_list arg_ptr; | 7222 va_list arg_ptr; |
7220 va_start(arg_ptr, iStringID); | 7223 va_start(arg_ptr, iStringID); |
7221 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7224 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
7222 va_end(arg_ptr); | 7225 va_end(arg_ptr); |
7223 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); | 7226 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); |
7224 } | 7227 } |
OLD | NEW |