From c002261326795102c4680c43ea447674dd4d6f3b Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 11 Dec 2017 22:31:58 +0000 Subject: [xfa] Move CJX code into fxjs/xfa This CL moves the remaining CJX clases into fxjs/xfa so they co-exist with the rest of the CJX classes. Change-Id: I2b1e5504ac23f73df177f309967a04ab27fb61d1 Reviewed-on: https://pdfium-review.googlesource.com/20550 Commit-Queue: dsinclair Reviewed-by: Lei Zhang --- fxjs/cjx_object.h | 164 ------------------------------------------------------ 1 file changed, 164 deletions(-) delete mode 100644 fxjs/cjx_object.h (limited to 'fxjs/cjx_object.h') diff --git a/fxjs/cjx_object.h b/fxjs/cjx_object.h deleted file mode 100644 index fb6251e224..0000000000 --- a/fxjs/cjx_object.h +++ /dev/null @@ -1,164 +0,0 @@ -// 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_CJX_OBJECT_H_ -#define FXJS_CJX_OBJECT_H_ - -#include -#include -#include - -#include "core/fxcrt/unowned_ptr.h" -#include "core/fxcrt/widestring.h" -#include "core/fxcrt/xml/cfx_xmlelement.h" -#include "third_party/base/optional.h" -#include "xfa/fxfa/fxfa_basic.h" - -class CFXJSE_Value; -class CJS_V8; -class CXFA_CalcData; -class CXFA_Document; -class CXFA_Object; -struct XFA_MAPMODULEDATA; - -typedef CJS_Return (*CJX_MethodCall)( - CJX_Object* obj, - CJS_V8* runtime, - const std::vector>& params); -struct CJX_MethodSpec { - const char* pName; - CJX_MethodCall pMethodCall; -}; - -typedef void (*PD_CALLBACK_FREEDATA)(void* pData); -typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData); - -struct XFA_MAPDATABLOCKCALLBACKINFO { - PD_CALLBACK_FREEDATA pFree; - PD_CALLBACK_DUPLICATEDATA pCopy; -}; - -class CJX_Object { - public: - virtual ~CJX_Object(); - - CXFA_Object* GetXFAObject() { return object_.Get(); } - const CXFA_Object* GetXFAObject() const { return object_.Get(); } - - CXFA_Document* GetDocument() const; - - bool HasMethod(const WideString& func) const; - CJS_Return RunMethod(const WideString& func, - const std::vector>& params); - - bool HasAttribute(XFA_Attribute eAttr); - bool SetAttribute(XFA_Attribute eAttr, - const WideStringView& wsValue, - bool bNotify); - bool SetAttribute(const WideStringView& wsAttr, - const WideStringView& wsValue, - bool bNotify); - void RemoveAttribute(const WideStringView& wsAttr); - WideString GetAttribute(const WideStringView& attr); - WideString GetAttribute(XFA_Attribute attr); - pdfium::Optional TryAttribute(const WideStringView& wsAttr, - bool bUseDefault); - pdfium::Optional TryAttribute(XFA_Attribute eAttr, - bool bUseDefault); - - void SetAttributeValue(const WideString& wsValue, - const WideString& wsXMLValue, - bool bNotify, - bool bScriptModify); - - pdfium::Optional TryInteger(XFA_Attribute eAttr, bool bUseDefault); - bool SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify); - int32_t GetInteger(XFA_Attribute eAttr); - - pdfium::Optional TryCData(XFA_Attribute eAttr, bool bUseDefault); - bool SetCData(XFA_Attribute eAttr, - const WideString& wsValue, - bool bNotify, - bool bScriptModify); - WideString GetCData(XFA_Attribute eAttr); - - pdfium::Optional TryEnum(XFA_Attribute eAttr, - bool bUseDefault); - bool SetEnum(XFA_Attribute eAttr, XFA_AttributeEnum eValue, bool bNotify); - XFA_AttributeEnum GetEnum(XFA_Attribute eAttr); - - pdfium::Optional TryBoolean(XFA_Attribute eAttr, bool bUseDefault); - bool SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify); - bool GetBoolean(XFA_Attribute eAttr); - - pdfium::Optional TryMeasure(XFA_Attribute eAttr, - bool bUseDefault) const; - bool SetMeasure(XFA_Attribute eAttr, CXFA_Measurement mValue, bool bNotify); - CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const; - - void Script_ObjectClass_ClassName(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute); - - void MergeAllData(CXFA_Object* pDstModule); - - void SetCalcData(std::unique_ptr data); - CXFA_CalcData* GetCalcData() const { return calc_data_.get(); } - std::unique_ptr ReleaseCalcData(); - - void ThrowInvalidPropertyException() const; - void ThrowArgumentMismatchException() const; - void ThrowIndexOutOfBoundsException() const; - void ThrowParamCountMismatchException(const WideString& method) const; - - protected: - explicit CJX_Object(CXFA_Object* obj); - - void DefineMethods(const CJX_MethodSpec method_specs[]); - - void MoveBufferMapData(CXFA_Object* pSrcModule, CXFA_Object* pDstModule); - void SetMapModuleString(void* pKey, const WideStringView& wsValue); - void ThrowException(const wchar_t* str, ...) const; - - private: - void OnChanged(XFA_Attribute eAttr, bool bNotify, bool bScriptModify); - void OnChanging(XFA_Attribute eAttr, bool bNotify); - bool SetUserData(void* pKey, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo); - - // Returns a pointer to the XML node that needs to be updated with the new - // attribute value. |nullptr| if no update is needed. - CFX_XMLElement* SetValue(XFA_Attribute eAttr, - XFA_AttributeType eType, - void* pValue, - bool bNotify); - - XFA_MAPMODULEDATA* CreateMapModuleData(); - XFA_MAPMODULEDATA* GetMapModuleData() const; - void SetMapModuleValue(void* pKey, void* pValue); - bool GetMapModuleValue(void* pKey, void*& pValue); - bool GetMapModuleString(void* pKey, WideStringView& wsValue); - void SetMapModuleBuffer(void* pKey, - void* pValue, - int32_t iBytes, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo); - bool GetMapModuleBuffer(void* pKey, - void*& pValue, - int32_t& iBytes, - bool bProtoAlso) const; - bool HasMapModuleKey(void* pKey); - void ClearMapModuleBuffer(); - void RemoveMapModuleKey(void* pKey); - void MoveBufferMapData(CXFA_Object* pDstModule); - - UnownedPtr object_; - std::unique_ptr map_module_data_; - std::unique_ptr calc_data_; - std::map method_specs_; -}; - -#endif // FXJS_CJX_OBJECT_H_ -- cgit v1.2.3