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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1095 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
1096 CFX_ByteString szArgString; | 1096 CFX_ByteString szArgString; |
1097 HValueToUTF8String(argOne, szArgString); | 1097 HValueToUTF8String(argOne, szArgString); |
1098 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); | 1098 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); |
1099 if (szArgString.IsEmpty()) { | 1099 if (szArgString.IsEmpty()) { |
1100 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1100 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
1101 FXJSE_Value_Release(argOne); | 1101 FXJSE_Value_Release(argOne); |
1102 return; | 1102 return; |
1103 } | 1103 } |
1104 CXFA_LocaleValue timeValue( | 1104 CXFA_LocaleValue timeValue( |
1105 XFA_VT_TIME, | 1105 XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsByteStringC()), |
1106 CFX_WideString::FromUTF8(szArgString, szArgString.GetLength()), | |
1107 (CXFA_LocaleMgr*)pMgr); | 1106 (CXFA_LocaleMgr*)pMgr); |
1108 if (timeValue.IsValid()) { | 1107 if (timeValue.IsValid()) { |
1109 CFX_Unitime uniTime = timeValue.GetTime(); | 1108 CFX_Unitime uniTime = timeValue.GetTime(); |
1110 int32_t hour = uniTime.GetHour(); | 1109 int32_t hour = uniTime.GetHour(); |
1111 int32_t min = uniTime.GetMinute(); | 1110 int32_t min = uniTime.GetMinute(); |
1112 int32_t second = uniTime.GetSecond(); | 1111 int32_t second = uniTime.GetSecond(); |
1113 int32_t milSecond = uniTime.GetMillisecond(); | 1112 int32_t milSecond = uniTime.GetMillisecond(); |
1114 IFX_Locale* pDefLocale = pMgr->GetDefLocale(); | 1113 IFX_Locale* pDefLocale = pMgr->GetDefLocale(); |
1115 FXSYS_assert(pDefLocale); | 1114 FXSYS_assert(pDefLocale); |
1116 FX_TIMEZONE tzLocale; | 1115 FX_TIMEZONE tzLocale; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1581 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
1583 IFX_Locale* pLocale = NULL; | 1582 IFX_Locale* pLocale = NULL; |
1584 if (localString.IsEmpty()) { | 1583 if (localString.IsEmpty()) { |
1585 CXFA_Node* pThisNode = | 1584 CXFA_Node* pThisNode = |
1586 ToNode(pDoc->GetScriptContext()->GetThisObject()); | 1585 ToNode(pDoc->GetScriptContext()->GetThisObject()); |
1587 FXSYS_assert(pThisNode); | 1586 FXSYS_assert(pThisNode); |
1588 CXFA_WidgetData widgetData(pThisNode); | 1587 CXFA_WidgetData widgetData(pThisNode); |
1589 pLocale = widgetData.GetLocal(); | 1588 pLocale = widgetData.GetLocal(); |
1590 } else { | 1589 } else { |
1591 pLocale = pMgr->GetLocaleByName( | 1590 pLocale = pMgr->GetLocaleByName( |
1592 CFX_WideString::FromUTF8(localString, localString.GetLength()) | 1591 CFX_WideString::FromUTF8(localString.AsByteStringC()) |
1593 .AsWideStringC()); | 1592 .AsWideStringC()); |
1594 } | 1593 } |
1595 CFX_WideString wsFormat; | 1594 CFX_WideString wsFormat; |
1596 if (formatString.IsEmpty()) { | 1595 if (formatString.IsEmpty()) { |
1597 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 1596 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
1598 } else { | 1597 } else { |
1599 wsFormat = | 1598 wsFormat = CFX_WideString::FromUTF8(formatString.AsByteStringC()); |
1600 CFX_WideString::FromUTF8(formatString, formatString.GetLength()); | |
1601 } | 1599 } |
1602 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 1600 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
1603 wsFormat += FX_WSTRC(L"}"); | 1601 wsFormat += FX_WSTRC(L"}"); |
1604 CXFA_LocaleValue timeValue( | 1602 CXFA_LocaleValue timeValue( |
1605 XFA_VT_TIME, | 1603 XFA_VT_TIME, CFX_WideString::FromUTF8(timeString.AsByteStringC()), |
1606 CFX_WideString::FromUTF8(timeString, timeString.GetLength()), | |
1607 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 1604 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
1608 if (timeValue.IsValid()) { | 1605 if (timeValue.IsValid()) { |
1609 CFX_Unitime uniTime = timeValue.GetTime(); | 1606 CFX_Unitime uniTime = timeValue.GetTime(); |
1610 int32_t hour = uniTime.GetHour(); | 1607 int32_t hour = uniTime.GetHour(); |
1611 int32_t min = uniTime.GetMinute(); | 1608 int32_t min = uniTime.GetMinute(); |
1612 int32_t second = uniTime.GetSecond(); | 1609 int32_t second = uniTime.GetSecond(); |
1613 int32_t milSecond = uniTime.GetMillisecond(); | 1610 int32_t milSecond = uniTime.GetMillisecond(); |
1614 int32_t mins = hour * 60 + min; | 1611 int32_t mins = hour * 60 + min; |
1615 CXFA_TimeZoneProvider* pProvider = CXFA_TimeZoneProvider::Get(); | 1612 CXFA_TimeZoneProvider* pProvider = CXFA_TimeZoneProvider::Get(); |
1616 if (pProvider) { | 1613 if (pProvider) { |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 } | 2030 } |
2034 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2031 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
2035 IFX_Locale* pLocale = NULL; | 2032 IFX_Locale* pLocale = NULL; |
2036 if (szLocale.IsEmpty()) { | 2033 if (szLocale.IsEmpty()) { |
2037 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2034 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
2038 FXSYS_assert(pThisNode); | 2035 FXSYS_assert(pThisNode); |
2039 CXFA_WidgetData widgetData(pThisNode); | 2036 CXFA_WidgetData widgetData(pThisNode); |
2040 pLocale = widgetData.GetLocal(); | 2037 pLocale = widgetData.GetLocal(); |
2041 } else { | 2038 } else { |
2042 pLocale = pMgr->GetLocaleByName( | 2039 pLocale = pMgr->GetLocaleByName( |
2043 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) | 2040 CFX_WideString::FromUTF8(szLocale).AsWideStringC()); |
2044 .AsWideStringC()); | |
2045 } | 2041 } |
2046 if (!pLocale) { | 2042 if (!pLocale) { |
2047 return FALSE; | 2043 return FALSE; |
2048 } | 2044 } |
2049 CFX_WideString wsFormat; | 2045 CFX_WideString wsFormat; |
2050 if (szFormat.IsEmpty()) { | 2046 if (szFormat.IsEmpty()) { |
2051 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2047 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
2052 } else { | 2048 } else { |
2053 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2049 wsFormat = CFX_WideString::FromUTF8(szFormat); |
2054 } | 2050 } |
2055 CXFA_LocaleValue widgetValue( | 2051 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
2056 XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()), | 2052 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
2057 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | |
2058 CFX_Unitime dt = widgetValue.GetDate(); | 2053 CFX_Unitime dt = widgetValue.GetDate(); |
2059 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); | 2054 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); |
2060 return TRUE; | 2055 return TRUE; |
2061 } | 2056 } |
2062 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, | 2057 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, |
2063 const CFX_ByteStringC& szTime, | 2058 const CFX_ByteStringC& szTime, |
2064 const CFX_ByteStringC& szFormat, | 2059 const CFX_ByteStringC& szFormat, |
2065 const CFX_ByteStringC& szLocale, | 2060 const CFX_ByteStringC& szLocale, |
2066 CFX_ByteString& strIsoTime) { | 2061 CFX_ByteString& strIsoTime) { |
2067 CXFA_FM2JSContext* pContext = | 2062 CXFA_FM2JSContext* pContext = |
2068 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2063 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
2069 CXFA_Document* pDoc = pContext->GetDocument(); | 2064 CXFA_Document* pDoc = pContext->GetDocument(); |
2070 if (!pDoc) { | 2065 if (!pDoc) { |
2071 return FALSE; | 2066 return FALSE; |
2072 } | 2067 } |
2073 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2068 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
2074 IFX_Locale* pLocale = NULL; | 2069 IFX_Locale* pLocale = NULL; |
2075 if (szLocale.IsEmpty()) { | 2070 if (szLocale.IsEmpty()) { |
2076 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2071 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
2077 FXSYS_assert(pThisNode); | 2072 FXSYS_assert(pThisNode); |
2078 CXFA_WidgetData widgetData(pThisNode); | 2073 CXFA_WidgetData widgetData(pThisNode); |
2079 pLocale = widgetData.GetLocal(); | 2074 pLocale = widgetData.GetLocal(); |
2080 } else { | 2075 } else { |
2081 pLocale = pMgr->GetLocaleByName( | 2076 pLocale = pMgr->GetLocaleByName( |
2082 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) | 2077 CFX_WideString::FromUTF8(szLocale).AsWideStringC()); |
2083 .AsWideStringC()); | |
2084 } | 2078 } |
2085 if (!pLocale) { | 2079 if (!pLocale) { |
2086 return FALSE; | 2080 return FALSE; |
2087 } | 2081 } |
2088 CFX_WideString wsFormat; | 2082 CFX_WideString wsFormat; |
2089 if (szFormat.IsEmpty()) { | 2083 if (szFormat.IsEmpty()) { |
2090 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2084 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
2091 } else { | 2085 } else { |
2092 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2086 wsFormat = CFX_WideString::FromUTF8(szFormat); |
2093 } | 2087 } |
2094 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2088 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
2095 wsFormat += FX_WSTRC(L"}"); | 2089 wsFormat += FX_WSTRC(L"}"); |
2096 CXFA_LocaleValue widgetValue( | 2090 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
2097 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()), | 2091 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
2098 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | |
2099 CFX_Unitime utime = widgetValue.GetTime(); | 2092 CFX_Unitime utime = widgetValue.GetTime(); |
2100 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), | 2093 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), |
2101 utime.GetSecond(), utime.GetMillisecond()); | 2094 utime.GetSecond(), utime.GetMillisecond()); |
2102 return TRUE; | 2095 return TRUE; |
2103 } | 2096 } |
2104 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, | 2097 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, |
2105 const CFX_ByteStringC& szDate, | 2098 const CFX_ByteStringC& szDate, |
2106 const CFX_ByteStringC& szFormat, | 2099 const CFX_ByteStringC& szFormat, |
2107 const CFX_ByteStringC& szLocale, | 2100 const CFX_ByteStringC& szLocale, |
2108 CFX_ByteString& strLocalDate) { | 2101 CFX_ByteString& strLocalDate) { |
2109 CXFA_FM2JSContext* pContext = | 2102 CXFA_FM2JSContext* pContext = |
2110 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2103 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
2111 CXFA_Document* pDoc = pContext->GetDocument(); | 2104 CXFA_Document* pDoc = pContext->GetDocument(); |
2112 if (!pDoc) { | 2105 if (!pDoc) { |
2113 return FALSE; | 2106 return FALSE; |
2114 } | 2107 } |
2115 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2108 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
2116 IFX_Locale* pLocale = NULL; | 2109 IFX_Locale* pLocale = NULL; |
2117 if (szLocale.IsEmpty()) { | 2110 if (szLocale.IsEmpty()) { |
2118 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2111 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
2119 FXSYS_assert(pThisNode); | 2112 FXSYS_assert(pThisNode); |
2120 CXFA_WidgetData widgetData(pThisNode); | 2113 CXFA_WidgetData widgetData(pThisNode); |
2121 pLocale = widgetData.GetLocal(); | 2114 pLocale = widgetData.GetLocal(); |
2122 } else { | 2115 } else { |
2123 pLocale = pMgr->GetLocaleByName( | 2116 pLocale = pMgr->GetLocaleByName( |
2124 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) | 2117 CFX_WideString::FromUTF8(szLocale).AsWideStringC()); |
2125 .AsWideStringC()); | |
2126 } | 2118 } |
2127 if (!pLocale) { | 2119 if (!pLocale) { |
2128 return FALSE; | 2120 return FALSE; |
2129 } | 2121 } |
2130 CFX_WideString wsFormat; | 2122 CFX_WideString wsFormat; |
2131 if (szFormat.IsEmpty()) { | 2123 if (szFormat.IsEmpty()) { |
2132 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2124 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
2133 } else { | 2125 } else { |
2134 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2126 wsFormat = CFX_WideString::FromUTF8(szFormat); |
2135 } | 2127 } |
2136 CXFA_LocaleValue widgetValue( | 2128 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
2137 XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()), | 2129 (CXFA_LocaleMgr*)pMgr); |
2138 (CXFA_LocaleMgr*)pMgr); | |
2139 CFX_WideString wsRet; | 2130 CFX_WideString wsRet; |
2140 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2131 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
2141 XFA_VALUEPICTURE_Display); | 2132 XFA_VALUEPICTURE_Display); |
2142 strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength()); | 2133 strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength()); |
2143 return TRUE; | 2134 return TRUE; |
2144 } | 2135 } |
2145 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, | 2136 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, |
2146 const CFX_ByteStringC& szTime, | 2137 const CFX_ByteStringC& szTime, |
2147 const CFX_ByteStringC& szFormat, | 2138 const CFX_ByteStringC& szFormat, |
2148 const CFX_ByteStringC& szLocale, | 2139 const CFX_ByteStringC& szLocale, |
2149 CFX_ByteString& strLocalTime) { | 2140 CFX_ByteString& strLocalTime) { |
2150 CXFA_FM2JSContext* pContext = | 2141 CXFA_FM2JSContext* pContext = |
2151 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2142 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
2152 CXFA_Document* pDoc = pContext->GetDocument(); | 2143 CXFA_Document* pDoc = pContext->GetDocument(); |
2153 if (!pDoc) { | 2144 if (!pDoc) { |
2154 return FALSE; | 2145 return FALSE; |
2155 } | 2146 } |
2156 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2147 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
2157 IFX_Locale* pLocale = NULL; | 2148 IFX_Locale* pLocale = NULL; |
2158 if (szLocale.IsEmpty()) { | 2149 if (szLocale.IsEmpty()) { |
2159 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2150 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
2160 FXSYS_assert(pThisNode); | 2151 FXSYS_assert(pThisNode); |
2161 CXFA_WidgetData widgetData(pThisNode); | 2152 CXFA_WidgetData widgetData(pThisNode); |
2162 pLocale = widgetData.GetLocal(); | 2153 pLocale = widgetData.GetLocal(); |
2163 } else { | 2154 } else { |
2164 pLocale = pMgr->GetLocaleByName( | 2155 pLocale = pMgr->GetLocaleByName( |
2165 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) | 2156 CFX_WideString::FromUTF8(szLocale).AsWideStringC()); |
2166 .AsWideStringC()); | |
2167 } | 2157 } |
2168 if (!pLocale) { | 2158 if (!pLocale) { |
2169 return FALSE; | 2159 return FALSE; |
2170 } | 2160 } |
2171 CFX_WideString wsFormat; | 2161 CFX_WideString wsFormat; |
2172 if (szFormat.IsEmpty()) { | 2162 if (szFormat.IsEmpty()) { |
2173 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2163 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
2174 } else { | 2164 } else { |
2175 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2165 wsFormat = CFX_WideString::FromUTF8(szFormat); |
2176 } | 2166 } |
2177 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2167 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
2178 wsFormat += FX_WSTRC(L"}"); | 2168 wsFormat += FX_WSTRC(L"}"); |
2179 CXFA_LocaleValue widgetValue( | 2169 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
2180 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()), | 2170 (CXFA_LocaleMgr*)pMgr); |
2181 (CXFA_LocaleMgr*)pMgr); | |
2182 CFX_WideString wsRet; | 2171 CFX_WideString wsRet; |
2183 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2172 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
2184 XFA_VALUEPICTURE_Display); | 2173 XFA_VALUEPICTURE_Display); |
2185 strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); | 2174 strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); |
2186 return TRUE; | 2175 return TRUE; |
2187 } | 2176 } |
2188 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, | 2177 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, |
2189 const CFX_ByteStringC& szTime, | 2178 const CFX_ByteStringC& szTime, |
2190 const CFX_ByteStringC& szFormat, | 2179 const CFX_ByteStringC& szFormat, |
2191 const CFX_ByteStringC& szLocale, | 2180 const CFX_ByteStringC& szLocale, |
2192 CFX_ByteString& strGMTTime) { | 2181 CFX_ByteString& strGMTTime) { |
2193 CXFA_FM2JSContext* pContext = | 2182 CXFA_FM2JSContext* pContext = |
2194 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2183 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
2195 CXFA_Document* pDoc = pContext->GetDocument(); | 2184 CXFA_Document* pDoc = pContext->GetDocument(); |
2196 if (!pDoc) { | 2185 if (!pDoc) { |
2197 return FALSE; | 2186 return FALSE; |
2198 } | 2187 } |
2199 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2188 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
2200 IFX_Locale* pLocale = NULL; | 2189 IFX_Locale* pLocale = NULL; |
2201 if (szLocale.IsEmpty()) { | 2190 if (szLocale.IsEmpty()) { |
2202 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2191 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
2203 FXSYS_assert(pThisNode); | 2192 FXSYS_assert(pThisNode); |
2204 CXFA_WidgetData widgetData(pThisNode); | 2193 CXFA_WidgetData widgetData(pThisNode); |
2205 pLocale = widgetData.GetLocal(); | 2194 pLocale = widgetData.GetLocal(); |
2206 } else { | 2195 } else { |
2207 pLocale = pMgr->GetLocaleByName( | 2196 pLocale = pMgr->GetLocaleByName( |
2208 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()) | 2197 CFX_WideString::FromUTF8(szLocale).AsWideStringC()); |
2209 .AsWideStringC()); | |
2210 } | 2198 } |
2211 if (!pLocale) { | 2199 if (!pLocale) { |
2212 return FALSE; | 2200 return FALSE; |
2213 } | 2201 } |
2214 CFX_WideString wsFormat; | 2202 CFX_WideString wsFormat; |
2215 if (szFormat.IsEmpty()) { | 2203 if (szFormat.IsEmpty()) { |
2216 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2204 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
2217 } else { | 2205 } else { |
2218 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); | 2206 wsFormat = CFX_WideString::FromUTF8(szFormat); |
2219 } | 2207 } |
2220 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2208 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
2221 wsFormat += FX_WSTRC(L"}"); | 2209 wsFormat += FX_WSTRC(L"}"); |
2222 CXFA_LocaleValue widgetValue( | 2210 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
2223 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()), | 2211 (CXFA_LocaleMgr*)pMgr); |
2224 (CXFA_LocaleMgr*)pMgr); | |
2225 CFX_WideString wsRet; | 2212 CFX_WideString wsRet; |
2226 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2213 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
2227 XFA_VALUEPICTURE_Display); | 2214 XFA_VALUEPICTURE_Display); |
2228 strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); | 2215 strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); |
2229 return TRUE; | 2216 return TRUE; |
2230 } | 2217 } |
2231 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { | 2218 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { |
2232 FX_BOOL bFlags = FALSE; | 2219 FX_BOOL bFlags = FALSE; |
2233 int32_t iLength = szDateString.GetLength(); | 2220 int32_t iLength = szDateString.GetLength(); |
2234 FX_BOOL iRet = FALSE; | 2221 FX_BOOL iRet = FALSE; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 } | 2369 } |
2383 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2370 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
2384 IFX_Locale* pLocale = NULL; | 2371 IFX_Locale* pLocale = NULL; |
2385 if (szLocalStr.IsEmpty()) { | 2372 if (szLocalStr.IsEmpty()) { |
2386 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2373 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
2387 FXSYS_assert(pThisNode); | 2374 FXSYS_assert(pThisNode); |
2388 CXFA_WidgetData widgetData(pThisNode); | 2375 CXFA_WidgetData widgetData(pThisNode); |
2389 pLocale = widgetData.GetLocal(); | 2376 pLocale = widgetData.GetLocal(); |
2390 } else { | 2377 } else { |
2391 pLocale = pMgr->GetLocaleByName( | 2378 pLocale = pMgr->GetLocaleByName( |
2392 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength()) | 2379 CFX_WideString::FromUTF8(szLocalStr).AsWideStringC()); |
2393 .AsWideStringC()); | |
2394 } | 2380 } |
2395 if (!pLocale) { | 2381 if (!pLocale) { |
2396 return; | 2382 return; |
2397 } | 2383 } |
2398 CFX_WideString strRet; | 2384 CFX_WideString strRet; |
2399 pLocale->GetDatePattern(strStyle, strRet); | 2385 pLocale->GetDatePattern(strStyle, strRet); |
2400 if (!bStandard) { | 2386 if (!bStandard) { |
2401 CFX_WideString wsSymbols; | 2387 CFX_WideString wsSymbols; |
2402 pLocale->GetDateTimeSymbols(wsSymbols); | 2388 pLocale->GetDateTimeSymbols(wsSymbols); |
2403 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); | 2389 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2438 } | 2424 } |
2439 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2425 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
2440 IFX_Locale* pLocale = NULL; | 2426 IFX_Locale* pLocale = NULL; |
2441 if (szLocalStr.IsEmpty()) { | 2427 if (szLocalStr.IsEmpty()) { |
2442 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2428 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
2443 FXSYS_assert(pThisNode); | 2429 FXSYS_assert(pThisNode); |
2444 CXFA_WidgetData widgetData(pThisNode); | 2430 CXFA_WidgetData widgetData(pThisNode); |
2445 pLocale = widgetData.GetLocal(); | 2431 pLocale = widgetData.GetLocal(); |
2446 } else { | 2432 } else { |
2447 pLocale = pMgr->GetLocaleByName( | 2433 pLocale = pMgr->GetLocaleByName( |
2448 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength()) | 2434 CFX_WideString::FromUTF8(szLocalStr).AsWideStringC()); |
2449 .AsWideStringC()); | |
2450 } | 2435 } |
2451 if (!pLocale) { | 2436 if (!pLocale) { |
2452 return; | 2437 return; |
2453 } | 2438 } |
2454 CFX_WideString strRet; | 2439 CFX_WideString strRet; |
2455 pLocale->GetTimePattern(strStyle, strRet); | 2440 pLocale->GetTimePattern(strStyle, strRet); |
2456 if (!bStandard) { | 2441 if (!bStandard) { |
2457 CFX_WideString wsSymbols; | 2442 CFX_WideString wsSymbols; |
2458 pLocale->GetDateTimeSymbols(wsSymbols); | 2443 pLocale->GetDateTimeSymbols(wsSymbols); |
2459 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); | 2444 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3258 if (args.GetLength() == 1) { | 3243 if (args.GetLength() == 1) { |
3259 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); | 3244 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); |
3260 CFX_ByteString utf8ScriptString; | 3245 CFX_ByteString utf8ScriptString; |
3261 HValueToUTF8String(scriptValue, utf8ScriptString); | 3246 HValueToUTF8String(scriptValue, utf8ScriptString); |
3262 if (utf8ScriptString.IsEmpty()) { | 3247 if (utf8ScriptString.IsEmpty()) { |
3263 FXJSE_Value_SetNull(args.GetReturnValue()); | 3248 FXJSE_Value_SetNull(args.GetReturnValue()); |
3264 } else { | 3249 } else { |
3265 CFX_WideTextBuf wsJavaScriptBuf; | 3250 CFX_WideTextBuf wsJavaScriptBuf; |
3266 CFX_WideString javaScript; | 3251 CFX_WideString javaScript; |
3267 CFX_WideString wsError; | 3252 CFX_WideString wsError; |
3268 XFA_FM2JS_Translate(CFX_WideString::FromUTF8(utf8ScriptString, | 3253 XFA_FM2JS_Translate( |
3269 utf8ScriptString.GetLength()) | 3254 CFX_WideString::FromUTF8(utf8ScriptString.AsByteStringC()) |
3270 .AsWideStringC(), | 3255 .AsWideStringC(), |
3271 wsJavaScriptBuf, wsError); | 3256 wsJavaScriptBuf, wsError); |
3272 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); | 3257 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); |
3273 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); | 3258 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); |
3274 javaScript = wsJavaScriptBuf.GetWideString(); | 3259 javaScript = wsJavaScriptBuf.GetWideString(); |
3275 FXJSE_ExecuteScript(hContext, | 3260 FXJSE_ExecuteScript(hContext, |
3276 FX_UTF8Encode(javaScript, javaScript.GetLength()), | 3261 FX_UTF8Encode(javaScript, javaScript.GetLength()), |
3277 returnValue); | 3262 returnValue); |
3278 FXJSE_Value_Set(args.GetReturnValue(), returnValue); | 3263 FXJSE_Value_Set(args.GetReturnValue(), returnValue); |
3279 FXJSE_Value_Release(returnValue); | 3264 FXJSE_Value_Release(returnValue); |
3280 FXJSE_Context_Release(hContext); | 3265 FXJSE_Context_Release(hContext); |
3281 } | 3266 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3382 VALUETYPE_HAVEDIGIT, | 3367 VALUETYPE_HAVEDIGIT, |
3383 VALUETYPE_HAVEDIGITWHITE, | 3368 VALUETYPE_HAVEDIGITWHITE, |
3384 VALUETYPE_ISCM, | 3369 VALUETYPE_ISCM, |
3385 VALUETYPE_ISMM, | 3370 VALUETYPE_ISMM, |
3386 VALUETYPE_ISPT, | 3371 VALUETYPE_ISPT, |
3387 VALUETYPE_ISMP, | 3372 VALUETYPE_ISMP, |
3388 VALUETYPE_ISIN, | 3373 VALUETYPE_ISIN, |
3389 }; | 3374 }; |
3390 unitspanString.MakeLower(); | 3375 unitspanString.MakeLower(); |
3391 CFX_WideString wsTypeString = | 3376 CFX_WideString wsTypeString = |
3392 CFX_WideString::FromUTF8(unitspanString, unitspanString.GetLength()); | 3377 CFX_WideString::FromUTF8(unitspanString.AsByteStringC()); |
3393 const FX_WCHAR* pData = wsTypeString; | 3378 const FX_WCHAR* pData = wsTypeString; |
3394 int32_t u = 0; | 3379 int32_t u = 0; |
3395 int32_t uLen = wsTypeString.GetLength(); | 3380 int32_t uLen = wsTypeString.GetLength(); |
3396 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || | 3381 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || |
3397 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3382 *(pData + u) == 0x0B || *(pData + u) == 0x0C || |
3398 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3383 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
3399 u++; | 3384 u++; |
3400 } | 3385 } |
3401 XFA_FM2JS_VALUETYPE_ParserStatus eParserStatus = VALUETYPE_START; | 3386 XFA_FM2JS_VALUETYPE_ParserStatus eParserStatus = VALUETYPE_START; |
3402 FX_WCHAR typeChar; | 3387 FX_WCHAR typeChar; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3742 } | 3727 } |
3743 FXJSE_Value_Release(argOne); | 3728 FXJSE_Value_Release(argOne); |
3744 FXJSE_Value_Release(argTwo); | 3729 FXJSE_Value_Release(argTwo); |
3745 } else { | 3730 } else { |
3746 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3731 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3747 L"Decode"); | 3732 L"Decode"); |
3748 } | 3733 } |
3749 } | 3734 } |
3750 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, | 3735 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, |
3751 CFX_ByteTextBuf& szResultString) { | 3736 CFX_ByteTextBuf& szResultString) { |
3752 CFX_WideString wsURLString = | 3737 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
3753 CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength()); | |
3754 const FX_WCHAR* pData = wsURLString; | 3738 const FX_WCHAR* pData = wsURLString; |
3755 int32_t iLen = wsURLString.GetLength(); | 3739 int32_t iLen = wsURLString.GetLength(); |
3756 int32_t i = 0; | 3740 int32_t i = 0; |
3757 FX_WCHAR ch = 0; | 3741 FX_WCHAR ch = 0; |
3758 FX_WCHAR chTemp = 0; | 3742 FX_WCHAR chTemp = 0; |
3759 CFX_WideTextBuf wsResultBuf; | 3743 CFX_WideTextBuf wsResultBuf; |
3760 while (i < iLen) { | 3744 while (i < iLen) { |
3761 ch = *(pData + i); | 3745 ch = *(pData + i); |
3762 if ('%' == ch) { | 3746 if ('%' == ch) { |
3763 chTemp = 0; | 3747 chTemp = 0; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3798 ++i; | 3782 ++i; |
3799 } | 3783 } |
3800 wsResultBuf.AppendChar(0); | 3784 wsResultBuf.AppendChar(0); |
3801 szResultString.Clear(); | 3785 szResultString.Clear(); |
3802 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 3786 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
3803 wsResultBuf.GetLength()) | 3787 wsResultBuf.GetLength()) |
3804 .AsByteStringC(); | 3788 .AsByteStringC(); |
3805 } | 3789 } |
3806 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, | 3790 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, |
3807 CFX_ByteTextBuf& szResultString) { | 3791 CFX_ByteTextBuf& szResultString) { |
3808 CFX_WideString wsHTMLString = | 3792 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(szHTMLString); |
3809 CFX_WideString::FromUTF8(szHTMLString.c_str(), szHTMLString.GetLength()); | |
3810 FX_WCHAR strString[9]; | 3793 FX_WCHAR strString[9]; |
3811 int32_t iStrIndex = 0; | 3794 int32_t iStrIndex = 0; |
3812 int32_t iLen = wsHTMLString.GetLength(); | 3795 int32_t iLen = wsHTMLString.GetLength(); |
3813 int32_t i = 0; | 3796 int32_t i = 0; |
3814 int32_t iCode = 0; | 3797 int32_t iCode = 0; |
3815 FX_WCHAR ch = 0; | 3798 FX_WCHAR ch = 0; |
3816 const FX_WCHAR* pData = wsHTMLString; | 3799 const FX_WCHAR* pData = wsHTMLString; |
3817 CFX_WideTextBuf wsResultBuf; | 3800 CFX_WideTextBuf wsResultBuf; |
3818 while (i < iLen) { | 3801 while (i < iLen) { |
3819 ch = *(pData + i); | 3802 ch = *(pData + i); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3873 ++i; | 3856 ++i; |
3874 } | 3857 } |
3875 wsResultBuf.AppendChar(0); | 3858 wsResultBuf.AppendChar(0); |
3876 szResultString.Clear(); | 3859 szResultString.Clear(); |
3877 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 3860 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
3878 wsResultBuf.GetLength()) | 3861 wsResultBuf.GetLength()) |
3879 .AsByteStringC(); | 3862 .AsByteStringC(); |
3880 } | 3863 } |
3881 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, | 3864 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, |
3882 CFX_ByteTextBuf& szResultString) { | 3865 CFX_ByteTextBuf& szResultString) { |
3883 CFX_WideString wsXMLString = | 3866 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); |
3884 CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength()); | |
3885 FX_WCHAR strString[9]; | 3867 FX_WCHAR strString[9]; |
3886 int32_t iStrIndex = 0; | 3868 int32_t iStrIndex = 0; |
3887 int32_t iLen = wsXMLString.GetLength(); | 3869 int32_t iLen = wsXMLString.GetLength(); |
3888 int32_t i = 0; | 3870 int32_t i = 0; |
3889 int32_t iCode = 0; | 3871 int32_t iCode = 0; |
3890 FX_WCHAR ch = 0; | 3872 FX_WCHAR ch = 0; |
3891 const FX_WCHAR* pData = wsXMLString; | 3873 const FX_WCHAR* pData = wsXMLString; |
3892 CFX_WideTextBuf wsXMLBuf; | 3874 CFX_WideTextBuf wsXMLBuf; |
3893 while (i < iLen) { | 3875 while (i < iLen) { |
3894 ch = *(pData + i); | 3876 ch = *(pData + i); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4018 } | 4000 } |
4019 FXJSE_Value_Release(argOne); | 4001 FXJSE_Value_Release(argOne); |
4020 FXJSE_Value_Release(argTwo); | 4002 FXJSE_Value_Release(argTwo); |
4021 } else { | 4003 } else { |
4022 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4004 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4023 L"Encode"); | 4005 L"Encode"); |
4024 } | 4006 } |
4025 } | 4007 } |
4026 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, | 4008 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, |
4027 CFX_ByteTextBuf& szResultBuf) { | 4009 CFX_ByteTextBuf& szResultBuf) { |
4028 CFX_WideString wsURLString = | 4010 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
4029 CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength()); | |
4030 CFX_WideTextBuf wsResultBuf; | 4011 CFX_WideTextBuf wsResultBuf; |
4031 FX_WCHAR ch = 0; | 4012 FX_WCHAR ch = 0; |
4032 int32_t iLength = wsURLString.GetLength(); | 4013 int32_t iLength = wsURLString.GetLength(); |
4033 FX_WCHAR strEncode[4]; | 4014 FX_WCHAR strEncode[4]; |
4034 strEncode[0] = '%'; | 4015 strEncode[0] = '%'; |
4035 strEncode[3] = 0; | 4016 strEncode[3] = 0; |
4036 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', | 4017 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', |
4037 '|', '\\', '^', '~', '[', ']', '`'}; | 4018 '|', '\\', '^', '~', '[', ']', '`'}; |
4038 FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'}; | 4019 FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'}; |
4039 FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','}; | 4020 FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','}; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4127 } | 4108 } |
4128 } | 4109 } |
4129 wsResultBuf.AppendChar(0); | 4110 wsResultBuf.AppendChar(0); |
4130 szResultBuf.Clear(); | 4111 szResultBuf.Clear(); |
4131 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4112 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
4132 .AsByteStringC(); | 4113 .AsByteStringC(); |
4133 } | 4114 } |
4134 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, | 4115 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, |
4135 CFX_ByteTextBuf& szResultBuf) { | 4116 CFX_ByteTextBuf& szResultBuf) { |
4136 CFX_ByteString str = szHTMLString.c_str(); | 4117 CFX_ByteString str = szHTMLString.c_str(); |
4137 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength()); | 4118 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str.AsByteStringC()); |
4138 const FX_WCHAR* strCode = L"0123456789abcdef"; | 4119 const FX_WCHAR* strCode = L"0123456789abcdef"; |
4139 FX_WCHAR strEncode[9]; | 4120 FX_WCHAR strEncode[9]; |
4140 strEncode[0] = '&'; | 4121 strEncode[0] = '&'; |
4141 strEncode[1] = '#'; | 4122 strEncode[1] = '#'; |
4142 strEncode[2] = 'x'; | 4123 strEncode[2] = 'x'; |
4143 strEncode[5] = ';'; | 4124 strEncode[5] = ';'; |
4144 strEncode[6] = 0; | 4125 strEncode[6] = 0; |
4145 strEncode[7] = ';'; | 4126 strEncode[7] = ';'; |
4146 strEncode[8] = 0; | 4127 strEncode[8] = 0; |
4147 CFX_WideTextBuf wsResultBuf; | 4128 CFX_WideTextBuf wsResultBuf; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4180 } | 4161 } |
4181 ++i; | 4162 ++i; |
4182 } | 4163 } |
4183 wsResultBuf.AppendChar(0); | 4164 wsResultBuf.AppendChar(0); |
4184 szResultBuf.Clear(); | 4165 szResultBuf.Clear(); |
4185 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4166 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
4186 .AsByteStringC(); | 4167 .AsByteStringC(); |
4187 } | 4168 } |
4188 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, | 4169 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, |
4189 CFX_ByteTextBuf& szResultBuf) { | 4170 CFX_ByteTextBuf& szResultBuf) { |
4190 CFX_WideString wsXMLString = | 4171 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); |
4191 CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength()); | |
4192 CFX_WideTextBuf wsResultBuf; | 4172 CFX_WideTextBuf wsResultBuf; |
4193 enum { | 4173 enum { |
4194 QUOT, | 4174 QUOT, |
4195 AMP, | 4175 AMP, |
4196 APOS, | 4176 APOS, |
4197 LT, | 4177 LT, |
4198 GT, | 4178 GT, |
4199 }; | 4179 }; |
4200 FX_WCHAR strEncode[9]; | 4180 FX_WCHAR strEncode[9]; |
4201 strEncode[0] = '&'; | 4181 strEncode[0] = '&'; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4304 } else if (iCode < htmlreservecode.m_uCode) { | 4284 } else if (iCode < htmlreservecode.m_uCode) { |
4305 iEnd = iMid - 1; | 4285 iEnd = iMid - 1; |
4306 } else { | 4286 } else { |
4307 iStart = iMid + 1; | 4287 iStart = iMid + 1; |
4308 } | 4288 } |
4309 } while (iStart <= iEnd); | 4289 } while (iStart <= iEnd); |
4310 return FALSE; | 4290 return FALSE; |
4311 } | 4291 } |
4312 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, | 4292 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, |
4313 uint32_t& patternType) { | 4293 uint32_t& patternType) { |
4314 CFX_WideString wsPattern = | 4294 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern); |
4315 CFX_WideString::FromUTF8(szPattern.c_str(), szPattern.GetLength()); | |
4316 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { | 4295 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { |
4317 patternType = XFA_VT_DATETIME; | 4296 patternType = XFA_VT_DATETIME; |
4318 return TRUE; | 4297 return TRUE; |
4319 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { | 4298 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { |
4320 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; | 4299 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; |
4321 return TRUE; | 4300 return TRUE; |
4322 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { | 4301 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { |
4323 patternType = XFA_VT_TIME; | 4302 patternType = XFA_VT_TIME; |
4324 return TRUE; | 4303 return TRUE; |
4325 } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { | 4304 } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4410 CXFA_Document* pDoc = pContext->GetDocument(); | 4389 CXFA_Document* pDoc = pContext->GetDocument(); |
4411 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4390 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
4412 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4391 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
4413 FXSYS_assert(pThisNode); | 4392 FXSYS_assert(pThisNode); |
4414 CXFA_WidgetData widgetData(pThisNode); | 4393 CXFA_WidgetData widgetData(pThisNode); |
4415 IFX_Locale* pLocale = widgetData.GetLocal(); | 4394 IFX_Locale* pLocale = widgetData.GetLocal(); |
4416 uint32_t patternType; | 4395 uint32_t patternType; |
4417 FX_BOOL bCompelte = | 4396 FX_BOOL bCompelte = |
4418 XFA_PATTERN_STRING_Type(szPattern.AsByteStringC(), patternType); | 4397 XFA_PATTERN_STRING_Type(szPattern.AsByteStringC(), patternType); |
4419 CFX_WideString wsPattern = | 4398 CFX_WideString wsPattern = |
4420 CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); | 4399 CFX_WideString::FromUTF8(szPattern.AsByteStringC()); |
4421 CFX_WideString wsValue = | 4400 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsByteStringC()); |
4422 CFX_WideString::FromUTF8(szValue, szValue.GetLength()); | |
4423 if (!bCompelte) { | 4401 if (!bCompelte) { |
4424 switch (patternType) { | 4402 switch (patternType) { |
4425 case XFA_VT_DATETIME: { | 4403 case XFA_VT_DATETIME: { |
4426 FX_STRSIZE iTChar = wsPattern.Find(L'T'); | 4404 FX_STRSIZE iTChar = wsPattern.Find(L'T'); |
4427 CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); | 4405 CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); |
4428 wsDatePattern += wsPattern.Left(iTChar); | 4406 wsDatePattern += wsPattern.Left(iTChar); |
4429 wsDatePattern += FX_WSTRC(L"} "); | 4407 wsDatePattern += FX_WSTRC(L"} "); |
4430 CFX_WideString wsTimePattern = FX_WSTRC(L"time{"); | 4408 CFX_WideString wsTimePattern = FX_WSTRC(L"time{"); |
4431 wsTimePattern += wsPattern.Mid(iTChar + 1); | 4409 wsTimePattern += wsPattern.Mid(iTChar + 1); |
4432 wsTimePattern += FX_WSTRC(L"}"); | 4410 wsTimePattern += FX_WSTRC(L"}"); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4545 FXJSE_HVALUE localeValue = 0; | 4523 FXJSE_HVALUE localeValue = 0; |
4546 if (HValueIsNull(hThis, argOne)) { | 4524 if (HValueIsNull(hThis, argOne)) { |
4547 FXJSE_Value_SetNull(args.GetReturnValue()); | 4525 FXJSE_Value_SetNull(args.GetReturnValue()); |
4548 } else { | 4526 } else { |
4549 if (argc == 2) { | 4527 if (argc == 2) { |
4550 localeValue = GetSimpleHValue(hThis, args, 1); | 4528 localeValue = GetSimpleHValue(hThis, args, 1); |
4551 } | 4529 } |
4552 HValueToUTF8String(argOne, argString); | 4530 HValueToUTF8String(argOne, argString); |
4553 CFX_WideTextBuf lowStringBuf; | 4531 CFX_WideTextBuf lowStringBuf; |
4554 CFX_WideString wsArgString = | 4532 CFX_WideString wsArgString = |
4555 CFX_WideString::FromUTF8(argString, argString.GetLength()); | 4533 CFX_WideString::FromUTF8(argString.AsByteStringC()); |
4556 const FX_WCHAR* pData = wsArgString; | 4534 const FX_WCHAR* pData = wsArgString; |
4557 int32_t iLen = argString.GetLength(); | 4535 int32_t iLen = argString.GetLength(); |
4558 int32_t i = 0; | 4536 int32_t i = 0; |
4559 int32_t ch = 0; | 4537 int32_t ch = 0; |
4560 while (i < iLen) { | 4538 while (i < iLen) { |
4561 ch = *(pData + i); | 4539 ch = *(pData + i); |
4562 if (ch >= 0x41 && ch <= 0x5A) { | 4540 if (ch >= 0x41 && ch <= 0x5A) { |
4563 ch += 32; | 4541 ch += 32; |
4564 } else if (ch >= 0xC0 && ch <= 0xDE) { | 4542 } else if (ch >= 0xC0 && ch <= 0xDE) { |
4565 ch += 32; | 4543 ch += 32; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4626 CXFA_Document* pDoc = pContext->GetDocument(); | 4604 CXFA_Document* pDoc = pContext->GetDocument(); |
4627 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4605 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
4628 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4606 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
4629 FXSYS_assert(pThisNode); | 4607 FXSYS_assert(pThisNode); |
4630 CXFA_WidgetData widgetData(pThisNode); | 4608 CXFA_WidgetData widgetData(pThisNode); |
4631 IFX_Locale* pLocale = widgetData.GetLocal(); | 4609 IFX_Locale* pLocale = widgetData.GetLocal(); |
4632 uint32_t patternType; | 4610 uint32_t patternType; |
4633 FX_BOOL bCompletePattern = | 4611 FX_BOOL bCompletePattern = |
4634 XFA_PATTERN_STRING_Type(szPattern.AsByteStringC(), patternType); | 4612 XFA_PATTERN_STRING_Type(szPattern.AsByteStringC(), patternType); |
4635 CFX_WideString wsPattern = | 4613 CFX_WideString wsPattern = |
4636 CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); | 4614 CFX_WideString::FromUTF8(szPattern.AsByteStringC()); |
4637 CFX_WideString wsValue = | 4615 CFX_WideString wsValue = |
4638 CFX_WideString::FromUTF8(szValue, szValue.GetLength()); | 4616 CFX_WideString::FromUTF8(szValue.AsByteStringC()); |
4639 CFX_ByteString szParsedValue; | 4617 CFX_ByteString szParsedValue; |
4640 if (bCompletePattern) { | 4618 if (bCompletePattern) { |
4641 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, | 4619 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, |
4642 (CXFA_LocaleMgr*)pMgr); | 4620 (CXFA_LocaleMgr*)pMgr); |
4643 if (localeValue.IsValid()) { | 4621 if (localeValue.IsValid()) { |
4644 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); | 4622 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); |
4645 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4623 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
4646 szParsedValue.AsByteStringC()); | 4624 szParsedValue.AsByteStringC()); |
4647 } else { | 4625 } else { |
4648 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4626 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5173 FXJSE_HVALUE localeValue = 0; | 5151 FXJSE_HVALUE localeValue = 0; |
5174 if (HValueIsNull(hThis, argOne)) { | 5152 if (HValueIsNull(hThis, argOne)) { |
5175 FXJSE_Value_SetNull(args.GetReturnValue()); | 5153 FXJSE_Value_SetNull(args.GetReturnValue()); |
5176 } else { | 5154 } else { |
5177 if (argc == 2) { | 5155 if (argc == 2) { |
5178 localeValue = GetSimpleHValue(hThis, args, 1); | 5156 localeValue = GetSimpleHValue(hThis, args, 1); |
5179 } | 5157 } |
5180 HValueToUTF8String(argOne, argString); | 5158 HValueToUTF8String(argOne, argString); |
5181 CFX_WideTextBuf upperStringBuf; | 5159 CFX_WideTextBuf upperStringBuf; |
5182 CFX_WideString wsArgString = | 5160 CFX_WideString wsArgString = |
5183 CFX_WideString::FromUTF8(argString, argString.GetLength()); | 5161 CFX_WideString::FromUTF8(argString.AsByteStringC()); |
5184 const FX_WCHAR* pData = wsArgString; | 5162 const FX_WCHAR* pData = wsArgString; |
5185 int32_t iLen = wsArgString.GetLength(); | 5163 int32_t iLen = wsArgString.GetLength(); |
5186 int32_t i = 0; | 5164 int32_t i = 0; |
5187 int32_t ch = 0; | 5165 int32_t ch = 0; |
5188 while (i < iLen) { | 5166 while (i < iLen) { |
5189 ch = *(pData + i); | 5167 ch = *(pData + i); |
5190 if (ch >= 0x61 && ch <= 0x7A) { | 5168 if (ch >= 0x61 && ch <= 0x7A) { |
5191 ch -= 32; | 5169 ch -= 32; |
5192 } else if (ch >= 0xE0 && ch <= 0xFE) { | 5170 } else if (ch >= 0xE0 && ch <= 0xFE) { |
5193 ch -= 32; | 5171 ch -= 32; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5483 } | 5461 } |
5484 IXFA_AppProvider* pAppProvider = | 5462 IXFA_AppProvider* pAppProvider = |
5485 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5463 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
5486 if (!pAppProvider) { | 5464 if (!pAppProvider) { |
5487 return; | 5465 return; |
5488 } | 5466 } |
5489 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5467 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); |
5490 CFX_ByteString urlString; | 5468 CFX_ByteString urlString; |
5491 HValueToUTF8String(argOne, urlString); | 5469 HValueToUTF8String(argOne, urlString); |
5492 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 5470 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
5493 CFX_WideString::FromUTF8(urlString, urlString.GetLength()) | 5471 CFX_WideString::FromUTF8(urlString.AsByteStringC()).AsWideStringC()); |
5494 .AsWideStringC()); | |
5495 if (pFile) { | 5472 if (pFile) { |
5496 int32_t size = pFile->GetSize(); | 5473 int32_t size = pFile->GetSize(); |
5497 uint8_t* pData = FX_Alloc(uint8_t, size); | 5474 uint8_t* pData = FX_Alloc(uint8_t, size); |
5498 pFile->ReadBlock(pData, size); | 5475 pFile->ReadBlock(pData, size); |
5499 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5476 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
5500 CFX_ByteStringC(pData, size)); | 5477 CFX_ByteStringC(pData, size)); |
5501 FX_Free(pData); | 5478 FX_Free(pData); |
5502 pFile->Release(); | 5479 pFile->Release(); |
5503 } | 5480 } |
5504 FXJSE_Value_Release(argOne); | 5481 FXJSE_Value_Release(argOne); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5544 if (argc > 3) { | 5521 if (argc > 3) { |
5545 argFour = GetSimpleHValue(hThis, args, 3); | 5522 argFour = GetSimpleHValue(hThis, args, 3); |
5546 HValueToUTF8String(argFour, bsEncode); | 5523 HValueToUTF8String(argFour, bsEncode); |
5547 } | 5524 } |
5548 if (argc > 4) { | 5525 if (argc > 4) { |
5549 argFive = GetSimpleHValue(hThis, args, 4); | 5526 argFive = GetSimpleHValue(hThis, args, 4); |
5550 HValueToUTF8String(argFive, bsHeader); | 5527 HValueToUTF8String(argFive, bsHeader); |
5551 } | 5528 } |
5552 CFX_WideString decodedResponse; | 5529 CFX_WideString decodedResponse; |
5553 FX_BOOL bFlags = pAppProvider->PostRequestURL( | 5530 FX_BOOL bFlags = pAppProvider->PostRequestURL( |
5554 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(), | 5531 CFX_WideString::FromUTF8(bsURL.AsByteStringC()).AsWideStringC(), |
5555 CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(), | 5532 CFX_WideString::FromUTF8(bsData.AsByteStringC()).AsWideStringC(), |
5556 CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength()) | 5533 CFX_WideString::FromUTF8(bsContentType.AsByteStringC()).AsWideStringC(), |
5557 .AsWideStringC(), | 5534 CFX_WideString::FromUTF8(bsEncode.AsByteStringC()).AsWideStringC(), |
5558 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()) | 5535 CFX_WideString::FromUTF8(bsHeader.AsByteStringC()).AsWideStringC(), |
5559 .AsWideStringC(), | |
5560 CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength()) | |
5561 .AsWideStringC(), | |
5562 decodedResponse); | 5536 decodedResponse); |
5563 FXJSE_Value_Release(argOne); | 5537 FXJSE_Value_Release(argOne); |
5564 FXJSE_Value_Release(argTwo); | 5538 FXJSE_Value_Release(argTwo); |
5565 if (argc > 2) { | 5539 if (argc > 2) { |
5566 FXJSE_Value_Release(argThree); | 5540 FXJSE_Value_Release(argThree); |
5567 } | 5541 } |
5568 if (argc > 3) { | 5542 if (argc > 3) { |
5569 FXJSE_Value_Release(argFour); | 5543 FXJSE_Value_Release(argFour); |
5570 } | 5544 } |
5571 if (argc > 4) { | 5545 if (argc > 4) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5608 FXJSE_HVALUE argThree; | 5582 FXJSE_HVALUE argThree; |
5609 argOne = GetSimpleHValue(hThis, args, 0); | 5583 argOne = GetSimpleHValue(hThis, args, 0); |
5610 HValueToUTF8String(argOne, bsURL); | 5584 HValueToUTF8String(argOne, bsURL); |
5611 argTwo = GetSimpleHValue(hThis, args, 1); | 5585 argTwo = GetSimpleHValue(hThis, args, 1); |
5612 HValueToUTF8String(argTwo, bsData); | 5586 HValueToUTF8String(argTwo, bsData); |
5613 if (argc > 2) { | 5587 if (argc > 2) { |
5614 argThree = GetSimpleHValue(hThis, args, 2); | 5588 argThree = GetSimpleHValue(hThis, args, 2); |
5615 HValueToUTF8String(argThree, bsEncode); | 5589 HValueToUTF8String(argThree, bsEncode); |
5616 } | 5590 } |
5617 FX_BOOL bFlags = pAppProvider->PutRequestURL( | 5591 FX_BOOL bFlags = pAppProvider->PutRequestURL( |
5618 CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(), | 5592 CFX_WideString::FromUTF8(bsURL.AsByteStringC()).AsWideStringC(), |
5619 CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(), | 5593 CFX_WideString::FromUTF8(bsData.AsByteStringC()).AsWideStringC(), |
5620 CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()) | 5594 CFX_WideString::FromUTF8(bsEncode.AsByteStringC()).AsWideStringC()); |
5621 .AsWideStringC()); | |
5622 FXJSE_Value_Release(argOne); | 5595 FXJSE_Value_Release(argOne); |
5623 FXJSE_Value_Release(argTwo); | 5596 FXJSE_Value_Release(argTwo); |
5624 if (argc > 2) { | 5597 if (argc > 2) { |
5625 FXJSE_Value_Release(argThree); | 5598 FXJSE_Value_Release(argThree); |
5626 } | 5599 } |
5627 if (bFlags) { | 5600 if (bFlags) { |
5628 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5601 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
5629 } else { | 5602 } else { |
5630 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5603 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
5631 } | 5604 } |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6174 iIndex++; | 6147 iIndex++; |
6175 } | 6148 } |
6176 } | 6149 } |
6177 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); | 6150 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); |
6178 for (int32_t i = 0; i < (iCounter + 2); i++) { | 6151 for (int32_t i = 0; i < (iCounter + 2); i++) { |
6179 FXJSE_Value_Release(rgValues[i]); | 6152 FXJSE_Value_Release(rgValues[i]); |
6180 } | 6153 } |
6181 FX_Free(rgValues); | 6154 FX_Free(rgValues); |
6182 } else { | 6155 } else { |
6183 CFX_WideString wsPropertyName = | 6156 CFX_WideString wsPropertyName = |
6184 CFX_WideString::FromUTF8(szName, szName.GetLength()); | 6157 CFX_WideString::FromUTF8(szName.AsByteStringC()); |
6185 CFX_WideString wsSomExpression = | 6158 CFX_WideString wsSomExpression = |
6186 CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); | 6159 CFX_WideString::FromUTF8(szSomExp.AsByteStringC()); |
6187 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6160 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
6188 (const FX_WCHAR*)wsPropertyName, | 6161 (const FX_WCHAR*)wsPropertyName, |
6189 (const FX_WCHAR*)wsSomExpression); | 6162 (const FX_WCHAR*)wsSomExpression); |
6190 } | 6163 } |
6191 for (int32_t i = 0; i < iLength - 2; i++) { | 6164 for (int32_t i = 0; i < iLength - 2; i++) { |
6192 for (int32_t j = 0; j < iSizes[i]; j++) { | 6165 for (int32_t j = 0; j < iSizes[i]; j++) { |
6193 FXJSE_Value_Release(hResolveValues[i][j]); | 6166 FXJSE_Value_Release(hResolveValues[i][j]); |
6194 } | 6167 } |
6195 if (iSizes[i] > 0) { | 6168 if (iSizes[i] > 0) { |
6196 FX_Free(hResolveValues[i]); | 6169 FX_Free(hResolveValues[i]); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6237 for (int32_t i = 0; i < (iSize + 2); i++) { | 6210 for (int32_t i = 0; i < (iSize + 2); i++) { |
6238 FXJSE_Value_Release(rgValues[i]); | 6211 FXJSE_Value_Release(rgValues[i]); |
6239 } | 6212 } |
6240 FX_Free(rgValues); | 6213 FX_Free(rgValues); |
6241 for (int32_t i = 0; i < iSize; i++) { | 6214 for (int32_t i = 0; i < iSize; i++) { |
6242 FXJSE_Value_Release(hResolveValues[i]); | 6215 FXJSE_Value_Release(hResolveValues[i]); |
6243 } | 6216 } |
6244 FX_Free(hResolveValues); | 6217 FX_Free(hResolveValues); |
6245 } else { | 6218 } else { |
6246 CFX_WideString wsPropertyName = | 6219 CFX_WideString wsPropertyName = |
6247 CFX_WideString::FromUTF8(szName, szName.GetLength()); | 6220 CFX_WideString::FromUTF8(szName.AsByteStringC()); |
6248 CFX_WideString wsSomExpression = | 6221 CFX_WideString wsSomExpression = |
6249 CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); | 6222 CFX_WideString::FromUTF8(szSomExp.AsByteStringC()); |
6250 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6223 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
6251 (const FX_WCHAR*)wsPropertyName, | 6224 (const FX_WCHAR*)wsPropertyName, |
6252 (const FX_WCHAR*)wsSomExpression); | 6225 (const FX_WCHAR*)wsSomExpression); |
6253 } | 6226 } |
6254 } | 6227 } |
6255 if (argc == 5) { | 6228 if (argc == 5) { |
6256 FXJSE_Value_Release(argIndex); | 6229 FXJSE_Value_Release(argIndex); |
6257 } | 6230 } |
6258 FXJSE_Value_Release(argAccessor); | 6231 FXJSE_Value_Release(argAccessor); |
6259 } else { | 6232 } else { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6322 iIndex++; | 6295 iIndex++; |
6323 } | 6296 } |
6324 } | 6297 } |
6325 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); | 6298 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); |
6326 for (int32_t i = 0; i < (iCounter + 2); i++) { | 6299 for (int32_t i = 0; i < (iCounter + 2); i++) { |
6327 FXJSE_Value_Release(rgValues[i]); | 6300 FXJSE_Value_Release(rgValues[i]); |
6328 } | 6301 } |
6329 FX_Free(rgValues); | 6302 FX_Free(rgValues); |
6330 } else { | 6303 } else { |
6331 CFX_WideString wsPropertyName = | 6304 CFX_WideString wsPropertyName = |
6332 CFX_WideString::FromUTF8(szName, szName.GetLength()); | 6305 CFX_WideString::FromUTF8(szName.AsByteStringC()); |
6333 CFX_WideString wsSomExpression = | 6306 CFX_WideString wsSomExpression = |
6334 CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); | 6307 CFX_WideString::FromUTF8(szSomExp.AsByteStringC()); |
6335 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6308 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
6336 (const FX_WCHAR*)wsPropertyName, | 6309 (const FX_WCHAR*)wsPropertyName, |
6337 (const FX_WCHAR*)wsSomExpression); | 6310 (const FX_WCHAR*)wsSomExpression); |
6338 } | 6311 } |
6339 for (int32_t i = 0; i < iLength - 2; i++) { | 6312 for (int32_t i = 0; i < iLength - 2; i++) { |
6340 for (int32_t j = 0; j < iSizes[i]; j++) { | 6313 for (int32_t j = 0; j < iSizes[i]; j++) { |
6341 FXJSE_Value_Release(hResolveValues[i][j]); | 6314 FXJSE_Value_Release(hResolveValues[i][j]); |
6342 } | 6315 } |
6343 FX_Free(hResolveValues[i]); | 6316 FX_Free(hResolveValues[i]); |
6344 } | 6317 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6384 for (int32_t i = 0; i < (iSize + 2); i++) { | 6357 for (int32_t i = 0; i < (iSize + 2); i++) { |
6385 FXJSE_Value_Release(rgValues[i]); | 6358 FXJSE_Value_Release(rgValues[i]); |
6386 } | 6359 } |
6387 FX_Free(rgValues); | 6360 FX_Free(rgValues); |
6388 for (int32_t i = 0; i < iSize; i++) { | 6361 for (int32_t i = 0; i < iSize; i++) { |
6389 FXJSE_Value_Release(hResolveValues[i]); | 6362 FXJSE_Value_Release(hResolveValues[i]); |
6390 } | 6363 } |
6391 FX_Free(hResolveValues); | 6364 FX_Free(hResolveValues); |
6392 } else { | 6365 } else { |
6393 CFX_WideString wsPropertyName = | 6366 CFX_WideString wsPropertyName = |
6394 CFX_WideString::FromUTF8(szName, szName.GetLength()); | 6367 CFX_WideString::FromUTF8(szName.AsByteStringC()); |
6395 CFX_WideString wsSomExpression = | 6368 CFX_WideString wsSomExpression = |
6396 CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); | 6369 CFX_WideString::FromUTF8(szSomExp.AsByteStringC()); |
6397 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6370 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
6398 (const FX_WCHAR*)wsPropertyName, | 6371 (const FX_WCHAR*)wsPropertyName, |
6399 (const FX_WCHAR*)wsSomExpression); | 6372 (const FX_WCHAR*)wsSomExpression); |
6400 } | 6373 } |
6401 } | 6374 } |
6402 if (argc == 5) { | 6375 if (argc == 5) { |
6403 FXJSE_Value_Release(argIndex); | 6376 FXJSE_Value_Release(argIndex); |
6404 } | 6377 } |
6405 FXJSE_Value_Release(argAccessor); | 6378 FXJSE_Value_Release(argAccessor); |
6406 } else { | 6379 } else { |
6407 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6380 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6408 } | 6381 } |
6409 } | 6382 } |
6410 void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis, | 6383 void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis, |
6411 const CFX_ByteStringC& szFuncName, | 6384 const CFX_ByteStringC& szFuncName, |
6412 CFXJSE_Arguments& args) { | 6385 CFXJSE_Arguments& args) { |
6413 CXFA_FM2JSContext* pContext = | 6386 CXFA_FM2JSContext* pContext = |
6414 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6387 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
6415 int32_t argc = args.GetLength(); | 6388 int32_t argc = args.GetLength(); |
6416 if (argc == 1) { | 6389 if (argc == 1) { |
6417 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 6390 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); |
6418 CFX_ByteString argString; | 6391 CFX_ByteString argString; |
6419 HValueToUTF8String(argOne, argString); | 6392 HValueToUTF8String(argOne, argString); |
6420 if (argString.IsEmpty()) { | 6393 if (argString.IsEmpty()) { |
6421 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6394 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
6422 } else { | 6395 } else { |
6423 CFX_WideString scriptString = | 6396 CFX_WideString scriptString = |
6424 CFX_WideString::FromUTF8(argString, argString.GetLength()); | 6397 CFX_WideString::FromUTF8(argString.AsByteStringC()); |
6425 CFX_WideTextBuf wsJavaScriptBuf; | 6398 CFX_WideTextBuf wsJavaScriptBuf; |
6426 CFX_WideString wsError; | 6399 CFX_WideString wsError; |
6427 XFA_FM2JS_Translate(scriptString.AsWideStringC(), wsJavaScriptBuf, | 6400 XFA_FM2JS_Translate(scriptString.AsWideStringC(), wsJavaScriptBuf, |
6428 wsError); | 6401 wsError); |
6429 if (wsError.IsEmpty()) { | 6402 if (wsError.IsEmpty()) { |
6430 CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); | 6403 CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); |
6431 FXJSE_Value_SetUTF8String( | 6404 FXJSE_Value_SetUTF8String( |
6432 args.GetReturnValue(), | 6405 args.GetReturnValue(), |
6433 FX_UTF8Encode(javaScript, javaScript.GetLength()).AsByteStringC()); | 6406 FX_UTF8Encode(javaScript, javaScript.GetLength()).AsByteStringC()); |
6434 } else { | 6407 } else { |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6886 CXFA_Document* pDoc = pContext->GetDocument(); | 6859 CXFA_Document* pDoc = pContext->GetDocument(); |
6887 if (!pDoc) { | 6860 if (!pDoc) { |
6888 return bFlags; | 6861 return bFlags; |
6889 } | 6862 } |
6890 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6863 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6891 XFA_RESOLVENODE_RS resoveNodeRS; | 6864 XFA_RESOLVENODE_RS resoveNodeRS; |
6892 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6865 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
6893 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6866 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
6894 int32_t iRet = pScriptContext->ResolveObjects( | 6867 int32_t iRet = pScriptContext->ResolveObjects( |
6895 pScriptContext->GetThisObject(), | 6868 pScriptContext->GetThisObject(), |
6896 CFX_WideString::FromUTF8(szAccessorName.c_str(), | 6869 CFX_WideString::FromUTF8(szAccessorName).AsWideStringC(), resoveNodeRS, |
6897 szAccessorName.GetLength()) | 6870 dwFlags); |
6898 .AsWideStringC(), | |
6899 resoveNodeRS, dwFlags); | |
6900 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6871 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
6901 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6872 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
6902 resoveNodeRS.nodes.GetAt(0))); | 6873 resoveNodeRS.nodes.GetAt(0))); |
6903 bFlags = TRUE; | 6874 bFlags = TRUE; |
6904 } | 6875 } |
6905 return bFlags; | 6876 return bFlags; |
6906 } | 6877 } |
6907 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, | 6878 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, |
6908 FXJSE_HVALUE hRefValue, | 6879 FXJSE_HVALUE hRefValue, |
6909 const CFX_ByteStringC& bsSomExp, | 6880 const CFX_ByteStringC& bsSomExp, |
6910 XFA_RESOLVENODE_RS& resoveNodeRS, | 6881 XFA_RESOLVENODE_RS& resoveNodeRS, |
6911 FX_BOOL bdotAccessor, | 6882 FX_BOOL bdotAccessor, |
6912 FX_BOOL bHasNoResolveName) { | 6883 FX_BOOL bHasNoResolveName) { |
6913 CFX_WideString wsSomExpression = | 6884 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); |
6914 CFX_WideString::FromUTF8(bsSomExp.c_str(), bsSomExp.GetLength()); | |
6915 int32_t iRet = -1; | 6885 int32_t iRet = -1; |
6916 CXFA_FM2JSContext* pContext = | 6886 CXFA_FM2JSContext* pContext = |
6917 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6887 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
6918 CXFA_Document* pDoc = pContext->GetDocument(); | 6888 CXFA_Document* pDoc = pContext->GetDocument(); |
6919 if (!pDoc) { | 6889 if (!pDoc) { |
6920 return iRet; | 6890 return iRet; |
6921 } | 6891 } |
6922 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6892 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6923 CXFA_Object* pNode = NULL; | 6893 CXFA_Object* pNode = NULL; |
6924 uint32_t dFlags = 0UL; | 6894 uint32_t dFlags = 0UL; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7272 CFX_WideString wsFormat; | 7242 CFX_WideString wsFormat; |
7273 pAppProvider->LoadString(iStringID, wsFormat); | 7243 pAppProvider->LoadString(iStringID, wsFormat); |
7274 CFX_WideString wsMessage; | 7244 CFX_WideString wsMessage; |
7275 va_list arg_ptr; | 7245 va_list arg_ptr; |
7276 va_start(arg_ptr, iStringID); | 7246 va_start(arg_ptr, iStringID); |
7277 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7247 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
7278 va_end(arg_ptr); | 7248 va_end(arg_ptr); |
7279 FXJSE_ThrowMessage( | 7249 FXJSE_ThrowMessage( |
7280 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC()); | 7250 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC()); |
7281 } | 7251 } |
OLD | NEW |