| 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 #ifndef FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ | 7 #ifndef FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ |
| 8 #define FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ | 8 #define FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 CJS_KeyValue data; | 58 CJS_KeyValue data; |
| 59 FX_BOOL bPersistent; | 59 FX_BOOL bPersistent; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class CJS_GlobalData { | 62 class CJS_GlobalData { |
| 63 public: | 63 public: |
| 64 static CJS_GlobalData* GetRetainedInstance(CPDFDoc_Environment* pApp); | 64 static CJS_GlobalData* GetRetainedInstance(CPDFDoc_Environment* pApp); |
| 65 void Release(); | 65 void Release(); |
| 66 | 66 |
| 67 void SetGlobalVariableNumber(const FX_CHAR* propname, double dData); | 67 void SetGlobalVariableNumber(const CFX_ByteString& propname, double dData); |
| 68 void SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData); | 68 void SetGlobalVariableBoolean(const CFX_ByteString& propname, bool bData); |
| 69 void SetGlobalVariableString(const FX_CHAR* propname, | 69 void SetGlobalVariableString(const CFX_ByteString& propname, |
| 70 const CFX_ByteString& sData); | 70 const CFX_ByteString& sData); |
| 71 void SetGlobalVariableObject(const FX_CHAR* propname, | 71 void SetGlobalVariableObject(const CFX_ByteString& propname, |
| 72 const CJS_GlobalVariableArray& array); | 72 const CJS_GlobalVariableArray& array); |
| 73 void SetGlobalVariableNull(const FX_CHAR* propname); | 73 void SetGlobalVariableNull(const CFX_ByteString& propname); |
| 74 | 74 FX_BOOL SetGlobalVariablePersistent(const CFX_ByteString& propname, |
| 75 FX_BOOL SetGlobalVariablePersistent(const FX_CHAR* propname, | |
| 76 FX_BOOL bPersistent); | 75 FX_BOOL bPersistent); |
| 77 FX_BOOL DeleteGlobalVariable(const FX_CHAR* propname); | 76 FX_BOOL DeleteGlobalVariable(const CFX_ByteString& propname); |
| 78 | 77 |
| 79 int32_t GetSize() const; | 78 int32_t GetSize() const; |
| 80 CJS_GlobalData_Element* GetAt(int index) const; | 79 CJS_GlobalData_Element* GetAt(int index) const; |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 using iterator = | 82 using iterator = |
| 84 std::vector<std::unique_ptr<CJS_GlobalData_Element>>::iterator; | 83 std::vector<std::unique_ptr<CJS_GlobalData_Element>>::iterator; |
| 85 using const_iterator = | 84 using const_iterator = |
| 86 std::vector<std::unique_ptr<CJS_GlobalData_Element>>::const_iterator; | 85 std::vector<std::unique_ptr<CJS_GlobalData_Element>>::const_iterator; |
| 87 | 86 |
| 88 static CJS_GlobalData* g_Instance; | 87 static CJS_GlobalData* g_Instance; |
| 89 | 88 |
| 90 CJS_GlobalData(); | 89 CJS_GlobalData(); |
| 91 ~CJS_GlobalData(); | 90 ~CJS_GlobalData(); |
| 92 | 91 |
| 93 void LoadGlobalPersistentVariables(); | 92 void LoadGlobalPersistentVariables(); |
| 94 void SaveGlobalPersisitentVariables(); | 93 void SaveGlobalPersisitentVariables(); |
| 95 | 94 |
| 96 CJS_GlobalData_Element* GetGlobalVariable(const FX_CHAR* propname); | 95 CJS_GlobalData_Element* GetGlobalVariable(const CFX_ByteString& sPropname); |
| 97 iterator FindGlobalVariable(const FX_CHAR* propname); | 96 iterator FindGlobalVariable(const CFX_ByteString& sPropname); |
| 98 const_iterator FindGlobalVariable(const FX_CHAR* propname) const; | 97 const_iterator FindGlobalVariable(const CFX_ByteString& sPropname) const; |
| 99 | 98 |
| 100 void LoadFileBuffer(const FX_WCHAR* sFilePath, | 99 void LoadFileBuffer(const FX_WCHAR* sFilePath, |
| 101 uint8_t*& pBuffer, | 100 uint8_t*& pBuffer, |
| 102 int32_t& nLength); | 101 int32_t& nLength); |
| 103 void WriteFileBuffer(const FX_WCHAR* sFilePath, | 102 void WriteFileBuffer(const FX_WCHAR* sFilePath, |
| 104 const FX_CHAR* pBuffer, | 103 const FX_CHAR* pBuffer, |
| 105 int32_t nLength); | 104 int32_t nLength); |
| 106 void MakeByteString(const CFX_ByteString& name, | 105 void MakeByteString(const CFX_ByteString& name, |
| 107 CJS_KeyValue* pData, | 106 CJS_KeyValue* pData, |
| 108 CFX_BinaryBuf& sData); | 107 CFX_BinaryBuf& sData); |
| 109 | 108 |
| 110 size_t m_RefCount; | 109 size_t m_RefCount; |
| 111 std::vector<std::unique_ptr<CJS_GlobalData_Element>> m_arrayGlobalData; | 110 std::vector<std::unique_ptr<CJS_GlobalData_Element>> m_arrayGlobalData; |
| 112 CFX_WideString m_sFilePath; | 111 CFX_WideString m_sFilePath; |
| 113 }; | 112 }; |
| 114 | 113 |
| 115 #endif // FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ | 114 #endif // FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ |
| OLD | NEW |