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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 else | 289 else |
290 { | 290 { |
291 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; | 291 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; |
292 pNewData->data.sKey = sPropName; | 292 pNewData->data.sKey = sPropName; |
293 pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL; | 293 pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL; |
294 | 294 |
295 m_arrayGlobalData.Add(pNewData); | 295 m_arrayGlobalData.Add(pNewData); |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname, FX_
BOOL bPersistent) | 299 bool CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname, bool b
Persistent) |
300 { | 300 { |
301 ASSERT(propname != NULL); | 301 ASSERT(propname != NULL); |
302 CFX_ByteString sPropName = propname; | 302 CFX_ByteString sPropName = propname; |
303 | 303 |
304 sPropName.TrimLeft(); | 304 sPropName.TrimLeft(); |
305 sPropName.TrimRight(); | 305 sPropName.TrimRight(); |
306 | 306 |
307 if (sPropName.GetLength() == 0) return FALSE; | 307 if (sPropName.GetLength() == 0) return false; |
308 | 308 |
309 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) | 309 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) |
310 { | 310 { |
311 pData->bPersistent = bPersistent; | 311 pData->bPersistent = bPersistent; |
312 return TRUE; | 312 return true; |
313 } | 313 } |
314 | 314 |
315 return FALSE; | 315 return false; |
316 } | 316 } |
317 | 317 |
318 FX_BOOL CJS_GlobalData::DeleteGlobalVariable(const FX_CHAR* propname) | 318 bool CJS_GlobalData::DeleteGlobalVariable(const FX_CHAR* propname) |
319 { | 319 { |
320 ASSERT(propname != NULL); | 320 ASSERT(propname != NULL); |
321 CFX_ByteString sPropName = propname; | 321 CFX_ByteString sPropName = propname; |
322 | 322 |
323 sPropName.TrimLeft(); | 323 sPropName.TrimLeft(); |
324 sPropName.TrimRight(); | 324 sPropName.TrimRight(); |
325 | 325 |
326 if (sPropName.GetLength() == 0) return FALSE; | 326 if (sPropName.GetLength() == 0) return false; |
327 | 327 |
328 int nFind = FindGlobalVariable(sPropName); | 328 int nFind = FindGlobalVariable(sPropName); |
329 | 329 |
330 if (nFind >= 0) | 330 if (nFind >= 0) |
331 { | 331 { |
332 delete m_arrayGlobalData.GetAt(nFind); | 332 delete m_arrayGlobalData.GetAt(nFind); |
333 m_arrayGlobalData.RemoveAt(nFind); | 333 m_arrayGlobalData.RemoveAt(nFind); |
334 return TRUE; | 334 return true; |
335 } | 335 } |
336 | 336 |
337 return FALSE; | 337 return false; |
338 } | 338 } |
339 | 339 |
340 int32_t CJS_GlobalData::GetSize() const | 340 int32_t CJS_GlobalData::GetSize() const |
341 { | 341 { |
342 return m_arrayGlobalData.GetSize(); | 342 return m_arrayGlobalData.GetSize(); |
343 } | 343 } |
344 | 344 |
345 CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const | 345 CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const |
346 { | 346 { |
347 return m_arrayGlobalData.GetAt(index); | 347 return m_arrayGlobalData.GetAt(index); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 410 } |
411 break; | 411 break; |
412 case 2: | 412 case 2: |
413 { | 413 { |
414 dData = *((double*)p); | 414 dData = *((double*)p); |
415 p += sizeof(double); | 415 p += sizeof(double); |
416 } | 416 } |
417 break; | 417 break; |
418 } | 418 } |
419 SetGlobalVariableNumber(sEntry, dData); | 419 SetGlobalVariableNumber(sEntry, dData); |
420 SetGlobalVariablePersistent(sEntry, TRUE); | 420 SetGlobalVariablePersistent(sEntry, true); |
421 } | 421 } |
422 break; | 422 break; |
423 case JS_GLOBALDATA_TYPE_BOOLEAN: | 423 case JS_GLOBALDATA_TYPE_BOOLEAN: |
424 { | 424 { |
425 FX_WORD wData = *((FX_WORD*)p); | 425 FX_WORD wData = *((FX_WORD*)p); |
426 p += sizeof(FX_WORD); | 426 p += sizeof(FX_WORD); |
427 SetGlobalVariableBoolean(sEntry, (bool)(wData == 1))
; | 427 SetGlobalVariableBoolean(sEntry, (bool)(wData == 1))
; |
428 SetGlobalVariablePersistent(sEntry, TRUE); | 428 SetGlobalVariablePersistent(sEntry, true); |
429 } | 429 } |
430 break; | 430 break; |
431 case JS_GLOBALDATA_TYPE_STRING: | 431 case JS_GLOBALDATA_TYPE_STRING: |
432 { | 432 { |
433 FX_DWORD dwLength = *((FX_DWORD*)p); | 433 FX_DWORD dwLength = *((FX_DWORD*)p); |
434 p += sizeof(FX_DWORD); | 434 p += sizeof(FX_DWORD); |
435 | 435 |
436 if (p + dwLength > pBuffer + nLength) | 436 if (p + dwLength > pBuffer + nLength) |
437 break; | 437 break; |
438 | 438 |
439 SetGlobalVariableString(sEntry, CFX_ByteString(p, dw
Length)); | 439 SetGlobalVariableString(sEntry, CFX_ByteString(p, dw
Length)); |
440 SetGlobalVariablePersistent(sEntry, TRUE); | 440 SetGlobalVariablePersistent(sEntry, true); |
441 p += sizeof(char) * dwLength; | 441 p += sizeof(char) * dwLength; |
442 } | 442 } |
443 break; | 443 break; |
444 case JS_GLOBALDATA_TYPE_NULL: | 444 case JS_GLOBALDATA_TYPE_NULL: |
445 { | 445 { |
446 SetGlobalVariableNull(sEntry); | 446 SetGlobalVariableNull(sEntry); |
447 SetGlobalVariablePersistent(sEntry, TRUE); | 447 SetGlobalVariablePersistent(sEntry, true); |
448 } | 448 } |
449 } | 449 } |
450 } | 450 } |
451 } | 451 } |
452 } | 452 } |
453 FX_Free(pBuffer); | 453 FX_Free(pBuffer); |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 /* | 457 /* |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD)); | 565 sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD)); |
566 sData.AppendString(name); | 566 sData.AppendString(name); |
567 sData.AppendBlock(&wType, sizeof(FX_DWORD)); | 567 sData.AppendBlock(&wType, sizeof(FX_DWORD)); |
568 } | 568 } |
569 break; | 569 break; |
570 default: | 570 default: |
571 break; | 571 break; |
572 } | 572 } |
573 } | 573 } |
574 | 574 |
OLD | NEW |