| 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 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1582 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 1583 IFX_Locale* pLocale = NULL; | 1583 IFX_Locale* pLocale = NULL; |
| 1584 if (localString.IsEmpty()) { | 1584 if (localString.IsEmpty()) { |
| 1585 CXFA_Node* pThisNode = | 1585 CXFA_Node* pThisNode = |
| 1586 ToNode(pDoc->GetScriptContext()->GetThisObject()); | 1586 ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 1587 FXSYS_assert(pThisNode); | 1587 FXSYS_assert(pThisNode); |
| 1588 CXFA_WidgetData widgetData(pThisNode); | 1588 CXFA_WidgetData widgetData(pThisNode); |
| 1589 pLocale = widgetData.GetLocal(); | 1589 pLocale = widgetData.GetLocal(); |
| 1590 } else { | 1590 } else { |
| 1591 pLocale = pMgr->GetLocaleByName( | 1591 pLocale = pMgr->GetLocaleByName( |
| 1592 CFX_WideString::FromUTF8(localString, localString.GetLength())); | 1592 CFX_WideString::FromUTF8(localString, localString.GetLength()) |
| 1593 .AsWideStringC()); |
| 1593 } | 1594 } |
| 1594 CFX_WideString wsFormat; | 1595 CFX_WideString wsFormat; |
| 1595 if (formatString.IsEmpty()) { | 1596 if (formatString.IsEmpty()) { |
| 1596 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 1597 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 1597 } else { | 1598 } else { |
| 1598 wsFormat = | 1599 wsFormat = |
| 1599 CFX_WideString::FromUTF8(formatString, formatString.GetLength()); | 1600 CFX_WideString::FromUTF8(formatString, formatString.GetLength()); |
| 1600 } | 1601 } |
| 1601 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 1602 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 1602 wsFormat += FX_WSTRC(L"}"); | 1603 wsFormat += FX_WSTRC(L"}"); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 } | 2033 } |
| 2033 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2034 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2034 IFX_Locale* pLocale = NULL; | 2035 IFX_Locale* pLocale = NULL; |
| 2035 if (szLocale.IsEmpty()) { | 2036 if (szLocale.IsEmpty()) { |
| 2036 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2037 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2037 FXSYS_assert(pThisNode); | 2038 FXSYS_assert(pThisNode); |
| 2038 CXFA_WidgetData widgetData(pThisNode); | 2039 CXFA_WidgetData widgetData(pThisNode); |
| 2039 pLocale = widgetData.GetLocal(); | 2040 pLocale = widgetData.GetLocal(); |
| 2040 } else { | 2041 } else { |
| 2041 pLocale = pMgr->GetLocaleByName( | 2042 pLocale = pMgr->GetLocaleByName( |
| 2042 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); | 2043 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) |
| 2044 .AsWideStringC()); |
| 2043 } | 2045 } |
| 2044 if (!pLocale) { | 2046 if (!pLocale) { |
| 2045 return FALSE; | 2047 return FALSE; |
| 2046 } | 2048 } |
| 2047 CFX_WideString wsFormat; | 2049 CFX_WideString wsFormat; |
| 2048 if (szFormat.IsEmpty()) { | 2050 if (szFormat.IsEmpty()) { |
| 2049 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2051 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2050 } else { | 2052 } else { |
| 2051 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2053 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2052 } | 2054 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2070 } | 2072 } |
| 2071 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2073 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2072 IFX_Locale* pLocale = NULL; | 2074 IFX_Locale* pLocale = NULL; |
| 2073 if (szLocale.IsEmpty()) { | 2075 if (szLocale.IsEmpty()) { |
| 2074 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2076 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2075 FXSYS_assert(pThisNode); | 2077 FXSYS_assert(pThisNode); |
| 2076 CXFA_WidgetData widgetData(pThisNode); | 2078 CXFA_WidgetData widgetData(pThisNode); |
| 2077 pLocale = widgetData.GetLocal(); | 2079 pLocale = widgetData.GetLocal(); |
| 2078 } else { | 2080 } else { |
| 2079 pLocale = pMgr->GetLocaleByName( | 2081 pLocale = pMgr->GetLocaleByName( |
| 2080 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); | 2082 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) |
| 2083 .AsWideStringC()); |
| 2081 } | 2084 } |
| 2082 if (!pLocale) { | 2085 if (!pLocale) { |
| 2083 return FALSE; | 2086 return FALSE; |
| 2084 } | 2087 } |
| 2085 CFX_WideString wsFormat; | 2088 CFX_WideString wsFormat; |
| 2086 if (szFormat.IsEmpty()) { | 2089 if (szFormat.IsEmpty()) { |
| 2087 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2090 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2088 } else { | 2091 } else { |
| 2089 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2092 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2090 } | 2093 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2111 } | 2114 } |
| 2112 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2115 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2113 IFX_Locale* pLocale = NULL; | 2116 IFX_Locale* pLocale = NULL; |
| 2114 if (szLocale.IsEmpty()) { | 2117 if (szLocale.IsEmpty()) { |
| 2115 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2118 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2116 FXSYS_assert(pThisNode); | 2119 FXSYS_assert(pThisNode); |
| 2117 CXFA_WidgetData widgetData(pThisNode); | 2120 CXFA_WidgetData widgetData(pThisNode); |
| 2118 pLocale = widgetData.GetLocal(); | 2121 pLocale = widgetData.GetLocal(); |
| 2119 } else { | 2122 } else { |
| 2120 pLocale = pMgr->GetLocaleByName( | 2123 pLocale = pMgr->GetLocaleByName( |
| 2121 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); | 2124 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) |
| 2125 .AsWideStringC()); |
| 2122 } | 2126 } |
| 2123 if (!pLocale) { | 2127 if (!pLocale) { |
| 2124 return FALSE; | 2128 return FALSE; |
| 2125 } | 2129 } |
| 2126 CFX_WideString wsFormat; | 2130 CFX_WideString wsFormat; |
| 2127 if (szFormat.IsEmpty()) { | 2131 if (szFormat.IsEmpty()) { |
| 2128 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2132 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2129 } else { | 2133 } else { |
| 2130 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2134 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2131 } | 2135 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2151 } | 2155 } |
| 2152 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2156 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2153 IFX_Locale* pLocale = NULL; | 2157 IFX_Locale* pLocale = NULL; |
| 2154 if (szLocale.IsEmpty()) { | 2158 if (szLocale.IsEmpty()) { |
| 2155 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2159 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2156 FXSYS_assert(pThisNode); | 2160 FXSYS_assert(pThisNode); |
| 2157 CXFA_WidgetData widgetData(pThisNode); | 2161 CXFA_WidgetData widgetData(pThisNode); |
| 2158 pLocale = widgetData.GetLocal(); | 2162 pLocale = widgetData.GetLocal(); |
| 2159 } else { | 2163 } else { |
| 2160 pLocale = pMgr->GetLocaleByName( | 2164 pLocale = pMgr->GetLocaleByName( |
| 2161 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); | 2165 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) |
| 2166 .AsWideStringC()); |
| 2162 } | 2167 } |
| 2163 if (!pLocale) { | 2168 if (!pLocale) { |
| 2164 return FALSE; | 2169 return FALSE; |
| 2165 } | 2170 } |
| 2166 CFX_WideString wsFormat; | 2171 CFX_WideString wsFormat; |
| 2167 if (szFormat.IsEmpty()) { | 2172 if (szFormat.IsEmpty()) { |
| 2168 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2173 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2169 } else { | 2174 } else { |
| 2170 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2175 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2171 } | 2176 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2193 } | 2198 } |
| 2194 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2199 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2195 IFX_Locale* pLocale = NULL; | 2200 IFX_Locale* pLocale = NULL; |
| 2196 if (szLocale.IsEmpty()) { | 2201 if (szLocale.IsEmpty()) { |
| 2197 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2202 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2198 FXSYS_assert(pThisNode); | 2203 FXSYS_assert(pThisNode); |
| 2199 CXFA_WidgetData widgetData(pThisNode); | 2204 CXFA_WidgetData widgetData(pThisNode); |
| 2200 pLocale = widgetData.GetLocal(); | 2205 pLocale = widgetData.GetLocal(); |
| 2201 } else { | 2206 } else { |
| 2202 pLocale = pMgr->GetLocaleByName( | 2207 pLocale = pMgr->GetLocaleByName( |
| 2203 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); | 2208 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) |
| 2209 .AsWideStringC()); |
| 2204 } | 2210 } |
| 2205 if (!pLocale) { | 2211 if (!pLocale) { |
| 2206 return FALSE; | 2212 return FALSE; |
| 2207 } | 2213 } |
| 2208 CFX_WideString wsFormat; | 2214 CFX_WideString wsFormat; |
| 2209 if (szFormat.IsEmpty()) { | 2215 if (szFormat.IsEmpty()) { |
| 2210 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2216 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2211 } else { | 2217 } else { |
| 2212 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2218 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2213 } | 2219 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2376 } | 2382 } |
| 2377 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2383 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2378 IFX_Locale* pLocale = NULL; | 2384 IFX_Locale* pLocale = NULL; |
| 2379 if (szLocalStr.IsEmpty()) { | 2385 if (szLocalStr.IsEmpty()) { |
| 2380 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2386 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2381 FXSYS_assert(pThisNode); | 2387 FXSYS_assert(pThisNode); |
| 2382 CXFA_WidgetData widgetData(pThisNode); | 2388 CXFA_WidgetData widgetData(pThisNode); |
| 2383 pLocale = widgetData.GetLocal(); | 2389 pLocale = widgetData.GetLocal(); |
| 2384 } else { | 2390 } else { |
| 2385 pLocale = pMgr->GetLocaleByName( | 2391 pLocale = pMgr->GetLocaleByName( |
| 2386 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength())); | 2392 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength()) |
| 2393 .AsWideStringC()); |
| 2387 } | 2394 } |
| 2388 if (!pLocale) { | 2395 if (!pLocale) { |
| 2389 return; | 2396 return; |
| 2390 } | 2397 } |
| 2391 CFX_WideString strRet; | 2398 CFX_WideString strRet; |
| 2392 pLocale->GetDatePattern(strStyle, strRet); | 2399 pLocale->GetDatePattern(strStyle, strRet); |
| 2393 if (!bStandard) { | 2400 if (!bStandard) { |
| 2394 CFX_WideString wsSymbols; | 2401 CFX_WideString wsSymbols; |
| 2395 pLocale->GetDateTimeSymbols(wsSymbols); | 2402 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2396 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); | 2403 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2431 } | 2438 } |
| 2432 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2439 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2433 IFX_Locale* pLocale = NULL; | 2440 IFX_Locale* pLocale = NULL; |
| 2434 if (szLocalStr.IsEmpty()) { | 2441 if (szLocalStr.IsEmpty()) { |
| 2435 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2442 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2436 FXSYS_assert(pThisNode); | 2443 FXSYS_assert(pThisNode); |
| 2437 CXFA_WidgetData widgetData(pThisNode); | 2444 CXFA_WidgetData widgetData(pThisNode); |
| 2438 pLocale = widgetData.GetLocal(); | 2445 pLocale = widgetData.GetLocal(); |
| 2439 } else { | 2446 } else { |
| 2440 pLocale = pMgr->GetLocaleByName( | 2447 pLocale = pMgr->GetLocaleByName( |
| 2441 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength())); | 2448 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength()) |
| 2449 .AsWideStringC()); |
| 2442 } | 2450 } |
| 2443 if (!pLocale) { | 2451 if (!pLocale) { |
| 2444 return; | 2452 return; |
| 2445 } | 2453 } |
| 2446 CFX_WideString strRet; | 2454 CFX_WideString strRet; |
| 2447 pLocale->GetTimePattern(strStyle, strRet); | 2455 pLocale->GetTimePattern(strStyle, strRet); |
| 2448 if (!bStandard) { | 2456 if (!bStandard) { |
| 2449 CFX_WideString wsSymbols; | 2457 CFX_WideString wsSymbols; |
| 2450 pLocale->GetDateTimeSymbols(wsSymbols); | 2458 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2451 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); | 2459 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3250 if (args.GetLength() == 1) { | 3258 if (args.GetLength() == 1) { |
| 3251 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); | 3259 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); |
| 3252 CFX_ByteString utf8ScriptString; | 3260 CFX_ByteString utf8ScriptString; |
| 3253 HValueToUTF8String(scriptValue, utf8ScriptString); | 3261 HValueToUTF8String(scriptValue, utf8ScriptString); |
| 3254 if (utf8ScriptString.IsEmpty()) { | 3262 if (utf8ScriptString.IsEmpty()) { |
| 3255 FXJSE_Value_SetNull(args.GetReturnValue()); | 3263 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3256 } else { | 3264 } else { |
| 3257 CFX_WideTextBuf wsJavaScriptBuf; | 3265 CFX_WideTextBuf wsJavaScriptBuf; |
| 3258 CFX_WideString javaScript; | 3266 CFX_WideString javaScript; |
| 3259 CFX_WideString wsError; | 3267 CFX_WideString wsError; |
| 3260 XFA_FM2JS_Translate(CFX_WideString::FromUTF8( | 3268 XFA_FM2JS_Translate(CFX_WideString::FromUTF8(utf8ScriptString, |
| 3261 utf8ScriptString, utf8ScriptString.GetLength()), | 3269 utf8ScriptString.GetLength()) |
| 3270 .AsWideStringC(), |
| 3262 wsJavaScriptBuf, wsError); | 3271 wsJavaScriptBuf, wsError); |
| 3263 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); | 3272 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); |
| 3264 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); | 3273 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); |
| 3265 javaScript = wsJavaScriptBuf.GetWideString(); | 3274 javaScript = wsJavaScriptBuf.GetWideString(); |
| 3266 FXJSE_ExecuteScript(hContext, | 3275 FXJSE_ExecuteScript(hContext, |
| 3267 FX_UTF8Encode(javaScript, javaScript.GetLength()), | 3276 FX_UTF8Encode(javaScript, javaScript.GetLength()), |
| 3268 returnValue); | 3277 returnValue); |
| 3269 FXJSE_Value_Set(args.GetReturnValue(), returnValue); | 3278 FXJSE_Value_Set(args.GetReturnValue(), returnValue); |
| 3270 FXJSE_Value_Release(returnValue); | 3279 FXJSE_Value_Release(returnValue); |
| 3271 FXJSE_Context_Release(hContext); | 3280 FXJSE_Context_Release(hContext); |
| (...skipping 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5474 } | 5483 } |
| 5475 IXFA_AppProvider* pAppProvider = | 5484 IXFA_AppProvider* pAppProvider = |
| 5476 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5485 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5477 if (!pAppProvider) { | 5486 if (!pAppProvider) { |
| 5478 return; | 5487 return; |
| 5479 } | 5488 } |
| 5480 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5489 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); |
| 5481 CFX_ByteString urlString; | 5490 CFX_ByteString urlString; |
| 5482 HValueToUTF8String(argOne, urlString); | 5491 HValueToUTF8String(argOne, urlString); |
| 5483 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 5492 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
| 5484 CFX_WideString::FromUTF8(urlString, urlString.GetLength())); | 5493 CFX_WideString::FromUTF8(urlString, urlString.GetLength()) |
| 5494 .AsWideStringC()); |
| 5485 if (pFile) { | 5495 if (pFile) { |
| 5486 int32_t size = pFile->GetSize(); | 5496 int32_t size = pFile->GetSize(); |
| 5487 uint8_t* pData = FX_Alloc(uint8_t, size); | 5497 uint8_t* pData = FX_Alloc(uint8_t, size); |
| 5488 pFile->ReadBlock(pData, size); | 5498 pFile->ReadBlock(pData, size); |
| 5489 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5499 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5490 CFX_ByteStringC(pData, size)); | 5500 CFX_ByteStringC(pData, size)); |
| 5491 FX_Free(pData); | 5501 FX_Free(pData); |
| 5492 pFile->Release(); | 5502 pFile->Release(); |
| 5493 } | 5503 } |
| 5494 FXJSE_Value_Release(argOne); | 5504 FXJSE_Value_Release(argOne); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5534 if (argc > 3) { | 5544 if (argc > 3) { |
| 5535 argFour = GetSimpleHValue(hThis, args, 3); | 5545 argFour = GetSimpleHValue(hThis, args, 3); |
| 5536 HValueToUTF8String(argFour, bsEncode); | 5546 HValueToUTF8String(argFour, bsEncode); |
| 5537 } | 5547 } |
| 5538 if (argc > 4) { | 5548 if (argc > 4) { |
| 5539 argFive = GetSimpleHValue(hThis, args, 4); | 5549 argFive = GetSimpleHValue(hThis, args, 4); |
| 5540 HValueToUTF8String(argFive, bsHeader); | 5550 HValueToUTF8String(argFive, bsHeader); |
| 5541 } | 5551 } |
| 5542 CFX_WideString decodedResponse; | 5552 CFX_WideString decodedResponse; |
| 5543 FX_BOOL bFlags = pAppProvider->PostRequestURL( | 5553 FX_BOOL bFlags = pAppProvider->PostRequestURL( |
| 5544 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), | 5554 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(), |
| 5545 CFX_WideString::FromUTF8(bsData, bsData.GetLength()), | 5555 CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(), |
| 5546 CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength()), | 5556 CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength()) |
| 5547 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()), | 5557 .AsWideStringC(), |
| 5548 CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength()), | 5558 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()) |
| 5559 .AsWideStringC(), |
| 5560 CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength()) |
| 5561 .AsWideStringC(), |
| 5549 decodedResponse); | 5562 decodedResponse); |
| 5550 FXJSE_Value_Release(argOne); | 5563 FXJSE_Value_Release(argOne); |
| 5551 FXJSE_Value_Release(argTwo); | 5564 FXJSE_Value_Release(argTwo); |
| 5552 if (argc > 2) { | 5565 if (argc > 2) { |
| 5553 FXJSE_Value_Release(argThree); | 5566 FXJSE_Value_Release(argThree); |
| 5554 } | 5567 } |
| 5555 if (argc > 3) { | 5568 if (argc > 3) { |
| 5556 FXJSE_Value_Release(argFour); | 5569 FXJSE_Value_Release(argFour); |
| 5557 } | 5570 } |
| 5558 if (argc > 4) { | 5571 if (argc > 4) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5595 FXJSE_HVALUE argThree; | 5608 FXJSE_HVALUE argThree; |
| 5596 argOne = GetSimpleHValue(hThis, args, 0); | 5609 argOne = GetSimpleHValue(hThis, args, 0); |
| 5597 HValueToUTF8String(argOne, bsURL); | 5610 HValueToUTF8String(argOne, bsURL); |
| 5598 argTwo = GetSimpleHValue(hThis, args, 1); | 5611 argTwo = GetSimpleHValue(hThis, args, 1); |
| 5599 HValueToUTF8String(argTwo, bsData); | 5612 HValueToUTF8String(argTwo, bsData); |
| 5600 if (argc > 2) { | 5613 if (argc > 2) { |
| 5601 argThree = GetSimpleHValue(hThis, args, 2); | 5614 argThree = GetSimpleHValue(hThis, args, 2); |
| 5602 HValueToUTF8String(argThree, bsEncode); | 5615 HValueToUTF8String(argThree, bsEncode); |
| 5603 } | 5616 } |
| 5604 FX_BOOL bFlags = pAppProvider->PutRequestURL( | 5617 FX_BOOL bFlags = pAppProvider->PutRequestURL( |
| 5605 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), | 5618 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(), |
| 5606 CFX_WideString::FromUTF8(bsData, bsData.GetLength()), | 5619 CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(), |
| 5607 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength())); | 5620 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()) |
| 5621 .AsWideStringC()); |
| 5608 FXJSE_Value_Release(argOne); | 5622 FXJSE_Value_Release(argOne); |
| 5609 FXJSE_Value_Release(argTwo); | 5623 FXJSE_Value_Release(argTwo); |
| 5610 if (argc > 2) { | 5624 if (argc > 2) { |
| 5611 FXJSE_Value_Release(argThree); | 5625 FXJSE_Value_Release(argThree); |
| 5612 } | 5626 } |
| 5613 if (bFlags) { | 5627 if (bFlags) { |
| 5614 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5628 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5615 } else { | 5629 } else { |
| 5616 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5630 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5617 } | 5631 } |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6403 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 6417 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); |
| 6404 CFX_ByteString argString; | 6418 CFX_ByteString argString; |
| 6405 HValueToUTF8String(argOne, argString); | 6419 HValueToUTF8String(argOne, argString); |
| 6406 if (argString.IsEmpty()) { | 6420 if (argString.IsEmpty()) { |
| 6407 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6421 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 6408 } else { | 6422 } else { |
| 6409 CFX_WideString scriptString = | 6423 CFX_WideString scriptString = |
| 6410 CFX_WideString::FromUTF8(argString, argString.GetLength()); | 6424 CFX_WideString::FromUTF8(argString, argString.GetLength()); |
| 6411 CFX_WideTextBuf wsJavaScriptBuf; | 6425 CFX_WideTextBuf wsJavaScriptBuf; |
| 6412 CFX_WideString wsError; | 6426 CFX_WideString wsError; |
| 6413 XFA_FM2JS_Translate(scriptString, wsJavaScriptBuf, wsError); | 6427 XFA_FM2JS_Translate(scriptString.AsWideStringC(), wsJavaScriptBuf, |
| 6428 wsError); |
| 6414 if (wsError.IsEmpty()) { | 6429 if (wsError.IsEmpty()) { |
| 6415 CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); | 6430 CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); |
| 6416 FXJSE_Value_SetUTF8String( | 6431 FXJSE_Value_SetUTF8String( |
| 6417 args.GetReturnValue(), | 6432 args.GetReturnValue(), |
| 6418 FX_UTF8Encode(javaScript, javaScript.GetLength()).AsByteStringC()); | 6433 FX_UTF8Encode(javaScript, javaScript.GetLength()).AsByteStringC()); |
| 6419 } else { | 6434 } else { |
| 6420 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6435 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6421 } | 6436 } |
| 6422 } | 6437 } |
| 6423 FXJSE_Value_Release(argOne); | 6438 FXJSE_Value_Release(argOne); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6872 if (!pDoc) { | 6887 if (!pDoc) { |
| 6873 return bFlags; | 6888 return bFlags; |
| 6874 } | 6889 } |
| 6875 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6890 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6876 XFA_RESOLVENODE_RS resoveNodeRS; | 6891 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6877 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6892 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
| 6878 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6893 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6879 int32_t iRet = pScriptContext->ResolveObjects( | 6894 int32_t iRet = pScriptContext->ResolveObjects( |
| 6880 pScriptContext->GetThisObject(), | 6895 pScriptContext->GetThisObject(), |
| 6881 CFX_WideString::FromUTF8(szAccessorName.c_str(), | 6896 CFX_WideString::FromUTF8(szAccessorName.c_str(), |
| 6882 szAccessorName.GetLength()), | 6897 szAccessorName.GetLength()) |
| 6898 .AsWideStringC(), |
| 6883 resoveNodeRS, dwFlags); | 6899 resoveNodeRS, dwFlags); |
| 6884 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6900 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6885 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6901 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
| 6886 resoveNodeRS.nodes.GetAt(0))); | 6902 resoveNodeRS.nodes.GetAt(0))); |
| 6887 bFlags = TRUE; | 6903 bFlags = TRUE; |
| 6888 } | 6904 } |
| 6889 return bFlags; | 6905 return bFlags; |
| 6890 } | 6906 } |
| 6891 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, | 6907 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, |
| 6892 FXJSE_HVALUE hRefValue, | 6908 FXJSE_HVALUE hRefValue, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6929 dFlags = (bsSomExp == "*") | 6945 dFlags = (bsSomExp == "*") |
| 6930 ? (XFA_RESOLVENODE_Children) | 6946 ? (XFA_RESOLVENODE_Children) |
| 6931 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 6947 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
| 6932 XFA_RESOLVENODE_Properties); | 6948 XFA_RESOLVENODE_Properties); |
| 6933 } | 6949 } |
| 6934 } | 6950 } |
| 6935 } else { | 6951 } else { |
| 6936 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); | 6952 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); |
| 6937 dFlags = XFA_RESOLVENODE_AnyChild; | 6953 dFlags = XFA_RESOLVENODE_AnyChild; |
| 6938 } | 6954 } |
| 6939 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression, resoveNodeRS, | 6955 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsWideStringC(), |
| 6940 dFlags); | 6956 resoveNodeRS, dFlags); |
| 6941 return iRet; | 6957 return iRet; |
| 6942 } | 6958 } |
| 6943 void CXFA_FM2JSContext::ParseResolveResult( | 6959 void CXFA_FM2JSContext::ParseResolveResult( |
| 6944 FXJSE_HOBJECT hThis, | 6960 FXJSE_HOBJECT hThis, |
| 6945 const XFA_RESOLVENODE_RS& resoveNodeRS, | 6961 const XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6946 FXJSE_HVALUE hParentValue, | 6962 FXJSE_HVALUE hParentValue, |
| 6947 FXJSE_HVALUE*& resultValues, | 6963 FXJSE_HVALUE*& resultValues, |
| 6948 int32_t& iSize, | 6964 int32_t& iSize, |
| 6949 FX_BOOL& bAttribute) { | 6965 FX_BOOL& bAttribute) { |
| 6950 CXFA_FM2JSContext* pContext = | 6966 CXFA_FM2JSContext* pContext = |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7256 CFX_WideString wsFormat; | 7272 CFX_WideString wsFormat; |
| 7257 pAppProvider->LoadString(iStringID, wsFormat); | 7273 pAppProvider->LoadString(iStringID, wsFormat); |
| 7258 CFX_WideString wsMessage; | 7274 CFX_WideString wsMessage; |
| 7259 va_list arg_ptr; | 7275 va_list arg_ptr; |
| 7260 va_start(arg_ptr, iStringID); | 7276 va_start(arg_ptr, iStringID); |
| 7261 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7277 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
| 7262 va_end(arg_ptr); | 7278 va_end(arg_ptr); |
| 7263 FXJSE_ThrowMessage( | 7279 FXJSE_ThrowMessage( |
| 7264 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC()); | 7280 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC()); |
| 7265 } | 7281 } |
| OLD | NEW |