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