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 "../../../core/include/fdrm/fx_crypt.h" | 7 #include "../../../core/include/fdrm/fx_crypt.h" |
8 #include "../../include/javascript/JavaScript.h" | 8 #include "../../include/javascript/JavaScript.h" |
9 #include "../../include/javascript/IJavaScript.h" | 9 #include "../../include/javascript/IJavaScript.h" |
10 #include "../../include/javascript/JS_GlobalData.h" | 10 #include "../../include/javascript/JS_GlobalData.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 return nRet; | 158 return nRet; |
159 } | 159 } |
160 | 160 |
161 CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable(const FX_CHAR* propnam
e) | 161 CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable(const FX_CHAR* propnam
e) |
162 { | 162 { |
163 ASSERT(propname != NULL); | 163 ASSERT(propname != NULL); |
164 | 164 |
165 int nFind = FindGlobalVariable(propname); | 165 int nFind = FindGlobalVariable(propname); |
166 | |
167 if (nFind >= 0) | 166 if (nFind >= 0) |
168 return m_arrayGlobalData.GetAt(nFind); | 167 return m_arrayGlobalData.GetAt(nFind); |
169 » else | 168 |
170 » » return NULL; | 169 return NULL; |
171 } | 170 } |
172 | 171 |
173 void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname, double dDa
ta) | 172 void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname, double dDa
ta) |
174 { | 173 { |
175 ASSERT(propname != NULL); | 174 ASSERT(propname != NULL); |
| 175 |
176 CFX_ByteString sPropName = propname; | 176 CFX_ByteString sPropName = propname; |
177 | |
178 sPropName.TrimLeft(); | 177 sPropName.TrimLeft(); |
179 sPropName.TrimRight(); | 178 sPropName.TrimRight(); |
180 | 179 » if (sPropName.GetLength() == 0) |
181 » if (sPropName.GetLength() == 0) return; | 180 return; |
182 | 181 |
183 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) | 182 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) |
184 { | 183 { |
185 pData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; | 184 pData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; |
186 pData->data.dData = dData; | 185 pData->data.dData = dData; |
187 } | 186 } |
188 else | 187 else |
189 { | 188 { |
190 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; | 189 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; |
191 pNewData->data.sKey = sPropName; | 190 pNewData->data.sKey = sPropName; |
192 pNewData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; | 191 pNewData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; |
193 pNewData->data.dData = dData; | 192 pNewData->data.dData = dData; |
194 | |
195 m_arrayGlobalData.Add(pNewData); | 193 m_arrayGlobalData.Add(pNewData); |
196 } | 194 } |
197 } | 195 } |
198 | 196 |
199 void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname, bool bDat
a) | 197 void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname, bool bDat
a) |
200 { | 198 { |
201 ASSERT(propname != NULL); | 199 ASSERT(propname != NULL); |
202 CFX_ByteString sPropName = propname; | 200 CFX_ByteString sPropName = propname; |
203 | 201 |
204 sPropName.TrimLeft(); | 202 sPropName.TrimLeft(); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 sData.AppendString(name); | 570 sData.AppendString(name); |
573 | 571 |
574 sData.AppendBlock(&wType, sizeof(FX_DWORD)); | 572 sData.AppendBlock(&wType, sizeof(FX_DWORD)); |
575 } | 573 } |
576 break; | 574 break; |
577 default: | 575 default: |
578 break; | 576 break; |
579 } | 577 } |
580 } | 578 } |
581 | 579 |
OLD | NEW |