diff options
Diffstat (limited to 'fpdfsdk/include')
-rw-r--r-- | fpdfsdk/include/fpdfxfa/DEPS | 3 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_app.h | 98 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h | 238 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_page.h | 77 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_util.h | 47 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_define.h | 2 | ||||
-rw-r--r-- | fpdfsdk/include/fxedit/DEPS | 3 | ||||
-rw-r--r-- | fpdfsdk/include/fxedit/fx_edit.h | 629 | ||||
-rw-r--r-- | fpdfsdk/include/fxedit/fxet_edit.h | 804 | ||||
-rw-r--r-- | fpdfsdk/include/fxedit/fxet_list.h | 343 | ||||
-rw-r--r-- | fpdfsdk/include/jsapi/fxjs_v8.h | 305 |
11 files changed, 1 insertions, 2548 deletions
diff --git a/fpdfsdk/include/fpdfxfa/DEPS b/fpdfsdk/include/fpdfxfa/DEPS deleted file mode 100644 index f207778cb2..0000000000 --- a/fpdfsdk/include/fpdfxfa/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+xfa/fwl/core/include", -] diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h deleted file mode 100644 index ed626716f7..0000000000 --- a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h +++ /dev/null @@ -1,98 +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 FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_APP_H_ -#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_APP_H_ - -#include "xfa/include/fxfa/fxfa.h" - -class CPDFDoc_Environment; -class IFXJS_Runtime; - -class CPDFXFA_App : public IXFA_AppProvider { - public: - static CPDFXFA_App* GetInstance(); - static void ReleaseInstance(); - - CPDFXFA_App(); - ~CPDFXFA_App() override; - - FX_BOOL Initialize(FXJSE_HRUNTIME hRuntime); - CXFA_FFApp* GetXFAApp() { return m_pXFAApp; } - - FX_BOOL AddFormFillEnv(CPDFDoc_Environment* pEnv); - FX_BOOL RemoveFormFillEnv(CPDFDoc_Environment* pEnv); - - FX_BOOL IsJavaScriptInitialized() const { return m_bJavaScriptInitialized; } - void SetJavaScriptInitialized(FX_BOOL bInitialized) { - m_bJavaScriptInitialized = bInitialized; - } - - FXJSE_HRUNTIME GetJSERuntime() const { return m_hJSERuntime; } - - // IFXA_AppProvider: - void GetAppType(CFX_WideString& wsAppType) override; - void SetAppType(const CFX_WideStringC& wsAppType) override; - - void GetLanguage(CFX_WideString& wsLanguage) override; - void GetPlatform(CFX_WideString& wsPlatform) override; - void GetVariation(CFX_WideString& wsVariation) override; - void GetVersion(CFX_WideString& wsVersion) override; - void GetFoxitVersion(CFX_WideString& wsFoxitVersion) override { - wsFoxitVersion = L"7.0"; - } - - void GetAppName(CFX_WideString& wsName) override; - void GetFoxitAppName(CFX_WideString& wsFoxitName) override { - wsFoxitName = L"Foxit"; - } - - void Beep(uint32_t dwType) override; - int32_t MsgBox(const CFX_WideStringC& wsMessage, - const CFX_WideStringC& wsTitle, - uint32_t dwIconType, - uint32_t dwButtonType) override; - void Response(CFX_WideString& wsAnswer, - const CFX_WideStringC& wsQuestion, - const CFX_WideStringC& wsTitle, - const CFX_WideStringC& wsDefaultAnswer, - FX_BOOL bMark) override; - - int32_t GetDocumentCountInBatch() override; - int32_t GetCurDocumentInBatch() override; - - IFX_FileRead* DownloadURL(const CFX_WideStringC& wsURL) override; - FX_BOOL PostRequestURL(const CFX_WideStringC& wsURL, - const CFX_WideStringC& wsData, - const CFX_WideStringC& wsContentType, - const CFX_WideStringC& wsEncode, - const CFX_WideStringC& wsHeader, - CFX_WideString& wsResponse) override; - FX_BOOL PutRequestURL(const CFX_WideStringC& wsURL, - const CFX_WideStringC& wsData, - const CFX_WideStringC& wsEncode) override; - - void LoadString(int32_t iStringID, CFX_WideString& wsString) override; - FX_BOOL ShowFileDialog(const CFX_WideStringC& wsTitle, - const CFX_WideStringC& wsFilter, - CFX_WideStringArray& wsPathArr, - FX_BOOL bOpen) override; - IFWL_AdapterTimerMgr* GetTimerMgr() override; - - CFX_ArrayTemplate<CPDFDoc_Environment*> m_pEnvList; - - protected: - static CPDFXFA_App* g_pApp; - - FX_BOOL m_bJavaScriptInitialized; - CXFA_FFApp* m_pXFAApp; - FXJSE_HRUNTIME m_hJSERuntime; - IFXJS_Runtime* m_pJSRuntime; - CFX_WideString m_csAppType; - bool m_bOwnedRuntime; -}; - -#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_APP_H_ diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h deleted file mode 100644 index dc09c8b656..0000000000 --- a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h +++ /dev/null @@ -1,238 +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 FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_DOC_H_ -#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_DOC_H_ - -#include <vector> - -#include "public/fpdfview.h" -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/include/fxfa/xfa_ffdoc.h" -#include "xfa/include/fxfa/xfa_ffdochandler.h" - -class CPDFXFA_App; -class CPDFXFA_Document; -class CPDFXFA_Page; -class CPDFSDK_Document; -class CPDFDoc_Environment; -class IJS_Runtime; -class IJS_Context; -class CXFA_FFDocHandler; - -class CPDFXFA_Document : public IXFA_DocProvider { - public: - CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider); - ~CPDFXFA_Document(); - - FX_BOOL LoadXFADoc(); - CPDFXFA_App* GetApp() { return m_pApp; } - CPDF_Document* GetPDFDoc() { return m_pPDFDoc; } - CXFA_FFDoc* GetXFADoc() { return m_pXFADoc; } - CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } - - int GetPageCount(); - CPDFXFA_Page* GetPage(int page_index); - CPDFXFA_Page* GetPage(CXFA_FFPageView* pPage); - - void DeletePage(int page_index); - void RemovePage(CPDFXFA_Page* page); - int GetDocType() { return m_iDocType; } - - CPDFSDK_Document* GetSDKDocument(CPDFDoc_Environment* pFormFillEnv); - - void FXRect2PDFRect(const CFX_RectF& fxRectF, CFX_FloatRect& pdfRect); - - virtual void SetChangeMark(CXFA_FFDoc* hDoc); - virtual FX_BOOL GetChangeMark(CXFA_FFDoc* hDoc); - // used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. - virtual void InvalidateRect(CXFA_FFPageView* pPageView, - const CFX_RectF& rt, - uint32_t dwFlags = 0); - // used in static xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. - virtual void InvalidateRect(CXFA_FFWidget* hWidget, uint32_t dwFlags = 0); - // show or hide caret - virtual void DisplayCaret(CXFA_FFWidget* hWidget, - FX_BOOL bVisible, - const CFX_RectF* pRtAnchor); - // dwPos: (0:bottom 1:top) - virtual FX_BOOL GetPopupPos(CXFA_FFWidget* hWidget, - FX_FLOAT fMinPopup, - FX_FLOAT fMaxPopup, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); - virtual FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, - CFX_PointF ptPopup, - const CFX_RectF* pRectExclude = NULL); - - // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing - virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags); - // dwEvent refer to XFA_WIDGETEVENT_XXX - virtual void WidgetEvent(CXFA_FFWidget* hWidget, - CXFA_WidgetAcc* pWidgetData, - uint32_t dwEvent, - void* pParam = NULL, - void* pAdditional = NULL); - - // return true if render it. - virtual FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - const CFX_RectF& rtUI) { - return FALSE; - } - - // host method - virtual int32_t CountPages(CXFA_FFDoc* hDoc); - virtual int32_t GetCurrentPage(CXFA_FFDoc* hDoc); - virtual void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage); - virtual FX_BOOL IsCalculationsEnabled(CXFA_FFDoc* hDoc); - virtual void SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled); - virtual void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle); - virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideStringC& wsTitle); - virtual void ExportData(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFilePath, - FX_BOOL bXDP = TRUE); - virtual void ImportData(CXFA_FFDoc* hDoc, const CFX_WideStringC& wsFilePath); - virtual void GotoURL(CXFA_FFDoc* hDoc, - const CFX_WideStringC& bsURL, - FX_BOOL bAppend = TRUE); - virtual FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc); - virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled); - virtual void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget); - virtual void Print(CXFA_FFDoc* hDoc, - int32_t nStartPage, - int32_t nEndPage, - uint32_t dwOptions); - - // LayoutPseudo method - virtual int32_t AbsPageCountInBatch(CXFA_FFDoc* hDoc) { return 0; } - virtual int32_t AbsPageInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) { - return 0; - } - virtual int32_t SheetCountInBatch(CXFA_FFDoc* hDoc) { return 0; } - virtual int32_t SheetInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) { - return 0; - } - - virtual int32_t Verify(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bUsed = TRUE) { - return 0; - } - virtual FX_BOOL Sign(CXFA_FFDoc* hDoc, - CXFA_NodeList* pNodeList, - const CFX_WideStringC& wsExpression, - const CFX_WideStringC& wsXMLIdent, - const CFX_WideStringC& wsValue = FX_WSTRC(L"open"), - FX_BOOL bUsed = TRUE) { - return 0; - } - virtual CXFA_NodeList* Enumerate(CXFA_FFDoc* hDoc) { return 0; } - virtual FX_BOOL Clear(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bCleared = TRUE) { - return 0; - } - - // Get document path - virtual void GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL); - virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc); - - /** - *Submit data to email, http, ftp. - * @param[in] hDoc The document handler. - * @param[in] eFormat Determines the format in which the data will be - *submitted. XFA_ATTRIBUTEENUM_Xdp, XFA_ATTRIBUTEENUM_Xml... - * @param[in] wsTarget The URL to which the data will be submitted. - * @param[in] eEncoding The encoding of text content. - * @param[in] pXDPContent Controls what subset of the data is submitted, used - *only when the format property is xdp. - * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted - *content or not. - */ - virtual FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit); - - virtual FX_BOOL CheckWord(CXFA_FFDoc* hDoc, const CFX_ByteStringC& sWord) { - return FALSE; - } - virtual FX_BOOL GetSuggestWords(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& sWord, - std::vector<CFX_ByteString>& sSuggest) { - return FALSE; - } - - // Get PDF javascript object, set the object to hValue. - virtual FX_BOOL GetPDFScriptObject(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& utf8Name, - FXJSE_HVALUE hValue); - - virtual FX_BOOL GetGlobalProperty(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue); - virtual FX_BOOL SetGlobalProperty(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue); - virtual CPDF_Document* OpenPDF(CXFA_FFDoc* hDoc, - IFX_FileRead* pFile, - FX_BOOL bTakeOverFile) { - return NULL; - } - - virtual IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc, - const CFX_WideString& wsLink); - - FX_BOOL _GetHValueByName(const CFX_ByteStringC& utf8Name, - FXJSE_HVALUE hValue, - IJS_Runtime* runTime); - FX_BOOL _OnBeforeNotifySumbit(); - void _OnAfterNotifySumbit(); - FX_BOOL _NotifySubmit(FX_BOOL bPrevOrPost); - FX_BOOL _SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit); - FX_BOOL _MailToInfo(CFX_WideString& csURL, - CFX_WideString& csToAddress, - CFX_WideString& csCCAddress, - CFX_WideString& csBCCAddress, - CFX_WideString& csSubject, - CFX_WideString& csMsg); - FX_BOOL _ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler, - int fileType, - FPDF_DWORD encodeType, - FPDF_DWORD flag = 0x01111111); - void _ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag); - void _ClearChangeMark(); - - private: - enum LoadStatus { - FXFA_LOADSTATUS_PRELOAD = 0, - FXFA_LOADSTATUS_LOADING, - FXFA_LOADSTATUS_LOADED, - FXFA_LOADSTATUS_CLOSING, - FXFA_LOADSTATUS_CLOSED - }; - - void CloseXFADoc(CXFA_FFDocHandler* pDoc) { - if (pDoc) { - m_pXFADoc->CloseDoc(); - delete m_pXFADoc; - m_pXFADoc = nullptr; - m_pXFADocView = nullptr; - } - } - - int m_iDocType; - CPDF_Document* m_pPDFDoc; - CPDFSDK_Document* m_pSDKDoc; - CXFA_FFDoc* m_pXFADoc; - CXFA_FFDocView* m_pXFADocView; - CPDFXFA_App* m_pApp; - IJS_Context* m_pJSContext; - CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; - LoadStatus m_nLoadStatus; - int m_nPageCount; -}; - -#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_DOC_H_ diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h deleted file mode 100644 index 20da040a23..0000000000 --- a/fpdfsdk/include/fpdfxfa/fpdfxfa_page.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 FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_PAGE_H_ -#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_PAGE_H_ - -#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" -#include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fxcrt/include/fx_coordinates.h" -#include "core/fxcrt/include/fx_system.h" - -class CPDFXFA_Document; -class CPDF_Page; -class CXFA_FFPageView; - -class CPDFXFA_Page { - public: - CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index); - ~CPDFXFA_Page(); - - void Release(); - void AddRef() { m_iRef++; } - FX_BOOL LoadPage(); - FX_BOOL LoadPDFPage(CPDF_Dictionary* pageDict); - CPDFXFA_Document* GetDocument() { return m_pDocument; } - int GetPageIndex() { return m_iPageIndex; } - CPDF_Page* GetPDFPage() { return m_pPDFPage; } - CXFA_FFPageView* GetXFAPageView() { return m_pXFAPageView; } - void SetXFAPageView(CXFA_FFPageView* pPageView) { - m_pXFAPageView = pPageView; - } - - FX_FLOAT GetPageWidth(); - FX_FLOAT GetPageHeight(); - - void DeviceToPage(int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int device_x, - int device_y, - double* page_x, - double* page_y); - void PageToDevice(int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - double page_x, - double page_y, - int* device_x, - int* device_y); - - void GetDisplayMatrix(CFX_Matrix& matrix, - int xPos, - int yPos, - int xSize, - int ySize, - int iRotate) const; - - protected: - FX_BOOL LoadPDFPage(); - FX_BOOL LoadXFAPageView(); - - private: - CPDF_Page* m_pPDFPage; - CXFA_FFPageView* m_pXFAPageView; - int m_iPageIndex; - CPDFXFA_Document* m_pDocument; - int m_iRef; -}; - -#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_PAGE_H_ diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h deleted file mode 100644 index e0c508baa5..0000000000 --- a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h +++ /dev/null @@ -1,47 +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 FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_ -#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_ - -#include <vector> - -#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" -#include "xfa/fwl/core/include/ifwl_adaptertimermgr.h" - -#define JS_STR_VIEWERTYPE_STANDARD L"Exchange" -#define JS_STR_LANGUANGE L"ENU" -#define JS_STR_VIEWERVARIATION L"Full" -#define JS_STR_VIEWERVERSION_XFA L"11" - -struct CFWL_TimerInfo; - -class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { - public: - CXFA_FWLAdapterTimerMgr(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv) {} - virtual FWL_ERR Start(IFWL_Timer* pTimer, - uint32_t dwElapse, - FWL_HTIMER& hTimer, - FX_BOOL bImmediately = TRUE); - virtual FWL_ERR Stop(FWL_HTIMER hTimer); - - protected: - static void TimerProc(int32_t idEvent); - - static std::vector<CFWL_TimerInfo*>* s_TimerArray; - CPDFDoc_Environment* const m_pEnv; -}; - -struct CFWL_TimerInfo { - CFWL_TimerInfo() : pTimer(nullptr) {} - CFWL_TimerInfo(int32_t event, IFWL_Timer* timer) - : idEvent(event), pTimer(timer) {} - - int32_t idEvent; - IFWL_Timer* pTimer; -}; - -#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_ diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index 9882888ed9..d5f752c49b 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -14,7 +14,7 @@ #include "public/fpdfview.h" #ifdef PDF_ENABLE_XFA -#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" +#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #endif // PDF_ENABLE_XFA #ifdef _WIN32 diff --git a/fpdfsdk/include/fxedit/DEPS b/fpdfsdk/include/fxedit/DEPS deleted file mode 100644 index db9a09c342..0000000000 --- a/fpdfsdk/include/fxedit/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - '+core/fpdfdoc/include', -] diff --git a/fpdfsdk/include/fxedit/fx_edit.h b/fpdfsdk/include/fxedit/fx_edit.h deleted file mode 100644 index 46896457af..0000000000 --- a/fpdfsdk/include/fxedit/fx_edit.h +++ /dev/null @@ -1,629 +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 FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_ -#define FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_ - -#include "core/fpdfdoc/include/cpdf_variabletext.h" -#include "core/fxcrt/include/fx_basic.h" -#include "core/fxge/include/fx_dib.h" - -class CPDF_Font; -class CPDF_PageObjectHolder; -class CPDF_TextObject; -class CFX_FloatPoint; -class CFX_Matrix; -class CFX_RenderDevice; -class IFX_Edit; -class IPVT_FontMap; -class IFX_Edit_Iterator; -class IFX_Edit_Notify; -class IFX_Edit_UndoItem; -class IFX_List; -class IFX_List_Notify; -class IFX_SystemHandler; - -struct CPVT_Line; -struct CPVT_SecProps; -struct CPVT_Section; -struct CPVT_Word; -struct CPVT_WordPlace; -struct CPVT_WordProps; -struct CPVT_WordRange; - -#define PVTWORD_STYLE_NORMAL 0x0000L -#define PVTWORD_STYLE_HIGHLIGHT 0x0001L -#define PVTWORD_STYLE_UNDERLINE 0x0002L -#define PVTWORD_STYLE_CROSSOUT 0x0004L -#define PVTWORD_STYLE_SQUIGGLY 0x0008L -#define PVTWORD_STYLE_DUALCROSSOUT 0x0010L -#define PVTWORD_STYLE_BOLD 0x0020L -#define PVTWORD_STYLE_ITALIC 0x0040L - -#define FX_EDIT_ISLATINWORD(u) \ - (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \ - (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0)) - -#ifndef DEFAULT_CHARSET -#define DEFAULT_CHARSET 1 -#endif - -class IFX_Edit_Notify { - public: - virtual ~IFX_Edit_Notify() {} - // set the horizontal scrollbar information. - virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, - FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, - FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, - FX_FLOAT fBigStep) = 0; - // set the vertical scrollbar information. - virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, - FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, - FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, - FX_FLOAT fBigStep) = 0; - // set the position of horizontal scrollbar. - virtual void IOnSetScrollPosX(FX_FLOAT fx) = 0; - // set the position of vertical scrollbar. - virtual void IOnSetScrollPosY(FX_FLOAT fy) = 0; - // set the caret information. - virtual void IOnSetCaret(FX_BOOL bVisible, - const CFX_FloatPoint& ptHead, - const CFX_FloatPoint& ptFoot, - const CPVT_WordPlace& place) = 0; - // if the caret position is changed ,send the information of current postion - // to user. - virtual void IOnCaretChange(const CPVT_SecProps& secProps, - const CPVT_WordProps& wordProps) = 0; - // if the text area is changed, send the information to user. - virtual void IOnContentChange(const CFX_FloatRect& rcContent) = 0; - // Invalidate the rectangle relative to the bounding box of edit. - virtual void IOnInvalidateRect(CFX_FloatRect* pRect) = 0; -}; - -class IFX_Edit_OprNotify { - public: - virtual ~IFX_Edit_OprNotify() {} - - // OprType: 0 - virtual void OnInsertWord(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) = 0; - // OprType: 1 - virtual void OnInsertReturn(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) = 0; - // OprType: 2 - virtual void OnBackSpace(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) = 0; - // OprType: 3 - virtual void OnDelete(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) = 0; - // OprType: 4 - virtual void OnClear(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) = 0; - // OprType: 5 - virtual void OnInsertText(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) = 0; - // OprType: 6 - virtual void OnSetText(const CPVT_WordPlace& place, - const CPVT_WordPlace& oldplace) = 0; - // - virtual void OnAddUndo(IFX_Edit_UndoItem* pUndoItem) = 0; -}; - -class IFX_Edit_Iterator { - public: - virtual ~IFX_Edit_Iterator() {} - - public: - // move the current position to the next word. - virtual FX_BOOL NextWord() = 0; - // move the current position to the next line. - virtual FX_BOOL NextLine() = 0; - // move the current position to the next section. - virtual FX_BOOL NextSection() = 0; - - // move the current position to the previous word. - virtual FX_BOOL PrevWord() = 0; - // move the current position to the previous line. - virtual FX_BOOL PrevLine() = 0; - // move the current position to the previous section. - virtual FX_BOOL PrevSection() = 0; - - // get the information of the current word. - virtual FX_BOOL GetWord(CPVT_Word& word) const = 0; - // get the information of the current line. - virtual FX_BOOL GetLine(CPVT_Line& line) const = 0; - // get the information of the current section. - virtual FX_BOOL GetSection(CPVT_Section& section) const = 0; - // set the current position. - virtual void SetAt(int32_t nWordIndex) = 0; - // set the current position. - virtual void SetAt(const CPVT_WordPlace& place) = 0; - // get the current position. - virtual const CPVT_WordPlace& GetAt() const = 0; - - // get the edit which this iterator belongs to - virtual IFX_Edit* GetEdit() const = 0; -}; - -class IFX_Edit_UndoItem { - public: - virtual ~IFX_Edit_UndoItem() {} - - virtual void Undo() = 0; - virtual void Redo() = 0; - virtual CFX_WideString GetUndoTitle() = 0; -}; - -class IFX_Edit { - public: - static IFX_Edit* NewEdit(); - static void DelEdit(IFX_Edit* pEdit); - - // set a IPVT_FontMap pointer implemented by user. - virtual void SetFontMap(IPVT_FontMap* pFontMap) = 0; - - // if user don't like to use FontMap, implement VTProvider and set it - // directly. - virtual void SetVTProvider(CPDF_VariableText::Provider* pProvider) = 0; - - // set a IFX_Edit_Notify pointer implemented by user. - virtual void SetNotify(IFX_Edit_Notify* pNotify) = 0; - virtual void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) = 0; - - // get a pointer allocated by CPDF_Edit, by this pointer, user can iterate the - // contents of edit, but don't need to release. - virtual IFX_Edit_Iterator* GetIterator() = 0; - - // get a VT pointer relative to this edit. - virtual CPDF_VariableText* GetVariableText() = 0; - - // get the IPVT_FontMap pointer set by user. - virtual IPVT_FontMap* GetFontMap() = 0; - - // initialize the edit. - virtual void Initialize() = 0; - - // set the bounding box of the text area. - virtual void SetPlateRect(const CFX_FloatRect& rect, - FX_BOOL bPaint = TRUE) = 0; - - // set the scroll origin - virtual void SetScrollPos(const CFX_FloatPoint& point) = 0; - - // set the horizontal text alignment in text box, nFormat (0:left 1:middle - // 2:right). - virtual void SetAlignmentH(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) = 0; - - // set the vertical text alignment in text box, nFormat (0:top 1:center - // 2:bottom). - virtual void SetAlignmentV(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) = 0; - - // if the text is shown in secret , set a character for substitute. - virtual void SetPasswordChar(uint16_t wSubWord = '*', - FX_BOOL bPaint = TRUE) = 0; - - // set the maximal count of words of the text. - virtual void SetLimitChar(int32_t nLimitChar = 0, FX_BOOL bPaint = TRUE) = 0; - - // if set the count of charArray , then all words is shown in equal space. - virtual void SetCharArray(int32_t nCharArray = 0, FX_BOOL bPaint = TRUE) = 0; - - // set the space of two characters. - virtual void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, - FX_BOOL bPaint = TRUE) = 0; - - // set the horizontal scale of all characters. - virtual void SetHorzScale(int32_t nHorzScale = 100, - FX_BOOL bPaint = TRUE) = 0; - - // set the leading of all lines - virtual void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE) = 0; - - // if set, CRLF is allowed. - virtual void SetMultiLine(FX_BOOL bMultiLine = TRUE, - FX_BOOL bPaint = TRUE) = 0; - - // if set, all words auto fit the width of the bounding box. - virtual void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0; - - // if set, a font size is calculated to full fit the bounding box. - virtual void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0; - - // is set, the text is allowed to scroll. - virtual void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0; - - // set the font size of all words. - virtual void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE) = 0; - - // the text is allowed to auto-scroll, allow the text overflow? - virtual void SetTextOverflow(FX_BOOL bAllowed = FALSE, - FX_BOOL bPaint = TRUE) = 0; - - // query if the edit is richedit. - virtual FX_BOOL IsRichText() const = 0; - - // set the edit is richedit. - virtual void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE) = 0; - - // set the fontsize of selected text. - virtual FX_BOOL SetRichFontSize(FX_FLOAT fFontSize) = 0; - - // set the fontindex of selected text, user can change the font of selected - // text. - virtual FX_BOOL SetRichFontIndex(int32_t nFontIndex) = 0; - - // set the textcolor of selected text. - virtual FX_BOOL SetRichTextColor(FX_COLORREF dwColor) = 0; - - // set the text script type of selected text. (0:normal 1:superscript - // 2:subscript) - virtual FX_BOOL SetRichTextScript( - CPDF_VariableText::ScriptType nScriptType) = 0; - - // set the bold font style of selected text. - virtual FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE) = 0; - - // set the italic font style of selected text. - virtual FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE) = 0; - - // set the underline style of selected text. - virtual FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE) = 0; - - // set the crossout style of selected text. - virtual FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE) = 0; - - // set the charspace of selected text, in user coordinate. - virtual FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace) = 0; - - // set the horizontal scale of selected text, default value is 100. - virtual FX_BOOL SetRichTextHorzScale(int32_t nHorzScale = 100) = 0; - - // set the leading of selected section, in user coordinate. - virtual FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading) = 0; - - // set the indent of selected section, in user coordinate. - virtual FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent) = 0; - - // set the alignment of selected section, nAlignment(0:left 1:middle 2:right) - virtual FX_BOOL SetRichTextAlignment(int32_t nAlignment) = 0; - - // set the selected range of text. - // if nStartChar == 0 and nEndChar == -1, select all the text. - virtual void SetSel(int32_t nStartChar, int32_t nEndChar) = 0; - - // get the selected range of text. - virtual void GetSel(int32_t& nStartChar, int32_t& nEndChar) const = 0; - - // select all the text. - virtual void SelectAll() = 0; - - // set text is not selected. - virtual void SelectNone() = 0; - - // get the caret position. - virtual int32_t GetCaret() const = 0; - virtual CPVT_WordPlace GetCaretWordPlace() const = 0; - - // get the string of selected text. - virtual CFX_WideString GetSelText() const = 0; - - // get the text conent - virtual CFX_WideString GetText() const = 0; - - // query if any text is selected. - virtual FX_BOOL IsSelected() const = 0; - - // get the scroll origin - virtual CFX_FloatPoint GetScrollPos() const = 0; - - // get the bounding box of the text area. - virtual CFX_FloatRect GetPlateRect() const = 0; - - // get the fact area of the text. - virtual CFX_FloatRect GetContentRect() const = 0; - - // get the visible word range - virtual CPVT_WordRange GetVisibleWordRange() const = 0; - - // get the whole word range - virtual CPVT_WordRange GetWholeWordRange() const = 0; - - // get the word range of select text - virtual CPVT_WordRange GetSelectWordRange() const = 0; - - // send the mousedown message to edit for response. - // if Shift key is hold, bShift is TRUE, is Ctrl key is hold, bCtrl is TRUE. - virtual void OnMouseDown(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) = 0; - - // send the mousemove message to edit when mouse down is TRUE. - virtual void OnMouseMove(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) = 0; - - // send the UP key message to edit. - virtual void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - - // send the DOWN key message to edit. - virtual void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - - // send the LEFT key message to edit. - virtual void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - - // send the RIGHT key message to edit. - virtual void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - - // send the HOME key message to edit. - virtual void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - - // send the END key message to edit. - virtual void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - - // put text into edit. - virtual void SetText(const FX_WCHAR* text, - int32_t charset = DEFAULT_CHARSET, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL) = 0; - - // insert a word into the edit. - virtual FX_BOOL InsertWord(uint16_t word, - int32_t charset = DEFAULT_CHARSET, - const CPVT_WordProps* pWordProps = NULL) = 0; - - // insert a return into the edit. - virtual FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL) = 0; - - // insert text into the edit. - virtual FX_BOOL InsertText(const FX_WCHAR* text, - int32_t charset = DEFAULT_CHARSET, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL) = 0; - - // do backspace operation. - virtual FX_BOOL Backspace() = 0; - - // do delete operation. - virtual FX_BOOL Delete() = 0; - - // delete the selected text. - virtual FX_BOOL Clear() = 0; - - // do Redo operation. - virtual FX_BOOL Redo() = 0; - - // do Undo operation. - virtual FX_BOOL Undo() = 0; - - // move caret - virtual void SetCaret(int32_t nPos) = 0; - - // arrange all words over again - virtual void Paint() = 0; - - // allow to refresh screen? - virtual void EnableRefresh(FX_BOOL bRefresh) = 0; - - virtual void RefreshWordRange(const CPVT_WordRange& wr) = 0; - - // allow undo/redo? - virtual void EnableUndo(FX_BOOL bUndo) = 0; - - // allow notify? - virtual void EnableNotify(FX_BOOL bNotify) = 0; - - // allow opr notify? - virtual void EnableOprNotify(FX_BOOL bNotify) = 0; - - // map word place to word index. - virtual int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const = 0; - // map word index to word place. - virtual CPVT_WordPlace WordIndexToWordPlace(int32_t index) const = 0; - - // get the beginning position of a line - virtual CPVT_WordPlace GetLineBeginPlace( - const CPVT_WordPlace& place) const = 0; - - // get the ending position of a line - virtual CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const = 0; - - // get the beginning position of a section - virtual CPVT_WordPlace GetSectionBeginPlace( - const CPVT_WordPlace& place) const = 0; - - // get the ending position of a section - virtual CPVT_WordPlace GetSectionEndPlace( - const CPVT_WordPlace& place) const = 0; - - // search a wordplace form point - virtual CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const = 0; - - // get the font size of non_rich text or default font size of richtext. - virtual FX_FLOAT GetFontSize() const = 0; - - // get the mask character. - virtual uint16_t GetPasswordChar() const = 0; - - // get the count of charArray - virtual int32_t GetCharArray() const = 0; - - // get the horizontal scale of all characters - virtual int32_t GetHorzScale() const = 0; - - // get the space of two characters - virtual FX_FLOAT GetCharSpace() const = 0; - - // get the latin words of specified range - virtual CFX_WideString GetRangeText(const CPVT_WordRange& range) const = 0; - - // is the text full in bounding box - virtual FX_BOOL IsTextFull() const = 0; - virtual FX_BOOL CanUndo() const = 0; - virtual FX_BOOL CanRedo() const = 0; - - // if the content is changed after settext? - virtual FX_BOOL IsModified() const = 0; - - // get the total words in edit - virtual int32_t GetTotalWords() const = 0; - - virtual void AddUndoItem(IFX_Edit_UndoItem* pUndoItem) = 0; - - static CFX_ByteString GetEditAppearanceStream( - IFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange = NULL, - FX_BOOL bContinuous = TRUE, - uint16_t SubWord = 0); - static CFX_ByteString GetSelectAppearanceStream( - IFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange = NULL); - static void DrawEdit(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - IFX_Edit* pEdit, - FX_COLORREF crTextFill, - FX_COLORREF crTextStroke, - const CFX_FloatRect& rcClip, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - IFX_SystemHandler* pSystemHandler, - void* pFFLData); - static void DrawUnderline(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - IFX_Edit* pEdit, - FX_COLORREF color, - const CFX_FloatRect& rcClip, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange); - static void DrawRichEdit(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - IFX_Edit* pEdit, - const CFX_FloatRect& rcClip, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange); - static void GeneratePageObjects( - CPDF_PageObjectHolder* pObjectHolder, - IFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - FX_COLORREF crText, - CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray); - static void GenerateRichPageObjects( - CPDF_PageObjectHolder* pObjectHolder, - IFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray); - static void GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder, - IFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - FX_COLORREF color); - - protected: - virtual ~IFX_Edit() {} -}; - -class IFX_List_Notify { - public: - // set the horizontal scrollbar information. - virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, - FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, - FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, - FX_FLOAT fBigStep) = 0; - // set the vertical scrollbar information. - virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, - FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, - FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, - FX_FLOAT fBigStep) = 0; - // set the position of horizontal scrollbar. - virtual void IOnSetScrollPosX(FX_FLOAT fx) = 0; - // set the position of vertical scrollbar. - virtual void IOnSetScrollPosY(FX_FLOAT fy) = 0; - // Invalidate the rectangle relative to the bounding box of edit. - virtual void IOnInvalidateRect(CFX_FloatRect* pRect) = 0; - - protected: - virtual ~IFX_List_Notify() {} -}; - -class IFX_List { - public: - static IFX_List* NewList(); - static void DelList(IFX_List* pList); - - virtual void SetFontMap(IPVT_FontMap* pFontMap) = 0; - virtual void SetNotify(IFX_List_Notify* pNotify) = 0; - - virtual void SetPlateRect(const CFX_FloatRect& rect) = 0; - virtual void SetFontSize(FX_FLOAT fFontSize) = 0; - - virtual CFX_FloatRect GetPlateRect() const = 0; - virtual CFX_FloatRect GetContentRect() const = 0; - - virtual FX_FLOAT GetFontSize() const = 0; - virtual IFX_Edit* GetItemEdit(int32_t nIndex) const = 0; - virtual int32_t GetCount() const = 0; - virtual FX_BOOL IsItemSelected(int32_t nIndex) const = 0; - virtual FX_FLOAT GetFirstHeight() const = 0; - - virtual void SetMultipleSel(FX_BOOL bMultiple) = 0; - virtual FX_BOOL IsMultipleSel() const = 0; - virtual FX_BOOL IsValid(int32_t nItemIndex) const = 0; - virtual int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const = 0; - - virtual void SetScrollPos(const CFX_FloatPoint& point) = 0; - virtual void ScrollToListItem(int32_t nItemIndex) = 0; - virtual CFX_FloatRect GetItemRect(int32_t nIndex) const = 0; - virtual int32_t GetCaret() const = 0; - virtual int32_t GetSelect() const = 0; - virtual int32_t GetTopItem() const = 0; - virtual int32_t GetItemIndex(const CFX_FloatPoint& point) const = 0; - virtual int32_t GetFirstSelected() const = 0; - - virtual void AddString(const FX_WCHAR* str) = 0; - virtual void SetTopItem(int32_t nIndex) = 0; - virtual void Select(int32_t nItemIndex) = 0; - virtual void SetCaret(int32_t nItemIndex) = 0; - virtual void Empty() = 0; - virtual void Cancel() = 0; - virtual CFX_WideString GetText() const = 0; - - virtual void OnMouseDown(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) = 0; - virtual void OnMouseMove(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) = 0; - virtual void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - virtual void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - virtual void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - virtual void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - virtual void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - virtual void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) = 0; - virtual void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl) = 0; - virtual FX_BOOL OnChar(uint16_t nChar, FX_BOOL bShift, FX_BOOL bCtrl) = 0; - - protected: - virtual ~IFX_List() {} -}; - -CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap, - int32_t nFontIndex, - uint16_t Word, - uint16_t SubWord); - -#endif // FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_ diff --git a/fpdfsdk/include/fxedit/fxet_edit.h b/fpdfsdk/include/fxedit/fxet_edit.h deleted file mode 100644 index fb6c917582..0000000000 --- a/fpdfsdk/include/fxedit/fxet_edit.h +++ /dev/null @@ -1,804 +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 FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ -#define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ - -#include "core/fpdfdoc/include/cpvt_secprops.h" -#include "core/fpdfdoc/include/cpvt_wordprops.h" -#include "fpdfsdk/include/fxedit/fx_edit.h" - -class CFX_Edit; -class CFX_Edit_Iterator; -class CFX_Edit_Provider; - -#define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001) -#define FX_EDIT_IsFloatEqual(fa, fb) FX_EDIT_IsFloatZero(fa - fb) -#define FX_EDIT_IsFloatBigger(fa, fb) (fa > fb && !FX_EDIT_IsFloatEqual(fa, fb)) -#define FX_EDIT_IsFloatSmaller(fa, fb) \ - (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb)) - -enum REFRESH_PLAN_E { RP_ANALYSE, RP_NOANALYSE, RP_OPTIONAL }; - -enum EDIT_PROPS_E { - EP_LINELEADING, - EP_LINEINDENT, - EP_ALIGNMENT, - EP_FONTINDEX, - EP_FONTSIZE, - EP_WORDCOLOR, - EP_SCRIPTTYPE, - EP_UNDERLINE, - EP_CROSSOUT, - EP_CHARSPACE, - EP_HORZSCALE, - EP_BOLD, - EP_ITALIC -}; - -struct CFX_Edit_LineRect { - CFX_Edit_LineRect(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine) - : m_wrLine(wrLine), m_rcLine(rcLine) {} - - FX_BOOL operator!=(const CFX_Edit_LineRect& linerect) const { - return FXSYS_memcmp(this, &linerect, sizeof(CFX_Edit_LineRect)) != 0; - } - - FX_BOOL IsSameHeight(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero( - (m_rcLine.top - m_rcLine.bottom) - - (linerect.m_rcLine.top - linerect.m_rcLine.bottom)); - } - - FX_BOOL IsSameTop(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero(m_rcLine.top - linerect.m_rcLine.top); - } - - FX_BOOL IsSameLeft(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero(m_rcLine.left - linerect.m_rcLine.left); - } - - FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const { - return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right); - } - - CPVT_WordRange m_wrLine; - CFX_FloatRect m_rcLine; -}; - -class CFX_Edit_LineRectArray { - public: - CFX_Edit_LineRectArray() {} - - virtual ~CFX_Edit_LineRectArray() { Empty(); } - - void Empty() { - for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++) - delete m_LineRects.GetAt(i); - - m_LineRects.RemoveAll(); - } - - void RemoveAll() { m_LineRects.RemoveAll(); } - - void operator=(CFX_Edit_LineRectArray& rects) { - Empty(); - for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++) - m_LineRects.Add(rects.GetAt(i)); - - rects.RemoveAll(); - } - - void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine) { - m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine)); - } - - int32_t GetSize() const { return m_LineRects.GetSize(); } - - CFX_Edit_LineRect* GetAt(int32_t nIndex) const { - if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) - return NULL; - - return m_LineRects.GetAt(nIndex); - } - - CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; -}; - -class CFX_Edit_RectArray { - public: - CFX_Edit_RectArray() {} - - virtual ~CFX_Edit_RectArray() { Empty(); } - - void Empty() { - for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) - delete m_Rects.GetAt(i); - - m_Rects.RemoveAll(); - } - - void Add(const CFX_FloatRect& rect) { - // check for overlapped area - for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { - CFX_FloatRect* pRect = m_Rects.GetAt(i); - if (pRect && pRect->Contains(rect)) - return; - } - - m_Rects.Add(new CFX_FloatRect(rect)); - } - - int32_t GetSize() const { return m_Rects.GetSize(); } - - CFX_FloatRect* GetAt(int32_t nIndex) const { - if (nIndex < 0 || nIndex >= m_Rects.GetSize()) - return NULL; - - return m_Rects.GetAt(nIndex); - } - - CFX_ArrayTemplate<CFX_FloatRect*> m_Rects; -}; - -class CFX_Edit_Refresh { - public: - CFX_Edit_Refresh(); - virtual ~CFX_Edit_Refresh(); - - void BeginRefresh(); - void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect); - void NoAnalyse(); - void Analyse(int32_t nAlignment); - void AddRefresh(const CFX_FloatRect& rect); - const CFX_Edit_RectArray* GetRefreshRects() const; - void EndRefresh(); - - private: - CFX_Edit_LineRectArray m_NewLineRects; - CFX_Edit_LineRectArray m_OldLineRects; - CFX_Edit_RectArray m_RefreshRects; -}; - -class CFX_Edit_Select { - public: - CFX_Edit_Select() {} - - CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { - Set(begin, end); - } - - explicit CFX_Edit_Select(const CPVT_WordRange& range) { - Set(range.BeginPos, range.EndPos); - } - - CPVT_WordRange ConvertToWordRange() const { - return CPVT_WordRange(BeginPos, EndPos); - } - - void Default() { - BeginPos.Default(); - EndPos.Default(); - } - - void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { - BeginPos = begin; - EndPos = end; - } - - void SetBeginPos(const CPVT_WordPlace& begin) { BeginPos = begin; } - - void SetEndPos(const CPVT_WordPlace& end) { EndPos = end; } - - FX_BOOL IsExist() const { return BeginPos != EndPos; } - - FX_BOOL operator!=(const CPVT_WordRange& wr) const { - return wr.BeginPos != BeginPos || wr.EndPos != EndPos; - } - - CPVT_WordPlace BeginPos, EndPos; -}; - -class CFX_Edit_Undo { - public: - explicit CFX_Edit_Undo(int32_t nBufsize); - virtual ~CFX_Edit_Undo(); - - void Undo(); - void Redo(); - - void AddItem(IFX_Edit_UndoItem* pItem); - - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - FX_BOOL IsModified() const; - FX_BOOL IsWorking() const; - - void Reset(); - - IFX_Edit_UndoItem* GetItem(int32_t nIndex); - int32_t GetItemCount() { return m_UndoItemStack.GetSize(); } - int32_t GetCurUndoPos() { return m_nCurUndoPos; } - - private: - void SetBufSize(int32_t nSize) { m_nBufSize = nSize; } - int32_t GetBufSize() { return m_nBufSize; } - - void RemoveHeads(); - void RemoveTails(); - - private: - CFX_ArrayTemplate<IFX_Edit_UndoItem*> m_UndoItemStack; - - int32_t m_nCurUndoPos; - int32_t m_nBufSize; - FX_BOOL m_bModified; - FX_BOOL m_bVirgin; - FX_BOOL m_bWorking; -}; - -class CFX_Edit_UndoItem : public IFX_Edit_UndoItem { - public: - CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} - ~CFX_Edit_UndoItem() override {} - - CFX_WideString GetUndoTitle() override { return L""; } - - void SetFirst(FX_BOOL bFirst) { m_bFirst = bFirst; } - FX_BOOL IsFirst() { return m_bFirst; } - void SetLast(FX_BOOL bLast) { m_bLast = bLast; } - FX_BOOL IsLast() { return m_bLast; } - - private: - FX_BOOL m_bFirst; - FX_BOOL m_bLast; -}; - -class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { - public: - explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); - ~CFX_Edit_GroupUndoItem() override; - - void Undo() override; - void Redo() override; - CFX_WideString GetUndoTitle() override; - - void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); - void UpdateItems(); - - private: - CFX_WideString m_sTitle; - CFX_ArrayTemplate<CFX_Edit_UndoItem*> m_Items; -}; - -class CFXEU_InsertWord : public CFX_Edit_UndoItem { - public: - CFXEU_InsertWord(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - uint16_t word, - int32_t charset, - const CPVT_WordProps* pWordProps); - ~CFXEU_InsertWord() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - uint16_t m_Word; - int32_t m_nCharset; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_InsertReturn : public CFX_Edit_UndoItem { - public: - CFXEU_InsertReturn(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps); - ~CFXEU_InsertReturn() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_Backspace : public CFX_Edit_UndoItem { - public: - CFXEU_Backspace(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - uint16_t word, - int32_t charset, - const CPVT_SecProps& SecProps, - const CPVT_WordProps& WordProps); - ~CFXEU_Backspace() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - uint16_t m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_Delete : public CFX_Edit_UndoItem { - public: - CFXEU_Delete(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - uint16_t word, - int32_t charset, - const CPVT_SecProps& SecProps, - const CPVT_WordProps& WordProps, - FX_BOOL bSecEnd); - ~CFXEU_Delete() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - uint16_t m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; - FX_BOOL m_bSecEnd; -}; - -class CFXEU_Clear : public CFX_Edit_UndoItem { - public: - CFXEU_Clear(CFX_Edit* pEdit, - const CPVT_WordRange& wrSel, - const CFX_WideString& swText); - ~CFXEU_Clear() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordRange m_wrSel; - CFX_WideString m_swText; -}; - -class CFXEU_ClearRich : public CFX_Edit_UndoItem { - public: - CFXEU_ClearRich(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - const CPVT_WordRange& wrSel, - uint16_t word, - int32_t charset, - const CPVT_SecProps& SecProps, - const CPVT_WordProps& WordProps); - ~CFXEU_ClearRich() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CPVT_WordRange m_wrSel; - uint16_t m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_InsertText : public CFX_Edit_UndoItem { - public: - CFXEU_InsertText(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - const CFX_WideString& swText, - int32_t charset, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps); - ~CFXEU_InsertText() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CFX_WideString m_swText; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_SetSecProps : public CFX_Edit_UndoItem { - public: - CFXEU_SetSecProps(CFX_Edit* pEdit, - const CPVT_WordPlace& place, - EDIT_PROPS_E ep, - const CPVT_SecProps& oldsecprops, - const CPVT_WordProps& oldwordprops, - const CPVT_SecProps& newsecprops, - const CPVT_WordProps& newwordprops, - const CPVT_WordRange& range); - ~CFXEU_SetSecProps() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - CPVT_WordPlace m_wpPlace; - CPVT_WordRange m_wrPlace; - EDIT_PROPS_E m_eProps; - - CPVT_SecProps m_OldSecProps; - CPVT_SecProps m_NewSecProps; - CPVT_WordProps m_OldWordProps; - CPVT_WordProps m_NewWordProps; -}; - -class CFXEU_SetWordProps : public CFX_Edit_UndoItem { - public: - CFXEU_SetWordProps(CFX_Edit* pEdit, - const CPVT_WordPlace& place, - EDIT_PROPS_E ep, - const CPVT_WordProps& oldprops, - const CPVT_WordProps& newprops, - const CPVT_WordRange& range); - ~CFXEU_SetWordProps() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - CPVT_WordPlace m_wpPlace; - CPVT_WordRange m_wrPlace; - EDIT_PROPS_E m_eProps; - - CPVT_WordProps m_OldWordProps; - CPVT_WordProps m_NewWordProps; -}; - -class CFX_Edit : public IFX_Edit { - friend class CFX_Edit_Iterator; - friend class CFXEU_InsertWord; - friend class CFXEU_InsertReturn; - friend class CFXEU_Backspace; - friend class CFXEU_Delete; - friend class CFXEU_Clear; - friend class CFXEU_ClearRich; - friend class CFXEU_SetSecProps; - friend class CFXEU_SetWordProps; - friend class CFXEU_InsertText; - - public: - explicit CFX_Edit(CPDF_VariableText* pVT); - ~CFX_Edit() override; - - // IFX_Edit - void SetFontMap(IPVT_FontMap* pFontMap) override; - void SetVTProvider(CPDF_VariableText::Provider* pProvider) override; - void SetNotify(IFX_Edit_Notify* pNotify) override; - void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) override; - IFX_Edit_Iterator* GetIterator() override; - CPDF_VariableText* GetVariableText() override; - IPVT_FontMap* GetFontMap() override; - void Initialize() override; - void SetPlateRect(const CFX_FloatRect& rect, FX_BOOL bPaint = TRUE) override; - void SetScrollPos(const CFX_FloatPoint& point) override; - void SetAlignmentH(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) override; - void SetAlignmentV(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) override; - void SetPasswordChar(uint16_t wSubWord = '*', FX_BOOL bPaint = TRUE) override; - void SetLimitChar(int32_t nLimitChar = 0, FX_BOOL bPaint = TRUE) override; - void SetCharArray(int32_t nCharArray = 0, FX_BOOL bPaint = TRUE) override; - void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, FX_BOOL bPaint = TRUE) override; - void SetHorzScale(int32_t nHorzScale = 100, FX_BOOL bPaint = TRUE) override; - void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE) override; - void SetMultiLine(FX_BOOL bMultiLine = TRUE, FX_BOOL bPaint = TRUE) override; - void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override; - void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override; - void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override; - void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE) override; - void SetTextOverflow(FX_BOOL bAllowed = FALSE, - FX_BOOL bPaint = TRUE) override; - FX_BOOL IsRichText() const override; - void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE) override; - FX_BOOL SetRichFontSize(FX_FLOAT fFontSize) override; - FX_BOOL SetRichFontIndex(int32_t nFontIndex) override; - FX_BOOL SetRichTextColor(FX_COLORREF dwColor) override; - FX_BOOL SetRichTextScript(CPDF_VariableText::ScriptType nScriptType) override; - FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE) override; - FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE) override; - FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE) override; - FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE) override; - FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace) override; - FX_BOOL SetRichTextHorzScale(int32_t nHorzScale = 100) override; - FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading) override; - FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent) override; - FX_BOOL SetRichTextAlignment(int32_t nAlignment) override; - void OnMouseDown(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) override; - void OnMouseMove(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) override; - void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) override; - void SetText(const FX_WCHAR* text, - int32_t charset = DEFAULT_CHARSET, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL) override; - FX_BOOL InsertWord(uint16_t word, - int32_t charset = DEFAULT_CHARSET, - const CPVT_WordProps* pWordProps = NULL) override; - FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL) override; - FX_BOOL Backspace() override; - FX_BOOL Delete() override; - FX_BOOL Clear() override; - FX_BOOL InsertText(const FX_WCHAR* text, - int32_t charset = DEFAULT_CHARSET, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL) override; - FX_BOOL Redo() override; - FX_BOOL Undo() override; - int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override; - CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override; - CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override; - CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override; - CPVT_WordPlace GetSectionBeginPlace( - const CPVT_WordPlace& place) const override; - CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override; - CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const override; - int32_t GetCaret() const override; - CPVT_WordPlace GetCaretWordPlace() const override; - CFX_WideString GetSelText() const override; - CFX_WideString GetText() const override; - FX_FLOAT GetFontSize() const override; - uint16_t GetPasswordChar() const override; - CFX_FloatPoint GetScrollPos() const override; - int32_t GetCharArray() const override; - CFX_FloatRect GetPlateRect() const override; - CFX_FloatRect GetContentRect() const override; - CFX_WideString GetRangeText(const CPVT_WordRange& range) const override; - int32_t GetHorzScale() const override; - FX_FLOAT GetCharSpace() const override; - int32_t GetTotalWords() const override; - void SetSel(int32_t nStartChar, int32_t nEndChar) override; - void GetSel(int32_t& nStartChar, int32_t& nEndChar) const override; - void SelectAll() override; - void SelectNone() override; - FX_BOOL IsSelected() const override; - void Paint() override; - void EnableNotify(FX_BOOL bNotify) override; - void EnableRefresh(FX_BOOL bRefresh) override; - void RefreshWordRange(const CPVT_WordRange& wr) override; - void SetCaret(int32_t nPos) override; - CPVT_WordRange GetWholeWordRange() const override; - CPVT_WordRange GetSelectWordRange() const override; - void EnableUndo(FX_BOOL bUndo) override; - void EnableOprNotify(FX_BOOL bNotify) override; - FX_BOOL IsTextFull() const override; - FX_BOOL IsTextOverflow() const; - FX_BOOL CanUndo() const override; - FX_BOOL CanRedo() const override; - FX_BOOL IsModified() const override; - CPVT_WordRange GetVisibleWordRange() const override; - void AddUndoItem(IFX_Edit_UndoItem* pUndoItem) override; - - FX_BOOL Empty(); - - CPVT_WordPlace DoInsertText(const CPVT_WordPlace& place, - const FX_WCHAR* text, - int32_t charset, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps); - int32_t GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset); - - int32_t GetTotalLines() const; - - private: - void SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); - - void RearrangeAll(); - void RearrangePart(const CPVT_WordRange& range); - void ScrollToCaret(); - void SetScrollInfo(); - void SetScrollPosX(FX_FLOAT fx); - void SetScrollPosY(FX_FLOAT fy); - void SetScrollLimit(); - void SetContentChanged(); - - void SetText(const FX_WCHAR* text, - int32_t charset, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps, - FX_BOOL bAddUndo, - FX_BOOL bPaint); - FX_BOOL InsertWord(uint16_t word, - int32_t charset, - const CPVT_WordProps* pWordProps, - FX_BOOL bAddUndo, - FX_BOOL bPaint); - FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps, - FX_BOOL bAddUndo, - FX_BOOL bPaint); - FX_BOOL Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL Delete(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL Clear(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL InsertText(const FX_WCHAR* text, - int32_t charset, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps, - FX_BOOL bAddUndo, - FX_BOOL bPaint); - FX_BOOL SetRichTextProps(EDIT_PROPS_E eProps, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps); - FX_BOOL SetSecProps(EDIT_PROPS_E eProps, - const CPVT_WordPlace& place, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps, - const CPVT_WordRange& wr, - FX_BOOL bAddUndo); - FX_BOOL SetWordProps(EDIT_PROPS_E eProps, - const CPVT_WordPlace& place, - const CPVT_WordProps* pWordProps, - const CPVT_WordRange& wr, - FX_BOOL bAddUndo); - void PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange& wr); - void PaintInsertText(const CPVT_WordPlace& wpOld, - const CPVT_WordPlace& wpNew); - - inline CFX_FloatPoint VTToEdit(const CFX_FloatPoint& point) const; - inline CFX_FloatPoint EditToVT(const CFX_FloatPoint& point) const; - inline CFX_FloatRect VTToEdit(const CFX_FloatRect& rect) const; - inline CFX_FloatRect EditToVT(const CFX_FloatRect& rect) const; - - void Refresh(REFRESH_PLAN_E ePlan, - const CPVT_WordRange* pRange1 = NULL, - const CPVT_WordRange* pRange2 = NULL); - void RefreshPushLineRects(const CPVT_WordRange& wr); - void RefreshPushRandomRects(const CPVT_WordRange& wr); - - void SetCaret(const CPVT_WordPlace& place); - void SetCaretInfo(); - void SetCaretOrigin(); - void SetCaretChange(); - - CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace& place) const; - CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1, - const CPVT_WordRange& wr2); - - - void BeginGroupUndo(const CFX_WideString& sTitle); - void EndGroupUndo(); - void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem); - - void SetPageInfo(const CPVT_WordPlace& place); - CPVT_WordPlace SearchPageEndPlace(const CPVT_WordPlace& wpPageBegin, - const CFX_FloatPoint& point) const; - FX_FLOAT GetLineTop(const CPVT_WordPlace& place) const; - FX_FLOAT GetLineBottom(const CPVT_WordPlace& place) const; - - private: - CPDF_VariableText* m_pVT; - IFX_Edit_Notify* m_pNotify; - IFX_Edit_OprNotify* m_pOprNotify; - CFX_Edit_Provider* m_pVTProvide; - - CPVT_WordPlace m_wpCaret; - CPVT_WordPlace m_wpOldCaret; - CFX_Edit_Select m_SelState; - - CFX_FloatPoint m_ptScrollPos; - CFX_FloatPoint m_ptRefreshScrollPos; - FX_BOOL m_bEnableScroll; - IFX_Edit_Iterator* m_pIterator; - CFX_Edit_Refresh m_Refresh; - CFX_FloatPoint m_ptCaret; - CFX_Edit_Undo m_Undo; - int32_t m_nAlignment; - FX_BOOL m_bNotifyFlag; - FX_BOOL m_bEnableOverflow; - FX_BOOL m_bEnableRefresh; - CFX_FloatRect m_rcOldContent; - FX_BOOL m_bEnableUndo; - FX_BOOL m_bNotify; - FX_BOOL m_bOprNotify; - CFX_Edit_GroupUndoItem* m_pGroupUndoItem; -}; - -class CFX_Edit_Iterator : public IFX_Edit_Iterator { - public: - CFX_Edit_Iterator(CFX_Edit* pEdit, CPDF_VariableText::Iterator* pVTIterator); - ~CFX_Edit_Iterator() override; - - // IFX_Edit_Iterator - FX_BOOL NextWord() override; - FX_BOOL NextLine() override; - FX_BOOL NextSection() override; - FX_BOOL PrevWord() override; - FX_BOOL PrevLine() override; - FX_BOOL PrevSection() override; - FX_BOOL GetWord(CPVT_Word& word) const override; - FX_BOOL GetLine(CPVT_Line& line) const override; - FX_BOOL GetSection(CPVT_Section& section) const override; - void SetAt(int32_t nWordIndex) override; - void SetAt(const CPVT_WordPlace& place) override; - const CPVT_WordPlace& GetAt() const override; - IFX_Edit* GetEdit() const override; - - private: - CFX_Edit* m_pEdit; - CPDF_VariableText::Iterator* m_pVTIterator; -}; - -class CFX_Edit_Provider : public CPDF_VariableText::Provider { - public: - explicit CFX_Edit_Provider(IPVT_FontMap* pFontMap); - ~CFX_Edit_Provider() override; - - IPVT_FontMap* GetFontMap(); - - // CPDF_VariableText::Provider: - int32_t GetCharWidth(int32_t nFontIndex, - uint16_t word, - int32_t nWordStyle) override; - int32_t GetTypeAscent(int32_t nFontIndex) override; - int32_t GetTypeDescent(int32_t nFontIndex) override; - int32_t GetWordFontIndex(uint16_t word, - int32_t charset, - int32_t nFontIndex) override; - int32_t GetDefaultFontIndex() override; - FX_BOOL IsLatinWord(uint16_t word) override; - - private: - IPVT_FontMap* m_pFontMap; -}; - -#endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ diff --git a/fpdfsdk/include/fxedit/fxet_list.h b/fpdfsdk/include/fxedit/fxet_list.h deleted file mode 100644 index 0018f13b46..0000000000 --- a/fpdfsdk/include/fxedit/fxet_list.h +++ /dev/null @@ -1,343 +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 FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_ -#define FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_ - -#include "fpdfsdk/include/fxedit/fx_edit.h" - -class IFX_Edit; - -class CLST_Size { - public: - CLST_Size() : x(0.0f), y(0.0f) {} - - CLST_Size(FX_FLOAT other_x, FX_FLOAT other_y) { - x = other_x; - y = other_y; - } - - void Default() { - x = 0.0f; - y = 0.0f; - } - - FX_BOOL operator!=(const CLST_Size& size) const { - return FXSYS_memcmp(this, &size, sizeof(CLST_Size)) != 0; - } - - FX_FLOAT x, y; -}; - -class CLST_Rect : public CFX_FloatRect { - public: - CLST_Rect() { left = top = right = bottom = 0.0f; } - - CLST_Rect(FX_FLOAT other_left, - FX_FLOAT other_top, - FX_FLOAT other_right, - FX_FLOAT other_bottom) { - left = other_left; - top = other_top; - right = other_right; - bottom = other_bottom; - } - - CLST_Rect(const CFX_FloatRect& rect) { - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; - } - - ~CLST_Rect() {} - - void Default() { left = top = right = bottom = 0.0f; } - - const CLST_Rect operator=(const CFX_FloatRect& rect) { - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; - - return *this; - } - - bool operator==(const CLST_Rect& rect) const { - return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0; - } - - bool operator!=(const CLST_Rect& rect) const { return !(*this == rect); } - - FX_FLOAT Width() const { return right - left; } - - FX_FLOAT Height() const { - if (top > bottom) - return top - bottom; - return bottom - top; - } - - CFX_FloatPoint LeftTop() const { return CFX_FloatPoint(left, top); } - - CFX_FloatPoint RightBottom() const { return CFX_FloatPoint(right, bottom); } - - const CLST_Rect operator+=(const CFX_FloatPoint& point) { - left += point.x; - right += point.x; - top += point.y; - bottom += point.y; - - return *this; - } - - const CLST_Rect operator-=(const CFX_FloatPoint& point) { - left -= point.x; - right -= point.x; - top -= point.y; - bottom -= point.y; - - return *this; - } - - CLST_Rect operator+(const CFX_FloatPoint& point) const { - return CLST_Rect(left + point.x, top + point.y, right + point.x, - bottom + point.y); - } - - CLST_Rect operator-(const CFX_FloatPoint& point) const { - return CLST_Rect(left - point.x, top - point.y, right - point.x, - bottom - point.y); - } -}; - -class CFX_ListItem { - public: - CFX_ListItem(); - virtual ~CFX_ListItem(); - - void SetFontMap(IPVT_FontMap* pFontMap); - IFX_Edit_Iterator* GetIterator() const; - IFX_Edit* GetEdit() const; - - public: - void SetRect(const CLST_Rect& rect); - void SetSelect(FX_BOOL bSelected); - void SetCaret(FX_BOOL bCaret); - void SetText(const FX_WCHAR* text); - void SetFontSize(FX_FLOAT fFontSize); - CFX_WideString GetText() const; - - CLST_Rect GetRect() const; - FX_BOOL IsSelected() const; - FX_BOOL IsCaret() const; - FX_FLOAT GetItemHeight() const; - uint16_t GetFirstChar() const; - - private: - IFX_Edit* m_pEdit; - FX_BOOL m_bSelected; - FX_BOOL m_bCaret; - CLST_Rect m_rcListItem; -}; - -class CFX_ListContainer { - public: - CFX_ListContainer() - : m_rcPlate(0.0f, 0.0f, 0.0f, 0.0f), - m_rcContent(0.0f, 0.0f, 0.0f, 0.0f) {} - virtual ~CFX_ListContainer() {} - virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; } - CFX_FloatRect GetPlateRect() const { return m_rcPlate; } - void SetContentRect(const CLST_Rect& rect) { m_rcContent = rect; } - CLST_Rect GetContentRect() const { return m_rcContent; } - CFX_FloatPoint GetBTPoint() const { - return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); - } - CFX_FloatPoint GetETPoint() const { - return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); - } - - public: - CFX_FloatPoint InnerToOuter(const CFX_FloatPoint& point) const { - return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); - } - CFX_FloatPoint OuterToInner(const CFX_FloatPoint& point) const { - return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); - } - CFX_FloatRect InnerToOuter(const CLST_Rect& rect) const { - CFX_FloatPoint ptLeftTop = - InnerToOuter(CFX_FloatPoint(rect.left, rect.top)); - CFX_FloatPoint ptRightBottom = - InnerToOuter(CFX_FloatPoint(rect.right, rect.bottom)); - return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, - ptLeftTop.y); - } - CLST_Rect OuterToInner(const CFX_FloatRect& rect) const { - CFX_FloatPoint ptLeftTop = - OuterToInner(CFX_FloatPoint(rect.left, rect.top)); - CFX_FloatPoint ptRightBottom = - OuterToInner(CFX_FloatPoint(rect.right, rect.bottom)); - return CLST_Rect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, - ptRightBottom.y); - } - - private: - CFX_FloatRect m_rcPlate; - CLST_Rect m_rcContent; // positive forever! -}; - -template <class TYPE> -class CLST_ArrayTemplate : public CFX_ArrayTemplate<TYPE> { - public: - FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; } - TYPE GetAt(int32_t nIndex) const { - if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) - return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); - return NULL; - } - void RemoveAt(int32_t nIndex) { - if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) - CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); - } -}; - -class CFX_List : protected CFX_ListContainer, public IFX_List { - public: - CFX_List(); - ~CFX_List() override; - - // IFX_List: - void SetFontMap(IPVT_FontMap* pFontMap) override; - void SetFontSize(FX_FLOAT fFontSize) override; - CFX_FloatRect GetPlateRect() const override; - CFX_FloatRect GetContentRect() const override; - FX_FLOAT GetFontSize() const override; - IFX_Edit* GetItemEdit(int32_t nIndex) const override; - int32_t GetCount() const override; - FX_BOOL IsItemSelected(int32_t nIndex) const override; - FX_FLOAT GetFirstHeight() const override; - void SetMultipleSel(FX_BOOL bMultiple) override; - FX_BOOL IsMultipleSel() const override; - FX_BOOL IsValid(int32_t nItemIndex) const override; - int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const override; - void Empty() override; - CFX_FloatRect GetItemRect(int32_t nIndex) const override; - int32_t GetItemIndex(const CFX_FloatPoint& point) const override; - int32_t GetFirstSelected() const override; - - protected: - void AddItem(const FX_WCHAR* str); - virtual void ReArrange(int32_t nItemIndex); - CFX_WideString GetItemText(int32_t nIndex) const; - void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected); - void SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret); - int32_t GetLastSelected() const; - FX_WCHAR Toupper(FX_WCHAR c) const; - - private: - CLST_ArrayTemplate<CFX_ListItem*> m_aListItems; - FX_FLOAT m_fFontSize; - IPVT_FontMap* m_pFontMap; - FX_BOOL m_bMultiple; -}; - -struct CPLST_Select_Item { - CPLST_Select_Item(int32_t other_nItemIndex, int32_t other_nState) { - nItemIndex = other_nItemIndex; - nState = other_nState; - } - - int32_t nItemIndex; - int32_t nState; // 0:normal select -1:to deselect 1: to select -}; - -class CPLST_Select { - public: - CPLST_Select(); - virtual ~CPLST_Select(); - - public: - void Add(int32_t nItemIndex); - void Add(int32_t nBeginIndex, int32_t nEndIndex); - void Sub(int32_t nItemIndex); - void Sub(int32_t nBeginIndex, int32_t nEndIndex); - FX_BOOL IsExist(int32_t nItemIndex) const; - int32_t Find(int32_t nItemIndex) const; - int32_t GetCount() const; - int32_t GetItemIndex(int32_t nIndex) const; - int32_t GetState(int32_t nIndex) const; - void Done(); - void DeselectAll(); - - private: - CFX_ArrayTemplate<CPLST_Select_Item*> m_aItems; -}; - -class CFX_ListCtrl : public CFX_List { - public: - CFX_ListCtrl(); - ~CFX_ListCtrl() override; - - // CFX_List - void SetNotify(IFX_List_Notify* pNotify) override; - void OnMouseDown(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) override; - void OnMouseMove(const CFX_FloatPoint& point, - FX_BOOL bShift, - FX_BOOL bCtrl) override; - void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) override; - void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl) override; - FX_BOOL OnChar(uint16_t nChar, FX_BOOL bShift, FX_BOOL bCtrl) override; - void SetPlateRect(const CFX_FloatRect& rect) override; - void SetScrollPos(const CFX_FloatPoint& point) override; - void ScrollToListItem(int32_t nItemIndex) override; - CFX_FloatRect GetItemRect(int32_t nIndex) const override; - int32_t GetCaret() const override { return m_nCaretIndex; } - int32_t GetSelect() const override { return m_nSelItem; } - int32_t GetTopItem() const override; - CFX_FloatRect GetContentRect() const override; - int32_t GetItemIndex(const CFX_FloatPoint& point) const override; - void AddString(const FX_WCHAR* str) override; - void SetTopItem(int32_t nIndex) override; - void Select(int32_t nItemIndex) override; - void SetCaret(int32_t nItemIndex) override; - void Empty() override; - void Cancel() override; - CFX_WideString GetText() const override; - void ReArrange(int32_t nItemIndex) override; - - virtual CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const; - virtual CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const; - virtual CFX_FloatRect InToOut(const CFX_FloatRect& rect) const; - virtual CFX_FloatRect OutToIn(const CFX_FloatRect& rect) const; - - private: - void SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected); - void SetSingleSelect(int32_t nItemIndex); - void InvalidateItem(int32_t nItemIndex); - void SelectItems(); - FX_BOOL IsItemVisible(int32_t nItemIndex) const; - void SetScrollInfo(); - void SetScrollPosY(FX_FLOAT fy); - - private: - IFX_List_Notify* m_pNotify; - FX_BOOL m_bNotifyFlag; - CFX_FloatPoint m_ptScrollPos; - CPLST_Select m_aSelItems; // for multiple - int32_t m_nSelItem; // for single - int32_t m_nFootIndex; // for multiple - FX_BOOL m_bCtrlSel; // for multiple - int32_t m_nCaretIndex; // for multiple -}; - -#endif // FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_ diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h deleted file mode 100644 index 00107ef7e5..0000000000 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ /dev/null @@ -1,305 +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 - -// FXJS_V8 is a layer that makes it easier to define native objects in V8, but -// has no knowledge of PDF-specific native objects. It could in theory be used -// to implement other sets of native objects. - -// PDFium code should include this file rather than including V8 headers -// directly. - -#ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ -#define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ - -#include <v8-util.h> -#include <v8.h> - -#include <vector> - -#include "core/fxcrt/include/fx_string.h" - -class CFXJS_ObjDefinition; - -// FXJS_V8 places no restrictions on these two classes; it merely passes them -// on to caller-provided methods. -class IJS_Context; // A description of the event that caused JS execution. -class IJS_Runtime; // A native runtime, typically owns the v8::Context. - -#ifdef PDF_ENABLE_XFA -// FXJS_V8 places no interpreation on this calass; it merely passes it -// along to XFA. -class CFXJSE_RuntimeData; -#endif // PDF_ENABLE_XFA - -enum FXJSOBJTYPE { - FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. - FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. - FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). -}; - -struct FXJSErr { - const wchar_t* message; - const wchar_t* srcline; - unsigned linnum; -}; - -// Global weak map to save dynamic objects. -class V8TemplateMapTraits : public v8::StdMapTraits<void*, v8::Object> { - public: - typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; - typedef void WeakCallbackDataType; - - static WeakCallbackDataType* WeakCallbackParameter( - MapType* map, - void* key, - const v8::Local<v8::Object>& value) { - return key; - } - static MapType* MapFromWeakCallbackInfo( - const v8::WeakCallbackInfo<WeakCallbackDataType>&); - - static void* KeyFromWeakCallbackInfo( - const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { - return data.GetParameter(); - } - static const v8::PersistentContainerCallbackType kCallbackType = - v8::kWeakWithInternalFields; - static void DisposeWeak( - const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} - static void OnWeakCallback( - const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} - static void Dispose(v8::Isolate* isolate, - v8::Global<v8::Object> value, - void* key); - static void DisposeCallbackData(WeakCallbackDataType* callbackData) {} -}; - -class V8TemplateMap { - public: - typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; - - void set(void* key, v8::Local<v8::Object> handle) { - ASSERT(!m_map.Contains(key)); - m_map.Set(key, handle); - } - explicit V8TemplateMap(v8::Isolate* isolate) : m_map(isolate) {} - friend class V8TemplateMapTraits; - - private: - MapType m_map; -}; - -class FXJS_PerIsolateData { - public: - static void SetUp(v8::Isolate* pIsolate); - static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); - void CreateDynamicObjsMap(v8::Isolate* pIsolate) { - if (!m_pDynamicObjsMap) - m_pDynamicObjsMap = new V8TemplateMap(pIsolate); - } - void ReleaseDynamicObjsMap() { - delete m_pDynamicObjsMap; - m_pDynamicObjsMap = nullptr; - } - - std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; -#ifdef PDF_ENABLE_XFA - CFXJSE_RuntimeData* m_pFXJSERuntimeData; -#endif // PDF_ENABLE_XFA - V8TemplateMap* m_pDynamicObjsMap; - - protected: -#ifndef PDF_ENABLE_XFA - FXJS_PerIsolateData() : m_pDynamicObjsMap(nullptr) {} -#else // PDF_ENABLE_XFA - FXJS_PerIsolateData() - : m_pFXJSERuntimeData(nullptr), m_pDynamicObjsMap(nullptr) {} -#endif // PDF_ENABLE_XFA -}; - -extern const wchar_t kFXJSValueNameString[]; -extern const wchar_t kFXJSValueNameNumber[]; -extern const wchar_t kFXJSValueNameBoolean[]; -extern const wchar_t kFXJSValueNameDate[]; -extern const wchar_t kFXJSValueNameObject[]; -extern const wchar_t kFXJSValueNameFxobj[]; -extern const wchar_t kFXJSValueNameNull[]; -extern const wchar_t kFXJSValueNameUndefined[]; - -class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { - void* Allocate(size_t length) override; - void* AllocateUninitialized(size_t length) override; - void Free(void* data, size_t length) override; -}; - -using FXJS_CONSTRUCTOR = void (*)(IJS_Runtime* cc, v8::Local<v8::Object> obj); -using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj); - -// Call before making FXJS_PrepareIsolate call. -void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); -void FXJS_Release(); - -// Gets the global isolate set by FXJS_Initialize(), or makes a new one each -// time if there is no such isolate. Returns true if a new isolate had to be -// created. -bool FXJS_GetIsolate(v8::Isolate** pResultIsolate); - -// Get the global isolate's ref count. -size_t FXJS_GlobalIsolateRefCount(); - -// Call before making FXJS_Define* calls. Resources allocated here are cleared -// as part of FXJS_ReleaseRuntime(). -void FXJS_PrepareIsolate(v8::Isolate* pIsolate); - -// Call before making JS_Define* calls. Resources allocated here are cleared -// as part of JS_ReleaseRuntime(). -void JS_PrepareIsolate(v8::Isolate* pIsolate); - -// Always returns a valid, newly-created objDefnID. -int FXJS_DefineObj(v8::Isolate* pIsolate, - const wchar_t* sObjName, - FXJSOBJTYPE eObjType, - FXJS_CONSTRUCTOR pConstructor, - FXJS_DESTRUCTOR pDestructor); - -void FXJS_DefineObjMethod(v8::Isolate* pIsolate, - int nObjDefnID, - const wchar_t* sMethodName, - v8::FunctionCallback pMethodCall); -void FXJS_DefineObjProperty(v8::Isolate* pIsolate, - int nObjDefnID, - const wchar_t* sPropName, - v8::AccessorGetterCallback pPropGet, - v8::AccessorSetterCallback pPropPut); -void FXJS_DefineObjAllProperties(v8::Isolate* pIsolate, - int nObjDefnID, - v8::NamedPropertyQueryCallback pPropQurey, - v8::NamedPropertyGetterCallback pPropGet, - v8::NamedPropertySetterCallback pPropPut, - v8::NamedPropertyDeleterCallback pPropDel); -void FXJS_DefineObjConst(v8::Isolate* pIsolate, - int nObjDefnID, - const wchar_t* sConstName, - v8::Local<v8::Value> pDefault); -void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, - const wchar_t* sMethodName, - v8::FunctionCallback pMethodCall); -void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, - const wchar_t* sConstName, - v8::FunctionCallback pConstGetter); - -// Called after FXJS_Define* calls made. -void FXJS_InitializeRuntime( - v8::Isolate* pIsolate, - IJS_Runtime* pIRuntime, - v8::Global<v8::Context>* pV8PersistentContext, - std::vector<v8::Global<v8::Object>*>* pStaticObjects); -void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, - v8::Global<v8::Context>* pV8PersistentContext, - std::vector<v8::Global<v8::Object>*>* pStaticObjects); -IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); - -#ifdef PDF_ENABLE_XFA -// Called as part of FXJS_InitializeRuntime, exposed so PDF can make its -// own contexts compatible with XFA or vice versa. -void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, - IJS_Runtime* pIRuntime); -#endif // PDF_ENABLE_XFA - -// Called after FXJS_InitializeRuntime call made. -int FXJS_Execute(v8::Isolate* pIsolate, - IJS_Context* pJSContext, - const wchar_t* script, - FXJSErr* perror); - -v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, - IJS_Runtime* pJSContext, - int nObjDefnID, - bool bStatic = false); -v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); -int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj); -const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj); - -void FXJS_SetPrivate(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - void* p); -void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj); -void FXJS_FreePrivate(void* p); -void FXJS_FreePrivate(v8::Local<v8::Object> pObj); - -void FXJS_Error(v8::Isolate* isolate, const CFX_WideString& message); -v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate, - const wchar_t* PropertyName, - int Len = -1); - -v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName); -v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj); - -v8::Local<v8::Value> FXJS_GetArrayElement(v8::Isolate* pIsolate, - v8::Local<v8::Array> pArray, - unsigned index); -unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray); - -void FXJS_PutObjectString(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName, - const wchar_t* sValue); -void FXJS_PutObjectNumber(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName, - int nValue); -void FXJS_PutObjectNumber(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName, - float fValue); -void FXJS_PutObjectNumber(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName, - double dValue); -void FXJS_PutObjectBoolean(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName, - bool bValue); -void FXJS_PutObjectObject(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName, - v8::Local<v8::Object> pPut); -void FXJS_PutObjectNull(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj, - const wchar_t* PropertyName); -unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate, - v8::Local<v8::Array> pArray, - unsigned index, - v8::Local<v8::Value> pValue); - -v8::Local<v8::Array> FXJS_NewArray(v8::Isolate* pIsolate); -v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, int number); -v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, double number); -v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, float number); -v8::Local<v8::Value> FXJS_NewBoolean(v8::Isolate* pIsolate, bool b); -v8::Local<v8::Value> FXJS_NewObject(v8::Isolate* pIsolate, - v8::Local<v8::Object> pObj); -v8::Local<v8::Value> FXJS_NewObject2(v8::Isolate* pIsolate, - v8::Local<v8::Array> pObj); -v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate, const wchar_t* str); -v8::Local<v8::Value> FXJS_NewNull(); -v8::Local<v8::Value> FXJS_NewDate(v8::Isolate* pIsolate, double d); - -int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); -bool FXJS_ToBoolean(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); -double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); -v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, - v8::Local<v8::Value> pValue); -CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, - v8::Local<v8::Value> pValue); -v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, - v8::Local<v8::Value> pValue); -void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); - -#endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |