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_INCLUDE_JAVASCRIPT_JS_GLOBALDATA_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_GLOBALDATA_H_ |
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_GLOBALDATA_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_GLOBALDATA_H_ |
9 | 9 |
10 #include "../../../core/include/fxcrt/fx_basic.h" | 10 #include "../../../core/include/fxcrt/fx_basic.h" |
11 | 11 |
12 #define JS_GLOBALDATA_TYPE_NUMBER» » 0 | 12 #define JS_GLOBALDATA_TYPE_NUMBER 0 |
13 #define JS_GLOBALDATA_TYPE_BOOLEAN» » 1 | 13 #define JS_GLOBALDATA_TYPE_BOOLEAN 1 |
14 #define JS_GLOBALDATA_TYPE_STRING» » 2 | 14 #define JS_GLOBALDATA_TYPE_STRING 2 |
15 #define JS_GLOBALDATA_TYPE_OBJECT» » 3 | 15 #define JS_GLOBALDATA_TYPE_OBJECT 3 |
16 #define JS_GLOBALDATA_TYPE_NULL»» » 4 | 16 #define JS_GLOBALDATA_TYPE_NULL 4 |
17 | 17 |
18 class CJS_KeyValue; | 18 class CJS_KeyValue; |
19 class CPDFDoc_Environment; | 19 class CPDFDoc_Environment; |
20 | 20 |
21 class CJS_GlobalVariableArray | 21 class CJS_GlobalVariableArray { |
22 { | 22 public: |
23 public: | 23 CJS_GlobalVariableArray(); |
24 » CJS_GlobalVariableArray(); | 24 virtual ~CJS_GlobalVariableArray(); |
25 » virtual ~CJS_GlobalVariableArray(); | |
26 | 25 |
27 » void» » » Add(CJS_KeyValue* p); | 26 void Add(CJS_KeyValue* p); |
28 » int» » » » Count() const; | 27 int Count() const; |
29 » CJS_KeyValue*» GetAt(int index) const; | 28 CJS_KeyValue* GetAt(int index) const; |
30 » void» » » Copy(const CJS_GlobalVariableArray& array); | 29 void Copy(const CJS_GlobalVariableArray& array); |
31 | 30 |
32 » void» » » Empty(); | 31 void Empty(); |
33 | 32 |
34 private: | 33 private: |
35 » CFX_ArrayTemplate<CJS_KeyValue*> array; | 34 CFX_ArrayTemplate<CJS_KeyValue*> array; |
36 }; | 35 }; |
37 | 36 |
38 class CJS_KeyValue | 37 class CJS_KeyValue { |
39 { | 38 public: |
40 public: | 39 CJS_KeyValue() {} |
41 » CJS_KeyValue(){} | 40 virtual ~CJS_KeyValue() {} |
42 » virtual ~CJS_KeyValue(){} | |
43 | 41 |
44 » CFX_ByteString» » » » » sKey; | 42 CFX_ByteString sKey; |
45 » int» » » » » » » » nType; /
/0:int 1:bool 2:string 3:obj | 43 int nType; // 0:int 1:bool 2:string 3:obj |
46 » double» » » » » » » dData; | 44 double dData; |
47 » bool» » » » » » » bData; | 45 bool bData; |
48 » CFX_ByteString» » » » » sData; | 46 CFX_ByteString sData; |
49 » CJS_GlobalVariableArray»» » objData; | 47 CJS_GlobalVariableArray objData; |
50 }; | 48 }; |
51 | 49 |
52 class CJS_GlobalData_Element | 50 class CJS_GlobalData_Element { |
53 { | 51 public: |
54 public: | 52 CJS_GlobalData_Element() {} |
55 » CJS_GlobalData_Element(){} | 53 virtual ~CJS_GlobalData_Element() {} |
56 » virtual ~CJS_GlobalData_Element(){} | |
57 | 54 |
58 » CJS_KeyValue» » » data; | 55 CJS_KeyValue data; |
59 » FX_BOOL»» » » » bPersistent; | 56 FX_BOOL bPersistent; |
60 }; | 57 }; |
61 | 58 |
62 class CJS_GlobalData | 59 class CJS_GlobalData { |
63 { | 60 public: |
64 public: | 61 CJS_GlobalData(CPDFDoc_Environment* pApp); |
65 » CJS_GlobalData(CPDFDoc_Environment* pApp); | 62 virtual ~CJS_GlobalData(); |
66 » virtual ~CJS_GlobalData(); | |
67 | 63 |
68 public: | 64 public: |
69 » void» » » » » » » » SetGloba
lVariableNumber(const FX_CHAR* propname, double dData); | 65 void SetGlobalVariableNumber(const FX_CHAR* propname, double dData); |
70 » void» » » » » » » » SetGloba
lVariableBoolean(const FX_CHAR* propname, bool bData); | 66 void SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData); |
71 » void» » » » » » » » SetGloba
lVariableString(const FX_CHAR* propname, const CFX_ByteString& sData); | 67 void SetGlobalVariableString(const FX_CHAR* propname, |
72 » void» » » » » » » » SetGloba
lVariableObject(const FX_CHAR* propname, const CJS_GlobalVariableArray& array); | 68 const CFX_ByteString& sData); |
73 » void» » » » » » » » SetGloba
lVariableNull(const FX_CHAR* propname); | 69 void SetGlobalVariableObject(const FX_CHAR* propname, |
| 70 const CJS_GlobalVariableArray& array); |
| 71 void SetGlobalVariableNull(const FX_CHAR* propname); |
74 | 72 |
75 » FX_BOOL»» » » » » » » SetGloba
lVariablePersistent(const FX_CHAR* propname, FX_BOOL bPersistent); | 73 FX_BOOL SetGlobalVariablePersistent(const FX_CHAR* propname, |
76 » FX_BOOL»» » » » » » » DeleteGl
obalVariable(const FX_CHAR* propname); | 74 FX_BOOL bPersistent); |
| 75 FX_BOOL DeleteGlobalVariable(const FX_CHAR* propname); |
77 | 76 |
78 » int32_t»» » » » » » GetSize() const; | 77 int32_t GetSize() const; |
79 » CJS_GlobalData_Element*»» » » GetAt(int index) const; | 78 CJS_GlobalData_Element* GetAt(int index) const; |
80 | 79 |
81 private: | 80 private: |
82 » void» » » » » » » » LoadGlob
alPersistentVariables(); | 81 void LoadGlobalPersistentVariables(); |
83 » void» » » » » » » » SaveGlob
alPersisitentVariables(); | 82 void SaveGlobalPersisitentVariables(); |
84 | 83 |
85 » CJS_GlobalData_Element*»» » » GetGlobalVariable(const
FX_CHAR* propname); | 84 CJS_GlobalData_Element* GetGlobalVariable(const FX_CHAR* propname); |
86 » int» » » » » » » » »
FindGlobalVariable(const FX_CHAR* propname); | 85 int FindGlobalVariable(const FX_CHAR* propname); |
87 | 86 |
88 » void» » » » » » » » LoadFile
Buffer(const FX_WCHAR* sFilePath, uint8_t*& pBuffer, int32_t& nLength); | 87 void LoadFileBuffer(const FX_WCHAR* sFilePath, |
89 » void» » » » » » » » WriteFil
eBuffer(const FX_WCHAR* sFilePath, const FX_CHAR* pBuffer, int32_t nLength); | 88 uint8_t*& pBuffer, |
90 » void» » » » » » » » MakeByte
String(const CFX_ByteString& name, CJS_KeyValue* pData, CFX_BinaryBuf& sData); | 89 int32_t& nLength); |
| 90 void WriteFileBuffer(const FX_WCHAR* sFilePath, |
| 91 const FX_CHAR* pBuffer, |
| 92 int32_t nLength); |
| 93 void MakeByteString(const CFX_ByteString& name, |
| 94 CJS_KeyValue* pData, |
| 95 CFX_BinaryBuf& sData); |
91 | 96 |
92 private: | 97 private: |
93 » CFX_ArrayTemplate<CJS_GlobalData_Element*>» m_arrayGlobalData; | 98 CFX_ArrayTemplate<CJS_GlobalData_Element*> m_arrayGlobalData; |
94 » CFX_WideString» » » » » » » »
m_sFilePath; | 99 CFX_WideString m_sFilePath; |
95 }; | 100 }; |
96 | 101 |
97 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_GLOBALDATA_H_ | 102 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_GLOBALDATA_H_ |
OLD | NEW |