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

Side by Side Diff: fpdfsdk/javascript/PublicMethods.h

Issue 1797423002: Fix CJS_PublicMethods::IsNumber() with unit test and some cleanup (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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
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 #ifndef FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_ 7 #ifndef FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_
8 #define FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_ 8 #define FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "fpdfsdk/javascript/JS_Define.h" 13 #include "fpdfsdk/javascript/JS_Define.h"
14 14
15 class CJS_PublicMethods : public CJS_Object { 15 class CJS_PublicMethods : public CJS_Object {
16 public: 16 public:
17 explicit CJS_PublicMethods(v8::Local<v8::Object> pObject) 17 explicit CJS_PublicMethods(v8::Local<v8::Object> pObject)
18 : CJS_Object(pObject) {} 18 : CJS_Object(pObject) {}
19 ~CJS_PublicMethods() override {} 19 ~CJS_PublicMethods() override {}
20 20
21 public:
22 static FX_BOOL AFNumber_Format(IJS_Context* cc, 21 static FX_BOOL AFNumber_Format(IJS_Context* cc,
23 const std::vector<CJS_Value>& params, 22 const std::vector<CJS_Value>& params,
24 CJS_Value& vRet, 23 CJS_Value& vRet,
25 CFX_WideString& sError); 24 CFX_WideString& sError);
26 static FX_BOOL AFNumber_Keystroke(IJS_Context* cc, 25 static FX_BOOL AFNumber_Keystroke(IJS_Context* cc,
27 const std::vector<CJS_Value>& params, 26 const std::vector<CJS_Value>& params,
28 CJS_Value& vRet, 27 CJS_Value& vRet,
29 CFX_WideString& sError); 28 CFX_WideString& sError);
30 static FX_BOOL AFPercent_Format(IJS_Context* cc, 29 static FX_BOOL AFPercent_Format(IJS_Context* cc,
31 const std::vector<CJS_Value>& params, 30 const std::vector<CJS_Value>& params,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 CFX_WideString& sError); 100 CFX_WideString& sError);
102 static FX_BOOL AFParseDateEx(IJS_Context* cc, 101 static FX_BOOL AFParseDateEx(IJS_Context* cc,
103 const std::vector<CJS_Value>& params, 102 const std::vector<CJS_Value>& params,
104 CJS_Value& vRet, 103 CJS_Value& vRet,
105 CFX_WideString& sError); 104 CFX_WideString& sError);
106 static FX_BOOL AFExtractNums(IJS_Context* cc, 105 static FX_BOOL AFExtractNums(IJS_Context* cc,
107 const std::vector<CJS_Value>& params, 106 const std::vector<CJS_Value>& params,
108 CJS_Value& vRet, 107 CJS_Value& vRet,
109 CFX_WideString& sError); 108 CFX_WideString& sError);
110 109
111 public:
112 JS_STATIC_GLOBAL_FUN(AFNumber_Format); 110 JS_STATIC_GLOBAL_FUN(AFNumber_Format);
113 JS_STATIC_GLOBAL_FUN(AFNumber_Keystroke); 111 JS_STATIC_GLOBAL_FUN(AFNumber_Keystroke);
114 JS_STATIC_GLOBAL_FUN(AFPercent_Format); 112 JS_STATIC_GLOBAL_FUN(AFPercent_Format);
115 JS_STATIC_GLOBAL_FUN(AFPercent_Keystroke); 113 JS_STATIC_GLOBAL_FUN(AFPercent_Keystroke);
116 JS_STATIC_GLOBAL_FUN(AFDate_FormatEx); 114 JS_STATIC_GLOBAL_FUN(AFDate_FormatEx);
117 JS_STATIC_GLOBAL_FUN(AFDate_KeystrokeEx); 115 JS_STATIC_GLOBAL_FUN(AFDate_KeystrokeEx);
118 JS_STATIC_GLOBAL_FUN(AFDate_Format); 116 JS_STATIC_GLOBAL_FUN(AFDate_Format);
119 JS_STATIC_GLOBAL_FUN(AFDate_Keystroke); 117 JS_STATIC_GLOBAL_FUN(AFDate_Keystroke);
120 JS_STATIC_GLOBAL_FUN(AFTime_FormatEx); 118 JS_STATIC_GLOBAL_FUN(AFTime_FormatEx);
121 JS_STATIC_GLOBAL_FUN(AFTime_KeystrokeEx); 119 JS_STATIC_GLOBAL_FUN(AFTime_KeystrokeEx);
122 JS_STATIC_GLOBAL_FUN(AFTime_Format); 120 JS_STATIC_GLOBAL_FUN(AFTime_Format);
123 JS_STATIC_GLOBAL_FUN(AFTime_Keystroke); 121 JS_STATIC_GLOBAL_FUN(AFTime_Keystroke);
124 JS_STATIC_GLOBAL_FUN(AFSpecial_Format); 122 JS_STATIC_GLOBAL_FUN(AFSpecial_Format);
125 JS_STATIC_GLOBAL_FUN(AFSpecial_Keystroke); 123 JS_STATIC_GLOBAL_FUN(AFSpecial_Keystroke);
126 JS_STATIC_GLOBAL_FUN(AFSpecial_KeystrokeEx); 124 JS_STATIC_GLOBAL_FUN(AFSpecial_KeystrokeEx);
127 JS_STATIC_GLOBAL_FUN(AFSimple); 125 JS_STATIC_GLOBAL_FUN(AFSimple);
128 JS_STATIC_GLOBAL_FUN(AFMakeNumber); 126 JS_STATIC_GLOBAL_FUN(AFMakeNumber);
129 JS_STATIC_GLOBAL_FUN(AFSimple_Calculate); 127 JS_STATIC_GLOBAL_FUN(AFSimple_Calculate);
130 JS_STATIC_GLOBAL_FUN(AFRange_Validate); 128 JS_STATIC_GLOBAL_FUN(AFRange_Validate);
131 JS_STATIC_GLOBAL_FUN(AFMergeChange); 129 JS_STATIC_GLOBAL_FUN(AFMergeChange);
132 JS_STATIC_GLOBAL_FUN(AFParseDateEx); 130 JS_STATIC_GLOBAL_FUN(AFParseDateEx);
133 JS_STATIC_GLOBAL_FUN(AFExtractNums); 131 JS_STATIC_GLOBAL_FUN(AFExtractNums);
134 132
135 JS_STATIC_DECLARE_GLOBAL_FUN(); 133 JS_STATIC_DECLARE_GLOBAL_FUN();
136 134
137 public:
138 static int ParseStringInteger(const CFX_WideString& string, 135 static int ParseStringInteger(const CFX_WideString& string,
139 int nStart, 136 int nStart,
140 int& nSkip, 137 int& nSkip,
141 int nMaxStep); 138 int nMaxStep);
142 static CFX_WideString ParseStringString(const CFX_WideString& string, 139 static CFX_WideString ParseStringString(const CFX_WideString& string,
143 int nStart, 140 int nStart,
144 int& nSkip); 141 int& nSkip);
145 static double MakeRegularDate(const CFX_WideString& value, 142 static double MakeRegularDate(const CFX_WideString& value,
146 const CFX_WideString& format, 143 const CFX_WideString& format,
147 bool* bWrongFormat); 144 bool* bWrongFormat);
148 static CFX_WideString MakeFormatDate(double dDate, 145 static CFX_WideString MakeFormatDate(double dDate,
149 const CFX_WideString& format); 146 const CFX_WideString& format);
150 static double ParseNormalDate(const CFX_WideString& value, 147 static double ParseNormalDate(const CFX_WideString& value,
151 bool* bWrongFormat); 148 bool* bWrongFormat);
152 static double MakeInterDate(CFX_WideString strValue); 149 static double MakeInterDate(CFX_WideString strValue);
153 150
154 public:
155 static CFX_WideString StrLTrim(const FX_WCHAR* pStr); 151 static CFX_WideString StrLTrim(const FX_WCHAR* pStr);
156 static CFX_WideString StrRTrim(const FX_WCHAR* pStr); 152 static CFX_WideString StrRTrim(const FX_WCHAR* pStr);
157 static CFX_WideString StrTrim(const FX_WCHAR* pStr); 153 static CFX_WideString StrTrim(const FX_WCHAR* pStr);
158 154
159 static CFX_ByteString StrLTrim(const FX_CHAR* pStr); 155 static CFX_ByteString StrLTrim(const FX_CHAR* pStr);
160 static CFX_ByteString StrRTrim(const FX_CHAR* pStr); 156 static CFX_ByteString StrRTrim(const FX_CHAR* pStr);
161 static CFX_ByteString StrTrim(const FX_CHAR* pStr); 157 static CFX_ByteString StrTrim(const FX_CHAR* pStr);
162 158
163 static FX_BOOL IsNumber(const FX_CHAR* string); 159 static bool IsNumber(const FX_WCHAR* string);
164 static FX_BOOL IsNumber(const FX_WCHAR* string);
165 160
166 static FX_BOOL maskSatisfied(wchar_t c_Change, wchar_t c_Mask); 161 static bool maskSatisfied(wchar_t c_Change, wchar_t c_Mask);
167 static FX_BOOL isReservedMaskChar(wchar_t ch); 162 static bool isReservedMaskChar(wchar_t ch);
168 163
169 static double AF_Simple(const FX_WCHAR* sFuction, 164 static double AF_Simple(const FX_WCHAR* sFuction,
170 double dValue1, 165 double dValue1,
171 double dValue2); 166 double dValue2);
172 static CJS_Array AF_MakeArrayFromList(CJS_Runtime* pRuntime, CJS_Value val); 167 static CJS_Array AF_MakeArrayFromList(CJS_Runtime* pRuntime, CJS_Value val);
173 }; 168 };
174 169
175 #endif // FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_ 170 #endif // FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698