summaryrefslogtreecommitdiff
path: root/fxjs/JS_GlobalData.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-30 20:20:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-10-30 20:20:42 +0000
commite0345a4aecfd16264d393234cf8fe22250d771fe (patch)
tree046f8e6c074b8525d6cf71daf4f2039582fb572a /fxjs/JS_GlobalData.h
parent341ec6256457c53d50f2d0a0667e61041d4d89be (diff)
downloadpdfium-e0345a4aecfd16264d393234cf8fe22250d771fe.tar.xz
Move fpdfsdk/javascript to fxjs/
This CL moves all of the CJS files into fxjs. The :javascript build rule is removed and :fxjs is used instead. Change-Id: I1701b308f51317d0346c7401b43812c3f43a27bf Reviewed-on: https://pdfium-review.googlesource.com/17047 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/JS_GlobalData.h')
-rw-r--r--fxjs/JS_GlobalData.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/fxjs/JS_GlobalData.h b/fxjs/JS_GlobalData.h
new file mode 100644
index 0000000000..c167d1e4e1
--- /dev/null
+++ b/fxjs/JS_GlobalData.h
@@ -0,0 +1,77 @@
+// 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 FXJS_JS_GLOBALDATA_H_
+#define FXJS_JS_GLOBALDATA_H_
+
+#include <memory>
+#include <vector>
+
+#include "core/fxcrt/cfx_binarybuf.h"
+#include "fxjs/JS_KeyValue.h"
+
+class CPDFSDK_FormFillEnvironment;
+
+class CJS_GlobalData_Element {
+ public:
+ CJS_GlobalData_Element() {}
+ ~CJS_GlobalData_Element() {}
+
+ CJS_KeyValue data;
+ bool bPersistent;
+};
+
+class CJS_GlobalData {
+ public:
+ static CJS_GlobalData* GetRetainedInstance(CPDFSDK_FormFillEnvironment* pApp);
+ void Release();
+
+ void SetGlobalVariableNumber(const ByteString& propname, double dData);
+ void SetGlobalVariableBoolean(const ByteString& propname, bool bData);
+ void SetGlobalVariableString(const ByteString& propname,
+ const ByteString& sData);
+ void SetGlobalVariableObject(const ByteString& propname,
+ const CJS_GlobalVariableArray& array);
+ void SetGlobalVariableNull(const ByteString& propname);
+ bool SetGlobalVariablePersistent(const ByteString& propname,
+ bool bPersistent);
+ bool DeleteGlobalVariable(const ByteString& propname);
+
+ int32_t GetSize() const;
+ CJS_GlobalData_Element* GetAt(int index) const;
+
+ private:
+ using iterator =
+ std::vector<std::unique_ptr<CJS_GlobalData_Element>>::iterator;
+ using const_iterator =
+ std::vector<std::unique_ptr<CJS_GlobalData_Element>>::const_iterator;
+
+ CJS_GlobalData();
+ ~CJS_GlobalData();
+
+ void LoadGlobalPersistentVariables();
+ void SaveGlobalPersisitentVariables();
+
+ CJS_GlobalData_Element* GetGlobalVariable(const ByteString& sPropname);
+ iterator FindGlobalVariable(const ByteString& sPropname);
+ const_iterator FindGlobalVariable(const ByteString& sPropname) const;
+
+ void LoadFileBuffer(const wchar_t* sFilePath,
+ uint8_t*& pBuffer,
+ int32_t& nLength);
+ void WriteFileBuffer(const wchar_t* sFilePath,
+ const char* pBuffer,
+ int32_t nLength);
+ void MakeByteString(const ByteString& name,
+ CJS_KeyValue* pData,
+ CFX_BinaryBuf& sData);
+
+ size_t m_RefCount;
+ std::vector<std::unique_ptr<CJS_GlobalData_Element>> m_arrayGlobalData;
+ WideString m_sFilePath;
+};
+
+#endif // FXJS_JS_GLOBALDATA_H_