| 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/fxcrt/include/fx_basic.h" | 7 #include "core/fxcrt/include/fx_basic.h" |
| 8 #include "core/fxcrt/include/fx_ext.h" | 8 #include "core/fxcrt/include/fx_ext.h" |
| 9 | 9 |
| 10 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 10 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 11 #include <dirent.h> | 11 #include <dirent.h> |
| 12 #include <sys/types.h> | 12 #include <sys/types.h> |
| 13 #else | 13 #else |
| 14 #include <direct.h> | 14 #include <direct.h> |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 #include <cctype> | 18 #include <cctype> |
| 19 | 19 |
| 20 #ifdef PDF_ENABLE_XFA | |
| 21 CFX_PrivateData::CFX_PrivateData() {} | |
| 22 | |
| 23 CFX_PrivateData::~CFX_PrivateData() { | |
| 24 ClearAll(); | |
| 25 } | |
| 26 void FX_PRIVATEDATA::FreeData() { | |
| 27 if (!m_pData) { | |
| 28 return; | |
| 29 } | |
| 30 if (m_bSelfDestruct) { | |
| 31 delete static_cast<CFX_Deletable*>(m_pData); | |
| 32 } else if (m_pCallback) { | |
| 33 m_pCallback(m_pData); | |
| 34 } | |
| 35 } | |
| 36 void CFX_PrivateData::AddData(void* pModuleId, | |
| 37 void* pData, | |
| 38 PD_CALLBACK_FREEDATA callback, | |
| 39 FX_BOOL bSelfDestruct) { | |
| 40 if (!pModuleId) { | |
| 41 return; | |
| 42 } | |
| 43 FX_PRIVATEDATA* pList = m_DataList.GetData(); | |
| 44 int count = m_DataList.GetSize(); | |
| 45 for (int i = 0; i < count; i++) { | |
| 46 if (pList[i].m_pModuleId == pModuleId) { | |
| 47 pList[i].FreeData(); | |
| 48 pList[i].m_pData = pData; | |
| 49 pList[i].m_pCallback = callback; | |
| 50 return; | |
| 51 } | |
| 52 } | |
| 53 FX_PRIVATEDATA data = {pModuleId, pData, callback, bSelfDestruct}; | |
| 54 m_DataList.Add(data); | |
| 55 } | |
| 56 void CFX_PrivateData::SetPrivateData(void* pModuleId, | |
| 57 void* pData, | |
| 58 PD_CALLBACK_FREEDATA callback) { | |
| 59 AddData(pModuleId, pData, callback, FALSE); | |
| 60 } | |
| 61 void CFX_PrivateData::SetPrivateObj(void* pModuleId, CFX_Deletable* pObj) { | |
| 62 AddData(pModuleId, pObj, NULL, TRUE); | |
| 63 } | |
| 64 FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) { | |
| 65 if (!pModuleId) { | |
| 66 return FALSE; | |
| 67 } | |
| 68 FX_PRIVATEDATA* pList = m_DataList.GetData(); | |
| 69 int count = m_DataList.GetSize(); | |
| 70 for (int i = 0; i < count; i++) { | |
| 71 if (pList[i].m_pModuleId == pModuleId) { | |
| 72 m_DataList.RemoveAt(i); | |
| 73 return TRUE; | |
| 74 } | |
| 75 } | |
| 76 return FALSE; | |
| 77 } | |
| 78 void* CFX_PrivateData::GetPrivateData(void* pModuleId) { | |
| 79 if (!pModuleId) { | |
| 80 return NULL; | |
| 81 } | |
| 82 FX_PRIVATEDATA* pList = m_DataList.GetData(); | |
| 83 int count = m_DataList.GetSize(); | |
| 84 for (int i = 0; i < count; i++) { | |
| 85 if (pList[i].m_pModuleId == pModuleId) { | |
| 86 return pList[i].m_pData; | |
| 87 } | |
| 88 } | |
| 89 return NULL; | |
| 90 } | |
| 91 void CFX_PrivateData::ClearAll() { | |
| 92 FX_PRIVATEDATA* pList = m_DataList.GetData(); | |
| 93 int count = m_DataList.GetSize(); | |
| 94 for (int i = 0; i < count; i++) { | |
| 95 pList[i].FreeData(); | |
| 96 } | |
| 97 m_DataList.RemoveAll(); | |
| 98 } | |
| 99 #endif // PDF_ENABLE_XFA | |
| 100 | |
| 101 void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { | 20 void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { |
| 102 if (strc.Find('.') == -1) { | 21 if (strc.Find('.') == -1) { |
| 103 bInteger = TRUE; | 22 bInteger = TRUE; |
| 104 int cc = 0; | 23 int cc = 0; |
| 105 pdfium::base::CheckedNumeric<int> integer = 0; | 24 pdfium::base::CheckedNumeric<int> integer = 0; |
| 106 FX_STRSIZE len = strc.GetLength(); | 25 FX_STRSIZE len = strc.GetLength(); |
| 107 bool bNegative = false; | 26 bool bNegative = false; |
| 108 if (strc[0] == '+') { | 27 if (strc[0] == '+') { |
| 109 cc++; | 28 cc++; |
| 110 } else if (strc[0] == '-') { | 29 } else if (strc[0] == '-') { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 dstShift -= 8; | 309 dstShift -= 8; |
| 391 result |= *dataPtr++ << dstShift; | 310 result |= *dataPtr++ << dstShift; |
| 392 } | 311 } |
| 393 if (dstShift > 0) { | 312 if (dstShift > 0) { |
| 394 bitShift = 8 - dstShift; | 313 bitShift = 8 - dstShift; |
| 395 bitMask = (1 << dstShift) - 1; | 314 bitMask = (1 << dstShift) - 1; |
| 396 result |= *dataPtr++ >> bitShift & bitMask; | 315 result |= *dataPtr++ >> bitShift & bitMask; |
| 397 } | 316 } |
| 398 return result; | 317 return result; |
| 399 } | 318 } |
| OLD | NEW |