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

Side by Side Diff: fpdfsdk/javascript/util.cpp

Issue 1833053002: util.printd() replaces specified date with current date. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: h is wrong, not H. 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 | « fpdfsdk/javascript/util.h ('k') | testing/resources/javascript/util_printd.in » ('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 "fpdfsdk/javascript/util.h" 7 #include "fpdfsdk/javascript/util.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
11 #include <algorithm>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "core/fxcrt/include/fx_ext.h" 15 #include "core/fxcrt/include/fx_ext.h"
15 #include "fpdfsdk/include/javascript/IJavaScript.h" 16 #include "fpdfsdk/include/javascript/IJavaScript.h"
16 #include "fpdfsdk/javascript/JS_Context.h" 17 #include "fpdfsdk/javascript/JS_Context.h"
17 #include "fpdfsdk/javascript/JS_Define.h" 18 #include "fpdfsdk/javascript/JS_Define.h"
18 #include "fpdfsdk/javascript/JS_EventHandler.h" 19 #include "fpdfsdk/javascript/JS_EventHandler.h"
19 #include "fpdfsdk/javascript/JS_Object.h" 20 #include "fpdfsdk/javascript/JS_Object.h"
20 #include "fpdfsdk/javascript/JS_Runtime.h" 21 #include "fpdfsdk/javascript/JS_Runtime.h"
(...skipping 14 matching lines...) Expand all
35 BEGIN_JS_STATIC_METHOD(CJS_Util) 36 BEGIN_JS_STATIC_METHOD(CJS_Util)
36 JS_STATIC_METHOD_ENTRY(printd) 37 JS_STATIC_METHOD_ENTRY(printd)
37 JS_STATIC_METHOD_ENTRY(printf) 38 JS_STATIC_METHOD_ENTRY(printf)
38 JS_STATIC_METHOD_ENTRY(printx) 39 JS_STATIC_METHOD_ENTRY(printx)
39 JS_STATIC_METHOD_ENTRY(scand) 40 JS_STATIC_METHOD_ENTRY(scand)
40 JS_STATIC_METHOD_ENTRY(byteToChar) 41 JS_STATIC_METHOD_ENTRY(byteToChar)
41 END_JS_STATIC_METHOD() 42 END_JS_STATIC_METHOD()
42 43
43 IMPLEMENT_JS_CLASS(CJS_Util, util) 44 IMPLEMENT_JS_CLASS(CJS_Util, util)
44 45
45 util::util(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
46
47 util::~util() {}
48
49 struct stru_TbConvert {
50 const FX_WCHAR* lpszJSMark;
51 const FX_WCHAR* lpszCppMark;
52 };
53
54 const stru_TbConvert fcTable[] = {
55 {L"mmmm", L"%B"},
56 {L"mmm", L"%b"},
57 {L"mm", L"%m"},
58 // "m"
59 {L"dddd", L"%A"},
60 {L"ddd", L"%a"},
61 {L"dd", L"%d"},
62 // "d", "%w",
63 {L"yyyy", L"%Y"},
64 {L"yy", L"%y"},
65 {L"HH", L"%H"},
66 // "H"
67 {L"hh", L"%I"},
68 // "h"
69 {L"MM", L"%M"},
70 // "M"
71 {L"ss", L"%S"},
72 // "s
73 {L"TT", L"%p"},
74 // "t"
75 #if defined(_WIN32)
76 {L"tt", L"%p"},
77 {L"h", L"%#I"},
78 #else
79 {L"tt", L"%P"},
80 {L"h", L"%l"},
81 #endif
82 };
83
84 #define UTIL_INT 0 46 #define UTIL_INT 0
85 #define UTIL_DOUBLE 1 47 #define UTIL_DOUBLE 1
86 #define UTIL_STRING 2 48 #define UTIL_STRING 2
87 49
88 int util::ParstDataType(std::wstring* sFormat) { 50 namespace {
51
52 // Map PDF-style directives to equivalent wcsftime directives. Not
53 // all have direct equivalents, though.
54 struct TbConvert {
55 const FX_WCHAR* lpszJSMark;
56 const FX_WCHAR* lpszCppMark;
57 };
58
59 // Map PDF-style directives lacking direct wcsftime directives to
60 // the value with which they will be replaced.
61 struct TbConvertAdditional {
62 const FX_WCHAR* lpszJSMark;
63 int iValue;
64 };
65
66 const TbConvert TbConvertTable[] = {
67 {L"mmmm", L"%B"}, {L"mmm", L"%b"}, {L"mm", L"%m"}, {L"dddd", L"%A"},
68 {L"ddd", L"%a"}, {L"dd", L"%d"}, {L"yyyy", L"%Y"}, {L"yy", L"%y"},
69 {L"HH", L"%H"}, {L"hh", L"%I"}, {L"MM", L"%M"}, {L"ss", L"%S"},
70 {L"TT", L"%p"},
71 #if defined(_WIN32)
72 {L"tt", L"%p"}, {L"h", L"%#I"},
73 #else
74 {L"tt", L"%P"}, {L"h", L"%l"},
75 #endif
76 };
77
78 int ParseDataType(std::wstring* sFormat) {
89 bool bPercent = FALSE; 79 bool bPercent = FALSE;
90 for (size_t i = 0; i < sFormat->length(); ++i) { 80 for (size_t i = 0; i < sFormat->length(); ++i) {
91 wchar_t c = (*sFormat)[i]; 81 wchar_t c = (*sFormat)[i];
92 if (c == L'%') { 82 if (c == L'%') {
93 bPercent = true; 83 bPercent = true;
94 continue; 84 continue;
95 } 85 }
96 86
97 if (bPercent) { 87 if (bPercent) {
98 if (c == L'c' || c == L'C' || c == L'd' || c == L'i' || c == L'o' || 88 if (c == L'c' || c == L'C' || c == L'd' || c == L'i' || c == L'o' ||
(...skipping 13 matching lines...) Expand all
112 FXSYS_iswdigit(c)) { 102 FXSYS_iswdigit(c)) {
113 continue; 103 continue;
114 } 104 }
115 break; 105 break;
116 } 106 }
117 } 107 }
118 108
119 return -1; 109 return -1;
120 } 110 }
121 111
112 } // namespace
113
114 util::util(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
115
116 util::~util() {}
117
122 FX_BOOL util::printf(IJS_Context* cc, 118 FX_BOOL util::printf(IJS_Context* cc,
123 const std::vector<CJS_Value>& params, 119 const std::vector<CJS_Value>& params,
124 CJS_Value& vRet, 120 CJS_Value& vRet,
125 CFX_WideString& sError) { 121 CFX_WideString& sError) {
126 int iSize = params.size(); 122 int iSize = params.size();
127 if (iSize < 1) 123 if (iSize < 1)
128 return FALSE; 124 return FALSE;
129 std::wstring c_ConvChar(params[0].ToCFXWideString().c_str()); 125 std::wstring c_ConvChar(params[0].ToCFXWideString().c_str());
130 std::vector<std::wstring> c_strConvers; 126 std::vector<std::wstring> c_strConvers;
131 int iOffset = 0; 127 int iOffset = 0;
132 int iOffend = 0; 128 int iOffend = 0;
133 c_ConvChar.insert(c_ConvChar.begin(), L'S'); 129 c_ConvChar.insert(c_ConvChar.begin(), L'S');
134 while (iOffset != -1) { 130 while (iOffset != -1) {
135 iOffend = c_ConvChar.find(L"%", iOffset + 1); 131 iOffend = c_ConvChar.find(L"%", iOffset + 1);
136 std::wstring strSub; 132 std::wstring strSub;
137 if (iOffend == -1) 133 if (iOffend == -1)
138 strSub = c_ConvChar.substr(iOffset); 134 strSub = c_ConvChar.substr(iOffset);
139 else 135 else
140 strSub = c_ConvChar.substr(iOffset, iOffend - iOffset); 136 strSub = c_ConvChar.substr(iOffset, iOffend - iOffset);
141 c_strConvers.push_back(strSub); 137 c_strConvers.push_back(strSub);
142 iOffset = iOffend; 138 iOffset = iOffend;
143 } 139 }
144 140
145 std::wstring c_strResult; 141 std::wstring c_strResult;
146
147 // for(int iIndex = 1;iIndex < params.size();iIndex++)
148 std::wstring c_strFormat; 142 std::wstring c_strFormat;
149 for (int iIndex = 0; iIndex < (int)c_strConvers.size(); iIndex++) { 143 for (int iIndex = 0; iIndex < (int)c_strConvers.size(); iIndex++) {
150 c_strFormat = c_strConvers[iIndex]; 144 c_strFormat = c_strConvers[iIndex];
151 if (iIndex == 0) { 145 if (iIndex == 0) {
152 c_strResult = c_strFormat; 146 c_strResult = c_strFormat;
153 continue; 147 continue;
154 } 148 }
155 149
156 CFX_WideString strSegment; 150 CFX_WideString strSegment;
157 if (iIndex >= iSize) { 151 if (iIndex >= iSize) {
158 c_strResult += c_strFormat; 152 c_strResult += c_strFormat;
159 continue; 153 continue;
160 } 154 }
161 155
162 switch (ParstDataType(&c_strFormat)) { 156 switch (ParseDataType(&c_strFormat)) {
163 case UTIL_INT: 157 case UTIL_INT:
164 strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt()); 158 strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt());
165 break; 159 break;
166 case UTIL_DOUBLE: 160 case UTIL_DOUBLE:
167 strSegment.Format(c_strFormat.c_str(), params[iIndex].ToDouble()); 161 strSegment.Format(c_strFormat.c_str(), params[iIndex].ToDouble());
168 break; 162 break;
169 case UTIL_STRING: 163 case UTIL_STRING:
170 strSegment.Format(c_strFormat.c_str(), 164 strSegment.Format(c_strFormat.c_str(),
171 params[iIndex].ToCFXWideString().c_str()); 165 params[iIndex].ToCFXWideString().c_str());
172 break; 166 break;
(...skipping 11 matching lines...) Expand all
184 178
185 FX_BOOL util::printd(IJS_Context* cc, 179 FX_BOOL util::printd(IJS_Context* cc,
186 const std::vector<CJS_Value>& params, 180 const std::vector<CJS_Value>& params,
187 CJS_Value& vRet, 181 CJS_Value& vRet,
188 CFX_WideString& sError) { 182 CFX_WideString& sError) {
189 int iSize = params.size(); 183 int iSize = params.size();
190 if (iSize < 2) 184 if (iSize < 2)
191 return FALSE; 185 return FALSE;
192 186
193 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 187 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
194 CJS_Value p1(pRuntime); 188 CJS_Value p1 = params[0];
195 p1 = params[0];
196
197 CJS_Value p2 = params[1]; 189 CJS_Value p2 = params[1];
198 CJS_Date jsDate(pRuntime); 190 CJS_Date jsDate(pRuntime);
199 if (!p2.ConvertToDate(jsDate)) { 191 if (!p2.ConvertToDate(jsDate)) {
200 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT1); 192 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT1);
201 return FALSE; 193 return FALSE;
202 } 194 }
203 195
204 if (!jsDate.IsValidDate()) { 196 if (!jsDate.IsValidDate()) {
205 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT2); 197 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT2);
206 return FALSE; 198 return FALSE;
207 } 199 }
208 200
209 if (p1.GetType() == CJS_Value::VT_number) { 201 if (p1.GetType() == CJS_Value::VT_number) {
210 int nFormat = p1.ToInt();
211 CFX_WideString swResult; 202 CFX_WideString swResult;
212 203 switch (p1.ToInt()) {
213 switch (nFormat) {
214 case 0: 204 case 0:
215 swResult.Format(L"D:%04d%02d%02d%02d%02d%02d", jsDate.GetYear(), 205 swResult.Format(L"D:%04d%02d%02d%02d%02d%02d", jsDate.GetYear(),
216 jsDate.GetMonth() + 1, jsDate.GetDay(), 206 jsDate.GetMonth() + 1, jsDate.GetDay(),
217 jsDate.GetHours(), jsDate.GetMinutes(), 207 jsDate.GetHours(), jsDate.GetMinutes(),
218 jsDate.GetSeconds()); 208 jsDate.GetSeconds());
219 break; 209 break;
220 case 1: 210 case 1:
221 swResult.Format(L"%04d.%02d.%02d %02d:%02d:%02d", jsDate.GetYear(), 211 swResult.Format(L"%04d.%02d.%02d %02d:%02d:%02d", jsDate.GetYear(),
222 jsDate.GetMonth() + 1, jsDate.GetDay(), 212 jsDate.GetMonth() + 1, jsDate.GetDay(),
223 jsDate.GetHours(), jsDate.GetMinutes(), 213 jsDate.GetHours(), jsDate.GetMinutes(),
224 jsDate.GetSeconds()); 214 jsDate.GetSeconds());
225 break; 215 break;
226 case 2: 216 case 2:
227 swResult.Format(L"%04d/%02d/%02d %02d:%02d:%02d", jsDate.GetYear(), 217 swResult.Format(L"%04d/%02d/%02d %02d:%02d:%02d", jsDate.GetYear(),
228 jsDate.GetMonth() + 1, jsDate.GetDay(), 218 jsDate.GetMonth() + 1, jsDate.GetDay(),
229 jsDate.GetHours(), jsDate.GetMinutes(), 219 jsDate.GetHours(), jsDate.GetMinutes(),
230 jsDate.GetSeconds()); 220 jsDate.GetSeconds());
231 break; 221 break;
232 default: 222 default:
223 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSVALUEERROR);
233 return FALSE; 224 return FALSE;
234 } 225 }
235 226
236 vRet = swResult.c_str(); 227 vRet = swResult.c_str();
237 return TRUE; 228 return TRUE;
238 } 229 }
230
239 if (p1.GetType() == CJS_Value::VT_string) { 231 if (p1.GetType() == CJS_Value::VT_string) {
240 std::basic_string<wchar_t> cFormat = p1.ToCFXWideString().c_str(); 232 if (iSize > 2 && params[2].ToBool()) {
241 233 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_NOTSUPPORT);
242 bool bXFAPicture = false;
243 if (iSize > 2) {
244 bXFAPicture = params[2].ToBool();
245 }
246
247 if (bXFAPicture) {
248 return FALSE; // currently, it doesn't support XFAPicture. 234 return FALSE; // currently, it doesn't support XFAPicture.
249 } 235 }
250 236
251 for (size_t i = 0; i < sizeof(fcTable) / sizeof(stru_TbConvert); ++i) { 237 // Convert PDF-style format specifiers to wcsftime specifiers. Remove any
238 // pre-existing %-directives before inserting our own.
239 std::basic_string<wchar_t> cFormat = p1.ToCFXWideString().c_str();
240 cFormat.erase(std::remove(cFormat.begin(), cFormat.end(), '%'),
241 cFormat.end());
242
243 for (size_t i = 0; i < FX_ArraySize(TbConvertTable); ++i) {
252 int iStart = 0; 244 int iStart = 0;
253 int iEnd; 245 int iEnd;
254 while ((iEnd = cFormat.find(fcTable[i].lpszJSMark, iStart)) != -1) { 246 while ((iEnd = cFormat.find(TbConvertTable[i].lpszJSMark, iStart)) !=
255 cFormat.replace(iEnd, FXSYS_wcslen(fcTable[i].lpszJSMark), 247 -1) {
256 fcTable[i].lpszCppMark); 248 cFormat.replace(iEnd, FXSYS_wcslen(TbConvertTable[i].lpszJSMark),
249 TbConvertTable[i].lpszCppMark);
257 iStart = iEnd; 250 iStart = iEnd;
258 } 251 }
259 } 252 }
260 253
261 int iYear, iMonth, iDay, iHour, iMin, iSec; 254 int iYear = jsDate.GetYear();
262 iYear = jsDate.GetYear(); 255 int iMonth = jsDate.GetMonth();
263 iMonth = jsDate.GetMonth(); 256 int iDay = jsDate.GetDay();
264 iDay = jsDate.GetDay(); 257 int iHour = jsDate.GetHours();
265 iHour = jsDate.GetHours(); 258 int iMin = jsDate.GetMinutes();
266 iMin = jsDate.GetMinutes(); 259 int iSec = jsDate.GetSeconds();
267 iSec = jsDate.GetSeconds();
268 260
269 struct tm time = {}; 261 TbConvertAdditional cTableAd[] = {
270 time.tm_year = iYear - 1900;
271 time.tm_mon = iMonth;
272 time.tm_mday = iDay;
273 time.tm_hour = iHour;
274 time.tm_min = iMin;
275 time.tm_sec = iSec;
276
277 struct stru_TbConvertAd {
278 const FX_WCHAR* lpszJSMark;
279 int iValue;
280 };
281
282 stru_TbConvertAd cTableAd[] = {
283 {L"m", iMonth + 1}, {L"d", iDay}, 262 {L"m", iMonth + 1}, {L"d", iDay},
284 {L"H", iHour}, {L"h", iHour > 12 ? iHour - 12 : iHour}, 263 {L"H", iHour}, {L"h", iHour > 12 ? iHour - 12 : iHour},
285 {L"M", iMin}, {L"s", iSec}, 264 {L"M", iMin}, {L"s", iSec},
286 }; 265 };
287 266
288 for (size_t i = 0; i < sizeof(cTableAd) / sizeof(stru_TbConvertAd); ++i) { 267 for (size_t i = 0; i < FX_ArraySize(cTableAd); ++i) {
289 wchar_t tszValue[10]; 268 wchar_t tszValue[16];
290 CFX_WideString sValue; 269 CFX_WideString sValue;
291 sValue.Format(L"%d", cTableAd[i].iValue); 270 sValue.Format(L"%d", cTableAd[i].iValue);
292 memcpy(tszValue, (wchar_t*)sValue.GetBuffer(sValue.GetLength() + 1), 271 memcpy(tszValue, (wchar_t*)sValue.GetBuffer(sValue.GetLength() + 1),
293 (sValue.GetLength() + 1) * sizeof(wchar_t)); 272 (sValue.GetLength() + 1) * sizeof(wchar_t));
294 273
295 int iStart = 0; 274 int iStart = 0;
296 int iEnd; 275 int iEnd;
297 while ((iEnd = cFormat.find(cTableAd[i].lpszJSMark, iStart)) != -1) { 276 while ((iEnd = cFormat.find(cTableAd[i].lpszJSMark, iStart)) != -1) {
298 if (iEnd > 0) { 277 if (iEnd > 0) {
299 if (cFormat[iEnd - 1] == L'%') { 278 if (cFormat[iEnd - 1] == L'%') {
300 iStart = iEnd + 1; 279 iStart = iEnd + 1;
301 continue; 280 continue;
302 } 281 }
303 } 282 }
304 cFormat.replace(iEnd, FXSYS_wcslen(cTableAd[i].lpszJSMark), tszValue); 283 cFormat.replace(iEnd, FXSYS_wcslen(cTableAd[i].lpszJSMark), tszValue);
305 iStart = iEnd; 284 iStart = iEnd;
306 } 285 }
307 } 286 }
308 287
309 CFX_WideString strFormat; 288 struct tm time = {};
289 time.tm_year = iYear - 1900;
290 time.tm_mon = iMonth;
291 time.tm_mday = iDay;
292 time.tm_hour = iHour;
293 time.tm_min = iMin;
294 time.tm_sec = iSec;
295
310 wchar_t buf[64] = {}; 296 wchar_t buf[64] = {};
311 strFormat = wcsftime(buf, 64, cFormat.c_str(), &time); 297 wcsftime(buf, 64, cFormat.c_str(), &time);
312 cFormat = buf; 298 cFormat = buf;
313 vRet = cFormat.c_str(); 299 vRet = cFormat.c_str();
314 return TRUE; 300 return TRUE;
315 } 301 }
302
303 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSTYPEERROR);
316 return FALSE; 304 return FALSE;
317 } 305 }
318 306
319 void util::printd(const std::wstring& cFormat2,
320 CJS_Date jsDate,
321 bool bXFAPicture,
322 std::wstring& cPurpose) {
323 std::wstring cFormat = cFormat2;
324
325 if (bXFAPicture) {
326 return; // currently, it doesn't support XFAPicture.
327 }
328
329 for (size_t i = 0; i < sizeof(fcTable) / sizeof(stru_TbConvert); ++i) {
330 int iStart = 0;
331 int iEnd;
332 while ((iEnd = cFormat.find(fcTable[i].lpszJSMark, iStart)) != -1) {
333 cFormat.replace(iEnd, FXSYS_wcslen(fcTable[i].lpszJSMark),
334 fcTable[i].lpszCppMark);
335 iStart = iEnd;
336 }
337 }
338
339 int iYear, iMonth, iDay, iHour, iMin, iSec;
340 iYear = jsDate.GetYear();
341 iMonth = jsDate.GetMonth();
342 iDay = jsDate.GetDay();
343 iHour = jsDate.GetHours();
344 iMin = jsDate.GetMinutes();
345 iSec = jsDate.GetSeconds();
346
347 struct tm time = {};
348 time.tm_year = iYear - 1900;
349 time.tm_mon = iMonth;
350 time.tm_mday = iDay;
351 time.tm_hour = iHour;
352 time.tm_min = iMin;
353 time.tm_sec = iSec;
354 // COleDateTime cppTm(iYear,iMonth+1,iDay,iHour,iMin,iSec);
355 // CString strFormat = cppTm.Format(cFormat.c_str());
356
357 struct stru_TbConvertAd {
358 const FX_WCHAR* lpszJSMark;
359 int iValue;
360 };
361
362 stru_TbConvertAd cTableAd[] = {
363 {L"m", iMonth + 1}, {L"d", iDay},
364 {L"H", iHour}, {L"h", iHour > 12 ? iHour - 12 : iHour},
365 {L"M", iMin}, {L"s", iSec},
366 };
367
368 // cFormat = strFormat.GetBuffer(strFormat.GetLength()+1);
369 for (size_t i = 0; i < sizeof(cTableAd) / sizeof(stru_TbConvertAd); ++i) {
370 wchar_t tszValue[10];
371 CFX_WideString sValue;
372 sValue.Format(L"%d", cTableAd[i].iValue);
373 memcpy(tszValue, (wchar_t*)sValue.GetBuffer(sValue.GetLength() + 1),
374 sValue.GetLength() * sizeof(wchar_t));
375
376 int iStart = 0;
377 int iEnd;
378 while ((iEnd = cFormat.find(cTableAd[i].lpszJSMark, iStart)) != -1) {
379 if (iEnd > 0) {
380 if (cFormat[iEnd - 1] == L'%') {
381 iStart = iEnd + 1;
382 continue;
383 }
384 }
385 cFormat.replace(iEnd, FXSYS_wcslen(cTableAd[i].lpszJSMark), tszValue);
386 iStart = iEnd;
387 }
388 }
389
390 CFX_WideString strFormat;
391 wchar_t buf[64] = {};
392 strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
393 cFormat = buf;
394 cPurpose = cFormat;
395 }
396 307
397 FX_BOOL util::printx(IJS_Context* cc, 308 FX_BOOL util::printx(IJS_Context* cc,
398 const std::vector<CJS_Value>& params, 309 const std::vector<CJS_Value>& params,
399 CJS_Value& vRet, 310 CJS_Value& vRet,
400 CFX_WideString& sError) { 311 CFX_WideString& sError) {
401 int iSize = params.size(); 312 int iSize = params.size();
402 if (iSize < 2) 313 if (iSize < 2)
403 return FALSE; 314 return FALSE;
404 CFX_WideString sFormat = params[0].ToCFXWideString(); 315 CFX_WideString sFormat = params[0].ToCFXWideString();
405 CFX_WideString sSource = params[1].ToCFXWideString(); 316 CFX_WideString sSource = params[1].ToCFXWideString();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 int iSize = params.size(); 432 int iSize = params.size();
522 if (iSize == 0) 433 if (iSize == 0)
523 return FALSE; 434 return FALSE;
524 int nByte = params[0].ToInt(); 435 int nByte = params[0].ToInt();
525 unsigned char cByte = (unsigned char)nByte; 436 unsigned char cByte = (unsigned char)nByte;
526 CFX_WideString csValue; 437 CFX_WideString csValue;
527 csValue.Format(L"%c", cByte); 438 csValue.Format(L"%c", cByte);
528 vRet = csValue.c_str(); 439 vRet = csValue.c_str();
529 return TRUE; 440 return TRUE;
530 } 441 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/util.h ('k') | testing/resources/javascript/util_printd.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698