From a3254627c664e2b88f48f1d6dd856503ab8742b3 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 30 Oct 2017 20:24:14 +0000 Subject: Rename global data files to match contents This CL renames the files related to Javascript global data to match their file contents. Change-Id: I65a6191968656b5e89c9eb6edb2ea9f9db92875a Reviewed-on: https://pdfium-review.googlesource.com/17090 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fxjs/cjs_globaldata.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 fxjs/cjs_globaldata.h (limited to 'fxjs/cjs_globaldata.h') diff --git a/fxjs/cjs_globaldata.h b/fxjs/cjs_globaldata.h new file mode 100644 index 0000000000..b9a4b2123e --- /dev/null +++ b/fxjs/cjs_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_CJS_GLOBALDATA_H_ +#define FXJS_CJS_GLOBALDATA_H_ + +#include +#include + +#include "core/fxcrt/cfx_binarybuf.h" +#include "fxjs/cjs_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>::iterator; + using const_iterator = + std::vector>::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> m_arrayGlobalData; + WideString m_sFilePath; +}; + +#endif // FXJS_CJS_GLOBALDATA_H_ -- cgit v1.2.3