diff options
author | John Abd-El-Malek <jabdelmalek@google.com> | 2014-05-17 22:33:34 -0700 |
---|---|---|
committer | John Abd-El-Malek <jabdelmalek@google.com> | 2014-05-17 22:33:34 -0700 |
commit | 5110c4743751145c4ae1934cd1d83bc6c55bb43f (patch) | |
tree | b141608096b73163182764c25b895d3df4b2c182 /fpdfsdk/include/javascript/JS_GlobalData.h | |
parent | 76b563d2feed92ed328afb1f15e3466a9536b11b (diff) | |
download | pdfium-5110c4743751145c4ae1934cd1d83bc6c55bb43f.tar.xz |
Initial commit.
Diffstat (limited to 'fpdfsdk/include/javascript/JS_GlobalData.h')
-rw-r--r-- | fpdfsdk/include/javascript/JS_GlobalData.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/fpdfsdk/include/javascript/JS_GlobalData.h b/fpdfsdk/include/javascript/JS_GlobalData.h new file mode 100644 index 0000000000..97a54024d0 --- /dev/null +++ b/fpdfsdk/include/javascript/JS_GlobalData.h @@ -0,0 +1,97 @@ +// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _JS_GLOBALDATA_H_
+#define _JS_GLOBALDATA_H_
+
+#define JS_GLOBALDATA_TYPE_NUMBER 0
+#define JS_GLOBALDATA_TYPE_BOOLEAN 1
+#define JS_GLOBALDATA_TYPE_STRING 2
+#define JS_GLOBALDATA_TYPE_OBJECT 3
+#define JS_GLOBALDATA_TYPE_NULL 4
+
+class CJS_KeyValue;
+class CJS_GlobalVariableArray;
+class CJS_GlobalData_Element;
+
+class CJS_GlobalVariableArray
+{
+public:
+ CJS_GlobalVariableArray();
+ virtual ~CJS_GlobalVariableArray();
+
+ void Add(CJS_KeyValue* p);
+ int Count() const;
+ CJS_KeyValue* GetAt(int index) const;
+ void Copy(const CJS_GlobalVariableArray& array);
+
+ void Empty();
+
+private:
+ CFX_ArrayTemplate<CJS_KeyValue*> array;
+};
+
+class CJS_KeyValue
+{
+public:
+ CJS_KeyValue(){}
+ virtual ~CJS_KeyValue(){}
+
+ CFX_ByteString sKey;
+ int nType; //0:int 1:bool 2:string 3:obj
+ double dData;
+ bool bData;
+ CFX_ByteString sData;
+ CJS_GlobalVariableArray objData;
+};
+
+class CJS_GlobalData_Element
+{
+public:
+ CJS_GlobalData_Element(){}
+ virtual ~CJS_GlobalData_Element(){}
+
+ CJS_KeyValue data;
+ FX_BOOL bPersistent;
+};
+
+class CJS_GlobalData
+{
+public:
+ CJS_GlobalData(CPDFDoc_Environment* pApp);
+ virtual ~CJS_GlobalData();
+
+public:
+ void SetGlobalVariableNumber(FX_LPCSTR propname, double dData);
+ void SetGlobalVariableBoolean(FX_LPCSTR propname, bool bData);
+ void SetGlobalVariableString(FX_LPCSTR propname, const CFX_ByteString& sData);
+ void SetGlobalVariableObject(FX_LPCSTR propname, const CJS_GlobalVariableArray& array);
+ void SetGlobalVariableNull(FX_LPCSTR propname);
+
+ FX_BOOL SetGlobalVariablePersistent(FX_LPCSTR propname, FX_BOOL bPersistent);
+ FX_BOOL DeleteGlobalVariable(FX_LPCSTR propname);
+
+ FX_INT32 GetSize() const;
+ CJS_GlobalData_Element* GetAt(int index) const;
+
+private:
+ void LoadGlobalPersistentVariables();
+ void SaveGlobalPersisitentVariables();
+
+ CJS_GlobalData_Element* GetGlobalVariable(FX_LPCSTR propname);
+ int FindGlobalVariable(FX_LPCSTR propname);
+
+ void LoadFileBuffer(FX_LPCWSTR sFilePath, FX_LPBYTE& pBuffer, FX_INT32& nLength);
+ void WriteFileBuffer(FX_LPCWSTR sFilePath, FX_LPCSTR pBuffer, FX_INT32 nLength);
+ void MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pData, CFX_BinaryBuf& sData);
+
+private:
+ CFX_ArrayTemplate<CJS_GlobalData_Element*> m_arrayGlobalData;
+ CFX_WideString m_sFilePath;
+ CPDFDoc_Environment* m_pApp;
+};
+
+#endif //_JS_GLOBALDATA_H_
|