| 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.GetCStr(), szLocale.GetLength())); | 2043 CFX_WideString::FromUTF8(szLocale.GetCStr(), 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 = | 2053 wsFormat = |
| 2052 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | 2054 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2072 } | 2074 } |
| 2073 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2075 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2074 IFX_Locale* pLocale = NULL; | 2076 IFX_Locale* pLocale = NULL; |
| 2075 if (szLocale.IsEmpty()) { | 2077 if (szLocale.IsEmpty()) { |
| 2076 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2078 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2077 FXSYS_assert(pThisNode); | 2079 FXSYS_assert(pThisNode); |
| 2078 CXFA_WidgetData widgetData(pThisNode); | 2080 CXFA_WidgetData widgetData(pThisNode); |
| 2079 pLocale = widgetData.GetLocal(); | 2081 pLocale = widgetData.GetLocal(); |
| 2080 } else { | 2082 } else { |
| 2081 pLocale = pMgr->GetLocaleByName( | 2083 pLocale = pMgr->GetLocaleByName( |
| 2082 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2084 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength()) |
| 2085 .AsWideStringC()); |
| 2083 } | 2086 } |
| 2084 if (!pLocale) { | 2087 if (!pLocale) { |
| 2085 return FALSE; | 2088 return FALSE; |
| 2086 } | 2089 } |
| 2087 CFX_WideString wsFormat; | 2090 CFX_WideString wsFormat; |
| 2088 if (szFormat.IsEmpty()) { | 2091 if (szFormat.IsEmpty()) { |
| 2089 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2092 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2090 } else { | 2093 } else { |
| 2091 wsFormat = | 2094 wsFormat = |
| 2092 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | 2095 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2115 } | 2118 } |
| 2116 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2119 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2117 IFX_Locale* pLocale = NULL; | 2120 IFX_Locale* pLocale = NULL; |
| 2118 if (szLocale.IsEmpty()) { | 2121 if (szLocale.IsEmpty()) { |
| 2119 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2122 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2120 FXSYS_assert(pThisNode); | 2123 FXSYS_assert(pThisNode); |
| 2121 CXFA_WidgetData widgetData(pThisNode); | 2124 CXFA_WidgetData widgetData(pThisNode); |
| 2122 pLocale = widgetData.GetLocal(); | 2125 pLocale = widgetData.GetLocal(); |
| 2123 } else { | 2126 } else { |
| 2124 pLocale = pMgr->GetLocaleByName( | 2127 pLocale = pMgr->GetLocaleByName( |
| 2125 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2128 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength()) |
| 2129 .AsWideStringC()); |
| 2126 } | 2130 } |
| 2127 if (!pLocale) { | 2131 if (!pLocale) { |
| 2128 return FALSE; | 2132 return FALSE; |
| 2129 } | 2133 } |
| 2130 CFX_WideString wsFormat; | 2134 CFX_WideString wsFormat; |
| 2131 if (szFormat.IsEmpty()) { | 2135 if (szFormat.IsEmpty()) { |
| 2132 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2136 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2133 } else { | 2137 } else { |
| 2134 wsFormat = | 2138 wsFormat = |
| 2135 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | 2139 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2157 } | 2161 } |
| 2158 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2162 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2159 IFX_Locale* pLocale = NULL; | 2163 IFX_Locale* pLocale = NULL; |
| 2160 if (szLocale.IsEmpty()) { | 2164 if (szLocale.IsEmpty()) { |
| 2161 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2165 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2162 FXSYS_assert(pThisNode); | 2166 FXSYS_assert(pThisNode); |
| 2163 CXFA_WidgetData widgetData(pThisNode); | 2167 CXFA_WidgetData widgetData(pThisNode); |
| 2164 pLocale = widgetData.GetLocal(); | 2168 pLocale = widgetData.GetLocal(); |
| 2165 } else { | 2169 } else { |
| 2166 pLocale = pMgr->GetLocaleByName( | 2170 pLocale = pMgr->GetLocaleByName( |
| 2167 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2171 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength()) |
| 2172 .AsWideStringC()); |
| 2168 } | 2173 } |
| 2169 if (!pLocale) { | 2174 if (!pLocale) { |
| 2170 return FALSE; | 2175 return FALSE; |
| 2171 } | 2176 } |
| 2172 CFX_WideString wsFormat; | 2177 CFX_WideString wsFormat; |
| 2173 if (szFormat.IsEmpty()) { | 2178 if (szFormat.IsEmpty()) { |
| 2174 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2179 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2175 } else { | 2180 } else { |
| 2176 wsFormat = | 2181 wsFormat = |
| 2177 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | 2182 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2201 } | 2206 } |
| 2202 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2207 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2203 IFX_Locale* pLocale = NULL; | 2208 IFX_Locale* pLocale = NULL; |
| 2204 if (szLocale.IsEmpty()) { | 2209 if (szLocale.IsEmpty()) { |
| 2205 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2210 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2206 FXSYS_assert(pThisNode); | 2211 FXSYS_assert(pThisNode); |
| 2207 CXFA_WidgetData widgetData(pThisNode); | 2212 CXFA_WidgetData widgetData(pThisNode); |
| 2208 pLocale = widgetData.GetLocal(); | 2213 pLocale = widgetData.GetLocal(); |
| 2209 } else { | 2214 } else { |
| 2210 pLocale = pMgr->GetLocaleByName( | 2215 pLocale = pMgr->GetLocaleByName( |
| 2211 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2216 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength()) |
| 2217 .AsWideStringC()); |
| 2212 } | 2218 } |
| 2213 if (!pLocale) { | 2219 if (!pLocale) { |
| 2214 return FALSE; | 2220 return FALSE; |
| 2215 } | 2221 } |
| 2216 CFX_WideString wsFormat; | 2222 CFX_WideString wsFormat; |
| 2217 if (szFormat.IsEmpty()) { | 2223 if (szFormat.IsEmpty()) { |
| 2218 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2224 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2219 } else { | 2225 } else { |
| 2220 wsFormat = | 2226 wsFormat = |
| 2221 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | 2227 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2386 } | 2392 } |
| 2387 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2393 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2388 IFX_Locale* pLocale = NULL; | 2394 IFX_Locale* pLocale = NULL; |
| 2389 if (szLocalStr.IsEmpty()) { | 2395 if (szLocalStr.IsEmpty()) { |
| 2390 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2396 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2391 FXSYS_assert(pThisNode); | 2397 FXSYS_assert(pThisNode); |
| 2392 CXFA_WidgetData widgetData(pThisNode); | 2398 CXFA_WidgetData widgetData(pThisNode); |
| 2393 pLocale = widgetData.GetLocal(); | 2399 pLocale = widgetData.GetLocal(); |
| 2394 } else { | 2400 } else { |
| 2395 pLocale = pMgr->GetLocaleByName( | 2401 pLocale = pMgr->GetLocaleByName( |
| 2396 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); | 2402 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength()) |
| 2403 .AsWideStringC()); |
| 2397 } | 2404 } |
| 2398 if (!pLocale) { | 2405 if (!pLocale) { |
| 2399 return; | 2406 return; |
| 2400 } | 2407 } |
| 2401 CFX_WideString strRet; | 2408 CFX_WideString strRet; |
| 2402 pLocale->GetDatePattern(strStyle, strRet); | 2409 pLocale->GetDatePattern(strStyle, strRet); |
| 2403 if (!bStandard) { | 2410 if (!bStandard) { |
| 2404 CFX_WideString wsSymbols; | 2411 CFX_WideString wsSymbols; |
| 2405 pLocale->GetDateTimeSymbols(wsSymbols); | 2412 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2406 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); | 2413 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2441 } | 2448 } |
| 2442 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2449 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2443 IFX_Locale* pLocale = NULL; | 2450 IFX_Locale* pLocale = NULL; |
| 2444 if (szLocalStr.IsEmpty()) { | 2451 if (szLocalStr.IsEmpty()) { |
| 2445 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2452 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2446 FXSYS_assert(pThisNode); | 2453 FXSYS_assert(pThisNode); |
| 2447 CXFA_WidgetData widgetData(pThisNode); | 2454 CXFA_WidgetData widgetData(pThisNode); |
| 2448 pLocale = widgetData.GetLocal(); | 2455 pLocale = widgetData.GetLocal(); |
| 2449 } else { | 2456 } else { |
| 2450 pLocale = pMgr->GetLocaleByName( | 2457 pLocale = pMgr->GetLocaleByName( |
| 2451 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); | 2458 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength()) |
| 2459 .AsWideStringC()); |
| 2452 } | 2460 } |
| 2453 if (!pLocale) { | 2461 if (!pLocale) { |
| 2454 return; | 2462 return; |
| 2455 } | 2463 } |
| 2456 CFX_WideString strRet; | 2464 CFX_WideString strRet; |
| 2457 pLocale->GetTimePattern(strStyle, strRet); | 2465 pLocale->GetTimePattern(strStyle, strRet); |
| 2458 if (!bStandard) { | 2466 if (!bStandard) { |
| 2459 CFX_WideString wsSymbols; | 2467 CFX_WideString wsSymbols; |
| 2460 pLocale->GetDateTimeSymbols(wsSymbols); | 2468 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2461 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); | 2469 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3260 if (args.GetLength() == 1) { | 3268 if (args.GetLength() == 1) { |
| 3261 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); | 3269 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); |
| 3262 CFX_ByteString utf8ScriptString; | 3270 CFX_ByteString utf8ScriptString; |
| 3263 HValueToUTF8String(scriptValue, utf8ScriptString); | 3271 HValueToUTF8String(scriptValue, utf8ScriptString); |
| 3264 if (utf8ScriptString.IsEmpty()) { | 3272 if (utf8ScriptString.IsEmpty()) { |
| 3265 FXJSE_Value_SetNull(args.GetReturnValue()); | 3273 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3266 } else { | 3274 } else { |
| 3267 CFX_WideTextBuf wsJavaScriptBuf; | 3275 CFX_WideTextBuf wsJavaScriptBuf; |
| 3268 CFX_WideString javaScript; | 3276 CFX_WideString javaScript; |
| 3269 CFX_WideString wsError; | 3277 CFX_WideString wsError; |
| 3270 XFA_FM2JS_Translate(CFX_WideString::FromUTF8( | 3278 XFA_FM2JS_Translate(CFX_WideString::FromUTF8(utf8ScriptString, |
| 3271 utf8ScriptString, utf8ScriptString.GetLength()), | 3279 utf8ScriptString.GetLength()) |
| 3280 .AsWideStringC(), |
| 3272 wsJavaScriptBuf, wsError); | 3281 wsJavaScriptBuf, wsError); |
| 3273 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); | 3282 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); |
| 3274 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); | 3283 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); |
| 3275 javaScript = wsJavaScriptBuf.GetWideString(); | 3284 javaScript = wsJavaScriptBuf.GetWideString(); |
| 3276 FXJSE_ExecuteScript(hContext, | 3285 FXJSE_ExecuteScript(hContext, |
| 3277 FX_UTF8Encode(javaScript, javaScript.GetLength()), | 3286 FX_UTF8Encode(javaScript, javaScript.GetLength()), |
| 3278 returnValue); | 3287 returnValue); |
| 3279 FXJSE_Value_Set(args.GetReturnValue(), returnValue); | 3288 FXJSE_Value_Set(args.GetReturnValue(), returnValue); |
| 3280 FXJSE_Value_Release(returnValue); | 3289 FXJSE_Value_Release(returnValue); |
| 3281 FXJSE_Context_Release(hContext); | 3290 FXJSE_Context_Release(hContext); |
| (...skipping 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5484 } | 5493 } |
| 5485 IXFA_AppProvider* pAppProvider = | 5494 IXFA_AppProvider* pAppProvider = |
| 5486 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5495 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5487 if (!pAppProvider) { | 5496 if (!pAppProvider) { |
| 5488 return; | 5497 return; |
| 5489 } | 5498 } |
| 5490 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5499 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); |
| 5491 CFX_ByteString urlString; | 5500 CFX_ByteString urlString; |
| 5492 HValueToUTF8String(argOne, urlString); | 5501 HValueToUTF8String(argOne, urlString); |
| 5493 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 5502 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
| 5494 CFX_WideString::FromUTF8(urlString, urlString.GetLength())); | 5503 CFX_WideString::FromUTF8(urlString, urlString.GetLength()) |
| 5504 .AsWideStringC()); |
| 5495 if (pFile) { | 5505 if (pFile) { |
| 5496 int32_t size = pFile->GetSize(); | 5506 int32_t size = pFile->GetSize(); |
| 5497 uint8_t* pData = FX_Alloc(uint8_t, size); | 5507 uint8_t* pData = FX_Alloc(uint8_t, size); |
| 5498 pFile->ReadBlock(pData, size); | 5508 pFile->ReadBlock(pData, size); |
| 5499 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5509 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5500 CFX_ByteStringC(pData, size)); | 5510 CFX_ByteStringC(pData, size)); |
| 5501 FX_Free(pData); | 5511 FX_Free(pData); |
| 5502 pFile->Release(); | 5512 pFile->Release(); |
| 5503 } | 5513 } |
| 5504 FXJSE_Value_Release(argOne); | 5514 FXJSE_Value_Release(argOne); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5544 if (argc > 3) { | 5554 if (argc > 3) { |
| 5545 argFour = GetSimpleHValue(hThis, args, 3); | 5555 argFour = GetSimpleHValue(hThis, args, 3); |
| 5546 HValueToUTF8String(argFour, bsEncode); | 5556 HValueToUTF8String(argFour, bsEncode); |
| 5547 } | 5557 } |
| 5548 if (argc > 4) { | 5558 if (argc > 4) { |
| 5549 argFive = GetSimpleHValue(hThis, args, 4); | 5559 argFive = GetSimpleHValue(hThis, args, 4); |
| 5550 HValueToUTF8String(argFive, bsHeader); | 5560 HValueToUTF8String(argFive, bsHeader); |
| 5551 } | 5561 } |
| 5552 CFX_WideString decodedResponse; | 5562 CFX_WideString decodedResponse; |
| 5553 FX_BOOL bFlags = pAppProvider->PostRequestURL( | 5563 FX_BOOL bFlags = pAppProvider->PostRequestURL( |
| 5554 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), | 5564 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(), |
| 5555 CFX_WideString::FromUTF8(bsData, bsData.GetLength()), | 5565 CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(), |
| 5556 CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength()), | 5566 CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength()) |
| 5557 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()), | 5567 .AsWideStringC(), |
| 5558 CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength()), | 5568 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()) |
| 5569 .AsWideStringC(), |
| 5570 CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength()) |
| 5571 .AsWideStringC(), |
| 5559 decodedResponse); | 5572 decodedResponse); |
| 5560 FXJSE_Value_Release(argOne); | 5573 FXJSE_Value_Release(argOne); |
| 5561 FXJSE_Value_Release(argTwo); | 5574 FXJSE_Value_Release(argTwo); |
| 5562 if (argc > 2) { | 5575 if (argc > 2) { |
| 5563 FXJSE_Value_Release(argThree); | 5576 FXJSE_Value_Release(argThree); |
| 5564 } | 5577 } |
| 5565 if (argc > 3) { | 5578 if (argc > 3) { |
| 5566 FXJSE_Value_Release(argFour); | 5579 FXJSE_Value_Release(argFour); |
| 5567 } | 5580 } |
| 5568 if (argc > 4) { | 5581 if (argc > 4) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5605 FXJSE_HVALUE argThree; | 5618 FXJSE_HVALUE argThree; |
| 5606 argOne = GetSimpleHValue(hThis, args, 0); | 5619 argOne = GetSimpleHValue(hThis, args, 0); |
| 5607 HValueToUTF8String(argOne, bsURL); | 5620 HValueToUTF8String(argOne, bsURL); |
| 5608 argTwo = GetSimpleHValue(hThis, args, 1); | 5621 argTwo = GetSimpleHValue(hThis, args, 1); |
| 5609 HValueToUTF8String(argTwo, bsData); | 5622 HValueToUTF8String(argTwo, bsData); |
| 5610 if (argc > 2) { | 5623 if (argc > 2) { |
| 5611 argThree = GetSimpleHValue(hThis, args, 2); | 5624 argThree = GetSimpleHValue(hThis, args, 2); |
| 5612 HValueToUTF8String(argThree, bsEncode); | 5625 HValueToUTF8String(argThree, bsEncode); |
| 5613 } | 5626 } |
| 5614 FX_BOOL bFlags = pAppProvider->PutRequestURL( | 5627 FX_BOOL bFlags = pAppProvider->PutRequestURL( |
| 5615 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), | 5628 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(), |
| 5616 CFX_WideString::FromUTF8(bsData, bsData.GetLength()), | 5629 CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(), |
| 5617 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength())); | 5630 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()) |
| 5631 .AsWideStringC()); |
| 5618 FXJSE_Value_Release(argOne); | 5632 FXJSE_Value_Release(argOne); |
| 5619 FXJSE_Value_Release(argTwo); | 5633 FXJSE_Value_Release(argTwo); |
| 5620 if (argc > 2) { | 5634 if (argc > 2) { |
| 5621 FXJSE_Value_Release(argThree); | 5635 FXJSE_Value_Release(argThree); |
| 5622 } | 5636 } |
| 5623 if (bFlags) { | 5637 if (bFlags) { |
| 5624 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5638 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5625 } else { | 5639 } else { |
| 5626 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5640 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5627 } | 5641 } |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6413 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 6427 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); |
| 6414 CFX_ByteString argString; | 6428 CFX_ByteString argString; |
| 6415 HValueToUTF8String(argOne, argString); | 6429 HValueToUTF8String(argOne, argString); |
| 6416 if (argString.IsEmpty()) { | 6430 if (argString.IsEmpty()) { |
| 6417 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6431 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 6418 } else { | 6432 } else { |
| 6419 CFX_WideString scriptString = | 6433 CFX_WideString scriptString = |
| 6420 CFX_WideString::FromUTF8(argString, argString.GetLength()); | 6434 CFX_WideString::FromUTF8(argString, argString.GetLength()); |
| 6421 CFX_WideTextBuf wsJavaScriptBuf; | 6435 CFX_WideTextBuf wsJavaScriptBuf; |
| 6422 CFX_WideString wsError; | 6436 CFX_WideString wsError; |
| 6423 XFA_FM2JS_Translate(scriptString, wsJavaScriptBuf, wsError); | 6437 XFA_FM2JS_Translate(scriptString.AsWideStringC(), wsJavaScriptBuf, |
| 6438 wsError); |
| 6424 if (wsError.IsEmpty()) { | 6439 if (wsError.IsEmpty()) { |
| 6425 CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); | 6440 CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); |
| 6426 FXJSE_Value_SetUTF8String( | 6441 FXJSE_Value_SetUTF8String( |
| 6427 args.GetReturnValue(), | 6442 args.GetReturnValue(), |
| 6428 FX_UTF8Encode(javaScript, javaScript.GetLength()).AsByteStringC()); | 6443 FX_UTF8Encode(javaScript, javaScript.GetLength()).AsByteStringC()); |
| 6429 } else { | 6444 } else { |
| 6430 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6445 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6431 } | 6446 } |
| 6432 } | 6447 } |
| 6433 FXJSE_Value_Release(argOne); | 6448 FXJSE_Value_Release(argOne); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6882 if (!pDoc) { | 6897 if (!pDoc) { |
| 6883 return bFlags; | 6898 return bFlags; |
| 6884 } | 6899 } |
| 6885 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6900 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6886 XFA_RESOLVENODE_RS resoveNodeRS; | 6901 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6887 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6902 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
| 6888 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6903 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6889 int32_t iRet = pScriptContext->ResolveObjects( | 6904 int32_t iRet = pScriptContext->ResolveObjects( |
| 6890 pScriptContext->GetThisObject(), | 6905 pScriptContext->GetThisObject(), |
| 6891 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), | 6906 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), |
| 6892 szAccessorName.GetLength()), | 6907 szAccessorName.GetLength()) |
| 6908 .AsWideStringC(), |
| 6893 resoveNodeRS, dwFlags); | 6909 resoveNodeRS, dwFlags); |
| 6894 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6910 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6895 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6911 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
| 6896 resoveNodeRS.nodes.GetAt(0))); | 6912 resoveNodeRS.nodes.GetAt(0))); |
| 6897 bFlags = TRUE; | 6913 bFlags = TRUE; |
| 6898 } | 6914 } |
| 6899 return bFlags; | 6915 return bFlags; |
| 6900 } | 6916 } |
| 6901 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, | 6917 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, |
| 6902 FXJSE_HVALUE hRefValue, | 6918 FXJSE_HVALUE hRefValue, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6939 dFlags = (bsSomExp == "*") | 6955 dFlags = (bsSomExp == "*") |
| 6940 ? (XFA_RESOLVENODE_Children) | 6956 ? (XFA_RESOLVENODE_Children) |
| 6941 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 6957 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
| 6942 XFA_RESOLVENODE_Properties); | 6958 XFA_RESOLVENODE_Properties); |
| 6943 } | 6959 } |
| 6944 } | 6960 } |
| 6945 } else { | 6961 } else { |
| 6946 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); | 6962 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); |
| 6947 dFlags = XFA_RESOLVENODE_AnyChild; | 6963 dFlags = XFA_RESOLVENODE_AnyChild; |
| 6948 } | 6964 } |
| 6949 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression, resoveNodeRS, | 6965 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsWideStringC(), |
| 6950 dFlags); | 6966 resoveNodeRS, dFlags); |
| 6951 return iRet; | 6967 return iRet; |
| 6952 } | 6968 } |
| 6953 void CXFA_FM2JSContext::ParseResolveResult( | 6969 void CXFA_FM2JSContext::ParseResolveResult( |
| 6954 FXJSE_HOBJECT hThis, | 6970 FXJSE_HOBJECT hThis, |
| 6955 const XFA_RESOLVENODE_RS& resoveNodeRS, | 6971 const XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6956 FXJSE_HVALUE hParentValue, | 6972 FXJSE_HVALUE hParentValue, |
| 6957 FXJSE_HVALUE*& resultValues, | 6973 FXJSE_HVALUE*& resultValues, |
| 6958 int32_t& iSize, | 6974 int32_t& iSize, |
| 6959 FX_BOOL& bAttribute) { | 6975 FX_BOOL& bAttribute) { |
| 6960 CXFA_FM2JSContext* pContext = | 6976 CXFA_FM2JSContext* pContext = |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7266 CFX_WideString wsFormat; | 7282 CFX_WideString wsFormat; |
| 7267 pAppProvider->LoadString(iStringID, wsFormat); | 7283 pAppProvider->LoadString(iStringID, wsFormat); |
| 7268 CFX_WideString wsMessage; | 7284 CFX_WideString wsMessage; |
| 7269 va_list arg_ptr; | 7285 va_list arg_ptr; |
| 7270 va_start(arg_ptr, iStringID); | 7286 va_start(arg_ptr, iStringID); |
| 7271 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7287 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
| 7272 va_end(arg_ptr); | 7288 va_end(arg_ptr); |
| 7273 FXJSE_ThrowMessage( | 7289 FXJSE_ThrowMessage( |
| 7274 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC()); | 7290 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC()); |
| 7275 } | 7291 } |
| OLD | NEW |