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 --- BUILD.gn | 10 +- fxjs/JS_GlobalData.cpp | 397 --------------------------------------- fxjs/JS_GlobalData.h | 77 -------- fxjs/JS_KeyValue.cpp | 70 ------- fxjs/JS_KeyValue.h | 46 ----- fxjs/cjs_global.cpp | 4 +- fxjs/cjs_globaldata.cpp | 397 +++++++++++++++++++++++++++++++++++++++ fxjs/cjs_globaldata.h | 77 ++++++++ fxjs/cjs_globalvariablearray.cpp | 68 +++++++ fxjs/cjs_globalvariablearray.h | 29 +++ fxjs/cjs_keyvalue.cpp | 11 ++ fxjs/cjs_keyvalue.h | 28 +++ fxjs/cjs_runtime.cpp | 2 +- 13 files changed, 619 insertions(+), 597 deletions(-) delete mode 100644 fxjs/JS_GlobalData.cpp delete mode 100644 fxjs/JS_GlobalData.h delete mode 100644 fxjs/JS_KeyValue.cpp delete mode 100644 fxjs/JS_KeyValue.h create mode 100644 fxjs/cjs_globaldata.cpp create mode 100644 fxjs/cjs_globaldata.h create mode 100644 fxjs/cjs_globalvariablearray.cpp create mode 100644 fxjs/cjs_globalvariablearray.h create mode 100644 fxjs/cjs_keyvalue.cpp create mode 100644 fxjs/cjs_keyvalue.h diff --git a/BUILD.gn b/BUILD.gn index e49b0d0156..20e0d88b07 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1190,10 +1190,6 @@ static_library("fxjs") { sources += [ "fxjs/JS_Define.cpp", "fxjs/JS_Define.h", - "fxjs/JS_GlobalData.cpp", - "fxjs/JS_GlobalData.h", - "fxjs/JS_KeyValue.cpp", - "fxjs/JS_KeyValue.h", "fxjs/cjs_annot.cpp", "fxjs/cjs_annot.h", "fxjs/cjs_app.cpp", @@ -1228,10 +1224,16 @@ static_library("fxjs") { "fxjs/cjs_globalarrays.h", "fxjs/cjs_globalconsts.cpp", "fxjs/cjs_globalconsts.h", + "fxjs/cjs_globaldata.cpp", + "fxjs/cjs_globaldata.h", + "fxjs/cjs_globalvariablearray.cpp", + "fxjs/cjs_globalvariablearray.h", "fxjs/cjs_highlight.cpp", "fxjs/cjs_highlight.h", "fxjs/cjs_icon.cpp", "fxjs/cjs_icon.h", + "fxjs/cjs_keyvalue.cpp", + "fxjs/cjs_keyvalue.h", "fxjs/cjs_object.cpp", "fxjs/cjs_object.h", "fxjs/cjs_position.cpp", diff --git a/fxjs/JS_GlobalData.cpp b/fxjs/JS_GlobalData.cpp deleted file mode 100644 index 78e19c9482..0000000000 --- a/fxjs/JS_GlobalData.cpp +++ /dev/null @@ -1,397 +0,0 @@ -// 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 - -#include "fxjs/JS_GlobalData.h" - -#include - -#include "core/fdrm/crypto/fx_crypt.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" - -#define JS_MAXGLOBALDATA (1024 * 4 - 8) - -#define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data" -#define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data" -#define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data" - -namespace { - -const uint8_t JS_RC4KEY[] = { - 0x19, 0xa8, 0xe8, 0x01, 0xf6, 0xa8, 0xb6, 0x4d, 0x82, 0x04, 0x45, 0x6d, - 0xb4, 0xcf, 0xd7, 0x77, 0x67, 0xf9, 0x75, 0x9f, 0xf0, 0xe0, 0x1e, 0x51, - 0xee, 0x46, 0xfd, 0x0b, 0xc9, 0x93, 0x25, 0x55, 0x4a, 0xee, 0xe0, 0x16, - 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22, - 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b, - 0x04, 0x75, 0x89, 0xc9, 0xb1, 0xed, 0x50, 0xca, 0x96, 0x6f, 0x1a, 0x7a, - 0xfe, 0x58, 0x5d, 0xec, 0x19, 0x4a, 0xf6, 0x35, 0x6a, 0x97, 0x14, 0x00, - 0x0e, 0xd0, 0x6b, 0xbb, 0xd5, 0x75, 0x55, 0x8b, 0x6e, 0x6b, 0x19, 0xa0, - 0xf8, 0x77, 0xd5, 0xa3}; - -// Returns true if non-empty, setting sPropName -bool TrimPropName(ByteString* sPropName) { - sPropName->TrimLeft(); - sPropName->TrimRight(); - return sPropName->GetLength() != 0; -} - -CJS_GlobalData* g_pInstance = nullptr; - -} // namespace - -// static -CJS_GlobalData* CJS_GlobalData::GetRetainedInstance( - CPDFSDK_FormFillEnvironment* pApp) { - if (!g_pInstance) { - g_pInstance = new CJS_GlobalData(); - } - ++g_pInstance->m_RefCount; - return g_pInstance; -} - -void CJS_GlobalData::Release() { - if (!--m_RefCount) { - delete g_pInstance; - g_pInstance = nullptr; - } -} - -CJS_GlobalData::CJS_GlobalData() - : m_RefCount(0), m_sFilePath(SDK_JS_GLOBALDATA_FILENAME) { - LoadGlobalPersistentVariables(); -} - -CJS_GlobalData::~CJS_GlobalData() { - SaveGlobalPersisitentVariables(); -} - -CJS_GlobalData::iterator CJS_GlobalData::FindGlobalVariable( - const ByteString& propname) { - for (auto it = m_arrayGlobalData.begin(); it != m_arrayGlobalData.end(); - ++it) { - if ((*it)->data.sKey == propname) - return it; - } - return m_arrayGlobalData.end(); -} - -CJS_GlobalData::const_iterator CJS_GlobalData::FindGlobalVariable( - const ByteString& propname) const { - for (auto it = m_arrayGlobalData.begin(); it != m_arrayGlobalData.end(); - ++it) { - if ((*it)->data.sKey == propname) - return it; - } - return m_arrayGlobalData.end(); -} - -CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable( - const ByteString& propname) { - auto iter = FindGlobalVariable(propname); - return iter != m_arrayGlobalData.end() ? iter->get() : nullptr; -} - -void CJS_GlobalData::SetGlobalVariableNumber(const ByteString& propname, - double dData) { - ByteString sPropName(propname); - if (!TrimPropName(&sPropName)) - return; - - if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { - pData->data.nType = JS_GlobalDataType::NUMBER; - pData->data.dData = dData; - return; - } - auto pNewData = pdfium::MakeUnique(); - pNewData->data.sKey = sPropName; - pNewData->data.nType = JS_GlobalDataType::NUMBER; - pNewData->data.dData = dData; - m_arrayGlobalData.push_back(std::move(pNewData)); -} - -void CJS_GlobalData::SetGlobalVariableBoolean(const ByteString& propname, - bool bData) { - ByteString sPropName(propname); - if (!TrimPropName(&sPropName)) - return; - - if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { - pData->data.nType = JS_GlobalDataType::BOOLEAN; - pData->data.bData = bData; - return; - } - auto pNewData = pdfium::MakeUnique(); - pNewData->data.sKey = sPropName; - pNewData->data.nType = JS_GlobalDataType::BOOLEAN; - pNewData->data.bData = bData; - m_arrayGlobalData.push_back(std::move(pNewData)); -} - -void CJS_GlobalData::SetGlobalVariableString(const ByteString& propname, - const ByteString& sData) { - ByteString sPropName(propname); - if (!TrimPropName(&sPropName)) - return; - - if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { - pData->data.nType = JS_GlobalDataType::STRING; - pData->data.sData = sData; - return; - } - auto pNewData = pdfium::MakeUnique(); - pNewData->data.sKey = sPropName; - pNewData->data.nType = JS_GlobalDataType::STRING; - pNewData->data.sData = sData; - m_arrayGlobalData.push_back(std::move(pNewData)); -} - -void CJS_GlobalData::SetGlobalVariableObject( - const ByteString& propname, - const CJS_GlobalVariableArray& array) { - ByteString sPropName(propname); - if (!TrimPropName(&sPropName)) - return; - - if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { - pData->data.nType = JS_GlobalDataType::OBJECT; - pData->data.objData.Copy(array); - return; - } - auto pNewData = pdfium::MakeUnique(); - pNewData->data.sKey = sPropName; - pNewData->data.nType = JS_GlobalDataType::OBJECT; - pNewData->data.objData.Copy(array); - m_arrayGlobalData.push_back(std::move(pNewData)); -} - -void CJS_GlobalData::SetGlobalVariableNull(const ByteString& propname) { - ByteString sPropName(propname); - if (!TrimPropName(&sPropName)) - return; - - if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { - pData->data.nType = JS_GlobalDataType::NULLOBJ; - return; - } - auto pNewData = pdfium::MakeUnique(); - pNewData->data.sKey = sPropName; - pNewData->data.nType = JS_GlobalDataType::NULLOBJ; - m_arrayGlobalData.push_back(std::move(pNewData)); -} - -bool CJS_GlobalData::SetGlobalVariablePersistent(const ByteString& propname, - bool bPersistent) { - ByteString sPropName(propname); - if (!TrimPropName(&sPropName)) - return false; - - CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName); - if (!pData) - return false; - - pData->bPersistent = bPersistent; - return true; -} - -bool CJS_GlobalData::DeleteGlobalVariable(const ByteString& propname) { - ByteString sPropName(propname); - if (!TrimPropName(&sPropName)) - return false; - - auto iter = FindGlobalVariable(sPropName); - if (iter == m_arrayGlobalData.end()) - return false; - - m_arrayGlobalData.erase(iter); - return true; -} - -int32_t CJS_GlobalData::GetSize() const { - return pdfium::CollectionSize(m_arrayGlobalData); -} - -CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const { - if (index < 0 || index >= GetSize()) - return nullptr; - return m_arrayGlobalData[index].get(); -} - -void CJS_GlobalData::LoadGlobalPersistentVariables() { - uint8_t* pBuffer = nullptr; - int32_t nLength = 0; - - LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength); - CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY)); - - if (pBuffer) { - uint8_t* p = pBuffer; - uint16_t wType = *((uint16_t*)p); - p += sizeof(uint16_t); - - if (wType == (uint16_t)(('X' << 8) | 'F')) { - uint16_t wVersion = *((uint16_t*)p); - p += sizeof(uint16_t); - - ASSERT(wVersion <= 2); - - uint32_t dwCount = *((uint32_t*)p); - p += sizeof(uint32_t); - - uint32_t dwSize = *((uint32_t*)p); - p += sizeof(uint32_t); - - if (dwSize == nLength - sizeof(uint16_t) * 2 - sizeof(uint32_t) * 2) { - for (int32_t i = 0, sz = dwCount; i < sz; i++) { - if (p > pBuffer + nLength) - break; - - uint32_t dwNameLen = *((uint32_t*)p); - p += sizeof(uint32_t); - - if (p + dwNameLen > pBuffer + nLength) - break; - - ByteString sEntry = ByteString(p, dwNameLen); - p += sizeof(char) * dwNameLen; - - JS_GlobalDataType wDataType = - static_cast(*((uint16_t*)p)); - p += sizeof(uint16_t); - - switch (wDataType) { - case JS_GlobalDataType::NUMBER: { - double dData = 0; - switch (wVersion) { - case 1: { - uint32_t dwData = *((uint32_t*)p); - p += sizeof(uint32_t); - dData = dwData; - } break; - case 2: { - dData = *((double*)p); - p += sizeof(double); - } break; - } - SetGlobalVariableNumber(sEntry, dData); - SetGlobalVariablePersistent(sEntry, true); - } break; - case JS_GlobalDataType::BOOLEAN: { - uint16_t wData = *((uint16_t*)p); - p += sizeof(uint16_t); - SetGlobalVariableBoolean(sEntry, (bool)(wData == 1)); - SetGlobalVariablePersistent(sEntry, true); - } break; - case JS_GlobalDataType::STRING: { - uint32_t dwLength = *((uint32_t*)p); - p += sizeof(uint32_t); - - if (p + dwLength > pBuffer + nLength) - break; - - SetGlobalVariableString(sEntry, ByteString(p, dwLength)); - SetGlobalVariablePersistent(sEntry, true); - p += sizeof(char) * dwLength; - } break; - case JS_GlobalDataType::NULLOBJ: { - SetGlobalVariableNull(sEntry); - SetGlobalVariablePersistent(sEntry, true); - } - case JS_GlobalDataType::OBJECT: - break; - } - } - } - } - FX_Free(pBuffer); - } -} - -void CJS_GlobalData::SaveGlobalPersisitentVariables() { - uint32_t nCount = 0; - CFX_BinaryBuf sData; - for (const auto& pElement : m_arrayGlobalData) { - if (pElement->bPersistent) { - CFX_BinaryBuf sElement; - MakeByteString(pElement->data.sKey, &pElement->data, sElement); - if (sData.GetSize() + sElement.GetSize() > JS_MAXGLOBALDATA) - break; - - sData.AppendBlock(sElement.GetBuffer(), sElement.GetSize()); - nCount++; - } - } - - CFX_BinaryBuf sFile; - uint16_t wType = (uint16_t)(('X' << 8) | 'F'); - sFile.AppendBlock(&wType, sizeof(uint16_t)); - uint16_t wVersion = 2; - sFile.AppendBlock(&wVersion, sizeof(uint16_t)); - sFile.AppendBlock(&nCount, sizeof(uint32_t)); - uint32_t dwSize = sData.GetSize(); - sFile.AppendBlock(&dwSize, sizeof(uint32_t)); - - sFile.AppendBlock(sData.GetBuffer(), sData.GetSize()); - - CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, - sizeof(JS_RC4KEY)); - WriteFileBuffer(m_sFilePath.c_str(), (const char*)sFile.GetBuffer(), - sFile.GetSize()); -} - -void CJS_GlobalData::LoadFileBuffer(const wchar_t* sFilePath, - uint8_t*& pBuffer, - int32_t& nLength) { - // UnSupport. -} - -void CJS_GlobalData::WriteFileBuffer(const wchar_t* sFilePath, - const char* pBuffer, - int32_t nLength) { - // UnSupport. -} - -void CJS_GlobalData::MakeByteString(const ByteString& name, - CJS_KeyValue* pData, - CFX_BinaryBuf& sData) { - switch (pData->nType) { - case JS_GlobalDataType::NUMBER: { - uint32_t dwNameLen = (uint32_t)name.GetLength(); - sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); - sData.AppendString(name); - sData.AppendBlock(&pData->nType, sizeof(uint16_t)); - - double dData = pData->dData; - sData.AppendBlock(&dData, sizeof(double)); - } break; - case JS_GlobalDataType::BOOLEAN: { - uint32_t dwNameLen = (uint32_t)name.GetLength(); - sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); - sData.AppendString(name); - sData.AppendBlock(&pData->nType, sizeof(uint16_t)); - - uint16_t wData = (uint16_t)pData->bData; - sData.AppendBlock(&wData, sizeof(uint16_t)); - } break; - case JS_GlobalDataType::STRING: { - uint32_t dwNameLen = (uint32_t)name.GetLength(); - sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); - sData.AppendString(name); - sData.AppendBlock(&pData->nType, sizeof(uint16_t)); - - uint32_t dwDataLen = (uint32_t)pData->sData.GetLength(); - sData.AppendBlock(&dwDataLen, sizeof(uint32_t)); - sData.AppendString(pData->sData); - } break; - case JS_GlobalDataType::NULLOBJ: { - uint32_t dwNameLen = (uint32_t)name.GetLength(); - sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); - sData.AppendString(name); - sData.AppendBlock(&pData->nType, sizeof(uint32_t)); - } break; - default: - break; - } -} diff --git a/fxjs/JS_GlobalData.h b/fxjs/JS_GlobalData.h deleted file mode 100644 index c167d1e4e1..0000000000 --- a/fxjs/JS_GlobalData.h +++ /dev/null @@ -1,77 +0,0 @@ -// 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 -#include - -#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>::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_JS_GLOBALDATA_H_ diff --git a/fxjs/JS_KeyValue.cpp b/fxjs/JS_KeyValue.cpp deleted file mode 100644 index aabfc38c76..0000000000 --- a/fxjs/JS_KeyValue.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 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 - -#include "fxjs/JS_KeyValue.h" - -CJS_GlobalVariableArray::CJS_GlobalVariableArray() {} - -CJS_GlobalVariableArray::~CJS_GlobalVariableArray() {} - -void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) { - m_Array.clear(); - for (int i = 0, sz = array.Count(); i < sz; i++) { - CJS_KeyValue* pOldObjData = array.GetAt(i); - switch (pOldObjData->nType) { - case JS_GlobalDataType::NUMBER: { - CJS_KeyValue* pNewObjData = new CJS_KeyValue; - pNewObjData->sKey = pOldObjData->sKey; - pNewObjData->nType = pOldObjData->nType; - pNewObjData->dData = pOldObjData->dData; - Add(pNewObjData); - } break; - case JS_GlobalDataType::BOOLEAN: { - CJS_KeyValue* pNewObjData = new CJS_KeyValue; - pNewObjData->sKey = pOldObjData->sKey; - pNewObjData->nType = pOldObjData->nType; - pNewObjData->bData = pOldObjData->bData; - Add(pNewObjData); - } break; - case JS_GlobalDataType::STRING: { - CJS_KeyValue* pNewObjData = new CJS_KeyValue; - pNewObjData->sKey = pOldObjData->sKey; - pNewObjData->nType = pOldObjData->nType; - pNewObjData->sData = pOldObjData->sData; - Add(pNewObjData); - } break; - case JS_GlobalDataType::OBJECT: { - CJS_KeyValue* pNewObjData = new CJS_KeyValue; - pNewObjData->sKey = pOldObjData->sKey; - pNewObjData->nType = pOldObjData->nType; - pNewObjData->objData.Copy(pOldObjData->objData); - Add(pNewObjData); - } break; - case JS_GlobalDataType::NULLOBJ: { - CJS_KeyValue* pNewObjData = new CJS_KeyValue; - pNewObjData->sKey = pOldObjData->sKey; - pNewObjData->nType = pOldObjData->nType; - Add(pNewObjData); - } break; - } - } -} - -void CJS_GlobalVariableArray::Add(CJS_KeyValue* p) { - m_Array.push_back(std::unique_ptr(p)); -} - -int CJS_GlobalVariableArray::Count() const { - return m_Array.size(); -} - -CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const { - return m_Array.at(index).get(); -} - -CJS_KeyValue::CJS_KeyValue() {} - -CJS_KeyValue::~CJS_KeyValue() {} diff --git a/fxjs/JS_KeyValue.h b/fxjs/JS_KeyValue.h deleted file mode 100644 index a81a6b432e..0000000000 --- a/fxjs/JS_KeyValue.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 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_KEYVALUE_H_ -#define FXJS_JS_KEYVALUE_H_ - -#include -#include - -#include "core/fxcrt/fx_string.h" - -enum class JS_GlobalDataType { NUMBER = 0, BOOLEAN, STRING, OBJECT, NULLOBJ }; - -class CJS_KeyValue; - -class CJS_GlobalVariableArray { - public: - CJS_GlobalVariableArray(); - ~CJS_GlobalVariableArray(); - - void Add(CJS_KeyValue* p); - int Count() const; - CJS_KeyValue* GetAt(int index) const; - void Copy(const CJS_GlobalVariableArray& array); - - private: - std::vector> m_Array; -}; - -class CJS_KeyValue { - public: - CJS_KeyValue(); - ~CJS_KeyValue(); - - ByteString sKey; - JS_GlobalDataType nType; - double dData; - bool bData; - ByteString sData; - CJS_GlobalVariableArray objData; -}; - -#endif // FXJS_JS_KEYVALUE_H_ diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp index c4a8edcf32..3c5c51b794 100644 --- a/fxjs/cjs_global.cpp +++ b/fxjs/cjs_global.cpp @@ -13,10 +13,10 @@ #include "core/fxcrt/fx_extension.h" #include "fxjs/JS_Define.h" -#include "fxjs/JS_GlobalData.h" -#include "fxjs/JS_KeyValue.h" #include "fxjs/cjs_event_context.h" #include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_globaldata.h" +#include "fxjs/cjs_keyvalue.h" #include "fxjs/cjs_object.h" #include "fxjs/js_resources.h" diff --git a/fxjs/cjs_globaldata.cpp b/fxjs/cjs_globaldata.cpp new file mode 100644 index 0000000000..fe7d94b9a4 --- /dev/null +++ b/fxjs/cjs_globaldata.cpp @@ -0,0 +1,397 @@ +// 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 + +#include "fxjs/cjs_globaldata.h" + +#include + +#include "core/fdrm/crypto/fx_crypt.h" +#include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" + +#define JS_MAXGLOBALDATA (1024 * 4 - 8) + +#define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data" +#define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data" +#define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data" + +namespace { + +const uint8_t JS_RC4KEY[] = { + 0x19, 0xa8, 0xe8, 0x01, 0xf6, 0xa8, 0xb6, 0x4d, 0x82, 0x04, 0x45, 0x6d, + 0xb4, 0xcf, 0xd7, 0x77, 0x67, 0xf9, 0x75, 0x9f, 0xf0, 0xe0, 0x1e, 0x51, + 0xee, 0x46, 0xfd, 0x0b, 0xc9, 0x93, 0x25, 0x55, 0x4a, 0xee, 0xe0, 0x16, + 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22, + 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b, + 0x04, 0x75, 0x89, 0xc9, 0xb1, 0xed, 0x50, 0xca, 0x96, 0x6f, 0x1a, 0x7a, + 0xfe, 0x58, 0x5d, 0xec, 0x19, 0x4a, 0xf6, 0x35, 0x6a, 0x97, 0x14, 0x00, + 0x0e, 0xd0, 0x6b, 0xbb, 0xd5, 0x75, 0x55, 0x8b, 0x6e, 0x6b, 0x19, 0xa0, + 0xf8, 0x77, 0xd5, 0xa3}; + +// Returns true if non-empty, setting sPropName +bool TrimPropName(ByteString* sPropName) { + sPropName->TrimLeft(); + sPropName->TrimRight(); + return sPropName->GetLength() != 0; +} + +CJS_GlobalData* g_pInstance = nullptr; + +} // namespace + +// static +CJS_GlobalData* CJS_GlobalData::GetRetainedInstance( + CPDFSDK_FormFillEnvironment* pApp) { + if (!g_pInstance) { + g_pInstance = new CJS_GlobalData(); + } + ++g_pInstance->m_RefCount; + return g_pInstance; +} + +void CJS_GlobalData::Release() { + if (!--m_RefCount) { + delete g_pInstance; + g_pInstance = nullptr; + } +} + +CJS_GlobalData::CJS_GlobalData() + : m_RefCount(0), m_sFilePath(SDK_JS_GLOBALDATA_FILENAME) { + LoadGlobalPersistentVariables(); +} + +CJS_GlobalData::~CJS_GlobalData() { + SaveGlobalPersisitentVariables(); +} + +CJS_GlobalData::iterator CJS_GlobalData::FindGlobalVariable( + const ByteString& propname) { + for (auto it = m_arrayGlobalData.begin(); it != m_arrayGlobalData.end(); + ++it) { + if ((*it)->data.sKey == propname) + return it; + } + return m_arrayGlobalData.end(); +} + +CJS_GlobalData::const_iterator CJS_GlobalData::FindGlobalVariable( + const ByteString& propname) const { + for (auto it = m_arrayGlobalData.begin(); it != m_arrayGlobalData.end(); + ++it) { + if ((*it)->data.sKey == propname) + return it; + } + return m_arrayGlobalData.end(); +} + +CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable( + const ByteString& propname) { + auto iter = FindGlobalVariable(propname); + return iter != m_arrayGlobalData.end() ? iter->get() : nullptr; +} + +void CJS_GlobalData::SetGlobalVariableNumber(const ByteString& propname, + double dData) { + ByteString sPropName(propname); + if (!TrimPropName(&sPropName)) + return; + + if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { + pData->data.nType = JS_GlobalDataType::NUMBER; + pData->data.dData = dData; + return; + } + auto pNewData = pdfium::MakeUnique(); + pNewData->data.sKey = sPropName; + pNewData->data.nType = JS_GlobalDataType::NUMBER; + pNewData->data.dData = dData; + m_arrayGlobalData.push_back(std::move(pNewData)); +} + +void CJS_GlobalData::SetGlobalVariableBoolean(const ByteString& propname, + bool bData) { + ByteString sPropName(propname); + if (!TrimPropName(&sPropName)) + return; + + if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { + pData->data.nType = JS_GlobalDataType::BOOLEAN; + pData->data.bData = bData; + return; + } + auto pNewData = pdfium::MakeUnique(); + pNewData->data.sKey = sPropName; + pNewData->data.nType = JS_GlobalDataType::BOOLEAN; + pNewData->data.bData = bData; + m_arrayGlobalData.push_back(std::move(pNewData)); +} + +void CJS_GlobalData::SetGlobalVariableString(const ByteString& propname, + const ByteString& sData) { + ByteString sPropName(propname); + if (!TrimPropName(&sPropName)) + return; + + if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { + pData->data.nType = JS_GlobalDataType::STRING; + pData->data.sData = sData; + return; + } + auto pNewData = pdfium::MakeUnique(); + pNewData->data.sKey = sPropName; + pNewData->data.nType = JS_GlobalDataType::STRING; + pNewData->data.sData = sData; + m_arrayGlobalData.push_back(std::move(pNewData)); +} + +void CJS_GlobalData::SetGlobalVariableObject( + const ByteString& propname, + const CJS_GlobalVariableArray& array) { + ByteString sPropName(propname); + if (!TrimPropName(&sPropName)) + return; + + if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { + pData->data.nType = JS_GlobalDataType::OBJECT; + pData->data.objData.Copy(array); + return; + } + auto pNewData = pdfium::MakeUnique(); + pNewData->data.sKey = sPropName; + pNewData->data.nType = JS_GlobalDataType::OBJECT; + pNewData->data.objData.Copy(array); + m_arrayGlobalData.push_back(std::move(pNewData)); +} + +void CJS_GlobalData::SetGlobalVariableNull(const ByteString& propname) { + ByteString sPropName(propname); + if (!TrimPropName(&sPropName)) + return; + + if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { + pData->data.nType = JS_GlobalDataType::NULLOBJ; + return; + } + auto pNewData = pdfium::MakeUnique(); + pNewData->data.sKey = sPropName; + pNewData->data.nType = JS_GlobalDataType::NULLOBJ; + m_arrayGlobalData.push_back(std::move(pNewData)); +} + +bool CJS_GlobalData::SetGlobalVariablePersistent(const ByteString& propname, + bool bPersistent) { + ByteString sPropName(propname); + if (!TrimPropName(&sPropName)) + return false; + + CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName); + if (!pData) + return false; + + pData->bPersistent = bPersistent; + return true; +} + +bool CJS_GlobalData::DeleteGlobalVariable(const ByteString& propname) { + ByteString sPropName(propname); + if (!TrimPropName(&sPropName)) + return false; + + auto iter = FindGlobalVariable(sPropName); + if (iter == m_arrayGlobalData.end()) + return false; + + m_arrayGlobalData.erase(iter); + return true; +} + +int32_t CJS_GlobalData::GetSize() const { + return pdfium::CollectionSize(m_arrayGlobalData); +} + +CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const { + if (index < 0 || index >= GetSize()) + return nullptr; + return m_arrayGlobalData[index].get(); +} + +void CJS_GlobalData::LoadGlobalPersistentVariables() { + uint8_t* pBuffer = nullptr; + int32_t nLength = 0; + + LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength); + CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY)); + + if (pBuffer) { + uint8_t* p = pBuffer; + uint16_t wType = *((uint16_t*)p); + p += sizeof(uint16_t); + + if (wType == (uint16_t)(('X' << 8) | 'F')) { + uint16_t wVersion = *((uint16_t*)p); + p += sizeof(uint16_t); + + ASSERT(wVersion <= 2); + + uint32_t dwCount = *((uint32_t*)p); + p += sizeof(uint32_t); + + uint32_t dwSize = *((uint32_t*)p); + p += sizeof(uint32_t); + + if (dwSize == nLength - sizeof(uint16_t) * 2 - sizeof(uint32_t) * 2) { + for (int32_t i = 0, sz = dwCount; i < sz; i++) { + if (p > pBuffer + nLength) + break; + + uint32_t dwNameLen = *((uint32_t*)p); + p += sizeof(uint32_t); + + if (p + dwNameLen > pBuffer + nLength) + break; + + ByteString sEntry = ByteString(p, dwNameLen); + p += sizeof(char) * dwNameLen; + + JS_GlobalDataType wDataType = + static_cast(*((uint16_t*)p)); + p += sizeof(uint16_t); + + switch (wDataType) { + case JS_GlobalDataType::NUMBER: { + double dData = 0; + switch (wVersion) { + case 1: { + uint32_t dwData = *((uint32_t*)p); + p += sizeof(uint32_t); + dData = dwData; + } break; + case 2: { + dData = *((double*)p); + p += sizeof(double); + } break; + } + SetGlobalVariableNumber(sEntry, dData); + SetGlobalVariablePersistent(sEntry, true); + } break; + case JS_GlobalDataType::BOOLEAN: { + uint16_t wData = *((uint16_t*)p); + p += sizeof(uint16_t); + SetGlobalVariableBoolean(sEntry, (bool)(wData == 1)); + SetGlobalVariablePersistent(sEntry, true); + } break; + case JS_GlobalDataType::STRING: { + uint32_t dwLength = *((uint32_t*)p); + p += sizeof(uint32_t); + + if (p + dwLength > pBuffer + nLength) + break; + + SetGlobalVariableString(sEntry, ByteString(p, dwLength)); + SetGlobalVariablePersistent(sEntry, true); + p += sizeof(char) * dwLength; + } break; + case JS_GlobalDataType::NULLOBJ: { + SetGlobalVariableNull(sEntry); + SetGlobalVariablePersistent(sEntry, true); + } + case JS_GlobalDataType::OBJECT: + break; + } + } + } + } + FX_Free(pBuffer); + } +} + +void CJS_GlobalData::SaveGlobalPersisitentVariables() { + uint32_t nCount = 0; + CFX_BinaryBuf sData; + for (const auto& pElement : m_arrayGlobalData) { + if (pElement->bPersistent) { + CFX_BinaryBuf sElement; + MakeByteString(pElement->data.sKey, &pElement->data, sElement); + if (sData.GetSize() + sElement.GetSize() > JS_MAXGLOBALDATA) + break; + + sData.AppendBlock(sElement.GetBuffer(), sElement.GetSize()); + nCount++; + } + } + + CFX_BinaryBuf sFile; + uint16_t wType = (uint16_t)(('X' << 8) | 'F'); + sFile.AppendBlock(&wType, sizeof(uint16_t)); + uint16_t wVersion = 2; + sFile.AppendBlock(&wVersion, sizeof(uint16_t)); + sFile.AppendBlock(&nCount, sizeof(uint32_t)); + uint32_t dwSize = sData.GetSize(); + sFile.AppendBlock(&dwSize, sizeof(uint32_t)); + + sFile.AppendBlock(sData.GetBuffer(), sData.GetSize()); + + CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, + sizeof(JS_RC4KEY)); + WriteFileBuffer(m_sFilePath.c_str(), (const char*)sFile.GetBuffer(), + sFile.GetSize()); +} + +void CJS_GlobalData::LoadFileBuffer(const wchar_t* sFilePath, + uint8_t*& pBuffer, + int32_t& nLength) { + // UnSupport. +} + +void CJS_GlobalData::WriteFileBuffer(const wchar_t* sFilePath, + const char* pBuffer, + int32_t nLength) { + // UnSupport. +} + +void CJS_GlobalData::MakeByteString(const ByteString& name, + CJS_KeyValue* pData, + CFX_BinaryBuf& sData) { + switch (pData->nType) { + case JS_GlobalDataType::NUMBER: { + uint32_t dwNameLen = (uint32_t)name.GetLength(); + sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); + sData.AppendString(name); + sData.AppendBlock(&pData->nType, sizeof(uint16_t)); + + double dData = pData->dData; + sData.AppendBlock(&dData, sizeof(double)); + } break; + case JS_GlobalDataType::BOOLEAN: { + uint32_t dwNameLen = (uint32_t)name.GetLength(); + sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); + sData.AppendString(name); + sData.AppendBlock(&pData->nType, sizeof(uint16_t)); + + uint16_t wData = (uint16_t)pData->bData; + sData.AppendBlock(&wData, sizeof(uint16_t)); + } break; + case JS_GlobalDataType::STRING: { + uint32_t dwNameLen = (uint32_t)name.GetLength(); + sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); + sData.AppendString(name); + sData.AppendBlock(&pData->nType, sizeof(uint16_t)); + + uint32_t dwDataLen = (uint32_t)pData->sData.GetLength(); + sData.AppendBlock(&dwDataLen, sizeof(uint32_t)); + sData.AppendString(pData->sData); + } break; + case JS_GlobalDataType::NULLOBJ: { + uint32_t dwNameLen = (uint32_t)name.GetLength(); + sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); + sData.AppendString(name); + sData.AppendBlock(&pData->nType, sizeof(uint32_t)); + } break; + default: + break; + } +} 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_ diff --git a/fxjs/cjs_globalvariablearray.cpp b/fxjs/cjs_globalvariablearray.cpp new file mode 100644 index 0000000000..8bf9f1b305 --- /dev/null +++ b/fxjs/cjs_globalvariablearray.cpp @@ -0,0 +1,68 @@ +// Copyright 2017 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 + +#include "fxjs/cjs_globalvariablearray.h" + +#include "fxjs/cjs_keyvalue.h" + +CJS_GlobalVariableArray::CJS_GlobalVariableArray() {} + +CJS_GlobalVariableArray::~CJS_GlobalVariableArray() {} + +void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) { + m_Array.clear(); + for (int i = 0, sz = array.Count(); i < sz; i++) { + CJS_KeyValue* pOldObjData = array.GetAt(i); + switch (pOldObjData->nType) { + case JS_GlobalDataType::NUMBER: { + CJS_KeyValue* pNewObjData = new CJS_KeyValue; + pNewObjData->sKey = pOldObjData->sKey; + pNewObjData->nType = pOldObjData->nType; + pNewObjData->dData = pOldObjData->dData; + Add(pNewObjData); + } break; + case JS_GlobalDataType::BOOLEAN: { + CJS_KeyValue* pNewObjData = new CJS_KeyValue; + pNewObjData->sKey = pOldObjData->sKey; + pNewObjData->nType = pOldObjData->nType; + pNewObjData->bData = pOldObjData->bData; + Add(pNewObjData); + } break; + case JS_GlobalDataType::STRING: { + CJS_KeyValue* pNewObjData = new CJS_KeyValue; + pNewObjData->sKey = pOldObjData->sKey; + pNewObjData->nType = pOldObjData->nType; + pNewObjData->sData = pOldObjData->sData; + Add(pNewObjData); + } break; + case JS_GlobalDataType::OBJECT: { + CJS_KeyValue* pNewObjData = new CJS_KeyValue; + pNewObjData->sKey = pOldObjData->sKey; + pNewObjData->nType = pOldObjData->nType; + pNewObjData->objData.Copy(pOldObjData->objData); + Add(pNewObjData); + } break; + case JS_GlobalDataType::NULLOBJ: { + CJS_KeyValue* pNewObjData = new CJS_KeyValue; + pNewObjData->sKey = pOldObjData->sKey; + pNewObjData->nType = pOldObjData->nType; + Add(pNewObjData); + } break; + } + } +} + +void CJS_GlobalVariableArray::Add(CJS_KeyValue* p) { + m_Array.push_back(std::unique_ptr(p)); +} + +int CJS_GlobalVariableArray::Count() const { + return m_Array.size(); +} + +CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const { + return m_Array.at(index).get(); +} diff --git a/fxjs/cjs_globalvariablearray.h b/fxjs/cjs_globalvariablearray.h new file mode 100644 index 0000000000..a249f60be9 --- /dev/null +++ b/fxjs/cjs_globalvariablearray.h @@ -0,0 +1,29 @@ +// Copyright 2017 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_GLOBALVARIABLEARRAY_H_ +#define FXJS_CJS_GLOBALVARIABLEARRAY_H_ + +#include +#include + +class CJS_KeyValue; + +class CJS_GlobalVariableArray { + public: + CJS_GlobalVariableArray(); + ~CJS_GlobalVariableArray(); + + void Add(CJS_KeyValue* p); + int Count() const; + CJS_KeyValue* GetAt(int index) const; + void Copy(const CJS_GlobalVariableArray& array); + + private: + std::vector> m_Array; +}; + +#endif // FXJS_CJS_GLOBALVARIABLEARRAY_H_ diff --git a/fxjs/cjs_keyvalue.cpp b/fxjs/cjs_keyvalue.cpp new file mode 100644 index 0000000000..4fda3d6fb2 --- /dev/null +++ b/fxjs/cjs_keyvalue.cpp @@ -0,0 +1,11 @@ +// Copyright 2016 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 + +#include "fxjs/cjs_keyvalue.h" + +CJS_KeyValue::CJS_KeyValue() {} + +CJS_KeyValue::~CJS_KeyValue() {} diff --git a/fxjs/cjs_keyvalue.h b/fxjs/cjs_keyvalue.h new file mode 100644 index 0000000000..a1fd314de4 --- /dev/null +++ b/fxjs/cjs_keyvalue.h @@ -0,0 +1,28 @@ +// Copyright 2016 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_KEYVALUE_H_ +#define FXJS_CJS_KEYVALUE_H_ + +#include "core/fxcrt/fx_string.h" +#include "fxjs/cjs_globalvariablearray.h" + +enum class JS_GlobalDataType { NUMBER = 0, BOOLEAN, STRING, OBJECT, NULLOBJ }; + +class CJS_KeyValue { + public: + CJS_KeyValue(); + ~CJS_KeyValue(); + + ByteString sKey; + JS_GlobalDataType nType; + double dData; + bool bData; + ByteString sData; + CJS_GlobalVariableArray objData; +}; + +#endif // FXJS_CJS_KEYVALUE_H_ diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp index 6043debc44..8a3b166cbd 100644 --- a/fxjs/cjs_runtime.cpp +++ b/fxjs/cjs_runtime.cpp @@ -10,7 +10,6 @@ #include "fpdfsdk/cpdfsdk_formfillenvironment.h" #include "fxjs/JS_Define.h" -#include "fxjs/JS_GlobalData.h" #include "fxjs/cjs_annot.h" #include "fxjs/cjs_app.h" #include "fxjs/cjs_border.h" @@ -26,6 +25,7 @@ #include "fxjs/cjs_global.h" #include "fxjs/cjs_globalarrays.h" #include "fxjs/cjs_globalconsts.h" +#include "fxjs/cjs_globaldata.h" #include "fxjs/cjs_highlight.h" #include "fxjs/cjs_icon.h" #include "fxjs/cjs_object.h" -- cgit v1.2.3