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 #ifndef XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ | 7 #ifndef XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ |
8 #define XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ | 8 #define XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ |
9 | 9 |
10 #include "fxjs/cfxjse_arguments.h" | 10 #include "fxjs/cfxjse_arguments.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 static void Time(CFXJSE_Value* pThis, | 81 static void Time(CFXJSE_Value* pThis, |
82 const CFX_ByteStringC& szFuncName, | 82 const CFX_ByteStringC& szFuncName, |
83 CFXJSE_Arguments& args); | 83 CFXJSE_Arguments& args); |
84 static void Time2Num(CFXJSE_Value* pThis, | 84 static void Time2Num(CFXJSE_Value* pThis, |
85 const CFX_ByteStringC& szFuncName, | 85 const CFX_ByteStringC& szFuncName, |
86 CFXJSE_Arguments& args); | 86 CFXJSE_Arguments& args); |
87 static void TimeFmt(CFXJSE_Value* pThis, | 87 static void TimeFmt(CFXJSE_Value* pThis, |
88 const CFX_ByteStringC& szFuncName, | 88 const CFX_ByteStringC& szFuncName, |
89 CFXJSE_Arguments& args); | 89 CFXJSE_Arguments& args); |
90 | 90 |
91 static FX_BOOL IsIsoDateFormat(const FX_CHAR* pData, | 91 static bool IsIsoDateFormat(const FX_CHAR* pData, |
92 int32_t iLength, | 92 int32_t iLength, |
93 int32_t& iStyle, | 93 int32_t& iStyle, |
94 int32_t& iYear, | 94 int32_t& iYear, |
95 int32_t& iMonth, | 95 int32_t& iMonth, |
96 int32_t& iDay); | 96 int32_t& iDay); |
97 static FX_BOOL IsIsoTimeFormat(const FX_CHAR* pData, | 97 static bool IsIsoTimeFormat(const FX_CHAR* pData, |
98 int32_t iLength, | 98 int32_t iLength, |
99 int32_t& iHour, | 99 int32_t& iHour, |
100 int32_t& iMinute, | 100 int32_t& iMinute, |
101 int32_t& iSecond, | 101 int32_t& iSecond, |
102 int32_t& iMilliSecond, | 102 int32_t& iMilliSecond, |
103 int32_t& iZoneHour, | 103 int32_t& iZoneHour, |
104 int32_t& iZoneMinute); | 104 int32_t& iZoneMinute); |
105 static FX_BOOL IsIsoDateTimeFormat(const FX_CHAR* pData, | 105 static bool IsIsoDateTimeFormat(const FX_CHAR* pData, |
106 int32_t iLength, | 106 int32_t iLength, |
107 int32_t& iYear, | 107 int32_t& iYear, |
108 int32_t& iMonth, | 108 int32_t& iMonth, |
109 int32_t& iDay, | 109 int32_t& iDay, |
110 int32_t& iHour, | 110 int32_t& iHour, |
111 int32_t& iMinute, | 111 int32_t& iMinute, |
112 int32_t& iSecond, | 112 int32_t& iSecond, |
113 int32_t& iMillionSecond, | 113 int32_t& iMillionSecond, |
114 int32_t& iZoneHour, | 114 int32_t& iZoneHour, |
115 int32_t& iZoneMinute); | 115 int32_t& iZoneMinute); |
116 static FX_BOOL Local2IsoDate(CFXJSE_Value* pThis, | 116 static bool Local2IsoDate(CFXJSE_Value* pThis, |
117 const CFX_ByteStringC& szDate, | 117 const CFX_ByteStringC& szDate, |
118 const CFX_ByteStringC& szFormat, | 118 const CFX_ByteStringC& szFormat, |
119 const CFX_ByteStringC& szLocale, | 119 const CFX_ByteStringC& szLocale, |
120 CFX_ByteString& strIsoDate); | 120 CFX_ByteString& strIsoDate); |
121 static FX_BOOL Local2IsoTime(CFXJSE_Value* pThis, | 121 static bool Local2IsoTime(CFXJSE_Value* pThis, |
122 const CFX_ByteStringC& szTime, | |
123 const CFX_ByteStringC& szFormat, | |
124 const CFX_ByteStringC& szLocale, | |
125 CFX_ByteString& strIsoTime); | |
126 static FX_BOOL IsoDate2Local(CFXJSE_Value* pThis, | |
127 const CFX_ByteStringC& szDate, | |
128 const CFX_ByteStringC& szFormat, | |
129 const CFX_ByteStringC& szLocale, | |
130 CFX_ByteString& strLocalDate); | |
131 static FX_BOOL IsoTime2Local(CFXJSE_Value* pThis, | |
132 const CFX_ByteStringC& szTime, | |
133 const CFX_ByteStringC& szFormat, | |
134 const CFX_ByteStringC& szLocale, | |
135 CFX_ByteString& strLocalTime); | |
136 static FX_BOOL GetGMTTime(CFXJSE_Value* pThis, | |
137 const CFX_ByteStringC& szTime, | 122 const CFX_ByteStringC& szTime, |
138 const CFX_ByteStringC& szFormat, | 123 const CFX_ByteStringC& szFormat, |
139 const CFX_ByteStringC& szLocale, | 124 const CFX_ByteStringC& szLocale, |
140 CFX_ByteString& strGMTTime); | 125 CFX_ByteString& strIsoTime); |
| 126 static bool IsoDate2Local(CFXJSE_Value* pThis, |
| 127 const CFX_ByteStringC& szDate, |
| 128 const CFX_ByteStringC& szFormat, |
| 129 const CFX_ByteStringC& szLocale, |
| 130 CFX_ByteString& strLocalDate); |
| 131 static bool IsoTime2Local(CFXJSE_Value* pThis, |
| 132 const CFX_ByteStringC& szTime, |
| 133 const CFX_ByteStringC& szFormat, |
| 134 const CFX_ByteStringC& szLocale, |
| 135 CFX_ByteString& strLocalTime); |
| 136 static bool GetGMTTime(CFXJSE_Value* pThis, |
| 137 const CFX_ByteStringC& szTime, |
| 138 const CFX_ByteStringC& szFormat, |
| 139 const CFX_ByteStringC& szLocale, |
| 140 CFX_ByteString& strGMTTime); |
141 static int32_t DateString2Num(const CFX_ByteStringC& szDateString); | 141 static int32_t DateString2Num(const CFX_ByteStringC& szDateString); |
142 static void GetLocalDateFormat(CFXJSE_Value* pThis, | 142 static void GetLocalDateFormat(CFXJSE_Value* pThis, |
143 int32_t iStyle, | 143 int32_t iStyle, |
144 const CFX_ByteStringC& szLocalStr, | 144 const CFX_ByteStringC& szLocalStr, |
145 CFX_ByteString& strFormat, | 145 CFX_ByteString& strFormat, |
146 FX_BOOL bStandard); | 146 bool bStandard); |
147 static void GetLocalTimeFormat(CFXJSE_Value* pThis, | 147 static void GetLocalTimeFormat(CFXJSE_Value* pThis, |
148 int32_t iStyle, | 148 int32_t iStyle, |
149 const CFX_ByteStringC& szLocalStr, | 149 const CFX_ByteStringC& szLocalStr, |
150 CFX_ByteString& strFormat, | 150 CFX_ByteString& strFormat, |
151 FX_BOOL bStandard); | 151 bool bStandard); |
152 static void GetStandardDateFormat(CFXJSE_Value* pThis, | 152 static void GetStandardDateFormat(CFXJSE_Value* pThis, |
153 int32_t iStyle, | 153 int32_t iStyle, |
154 const CFX_ByteStringC& szLocalStr, | 154 const CFX_ByteStringC& szLocalStr, |
155 CFX_ByteString& strFormat); | 155 CFX_ByteString& strFormat); |
156 static void GetStandardTimeFormat(CFXJSE_Value* pThis, | 156 static void GetStandardTimeFormat(CFXJSE_Value* pThis, |
157 int32_t iStyle, | 157 int32_t iStyle, |
158 const CFX_ByteStringC& szLocalStr, | 158 const CFX_ByteStringC& szLocalStr, |
159 CFX_ByteString& strFormat); | 159 CFX_ByteString& strFormat); |
160 | 160 |
161 static void Num2AllTime(CFXJSE_Value* pThis, | 161 static void Num2AllTime(CFXJSE_Value* pThis, |
162 int32_t iTime, | 162 int32_t iTime, |
163 const CFX_ByteStringC& szFormat, | 163 const CFX_ByteStringC& szFormat, |
164 const CFX_ByteStringC& szLocale, | 164 const CFX_ByteStringC& szLocale, |
165 FX_BOOL bGM, | 165 bool bGM, |
166 CFX_ByteString& strTime); | 166 CFX_ByteString& strTime); |
167 static void GetLocalTimeZone(int32_t& iHour, int32_t& iMin, int32_t& iSec); | 167 static void GetLocalTimeZone(int32_t& iHour, int32_t& iMin, int32_t& iSec); |
168 | 168 |
169 static void Apr(CFXJSE_Value* pThis, | 169 static void Apr(CFXJSE_Value* pThis, |
170 const CFX_ByteStringC& szFuncName, | 170 const CFX_ByteStringC& szFuncName, |
171 CFXJSE_Arguments& args); | 171 CFXJSE_Arguments& args); |
172 static void CTerm(CFXJSE_Value* pThis, | 172 static void CTerm(CFXJSE_Value* pThis, |
173 const CFX_ByteStringC& szFuncName, | 173 const CFX_ByteStringC& szFuncName, |
174 CFXJSE_Arguments& args); | 174 CFXJSE_Arguments& args); |
175 static void FV(CFXJSE_Value* pThis, | 175 static void FV(CFXJSE_Value* pThis, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 CFX_ByteTextBuf& szResultBuf); | 244 CFX_ByteTextBuf& szResultBuf); |
245 static void Encode(CFXJSE_Value* pThis, | 245 static void Encode(CFXJSE_Value* pThis, |
246 const CFX_ByteStringC& szFuncName, | 246 const CFX_ByteStringC& szFuncName, |
247 CFXJSE_Arguments& args); | 247 CFXJSE_Arguments& args); |
248 static void EncodeURL(const CFX_ByteStringC& szURLString, | 248 static void EncodeURL(const CFX_ByteStringC& szURLString, |
249 CFX_ByteTextBuf& szResultBuf); | 249 CFX_ByteTextBuf& szResultBuf); |
250 static void EncodeHTML(const CFX_ByteStringC& szHTMLString, | 250 static void EncodeHTML(const CFX_ByteStringC& szHTMLString, |
251 CFX_ByteTextBuf& szResultBuf); | 251 CFX_ByteTextBuf& szResultBuf); |
252 static void EncodeXML(const CFX_ByteStringC& szXMLString, | 252 static void EncodeXML(const CFX_ByteStringC& szXMLString, |
253 CFX_ByteTextBuf& szResultBuf); | 253 CFX_ByteTextBuf& szResultBuf); |
254 static FX_BOOL HTMLSTR2Code(const CFX_WideStringC& pData, uint32_t& iCode); | 254 static bool HTMLSTR2Code(const CFX_WideStringC& pData, uint32_t& iCode); |
255 static FX_BOOL HTMLCode2STR(uint32_t iCode, CFX_WideString& wsHTMLReserve); | 255 static bool HTMLCode2STR(uint32_t iCode, CFX_WideString& wsHTMLReserve); |
256 static void Format(CFXJSE_Value* pThis, | 256 static void Format(CFXJSE_Value* pThis, |
257 const CFX_ByteStringC& szFuncName, | 257 const CFX_ByteStringC& szFuncName, |
258 CFXJSE_Arguments& args); | 258 CFXJSE_Arguments& args); |
259 static void Left(CFXJSE_Value* pThis, | 259 static void Left(CFXJSE_Value* pThis, |
260 const CFX_ByteStringC& szFuncName, | 260 const CFX_ByteStringC& szFuncName, |
261 CFXJSE_Arguments& args); | 261 CFXJSE_Arguments& args); |
262 static void Len(CFXJSE_Value* pThis, | 262 static void Len(CFXJSE_Value* pThis, |
263 const CFX_ByteStringC& szFuncName, | 263 const CFX_ByteStringC& szFuncName, |
264 CFXJSE_Arguments& args); | 264 CFXJSE_Arguments& args); |
265 static void Lower(CFXJSE_Value* pThis, | 265 static void Lower(CFXJSE_Value* pThis, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 CFXJSE_Arguments& args); | 324 CFXJSE_Arguments& args); |
325 static void logical_and_operator(CFXJSE_Value* pThis, | 325 static void logical_and_operator(CFXJSE_Value* pThis, |
326 const CFX_ByteStringC& szFuncName, | 326 const CFX_ByteStringC& szFuncName, |
327 CFXJSE_Arguments& args); | 327 CFXJSE_Arguments& args); |
328 static void equality_operator(CFXJSE_Value* pThis, | 328 static void equality_operator(CFXJSE_Value* pThis, |
329 const CFX_ByteStringC& szFuncName, | 329 const CFX_ByteStringC& szFuncName, |
330 CFXJSE_Arguments& args); | 330 CFXJSE_Arguments& args); |
331 static void notequality_operator(CFXJSE_Value* pThis, | 331 static void notequality_operator(CFXJSE_Value* pThis, |
332 const CFX_ByteStringC& szFuncName, | 332 const CFX_ByteStringC& szFuncName, |
333 CFXJSE_Arguments& args); | 333 CFXJSE_Arguments& args); |
334 static FX_BOOL fm_ref_equal(CFXJSE_Value* pThis, CFXJSE_Arguments& args); | 334 static bool fm_ref_equal(CFXJSE_Value* pThis, CFXJSE_Arguments& args); |
335 static void less_operator(CFXJSE_Value* pThis, | 335 static void less_operator(CFXJSE_Value* pThis, |
336 const CFX_ByteStringC& szFuncName, | 336 const CFX_ByteStringC& szFuncName, |
337 CFXJSE_Arguments& args); | 337 CFXJSE_Arguments& args); |
338 static void lessequal_operator(CFXJSE_Value* pThis, | 338 static void lessequal_operator(CFXJSE_Value* pThis, |
339 const CFX_ByteStringC& szFuncName, | 339 const CFX_ByteStringC& szFuncName, |
340 CFXJSE_Arguments& args); | 340 CFXJSE_Arguments& args); |
341 static void greater_operator(CFXJSE_Value* pThis, | 341 static void greater_operator(CFXJSE_Value* pThis, |
342 const CFX_ByteStringC& szFuncName, | 342 const CFX_ByteStringC& szFuncName, |
343 CFXJSE_Arguments& args); | 343 CFXJSE_Arguments& args); |
344 static void greaterequal_operator(CFXJSE_Value* pThis, | 344 static void greaterequal_operator(CFXJSE_Value* pThis, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 CFXJSE_Arguments& args); | 388 CFXJSE_Arguments& args); |
389 static void fm_var_filter(CFXJSE_Value* pThis, | 389 static void fm_var_filter(CFXJSE_Value* pThis, |
390 const CFX_ByteStringC& szFuncName, | 390 const CFX_ByteStringC& szFuncName, |
391 CFXJSE_Arguments& args); | 391 CFXJSE_Arguments& args); |
392 static void concat_fm_object(CFXJSE_Value* pThis, | 392 static void concat_fm_object(CFXJSE_Value* pThis, |
393 const CFX_ByteStringC& szFuncName, | 393 const CFX_ByteStringC& szFuncName, |
394 CFXJSE_Arguments& args); | 394 CFXJSE_Arguments& args); |
395 | 395 |
396 static int32_t hvalue_get_array_length(CFXJSE_Value* pThis, | 396 static int32_t hvalue_get_array_length(CFXJSE_Value* pThis, |
397 CFXJSE_Value* arg); | 397 CFXJSE_Value* arg); |
398 static FX_BOOL simpleValueCompare(CFXJSE_Value* pThis, | 398 static bool simpleValueCompare(CFXJSE_Value* pThis, |
399 CFXJSE_Value* firstValue, | 399 CFXJSE_Value* firstValue, |
400 CFXJSE_Value* secondValue); | 400 CFXJSE_Value* secondValue); |
401 static void unfoldArgs(CFXJSE_Value* pThis, | 401 static void unfoldArgs(CFXJSE_Value* pThis, |
402 CFXJSE_Arguments& args, | 402 CFXJSE_Arguments& args, |
403 CFXJSE_Value**& resultValues, | 403 CFXJSE_Value**& resultValues, |
404 int32_t& iCount, | 404 int32_t& iCount, |
405 int32_t iStart = 0); | 405 int32_t iStart = 0); |
406 static void GetObjectDefaultValue(CFXJSE_Value* pObjectValue, | 406 static void GetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
407 CFXJSE_Value* pDefaultValue); | 407 CFXJSE_Value* pDefaultValue); |
408 static FX_BOOL SetObjectDefaultValue(CFXJSE_Value* pObjectValue, | 408 static bool SetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
409 CFXJSE_Value* pNewValue); | 409 CFXJSE_Value* pNewValue); |
410 static void GenerateSomExpression(const CFX_ByteStringC& szName, | 410 static void GenerateSomExpression(const CFX_ByteStringC& szName, |
411 int32_t iIndexFlags, | 411 int32_t iIndexFlags, |
412 int32_t iIndexValue, | 412 int32_t iIndexValue, |
413 bool bIsStar, | 413 bool bIsStar, |
414 CFX_ByteString& szSomExp); | 414 CFX_ByteString& szSomExp); |
415 static FX_BOOL GetObjectForName(CFXJSE_Value* pThis, | 415 static bool GetObjectForName(CFXJSE_Value* pThis, |
416 CFXJSE_Value* accessorValue, | 416 CFXJSE_Value* accessorValue, |
417 const CFX_ByteStringC& szAccessorName); | 417 const CFX_ByteStringC& szAccessorName); |
418 static int32_t ResolveObjects(CFXJSE_Value* pThis, | 418 static int32_t ResolveObjects(CFXJSE_Value* pThis, |
419 CFXJSE_Value* pParentValue, | 419 CFXJSE_Value* pParentValue, |
420 const CFX_ByteStringC& bsSomExp, | 420 const CFX_ByteStringC& bsSomExp, |
421 XFA_RESOLVENODE_RS& resoveNodeRS, | 421 XFA_RESOLVENODE_RS& resoveNodeRS, |
422 FX_BOOL bdotAccessor = TRUE, | 422 bool bdotAccessor = true, |
423 FX_BOOL bHasNoResolveName = FALSE); | 423 bool bHasNoResolveName = false); |
424 static void ParseResolveResult(CFXJSE_Value* pThis, | 424 static void ParseResolveResult(CFXJSE_Value* pThis, |
425 const XFA_RESOLVENODE_RS& resoveNodeRS, | 425 const XFA_RESOLVENODE_RS& resoveNodeRS, |
426 CFXJSE_Value* pParentValue, | 426 CFXJSE_Value* pParentValue, |
427 CFXJSE_Value**& resultValues, | 427 CFXJSE_Value**& resultValues, |
428 int32_t& iSize, | 428 int32_t& iSize, |
429 FX_BOOL& bAttribute); | 429 bool& bAttribute); |
430 | 430 |
431 static std::unique_ptr<CFXJSE_Value> GetSimpleValue(CFXJSE_Value* pThis, | 431 static std::unique_ptr<CFXJSE_Value> GetSimpleValue(CFXJSE_Value* pThis, |
432 CFXJSE_Arguments& args, | 432 CFXJSE_Arguments& args, |
433 uint32_t index); | 433 uint32_t index); |
434 static FX_BOOL ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* pValue); | 434 static bool ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* pValue); |
435 static int32_t ValueToInteger(CFXJSE_Value* pThis, CFXJSE_Value* pValue); | 435 static int32_t ValueToInteger(CFXJSE_Value* pThis, CFXJSE_Value* pValue); |
436 static FX_FLOAT ValueToFloat(CFXJSE_Value* pThis, CFXJSE_Value* pValue); | 436 static FX_FLOAT ValueToFloat(CFXJSE_Value* pThis, CFXJSE_Value* pValue); |
437 static FX_DOUBLE ValueToDouble(CFXJSE_Value* pThis, CFXJSE_Value* pValue); | 437 static FX_DOUBLE ValueToDouble(CFXJSE_Value* pThis, CFXJSE_Value* pValue); |
438 static void ValueToUTF8String(CFXJSE_Value* pValue, | 438 static void ValueToUTF8String(CFXJSE_Value* pValue, |
439 CFX_ByteString& outputValue); | 439 CFX_ByteString& outputValue); |
440 static double ExtractDouble(CFXJSE_Value* pThis, | 440 static double ExtractDouble(CFXJSE_Value* pThis, |
441 CFXJSE_Value* src, | 441 CFXJSE_Value* src, |
442 bool* ret); | 442 bool* ret); |
443 | 443 |
444 static int32_t Translate(const CFX_WideStringC& wsFormcalc, | 444 static int32_t Translate(const CFX_WideStringC& wsFormcalc, |
445 CFX_WideTextBuf& wsJavascript, | 445 CFX_WideTextBuf& wsJavascript, |
446 CFX_WideString& wsError); | 446 CFX_WideString& wsError); |
447 | 447 |
448 void GlobalPropertyGetter(CFXJSE_Value* pValue); | 448 void GlobalPropertyGetter(CFXJSE_Value* pValue); |
449 | 449 |
450 private: | 450 private: |
451 v8::Isolate* GetScriptRuntime() const { return m_pIsolate; } | 451 v8::Isolate* GetScriptRuntime() const { return m_pIsolate; } |
452 CXFA_Document* GetDocument() const { return m_pDocument; } | 452 CXFA_Document* GetDocument() const { return m_pDocument; } |
453 void ThrowException(int32_t iStringID, ...); | 453 void ThrowException(int32_t iStringID, ...); |
454 | 454 |
455 v8::Isolate* m_pIsolate; | 455 v8::Isolate* m_pIsolate; |
456 CFXJSE_Class* m_pFMClass; | 456 CFXJSE_Class* m_pFMClass; |
457 std::unique_ptr<CFXJSE_Value> m_pValue; | 457 std::unique_ptr<CFXJSE_Value> m_pValue; |
458 CXFA_Document* const m_pDocument; | 458 CXFA_Document* const m_pDocument; |
459 }; | 459 }; |
460 | 460 |
461 #endif // XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ | 461 #endif // XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ |
OLD | NEW |