Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 1857713003: Rename GetCStr and GetPtr to match CFX_ByteString (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | xfa/fxfa/fm2js/xfa_lexer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 } 2032 }
2033 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2033 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2034 IFX_Locale* pLocale = NULL; 2034 IFX_Locale* pLocale = NULL;
2035 if (szLocale.IsEmpty()) { 2035 if (szLocale.IsEmpty()) {
2036 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2036 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2037 FXSYS_assert(pThisNode); 2037 FXSYS_assert(pThisNode);
2038 CXFA_WidgetData widgetData(pThisNode); 2038 CXFA_WidgetData widgetData(pThisNode);
2039 pLocale = widgetData.GetLocal(); 2039 pLocale = widgetData.GetLocal();
2040 } else { 2040 } else {
2041 pLocale = pMgr->GetLocaleByName( 2041 pLocale = pMgr->GetLocaleByName(
2042 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); 2042 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()));
2043 } 2043 }
2044 if (!pLocale) { 2044 if (!pLocale) {
2045 return FALSE; 2045 return FALSE;
2046 } 2046 }
2047 CFX_WideString wsFormat; 2047 CFX_WideString wsFormat;
2048 if (szFormat.IsEmpty()) { 2048 if (szFormat.IsEmpty()) {
2049 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2049 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2050 } else { 2050 } else {
2051 wsFormat = 2051 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
2052 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength());
2053 } 2052 }
2054 CXFA_LocaleValue widgetValue( 2053 CXFA_LocaleValue widgetValue(
2055 XFA_VT_DATE, 2054 XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()),
2056 CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()), wsFormat, 2055 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr);
2057 pLocale, (CXFA_LocaleMgr*)pMgr);
2058 CFX_Unitime dt = widgetValue.GetDate(); 2056 CFX_Unitime dt = widgetValue.GetDate();
2059 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); 2057 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay());
2060 return TRUE; 2058 return TRUE;
2061 } 2059 }
2062 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, 2060 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis,
2063 const CFX_ByteStringC& szTime, 2061 const CFX_ByteStringC& szTime,
2064 const CFX_ByteStringC& szFormat, 2062 const CFX_ByteStringC& szFormat,
2065 const CFX_ByteStringC& szLocale, 2063 const CFX_ByteStringC& szLocale,
2066 CFX_ByteString& strIsoTime) { 2064 CFX_ByteString& strIsoTime) {
2067 CXFA_FM2JSContext* pContext = 2065 CXFA_FM2JSContext* pContext =
2068 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); 2066 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
2069 CXFA_Document* pDoc = pContext->GetDocument(); 2067 CXFA_Document* pDoc = pContext->GetDocument();
2070 if (!pDoc) { 2068 if (!pDoc) {
2071 return FALSE; 2069 return FALSE;
2072 } 2070 }
2073 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2071 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2074 IFX_Locale* pLocale = NULL; 2072 IFX_Locale* pLocale = NULL;
2075 if (szLocale.IsEmpty()) { 2073 if (szLocale.IsEmpty()) {
2076 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2074 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2077 FXSYS_assert(pThisNode); 2075 FXSYS_assert(pThisNode);
2078 CXFA_WidgetData widgetData(pThisNode); 2076 CXFA_WidgetData widgetData(pThisNode);
2079 pLocale = widgetData.GetLocal(); 2077 pLocale = widgetData.GetLocal();
2080 } else { 2078 } else {
2081 pLocale = pMgr->GetLocaleByName( 2079 pLocale = pMgr->GetLocaleByName(
2082 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); 2080 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()));
2083 } 2081 }
2084 if (!pLocale) { 2082 if (!pLocale) {
2085 return FALSE; 2083 return FALSE;
2086 } 2084 }
2087 CFX_WideString wsFormat; 2085 CFX_WideString wsFormat;
2088 if (szFormat.IsEmpty()) { 2086 if (szFormat.IsEmpty()) {
2089 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2087 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2090 } else { 2088 } else {
2091 wsFormat = 2089 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
2092 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength());
2093 } 2090 }
2094 wsFormat = FX_WSTRC(L"time{") + wsFormat; 2091 wsFormat = FX_WSTRC(L"time{") + wsFormat;
2095 wsFormat += FX_WSTRC(L"}"); 2092 wsFormat += FX_WSTRC(L"}");
2096 CXFA_LocaleValue widgetValue( 2093 CXFA_LocaleValue widgetValue(
2097 XFA_VT_TIME, 2094 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()),
2098 CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), wsFormat, 2095 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr);
2099 pLocale, (CXFA_LocaleMgr*)pMgr);
2100 CFX_Unitime utime = widgetValue.GetTime(); 2096 CFX_Unitime utime = widgetValue.GetTime();
2101 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), 2097 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(),
2102 utime.GetSecond(), utime.GetMillisecond()); 2098 utime.GetSecond(), utime.GetMillisecond());
2103 return TRUE; 2099 return TRUE;
2104 } 2100 }
2105 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, 2101 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis,
2106 const CFX_ByteStringC& szDate, 2102 const CFX_ByteStringC& szDate,
2107 const CFX_ByteStringC& szFormat, 2103 const CFX_ByteStringC& szFormat,
2108 const CFX_ByteStringC& szLocale, 2104 const CFX_ByteStringC& szLocale,
2109 CFX_ByteString& strLocalDate) { 2105 CFX_ByteString& strLocalDate) {
2110 CXFA_FM2JSContext* pContext = 2106 CXFA_FM2JSContext* pContext =
2111 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); 2107 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
2112 CXFA_Document* pDoc = pContext->GetDocument(); 2108 CXFA_Document* pDoc = pContext->GetDocument();
2113 if (!pDoc) { 2109 if (!pDoc) {
2114 return FALSE; 2110 return FALSE;
2115 } 2111 }
2116 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2112 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2117 IFX_Locale* pLocale = NULL; 2113 IFX_Locale* pLocale = NULL;
2118 if (szLocale.IsEmpty()) { 2114 if (szLocale.IsEmpty()) {
2119 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2115 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2120 FXSYS_assert(pThisNode); 2116 FXSYS_assert(pThisNode);
2121 CXFA_WidgetData widgetData(pThisNode); 2117 CXFA_WidgetData widgetData(pThisNode);
2122 pLocale = widgetData.GetLocal(); 2118 pLocale = widgetData.GetLocal();
2123 } else { 2119 } else {
2124 pLocale = pMgr->GetLocaleByName( 2120 pLocale = pMgr->GetLocaleByName(
2125 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); 2121 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()));
2126 } 2122 }
2127 if (!pLocale) { 2123 if (!pLocale) {
2128 return FALSE; 2124 return FALSE;
2129 } 2125 }
2130 CFX_WideString wsFormat; 2126 CFX_WideString wsFormat;
2131 if (szFormat.IsEmpty()) { 2127 if (szFormat.IsEmpty()) {
2132 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2128 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2133 } else { 2129 } else {
2134 wsFormat = 2130 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
2135 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength());
2136 } 2131 }
2137 CXFA_LocaleValue widgetValue( 2132 CXFA_LocaleValue widgetValue(
2138 XFA_VT_DATE, 2133 XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()),
2139 CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()),
2140 (CXFA_LocaleMgr*)pMgr); 2134 (CXFA_LocaleMgr*)pMgr);
2141 CFX_WideString wsRet; 2135 CFX_WideString wsRet;
2142 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, 2136 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
2143 XFA_VALUEPICTURE_Display); 2137 XFA_VALUEPICTURE_Display);
2144 strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength()); 2138 strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength());
2145 return TRUE; 2139 return TRUE;
2146 } 2140 }
2147 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, 2141 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis,
2148 const CFX_ByteStringC& szTime, 2142 const CFX_ByteStringC& szTime,
2149 const CFX_ByteStringC& szFormat, 2143 const CFX_ByteStringC& szFormat,
2150 const CFX_ByteStringC& szLocale, 2144 const CFX_ByteStringC& szLocale,
2151 CFX_ByteString& strLocalTime) { 2145 CFX_ByteString& strLocalTime) {
2152 CXFA_FM2JSContext* pContext = 2146 CXFA_FM2JSContext* pContext =
2153 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); 2147 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
2154 CXFA_Document* pDoc = pContext->GetDocument(); 2148 CXFA_Document* pDoc = pContext->GetDocument();
2155 if (!pDoc) { 2149 if (!pDoc) {
2156 return FALSE; 2150 return FALSE;
2157 } 2151 }
2158 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2152 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2159 IFX_Locale* pLocale = NULL; 2153 IFX_Locale* pLocale = NULL;
2160 if (szLocale.IsEmpty()) { 2154 if (szLocale.IsEmpty()) {
2161 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2155 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2162 FXSYS_assert(pThisNode); 2156 FXSYS_assert(pThisNode);
2163 CXFA_WidgetData widgetData(pThisNode); 2157 CXFA_WidgetData widgetData(pThisNode);
2164 pLocale = widgetData.GetLocal(); 2158 pLocale = widgetData.GetLocal();
2165 } else { 2159 } else {
2166 pLocale = pMgr->GetLocaleByName( 2160 pLocale = pMgr->GetLocaleByName(
2167 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); 2161 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()));
2168 } 2162 }
2169 if (!pLocale) { 2163 if (!pLocale) {
2170 return FALSE; 2164 return FALSE;
2171 } 2165 }
2172 CFX_WideString wsFormat; 2166 CFX_WideString wsFormat;
2173 if (szFormat.IsEmpty()) { 2167 if (szFormat.IsEmpty()) {
2174 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2168 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2175 } else { 2169 } else {
2176 wsFormat = 2170 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
2177 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength());
2178 } 2171 }
2179 wsFormat = FX_WSTRC(L"time{") + wsFormat; 2172 wsFormat = FX_WSTRC(L"time{") + wsFormat;
2180 wsFormat += FX_WSTRC(L"}"); 2173 wsFormat += FX_WSTRC(L"}");
2181 CXFA_LocaleValue widgetValue( 2174 CXFA_LocaleValue widgetValue(
2182 XFA_VT_TIME, 2175 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()),
2183 CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()),
2184 (CXFA_LocaleMgr*)pMgr); 2176 (CXFA_LocaleMgr*)pMgr);
2185 CFX_WideString wsRet; 2177 CFX_WideString wsRet;
2186 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, 2178 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
2187 XFA_VALUEPICTURE_Display); 2179 XFA_VALUEPICTURE_Display);
2188 strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); 2180 strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength());
2189 return TRUE; 2181 return TRUE;
2190 } 2182 }
2191 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, 2183 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis,
2192 const CFX_ByteStringC& szTime, 2184 const CFX_ByteStringC& szTime,
2193 const CFX_ByteStringC& szFormat, 2185 const CFX_ByteStringC& szFormat,
2194 const CFX_ByteStringC& szLocale, 2186 const CFX_ByteStringC& szLocale,
2195 CFX_ByteString& strGMTTime) { 2187 CFX_ByteString& strGMTTime) {
2196 CXFA_FM2JSContext* pContext = 2188 CXFA_FM2JSContext* pContext =
2197 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); 2189 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
2198 CXFA_Document* pDoc = pContext->GetDocument(); 2190 CXFA_Document* pDoc = pContext->GetDocument();
2199 if (!pDoc) { 2191 if (!pDoc) {
2200 return FALSE; 2192 return FALSE;
2201 } 2193 }
2202 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2194 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2203 IFX_Locale* pLocale = NULL; 2195 IFX_Locale* pLocale = NULL;
2204 if (szLocale.IsEmpty()) { 2196 if (szLocale.IsEmpty()) {
2205 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2197 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2206 FXSYS_assert(pThisNode); 2198 FXSYS_assert(pThisNode);
2207 CXFA_WidgetData widgetData(pThisNode); 2199 CXFA_WidgetData widgetData(pThisNode);
2208 pLocale = widgetData.GetLocal(); 2200 pLocale = widgetData.GetLocal();
2209 } else { 2201 } else {
2210 pLocale = pMgr->GetLocaleByName( 2202 pLocale = pMgr->GetLocaleByName(
2211 CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); 2203 CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength()));
2212 } 2204 }
2213 if (!pLocale) { 2205 if (!pLocale) {
2214 return FALSE; 2206 return FALSE;
2215 } 2207 }
2216 CFX_WideString wsFormat; 2208 CFX_WideString wsFormat;
2217 if (szFormat.IsEmpty()) { 2209 if (szFormat.IsEmpty()) {
2218 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2210 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2219 } else { 2211 } else {
2220 wsFormat = 2212 wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
2221 CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength());
2222 } 2213 }
2223 wsFormat = FX_WSTRC(L"time{") + wsFormat; 2214 wsFormat = FX_WSTRC(L"time{") + wsFormat;
2224 wsFormat += FX_WSTRC(L"}"); 2215 wsFormat += FX_WSTRC(L"}");
2225 CXFA_LocaleValue widgetValue( 2216 CXFA_LocaleValue widgetValue(
2226 XFA_VT_TIME, 2217 XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()),
2227 CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()),
2228 (CXFA_LocaleMgr*)pMgr); 2218 (CXFA_LocaleMgr*)pMgr);
2229 CFX_WideString wsRet; 2219 CFX_WideString wsRet;
2230 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, 2220 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
2231 XFA_VALUEPICTURE_Display); 2221 XFA_VALUEPICTURE_Display);
2232 strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); 2222 strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength());
2233 return TRUE; 2223 return TRUE;
2234 } 2224 }
2235 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { 2225 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) {
2236 FX_BOOL bFlags = FALSE; 2226 FX_BOOL bFlags = FALSE;
2237 int32_t iLength = szDateString.GetLength(); 2227 int32_t iLength = szDateString.GetLength();
2238 FX_BOOL iRet = FALSE; 2228 FX_BOOL iRet = FALSE;
2239 int32_t iStyle = -1; 2229 int32_t iStyle = -1;
2240 int32_t iYear = 0; 2230 int32_t iYear = 0;
2241 int32_t iMonth = 0; 2231 int32_t iMonth = 0;
2242 int32_t iDay = 0; 2232 int32_t iDay = 0;
2243 int32_t iHour = 0; 2233 int32_t iHour = 0;
2244 int32_t iMinute = 0; 2234 int32_t iMinute = 0;
2245 int32_t iSecond = 0; 2235 int32_t iSecond = 0;
2246 int32_t iMillionSecond = 0; 2236 int32_t iMillionSecond = 0;
2247 int32_t iZoneHour = 0; 2237 int32_t iZoneHour = 0;
2248 int32_t iZoneMinute = 0; 2238 int32_t iZoneMinute = 0;
2249 if (iLength <= 10) { 2239 if (iLength <= 10) {
2250 iRet = IsIsoDateFormat(szDateString.GetCStr(), iLength, iStyle, iYear, 2240 iRet = IsIsoDateFormat(szDateString.c_str(), iLength, iStyle, iYear, iMonth,
2251 iMonth, iDay); 2241 iDay);
2252 } else { 2242 } else {
2253 iRet = IsIsoDateTimeFormat(szDateString.GetCStr(), iLength, iYear, iMonth, 2243 iRet = IsIsoDateTimeFormat(szDateString.c_str(), iLength, iYear, iMonth,
2254 iDay, iHour, iMinute, iSecond, iMillionSecond, 2244 iDay, iHour, iMinute, iSecond, iMillionSecond,
2255 iZoneHour, iZoneMinute); 2245 iZoneHour, iZoneMinute);
2256 } 2246 }
2257 if (!iRet) { 2247 if (!iRet) {
2258 bFlags = TRUE; 2248 bFlags = TRUE;
2259 } 2249 }
2260 FX_FLOAT dDays = 0; 2250 FX_FLOAT dDays = 0;
2261 int32_t i = 1; 2251 int32_t i = 1;
2262 if (iYear < 1900) { 2252 if (iYear < 1900) {
2263 bFlags = TRUE; 2253 bFlags = TRUE;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 } 2376 }
2387 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2377 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2388 IFX_Locale* pLocale = NULL; 2378 IFX_Locale* pLocale = NULL;
2389 if (szLocalStr.IsEmpty()) { 2379 if (szLocalStr.IsEmpty()) {
2390 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2380 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2391 FXSYS_assert(pThisNode); 2381 FXSYS_assert(pThisNode);
2392 CXFA_WidgetData widgetData(pThisNode); 2382 CXFA_WidgetData widgetData(pThisNode);
2393 pLocale = widgetData.GetLocal(); 2383 pLocale = widgetData.GetLocal();
2394 } else { 2384 } else {
2395 pLocale = pMgr->GetLocaleByName( 2385 pLocale = pMgr->GetLocaleByName(
2396 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); 2386 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength()));
2397 } 2387 }
2398 if (!pLocale) { 2388 if (!pLocale) {
2399 return; 2389 return;
2400 } 2390 }
2401 CFX_WideString strRet; 2391 CFX_WideString strRet;
2402 pLocale->GetDatePattern(strStyle, strRet); 2392 pLocale->GetDatePattern(strStyle, strRet);
2403 if (!bStandard) { 2393 if (!bStandard) {
2404 CFX_WideString wsSymbols; 2394 CFX_WideString wsSymbols;
2405 pLocale->GetDateTimeSymbols(wsSymbols); 2395 pLocale->GetDateTimeSymbols(wsSymbols);
2406 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); 2396 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 } 2431 }
2442 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2432 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2443 IFX_Locale* pLocale = NULL; 2433 IFX_Locale* pLocale = NULL;
2444 if (szLocalStr.IsEmpty()) { 2434 if (szLocalStr.IsEmpty()) {
2445 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2435 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2446 FXSYS_assert(pThisNode); 2436 FXSYS_assert(pThisNode);
2447 CXFA_WidgetData widgetData(pThisNode); 2437 CXFA_WidgetData widgetData(pThisNode);
2448 pLocale = widgetData.GetLocal(); 2438 pLocale = widgetData.GetLocal();
2449 } else { 2439 } else {
2450 pLocale = pMgr->GetLocaleByName( 2440 pLocale = pMgr->GetLocaleByName(
2451 CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); 2441 CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength()));
2452 } 2442 }
2453 if (!pLocale) { 2443 if (!pLocale) {
2454 return; 2444 return;
2455 } 2445 }
2456 CFX_WideString strRet; 2446 CFX_WideString strRet;
2457 pLocale->GetTimePattern(strStyle, strRet); 2447 pLocale->GetTimePattern(strStyle, strRet);
2458 if (!bStandard) { 2448 if (!bStandard) {
2459 CFX_WideString wsSymbols; 2449 CFX_WideString wsSymbols;
2460 pLocale->GetDateTimeSymbols(wsSymbols); 2450 pLocale->GetDateTimeSymbols(wsSymbols);
2461 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); 2451 XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time);
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3744 FXJSE_Value_Release(argOne); 3734 FXJSE_Value_Release(argOne);
3745 FXJSE_Value_Release(argTwo); 3735 FXJSE_Value_Release(argTwo);
3746 } else { 3736 } else {
3747 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3737 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3748 L"Decode"); 3738 L"Decode");
3749 } 3739 }
3750 } 3740 }
3751 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, 3741 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString,
3752 CFX_ByteTextBuf& szResultString) { 3742 CFX_ByteTextBuf& szResultString) {
3753 CFX_WideString wsURLString = 3743 CFX_WideString wsURLString =
3754 CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); 3744 CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength());
3755 const FX_WCHAR* pData = wsURLString; 3745 const FX_WCHAR* pData = wsURLString;
3756 int32_t iLen = wsURLString.GetLength(); 3746 int32_t iLen = wsURLString.GetLength();
3757 int32_t i = 0; 3747 int32_t i = 0;
3758 FX_WCHAR ch = 0; 3748 FX_WCHAR ch = 0;
3759 FX_WCHAR chTemp = 0; 3749 FX_WCHAR chTemp = 0;
3760 CFX_WideTextBuf wsResultBuf; 3750 CFX_WideTextBuf wsResultBuf;
3761 while (i < iLen) { 3751 while (i < iLen) {
3762 ch = *(pData + i); 3752 ch = *(pData + i);
3763 if ('%' == ch) { 3753 if ('%' == ch) {
3764 chTemp = 0; 3754 chTemp = 0;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3799 ++i; 3789 ++i;
3800 } 3790 }
3801 wsResultBuf.AppendChar(0); 3791 wsResultBuf.AppendChar(0);
3802 szResultString.Clear(); 3792 szResultString.Clear();
3803 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), 3793 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(),
3804 wsResultBuf.GetLength()) 3794 wsResultBuf.GetLength())
3805 .AsByteStringC(); 3795 .AsByteStringC();
3806 } 3796 }
3807 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, 3797 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString,
3808 CFX_ByteTextBuf& szResultString) { 3798 CFX_ByteTextBuf& szResultString) {
3809 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8( 3799 CFX_WideString wsHTMLString =
3810 szHTMLString.GetCStr(), szHTMLString.GetLength()); 3800 CFX_WideString::FromUTF8(szHTMLString.c_str(), szHTMLString.GetLength());
3811 FX_WCHAR strString[9]; 3801 FX_WCHAR strString[9];
3812 int32_t iStrIndex = 0; 3802 int32_t iStrIndex = 0;
3813 int32_t iLen = wsHTMLString.GetLength(); 3803 int32_t iLen = wsHTMLString.GetLength();
3814 int32_t i = 0; 3804 int32_t i = 0;
3815 int32_t iCode = 0; 3805 int32_t iCode = 0;
3816 FX_WCHAR ch = 0; 3806 FX_WCHAR ch = 0;
3817 const FX_WCHAR* pData = wsHTMLString; 3807 const FX_WCHAR* pData = wsHTMLString;
3818 CFX_WideTextBuf wsResultBuf; 3808 CFX_WideTextBuf wsResultBuf;
3819 while (i < iLen) { 3809 while (i < iLen) {
3820 ch = *(pData + i); 3810 ch = *(pData + i);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3875 } 3865 }
3876 wsResultBuf.AppendChar(0); 3866 wsResultBuf.AppendChar(0);
3877 szResultString.Clear(); 3867 szResultString.Clear();
3878 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), 3868 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(),
3879 wsResultBuf.GetLength()) 3869 wsResultBuf.GetLength())
3880 .AsByteStringC(); 3870 .AsByteStringC();
3881 } 3871 }
3882 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, 3872 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString,
3883 CFX_ByteTextBuf& szResultString) { 3873 CFX_ByteTextBuf& szResultString) {
3884 CFX_WideString wsXMLString = 3874 CFX_WideString wsXMLString =
3885 CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); 3875 CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength());
3886 FX_WCHAR strString[9]; 3876 FX_WCHAR strString[9];
3887 int32_t iStrIndex = 0; 3877 int32_t iStrIndex = 0;
3888 int32_t iLen = wsXMLString.GetLength(); 3878 int32_t iLen = wsXMLString.GetLength();
3889 int32_t i = 0; 3879 int32_t i = 0;
3890 int32_t iCode = 0; 3880 int32_t iCode = 0;
3891 FX_WCHAR ch = 0; 3881 FX_WCHAR ch = 0;
3892 const FX_WCHAR* pData = wsXMLString; 3882 const FX_WCHAR* pData = wsXMLString;
3893 CFX_WideTextBuf wsXMLBuf; 3883 CFX_WideTextBuf wsXMLBuf;
3894 while (i < iLen) { 3884 while (i < iLen) {
3895 ch = *(pData + i); 3885 ch = *(pData + i);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4020 FXJSE_Value_Release(argOne); 4010 FXJSE_Value_Release(argOne);
4021 FXJSE_Value_Release(argTwo); 4011 FXJSE_Value_Release(argTwo);
4022 } else { 4012 } else {
4023 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4013 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4024 L"Encode"); 4014 L"Encode");
4025 } 4015 }
4026 } 4016 }
4027 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, 4017 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString,
4028 CFX_ByteTextBuf& szResultBuf) { 4018 CFX_ByteTextBuf& szResultBuf) {
4029 CFX_WideString wsURLString = 4019 CFX_WideString wsURLString =
4030 CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); 4020 CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength());
4031 CFX_WideTextBuf wsResultBuf; 4021 CFX_WideTextBuf wsResultBuf;
4032 FX_WCHAR ch = 0; 4022 FX_WCHAR ch = 0;
4033 int32_t iLength = wsURLString.GetLength(); 4023 int32_t iLength = wsURLString.GetLength();
4034 FX_WCHAR strEncode[4]; 4024 FX_WCHAR strEncode[4];
4035 strEncode[0] = '%'; 4025 strEncode[0] = '%';
4036 strEncode[3] = 0; 4026 strEncode[3] = 0;
4037 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', 4027 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}',
4038 '|', '\\', '^', '~', '[', ']', '`'}; 4028 '|', '\\', '^', '~', '[', ']', '`'};
4039 FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'}; 4029 FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'};
4040 FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','}; 4030 FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','};
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 } 4117 }
4128 } 4118 }
4129 } 4119 }
4130 wsResultBuf.AppendChar(0); 4120 wsResultBuf.AppendChar(0);
4131 szResultBuf.Clear(); 4121 szResultBuf.Clear();
4132 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) 4122 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
4133 .AsByteStringC(); 4123 .AsByteStringC();
4134 } 4124 }
4135 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, 4125 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString,
4136 CFX_ByteTextBuf& szResultBuf) { 4126 CFX_ByteTextBuf& szResultBuf) {
4137 CFX_ByteString str = szHTMLString.GetCStr(); 4127 CFX_ByteString str = szHTMLString.c_str();
4138 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength()); 4128 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength());
4139 const FX_WCHAR* strCode = L"0123456789abcdef"; 4129 const FX_WCHAR* strCode = L"0123456789abcdef";
4140 FX_WCHAR strEncode[9]; 4130 FX_WCHAR strEncode[9];
4141 strEncode[0] = '&'; 4131 strEncode[0] = '&';
4142 strEncode[1] = '#'; 4132 strEncode[1] = '#';
4143 strEncode[2] = 'x'; 4133 strEncode[2] = 'x';
4144 strEncode[5] = ';'; 4134 strEncode[5] = ';';
4145 strEncode[6] = 0; 4135 strEncode[6] = 0;
4146 strEncode[7] = ';'; 4136 strEncode[7] = ';';
4147 strEncode[8] = 0; 4137 strEncode[8] = 0;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4182 ++i; 4172 ++i;
4183 } 4173 }
4184 wsResultBuf.AppendChar(0); 4174 wsResultBuf.AppendChar(0);
4185 szResultBuf.Clear(); 4175 szResultBuf.Clear();
4186 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) 4176 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
4187 .AsByteStringC(); 4177 .AsByteStringC();
4188 } 4178 }
4189 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, 4179 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString,
4190 CFX_ByteTextBuf& szResultBuf) { 4180 CFX_ByteTextBuf& szResultBuf) {
4191 CFX_WideString wsXMLString = 4181 CFX_WideString wsXMLString =
4192 CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); 4182 CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength());
4193 CFX_WideTextBuf wsResultBuf; 4183 CFX_WideTextBuf wsResultBuf;
4194 enum { 4184 enum {
4195 QUOT, 4185 QUOT,
4196 AMP, 4186 AMP,
4197 APOS, 4187 APOS,
4198 LT, 4188 LT,
4199 GT, 4189 GT,
4200 }; 4190 };
4201 FX_WCHAR strEncode[9]; 4191 FX_WCHAR strEncode[9];
4202 strEncode[0] = '&'; 4192 strEncode[0] = '&';
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
4264 } 4254 }
4265 } 4255 }
4266 wsResultBuf.AppendChar(0); 4256 wsResultBuf.AppendChar(0);
4267 szResultBuf.Clear(); 4257 szResultBuf.Clear();
4268 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) 4258 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
4269 .AsByteStringC(); 4259 .AsByteStringC();
4270 } 4260 }
4271 FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData, 4261 FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData,
4272 uint32_t& iCode) { 4262 uint32_t& iCode) {
4273 int32_t iLength = pData.GetLength(); 4263 int32_t iLength = pData.GetLength();
4274 uint32_t uHash = FX_HashCode_String_GetW(pData.GetPtr(), iLength); 4264 uint32_t uHash = FX_HashCode_String_GetW(pData.raw_str(), iLength);
4275 XFA_FMHtmlHashedReserveCode htmlhashedreservecode; 4265 XFA_FMHtmlHashedReserveCode htmlhashedreservecode;
4276 int32_t iStart = 0, 4266 int32_t iStart = 0,
4277 iEnd = (sizeof(reservesForDecode) / sizeof(reservesForDecode[0])) - 1; 4267 iEnd = (sizeof(reservesForDecode) / sizeof(reservesForDecode[0])) - 1;
4278 int32_t iMid = (iStart + iEnd) / 2; 4268 int32_t iMid = (iStart + iEnd) / 2;
4279 do { 4269 do {
4280 iMid = (iStart + iEnd) / 2; 4270 iMid = (iStart + iEnd) / 2;
4281 htmlhashedreservecode = reservesForDecode[iMid]; 4271 htmlhashedreservecode = reservesForDecode[iMid];
4282 if (uHash == htmlhashedreservecode.m_uHash) { 4272 if (uHash == htmlhashedreservecode.m_uHash) {
4283 iCode = htmlhashedreservecode.m_uCode; 4273 iCode = htmlhashedreservecode.m_uCode;
4284 return TRUE; 4274 return TRUE;
(...skipping 21 matching lines...) Expand all
4306 iEnd = iMid - 1; 4296 iEnd = iMid - 1;
4307 } else { 4297 } else {
4308 iStart = iMid + 1; 4298 iStart = iMid + 1;
4309 } 4299 }
4310 } while (iStart <= iEnd); 4300 } while (iStart <= iEnd);
4311 return FALSE; 4301 return FALSE;
4312 } 4302 }
4313 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, 4303 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern,
4314 uint32_t& patternType) { 4304 uint32_t& patternType) {
4315 CFX_WideString wsPattern = 4305 CFX_WideString wsPattern =
4316 CFX_WideString::FromUTF8(szPattern.GetCStr(), szPattern.GetLength()); 4306 CFX_WideString::FromUTF8(szPattern.c_str(), szPattern.GetLength());
4317 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { 4307 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) {
4318 patternType = XFA_VT_DATETIME; 4308 patternType = XFA_VT_DATETIME;
4319 return TRUE; 4309 return TRUE;
4320 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { 4310 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) {
4321 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; 4311 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE;
4322 return TRUE; 4312 return TRUE;
4323 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { 4313 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) {
4324 patternType = XFA_VT_TIME; 4314 patternType = XFA_VT_TIME;
4325 return TRUE; 4315 return TRUE;
4326 } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { 4316 } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) {
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
5283 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", 5273 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four",
5284 "Five", "Six", "Seven", "Eight", "Nine"}; 5274 "Five", "Six", "Seven", "Eight", "Nine"};
5285 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", 5275 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen",
5286 "Fourteen", "Fifteen", "Sixteen", "Seventeen", 5276 "Fourteen", "Fifteen", "Sixteen", "Seventeen",
5287 "Eighteen", "Nineteen"}; 5277 "Eighteen", "Nineteen"};
5288 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", 5278 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty",
5289 "Sixty", "Seventy", "Eighty", "Ninety"}; 5279 "Sixty", "Seventy", "Eighty", "Ninety"};
5290 CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ", 5280 CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ",
5291 " Billion ", "Trillion"}; 5281 " Billion ", "Trillion"};
5292 int32_t iComm = 0; 5282 int32_t iComm = 0;
5293 const FX_CHAR* pData = szData.GetCStr(); 5283 const FX_CHAR* pData = szData.c_str();
5294 int32_t iLength = szData.GetLength(); 5284 int32_t iLength = szData.GetLength();
5295 if (iLength > 12) { 5285 if (iLength > 12) {
5296 iComm = 4; 5286 iComm = 4;
5297 } else if (iLength > 9) { 5287 } else if (iLength > 9) {
5298 iComm = 3; 5288 iComm = 3;
5299 } else if (iLength > 6) { 5289 } else if (iLength > 6) {
5300 iComm = 2; 5290 iComm = 2;
5301 } else if (iLength > 3) { 5291 } else if (iLength > 3) {
5302 iComm = 1; 5292 iComm = 1;
5303 } 5293 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5369 if (iIndex < iLength - 3) { 5359 if (iIndex < iLength - 3) {
5370 strBuf << pComm[iComm]; 5360 strBuf << pComm[iComm];
5371 --iComm; 5361 --iComm;
5372 } 5362 }
5373 iIndex += 3; 5363 iIndex += 3;
5374 } 5364 }
5375 } 5365 }
5376 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, 5366 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData,
5377 int32_t iStyle, 5367 int32_t iStyle,
5378 CFX_ByteTextBuf& strBuf) { 5368 CFX_ByteTextBuf& strBuf) {
5379 const FX_CHAR* pData = szData.GetCStr(); 5369 const FX_CHAR* pData = szData.c_str();
5380 int32_t iLength = szData.GetLength(); 5370 int32_t iLength = szData.GetLength();
5381 switch (iStyle) { 5371 switch (iStyle) {
5382 case 0: { 5372 case 0: {
5383 int32_t iIndex = 0; 5373 int32_t iIndex = 0;
5384 while (iIndex < iLength) { 5374 while (iIndex < iLength) {
5385 if (*(pData + iIndex) == '.') { 5375 if (*(pData + iIndex) == '.') {
5386 break; 5376 break;
5387 } 5377 }
5388 ++iIndex; 5378 ++iIndex;
5389 } 5379 }
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
6881 CXFA_Document* pDoc = pContext->GetDocument(); 6871 CXFA_Document* pDoc = pContext->GetDocument();
6882 if (!pDoc) { 6872 if (!pDoc) {
6883 return bFlags; 6873 return bFlags;
6884 } 6874 }
6885 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6875 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6886 XFA_RESOLVENODE_RS resoveNodeRS; 6876 XFA_RESOLVENODE_RS resoveNodeRS;
6887 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 6877 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
6888 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6878 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6889 int32_t iRet = pScriptContext->ResolveObjects( 6879 int32_t iRet = pScriptContext->ResolveObjects(
6890 pScriptContext->GetThisObject(), 6880 pScriptContext->GetThisObject(),
6891 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), 6881 CFX_WideString::FromUTF8(szAccessorName.c_str(),
6892 szAccessorName.GetLength()), 6882 szAccessorName.GetLength()),
6893 resoveNodeRS, dwFlags); 6883 resoveNodeRS, dwFlags);
6894 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6884 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6895 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( 6885 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap(
6896 resoveNodeRS.nodes.GetAt(0))); 6886 resoveNodeRS.nodes.GetAt(0)));
6897 bFlags = TRUE; 6887 bFlags = TRUE;
6898 } 6888 }
6899 return bFlags; 6889 return bFlags;
6900 } 6890 }
6901 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, 6891 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis,
6902 FXJSE_HVALUE hRefValue, 6892 FXJSE_HVALUE hRefValue,
6903 const CFX_ByteStringC& bsSomExp, 6893 const CFX_ByteStringC& bsSomExp,
6904 XFA_RESOLVENODE_RS& resoveNodeRS, 6894 XFA_RESOLVENODE_RS& resoveNodeRS,
6905 FX_BOOL bdotAccessor, 6895 FX_BOOL bdotAccessor,
6906 FX_BOOL bHasNoResolveName) { 6896 FX_BOOL bHasNoResolveName) {
6907 CFX_WideString wsSomExpression = 6897 CFX_WideString wsSomExpression =
6908 CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); 6898 CFX_WideString::FromUTF8(bsSomExp.c_str(), bsSomExp.GetLength());
6909 int32_t iRet = -1; 6899 int32_t iRet = -1;
6910 CXFA_FM2JSContext* pContext = 6900 CXFA_FM2JSContext* pContext =
6911 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); 6901 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
6912 CXFA_Document* pDoc = pContext->GetDocument(); 6902 CXFA_Document* pDoc = pContext->GetDocument();
6913 if (!pDoc) { 6903 if (!pDoc) {
6914 return iRet; 6904 return iRet;
6915 } 6905 }
6916 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6906 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6917 CXFA_Object* pNode = NULL; 6907 CXFA_Object* pNode = NULL;
6918 uint32_t dFlags = 0UL; 6908 uint32_t dFlags = 0UL;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
7266 CFX_WideString wsFormat; 7256 CFX_WideString wsFormat;
7267 pAppProvider->LoadString(iStringID, wsFormat); 7257 pAppProvider->LoadString(iStringID, wsFormat);
7268 CFX_WideString wsMessage; 7258 CFX_WideString wsMessage;
7269 va_list arg_ptr; 7259 va_list arg_ptr;
7270 va_start(arg_ptr, iStringID); 7260 va_start(arg_ptr, iStringID);
7271 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); 7261 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr);
7272 va_end(arg_ptr); 7262 va_end(arg_ptr);
7273 FXJSE_ThrowMessage( 7263 FXJSE_ThrowMessage(
7274 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC()); 7264 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC());
7275 } 7265 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | xfa/fxfa/fm2js/xfa_lexer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698