| 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 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 } | 2019 } |
| 2020 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2020 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2021 IFX_Locale* pLocale = NULL; | 2021 IFX_Locale* pLocale = NULL; |
| 2022 if (szLocale.IsEmpty()) { | 2022 if (szLocale.IsEmpty()) { |
| 2023 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2023 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2024 FXSYS_assert(pThisNode); | 2024 FXSYS_assert(pThisNode); |
| 2025 CXFA_WidgetData widgetData(pThisNode); | 2025 CXFA_WidgetData widgetData(pThisNode); |
| 2026 pLocale = widgetData.GetLocal(); | 2026 pLocale = widgetData.GetLocal(); |
| 2027 } else { | 2027 } else { |
| 2028 pLocale = pMgr->GetLocaleByName( | 2028 pLocale = pMgr->GetLocaleByName( |
| 2029 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2029 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); |
| 2030 } | 2030 } |
| 2031 if (!pLocale) { | 2031 if (!pLocale) { |
| 2032 return FALSE; | 2032 return FALSE; |
| 2033 } | 2033 } |
| 2034 CFX_WideString wsFormat; | 2034 CFX_WideString wsFormat; |
| 2035 if (szFormat.IsEmpty()) { | 2035 if (szFormat.IsEmpty()) { |
| 2036 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2036 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2037 } else { | 2037 } else { |
| 2038 wsFormat = | 2038 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2039 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | |
| 2040 } | 2039 } |
| 2041 CXFA_LocaleValue widgetValue( | 2040 CXFA_LocaleValue widgetValue( |
| 2042 XFA_VT_DATE, | 2041 XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()), |
| 2043 CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()), wsFormat, | 2042 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2044 pLocale, (CXFA_LocaleMgr*)pMgr); | |
| 2045 CFX_Unitime dt = widgetValue.GetDate(); | 2043 CFX_Unitime dt = widgetValue.GetDate(); |
| 2046 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); | 2044 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); |
| 2047 return TRUE; | 2045 return TRUE; |
| 2048 } | 2046 } |
| 2049 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, | 2047 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, |
| 2050 const CFX_ByteStringC& szTime, | 2048 const CFX_ByteStringC& szTime, |
| 2051 const CFX_ByteStringC& szFormat, | 2049 const CFX_ByteStringC& szFormat, |
| 2052 const CFX_ByteStringC& szLocale, | 2050 const CFX_ByteStringC& szLocale, |
| 2053 CFX_ByteString& strIsoTime) { | 2051 CFX_ByteString& strIsoTime) { |
| 2054 CXFA_FM2JSContext* pContext = | 2052 CXFA_FM2JSContext* pContext = |
| 2055 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2053 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
| 2056 CXFA_Document* pDoc = pContext->GetDocument(); | 2054 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2057 if (!pDoc) { | 2055 if (!pDoc) { |
| 2058 return FALSE; | 2056 return FALSE; |
| 2059 } | 2057 } |
| 2060 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2058 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2061 IFX_Locale* pLocale = NULL; | 2059 IFX_Locale* pLocale = NULL; |
| 2062 if (szLocale.IsEmpty()) { | 2060 if (szLocale.IsEmpty()) { |
| 2063 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2061 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2064 FXSYS_assert(pThisNode); | 2062 FXSYS_assert(pThisNode); |
| 2065 CXFA_WidgetData widgetData(pThisNode); | 2063 CXFA_WidgetData widgetData(pThisNode); |
| 2066 pLocale = widgetData.GetLocal(); | 2064 pLocale = widgetData.GetLocal(); |
| 2067 } else { | 2065 } else { |
| 2068 pLocale = pMgr->GetLocaleByName( | 2066 pLocale = pMgr->GetLocaleByName( |
| 2069 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2067 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); |
| 2070 } | 2068 } |
| 2071 if (!pLocale) { | 2069 if (!pLocale) { |
| 2072 return FALSE; | 2070 return FALSE; |
| 2073 } | 2071 } |
| 2074 CFX_WideString wsFormat; | 2072 CFX_WideString wsFormat; |
| 2075 if (szFormat.IsEmpty()) { | 2073 if (szFormat.IsEmpty()) { |
| 2076 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2074 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2077 } else { | 2075 } else { |
| 2078 wsFormat = | 2076 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2079 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | |
| 2080 } | 2077 } |
| 2081 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2078 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2082 wsFormat += FX_WSTRC(L"}"); | 2079 wsFormat += FX_WSTRC(L"}"); |
| 2083 CXFA_LocaleValue widgetValue( | 2080 CXFA_LocaleValue widgetValue( |
| 2084 XFA_VT_TIME, | 2081 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()), |
| 2085 CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), wsFormat, | 2082 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2086 pLocale, (CXFA_LocaleMgr*)pMgr); | |
| 2087 CFX_Unitime utime = widgetValue.GetTime(); | 2083 CFX_Unitime utime = widgetValue.GetTime(); |
| 2088 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), | 2084 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), |
| 2089 utime.GetSecond(), utime.GetMillisecond()); | 2085 utime.GetSecond(), utime.GetMillisecond()); |
| 2090 return TRUE; | 2086 return TRUE; |
| 2091 } | 2087 } |
| 2092 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, | 2088 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, |
| 2093 const CFX_ByteStringC& szDate, | 2089 const CFX_ByteStringC& szDate, |
| 2094 const CFX_ByteStringC& szFormat, | 2090 const CFX_ByteStringC& szFormat, |
| 2095 const CFX_ByteStringC& szLocale, | 2091 const CFX_ByteStringC& szLocale, |
| 2096 CFX_ByteString& strLocalDate) { | 2092 CFX_ByteString& strLocalDate) { |
| 2097 CXFA_FM2JSContext* pContext = | 2093 CXFA_FM2JSContext* pContext = |
| 2098 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2094 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
| 2099 CXFA_Document* pDoc = pContext->GetDocument(); | 2095 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2100 if (!pDoc) { | 2096 if (!pDoc) { |
| 2101 return FALSE; | 2097 return FALSE; |
| 2102 } | 2098 } |
| 2103 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2099 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2104 IFX_Locale* pLocale = NULL; | 2100 IFX_Locale* pLocale = NULL; |
| 2105 if (szLocale.IsEmpty()) { | 2101 if (szLocale.IsEmpty()) { |
| 2106 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2102 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2107 FXSYS_assert(pThisNode); | 2103 FXSYS_assert(pThisNode); |
| 2108 CXFA_WidgetData widgetData(pThisNode); | 2104 CXFA_WidgetData widgetData(pThisNode); |
| 2109 pLocale = widgetData.GetLocal(); | 2105 pLocale = widgetData.GetLocal(); |
| 2110 } else { | 2106 } else { |
| 2111 pLocale = pMgr->GetLocaleByName( | 2107 pLocale = pMgr->GetLocaleByName( |
| 2112 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2108 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); |
| 2113 } | 2109 } |
| 2114 if (!pLocale) { | 2110 if (!pLocale) { |
| 2115 return FALSE; | 2111 return FALSE; |
| 2116 } | 2112 } |
| 2117 CFX_WideString wsFormat; | 2113 CFX_WideString wsFormat; |
| 2118 if (szFormat.IsEmpty()) { | 2114 if (szFormat.IsEmpty()) { |
| 2119 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2115 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2120 } else { | 2116 } else { |
| 2121 wsFormat = | 2117 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2122 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | |
| 2123 } | 2118 } |
| 2124 CXFA_LocaleValue widgetValue( | 2119 CXFA_LocaleValue widgetValue( |
| 2125 XFA_VT_DATE, | 2120 XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()), |
| 2126 CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()), | |
| 2127 (CXFA_LocaleMgr*)pMgr); | 2121 (CXFA_LocaleMgr*)pMgr); |
| 2128 CFX_WideString wsRet; | 2122 CFX_WideString wsRet; |
| 2129 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2123 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2130 XFA_VALUEPICTURE_Display); | 2124 XFA_VALUEPICTURE_Display); |
| 2131 strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength()); | 2125 strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength()); |
| 2132 return TRUE; | 2126 return TRUE; |
| 2133 } | 2127 } |
| 2134 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, | 2128 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, |
| 2135 const CFX_ByteStringC& szTime, | 2129 const CFX_ByteStringC& szTime, |
| 2136 const CFX_ByteStringC& szFormat, | 2130 const CFX_ByteStringC& szFormat, |
| 2137 const CFX_ByteStringC& szLocale, | 2131 const CFX_ByteStringC& szLocale, |
| 2138 CFX_ByteString& strLocalTime) { | 2132 CFX_ByteString& strLocalTime) { |
| 2139 CXFA_FM2JSContext* pContext = | 2133 CXFA_FM2JSContext* pContext = |
| 2140 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2134 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
| 2141 CXFA_Document* pDoc = pContext->GetDocument(); | 2135 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2142 if (!pDoc) { | 2136 if (!pDoc) { |
| 2143 return FALSE; | 2137 return FALSE; |
| 2144 } | 2138 } |
| 2145 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2139 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2146 IFX_Locale* pLocale = NULL; | 2140 IFX_Locale* pLocale = NULL; |
| 2147 if (szLocale.IsEmpty()) { | 2141 if (szLocale.IsEmpty()) { |
| 2148 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2142 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2149 FXSYS_assert(pThisNode); | 2143 FXSYS_assert(pThisNode); |
| 2150 CXFA_WidgetData widgetData(pThisNode); | 2144 CXFA_WidgetData widgetData(pThisNode); |
| 2151 pLocale = widgetData.GetLocal(); | 2145 pLocale = widgetData.GetLocal(); |
| 2152 } else { | 2146 } else { |
| 2153 pLocale = pMgr->GetLocaleByName( | 2147 pLocale = pMgr->GetLocaleByName( |
| 2154 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2148 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); |
| 2155 } | 2149 } |
| 2156 if (!pLocale) { | 2150 if (!pLocale) { |
| 2157 return FALSE; | 2151 return FALSE; |
| 2158 } | 2152 } |
| 2159 CFX_WideString wsFormat; | 2153 CFX_WideString wsFormat; |
| 2160 if (szFormat.IsEmpty()) { | 2154 if (szFormat.IsEmpty()) { |
| 2161 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2155 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2162 } else { | 2156 } else { |
| 2163 wsFormat = | 2157 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2164 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | |
| 2165 } | 2158 } |
| 2166 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2159 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2167 wsFormat += FX_WSTRC(L"}"); | 2160 wsFormat += FX_WSTRC(L"}"); |
| 2168 CXFA_LocaleValue widgetValue( | 2161 CXFA_LocaleValue widgetValue( |
| 2169 XFA_VT_TIME, | 2162 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()), |
| 2170 CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), | |
| 2171 (CXFA_LocaleMgr*)pMgr); | 2163 (CXFA_LocaleMgr*)pMgr); |
| 2172 CFX_WideString wsRet; | 2164 CFX_WideString wsRet; |
| 2173 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2165 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2174 XFA_VALUEPICTURE_Display); | 2166 XFA_VALUEPICTURE_Display); |
| 2175 strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); | 2167 strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); |
| 2176 return TRUE; | 2168 return TRUE; |
| 2177 } | 2169 } |
| 2178 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, | 2170 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, |
| 2179 const CFX_ByteStringC& szTime, | 2171 const CFX_ByteStringC& szTime, |
| 2180 const CFX_ByteStringC& szFormat, | 2172 const CFX_ByteStringC& szFormat, |
| 2181 const CFX_ByteStringC& szLocale, | 2173 const CFX_ByteStringC& szLocale, |
| 2182 CFX_ByteString& strGMTTime) { | 2174 CFX_ByteString& strGMTTime) { |
| 2183 CXFA_FM2JSContext* pContext = | 2175 CXFA_FM2JSContext* pContext = |
| 2184 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2176 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
| 2185 CXFA_Document* pDoc = pContext->GetDocument(); | 2177 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2186 if (!pDoc) { | 2178 if (!pDoc) { |
| 2187 return FALSE; | 2179 return FALSE; |
| 2188 } | 2180 } |
| 2189 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2181 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2190 IFX_Locale* pLocale = NULL; | 2182 IFX_Locale* pLocale = NULL; |
| 2191 if (szLocale.IsEmpty()) { | 2183 if (szLocale.IsEmpty()) { |
| 2192 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2184 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2193 FXSYS_assert(pThisNode); | 2185 FXSYS_assert(pThisNode); |
| 2194 CXFA_WidgetData widgetData(pThisNode); | 2186 CXFA_WidgetData widgetData(pThisNode); |
| 2195 pLocale = widgetData.GetLocal(); | 2187 pLocale = widgetData.GetLocal(); |
| 2196 } else { | 2188 } else { |
| 2197 pLocale = pMgr->GetLocaleByName( | 2189 pLocale = pMgr->GetLocaleByName( |
| 2198 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); | 2190 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())); |
| 2199 } | 2191 } |
| 2200 if (!pLocale) { | 2192 if (!pLocale) { |
| 2201 return FALSE; | 2193 return FALSE; |
| 2202 } | 2194 } |
| 2203 CFX_WideString wsFormat; | 2195 CFX_WideString wsFormat; |
| 2204 if (szFormat.IsEmpty()) { | 2196 if (szFormat.IsEmpty()) { |
| 2205 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2197 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2206 } else { | 2198 } else { |
| 2207 wsFormat = | 2199 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength()); |
| 2208 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); | |
| 2209 } | 2200 } |
| 2210 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2201 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2211 wsFormat += FX_WSTRC(L"}"); | 2202 wsFormat += FX_WSTRC(L"}"); |
| 2212 CXFA_LocaleValue widgetValue( | 2203 CXFA_LocaleValue widgetValue( |
| 2213 XFA_VT_TIME, | 2204 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()), |
| 2214 CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), | |
| 2215 (CXFA_LocaleMgr*)pMgr); | 2205 (CXFA_LocaleMgr*)pMgr); |
| 2216 CFX_WideString wsRet; | 2206 CFX_WideString wsRet; |
| 2217 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2207 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2218 XFA_VALUEPICTURE_Display); | 2208 XFA_VALUEPICTURE_Display); |
| 2219 strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); | 2209 strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); |
| 2220 return TRUE; | 2210 return TRUE; |
| 2221 } | 2211 } |
| 2222 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { | 2212 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { |
| 2223 FX_BOOL bFlags = FALSE; | 2213 FX_BOOL bFlags = FALSE; |
| 2224 int32_t iLength = szDateString.GetLength(); | 2214 int32_t iLength = szDateString.GetLength(); |
| 2225 FX_BOOL iRet = FALSE; | 2215 FX_BOOL iRet = FALSE; |
| 2226 int32_t iStyle = -1; | 2216 int32_t iStyle = -1; |
| 2227 int32_t iYear = 0; | 2217 int32_t iYear = 0; |
| 2228 int32_t iMonth = 0; | 2218 int32_t iMonth = 0; |
| 2229 int32_t iDay = 0; | 2219 int32_t iDay = 0; |
| 2230 int32_t iHour = 0; | 2220 int32_t iHour = 0; |
| 2231 int32_t iMinute = 0; | 2221 int32_t iMinute = 0; |
| 2232 int32_t iSecond = 0; | 2222 int32_t iSecond = 0; |
| 2233 int32_t iMillionSecond = 0; | 2223 int32_t iMillionSecond = 0; |
| 2234 int32_t iZoneHour = 0; | 2224 int32_t iZoneHour = 0; |
| 2235 int32_t iZoneMinute = 0; | 2225 int32_t iZoneMinute = 0; |
| 2236 if (iLength <= 10) { | 2226 if (iLength <= 10) { |
| 2237 iRet = IsIsoDateFormat(szDateString.GetCStr(), iLength, iStyle, iYear, | 2227 iRet = IsIsoDateFormat(szDateString.c_str(), iLength, iStyle, iYear, iMonth, |
| 2238 iMonth, iDay); | 2228 iDay); |
| 2239 } else { | 2229 } else { |
| 2240 iRet = IsIsoDateTimeFormat(szDateString.GetCStr(), iLength, iYear, iMonth, | 2230 iRet = IsIsoDateTimeFormat(szDateString.c_str(), iLength, iYear, iMonth, |
| 2241 iDay, iHour, iMinute, iSecond, iMillionSecond, | 2231 iDay, iHour, iMinute, iSecond, iMillionSecond, |
| 2242 iZoneHour, iZoneMinute); | 2232 iZoneHour, iZoneMinute); |
| 2243 } | 2233 } |
| 2244 if (!iRet) { | 2234 if (!iRet) { |
| 2245 bFlags = TRUE; | 2235 bFlags = TRUE; |
| 2246 } | 2236 } |
| 2247 FX_FLOAT dDays = 0; | 2237 FX_FLOAT dDays = 0; |
| 2248 int32_t i = 1; | 2238 int32_t i = 1; |
| 2249 if (iYear < 1900) { | 2239 if (iYear < 1900) { |
| 2250 bFlags = TRUE; | 2240 bFlags = TRUE; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2373 } | 2363 } |
| 2374 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2364 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2375 IFX_Locale* pLocale = NULL; | 2365 IFX_Locale* pLocale = NULL; |
| 2376 if (szLocalStr.IsEmpty()) { | 2366 if (szLocalStr.IsEmpty()) { |
| 2377 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2367 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2378 FXSYS_assert(pThisNode); | 2368 FXSYS_assert(pThisNode); |
| 2379 CXFA_WidgetData widgetData(pThisNode); | 2369 CXFA_WidgetData widgetData(pThisNode); |
| 2380 pLocale = widgetData.GetLocal(); | 2370 pLocale = widgetData.GetLocal(); |
| 2381 } else { | 2371 } else { |
| 2382 pLocale = pMgr->GetLocaleByName( | 2372 pLocale = pMgr->GetLocaleByName( |
| 2383 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); | 2373 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength())); |
| 2384 } | 2374 } |
| 2385 if (!pLocale) { | 2375 if (!pLocale) { |
| 2386 return; | 2376 return; |
| 2387 } | 2377 } |
| 2388 CFX_WideString strRet; | 2378 CFX_WideString strRet; |
| 2389 pLocale->GetDatePattern(strStyle, strRet); | 2379 pLocale->GetDatePattern(strStyle, strRet); |
| 2390 if (!bStandard) { | 2380 if (!bStandard) { |
| 2391 CFX_WideString wsSymbols; | 2381 CFX_WideString wsSymbols; |
| 2392 pLocale->GetDateTimeSymbols(wsSymbols); | 2382 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2393 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); | 2383 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2428 } | 2418 } |
| 2429 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2419 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2430 IFX_Locale* pLocale = NULL; | 2420 IFX_Locale* pLocale = NULL; |
| 2431 if (szLocalStr.IsEmpty()) { | 2421 if (szLocalStr.IsEmpty()) { |
| 2432 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2422 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2433 FXSYS_assert(pThisNode); | 2423 FXSYS_assert(pThisNode); |
| 2434 CXFA_WidgetData widgetData(pThisNode); | 2424 CXFA_WidgetData widgetData(pThisNode); |
| 2435 pLocale = widgetData.GetLocal(); | 2425 pLocale = widgetData.GetLocal(); |
| 2436 } else { | 2426 } else { |
| 2437 pLocale = pMgr->GetLocaleByName( | 2427 pLocale = pMgr->GetLocaleByName( |
| 2438 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); | 2428 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength())); |
| 2439 } | 2429 } |
| 2440 if (!pLocale) { | 2430 if (!pLocale) { |
| 2441 return; | 2431 return; |
| 2442 } | 2432 } |
| 2443 CFX_WideString strRet; | 2433 CFX_WideString strRet; |
| 2444 pLocale->GetTimePattern(strStyle, strRet); | 2434 pLocale->GetTimePattern(strStyle, strRet); |
| 2445 if (!bStandard) { | 2435 if (!bStandard) { |
| 2446 CFX_WideString wsSymbols; | 2436 CFX_WideString wsSymbols; |
| 2447 pLocale->GetDateTimeSymbols(wsSymbols); | 2437 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2448 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); | 2438 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3724 FXJSE_Value_Release(argOne); | 3714 FXJSE_Value_Release(argOne); |
| 3725 FXJSE_Value_Release(argTwo); | 3715 FXJSE_Value_Release(argTwo); |
| 3726 } else { | 3716 } else { |
| 3727 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3717 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3728 L"Decode"); | 3718 L"Decode"); |
| 3729 } | 3719 } |
| 3730 } | 3720 } |
| 3731 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, | 3721 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, |
| 3732 CFX_ByteTextBuf& szResultString) { | 3722 CFX_ByteTextBuf& szResultString) { |
| 3733 CFX_WideString wsURLString = | 3723 CFX_WideString wsURLString = |
| 3734 CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); | 3724 CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength()); |
| 3735 const FX_WCHAR* pData = wsURLString; | 3725 const FX_WCHAR* pData = wsURLString; |
| 3736 int32_t iLen = wsURLString.GetLength(); | 3726 int32_t iLen = wsURLString.GetLength(); |
| 3737 int32_t i = 0; | 3727 int32_t i = 0; |
| 3738 FX_WCHAR ch = 0; | 3728 FX_WCHAR ch = 0; |
| 3739 FX_WCHAR chTemp = 0; | 3729 FX_WCHAR chTemp = 0; |
| 3740 CFX_WideTextBuf wsResultBuf; | 3730 CFX_WideTextBuf wsResultBuf; |
| 3741 while (i < iLen) { | 3731 while (i < iLen) { |
| 3742 ch = *(pData + i); | 3732 ch = *(pData + i); |
| 3743 if ('%' == ch) { | 3733 if ('%' == ch) { |
| 3744 chTemp = 0; | 3734 chTemp = 0; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3778 } | 3768 } |
| 3779 ++i; | 3769 ++i; |
| 3780 } | 3770 } |
| 3781 wsResultBuf.AppendChar(0); | 3771 wsResultBuf.AppendChar(0); |
| 3782 szResultString.Clear(); | 3772 szResultString.Clear(); |
| 3783 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 3773 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
| 3784 wsResultBuf.GetLength()); | 3774 wsResultBuf.GetLength()); |
| 3785 } | 3775 } |
| 3786 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, | 3776 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, |
| 3787 CFX_ByteTextBuf& szResultString) { | 3777 CFX_ByteTextBuf& szResultString) { |
| 3788 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8( | 3778 CFX_WideString wsHTMLString = |
| 3789 szHTMLString.GetCStr(), szHTMLString.GetLength()); | 3779 CFX_WideString::FromUTF8(szHTMLString.c_str(), szHTMLString.GetLength()); |
| 3790 FX_WCHAR strString[9]; | 3780 FX_WCHAR strString[9]; |
| 3791 int32_t iStrIndex = 0; | 3781 int32_t iStrIndex = 0; |
| 3792 int32_t iLen = wsHTMLString.GetLength(); | 3782 int32_t iLen = wsHTMLString.GetLength(); |
| 3793 int32_t i = 0; | 3783 int32_t i = 0; |
| 3794 int32_t iCode = 0; | 3784 int32_t iCode = 0; |
| 3795 FX_WCHAR ch = 0; | 3785 FX_WCHAR ch = 0; |
| 3796 const FX_WCHAR* pData = wsHTMLString; | 3786 const FX_WCHAR* pData = wsHTMLString; |
| 3797 CFX_WideTextBuf wsResultBuf; | 3787 CFX_WideTextBuf wsResultBuf; |
| 3798 while (i < iLen) { | 3788 while (i < iLen) { |
| 3799 ch = *(pData + i); | 3789 ch = *(pData + i); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3853 ++i; | 3843 ++i; |
| 3854 } | 3844 } |
| 3855 wsResultBuf.AppendChar(0); | 3845 wsResultBuf.AppendChar(0); |
| 3856 szResultString.Clear(); | 3846 szResultString.Clear(); |
| 3857 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 3847 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
| 3858 wsResultBuf.GetLength()); | 3848 wsResultBuf.GetLength()); |
| 3859 } | 3849 } |
| 3860 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, | 3850 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, |
| 3861 CFX_ByteTextBuf& szResultString) { | 3851 CFX_ByteTextBuf& szResultString) { |
| 3862 CFX_WideString wsXMLString = | 3852 CFX_WideString wsXMLString = |
| 3863 CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); | 3853 CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength()); |
| 3864 FX_WCHAR strString[9]; | 3854 FX_WCHAR strString[9]; |
| 3865 int32_t iStrIndex = 0; | 3855 int32_t iStrIndex = 0; |
| 3866 int32_t iLen = wsXMLString.GetLength(); | 3856 int32_t iLen = wsXMLString.GetLength(); |
| 3867 int32_t i = 0; | 3857 int32_t i = 0; |
| 3868 int32_t iCode = 0; | 3858 int32_t iCode = 0; |
| 3869 FX_WCHAR ch = 0; | 3859 FX_WCHAR ch = 0; |
| 3870 const FX_WCHAR* pData = wsXMLString; | 3860 const FX_WCHAR* pData = wsXMLString; |
| 3871 CFX_WideTextBuf wsXMLBuf; | 3861 CFX_WideTextBuf wsXMLBuf; |
| 3872 while (i < iLen) { | 3862 while (i < iLen) { |
| 3873 ch = *(pData + i); | 3863 ch = *(pData + i); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3997 FXJSE_Value_Release(argOne); | 3987 FXJSE_Value_Release(argOne); |
| 3998 FXJSE_Value_Release(argTwo); | 3988 FXJSE_Value_Release(argTwo); |
| 3999 } else { | 3989 } else { |
| 4000 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3990 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4001 L"Encode"); | 3991 L"Encode"); |
| 4002 } | 3992 } |
| 4003 } | 3993 } |
| 4004 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, | 3994 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, |
| 4005 CFX_ByteTextBuf& szResultBuf) { | 3995 CFX_ByteTextBuf& szResultBuf) { |
| 4006 CFX_WideString wsURLString = | 3996 CFX_WideString wsURLString = |
| 4007 CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); | 3997 CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength()); |
| 4008 CFX_WideTextBuf wsResultBuf; | 3998 CFX_WideTextBuf wsResultBuf; |
| 4009 FX_WCHAR ch = 0; | 3999 FX_WCHAR ch = 0; |
| 4010 int32_t iLength = wsURLString.GetLength(); | 4000 int32_t iLength = wsURLString.GetLength(); |
| 4011 FX_WCHAR strEncode[4]; | 4001 FX_WCHAR strEncode[4]; |
| 4012 strEncode[0] = '%'; | 4002 strEncode[0] = '%'; |
| 4013 strEncode[3] = 0; | 4003 strEncode[3] = 0; |
| 4014 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', | 4004 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', |
| 4015 '|', '\\', '^', '~', '[', ']', '`'}; | 4005 '|', '\\', '^', '~', '[', ']', '`'}; |
| 4016 FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'}; | 4006 FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'}; |
| 4017 FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','}; | 4007 FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','}; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4104 } | 4094 } |
| 4105 } | 4095 } |
| 4106 } | 4096 } |
| 4107 wsResultBuf.AppendChar(0); | 4097 wsResultBuf.AppendChar(0); |
| 4108 szResultBuf.Clear(); | 4098 szResultBuf.Clear(); |
| 4109 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 4099 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
| 4110 wsResultBuf.GetLength()); | 4100 wsResultBuf.GetLength()); |
| 4111 } | 4101 } |
| 4112 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, | 4102 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, |
| 4113 CFX_ByteTextBuf& szResultBuf) { | 4103 CFX_ByteTextBuf& szResultBuf) { |
| 4114 CFX_ByteString str = szHTMLString.GetCStr(); | 4104 CFX_ByteString str = szHTMLString.c_str(); |
| 4115 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength()); | 4105 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength()); |
| 4116 const FX_WCHAR* strCode = L"0123456789abcdef"; | 4106 const FX_WCHAR* strCode = L"0123456789abcdef"; |
| 4117 FX_WCHAR strEncode[9]; | 4107 FX_WCHAR strEncode[9]; |
| 4118 strEncode[0] = '&'; | 4108 strEncode[0] = '&'; |
| 4119 strEncode[1] = '#'; | 4109 strEncode[1] = '#'; |
| 4120 strEncode[2] = 'x'; | 4110 strEncode[2] = 'x'; |
| 4121 strEncode[5] = ';'; | 4111 strEncode[5] = ';'; |
| 4122 strEncode[6] = 0; | 4112 strEncode[6] = 0; |
| 4123 strEncode[7] = ';'; | 4113 strEncode[7] = ';'; |
| 4124 strEncode[8] = 0; | 4114 strEncode[8] = 0; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4159 ++i; | 4149 ++i; |
| 4160 } | 4150 } |
| 4161 wsResultBuf.AppendChar(0); | 4151 wsResultBuf.AppendChar(0); |
| 4162 szResultBuf.Clear(); | 4152 szResultBuf.Clear(); |
| 4163 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 4153 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
| 4164 wsResultBuf.GetLength()); | 4154 wsResultBuf.GetLength()); |
| 4165 } | 4155 } |
| 4166 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, | 4156 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, |
| 4167 CFX_ByteTextBuf& szResultBuf) { | 4157 CFX_ByteTextBuf& szResultBuf) { |
| 4168 CFX_WideString wsXMLString = | 4158 CFX_WideString wsXMLString = |
| 4169 CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); | 4159 CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength()); |
| 4170 CFX_WideTextBuf wsResultBuf; | 4160 CFX_WideTextBuf wsResultBuf; |
| 4171 enum { | 4161 enum { |
| 4172 QUOT, | 4162 QUOT, |
| 4173 AMP, | 4163 AMP, |
| 4174 APOS, | 4164 APOS, |
| 4175 LT, | 4165 LT, |
| 4176 GT, | 4166 GT, |
| 4177 }; | 4167 }; |
| 4178 FX_WCHAR strEncode[9]; | 4168 FX_WCHAR strEncode[9]; |
| 4179 strEncode[0] = '&'; | 4169 strEncode[0] = '&'; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4283 iEnd = iMid - 1; | 4273 iEnd = iMid - 1; |
| 4284 } else { | 4274 } else { |
| 4285 iStart = iMid + 1; | 4275 iStart = iMid + 1; |
| 4286 } | 4276 } |
| 4287 } while (iStart <= iEnd); | 4277 } while (iStart <= iEnd); |
| 4288 return FALSE; | 4278 return FALSE; |
| 4289 } | 4279 } |
| 4290 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, | 4280 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, |
| 4291 uint32_t& patternType) { | 4281 uint32_t& patternType) { |
| 4292 CFX_WideString wsPattern = | 4282 CFX_WideString wsPattern = |
| 4293 CFX_WideString::FromUTF8(szPattern.GetCStr(), szPattern.GetLength()); | 4283 CFX_WideString::FromUTF8(szPattern.c_str(), szPattern.GetLength()); |
| 4294 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { | 4284 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { |
| 4295 patternType = XFA_VT_DATETIME; | 4285 patternType = XFA_VT_DATETIME; |
| 4296 return TRUE; | 4286 return TRUE; |
| 4297 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { | 4287 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { |
| 4298 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; | 4288 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; |
| 4299 return TRUE; | 4289 return TRUE; |
| 4300 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { | 4290 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { |
| 4301 patternType = XFA_VT_TIME; | 4291 patternType = XFA_VT_TIME; |
| 4302 return TRUE; | 4292 return TRUE; |
| 4303 } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { | 4293 } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5247 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", | 5237 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", |
| 5248 "Five", "Six", "Seven", "Eight", "Nine"}; | 5238 "Five", "Six", "Seven", "Eight", "Nine"}; |
| 5249 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", | 5239 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", |
| 5250 "Fourteen", "Fifteen", "Sixteen", "Seventeen", | 5240 "Fourteen", "Fifteen", "Sixteen", "Seventeen", |
| 5251 "Eighteen", "Nineteen"}; | 5241 "Eighteen", "Nineteen"}; |
| 5252 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", | 5242 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", |
| 5253 "Sixty", "Seventy", "Eighty", "Ninety"}; | 5243 "Sixty", "Seventy", "Eighty", "Ninety"}; |
| 5254 CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ", | 5244 CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ", |
| 5255 " Billion ", "Trillion"}; | 5245 " Billion ", "Trillion"}; |
| 5256 int32_t iComm = 0; | 5246 int32_t iComm = 0; |
| 5257 const FX_CHAR* pData = szData.GetCStr(); | 5247 const FX_CHAR* pData = szData.c_str(); |
| 5258 int32_t iLength = szData.GetLength(); | 5248 int32_t iLength = szData.GetLength(); |
| 5259 if (iLength > 12) { | 5249 if (iLength > 12) { |
| 5260 iComm = 4; | 5250 iComm = 4; |
| 5261 } else if (iLength > 9) { | 5251 } else if (iLength > 9) { |
| 5262 iComm = 3; | 5252 iComm = 3; |
| 5263 } else if (iLength > 6) { | 5253 } else if (iLength > 6) { |
| 5264 iComm = 2; | 5254 iComm = 2; |
| 5265 } else if (iLength > 3) { | 5255 } else if (iLength > 3) { |
| 5266 iComm = 1; | 5256 iComm = 1; |
| 5267 } | 5257 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5333 if (iIndex < iLength - 3) { | 5323 if (iIndex < iLength - 3) { |
| 5334 strBuf << pComm[iComm]; | 5324 strBuf << pComm[iComm]; |
| 5335 --iComm; | 5325 --iComm; |
| 5336 } | 5326 } |
| 5337 iIndex += 3; | 5327 iIndex += 3; |
| 5338 } | 5328 } |
| 5339 } | 5329 } |
| 5340 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, | 5330 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, |
| 5341 int32_t iStyle, | 5331 int32_t iStyle, |
| 5342 CFX_ByteTextBuf& strBuf) { | 5332 CFX_ByteTextBuf& strBuf) { |
| 5343 const FX_CHAR* pData = szData.GetCStr(); | 5333 const FX_CHAR* pData = szData.c_str(); |
| 5344 int32_t iLength = szData.GetLength(); | 5334 int32_t iLength = szData.GetLength(); |
| 5345 switch (iStyle) { | 5335 switch (iStyle) { |
| 5346 case 0: { | 5336 case 0: { |
| 5347 int32_t iIndex = 0; | 5337 int32_t iIndex = 0; |
| 5348 while (iIndex < iLength) { | 5338 while (iIndex < iLength) { |
| 5349 if (*(pData + iIndex) == '.') { | 5339 if (*(pData + iIndex) == '.') { |
| 5350 break; | 5340 break; |
| 5351 } | 5341 } |
| 5352 ++iIndex; | 5342 ++iIndex; |
| 5353 } | 5343 } |
| (...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6833 CXFA_Document* pDoc = pContext->GetDocument(); | 6823 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6834 if (!pDoc) { | 6824 if (!pDoc) { |
| 6835 return bFlags; | 6825 return bFlags; |
| 6836 } | 6826 } |
| 6837 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6827 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6838 XFA_RESOLVENODE_RS resoveNodeRS; | 6828 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6839 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6829 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
| 6840 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6830 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6841 int32_t iRet = pScriptContext->ResolveObjects( | 6831 int32_t iRet = pScriptContext->ResolveObjects( |
| 6842 pScriptContext->GetThisObject(), | 6832 pScriptContext->GetThisObject(), |
| 6843 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), | 6833 CFX_WideString::FromUTF8(szAccessorName.c_str(), |
| 6844 szAccessorName.GetLength()), | 6834 szAccessorName.GetLength()), |
| 6845 resoveNodeRS, dwFlags); | 6835 resoveNodeRS, dwFlags); |
| 6846 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6836 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6847 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6837 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
| 6848 resoveNodeRS.nodes.GetAt(0))); | 6838 resoveNodeRS.nodes.GetAt(0))); |
| 6849 bFlags = TRUE; | 6839 bFlags = TRUE; |
| 6850 } | 6840 } |
| 6851 return bFlags; | 6841 return bFlags; |
| 6852 } | 6842 } |
| 6853 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, | 6843 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, |
| 6854 FXJSE_HVALUE hRefValue, | 6844 FXJSE_HVALUE hRefValue, |
| 6855 const CFX_ByteStringC& bsSomExp, | 6845 const CFX_ByteStringC& bsSomExp, |
| 6856 XFA_RESOLVENODE_RS& resoveNodeRS, | 6846 XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6857 FX_BOOL bdotAccessor, | 6847 FX_BOOL bdotAccessor, |
| 6858 FX_BOOL bHasNoResolveName) { | 6848 FX_BOOL bHasNoResolveName) { |
| 6859 CFX_WideString wsSomExpression = | 6849 CFX_WideString wsSomExpression = |
| 6860 CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); | 6850 CFX_WideString::FromUTF8(bsSomExp.c_str(), bsSomExp.GetLength()); |
| 6861 int32_t iRet = -1; | 6851 int32_t iRet = -1; |
| 6862 CXFA_FM2JSContext* pContext = | 6852 CXFA_FM2JSContext* pContext = |
| 6863 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6853 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
| 6864 CXFA_Document* pDoc = pContext->GetDocument(); | 6854 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6865 if (!pDoc) { | 6855 if (!pDoc) { |
| 6866 return iRet; | 6856 return iRet; |
| 6867 } | 6857 } |
| 6868 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6858 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6869 CXFA_Object* pNode = NULL; | 6859 CXFA_Object* pNode = NULL; |
| 6870 uint32_t dFlags = 0UL; | 6860 uint32_t dFlags = 0UL; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7214 FXSYS_assert(pAppProvider); | 7204 FXSYS_assert(pAppProvider); |
| 7215 CFX_WideString wsFormat; | 7205 CFX_WideString wsFormat; |
| 7216 pAppProvider->LoadString(iStringID, wsFormat); | 7206 pAppProvider->LoadString(iStringID, wsFormat); |
| 7217 CFX_WideString wsMessage; | 7207 CFX_WideString wsMessage; |
| 7218 va_list arg_ptr; | 7208 va_list arg_ptr; |
| 7219 va_start(arg_ptr, iStringID); | 7209 va_start(arg_ptr, iStringID); |
| 7220 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7210 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
| 7221 va_end(arg_ptr); | 7211 va_end(arg_ptr); |
| 7222 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); | 7212 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); |
| 7223 } | 7213 } |
| OLD | NEW |