From b048f791a15f2da781a01eba5b09eb9d389f9c11 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 4 Aug 2015 12:19:10 -0700 Subject: clang-format all pdfium code. No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163' | \ xargs ../../buildtools/mac/clang-format -i See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1265503005 . --- fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h | 70 +- fpdfsdk/include/formfiller/FFL_CheckBox.h | 34 +- fpdfsdk/include/formfiller/FFL_ComboBox.h | 103 +- fpdfsdk/include/formfiller/FFL_FormFiller.h | 309 +++--- fpdfsdk/include/formfiller/FFL_IFormFiller.h | 206 ++-- fpdfsdk/include/formfiller/FFL_ListBox.h | 71 +- fpdfsdk/include/formfiller/FFL_Notify.h | 93 +- fpdfsdk/include/formfiller/FFL_PushButton.h | 22 +- fpdfsdk/include/formfiller/FFL_RadioButton.h | 27 +- fpdfsdk/include/formfiller/FFL_TextField.h | 103 +- fpdfsdk/include/formfiller/FFL_Utils.h | 15 +- fpdfsdk/include/fsdk_actionhandler.h | 149 ++- fpdfsdk/include/fsdk_annothandler.h | 548 ++++++---- fpdfsdk/include/fsdk_baseannot.h | 263 ++--- fpdfsdk/include/fsdk_baseform.h | 494 +++++---- fpdfsdk/include/fsdk_common.h | 60 +- fpdfsdk/include/fsdk_define.h | 41 +- fpdfsdk/include/fsdk_mgr.h | 745 ++++++------- fpdfsdk/include/fsdk_rendercontext.h | 42 +- fpdfsdk/include/fx_systemhandler.h | 151 +-- fpdfsdk/include/fxedit/fx_edit.h | 936 ++++++++-------- fpdfsdk/include/fxedit/fxet_edit.h | 1430 +++++++++++++------------ fpdfsdk/include/fxedit/fxet_list.h | 624 ++++++----- fpdfsdk/include/javascript/Consts.h | 119 +- fpdfsdk/include/javascript/Document.h | 590 ++++++---- fpdfsdk/include/javascript/Field.h | 929 ++++++++++------ fpdfsdk/include/javascript/IJavaScript.h | 224 ++-- fpdfsdk/include/javascript/Icon.h | 42 +- fpdfsdk/include/javascript/JS_Context.h | 210 ++-- fpdfsdk/include/javascript/JS_Define.h | 646 ++++++----- fpdfsdk/include/javascript/JS_EventHandler.h | 345 +++--- fpdfsdk/include/javascript/JS_GlobalData.h | 143 +-- fpdfsdk/include/javascript/JS_Object.h | 451 ++++---- fpdfsdk/include/javascript/JS_Runtime.h | 81 +- fpdfsdk/include/javascript/JS_Value.h | 304 +++--- fpdfsdk/include/javascript/PublicMethods.h | 240 +++-- fpdfsdk/include/javascript/app.h | 349 +++--- fpdfsdk/include/javascript/color.h | 117 +- fpdfsdk/include/javascript/console.h | 52 +- fpdfsdk/include/javascript/event.h | 123 ++- fpdfsdk/include/javascript/global.h | 133 +-- fpdfsdk/include/javascript/report.h | 40 +- fpdfsdk/include/javascript/resource.h | 36 +- fpdfsdk/include/javascript/util.h | 76 +- fpdfsdk/include/jsapi/fxjs_v8.h | 293 +++-- fpdfsdk/include/pdfwindow/PWL_Button.h | 21 +- fpdfsdk/include/pdfwindow/PWL_Caret.h | 72 +- fpdfsdk/include/pdfwindow/PWL_ComboBox.h | 148 +-- fpdfsdk/include/pdfwindow/PWL_Edit.h | 276 ++--- fpdfsdk/include/pdfwindow/PWL_EditCtrl.h | 315 +++--- fpdfsdk/include/pdfwindow/PWL_FontMap.h | 207 ++-- fpdfsdk/include/pdfwindow/PWL_Icon.h | 73 +- fpdfsdk/include/pdfwindow/PWL_IconList.h | 202 ++-- fpdfsdk/include/pdfwindow/PWL_Label.h | 58 +- fpdfsdk/include/pdfwindow/PWL_ListBox.h | 180 ++-- fpdfsdk/include/pdfwindow/PWL_ListCtrl.h | 66 +- fpdfsdk/include/pdfwindow/PWL_Note.h | 585 +++++----- fpdfsdk/include/pdfwindow/PWL_ScrollBar.h | 273 +++-- fpdfsdk/include/pdfwindow/PWL_Signature.h | 74 +- fpdfsdk/include/pdfwindow/PWL_SpecialButton.h | 61 +- fpdfsdk/include/pdfwindow/PWL_Utils.h | 598 +++++++---- fpdfsdk/include/pdfwindow/PWL_Wnd.h | 829 +++++++------- 62 files changed, 8853 insertions(+), 7264 deletions(-) (limited to 'fpdfsdk/include') diff --git a/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h b/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h index 3be49fc2de..7978150736 100644 --- a/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h +++ b/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h @@ -12,39 +12,43 @@ class CPDF_Dictionary; class CPDFSDK_Annot; -class CBA_FontMap : public CPWL_FontMap -{ -public: - CBA_FontMap(CPDFSDK_Annot* pAnnot, IFX_SystemHandler* pSystemHandler); - CBA_FontMap(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict, IFX_SystemHandler* pSystemHandler); - - virtual ~CBA_FontMap(); - - virtual void Initial(const FX_CHAR* fontname = NULL); - -public: - void SetDefaultFont(CPDF_Font * pFont, const CFX_ByteString & sFontName); - - void Reset(); - void SetAPType(const CFX_ByteString& sAPType); - -protected: - virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t nCharset); - virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); - virtual CPDF_Document* GetDocument(); -private: - CPDF_Font* FindResFontSameCharset(CPDF_Dictionary* pResDict, CFX_ByteString& sFontAlias, - int32_t nCharset); - CPDF_Font* GetAnnotDefaultFont(CFX_ByteString &csNameTag); - void AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias); - -private: - CPDF_Document* m_pDocument; - CPDF_Dictionary* m_pAnnotDict; - CPDF_Font* m_pDefaultFont; - CFX_ByteString m_sDefaultFontName; - - CFX_ByteString m_sAPType; +class CBA_FontMap : public CPWL_FontMap { + public: + CBA_FontMap(CPDFSDK_Annot* pAnnot, IFX_SystemHandler* pSystemHandler); + CBA_FontMap(CPDF_Document* pDocument, + CPDF_Dictionary* pAnnotDict, + IFX_SystemHandler* pSystemHandler); + + virtual ~CBA_FontMap(); + + virtual void Initial(const FX_CHAR* fontname = NULL); + + public: + void SetDefaultFont(CPDF_Font* pFont, const CFX_ByteString& sFontName); + + void Reset(); + void SetAPType(const CFX_ByteString& sAPType); + + protected: + virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, + int32_t nCharset); + virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); + virtual CPDF_Document* GetDocument(); + + private: + CPDF_Font* FindResFontSameCharset(CPDF_Dictionary* pResDict, + CFX_ByteString& sFontAlias, + int32_t nCharset); + CPDF_Font* GetAnnotDefaultFont(CFX_ByteString& csNameTag); + void AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias); + + private: + CPDF_Document* m_pDocument; + CPDF_Dictionary* m_pAnnotDict; + CPDF_Font* m_pDefaultFont; + CFX_ByteString m_sDefaultFontName; + + CFX_ByteString m_sAPType; }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_CBA_FONTMAP_H_ diff --git a/fpdfsdk/include/formfiller/FFL_CheckBox.h b/fpdfsdk/include/formfiller/FFL_CheckBox.h index 3deeae8aa7..0ac7170a16 100644 --- a/fpdfsdk/include/formfiller/FFL_CheckBox.h +++ b/fpdfsdk/include/formfiller/FFL_CheckBox.h @@ -9,21 +9,25 @@ #include "FFL_FormFiller.h" -class CFFL_CheckBox : public CFFL_Button -{ -public: - CFFL_CheckBox(CPDFDoc_Environment* pApp, CPDFSDK_Widget* pWidget); - virtual ~CFFL_CheckBox(); - - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); +class CFFL_CheckBox : public CFFL_Button { + public: + CFFL_CheckBox(CPDFDoc_Environment* pApp, CPDFSDK_Widget* pWidget); + virtual ~CFFL_CheckBox(); + + virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView); + + virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, + FX_UINT nKeyCode, + FX_UINT nFlags); + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + + virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); + virtual void SaveData(CPDFSDK_PageView* pPageView); }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_CHECKBOX_H_ - diff --git a/fpdfsdk/include/formfiller/FFL_ComboBox.h b/fpdfsdk/include/formfiller/FFL_ComboBox.h index e5c65c2715..5be7198918 100644 --- a/fpdfsdk/include/formfiller/FFL_ComboBox.h +++ b/fpdfsdk/include/formfiller/FFL_ComboBox.h @@ -13,56 +13,63 @@ class CBA_FontMap; class CPDFSDK_Document; -struct FFL_ComboBoxState -{ - int nIndex; - int nStart; - int nEnd; - CFX_WideString sValue; +struct FFL_ComboBoxState { + int nIndex; + int nStart; + int nEnd; + CFX_WideString sValue; }; -class CFFL_ComboBox : public CFFL_FormFiller, public IPWL_FocusHandler, public IPWL_Edit_Notify -{ -public: - CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); - virtual ~CFFL_ComboBox(); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, const PDFSDK_FieldAction& fa); - virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, const PDFSDK_FieldAction& faNew); - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue); - virtual void OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag); - -public: - virtual void OnSetFocus(CPWL_Wnd* pWnd); - virtual void OnKillFocus(CPWL_Wnd* pWnd); - -public: - virtual void OnAddUndo(CPWL_Edit* pEdit); - -public: - virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); - -private: - CFX_WideString GetSelectExportText(); - -private: - CBA_FontMap* m_pFontMap; - FFL_ComboBoxState m_State; +class CFFL_ComboBox : public CFFL_FormFiller, + public IPWL_FocusHandler, + public IPWL_Edit_Notify { + public: + CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); + virtual ~CFFL_ComboBox(); + + virtual PWL_CREATEPARAM GetCreateParam(); + virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView); + + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + + virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); + virtual void SaveData(CPDFSDK_PageView* pPageView); + + virtual void GetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& fa); + virtual void SetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& fa); + virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& faOld, + const PDFSDK_FieldAction& faNew); + virtual void SaveState(CPDFSDK_PageView* pPageView); + virtual void RestoreState(CPDFSDK_PageView* pPageView); + + virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, + FX_BOOL bRestoreValue); + virtual void OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag); + + public: + virtual void OnSetFocus(CPWL_Wnd* pWnd); + virtual void OnKillFocus(CPWL_Wnd* pWnd); + + public: + virtual void OnAddUndo(CPWL_Edit* pEdit); + + public: + virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); + virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); + virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); + + private: + CFX_WideString GetSelectExportText(); + + private: + CBA_FontMap* m_pFontMap; + FFL_ComboBoxState m_State; }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_COMBOBOX_H_ diff --git a/fpdfsdk/include/formfiller/FFL_FormFiller.h b/fpdfsdk/include/formfiller/FFL_FormFiller.h index fc858a8822..64c813671a 100644 --- a/fpdfsdk/include/formfiller/FFL_FormFiller.h +++ b/fpdfsdk/include/formfiller/FFL_FormFiller.h @@ -18,138 +18,187 @@ class CPDFSDK_PageView; class CPDFSDK_Document; class CPDFSDK_Widget; -class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler -{ -public: - CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_FormFiller(); - - virtual FX_RECT GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags); - virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags); - - virtual void OnCreate(CPDFSDK_Annot* pAnnot); - virtual void OnLoad(CPDFSDK_Annot* pAnnot); - virtual void OnDelete(CPDFSDK_Annot* pAnnot); - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point); - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - - virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); - - virtual void DoCopy(CPDFSDK_Document* pDocument); - virtual void DoCut(CPDFSDK_Document* pDocument); - virtual void DoPaste(CPDFSDK_Document* pDocument); - - // CPWL_TimerHandler - virtual void TimerProc(); - virtual IFX_SystemHandler* GetSystemHandler() const; - - virtual CPDF_Matrix GetWindowMatrix(void* pAttachedData); - virtual CFX_WideString LoadPopupMenuString(int nIndex); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - const PDFSDK_FieldAction& fa); - virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, - const PDFSDK_FieldAction& faNew); - - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue); - - virtual void OnKeyStroke(FX_BOOL bKeyDown); - - CPDF_Matrix GetCurMatrix(); - - CPDF_Rect FFLtoPWL(const CPDF_Rect& rect); - CPDF_Rect PWLtoFFL(const CPDF_Rect& rect); - CPDF_Point FFLtoPWL(const CPDF_Point& point); - CPDF_Point PWLtoFFL(const CPDF_Point& point); - - CPDF_Point WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Point& pt); - CPDF_Rect FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect& rect); - - void SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow); - CPDF_Rect GetWindowRect(CPDFSDK_PageView* pPageView); - - FX_BOOL CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag); - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew); - void DestroyPDFWindow(CPDFSDK_PageView* pPageView); - void EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView) = 0; - virtual CPDF_Rect GetFocusBox(CPDFSDK_PageView* pPageView); - - FX_BOOL IsValid() const; - CPDF_Rect GetPDFWindowRect() const; - - CPDFSDK_PageView* GetCurPageView(); - void SetChangeMark(); - - virtual void InvalidateRect(double left, double top, double right, double bottom); - CPDFDoc_Environment* GetApp(){return m_pApp;} - CPDFSDK_Annot* GetSDKAnnot() {return m_pAnnot;} - -protected: - using CFFL_PageView2PDFWindow = std::map; - - CPDFDoc_Environment* m_pApp; - CPDFSDK_Widget* m_pWidget; - CPDFSDK_Annot* m_pAnnot; - - FX_BOOL m_bValid; - CFFL_PageView2PDFWindow m_Maps; - CPDF_Point m_ptOldPos; +class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler { + public: + CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + virtual ~CFFL_FormFiller(); + + virtual FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags); + virtual void OnDrawDeactive(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags); + + virtual void OnCreate(CPDFSDK_Annot* pAnnot); + virtual void OnLoad(CPDFSDK_Annot* pAnnot); + virtual void OnDelete(CPDFSDK_Annot* pAnnot); + + virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); + virtual void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); + + virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + short zDelta, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + + virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, + FX_UINT nKeyCode, + FX_UINT nFlags); + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + + virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); + virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); + + virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); + virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); + virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); + + virtual void DoCopy(CPDFSDK_Document* pDocument); + virtual void DoCut(CPDFSDK_Document* pDocument); + virtual void DoPaste(CPDFSDK_Document* pDocument); + + // CPWL_TimerHandler + virtual void TimerProc(); + virtual IFX_SystemHandler* GetSystemHandler() const; + + virtual CPDF_Matrix GetWindowMatrix(void* pAttachedData); + virtual CFX_WideString LoadPopupMenuString(int nIndex); + + virtual void GetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& fa); + virtual void SetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& fa); + virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& faOld, + const PDFSDK_FieldAction& faNew); + + virtual void SaveState(CPDFSDK_PageView* pPageView); + virtual void RestoreState(CPDFSDK_PageView* pPageView); + + virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, + FX_BOOL bRestoreValue); + + virtual void OnKeyStroke(FX_BOOL bKeyDown); + + CPDF_Matrix GetCurMatrix(); + + CPDF_Rect FFLtoPWL(const CPDF_Rect& rect); + CPDF_Rect PWLtoFFL(const CPDF_Rect& rect); + CPDF_Point FFLtoPWL(const CPDF_Point& point); + CPDF_Point PWLtoFFL(const CPDF_Point& point); + + CPDF_Point WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Point& pt); + CPDF_Rect FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect& rect); + + void SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow); + CPDF_Rect GetWindowRect(CPDFSDK_PageView* pPageView); + + FX_BOOL CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag); + virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); + virtual void SaveData(CPDFSDK_PageView* pPageView); + + CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew); + void DestroyPDFWindow(CPDFSDK_PageView* pPageView); + void EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow); + + virtual PWL_CREATEPARAM GetCreateParam(); + virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView) = 0; + virtual CPDF_Rect GetFocusBox(CPDFSDK_PageView* pPageView); + + FX_BOOL IsValid() const; + CPDF_Rect GetPDFWindowRect() const; + + CPDFSDK_PageView* GetCurPageView(); + void SetChangeMark(); + + virtual void InvalidateRect(double left, + double top, + double right, + double bottom); + CPDFDoc_Environment* GetApp() { return m_pApp; } + CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot; } + + protected: + using CFFL_PageView2PDFWindow = std::map; + + CPDFDoc_Environment* m_pApp; + CPDFSDK_Widget* m_pWidget; + CPDFSDK_Annot* m_pAnnot; + + FX_BOOL m_bValid; + CFFL_PageView2PDFWindow m_Maps; + CPDF_Point m_ptOldPos; }; -class CFFL_Button : public CFFL_FormFiller -{ -public: - CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); - virtual ~CFFL_Button(); - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags); - - virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags); -protected: - FX_BOOL m_bMouseIn; - FX_BOOL m_bMouseDown; +class CFFL_Button : public CFFL_FormFiller { + public: + CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); + virtual ~CFFL_Button(); + + virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); + virtual void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); + virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags); + + virtual void OnDrawDeactive(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags); + + protected: + FX_BOOL m_bMouseIn; + FX_BOOL m_bMouseDown; }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_FORMFILLER_H_ diff --git a/fpdfsdk/include/formfiller/FFL_IFormFiller.h b/fpdfsdk/include/formfiller/FFL_IFormFiller.h index e553723dc3..3acdb237d0 100644 --- a/fpdfsdk/include/formfiller/FFL_IFormFiller.h +++ b/fpdfsdk/include/formfiller/FFL_IFormFiller.h @@ -14,80 +14,142 @@ class CFFL_FormFiller; class CFFL_PrivateData; -class CFFL_IFormFiller : public IPWL_Filler_Notify -{ -public: - CFFL_IFormFiller(CPDFDoc_Environment* pApp); - virtual ~CFFL_IFormFiller(); - - virtual FX_BOOL Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point); - virtual FX_RECT GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - /*const CRect& rcWindow,*/ FX_DWORD dwFlags); - - - virtual void OnCreate(CPDFSDK_Annot* pAnnot); - virtual void OnLoad(CPDFSDK_Annot* pAnnot); - virtual void OnDelete(CPDFSDK_Annot* pAnnot); - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point); - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag); - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - - virtual void QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, int32_t & nRet, FX_FLOAT & fPopupRet); - virtual void OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode, - CFX_WideString & strChange, const CFX_WideString& strChangeEx, - int nSelStart, int nSelEnd, - FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag); - virtual void OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) ; - - CFFL_FormFiller* GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister); - void RemoveFormFiller(CPDFSDK_Annot* pAnnot); - - static FX_BOOL IsVisible(CPDFSDK_Widget* pWidget); - static FX_BOOL IsReadOnly(CPDFSDK_Widget* pWidget); - static FX_BOOL IsFillingAllowed(CPDFSDK_Widget* pWidget); - static FX_BOOL IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); - - void OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag); - void OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag); - - void OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag); - void OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag); - void OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag); - -private: - using CFFL_Widget2Filler = std::map; - - void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); - - CPDFDoc_Environment* m_pApp; - CFFL_Widget2Filler m_Maps; - FX_BOOL m_bNotifying; +class CFFL_IFormFiller : public IPWL_Filler_Notify { + public: + CFFL_IFormFiller(CPDFDoc_Environment* pApp); + virtual ~CFFL_IFormFiller(); + + virtual FX_BOOL Annot_HitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CPDF_Point point); + virtual FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + virtual void OnDraw(CPDFSDK_PageView* pPageView, + /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + /*const CRect& rcWindow,*/ FX_DWORD dwFlags); + + virtual void OnCreate(CPDFSDK_Annot* pAnnot); + virtual void OnLoad(CPDFSDK_Annot* pAnnot); + virtual void OnDelete(CPDFSDK_Annot* pAnnot); + + virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlag); + virtual void OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlag); + + virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + short zDelta, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + + virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, + FX_UINT nKeyCode, + FX_UINT nFlags); + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + + virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); + virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); + + virtual void QueryWherePopup(void* pPrivateData, + FX_FLOAT fPopupMin, + FX_FLOAT fPopupMax, + int32_t& nRet, + FX_FLOAT& fPopupRet); + virtual void OnBeforeKeyStroke(FX_BOOL bEditOrList, + void* pPrivateData, + int32_t nKeyCode, + CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + int nSelStart, + int nSelEnd, + FX_BOOL bKeyDown, + FX_BOOL& bRC, + FX_BOOL& bExit, + FX_DWORD nFlag); + virtual void OnAfterKeyStroke(FX_BOOL bEditOrList, + void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag); + + CFFL_FormFiller* GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister); + void RemoveFormFiller(CPDFSDK_Annot* pAnnot); + + static FX_BOOL IsVisible(CPDFSDK_Widget* pWidget); + static FX_BOOL IsReadOnly(CPDFSDK_Widget* pWidget); + static FX_BOOL IsFillingAllowed(CPDFSDK_Widget* pWidget); + static FX_BOOL IsValidAnnot(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + + void OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bRC, + FX_BOOL& bExit, + FX_DWORD nFlag); + void OnValidate(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bRC, + FX_BOOL& bExit, + FX_DWORD nFlag); + + void OnCalculate(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bExit, + FX_DWORD nFlag); + void OnFormat(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bExit, + FX_DWORD nFlag); + void OnButtonUp(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); + + private: + using CFFL_Widget2Filler = std::map; + + void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); + + CPDFDoc_Environment* m_pApp; + CFFL_Widget2Filler m_Maps; + FX_BOOL m_bNotifying; }; -class CFFL_PrivateData -{ -public: - CPDFSDK_Widget* pWidget; - CPDFSDK_PageView* pPageView; - int nWidgetAge; - int nValueAge; +class CFFL_PrivateData { + public: + CPDFSDK_Widget* pWidget; + CPDFSDK_PageView* pPageView; + int nWidgetAge; + int nValueAge; }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_IFORMFILLER_H_ - diff --git a/fpdfsdk/include/formfiller/FFL_ListBox.h b/fpdfsdk/include/formfiller/FFL_ListBox.h index 4c0813f5c8..2e26069e2c 100644 --- a/fpdfsdk/include/formfiller/FFL_ListBox.h +++ b/fpdfsdk/include/formfiller/FFL_ListBox.h @@ -11,43 +11,40 @@ #include "FFL_FormFiller.h" -class CBA_FontMap; - -class CFFL_ListBox : public CFFL_FormFiller -{ -public: - CFFL_ListBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); - virtual ~CFFL_ListBox(); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, - CPDFSDK_PageView* pPageView); - - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, - FX_UINT nFlags); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, - CPDF_AAction::AActionType type, - PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, - CPDF_AAction::AActionType type, - const PDFSDK_FieldAction& fa); - - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, - FX_BOOL bRestoreValue); - virtual void OnKeyStroke(FX_BOOL bKeyDown, FX_DWORD nFlag); - -private: - CBA_FontMap* m_pFontMap; - std::set m_OriginSelections; - CFX_ArrayTemplate m_State; -}; +class CBA_FontMap; + +class CFFL_ListBox : public CFFL_FormFiller { + public: + CFFL_ListBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); + virtual ~CFFL_ListBox(); + + virtual PWL_CREATEPARAM GetCreateParam(); + virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView); + + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + + virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); + virtual void SaveData(CPDFSDK_PageView* pPageView); + virtual void GetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& fa); + virtual void SetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& fa); + + virtual void SaveState(CPDFSDK_PageView* pPageView); + virtual void RestoreState(CPDFSDK_PageView* pPageView); + + virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, + FX_BOOL bRestoreValue); + virtual void OnKeyStroke(FX_BOOL bKeyDown, FX_DWORD nFlag); + + private: + CBA_FontMap* m_pFontMap; + std::set m_OriginSelections; + CFX_ArrayTemplate m_State; +}; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_LISTBOX_H_ diff --git a/fpdfsdk/include/formfiller/FFL_Notify.h b/fpdfsdk/include/formfiller/FFL_Notify.h index 961d4b7a79..ee9e81a18f 100644 --- a/fpdfsdk/include/formfiller/FFL_Notify.h +++ b/fpdfsdk/include/formfiller/FFL_Notify.h @@ -13,43 +13,62 @@ class CFFL_FormFiller; class CPDF_FormField; -class CFFL_Notify -{ -public: - CFFL_Notify(CFFL_FormFiller * pFormFiller); - virtual ~CFFL_Notify(); - -public: - FX_BOOL OnSetFocus(FX_BOOL & bExit); - FX_BOOL OnMouseEnter(FX_BOOL & bExit); - FX_BOOL OnMouseDown(FX_BOOL & bExit); - FX_BOOL OnMouseUp(FX_BOOL & bExit); - FX_BOOL OnMouseExit(FX_BOOL & bExit); - FX_BOOL OnKillFocus(FX_BOOL & bExit); - - FX_BOOL OnCalculate(); - FX_BOOL OnFormat(int iCommitKey); - FX_BOOL OnValidate(CPDF_FormField* pFormField, CFX_WideString& strValue, CFX_WideString & strChange, - const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL bModifier, - FX_BOOL bShift, FX_BOOL & bRC); - FX_BOOL OnKeyStroke(CPDF_FormField* pFormField, int nCommitKey, CFX_WideString& strValue, CFX_WideString& strChange, - const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL bModifier, - FX_BOOL bShift, FX_BOOL bWillCommit, FX_BOOL bFieldFull, - int& nSelStart, int& nSelEnd, FX_BOOL& bRC); - - void BeforeNotify(); - void AfterNotify(); - FX_BOOL IsNotifying() const {return m_nNotifyFlag > 0;} - -private: - FX_BOOL DoAAction(CPDF_AAction::AActionType eAAT, FX_BOOL & bExit); - FX_BOOL FindAAction(CPDF_AAction::AActionType eAAT,CPDF_Action & action); - FX_BOOL FindAAction(CPDF_AAction aaction,CPDF_AAction::AActionType eAAT,CPDF_Action & action); - FX_BOOL ExecuteActionTree(CPDF_AAction::AActionType eAAT, CPDF_Action & action, FX_BOOL& bExit); - FX_BOOL ExecuteAction(CPDF_AAction::AActionType eAAT,CPDF_Action & action,FX_BOOL& bExit); - - FX_BOOL m_bDoActioning; - int32_t m_nNotifyFlag; +class CFFL_Notify { + public: + CFFL_Notify(CFFL_FormFiller* pFormFiller); + virtual ~CFFL_Notify(); + + public: + FX_BOOL OnSetFocus(FX_BOOL& bExit); + FX_BOOL OnMouseEnter(FX_BOOL& bExit); + FX_BOOL OnMouseDown(FX_BOOL& bExit); + FX_BOOL OnMouseUp(FX_BOOL& bExit); + FX_BOOL OnMouseExit(FX_BOOL& bExit); + FX_BOOL OnKillFocus(FX_BOOL& bExit); + + FX_BOOL OnCalculate(); + FX_BOOL OnFormat(int iCommitKey); + FX_BOOL OnValidate(CPDF_FormField* pFormField, + CFX_WideString& strValue, + CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL bKeyDown, + FX_BOOL bModifier, + FX_BOOL bShift, + FX_BOOL& bRC); + FX_BOOL OnKeyStroke(CPDF_FormField* pFormField, + int nCommitKey, + CFX_WideString& strValue, + CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL bKeyDown, + FX_BOOL bModifier, + FX_BOOL bShift, + FX_BOOL bWillCommit, + FX_BOOL bFieldFull, + int& nSelStart, + int& nSelEnd, + FX_BOOL& bRC); + + void BeforeNotify(); + void AfterNotify(); + FX_BOOL IsNotifying() const { return m_nNotifyFlag > 0; } + + private: + FX_BOOL DoAAction(CPDF_AAction::AActionType eAAT, FX_BOOL& bExit); + FX_BOOL FindAAction(CPDF_AAction::AActionType eAAT, CPDF_Action& action); + FX_BOOL FindAAction(CPDF_AAction aaction, + CPDF_AAction::AActionType eAAT, + CPDF_Action& action); + FX_BOOL ExecuteActionTree(CPDF_AAction::AActionType eAAT, + CPDF_Action& action, + FX_BOOL& bExit); + FX_BOOL ExecuteAction(CPDF_AAction::AActionType eAAT, + CPDF_Action& action, + FX_BOOL& bExit); + + FX_BOOL m_bDoActioning; + int32_t m_nNotifyFlag; }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_NOTIFY_H_ diff --git a/fpdfsdk/include/formfiller/FFL_PushButton.h b/fpdfsdk/include/formfiller/FFL_PushButton.h index 3cfaefb9bd..5c4819400d 100644 --- a/fpdfsdk/include/formfiller/FFL_PushButton.h +++ b/fpdfsdk/include/formfiller/FFL_PushButton.h @@ -9,18 +9,20 @@ #include "FFL_FormFiller.h" -class CFFL_PushButton : public CFFL_Button -{ -public: - CFFL_PushButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_PushButton(); +class CFFL_PushButton : public CFFL_Button { + public: + CFFL_PushButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + virtual ~CFFL_PushButton(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); + virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags); + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags); }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_PUSHBUTTON_H_ diff --git a/fpdfsdk/include/formfiller/FFL_RadioButton.h b/fpdfsdk/include/formfiller/FFL_RadioButton.h index 46332e07fd..ba7bff4629 100644 --- a/fpdfsdk/include/formfiller/FFL_RadioButton.h +++ b/fpdfsdk/include/formfiller/FFL_RadioButton.h @@ -9,18 +9,23 @@ #include "FFL_FormFiller.h" -class CFFL_RadioButton : public CFFL_Button -{ -public: - CFFL_RadioButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_RadioButton(); +class CFFL_RadioButton : public CFFL_Button { + public: + CFFL_RadioButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + virtual ~CFFL_RadioButton(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); + virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView); + virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, + FX_UINT nKeyCode, + FX_UINT nFlags); + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CPDF_Point& point); + virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); + virtual void SaveData(CPDFSDK_PageView* pPageView); }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_RADIOBUTTON_H_ diff --git a/fpdfsdk/include/formfiller/FFL_TextField.h b/fpdfsdk/include/formfiller/FFL_TextField.h index 10bd5c0e43..65da9257ac 100644 --- a/fpdfsdk/include/formfiller/FFL_TextField.h +++ b/fpdfsdk/include/formfiller/FFL_TextField.h @@ -9,61 +9,64 @@ #include "FFL_FormFiller.h" -#define BF_ALIGN_LEFT 0 -#define BF_ALIGN_MIDDLE 1 -#define BF_ALIGN_RIGHT 2 +#define BF_ALIGN_LEFT 0 +#define BF_ALIGN_MIDDLE 1 +#define BF_ALIGN_RIGHT 2 class CBA_FontMap; -struct FFL_TextFieldState -{ - int nStart; - int nEnd; - CFX_WideString sValue; +struct FFL_TextFieldState { + int nStart; + int nEnd; + CFX_WideString sValue; }; -class CFFL_TextField : public CFFL_FormFiller, public IPWL_FocusHandler, public IPWL_Edit_Notify -{ -public: - CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_TextField(); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - const PDFSDK_FieldAction& fa); - virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, - const PDFSDK_FieldAction& faNew); - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue); - -public: - virtual void OnSetFocus(CPWL_Wnd* pWnd); - virtual void OnKillFocus(CPWL_Wnd* pWnd); - -public: - virtual void OnAddUndo(CPWL_Edit* pEdit); - -public: - virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); - -private: - CBA_FontMap* m_pFontMap; - FFL_TextFieldState m_State; - +class CFFL_TextField : public CFFL_FormFiller, + public IPWL_FocusHandler, + public IPWL_Edit_Notify { + public: + CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + virtual ~CFFL_TextField(); + + virtual PWL_CREATEPARAM GetCreateParam(); + virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView); + + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); + + virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); + virtual void SaveData(CPDFSDK_PageView* pPageView); + + virtual void GetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& fa); + virtual void SetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& fa); + virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& faOld, + const PDFSDK_FieldAction& faNew); + virtual void SaveState(CPDFSDK_PageView* pPageView); + virtual void RestoreState(CPDFSDK_PageView* pPageView); + + virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, + FX_BOOL bRestoreValue); + + public: + virtual void OnSetFocus(CPWL_Wnd* pWnd); + virtual void OnKillFocus(CPWL_Wnd* pWnd); + + public: + virtual void OnAddUndo(CPWL_Edit* pEdit); + + public: + virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); + virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); + virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); + + private: + CBA_FontMap* m_pFontMap; + FFL_TextFieldState m_State; }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_TEXTFIELD_H_ diff --git a/fpdfsdk/include/formfiller/FFL_Utils.h b/fpdfsdk/include/formfiller/FFL_Utils.h index fe025eca4b..372a2b6837 100644 --- a/fpdfsdk/include/formfiller/FFL_Utils.h +++ b/fpdfsdk/include/formfiller/FFL_Utils.h @@ -9,15 +9,12 @@ #include "../../../core/include/fpdfapi/fpdf_parser.h" -class CFFL_Utils -{ -public: - static CPDF_Rect MaxRect(const CPDF_Rect& rect1,const CPDF_Rect& rect2); - static CPDF_Rect InflateRect(const CPDF_Rect& crRect, - const FX_FLOAT& fSize); - static CPDF_Rect DeflateRect(const CPDF_Rect& crRect, - const FX_FLOAT& fSize); - static FX_BOOL TraceObject(CPDF_Object* pObj); +class CFFL_Utils { + public: + static CPDF_Rect MaxRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); + static CPDF_Rect InflateRect(const CPDF_Rect& crRect, const FX_FLOAT& fSize); + static CPDF_Rect DeflateRect(const CPDF_Rect& crRect, const FX_FLOAT& fSize); + static FX_BOOL TraceObject(CPDF_Object* pObj); }; #endif // FPDFSDK_INCLUDE_FORMFILLER_FFL_UTILS_H_ diff --git a/fpdfsdk/include/fsdk_actionhandler.h b/fpdfsdk/include/fsdk_actionhandler.h index 39ec4f41af..dfb7d488c2 100644 --- a/fpdfsdk/include/fsdk_actionhandler.h +++ b/fpdfsdk/include/fsdk_actionhandler.h @@ -20,65 +20,118 @@ class CPDF_Bookmark; class CPDF_Dictionary; class IFXJS_Runtime; -class CPDFSDK_FormActionHandler -{ -public: - FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_SubmitForm(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_ResetForm(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_ImportData(const CPDF_Action& action, CPDFSDK_Document* pDocument); +class CPDFSDK_FormActionHandler { + public: + FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument); + FX_BOOL DoAction_SubmitForm(const CPDF_Action& action, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_ResetForm(const CPDF_Action& action, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_ImportData(const CPDF_Action& action, + CPDFSDK_Document* pDocument); }; -class CPDFSDK_MediaActionHandler -{ -public: - FX_BOOL DoAction_Rendition(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Sound(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Movie(const CPDF_Action& action, CPDFSDK_Document* pDocument); +class CPDFSDK_MediaActionHandler { + public: + FX_BOOL DoAction_Rendition(const CPDF_Action& action, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_Sound(const CPDF_Action& action, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_Movie(const CPDF_Action& action, + CPDFSDK_Document* pDocument); }; -class CPDFSDK_ActionHandler -{ -public: - CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi); +class CPDFSDK_ActionHandler { + public: + CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi); - void SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler); + void SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler); - FX_BOOL DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction,CFX_WideString csJSName, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Page(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Screen(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDFSDK_Annot* pScreen); - FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Field(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data); - FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data); + FX_BOOL DoAction_DocOpen(const CPDF_Action& action, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction, + CFX_WideString csJSName, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_Page(const CPDF_Action& action, + enum CPDF_AAction::AActionType eType, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_Document(const CPDF_Action& action, + enum CPDF_AAction::AActionType eType, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_BookMark(CPDF_Bookmark* pBookMark, + const CPDF_Action& action, + CPDF_AAction::AActionType type, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_Screen(const CPDF_Action& action, + CPDF_AAction::AActionType type, + CPDFSDK_Document* pDocument, + CPDFSDK_Annot* pScreen); + FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument); + FX_BOOL DoAction_Field(const CPDF_Action& action, + CPDF_AAction::AActionType type, + CPDFSDK_Document* pDocument, + CPDF_FormField* pFormField, + PDFSDK_FieldAction& data); + FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction, + CPDF_AAction::AActionType type, + CPDFSDK_Document* pDocument, + CPDF_FormField* pFormField, + PDFSDK_FieldAction& data); -private: - FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action, CPDFSDK_Document* pDocument, CFX_PtrList& list); - FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CFX_PtrList& list); - FX_BOOL ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data, CFX_PtrList& list); - FX_BOOL ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDFSDK_Annot* pScreen, CFX_PtrList& list); - FX_BOOL ExecuteBookMark(const CPDF_Action& action, CPDFSDK_Document* pDocument, CPDF_Bookmark* pBookmark, CFX_PtrList& list); - FX_BOOL ExecuteLinkAction(const CPDF_Action& action, CPDFSDK_Document* pDocument, CFX_PtrList& list); + private: + FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action, + CPDFSDK_Document* pDocument, + CFX_PtrList& list); + FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action, + CPDF_AAction::AActionType type, + CPDFSDK_Document* pDocument, + CFX_PtrList& list); + FX_BOOL ExecuteFieldAction(const CPDF_Action& action, + CPDF_AAction::AActionType type, + CPDFSDK_Document* pDocument, + CPDF_FormField* pFormField, + PDFSDK_FieldAction& data, + CFX_PtrList& list); + FX_BOOL ExecuteScreenAction(const CPDF_Action& action, + CPDF_AAction::AActionType type, + CPDFSDK_Document* pDocument, + CPDFSDK_Annot* pScreen, + CFX_PtrList& list); + FX_BOOL ExecuteBookMark(const CPDF_Action& action, + CPDFSDK_Document* pDocument, + CPDF_Bookmark* pBookmark, + CFX_PtrList& list); + FX_BOOL ExecuteLinkAction(const CPDF_Action& action, + CPDFSDK_Document* pDocument, + CFX_PtrList& list); - void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument); - void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument, CPDF_AAction::AActionType type, const CFX_WideString& script); - void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument, const CFX_WideString& sScriptName, const CFX_WideString& script); - void RunFieldJavaScript(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, const CFX_WideString& script); + void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument); + void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument, + CPDF_AAction::AActionType type, + const CFX_WideString& script); + void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument, + const CFX_WideString& sScriptName, + const CFX_WideString& script); + void RunFieldJavaScript(CPDFSDK_Document* pDocument, + CPDF_FormField* pFormField, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& data, + const CFX_WideString& script); - FX_BOOL IsValidField(CPDFSDK_Document* pDocument, CPDF_Dictionary* pFieldDict); - FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument); + FX_BOOL IsValidField(CPDFSDK_Document* pDocument, + CPDF_Dictionary* pFieldDict); + FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument); - void DoAction_GoTo(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_SetOCGState(CPDFSDK_Document* pDocument, const CPDF_Action& action); + void DoAction_GoTo(CPDFSDK_Document* pDocument, const CPDF_Action& action); + void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action); + void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action); + void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action); + void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action); + void DoAction_SetOCGState(CPDFSDK_Document* pDocument, + const CPDF_Action& action); - nonstd::unique_ptr m_pFormActionHandler; - CPDFSDK_MediaActionHandler* m_pMediaActionHandler; + nonstd::unique_ptr m_pFormActionHandler; + CPDFSDK_MediaActionHandler* m_pMediaActionHandler; }; #endif // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_ diff --git a/fpdfsdk/include/fsdk_annothandler.h b/fpdfsdk/include/fsdk_annothandler.h index b4705699c8..8bcf116e45 100644 --- a/fpdfsdk/include/fsdk_annothandler.h +++ b/fpdfsdk/include/fsdk_annothandler.h @@ -19,235 +19,339 @@ class CPDF_Matrix; class CPDF_Point; class CPDF_Rect; -class IPDFSDK_AnnotHandler -{ - -public: - virtual ~IPDFSDK_AnnotHandler() {}; - - virtual CFX_ByteString GetType() = 0; - - virtual CFX_ByteString GetName() = 0; - - virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; - - - virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) = 0; - - virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; - - virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; - - - virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot) = 0; - - virtual FX_BOOL HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point) = 0; - - - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags) = 0; - - virtual void OnDrawSleep(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect& rcWindow, FX_DWORD dwFlags) = 0; - - - - - virtual void OnCreate(CPDFSDK_Annot* pAnnot) = 0; - - virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0; - - virtual void OnDelete(CPDFSDK_Annot* pAnnot) = 0; - - virtual void OnRelease(CPDFSDK_Annot* pAnnot) = 0; - - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point) = 0; - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; -//by wjm. - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags) = 0; - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; - virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) =0 ; - - virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; - virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - +class IPDFSDK_AnnotHandler { + public: + virtual ~IPDFSDK_AnnotHandler(){}; + + virtual CFX_ByteString GetType() = 0; + + virtual CFX_ByteString GetName() = 0; + + virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; + + virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, + CPDFSDK_PageView* pPage) = 0; + + virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; + + virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; + + virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot) = 0; + + virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + const CPDF_Point& point) = 0; + + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags) = 0; + + virtual void OnDrawSleep(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Rect& rcWindow, + FX_DWORD dwFlags) = 0; + + virtual void OnCreate(CPDFSDK_Annot* pAnnot) = 0; + + virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0; + + virtual void OnDelete(CPDFSDK_Annot* pAnnot) = 0; + + virtual void OnRelease(CPDFSDK_Annot* pAnnot) = 0; + + virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlag) = 0; + virtual void OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlag) = 0; + + virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) = 0; + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) = 0; + virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) = 0; + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) = 0; + virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + short zDelta, + const CPDF_Point& point) = 0; + virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) = 0; + virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) = 0; + virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) = 0; + // by wjm. + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, + FX_DWORD nChar, + FX_DWORD nFlags) = 0; + virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; + virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; + + virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; + virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; + + virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; + virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; }; - -class CPDFSDK_BFAnnotHandler:public IPDFSDK_AnnotHandler -{ -public: - CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) : m_pApp(pApp), m_pFormFiller(NULL) {} - virtual ~CPDFSDK_BFAnnotHandler() {} -public: - - virtual CFX_ByteString GetType() {return CFX_ByteString("Widget");} - - virtual CFX_ByteString GetName() {return CFX_ByteString("WidgetHandler");} - - virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot); - - virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage); - - virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) ; - - virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {} - - - virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot) ; - - virtual FX_BOOL HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point); - - - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags) ; - - virtual void OnDrawSleep(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect& rcWindow, FX_DWORD dwFlags) {} - - - virtual void OnCreate(CPDFSDK_Annot* pAnnot) ; - - virtual void OnLoad(CPDFSDK_Annot* pAnnot) ; - - virtual void OnDelete(CPDFSDK_Annot* pAnnot) {} - - virtual void OnRelease(CPDFSDK_Annot* pAnnot) {} - - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) ; - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) ; - - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point) ; - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) {return FALSE;} - -//by wjm. - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags); - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - - virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) {} - virtual void OnSelected(CPDFSDK_Annot* pAnnot) {} - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - - void SetFormFiller(CFFL_IFormFiller* pFiller){m_pFormFiller = pFiller;} - CFFL_IFormFiller* GetFormFiller() {return m_pFormFiller;} -private: - - CPDFDoc_Environment* m_pApp; - CFFL_IFormFiller* m_pFormFiller; +class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { + public: + CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) + : m_pApp(pApp), m_pFormFiller(NULL) {} + virtual ~CPDFSDK_BFAnnotHandler() {} + + public: + virtual CFX_ByteString GetType() { return CFX_ByteString("Widget"); } + + virtual CFX_ByteString GetName() { return CFX_ByteString("WidgetHandler"); } + + virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot); + + virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage); + + virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); + + virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {} + + virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + + virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + const CPDF_Point& point); + + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags); + + virtual void OnDrawSleep(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Rect& rcWindow, + FX_DWORD dwFlags) {} + + virtual void OnCreate(CPDFSDK_Annot* pAnnot); + + virtual void OnLoad(CPDFSDK_Annot* pAnnot); + + virtual void OnDelete(CPDFSDK_Annot* pAnnot) {} + + virtual void OnRelease(CPDFSDK_Annot* pAnnot) {} + + virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlag); + virtual void OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlag); + + virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + short zDelta, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point) { + return FALSE; + } + + // by wjm. + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, + FX_DWORD nChar, + FX_DWORD nFlags); + virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); + virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); + + virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) {} + virtual void OnSelected(CPDFSDK_Annot* pAnnot) {} + + virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); + virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); + + void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } + CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; } + + private: + CPDFDoc_Environment* m_pApp; + CFFL_IFormFiller* m_pFormFiller; }; #define CBA_AnnotHandlerArray CFX_ArrayTemplate -class CPDFSDK_AnnotHandlerMgr -{ -public: - // Destroy the handler - CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp); - virtual ~CPDFSDK_AnnotHandlerMgr() ; - -public: - void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); - void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); - - virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot * pAnnot, CPDFSDK_PageView *pPageView); - virtual void ReleaseAnnot(CPDFSDK_Annot * pAnnot); - - virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); - virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot); -public: - IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; - virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,FX_DWORD dwFlags); - - virtual void Annot_OnMouseEnter(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags); - virtual void Annot_OnMouseExit(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags); - - virtual FX_BOOL Annot_OnLButtonDown(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnLButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnLButtonDblClk(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - - virtual FX_BOOL Annot_OnMouseMove(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnMouseWheel(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point); - virtual FX_BOOL Annot_OnRButtonDown(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnRButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - - - virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags); - virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - virtual FX_BOOL Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - - virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - - virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point); - -private: - IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; - CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,FX_BOOL bNext); -private: - CBA_AnnotHandlerArray m_Handlers; - CFX_MapByteStringToPtr m_mapType2Handler; - CPDFDoc_Environment* m_pApp; +class CPDFSDK_AnnotHandlerMgr { + public: + // Destroy the handler + CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp); + virtual ~CPDFSDK_AnnotHandlerMgr(); + + public: + void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); + void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); + + virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, + CPDFSDK_PageView* pPageView); + virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); + + virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); + virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot); + + public: + IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; + virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_DWORD dwFlags); + + virtual void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags); + virtual void Annot_OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags); + + virtual FX_BOOL Annot_OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL Annot_OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + + virtual FX_BOOL Annot_OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL Annot_OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + short zDelta, + const CPDF_Point& point); + virtual FX_BOOL Annot_OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL Annot_OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + + virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot, + FX_DWORD nChar, + FX_DWORD nFlags); + virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, + int nKeyCode, + int nFlag); + virtual FX_BOOL Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); + + virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); + virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); + + virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + const CPDF_Point& point); + + private: + IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; + CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); + + private: + CBA_AnnotHandlerArray m_Handlers; + CFX_MapByteStringToPtr m_mapType2Handler; + CPDFDoc_Environment* m_pApp; }; -typedef int (*AI_COMPARE) (CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); - -class CPDFSDK_AnnotIterator -{ -public: - CPDFSDK_AnnotIterator(CPDFSDK_PageView * pPageView, FX_BOOL bReverse, - FX_BOOL bIgnoreTopmost=FALSE,FX_BOOL bCircle=FALSE,CFX_PtrArray* pList=NULL); - virtual ~CPDFSDK_AnnotIterator() { } - - virtual CPDFSDK_Annot* Next (const CPDFSDK_Annot* pCurrent) ; - virtual CPDFSDK_Annot* Prev (const CPDFSDK_Annot* pCurrent) ; - virtual CPDFSDK_Annot* Next(int& index ) ; - virtual CPDFSDK_Annot* Prev(int& index ) ; - virtual int Count(){return m_pIteratorAnnotList.GetSize();} - - virtual FX_BOOL InitIteratorAnnotList(CPDFSDK_PageView * pPageView,CFX_PtrArray* pList=NULL); - - void InsertSort(CFX_PtrArray &arrayList, AI_COMPARE pCompare); - -protected: - CPDFSDK_Annot* NextAnnot (const CPDFSDK_Annot* pCurrent) ; - CPDFSDK_Annot* PrevAnnot (const CPDFSDK_Annot* pCurrent) ; - CPDFSDK_Annot* NextAnnot(int& index ) ; - CPDFSDK_Annot* PrevAnnot(int& index ) ; - - CFX_PtrArray m_pIteratorAnnotList; - FX_BOOL m_bReverse; - FX_BOOL m_bIgnoreTopmost; - FX_BOOL m_bCircle; +typedef int (*AI_COMPARE)(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); + +class CPDFSDK_AnnotIterator { + public: + CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, + FX_BOOL bReverse, + FX_BOOL bIgnoreTopmost = FALSE, + FX_BOOL bCircle = FALSE, + CFX_PtrArray* pList = NULL); + virtual ~CPDFSDK_AnnotIterator() {} + + virtual CPDFSDK_Annot* Next(const CPDFSDK_Annot* pCurrent); + virtual CPDFSDK_Annot* Prev(const CPDFSDK_Annot* pCurrent); + virtual CPDFSDK_Annot* Next(int& index); + virtual CPDFSDK_Annot* Prev(int& index); + virtual int Count() { return m_pIteratorAnnotList.GetSize(); } + + virtual FX_BOOL InitIteratorAnnotList(CPDFSDK_PageView* pPageView, + CFX_PtrArray* pList = NULL); + + void InsertSort(CFX_PtrArray& arrayList, AI_COMPARE pCompare); + + protected: + CPDFSDK_Annot* NextAnnot(const CPDFSDK_Annot* pCurrent); + CPDFSDK_Annot* PrevAnnot(const CPDFSDK_Annot* pCurrent); + CPDFSDK_Annot* NextAnnot(int& index); + CPDFSDK_Annot* PrevAnnot(int& index); + + CFX_PtrArray m_pIteratorAnnotList; + FX_BOOL m_bReverse; + FX_BOOL m_bIgnoreTopmost; + FX_BOOL m_bCircle; }; #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h index dcd295de9f..bfeebeb9f3 100644 --- a/fpdfsdk/include/fsdk_baseannot.h +++ b/fpdfsdk/include/fsdk_baseannot.h @@ -25,169 +25,172 @@ class CPDF_Matrix; class CPDF_RenderOptions; class CFX_RenderDevice; -#define CFX_IntArray CFX_ArrayTemplate - -class CPDFSDK_DateTime -{ -public: - CPDFSDK_DateTime(); - CPDFSDK_DateTime(const CFX_ByteString& dtStr); - CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime); - CPDFSDK_DateTime(const FX_SYSTEMTIME& st); - - - CPDFSDK_DateTime& operator = (const CPDFSDK_DateTime& datetime); - CPDFSDK_DateTime& operator = (const FX_SYSTEMTIME& st); - FX_BOOL operator == (CPDFSDK_DateTime& datetime); - FX_BOOL operator != (CPDFSDK_DateTime& datetime); - FX_BOOL operator > (CPDFSDK_DateTime& datetime); - FX_BOOL operator >= (CPDFSDK_DateTime& datetime); - FX_BOOL operator < (CPDFSDK_DateTime& datetime); - FX_BOOL operator <= (CPDFSDK_DateTime& datetime); - operator time_t(); - - CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr); - CFX_ByteString ToCommonDateTimeString(); - CFX_ByteString ToPDFDateTimeString(); - void ToSystemTime(FX_SYSTEMTIME& st); - CPDFSDK_DateTime ToGMT(); - CPDFSDK_DateTime& AddDays(short days); - CPDFSDK_DateTime& AddSeconds(int seconds); - - void ResetDateTime(); - - struct FX_DATETIME - { - int16_t year; - uint8_t month; - uint8_t day; - uint8_t hour; - uint8_t minute; - uint8_t second; - int8_t tzHour; - uint8_t tzMinute; - }dt; +#define CFX_IntArray CFX_ArrayTemplate + +class CPDFSDK_DateTime { + public: + CPDFSDK_DateTime(); + CPDFSDK_DateTime(const CFX_ByteString& dtStr); + CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime); + CPDFSDK_DateTime(const FX_SYSTEMTIME& st); + + CPDFSDK_DateTime& operator=(const CPDFSDK_DateTime& datetime); + CPDFSDK_DateTime& operator=(const FX_SYSTEMTIME& st); + FX_BOOL operator==(CPDFSDK_DateTime& datetime); + FX_BOOL operator!=(CPDFSDK_DateTime& datetime); + FX_BOOL operator>(CPDFSDK_DateTime& datetime); + FX_BOOL operator>=(CPDFSDK_DateTime& datetime); + FX_BOOL operator<(CPDFSDK_DateTime& datetime); + FX_BOOL operator<=(CPDFSDK_DateTime& datetime); + operator time_t(); + + CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr); + CFX_ByteString ToCommonDateTimeString(); + CFX_ByteString ToPDFDateTimeString(); + void ToSystemTime(FX_SYSTEMTIME& st); + CPDFSDK_DateTime ToGMT(); + CPDFSDK_DateTime& AddDays(short days); + CPDFSDK_DateTime& AddSeconds(int seconds); + + void ResetDateTime(); + + struct FX_DATETIME { + int16_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; + int8_t tzHour; + uint8_t tzMinute; + } dt; }; -class CPDFSDK_Annot -{ -public: - CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); - virtual ~CPDFSDK_Annot(); -public: - virtual FX_FLOAT GetMinWidth() const; - virtual FX_FLOAT GetMinHeight() const; - //define layout order to 5. - virtual int GetLayoutOrder() const { return 5; } +class CPDFSDK_Annot { + public: + CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); + virtual ~CPDFSDK_Annot(); -public: - CPDF_Annot* GetPDFAnnot(); + public: + virtual FX_FLOAT GetMinWidth() const; + virtual FX_FLOAT GetMinHeight() const; + // define layout order to 5. + virtual int GetLayoutOrder() const { return 5; } - void SetPage(CPDFSDK_PageView* pPageView); - CPDFSDK_PageView* GetPageView(); - FX_DWORD GetFlags(); + public: + CPDF_Annot* GetPDFAnnot(); - // Tab Order - int GetTabOrder(); - void SetTabOrder(int iTabOrder); + void SetPage(CPDFSDK_PageView* pPageView); + CPDFSDK_PageView* GetPageView(); + FX_DWORD GetFlags(); - // Selection - FX_BOOL IsSelected(); - void SetSelected(FX_BOOL bSelected); + // Tab Order + int GetTabOrder(); + void SetTabOrder(int iTabOrder); - CFX_ByteString GetType() const; - virtual CFX_ByteString GetSubType() const; + // Selection + FX_BOOL IsSelected(); + void SetSelected(FX_BOOL bSelected); - CPDF_Page* GetPDFPage(); + CFX_ByteString GetType() const; + virtual CFX_ByteString GetSubType() const; -public: - CPDF_Dictionary* GetAnnotDict() const; + CPDF_Page* GetPDFPage(); - void SetRect(const CPDF_Rect& rect); - CPDF_Rect GetRect() const; + public: + CPDF_Dictionary* GetAnnotDict() const; - void SetContents(const CFX_WideString& sContents); - CFX_WideString GetContents() const; + void SetRect(const CPDF_Rect& rect); + CPDF_Rect GetRect() const; - void SetAnnotName(const CFX_WideString& sName); - CFX_WideString GetAnnotName() const; + void SetContents(const CFX_WideString& sContents); + CFX_WideString GetContents() const; - void SetModifiedDate(const FX_SYSTEMTIME& st); - FX_SYSTEMTIME GetModifiedDate() const; + void SetAnnotName(const CFX_WideString& sName); + CFX_WideString GetAnnotName() const; - void SetFlags(int nFlags); - int GetFlags() const; + void SetModifiedDate(const FX_SYSTEMTIME& st); + FX_SYSTEMTIME GetModifiedDate() const; - void SetAppState(const CFX_ByteString& str); - CFX_ByteString GetAppState() const; + void SetFlags(int nFlags); + int GetFlags() const; - void SetStructParent(int key); - int GetStructParent() const; + void SetAppState(const CFX_ByteString& str); + CFX_ByteString GetAppState() const; - //border - void SetBorderWidth(int nWidth); - int GetBorderWidth() const; + void SetStructParent(int key); + int GetStructParent() const; - //BBS_SOLID - //BBS_DASH - //BBS_BEVELED - //BBS_INSET - //BBS_UNDERLINE + // border + void SetBorderWidth(int nWidth); + int GetBorderWidth() const; - void SetBorderStyle(int nStyle); - int GetBorderStyle() const; + // BBS_SOLID + // BBS_DASH + // BBS_BEVELED + // BBS_INSET + // BBS_UNDERLINE - void SetBorderDash(const CFX_IntArray& array); - void GetBorderDash(CFX_IntArray& array) const; + void SetBorderStyle(int nStyle); + int GetBorderStyle() const; - //The background of the annotation's icon when closed - //The title bar of the annotation's pop-up window - //The border of a link annotation + void SetBorderDash(const CFX_IntArray& array); + void GetBorderDash(CFX_IntArray& array) const; - void SetColor(FX_COLORREF color); - void RemoveColor(); - FX_BOOL GetColor(FX_COLORREF& color) const; + // The background of the annotation's icon when closed + // The title bar of the annotation's pop-up window + // The border of a link annotation - FX_BOOL IsVisible() const; - //action + void SetColor(FX_COLORREF color); + void RemoveColor(); + FX_BOOL GetColor(FX_COLORREF& color) const; - CPDF_Action GetAction() const; - void SetAction(const CPDF_Action& a); - void RemoveAction(); + FX_BOOL IsVisible() const; + // action - CPDF_AAction GetAAction() const; - void SetAAction(const CPDF_AAction& aa); - void RemoveAAction(); + CPDF_Action GetAction() const; + void SetAction(const CPDF_Action& a); + void RemoveAction(); - virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); + CPDF_AAction GetAAction() const; + void SetAAction(const CPDF_AAction& aa); + void RemoveAAction(); -public: - FX_BOOL IsAppearanceValid(); - FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode); - void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, - CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions); - void DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, - const CPDF_RenderOptions* pOptions); + virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); - void ClearCachedAP(); + public: + FX_BOOL IsAppearanceValid(); + FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode); + void DrawAppearance(CFX_RenderDevice* pDevice, + const CPDF_Matrix* pUser2Device, + CPDF_Annot::AppearanceMode mode, + const CPDF_RenderOptions* pOptions); + void DrawBorder(CFX_RenderDevice* pDevice, + const CPDF_Matrix* pUser2Device, + const CPDF_RenderOptions* pOptions); - void WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox, - const CPDF_Matrix& matrix, const CFX_ByteString& sContents, - const CFX_ByteString& sAPState = ""); + void ClearCachedAP(); -public: - virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions); -public: + void WriteAppearance(const CFX_ByteString& sAPType, + const CPDF_Rect& rcBBox, + const CPDF_Matrix& matrix, + const CFX_ByteString& sContents, + const CFX_ByteString& sAPState = ""); + public: + virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + CPDF_RenderOptions* pOptions); -private: - FX_BOOL CreateFormFiller(); -protected: - CPDF_Annot* m_pAnnot; - CPDFSDK_PageView* m_pPageView; - FX_BOOL m_bSelected; - int m_nTabOrder; + public: + private: + FX_BOOL CreateFormFiller(); + protected: + CPDF_Annot* m_pAnnot; + CPDFSDK_PageView* m_pPageView; + FX_BOOL m_bSelected; + int m_nTabOrder; }; #endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_ diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index edbd5e4efc..b685ae6a8e 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -31,255 +31,277 @@ class CPDF_Action; class CPDF_FormField; struct CPWL_Color; -typedef struct _PDFSDK_FieldAction -{ - _PDFSDK_FieldAction() - { - bModifier = FALSE; - bShift = FALSE; - nCommitKey = 0; - bKeyDown = FALSE; - nSelEnd = nSelStart = 0; - bWillCommit = FALSE; - bFieldFull = FALSE; - bRC = TRUE; - } - - FX_BOOL bModifier; //in - FX_BOOL bShift; //in - int nCommitKey; //in - CFX_WideString sChange; //in[out] - CFX_WideString sChangeEx; //in - FX_BOOL bKeyDown; //in - int nSelEnd; //in[out] - int nSelStart; //in[out] - CFX_WideString sValue; //in[out] - FX_BOOL bWillCommit; //in - FX_BOOL bFieldFull; //in - FX_BOOL bRC; //in[out] -}PDFSDK_FieldAction; -class CPDFSDK_Widget : public CPDFSDK_Annot -{ -public: - CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm); - virtual ~CPDFSDK_Widget(); - - virtual CFX_ByteString GetSubType() const; - - virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); - - int GetFieldType() const; - //define layout order to 2. - virtual int GetLayoutOrder() const {return 2;} - /* - FIELDFLAG_READONLY - FIELDFLAG_REQUIRED - FIELDFLAG_NOEXPORT - */ - - int GetFieldFlags() const; - int GetRotate() const; - - FX_BOOL GetFillColor(FX_COLORREF& color) const; - FX_BOOL GetBorderColor(FX_COLORREF& color) const; - FX_BOOL GetTextColor(FX_COLORREF& color) const; - FX_FLOAT GetFontSize() const; - - int GetSelectedIndex(int nIndex) const; - CFX_WideString GetValue() const; - CFX_WideString GetDefaultValue() const; - CFX_WideString GetOptionLabel(int nIndex) const; - int CountOptions() const; - FX_BOOL IsOptionSelected(int nIndex) const; - int GetTopVisibleIndex() const; - FX_BOOL IsChecked() const; - /* - BF_ALIGN_LEFT - BF_ALIGN_MIDDL - BF_ALIGN_RIGHT - */ - int GetAlignment() const; - int GetMaxLen() const; - CFX_WideString GetAlternateName() const; - -//Set Properties. - void SetCheck(FX_BOOL bChecked, FX_BOOL bNotify); - void SetValue(const CFX_WideString& sValue, FX_BOOL bNotify); - void SetDefaultValue(const CFX_WideString& sValue); - void SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify); - void ClearSelection(FX_BOOL bNotify); - void SetTopVisibleIndex(int index); - - void ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChanged); - void ResetFieldAppearance(FX_BOOL bValueChanged); - void UpdateField(); - CFX_WideString OnFormat(FX_BOOL& bFormated); - -//Message. - FX_BOOL OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, - CPDFSDK_PageView* pPageView); - - CPDFSDK_InterForm* GetInterForm() const {return m_pInterForm;} - CPDF_FormField* GetFormField() const; - CPDF_FormControl* GetFormControl() const; - static CPDF_FormControl* GetFormControl(CPDF_InterForm* pInterForm, CPDF_Dictionary* pAnnotDict); - - void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView); - - void SetAppModified(); - void ClearAppModified(); - FX_BOOL IsAppModified() const; - - int32_t GetAppearanceAge() const; - int32_t GetValueAge() const; - -private: - void ResetAppearance_PushButton(); - void ResetAppearance_CheckBox(); - void ResetAppearance_RadioButton(); - void ResetAppearance_ComboBox(const FX_WCHAR* sValue); - void ResetAppearance_ListBox(); - void ResetAppearance_TextField(const FX_WCHAR* sValue); - - CPDF_Rect GetClientRect() const; - CPDF_Rect GetRotatedRect() const; - - CFX_ByteString GetBackgroundAppStream() const; - CFX_ByteString GetBorderAppStream() const; - CPDF_Matrix GetMatrix() const; - - CPWL_Color GetTextPWLColor() const; - CPWL_Color GetBorderPWLColor() const; - CPWL_Color GetFillPWLColor() const; - - void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage); - void RemoveAppearance(const CFX_ByteString& sAPType); -public: - FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode); - void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, - CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions); -public: - FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY); -private: - CPDFSDK_InterForm* m_pInterForm; - FX_BOOL m_bAppModified; - int32_t m_nAppAge; - int32_t m_nValueAge; +typedef struct _PDFSDK_FieldAction { + _PDFSDK_FieldAction() { + bModifier = FALSE; + bShift = FALSE; + nCommitKey = 0; + bKeyDown = FALSE; + nSelEnd = nSelStart = 0; + bWillCommit = FALSE; + bFieldFull = FALSE; + bRC = TRUE; + } + + FX_BOOL bModifier; // in + FX_BOOL bShift; // in + int nCommitKey; // in + CFX_WideString sChange; // in[out] + CFX_WideString sChangeEx; // in + FX_BOOL bKeyDown; // in + int nSelEnd; // in[out] + int nSelStart; // in[out] + CFX_WideString sValue; // in[out] + FX_BOOL bWillCommit; // in + FX_BOOL bFieldFull; // in + FX_BOOL bRC; // in[out] +} PDFSDK_FieldAction; +class CPDFSDK_Widget : public CPDFSDK_Annot { + public: + CPDFSDK_Widget(CPDF_Annot* pAnnot, + CPDFSDK_PageView* pPageView, + CPDFSDK_InterForm* pInterForm); + virtual ~CPDFSDK_Widget(); + + virtual CFX_ByteString GetSubType() const; + + virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); + + int GetFieldType() const; + // define layout order to 2. + virtual int GetLayoutOrder() const { return 2; } + /* + FIELDFLAG_READONLY + FIELDFLAG_REQUIRED + FIELDFLAG_NOEXPORT + */ + + int GetFieldFlags() const; + int GetRotate() const; + + FX_BOOL GetFillColor(FX_COLORREF& color) const; + FX_BOOL GetBorderColor(FX_COLORREF& color) const; + FX_BOOL GetTextColor(FX_COLORREF& color) const; + FX_FLOAT GetFontSize() const; + + int GetSelectedIndex(int nIndex) const; + CFX_WideString GetValue() const; + CFX_WideString GetDefaultValue() const; + CFX_WideString GetOptionLabel(int nIndex) const; + int CountOptions() const; + FX_BOOL IsOptionSelected(int nIndex) const; + int GetTopVisibleIndex() const; + FX_BOOL IsChecked() const; + /* + BF_ALIGN_LEFT + BF_ALIGN_MIDDL + BF_ALIGN_RIGHT + */ + int GetAlignment() const; + int GetMaxLen() const; + CFX_WideString GetAlternateName() const; + + // Set Properties. + void SetCheck(FX_BOOL bChecked, FX_BOOL bNotify); + void SetValue(const CFX_WideString& sValue, FX_BOOL bNotify); + void SetDefaultValue(const CFX_WideString& sValue); + void SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify); + void ClearSelection(FX_BOOL bNotify); + void SetTopVisibleIndex(int index); + + void ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChanged); + void ResetFieldAppearance(FX_BOOL bValueChanged); + void UpdateField(); + CFX_WideString OnFormat(FX_BOOL& bFormated); + + // Message. + FX_BOOL OnAAction(CPDF_AAction::AActionType type, + PDFSDK_FieldAction& data, + CPDFSDK_PageView* pPageView); + + CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm; } + CPDF_FormField* GetFormField() const; + CPDF_FormControl* GetFormControl() const; + static CPDF_FormControl* GetFormControl(CPDF_InterForm* pInterForm, + CPDF_Dictionary* pAnnotDict); + + void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView); + + void SetAppModified(); + void ClearAppModified(); + FX_BOOL IsAppModified() const; + + int32_t GetAppearanceAge() const; + int32_t GetValueAge() const; + + private: + void ResetAppearance_PushButton(); + void ResetAppearance_CheckBox(); + void ResetAppearance_RadioButton(); + void ResetAppearance_ComboBox(const FX_WCHAR* sValue); + void ResetAppearance_ListBox(); + void ResetAppearance_TextField(const FX_WCHAR* sValue); + + CPDF_Rect GetClientRect() const; + CPDF_Rect GetRotatedRect() const; + + CFX_ByteString GetBackgroundAppStream() const; + CFX_ByteString GetBorderAppStream() const; + CPDF_Matrix GetMatrix() const; + + CPWL_Color GetTextPWLColor() const; + CPWL_Color GetBorderPWLColor() const; + CPWL_Color GetFillPWLColor() const; + + void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage); + void RemoveAppearance(const CFX_ByteString& sAPType); + + public: + FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode); + void DrawAppearance(CFX_RenderDevice* pDevice, + const CPDF_Matrix* pUser2Device, + CPDF_Annot::AppearanceMode mode, + const CPDF_RenderOptions* pOptions); + + public: + FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY); + + private: + CPDFSDK_InterForm* m_pInterForm; + FX_BOOL m_bAppModified; + int32_t m_nAppAge; + int32_t m_nValueAge; }; -class CPDFSDK_InterForm : public CPDF_FormNotify -{ -public: - explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument); - ~CPDFSDK_InterForm() override; +class CPDFSDK_InterForm : public CPDF_FormNotify { + public: + explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument); + ~CPDFSDK_InterForm() override; - CPDF_InterForm* GetInterForm() const { return m_pInterForm; } - CPDFSDK_Document* GetDocument() const { return m_pDocument; } + CPDF_InterForm* GetInterForm() const { return m_pInterForm; } + CPDFSDK_Document* GetDocument() const { return m_pDocument; } - FX_BOOL HighlightWidgets(); + FX_BOOL HighlightWidgets(); - CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const; - CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl) const; - void GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArray& widgets); - void GetWidgets(CPDF_FormField* pField, CFX_PtrArray& widgets); + CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const; + CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl) const; + void GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArray& widgets); + void GetWidgets(CPDF_FormField* pField, CFX_PtrArray& widgets); - void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget); - void RemoveMap(CPDF_FormControl* pControl); + void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget); + void RemoveMap(CPDF_FormControl* pControl); - void EnableCalculate(FX_BOOL bEnabled); - FX_BOOL IsCalculateEnabled() const; + void EnableCalculate(FX_BOOL bEnabled); + FX_BOOL IsCalculateEnabled() const; #ifdef _WIN32 - CPDF_Stream* LoadImageFromFile(const CFX_WideString& sFile); + CPDF_Stream* LoadImageFromFile(const CFX_WideString& sFile); #endif - void OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC); - void OnValidate(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC); - void OnCalculate(CPDF_FormField* pFormField = NULL); - CFX_WideString OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormated); - - void ResetFieldAppearance(CPDF_FormField* pFormField, const FX_WCHAR* sValue, FX_BOOL bValueChanged); - void UpdateField(CPDF_FormField* pFormField); - - FX_BOOL DoAction_Hide(const CPDF_Action& action); - FX_BOOL DoAction_SubmitForm(const CPDF_Action& action); - FX_BOOL DoAction_ResetForm(const CPDF_Action& action); - FX_BOOL DoAction_ImportData(const CPDF_Action& action); - - void GetFieldFromObjects(const CFX_PtrArray& objects, CFX_PtrArray& fields); - FX_BOOL IsValidField(CPDF_Dictionary* pFieldDict); - FX_BOOL SubmitFields(const CFX_WideString& csDestination, const CFX_PtrArray& fields, - FX_BOOL bIncludeOrExclude, FX_BOOL bUrlEncoded); - FX_BOOL SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded); - FX_BOOL ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf); - FX_BOOL ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,FX_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf); - CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); - -private: - virtual int BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue); - virtual int AfterValueChange(const CPDF_FormField* pField); - virtual int BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue); - virtual int AfterSelectionChange(const CPDF_FormField* pField); - virtual int AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray); - virtual int BeforeFormReset(const CPDF_InterForm* pForm); - virtual int AfterFormReset(const CPDF_InterForm* pForm); - virtual int BeforeFormImportData(const CPDF_InterForm* pForm); - virtual int AfterFormImportData(const CPDF_InterForm* pForm); - - FX_BOOL FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_WideString csTxtFile); - FX_BOOL FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize); - int GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const; - void DoFDFBuffer(CFX_ByteString sBuffer); - - using CPDFSDK_WidgetMap = std::map; - - CPDFSDK_Document* m_pDocument; - CPDF_InterForm* m_pInterForm; - CPDFSDK_WidgetMap m_Map; - FX_BOOL m_bCalculate; - FX_BOOL m_bBusy; - -public: - FX_BOOL IsNeedHighLight(int nFieldType); - void RemoveAllHighLight(); - void SetHighlightAlpha(uint8_t alpha) {m_iHighlightAlpha = alpha;} - uint8_t GetHighlightAlpha() {return m_iHighlightAlpha;} - void SetHighlightColor(FX_COLORREF clr, int nFieldType); - FX_COLORREF GetHighlightColor(int nFieldType); -private: - FX_COLORREF m_aHighlightColor[6]; - uint8_t m_iHighlightAlpha; - FX_BOOL m_bNeedHightlight[6]; + void OnKeyStrokeCommit(CPDF_FormField* pFormField, + CFX_WideString& csValue, + FX_BOOL& bRC); + void OnValidate(CPDF_FormField* pFormField, + CFX_WideString& csValue, + FX_BOOL& bRC); + void OnCalculate(CPDF_FormField* pFormField = NULL); + CFX_WideString OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormated); + + void ResetFieldAppearance(CPDF_FormField* pFormField, + const FX_WCHAR* sValue, + FX_BOOL bValueChanged); + void UpdateField(CPDF_FormField* pFormField); + + FX_BOOL DoAction_Hide(const CPDF_Action& action); + FX_BOOL DoAction_SubmitForm(const CPDF_Action& action); + FX_BOOL DoAction_ResetForm(const CPDF_Action& action); + FX_BOOL DoAction_ImportData(const CPDF_Action& action); + + void GetFieldFromObjects(const CFX_PtrArray& objects, CFX_PtrArray& fields); + FX_BOOL IsValidField(CPDF_Dictionary* pFieldDict); + FX_BOOL SubmitFields(const CFX_WideString& csDestination, + const CFX_PtrArray& fields, + FX_BOOL bIncludeOrExclude, + FX_BOOL bUrlEncoded); + FX_BOOL SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded); + FX_BOOL ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf); + FX_BOOL ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields, + FX_BOOL bIncludeOrExclude, + CFX_ByteTextBuf& textBuf); + CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); + + private: + virtual int BeforeValueChange(const CPDF_FormField* pField, + CFX_WideString& csValue); + virtual int AfterValueChange(const CPDF_FormField* pField); + virtual int BeforeSelectionChange(const CPDF_FormField* pField, + CFX_WideString& csValue); + virtual int AfterSelectionChange(const CPDF_FormField* pField); + virtual int AfterCheckedStatusChange(const CPDF_FormField* pField, + const CFX_ByteArray& statusArray); + virtual int BeforeFormReset(const CPDF_InterForm* pForm); + virtual int AfterFormReset(const CPDF_InterForm* pForm); + virtual int BeforeFormImportData(const CPDF_InterForm* pForm); + virtual int AfterFormImportData(const CPDF_InterForm* pForm); + + FX_BOOL FDFToURLEncodedData(CFX_WideString csFDFFile, + CFX_WideString csTxtFile); + FX_BOOL FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize); + int GetPageIndexByAnnotDict(CPDF_Document* pDocument, + CPDF_Dictionary* pAnnotDict) const; + void DoFDFBuffer(CFX_ByteString sBuffer); + + using CPDFSDK_WidgetMap = std::map; + + CPDFSDK_Document* m_pDocument; + CPDF_InterForm* m_pInterForm; + CPDFSDK_WidgetMap m_Map; + FX_BOOL m_bCalculate; + FX_BOOL m_bBusy; + + public: + FX_BOOL IsNeedHighLight(int nFieldType); + void RemoveAllHighLight(); + void SetHighlightAlpha(uint8_t alpha) { m_iHighlightAlpha = alpha; } + uint8_t GetHighlightAlpha() { return m_iHighlightAlpha; } + void SetHighlightColor(FX_COLORREF clr, int nFieldType); + FX_COLORREF GetHighlightColor(int nFieldType); + + private: + FX_COLORREF m_aHighlightColor[6]; + uint8_t m_iHighlightAlpha; + FX_BOOL m_bNeedHightlight[6]; }; -#define BAI_STRUCTURE 0 -#define BAI_ROW 1 -#define BAI_COLUMN 2 - -#define CPDFSDK_Annots CFX_ArrayTemplate -#define CPDFSDK_SortAnnots CGW_ArrayTemplate -class CBA_AnnotIterator -{ -public: - CBA_AnnotIterator(CPDFSDK_PageView* pPageView, const CFX_ByteString& sType, const CFX_ByteString& sSubType); - ~CBA_AnnotIterator(); - - CPDFSDK_Annot* GetFirstAnnot(); - CPDFSDK_Annot* GetLastAnnot(); - CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pAnnot); - CPDFSDK_Annot* GetPrevAnnot(CPDFSDK_Annot* pAnnot); - -private: - void GenerateResults(); - static int CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); - static int CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); - static CPDF_Rect GetAnnotRect(CPDFSDK_Annot* pAnnot); - - CPDFSDK_PageView* m_pPageView; - CFX_ByteString m_sType; - CFX_ByteString m_sSubType; - int m_nTabs; - CPDFSDK_Annots m_Annots; +#define BAI_STRUCTURE 0 +#define BAI_ROW 1 +#define BAI_COLUMN 2 + +#define CPDFSDK_Annots CFX_ArrayTemplate +#define CPDFSDK_SortAnnots CGW_ArrayTemplate +class CBA_AnnotIterator { + public: + CBA_AnnotIterator(CPDFSDK_PageView* pPageView, + const CFX_ByteString& sType, + const CFX_ByteString& sSubType); + ~CBA_AnnotIterator(); + + CPDFSDK_Annot* GetFirstAnnot(); + CPDFSDK_Annot* GetLastAnnot(); + CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pAnnot); + CPDFSDK_Annot* GetPrevAnnot(CPDFSDK_Annot* pAnnot); + + private: + void GenerateResults(); + static int CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); + static int CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); + static CPDF_Rect GetAnnotRect(CPDFSDK_Annot* pAnnot); + + CPDFSDK_PageView* m_pPageView; + CFX_ByteString m_sType; + CFX_ByteString m_sSubType; + int m_nTabs; + CPDFSDK_Annots m_Annots; }; #endif // FPDFSDK_INCLUDE_FSDK_BASEFORM_H_ diff --git a/fpdfsdk/include/fsdk_common.h b/fpdfsdk/include/fsdk_common.h index b243cd4ab7..279048b9ac 100644 --- a/fpdfsdk/include/fsdk_common.h +++ b/fpdfsdk/include/fsdk_common.h @@ -7,39 +7,39 @@ #ifndef FPDFSDK_INCLUDE_FSDK_COMMON_H_ #define FPDFSDK_INCLUDE_FSDK_COMMON_H_ -#define BFFT_SIGNATURE "Signature" +#define BFFT_SIGNATURE "Signature" -//for all fields -#define FIELDFLAG_READONLY 1 -#define FIELDFLAG_REQUIRED 2 -#define FIELDFLAG_NOEXPORT 4 -//for text fields -#define FIELDFLAG_MULTILINE (1<<12) -#define FIELDFLAG_PASSWORD (1<<13) -#define FIELDFLAG_FILESELECT (1<<20) -#define FIELDFLAG_DONOTSPELLCHECK (1<<22) -#define FIELDFLAG_DONOTSCROLL (1<<23) -#define FIELDFLAG_COMB (1<<24) -#define FIELDFLAG_RICHTEXT (1<<25) -//for button fileds -#define FIELDFLAG_NOTOGGLETOOFF (1<<14) -#define FIELDFLAG_RADIO (1<<15) -#define FIELDFLAG_PUSHBUTTON (1<<16) -#define FIELDFLAG_RADIOSINUNISON (1<<25) -//for choice fields -#define FIELDFLAG_COMBO (1<<17) -#define FIELDFLAG_EDIT (1<<18) -#define FIELDFLAG_SORT (1<<19) -#define FIELDFLAG_MULTISELECT (1<<21) +// for all fields +#define FIELDFLAG_READONLY 1 +#define FIELDFLAG_REQUIRED 2 +#define FIELDFLAG_NOEXPORT 4 +// for text fields +#define FIELDFLAG_MULTILINE (1 << 12) +#define FIELDFLAG_PASSWORD (1 << 13) +#define FIELDFLAG_FILESELECT (1 << 20) +#define FIELDFLAG_DONOTSPELLCHECK (1 << 22) +#define FIELDFLAG_DONOTSCROLL (1 << 23) +#define FIELDFLAG_COMB (1 << 24) +#define FIELDFLAG_RICHTEXT (1 << 25) +// for button fileds +#define FIELDFLAG_NOTOGGLETOOFF (1 << 14) +#define FIELDFLAG_RADIO (1 << 15) +#define FIELDFLAG_PUSHBUTTON (1 << 16) +#define FIELDFLAG_RADIOSINUNISON (1 << 25) +// for choice fields +#define FIELDFLAG_COMBO (1 << 17) +#define FIELDFLAG_EDIT (1 << 18) +#define FIELDFLAG_SORT (1 << 19) +#define FIELDFLAG_MULTISELECT (1 << 21) #ifndef FIELDFLAG_DONOTSPELLCHECK -#define FIELDFLAG_DONOTSPELLCHECK (1<<22) +#define FIELDFLAG_DONOTSPELLCHECK (1 << 22) #endif -#define FIELDFLAG_COMMITONSELCHANGE (1<<26) +#define FIELDFLAG_COMMITONSELCHANGE (1 << 26) -#define BBS_SOLID 0 -#define BBS_DASH 1 -#define BBS_BEVELED 2 -#define BBS_INSET 3 -#define BBS_UNDERLINE 4 +#define BBS_SOLID 0 +#define BBS_DASH 1 +#define BBS_BEVELED 2 +#define BBS_INSET 3 +#define BBS_UNDERLINE 4 #endif // FPDFSDK_INCLUDE_FSDK_COMMON_H_ diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index 29b265a428..310fa43bd0 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -27,40 +27,51 @@ #ifndef FX_ARGBTOCOLORREF /** @brief Convert a #FX_ARGB to a #FX_COLORREF. */ -#define FX_ARGBTOCOLORREF(argb) ((((FX_DWORD)argb & 0x00FF0000) >> 16)|((FX_DWORD)argb & 0x0000FF00)|(((FX_DWORD)argb & 0x000000FF) << 16)) +#define FX_ARGBTOCOLORREF(argb) \ + ((((FX_DWORD)argb & 0x00FF0000) >> 16) | ((FX_DWORD)argb & 0x0000FF00) | \ + (((FX_DWORD)argb & 0x000000FF) << 16)) #endif #ifndef FX_COLORREFTOARGB /** @brief Convert a #FX_COLORREF to a #FX_ARGB. */ -#define FX_COLORREFTOARGB(rgb) ((FX_DWORD)0xFF000000|(((FX_DWORD)rgb & 0x000000FF) << 16)|((FX_DWORD)rgb & 0x0000FF00)|(((FX_DWORD)rgb & 0x00FF0000) >> 16)) +#define FX_COLORREFTOARGB(rgb) \ + ((FX_DWORD)0xFF000000 | (((FX_DWORD)rgb & 0x000000FF) << 16) | \ + ((FX_DWORD)rgb & 0x0000FF00) | (((FX_DWORD)rgb & 0x00FF0000) >> 16)) #endif typedef unsigned int FX_UINT; class CRenderContext; class IFSDK_PAUSE_Adapter; -class CPDF_CustomAccess final : public IFX_FileRead -{ -public: - CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess); - ~CPDF_CustomAccess() {} +class CPDF_CustomAccess final : public IFX_FileRead { + public: + CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess); + ~CPDF_CustomAccess() {} - virtual FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; } + virtual FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; } - virtual void Release() override { delete this; } + virtual void Release() override { delete this; } - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; + virtual FX_BOOL ReadBlock(void* buffer, + FX_FILESIZE offset, + size_t size) override; -private: - FPDF_FILEACCESS m_FileAccess; + private: + FPDF_FILEACCESS m_FileAccess; }; void DropContext(void* data); void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy); -void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, - int start_x, int start_y, int size_x, int size_y, - int rotate, int flags, FX_BOOL bNeedToRestore, +void FPDF_RenderPage_Retail(CRenderContext* pContext, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags, + FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter* pause); #endif // FPDFSDK_INCLUDE_FSDK_DEFINE_H_ diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index d57138b350..4cb0ae8c15 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -11,7 +11,7 @@ #include "../../core/include/fpdftext/fpdf_text.h" #include "../../public/fpdf_formfill.h" -#include "../../public/fpdf_fwlevent.h" // cross platform keycode and events define. +#include "../../public/fpdf_fwlevent.h" // cross platform keycode and events define. #include "fsdk_common.h" #include "fsdk_define.h" #include "fx_systemhandler.h" @@ -31,384 +31,399 @@ class CPDFSDK_PageView; class CPDFSDK_Widget; class IFX_SystemHandler; -class CPDFDoc_Environment final -{ -public: - CPDFDoc_Environment(CPDF_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo); - ~CPDFDoc_Environment(); - - void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom) - { - if (m_pInfo && m_pInfo->FFI_Invalidate) - m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); - } - - void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom) - { - if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) - m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); - } - - void FFI_SetCursor(int nCursorType) - { - if (m_pInfo && m_pInfo->FFI_SetCursor) - m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); - } - - int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) - { - if (m_pInfo && m_pInfo->FFI_SetTimer) - return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); - return -1; - } - - void FFI_KillTimer(int nTimerID) - { - if (m_pInfo && m_pInfo->FFI_KillTimer) - m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); - } - - FX_SYSTEMTIME FFI_GetLocalTime() const - { - FX_SYSTEMTIME fxtime; - if (m_pInfo && m_pInfo->FFI_GetLocalTime) - { - FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); - fxtime.wDay = systime.wDay; - fxtime.wDayOfWeek = systime.wDayOfWeek; - fxtime.wHour = systime.wHour; - fxtime.wMilliseconds = systime.wMilliseconds; - fxtime.wMinute = systime.wMinute; - fxtime.wMonth = systime.wMonth; - fxtime.wSecond = systime.wSecond; - fxtime.wYear = systime.wYear; - } - return fxtime; - } - - void FFI_OnChange() - { - if (m_pInfo && m_pInfo->FFI_OnChange) - m_pInfo->FFI_OnChange(m_pInfo); - } - - FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) const - { - return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; - } - - FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) const - { - return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; - } - - FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) const - { - return (nFlag & FWL_EVENTFLAG_AltKey) != 0; - } - - FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) const - { - return FALSE; - } - - int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon); - int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default, - const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length); - - void JS_appBeep(int nType) - { - if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep) - m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); - } - - CFX_WideString JS_fieldBrowse(); - CFX_WideString JS_docGetFilePath(); - - void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL); - void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI, - const FX_WCHAR* To, const FX_WCHAR* Subject, - const FX_WCHAR* CC, const FX_WCHAR* BCC, - const FX_WCHAR* Msg); - - void JS_docprint(FPDF_BOOL bUI, int nStart, int nEnd, FPDF_BOOL bSilent, - FPDF_BOOL bShrinkToFit, FPDF_BOOL bPrintAsImage, - FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations) - { - if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print) - m_pInfo->m_pJsPlatform->Doc_print( - m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit, - bPrintAsImage, bReverse, bAnnotations); - } - - void JS_docgotoPage(int nPageNum) - { - if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage) - m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); - } - - FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document, int nPageIndex) - { - if (m_pInfo && m_pInfo->FFI_GetPage) - return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); - return NULL; +class CPDFDoc_Environment final { + public: + CPDFDoc_Environment(CPDF_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo); + ~CPDFDoc_Environment(); + + void FFI_Invalidate(FPDF_PAGE page, + double left, + double top, + double right, + double bottom) { + if (m_pInfo && m_pInfo->FFI_Invalidate) + m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); + } + + void FFI_OutputSelectedRect(FPDF_PAGE page, + double left, + double top, + double right, + double bottom) { + if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) + m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); + } + + void FFI_SetCursor(int nCursorType) { + if (m_pInfo && m_pInfo->FFI_SetCursor) + m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); + } + + int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) { + if (m_pInfo && m_pInfo->FFI_SetTimer) + return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); + return -1; + } + + void FFI_KillTimer(int nTimerID) { + if (m_pInfo && m_pInfo->FFI_KillTimer) + m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); + } + + FX_SYSTEMTIME FFI_GetLocalTime() const { + FX_SYSTEMTIME fxtime; + if (m_pInfo && m_pInfo->FFI_GetLocalTime) { + FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); + fxtime.wDay = systime.wDay; + fxtime.wDayOfWeek = systime.wDayOfWeek; + fxtime.wHour = systime.wHour; + fxtime.wMilliseconds = systime.wMilliseconds; + fxtime.wMinute = systime.wMinute; + fxtime.wMonth = systime.wMonth; + fxtime.wSecond = systime.wSecond; + fxtime.wYear = systime.wYear; } + return fxtime; + } + + void FFI_OnChange() { + if (m_pInfo && m_pInfo->FFI_OnChange) + m_pInfo->FFI_OnChange(m_pInfo); + } + + FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) const { + return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; + } + + FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) const { + return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; + } + + FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) const { + return (nFlag & FWL_EVENTFLAG_AltKey) != 0; + } + + FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) const { return FALSE; } + + int JS_appAlert(const FX_WCHAR* Msg, + const FX_WCHAR* Title, + FX_UINT Type, + FX_UINT Icon); + int JS_appResponse(const FX_WCHAR* Question, + const FX_WCHAR* Title, + const FX_WCHAR* Default, + const FX_WCHAR* cLabel, + FPDF_BOOL bPassword, + void* response, + int length); + + void JS_appBeep(int nType) { + if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep) + m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); + } + + CFX_WideString JS_fieldBrowse(); + CFX_WideString JS_docGetFilePath(); + + void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL); + void JS_docmailForm(void* mailData, + int length, + FPDF_BOOL bUI, + const FX_WCHAR* To, + const FX_WCHAR* Subject, + const FX_WCHAR* CC, + const FX_WCHAR* BCC, + const FX_WCHAR* Msg); + + void JS_docprint(FPDF_BOOL bUI, + int nStart, + int nEnd, + FPDF_BOOL bSilent, + FPDF_BOOL bShrinkToFit, + FPDF_BOOL bPrintAsImage, + FPDF_BOOL bReverse, + FPDF_BOOL bAnnotations) { + if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print) + m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, + nEnd, bSilent, bShrinkToFit, + bPrintAsImage, bReverse, bAnnotations); + } + + void JS_docgotoPage(int nPageNum) { + if (m_pInfo && m_pInfo->m_pJsPlatform && + m_pInfo->m_pJsPlatform->Doc_gotoPage) + m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); + } + + FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document, int nPageIndex) { + if (m_pInfo && m_pInfo->FFI_GetPage) + return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); + return NULL; + } + + FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) { + if (m_pInfo && m_pInfo->FFI_GetCurrentPage) + return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); + return NULL; + } + + int FFI_GetRotation(FPDF_PAGE page) { + if (m_pInfo && m_pInfo->FFI_GetRotation) + return m_pInfo->FFI_GetRotation(m_pInfo, page); + return 0; + } + + void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) { + if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) + m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); + } + + void FFI_OnSetFieldInputFocus(void* field, + FPDF_WIDESTRING focusText, + FPDF_DWORD nTextLen, + FX_BOOL bFocus) { + if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) + m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); + } + + void FFI_DoURIAction(const FX_CHAR* bsURI) { + if (m_pInfo && m_pInfo->FFI_DoURIAction) + m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); + } + + void FFI_DoGoToAction(int nPageIndex, + int zoomMode, + float* fPosArray, + int sizeOfArray) { + if (m_pInfo && m_pInfo->FFI_DoGoToAction) + m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, + sizeOfArray); + } + + FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } + void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; } + CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } + CPDF_Document* GetPDFDocument() const { return m_pPDFDoc; } + CFX_ByteString GetAppName() const { return ""; } + IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler; } + FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } + CJS_RuntimeFactory* GetRuntimeFactory() const { return m_pJSRuntimeFactory; } + + CFFL_IFormFiller* GetIFormFiller(); // Creates if not present. + CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. + IFXJS_Runtime* GetJSRuntime(); // Creates if not present. + CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. + + private: + CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; + CPDFSDK_ActionHandler* m_pActionHandler; + IFXJS_Runtime* m_pJSRuntime; + FPDF_FORMFILLINFO* const m_pInfo; + CPDFSDK_Document* m_pSDKDoc; + CPDF_Document* const m_pPDFDoc; + CFFL_IFormFiller* m_pIFormFiller; + IFX_SystemHandler* m_pSysHandler; + CJS_RuntimeFactory* m_pJSRuntimeFactory; +}; - FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) - { - if (m_pInfo && m_pInfo->FFI_GetCurrentPage) - return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); - return NULL; - } +class CPDFSDK_Document { + public: + CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv); + ~CPDFSDK_Document(); + + CPDFSDK_InterForm* GetInterForm(); + CPDF_Document* GetDocument() { return m_pDoc; } + + CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE); + CPDFSDK_PageView* GetPageView(int nIndex); + CPDFSDK_PageView* GetCurrentView(); + void ReMovePageView(CPDF_Page* pPDFPage); + void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); + + CPDFSDK_Annot* GetFocusAnnot(); + + IFXJS_Runtime* GetJsRuntime(); + + FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); + FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); + + FX_BOOL ExtractPages(const CFX_WordArray& arrExtraPages, + CPDF_Document* pDstDoc); + FX_BOOL InsertPages(int nInsertAt, + const CPDF_Document* pSrcDoc, + const CFX_WordArray& arrSrcPages); + FX_BOOL ReplacePages(int nPage, + const CPDF_Document* pSrcDoc, + const CFX_WordArray& arrSrcPages); + + void OnCloseDocument(); + + int GetPageCount() { return m_pDoc->GetPageCount(); } + FX_BOOL GetPermissions(int nFlag); + FX_BOOL GetChangeMark() { return m_bChangeMask; } + void SetChangeMark() { m_bChangeMask = TRUE; } + void ClearChangeMark() { m_bChangeMask = FALSE; } + CFX_WideString GetPath(); + CPDF_Page* GetPage(int nIndex); + CPDFDoc_Environment* GetEnv() { return m_pEnv; } + void ProcJavascriptFun(); + FX_BOOL ProcOpenAction(); + CPDF_OCContext* GetOCContext(); + + private: + std::map m_pageMap; + CPDF_Document* m_pDoc; + CPDFSDK_InterForm* m_pInterForm; + CPDFSDK_Annot* m_pFocusAnnot; + CPDFDoc_Environment* m_pEnv; + CPDF_OCContext* m_pOccontent; + FX_BOOL m_bChangeMask; +}; +class CPDFSDK_PageView final { + public: + CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDF_Page* page); + ~CPDFSDK_PageView(); + void PageView_OnDraw(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + CPDF_RenderOptions* pOptions); + CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + CPDFSDK_Annot* GetFocusAnnot(); + void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) { + m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag); + } + FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) { + return m_pSDKDoc->KillFocusAnnot(nFlag); + } + FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot); + + CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict); + CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); + CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); + FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); + int CountAnnots(); + CPDFSDK_Annot* GetAnnot(int nIndex); + CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); + CPDF_Page* GetPDFPage() { return m_page; } + CPDF_Document* GetPDFDocument(); + CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } + FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_UINT nFlag); + FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag); + FX_BOOL OnChar(int nChar, FX_UINT nFlag); + FX_BOOL OnKeyDown(int nKeyCode, int nFlag); + FX_BOOL OnKeyUp(int nKeyCode, int nFlag); + + FX_BOOL OnMouseMove(const CPDF_Point& point, int nFlag); + FX_BOOL OnMouseWheel(double deltaX, + double deltaY, + const CPDF_Point& point, + int nFlag); + FX_BOOL IsValidAnnot(void* p); + void GetCurrentMatrix(CPDF_Matrix& matrix) { matrix = m_curMatrix; } + void UpdateRects(CFX_RectArray& rects); + void UpdateView(CPDFSDK_Annot* pAnnot); + CFX_PtrArray* GetAnnotList() { return &m_fxAnnotArray; } + + int GetPageIndex(); + void LoadFXAnnots(); + + void SetValid(FX_BOOL bValid) { m_bValid = bValid; } + FX_BOOL IsValid() { return m_bValid; } + void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; } + FX_BOOL IsLocked() { return m_bLocked; } + void TakeOverPage() { m_bTakeOverPage = TRUE; } + + private: + void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, + CPDFSDK_Widget* pWidget); + CPDF_Matrix m_curMatrix; + CPDF_Page* m_page; + CPDF_AnnotList* m_pAnnotList; + // CPDFSDK_Annot* m_pFocusAnnot; + CFX_PtrArray m_fxAnnotArray; + CPDFSDK_Document* m_pSDKDoc; + CPDFSDK_Widget* m_CaptureWidget; + FX_BOOL m_bEnterWidget; + FX_BOOL m_bExitWidget; + FX_BOOL m_bOnWidget; + FX_BOOL m_bValid; + FX_BOOL m_bLocked; + FX_BOOL m_bTakeOverPage; +}; - int FFI_GetRotation(FPDF_PAGE page) - { - if (m_pInfo && m_pInfo->FFI_GetRotation) - return m_pInfo->FFI_GetRotation(m_pInfo, page); - return 0; +template +class CGW_ArrayTemplate : public CFX_ArrayTemplate { + public: + CGW_ArrayTemplate() {} + virtual ~CGW_ArrayTemplate() {} + + typedef int (*LP_COMPARE)(TYPE p1, TYPE p2); + + void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) { + int nSize = this->GetSize(); + QuickSort(0, nSize - 1, bAscent, pCompare); + } + + private: + void QuickSort(FX_UINT nStartPos, + FX_UINT nStopPos, + FX_BOOL bAscend, + LP_COMPARE pCompare) { + if (nStartPos >= nStopPos) + return; + + if ((nStopPos - nStartPos) == 1) { + TYPE Value1 = this->GetAt(nStartPos); + TYPE Value2 = this->GetAt(nStopPos); + + int iGreate = (*pCompare)(Value1, Value2); + if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) { + this->SetAt(nStartPos, Value2); + this->SetAt(nStopPos, Value1); + } + return; } - void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) - { - if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) - m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); - } + FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2; + FX_UINT i = nStartPos; - void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus) - { - if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) - m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); - } + TYPE Value = this->GetAt(m); - void FFI_DoURIAction(const FX_CHAR* bsURI) - { - if (m_pInfo && m_pInfo->FFI_DoURIAction) - m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); - } + while (i < m) { + TYPE temp = this->GetAt(i); - void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray) - { - if (m_pInfo && m_pInfo->FFI_DoGoToAction) - m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray); + int iGreate = (*pCompare)(temp, Value); + if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) { + this->InsertAt(m + 1, temp); + this->RemoveAt(i); + m--; + } else { + i++; + } } - FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } - void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; } - CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } - CPDF_Document* GetPDFDocument() const { return m_pPDFDoc; } - CFX_ByteString GetAppName() const { return ""; } - IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler; } - FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo;} - CJS_RuntimeFactory* GetRuntimeFactory() const { return m_pJSRuntimeFactory; } - - CFFL_IFormFiller* GetIFormFiller(); // Creates if not present. - CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. - IFXJS_Runtime* GetJSRuntime(); // Creates if not present. - CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. - -private: - CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; - CPDFSDK_ActionHandler* m_pActionHandler; - IFXJS_Runtime* m_pJSRuntime; - FPDF_FORMFILLINFO* const m_pInfo; - CPDFSDK_Document* m_pSDKDoc; - CPDF_Document* const m_pPDFDoc; - CFFL_IFormFiller* m_pIFormFiller; - IFX_SystemHandler* m_pSysHandler; - CJS_RuntimeFactory* m_pJSRuntimeFactory; -}; + FX_UINT j = nStopPos; -class CPDFSDK_Document -{ -public: - CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv); - ~CPDFSDK_Document(); - - CPDFSDK_InterForm* GetInterForm() ; - CPDF_Document* GetDocument() {return m_pDoc;} - - CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE); - CPDFSDK_PageView* GetPageView(int nIndex); - CPDFSDK_PageView* GetCurrentView(); - void ReMovePageView(CPDF_Page* pPDFPage); - void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); - - CPDFSDK_Annot* GetFocusAnnot(); - - IFXJS_Runtime * GetJsRuntime(); - - FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); - FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); - - FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc); - FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); - FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); - - void OnCloseDocument(); - - int GetPageCount() {return m_pDoc->GetPageCount();} - FX_BOOL GetPermissions(int nFlag); - FX_BOOL GetChangeMark() {return m_bChangeMask;} - void SetChangeMark() {m_bChangeMask = TRUE;} - void ClearChangeMark() {m_bChangeMask= FALSE;} - CFX_WideString GetPath() ; - CPDF_Page* GetPage(int nIndex); - CPDFDoc_Environment * GetEnv() {return m_pEnv; } - void ProcJavascriptFun(); - FX_BOOL ProcOpenAction(); - CPDF_OCContext* GetOCContext(); -private: - std::map m_pageMap; - CPDF_Document* m_pDoc; - CPDFSDK_InterForm* m_pInterForm; - CPDFSDK_Annot* m_pFocusAnnot; - CPDFDoc_Environment* m_pEnv; - CPDF_OCContext* m_pOccontent; - FX_BOOL m_bChangeMask; -}; -class CPDFSDK_PageView final -{ -public: - CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page); - ~CPDFSDK_PageView(); - void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ; - CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFocusAnnot() ; - void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);} - FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);} - FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot); - - CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict); - CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict); - CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot); - FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); - int CountAnnots(); - CPDFSDK_Annot* GetAnnot(int nIndex); - CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict); - CPDF_Page* GetPDFPage(){return m_page;} - CPDF_Document* GetPDFDocument(); - CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;} - FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag); - FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag); - FX_BOOL OnChar(int nChar, FX_UINT nFlag); - FX_BOOL OnKeyDown(int nKeyCode, int nFlag); - FX_BOOL OnKeyUp(int nKeyCode, int nFlag); - - FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag); - FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag); - FX_BOOL IsValidAnnot(void* p); - void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;} - void UpdateRects(CFX_RectArray& rects); - void UpdateView(CPDFSDK_Annot* pAnnot); - CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; } - - int GetPageIndex(); - void LoadFXAnnots(); - - void SetValid(FX_BOOL bValid) {m_bValid = bValid;} - FX_BOOL IsValid() {return m_bValid;} - void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;} - FX_BOOL IsLocked() {return m_bLocked;} - void TakeOverPage() {m_bTakeOverPage = TRUE;} -private: - void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget); - CPDF_Matrix m_curMatrix; - CPDF_Page* m_page; - CPDF_AnnotList* m_pAnnotList; - //CPDFSDK_Annot* m_pFocusAnnot; - CFX_PtrArray m_fxAnnotArray; - CPDFSDK_Document* m_pSDKDoc; - CPDFSDK_Widget* m_CaptureWidget; - FX_BOOL m_bEnterWidget; - FX_BOOL m_bExitWidget; - FX_BOOL m_bOnWidget; - FX_BOOL m_bValid; - FX_BOOL m_bLocked; - FX_BOOL m_bTakeOverPage; -}; - - -template -class CGW_ArrayTemplate : public CFX_ArrayTemplate -{ -public: - CGW_ArrayTemplate(){} - virtual ~CGW_ArrayTemplate(){} + while (j > m) { + TYPE temp = this->GetAt(j); - typedef int (*LP_COMPARE)(TYPE p1, TYPE p2); - - void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) - { - int nSize = this->GetSize(); - QuickSort(0, nSize -1, bAscent, pCompare); + int iGreate = (*pCompare)(temp, Value); + if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) { + this->RemoveAt(j); + this->InsertAt(m, temp); + m++; + } else { + j--; + } } -private: - void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare) - { - if (nStartPos >= nStopPos) return; - - if ((nStopPos - nStartPos) == 1) - { - TYPE Value1 = this->GetAt(nStartPos); - TYPE Value2 = this->GetAt(nStopPos); - - int iGreate = (*pCompare)(Value1, Value2); - if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) - { - this->SetAt(nStartPos, Value2); - this->SetAt(nStopPos, Value1); - } - return; - } - - FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2; - FX_UINT i = nStartPos; - - TYPE Value = this->GetAt(m); - - while (i < m) - { - TYPE temp = this->GetAt(i); - - int iGreate = (*pCompare)(temp, Value); - if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) - { - this->InsertAt(m+1, temp); - this->RemoveAt(i); - m--; - } - else - { - i++; - } - } - - FX_UINT j = nStopPos; - - while (j > m) - { - TYPE temp = this->GetAt(j); - - int iGreate = (*pCompare)(temp, Value); - if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) - { - this->RemoveAt(j); - this->InsertAt(m, temp); - m++; - } - else - { - j--; - } - } - - if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); - if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); - } + if (nStartPos < m) + QuickSort(nStartPos, m, bAscend, pCompare); + if (nStopPos > m) + QuickSort(m, nStopPos, bAscend, pCompare); + } }; #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ diff --git a/fpdfsdk/include/fsdk_rendercontext.h b/fpdfsdk/include/fsdk_rendercontext.h index b2bc163b49..9d1dabd41c 100644 --- a/fpdfsdk/include/fsdk_rendercontext.h +++ b/fpdfsdk/include/fsdk_rendercontext.h @@ -11,33 +11,31 @@ #include "fsdk_define.h" // Everything about rendering is put here: for OOM recovery -class CRenderContext -{ -public: - CRenderContext() { Clear(); } - ~CRenderContext(); - - void Clear(); - - CFX_RenderDevice* m_pDevice; - CPDF_RenderContext* m_pContext; - CPDF_ProgressiveRenderer* m_pRenderer; - CPDF_AnnotList* m_pAnnots; - CPDF_RenderOptions* m_pOptions; +class CRenderContext { + public: + CRenderContext() { Clear(); } + ~CRenderContext(); + + void Clear(); + + CFX_RenderDevice* m_pDevice; + CPDF_RenderContext* m_pContext; + CPDF_ProgressiveRenderer* m_pRenderer; + CPDF_AnnotList* m_pAnnots; + CPDF_RenderOptions* m_pOptions; #ifdef _WIN32_WCE - CFX_DIBitmap* m_pBitmap; - HBITMAP m_hBitmap; + CFX_DIBitmap* m_pBitmap; + HBITMAP m_hBitmap; #endif }; -class IFSDK_PAUSE_Adapter : public IFX_Pause -{ -public: - IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause ); - FX_BOOL NeedToPauseNow(); +class IFSDK_PAUSE_Adapter : public IFX_Pause { + public: + IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause); + FX_BOOL NeedToPauseNow(); -private: - IFSDK_PAUSE* m_IPause; + private: + IFSDK_PAUSE* m_IPause; }; #endif // FPDFSDK_INCLUDE_FSDK_RENDERCONTEXT_H_ diff --git a/fpdfsdk/include/fx_systemhandler.h b/fpdfsdk/include/fx_systemhandler.h index bf59e452ea..31d3347477 100644 --- a/fpdfsdk/include/fx_systemhandler.h +++ b/fpdfsdk/include/fx_systemhandler.h @@ -7,13 +7,12 @@ #ifndef FPDFSDK_INCLUDE_FX_SYSTEMHANDLER_H_ #define FPDFSDK_INCLUDE_FX_SYSTEMHANDLER_H_ -typedef void* FX_HWND; -typedef void* FX_HMENU; -typedef void (*TimerCallback)(int32_t idEvent); +typedef void* FX_HWND; +typedef void* FX_HMENU; +typedef void (*TimerCallback)(int32_t idEvent); -typedef struct _FX_SYSTEMTIME -{ - _FX_SYSTEMTIME() +typedef struct _FX_SYSTEMTIME { + _FX_SYSTEMTIME() : wYear(0), wMonth(0), wDayOfWeek(0), @@ -22,72 +21,80 @@ typedef struct _FX_SYSTEMTIME wMinute(0), wSecond(0), wMilliseconds(0) {} - FX_WORD wYear; - FX_WORD wMonth; - FX_WORD wDayOfWeek; - FX_WORD wDay; - FX_WORD wHour; - FX_WORD wMinute; - FX_WORD wSecond; - FX_WORD wMilliseconds; -}FX_SYSTEMTIME; - -//cursor style -#define FXCT_ARROW 0 -#define FXCT_NESW 1 -#define FXCT_NWSE 2 -#define FXCT_VBEAM 3 -#define FXCT_HBEAM 4 -#define FXCT_HAND 5 - -class IFX_SystemHandler -{ -public: - virtual ~IFX_SystemHandler() {} - virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) = 0; - virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect&rect) = 0; - - virtual FX_BOOL IsSelectionImplemented() = 0; - - virtual CFX_WideString GetClipboardText(FX_HWND hWnd) = 0; - virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) = 0; - - virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t& y) = 0; - virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t& y) = 0; - - /*cursor style - FXCT_ARROW - FXCT_NESW - FXCT_NWSE - FXCT_VBEAM - FXCT_HBEAM - FXCT_HAND - */ - virtual void SetCursor(int32_t nCursorType) = 0; - - virtual FX_HMENU CreatePopupMenu() = 0; - virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu, int32_t nIDNewItem, CFX_WideString string) = 0; - virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu, int32_t nIDItem, FX_BOOL bEnabled) = 0; - virtual int32_t TrackPopupMenu(FX_HMENU hMenu, int32_t x, int32_t y, FX_HWND hParent) = 0; - virtual void DestroyMenu(FX_HMENU hMenu) = 0; - - virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset) = 0; - virtual FX_BOOL FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString sFontFaceName) = 0; - virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CFX_ByteString sFontFaceName, uint8_t nCharset) = 0; - - virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) = 0; - virtual void KillTimer(int32_t nID) = 0; - - - virtual FX_BOOL IsSHIFTKeyDown(FX_DWORD nFlag) = 0; - virtual FX_BOOL IsCTRLKeyDown(FX_DWORD nFlag) = 0; - virtual FX_BOOL IsALTKeyDown(FX_DWORD nFlag) = 0; - virtual FX_BOOL IsINSERTKeyDown(FX_DWORD nFlag) = 0; - - virtual FX_SYSTEMTIME GetLocalTime() = 0; - - virtual int32_t GetCharSet() = 0; - virtual void SetCharSet(int32_t nCharSet) = 0; + FX_WORD wYear; + FX_WORD wMonth; + FX_WORD wDayOfWeek; + FX_WORD wDay; + FX_WORD wHour; + FX_WORD wMinute; + FX_WORD wSecond; + FX_WORD wMilliseconds; +} FX_SYSTEMTIME; + +// cursor style +#define FXCT_ARROW 0 +#define FXCT_NESW 1 +#define FXCT_NWSE 2 +#define FXCT_VBEAM 3 +#define FXCT_HBEAM 4 +#define FXCT_HAND 5 + +class IFX_SystemHandler { + public: + virtual ~IFX_SystemHandler() {} + virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) = 0; + virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) = 0; + + virtual FX_BOOL IsSelectionImplemented() = 0; + + virtual CFX_WideString GetClipboardText(FX_HWND hWnd) = 0; + virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) = 0; + + virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t& y) = 0; + virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t& y) = 0; + + /*cursor style + FXCT_ARROW + FXCT_NESW + FXCT_NWSE + FXCT_VBEAM + FXCT_HBEAM + FXCT_HAND + */ + virtual void SetCursor(int32_t nCursorType) = 0; + + virtual FX_HMENU CreatePopupMenu() = 0; + virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu, + int32_t nIDNewItem, + CFX_WideString string) = 0; + virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu, + int32_t nIDItem, + FX_BOOL bEnabled) = 0; + virtual int32_t TrackPopupMenu(FX_HMENU hMenu, + int32_t x, + int32_t y, + FX_HWND hParent) = 0; + virtual void DestroyMenu(FX_HMENU hMenu) = 0; + + virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset) = 0; + virtual FX_BOOL FindNativeTrueTypeFont(int32_t nCharset, + CFX_ByteString sFontFaceName) = 0; + virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, + CFX_ByteString sFontFaceName, + uint8_t nCharset) = 0; + + virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) = 0; + virtual void KillTimer(int32_t nID) = 0; + + virtual FX_BOOL IsSHIFTKeyDown(FX_DWORD nFlag) = 0; + virtual FX_BOOL IsCTRLKeyDown(FX_DWORD nFlag) = 0; + virtual FX_BOOL IsALTKeyDown(FX_DWORD nFlag) = 0; + virtual FX_BOOL IsINSERTKeyDown(FX_DWORD nFlag) = 0; + + virtual FX_SYSTEMTIME GetLocalTime() = 0; + + virtual int32_t GetCharSet() = 0; + virtual void SetCharSet(int32_t nCharSet) = 0; }; #endif // FPDFSDK_INCLUDE_FX_SYSTEMHANDLER_H_ diff --git a/fpdfsdk/include/fxedit/fx_edit.h b/fpdfsdk/include/fxedit/fx_edit.h index d154cb2290..bfe6a254ff 100644 --- a/fpdfsdk/include/fxedit/fx_edit.h +++ b/fpdfsdk/include/fxedit/fx_edit.h @@ -35,451 +35,535 @@ 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)) +#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 +#define DEFAULT_CHARSET 1 #endif -class IFX_Edit_FontMap -{ -public: - virtual ~IFX_Edit_FontMap() { } - //map a fontindex to pdf font. - virtual CPDF_Font * GetPDFFont(int32_t nFontIndex) = 0; - //get the alias of a pdf font. - virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0; - //get the index of a font that can show a word. - virtual int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex) = 0; - //get the charcode of word from unicode - virtual int32_t CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) = 0; - //get the charset of unicode - virtual int32_t CharSetFromUnicode(FX_WORD word, int32_t nOldCharset) = 0; +class IFX_Edit_FontMap { + public: + virtual ~IFX_Edit_FontMap() {} + // map a fontindex to pdf font. + virtual CPDF_Font* GetPDFFont(int32_t nFontIndex) = 0; + // get the alias of a pdf font. + virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0; + // get the index of a font that can show a word. + virtual int32_t GetWordFontIndex(FX_WORD word, + int32_t charset, + int32_t nFontIndex) = 0; + // get the charcode of word from unicode + virtual int32_t CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) = 0; + // get the charset of unicode + virtual int32_t CharSetFromUnicode(FX_WORD word, int32_t nOldCharset) = 0; }; -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 CPDF_Point & ptHead,const CPDF_Point & 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 CPDF_Rect& rcContent) = 0; - //Invalidate the rectangle relative to the bounding box of edit. - virtual void IOnInvalidateRect(CPDF_Rect * pRect) = 0; +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 CPDF_Point& ptHead, + const CPDF_Point& 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 CPDF_Rect& rcContent) = 0; + // Invalidate the rectangle relative to the bounding box of edit. + virtual void IOnInvalidateRect(CPDF_Rect* 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_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_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() { } +class IFX_Edit_UndoItem { + public: + virtual ~IFX_Edit_UndoItem() {} - virtual void Undo() = 0; - virtual void Redo() = 0; - virtual CFX_WideString GetUndoTitle() = 0; + 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 IFX_Edit_FontMap pointer implemented by user. - virtual void SetFontMap(IFX_Edit_FontMap* pFontMap) = 0; - //if user don't like to use FontMap, implement VTProvider and set it directly. - virtual void SetVTProvider(IPDF_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 IPDF_VariableText* GetVariableText() = 0; - //get the IFX_Edit_FontMap pointer set by user. - virtual IFX_Edit_FontMap* GetFontMap() = 0; - - //initialize the edit. - virtual void Initialize() = 0; - - //set the bounding box of the text area. - virtual void SetPlateRect(const CPDF_Rect & rect, FX_BOOL bPaint = TRUE) = 0; - //set the scroll origin - virtual void SetScrollPos(const CPDF_Point & 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(FX_WORD 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(int32_t 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 CPDF_Point GetScrollPos() const = 0; - //get the bounding box of the text area. - virtual CPDF_Rect GetPlateRect() const = 0; - //get the fact area of the text. - virtual CPDF_Rect 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 CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the mousemove message to edit when mouse down is TRUE. - virtual void OnMouseMove(const CPDF_Point & 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(FX_WORD 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 CPDF_Point& 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 FX_WORD 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 CPDF_Point & ptOffset, - const CPVT_WordRange* pRange = NULL, - FX_BOOL bContinuous = TRUE, FX_WORD SubWord = 0); - static CFX_ByteString GetSelectAppearanceStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, const CPVT_WordRange* pRange = NULL); - static void DrawEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, FX_COLORREF crTextFill, FX_COLORREF crTextStroke, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, IFX_SystemHandler* pSystemHandler, void* pFFLData); - static void DrawUnderline(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, FX_COLORREF color, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange); - static void DrawRichEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange); - static void GeneratePageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit, - const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF crText, CFX_ArrayTemplate& ObjArray); - static void GenerateRichPageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit, - const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, CFX_ArrayTemplate& ObjArray); - static void GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit, - const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF color); - -protected: - ~IFX_Edit() { } +class IFX_Edit { + public: + static IFX_Edit* NewEdit(); + static void DelEdit(IFX_Edit* pEdit); + + // set a IFX_Edit_FontMap pointer implemented by user. + virtual void SetFontMap(IFX_Edit_FontMap* pFontMap) = 0; + // if user don't like to use FontMap, implement VTProvider and set it + // directly. + virtual void SetVTProvider(IPDF_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 IPDF_VariableText* GetVariableText() = 0; + // get the IFX_Edit_FontMap pointer set by user. + virtual IFX_Edit_FontMap* GetFontMap() = 0; + + // initialize the edit. + virtual void Initialize() = 0; + + // set the bounding box of the text area. + virtual void SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint = TRUE) = 0; + // set the scroll origin + virtual void SetScrollPos(const CPDF_Point& 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(FX_WORD 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(int32_t 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 CPDF_Point GetScrollPos() const = 0; + // get the bounding box of the text area. + virtual CPDF_Rect GetPlateRect() const = 0; + // get the fact area of the text. + virtual CPDF_Rect 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 CPDF_Point& point, + FX_BOOL bShift, + FX_BOOL bCtrl) = 0; + // send the mousemove message to edit when mouse down is TRUE. + virtual void OnMouseMove(const CPDF_Point& 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(FX_WORD 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 CPDF_Point& 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 FX_WORD 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 CPDF_Point& ptOffset, + const CPVT_WordRange* pRange = NULL, + FX_BOOL bContinuous = TRUE, + FX_WORD SubWord = 0); + static CFX_ByteString GetSelectAppearanceStream( + IFX_Edit* pEdit, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange = NULL); + static void DrawEdit(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + IFX_Edit* pEdit, + FX_COLORREF crTextFill, + FX_COLORREF crTextStroke, + const CPDF_Rect& rcClip, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange, + IFX_SystemHandler* pSystemHandler, + void* pFFLData); + static void DrawUnderline(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + IFX_Edit* pEdit, + FX_COLORREF color, + const CPDF_Rect& rcClip, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange); + static void DrawRichEdit(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + IFX_Edit* pEdit, + const CPDF_Rect& rcClip, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange); + static void GeneratePageObjects( + CPDF_PageObjects* pPageObjects, + IFX_Edit* pEdit, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange, + FX_COLORREF crText, + CFX_ArrayTemplate& ObjArray); + static void GenerateRichPageObjects( + CPDF_PageObjects* pPageObjects, + IFX_Edit* pEdit, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange, + CFX_ArrayTemplate& ObjArray); + static void GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects, + IFX_Edit* pEdit, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange, + FX_COLORREF color); + + protected: + ~IFX_Edit() {} }; -class IFX_List_Notify -{ -public: - virtual ~IFX_List_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; - //Invalidate the rectangle relative to the bounding box of edit. - virtual void IOnInvalidateRect(CPDF_Rect * pRect) = 0; +class IFX_List_Notify { + public: + virtual ~IFX_List_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; + // Invalidate the rectangle relative to the bounding box of edit. + virtual void IOnInvalidateRect(CPDF_Rect* pRect) = 0; }; -class IFX_List -{ -public: - static IFX_List* NewList(); - static void DelList(IFX_List* pList); - - virtual void SetFontMap(IFX_Edit_FontMap * pFontMap) = 0; - virtual void SetNotify(IFX_List_Notify * pNotify) = 0; - - virtual void SetPlateRect(const CPDF_Rect & rect) = 0; - virtual void SetFontSize(FX_FLOAT fFontSize) = 0; - - virtual CPDF_Rect GetPlateRect() const = 0; - virtual CPDF_Rect 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 CPDF_Point & point) = 0; - virtual void ScrollToListItem(int32_t nItemIndex) = 0; - virtual CPDF_Rect 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 CPDF_Point & point) const = 0; - virtual int32_t GetFirstSelected() const = 0; - - virtual void AddString(const FX_WCHAR* string) = 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 CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnMouseMove(const CPDF_Point & 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(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - -protected: - ~IFX_List() { } +class IFX_List { + public: + static IFX_List* NewList(); + static void DelList(IFX_List* pList); + + virtual void SetFontMap(IFX_Edit_FontMap* pFontMap) = 0; + virtual void SetNotify(IFX_List_Notify* pNotify) = 0; + + virtual void SetPlateRect(const CPDF_Rect& rect) = 0; + virtual void SetFontSize(FX_FLOAT fFontSize) = 0; + + virtual CPDF_Rect GetPlateRect() const = 0; + virtual CPDF_Rect 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 CPDF_Point& point) = 0; + virtual void ScrollToListItem(int32_t nItemIndex) = 0; + virtual CPDF_Rect 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 CPDF_Point& point) const = 0; + virtual int32_t GetFirstSelected() const = 0; + + virtual void AddString(const FX_WCHAR* string) = 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 CPDF_Point& point, + FX_BOOL bShift, + FX_BOOL bCtrl) = 0; + virtual void OnMouseMove(const CPDF_Point& 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(FX_WORD nChar, FX_BOOL bShift, FX_BOOL bCtrl) = 0; + + protected: + ~IFX_List() {} }; #endif // FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_ diff --git a/fpdfsdk/include/fxedit/fxet_edit.h b/fpdfsdk/include/fxedit/fxet_edit.h index 7a2742f0ee..d654ebc451 100644 --- a/fpdfsdk/include/fxedit/fxet_edit.h +++ b/fpdfsdk/include/fxedit/fxet_edit.h @@ -23,795 +23,801 @@ class CFX_Edit_UndoItem; class CFX_Edit_Undo; 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)) +#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)) + +template +T FX_EDIT_MIN(const T& i, const T& j) { + return ((i < j) ? i : j); +} +template +T FX_EDIT_MAX(const T& i, const T& j) { + return ((i > j) ? i : j); +} + +#define FX_EDIT_PI 3.14159265358979f +#define FX_EDIT_ITALIC_ANGEL 10 * FX_EDIT_PI / 180.0f -template T FX_EDIT_MIN (const T & i, const T & j) { return ((i < j) ? i : j); } -template T FX_EDIT_MAX (const T & i, const T & j) { return ((i > j) ? i : j); } +/* ------------------------- CFX_Edit_Refresh ---------------------------- */ -#define FX_EDIT_PI 3.14159265358979f -#define FX_EDIT_ITALIC_ANGEL 10 * FX_EDIT_PI / 180.0f +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 CPDF_Rect& rcLine) + : m_wrLine(wrLine), m_rcLine(rcLine) {} -/* ------------------------- CFX_Edit_Refresh ---------------------------- */ + FX_BOOL operator!=(const CFX_Edit_LineRect& linerect) const { + return FXSYS_memcmp(this, &linerect, sizeof(CFX_Edit_LineRect)) != 0; + } -enum REFRESH_PLAN_E -{ - RP_ANALYSE, - RP_NOANALYSE, - RP_OPTIONAL -}; + 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)); + } -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 -}; + FX_BOOL IsSameTop(const CFX_Edit_LineRect& linerect) const { + return FX_EDIT_IsFloatZero(m_rcLine.top - linerect.m_rcLine.top); + } -struct CFX_Edit_LineRect -{ - CFX_Edit_LineRect(const CPVT_WordRange & wrLine,const CPDF_Rect & 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; - CPDF_Rect m_rcLine; -}; + FX_BOOL IsSameLeft(const CFX_Edit_LineRect& linerect) const { + return FX_EDIT_IsFloatZero(m_rcLine.left - linerect.m_rcLine.left); + } -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 CPDF_Rect & rcLine) - { - if (CFX_Edit_LineRect * pRect = new CFX_Edit_LineRect(wrLine,rcLine)) - m_LineRects.Add(pRect); - } - - 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 m_LineRects; -}; + FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const { + return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right); + } -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 CPDF_Rect & rect) - { - //check for overlaped area - for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) - if (CPDF_Rect * pRect = m_Rects.GetAt(i)) - if (pRect->Contains(rect))return; - - if (CPDF_Rect * pNewRect = new CPDF_Rect(rect)) - m_Rects.Add(pNewRect); - } - - int32_t GetSize() const - { - return m_Rects.GetSize(); - } - - CPDF_Rect * GetAt(int32_t nIndex) const - { - if (nIndex < 0 || nIndex >= m_Rects.GetSize()) - return NULL; - - return m_Rects.GetAt(nIndex); - } - - CFX_ArrayTemplate m_Rects; + CPVT_WordRange m_wrLine; + CPDF_Rect m_rcLine; }; -class CFX_Edit_Refresh -{ -public: - CFX_Edit_Refresh(); - virtual ~CFX_Edit_Refresh(); - - void BeginRefresh(); - void Push(const CPVT_WordRange & linerange,const CPDF_Rect & rect); - void NoAnalyse(); - void Analyse(int32_t nAlignment); - void AddRefresh(const CPDF_Rect & 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_LineRectArray { + public: + CFX_Edit_LineRectArray() {} + virtual ~CFX_Edit_LineRectArray() { Empty(); } -/* ------------------------- CFX_Edit_Select ---------------------------- */ + 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(); } -class CFX_Edit_Select -{ -public: - CFX_Edit_Select() - { - } - - CFX_Edit_Select(const CPVT_WordPlace & begin,const CPVT_WordPlace & end) - { - Set(begin,end); - } - - 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; + 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 CPDF_Rect& rcLine) { + if (CFX_Edit_LineRect* pRect = new CFX_Edit_LineRect(wrLine, rcLine)) + m_LineRects.Add(pRect); + } + + 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 m_LineRects; }; -/* ------------------------- CFX_Edit_Undo ---------------------------- */ +class CFX_Edit_RectArray { + public: + CFX_Edit_RectArray() {} -class CFX_Edit_Undo -{ -public: - CFX_Edit_Undo(int32_t nBufsize = 10000); - virtual ~CFX_Edit_Undo(); + virtual ~CFX_Edit_RectArray() { Empty(); } - void Undo(); - void Redo(); + void Empty() { + for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) + delete m_Rects.GetAt(i); - void AddItem(IFX_Edit_UndoItem* pItem); + m_Rects.RemoveAll(); + } - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - FX_BOOL IsModified() const; - FX_BOOL IsWorking() const; + void Add(const CPDF_Rect& rect) { + // check for overlaped area + for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) + if (CPDF_Rect* pRect = m_Rects.GetAt(i)) + if (pRect->Contains(rect)) + return; - void Reset(); + if (CPDF_Rect* pNewRect = new CPDF_Rect(rect)) + m_Rects.Add(pNewRect); + } - IFX_Edit_UndoItem* GetItem(int32_t nIndex); - int32_t GetItemCount(){return m_UndoItemStack.GetSize();} - int32_t GetCurUndoPos(){return m_nCurUndoPos;} + int32_t GetSize() const { return m_Rects.GetSize(); } -private: - void SetBufSize(int32_t nSize){m_nBufSize = nSize;} - int32_t GetBufSize(){return m_nBufSize;} + CPDF_Rect* GetAt(int32_t nIndex) const { + if (nIndex < 0 || nIndex >= m_Rects.GetSize()) + return NULL; - void RemoveHeads(); - void RemoveTails(); + return m_Rects.GetAt(nIndex); + } -private: - CFX_ArrayTemplate m_UndoItemStack; + CFX_ArrayTemplate m_Rects; +}; - int32_t m_nCurUndoPos; - int32_t m_nBufSize; - FX_BOOL m_bModified; - FX_BOOL m_bVirgin; - FX_BOOL m_bWorking; +class CFX_Edit_Refresh { + public: + CFX_Edit_Refresh(); + virtual ~CFX_Edit_Refresh(); + + void BeginRefresh(); + void Push(const CPVT_WordRange& linerange, const CPDF_Rect& rect); + void NoAnalyse(); + void Analyse(int32_t nAlignment); + void AddRefresh(const CPDF_Rect& 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_UndoItem : public IFX_Edit_UndoItem -{ -public: - CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} +/* ------------------------- CFX_Edit_Select ---------------------------- */ - CFX_WideString GetUndoTitle() override { return L""; } +class CFX_Edit_Select { + public: + CFX_Edit_Select() {} - 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;} + CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { + Set(begin, end); + } -private: - FX_BOOL m_bFirst; - FX_BOOL m_bLast; -}; + CFX_Edit_Select(const CPVT_WordRange& range) { + Set(range.BeginPos, range.EndPos); + } -class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem -{ -public: - CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); - ~CFX_Edit_GroupUndoItem() override; + CPVT_WordRange ConvertToWordRange() const { + return CPVT_WordRange(BeginPos, EndPos); + } - void Undo() override; - void Redo() override; - CFX_WideString GetUndoTitle() override; + void Default() { + BeginPos.Default(); + EndPos.Default(); + } - void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); - void UpdateItems(); + void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { + BeginPos = begin; + EndPos = end; + } -private: - CFX_WideString m_sTitle; - CFX_ArrayTemplate m_Items; + 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; }; -/* ------------------------- CFX_Edit_UndoItem derived classes ---------------------------- */ +/* ------------------------- CFX_Edit_Undo ---------------------------- */ -class CFXEU_InsertWord : public CFX_Edit_UndoItem -{ -public: - CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - FX_WORD word, int32_t charset, const CPVT_WordProps * pWordProps); - virtual ~CFXEU_InsertWord(); +class CFX_Edit_Undo { + public: + CFX_Edit_Undo(int32_t nBufsize = 10000); + virtual ~CFX_Edit_Undo(); - void Redo(); - void Undo(); + void Undo(); + void Redo(); -private: - CFX_Edit* m_pEdit; + void AddItem(IFX_Edit_UndoItem* pItem); - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - FX_WORD m_Word; - int32_t m_nCharset; - CPVT_WordProps m_WordProps; -}; + FX_BOOL CanUndo() const; + FX_BOOL CanRedo() const; + FX_BOOL IsModified() const; + FX_BOOL IsWorking() const; -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); - virtual ~CFXEU_InsertReturn(); + void Reset(); - void Redo(); - void Undo(); + IFX_Edit_UndoItem* GetItem(int32_t nIndex); + int32_t GetItemCount() { return m_UndoItemStack.GetSize(); } + int32_t GetCurUndoPos() { return m_nCurUndoPos; } -private: - CFX_Edit * m_pEdit; + private: + void SetBufSize(int32_t nSize) { m_nBufSize = nSize; } + int32_t GetBufSize() { return m_nBufSize; } - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; + void RemoveHeads(); + void RemoveTails(); + + private: + CFX_ArrayTemplate m_UndoItemStack; -class CFXEU_Backspace : public CFX_Edit_UndoItem -{ -public: - CFXEU_Backspace(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - FX_WORD word, int32_t charset, - const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps); - virtual ~CFXEU_Backspace(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - FX_WORD m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; + int32_t m_nCurUndoPos; + int32_t m_nBufSize; + FX_BOOL m_bModified; + FX_BOOL m_bVirgin; + FX_BOOL m_bWorking; }; -class CFXEU_Delete : public CFX_Edit_UndoItem -{ -public: - CFXEU_Delete(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - FX_WORD word, int32_t charset, - const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps, FX_BOOL bSecEnd); - virtual ~CFXEU_Delete(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - FX_WORD m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; - FX_BOOL m_bSecEnd; +class CFX_Edit_UndoItem : public IFX_Edit_UndoItem { + public: + CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} + + 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 CFXEU_Clear : public CFX_Edit_UndoItem -{ -public: - CFXEU_Clear(CFX_Edit * pEdit, const CPVT_WordRange & wrSel, const CFX_WideString & swText); - virtual ~CFXEU_Clear(); +class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { + public: + CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); + ~CFX_Edit_GroupUndoItem() override; - void Redo(); - void Undo(); + void Undo() override; + void Redo() override; + CFX_WideString GetUndoTitle() override; -private: - CFX_Edit* m_pEdit; + void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); + void UpdateItems(); - CPVT_WordRange m_wrSel; - CFX_WideString m_swText; + private: + CFX_WideString m_sTitle; + CFX_ArrayTemplate m_Items; }; -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, - FX_WORD word, int32_t charset, - const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps); - virtual ~CFXEU_ClearRich(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CPVT_WordRange m_wrSel; - FX_WORD m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; +/* ------------------------- CFX_Edit_UndoItem derived classes + * ---------------------------- */ + +class CFXEU_InsertWord : public CFX_Edit_UndoItem { + public: + CFXEU_InsertWord(CFX_Edit* pEdit, + const CPVT_WordPlace& wpOldPlace, + const CPVT_WordPlace& wpNewPlace, + FX_WORD word, + int32_t charset, + const CPVT_WordProps* pWordProps); + virtual ~CFXEU_InsertWord(); + + void Redo(); + void Undo(); + + private: + CFX_Edit* m_pEdit; + + CPVT_WordPlace m_wpOld; + CPVT_WordPlace m_wpNew; + FX_WORD m_Word; + int32_t m_nCharset; + 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); - virtual ~CFXEU_InsertText(); - - void Redo(); - void Undo(); - -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_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); + virtual ~CFXEU_InsertReturn(); + + void Redo(); + void Undo(); + + private: + CFX_Edit* m_pEdit; + + CPVT_WordPlace m_wpOld; + CPVT_WordPlace m_wpNew; + 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); - virtual ~CFXEU_SetSecProps(); - - void Redo(); - void Undo(); - -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_Backspace : public CFX_Edit_UndoItem { + public: + CFXEU_Backspace(CFX_Edit* pEdit, + const CPVT_WordPlace& wpOldPlace, + const CPVT_WordPlace& wpNewPlace, + FX_WORD word, + int32_t charset, + const CPVT_SecProps& SecProps, + const CPVT_WordProps& WordProps); + virtual ~CFXEU_Backspace(); + + void Redo(); + void Undo(); + + private: + CFX_Edit* m_pEdit; + + CPVT_WordPlace m_wpOld; + CPVT_WordPlace m_wpNew; + FX_WORD m_Word; + int32_t m_nCharset; + CPVT_SecProps m_SecProps; + CPVT_WordProps m_WordProps; }; -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); - virtual ~CFXEU_SetWordProps(); +class CFXEU_Delete : public CFX_Edit_UndoItem { + public: + CFXEU_Delete(CFX_Edit* pEdit, + const CPVT_WordPlace& wpOldPlace, + const CPVT_WordPlace& wpNewPlace, + FX_WORD word, + int32_t charset, + const CPVT_SecProps& SecProps, + const CPVT_WordProps& WordProps, + FX_BOOL bSecEnd); + virtual ~CFXEU_Delete(); + + void Redo(); + void Undo(); + + private: + CFX_Edit* m_pEdit; + + CPVT_WordPlace m_wpOld; + CPVT_WordPlace m_wpNew; + FX_WORD 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); + virtual ~CFXEU_Clear(); + + void Redo(); + void Undo(); + + private: + CFX_Edit* m_pEdit; + + CPVT_WordRange m_wrSel; + CFX_WideString m_swText; +}; - void Redo(); - void Undo(); +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, + FX_WORD word, + int32_t charset, + const CPVT_SecProps& SecProps, + const CPVT_WordProps& WordProps); + virtual ~CFXEU_ClearRich(); + + void Redo(); + void Undo(); + + private: + CFX_Edit* m_pEdit; + + CPVT_WordPlace m_wpOld; + CPVT_WordPlace m_wpNew; + CPVT_WordRange m_wrSel; + FX_WORD m_Word; + int32_t m_nCharset; + CPVT_SecProps m_SecProps; + CPVT_WordProps m_WordProps; +}; -private: - CFX_Edit * m_pEdit; - CPVT_WordPlace m_wpPlace; - CPVT_WordRange m_wrPlace; - EDIT_PROPS_E m_eProps; +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); + virtual ~CFXEU_InsertText(); + + void Redo(); + void Undo(); + + 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); + virtual ~CFXEU_SetSecProps(); + + void Redo(); + void Undo(); + + 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; +}; - 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); + virtual ~CFXEU_SetWordProps(); + + void Redo(); + void Undo(); + + 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; }; /* ------------------------- CFX_Edit ---------------------------- */ -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: - CFX_Edit(IPDF_VariableText * pVT); - virtual ~CFX_Edit(); - - void SetFontMap(IFX_Edit_FontMap * pFontMap); - void SetVTProvider(IPDF_VariableText_Provider* pProvider); - void SetNotify(IFX_Edit_Notify * pNotify); - void SetOprNotify(IFX_Edit_OprNotify* pOprNotify); - IFX_Edit_Iterator* GetIterator(); - IPDF_VariableText * GetVariableText(); - IFX_Edit_FontMap* GetFontMap(); - - void Initialize(); - void SetPlateRect(const CPDF_Rect & rect, FX_BOOL bPaint = TRUE); - void SetScrollPos(const CPDF_Point & point); - - void SetAlignmentH(int32_t nFormat = 0, FX_BOOL bPaint = TRUE); - void SetAlignmentV(int32_t nFormat = 0, FX_BOOL bPaint = TRUE); - void SetPasswordChar(FX_WORD wSubWord = '*', FX_BOOL bPaint = TRUE); - void SetLimitChar(int32_t nLimitChar = 0, FX_BOOL bPaint = TRUE); - void SetCharArray(int32_t nCharArray = 0, FX_BOOL bPaint = TRUE); - void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, FX_BOOL bPaint = TRUE); - void SetHorzScale(int32_t nHorzScale = 100, FX_BOOL bPaint = TRUE); - void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE); - void SetMultiLine(FX_BOOL bMultiLine = TRUE, FX_BOOL bPaint = TRUE); - void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); - void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); - void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); - void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE); - void SetTextOverflow(FX_BOOL bAllowed = FALSE, FX_BOOL bPaint = TRUE); - - FX_BOOL IsRichText() const; - void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE); - FX_BOOL SetRichFontSize(FX_FLOAT fFontSize); - FX_BOOL SetRichFontIndex(int32_t nFontIndex); - FX_BOOL SetRichTextColor(FX_COLORREF dwColor); - FX_BOOL SetRichTextScript(int32_t nScriptType); - FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE); - FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE); - FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE); - FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE); - FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace); - FX_BOOL SetRichTextHorzScale(int32_t nHorzScale = 100); - FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading); - FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent); - FX_BOOL SetRichTextAlignment(int32_t nAlignment); - - void OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl); - - void SetText(const FX_WCHAR* text,int32_t charset = DEFAULT_CHARSET, - const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL); - FX_BOOL InsertWord(FX_WORD word, int32_t charset = DEFAULT_CHARSET, const CPVT_WordProps * pWordProps = NULL); - FX_BOOL InsertReturn(const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL); - FX_BOOL Backspace(); - FX_BOOL Delete(); - FX_BOOL Clear(); - FX_BOOL Empty(); - FX_BOOL InsertText(const FX_WCHAR* text, int32_t charset = DEFAULT_CHARSET, - const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL); - FX_BOOL Redo(); - FX_BOOL Undo(); - 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(FX_WORD word, int32_t nOldCharset); - - int32_t WordPlaceToWordIndex(const CPVT_WordPlace & place) const; - CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; - - CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; - - int32_t GetCaret() const; - CPVT_WordPlace GetCaretWordPlace() const; - CFX_WideString GetSelText() const; - CFX_WideString GetText() const; - FX_FLOAT GetFontSize() const; - FX_WORD GetPasswordChar() const; - CPDF_Point GetScrollPos() const; - int32_t GetCharArray() const; - CPDF_Rect GetPlateRect() const; - CPDF_Rect GetContentRect() const; - CFX_WideString GetRangeText(const CPVT_WordRange & range) const; - int32_t GetHorzScale() const; - FX_FLOAT GetCharSpace() const; - int32_t GetTotalWords() const; - int32_t GetTotalLines() const; - - void SetSel(int32_t nStartChar,int32_t nEndChar); - void GetSel(int32_t & nStartChar, int32_t & nEndChar) const; - -private: - void SelectAll(); - void SelectNone(); - void SetSel(const CPVT_WordPlace & begin,const CPVT_WordPlace & end); - FX_BOOL IsSelected() const; - - void RearrangeAll(); - void RearrangePart(const CPVT_WordRange & range); - void Paint(); - void ScrollToCaret(); - void SetScrollInfo(); - void SetScrollPosX(FX_FLOAT fx); - void SetScrollPosY(FX_FLOAT fy); - void SetScrollLimit(); - void SetContentChanged(); - void EnableNotify(FX_BOOL bNotify); - - 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(FX_WORD 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 CPDF_Point VTToEdit(const CPDF_Point & point) const; - inline CPDF_Point EditToVT(const CPDF_Point & point) const; - inline CPDF_Rect VTToEdit(const CPDF_Rect & rect) const; - inline CPDF_Rect EditToVT(const CPDF_Rect & rect) const; - - void EnableRefresh(FX_BOOL bRefresh); - 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 RefreshWordRange(const CPVT_WordRange& wr); - - void SetCaret(int32_t nPos); - void SetCaret(const CPVT_WordPlace & place); - void SetCaretInfo(); - void SetCaretOrigin(); - void SetCaretChange(); - - CPVT_WordRange GetWholeWordRange() const; - CPVT_WordRange GetVisibleWordRange() const; - CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace & place) const; - CPVT_WordRange CombineWordRange(const CPVT_WordRange & wr1, const CPVT_WordRange & wr2); - CPVT_WordRange GetSelectWordRange() const; - - void EnableUndo(FX_BOOL bUndo); - void EnableOprNotify(FX_BOOL bNotify); - - FX_BOOL IsTextFull() const; - FX_BOOL IsTextOverflow() const; - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - FX_BOOL IsModified() const; - - void BeginGroupUndo(const CFX_WideString& sTitle); - void EndGroupUndo(); - void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem); - void AddUndoItem(IFX_Edit_UndoItem* pUndoItem); - - void SetPageInfo(const CPVT_WordPlace& place); - CPVT_WordPlace SearchPageEndPlace(const CPVT_WordPlace& wpPageBegin, const CPDF_Point& point) const; - FX_FLOAT GetLineTop(const CPVT_WordPlace& place) const; - FX_FLOAT GetLineBottom(const CPVT_WordPlace& place) const; - -private: - IPDF_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; - - CPDF_Point m_ptScrollPos; - CPDF_Point m_ptRefreshScrollPos; - FX_BOOL m_bEnableScroll; - IFX_Edit_Iterator * m_pIterator; - CFX_Edit_Refresh m_Refresh; - CPDF_Point m_ptCaret; - CFX_Edit_Undo m_Undo; - int32_t m_nAlignment; - FX_BOOL m_bNotifyFlag; - FX_BOOL m_bEnableOverflow; - FX_BOOL m_bEnableRefresh; - CPDF_Rect m_rcOldContent; - FX_BOOL m_bEnableUndo; - FX_BOOL m_bNotify; - FX_BOOL m_bOprNotify; - CFX_Edit_GroupUndoItem* m_pGroupUndoItem; +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: + CFX_Edit(IPDF_VariableText* pVT); + virtual ~CFX_Edit(); + + void SetFontMap(IFX_Edit_FontMap* pFontMap); + void SetVTProvider(IPDF_VariableText_Provider* pProvider); + void SetNotify(IFX_Edit_Notify* pNotify); + void SetOprNotify(IFX_Edit_OprNotify* pOprNotify); + IFX_Edit_Iterator* GetIterator(); + IPDF_VariableText* GetVariableText(); + IFX_Edit_FontMap* GetFontMap(); + + void Initialize(); + void SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint = TRUE); + void SetScrollPos(const CPDF_Point& point); + + void SetAlignmentH(int32_t nFormat = 0, FX_BOOL bPaint = TRUE); + void SetAlignmentV(int32_t nFormat = 0, FX_BOOL bPaint = TRUE); + void SetPasswordChar(FX_WORD wSubWord = '*', FX_BOOL bPaint = TRUE); + void SetLimitChar(int32_t nLimitChar = 0, FX_BOOL bPaint = TRUE); + void SetCharArray(int32_t nCharArray = 0, FX_BOOL bPaint = TRUE); + void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, FX_BOOL bPaint = TRUE); + void SetHorzScale(int32_t nHorzScale = 100, FX_BOOL bPaint = TRUE); + void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE); + void SetMultiLine(FX_BOOL bMultiLine = TRUE, FX_BOOL bPaint = TRUE); + void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); + void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); + void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); + void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE); + void SetTextOverflow(FX_BOOL bAllowed = FALSE, FX_BOOL bPaint = TRUE); + + FX_BOOL IsRichText() const; + void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE); + FX_BOOL SetRichFontSize(FX_FLOAT fFontSize); + FX_BOOL SetRichFontIndex(int32_t nFontIndex); + FX_BOOL SetRichTextColor(FX_COLORREF dwColor); + FX_BOOL SetRichTextScript(int32_t nScriptType); + FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE); + FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE); + FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE); + FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE); + FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace); + FX_BOOL SetRichTextHorzScale(int32_t nHorzScale = 100); + FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading); + FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent); + FX_BOOL SetRichTextAlignment(int32_t nAlignment); + + void OnMouseDown(const CPDF_Point& point, FX_BOOL bShift, FX_BOOL bCtrl); + void OnMouseMove(const CPDF_Point& point, FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl); + + void SetText(const FX_WCHAR* text, + int32_t charset = DEFAULT_CHARSET, + const CPVT_SecProps* pSecProps = NULL, + const CPVT_WordProps* pWordProps = NULL); + FX_BOOL InsertWord(FX_WORD word, + int32_t charset = DEFAULT_CHARSET, + const CPVT_WordProps* pWordProps = NULL); + FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps = NULL, + const CPVT_WordProps* pWordProps = NULL); + FX_BOOL Backspace(); + FX_BOOL Delete(); + FX_BOOL Clear(); + FX_BOOL Empty(); + FX_BOOL InsertText(const FX_WCHAR* text, + int32_t charset = DEFAULT_CHARSET, + const CPVT_SecProps* pSecProps = NULL, + const CPVT_WordProps* pWordProps = NULL); + FX_BOOL Redo(); + FX_BOOL Undo(); + 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(FX_WORD word, int32_t nOldCharset); + + int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const; + CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; + + CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const; + CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const; + CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace& place) const; + CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const; + CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; + + int32_t GetCaret() const; + CPVT_WordPlace GetCaretWordPlace() const; + CFX_WideString GetSelText() const; + CFX_WideString GetText() const; + FX_FLOAT GetFontSize() const; + FX_WORD GetPasswordChar() const; + CPDF_Point GetScrollPos() const; + int32_t GetCharArray() const; + CPDF_Rect GetPlateRect() const; + CPDF_Rect GetContentRect() const; + CFX_WideString GetRangeText(const CPVT_WordRange& range) const; + int32_t GetHorzScale() const; + FX_FLOAT GetCharSpace() const; + int32_t GetTotalWords() const; + int32_t GetTotalLines() const; + + void SetSel(int32_t nStartChar, int32_t nEndChar); + void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; + + private: + void SelectAll(); + void SelectNone(); + void SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); + FX_BOOL IsSelected() const; + + void RearrangeAll(); + void RearrangePart(const CPVT_WordRange& range); + void Paint(); + void ScrollToCaret(); + void SetScrollInfo(); + void SetScrollPosX(FX_FLOAT fx); + void SetScrollPosY(FX_FLOAT fy); + void SetScrollLimit(); + void SetContentChanged(); + void EnableNotify(FX_BOOL bNotify); + + 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(FX_WORD 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 CPDF_Point VTToEdit(const CPDF_Point& point) const; + inline CPDF_Point EditToVT(const CPDF_Point& point) const; + inline CPDF_Rect VTToEdit(const CPDF_Rect& rect) const; + inline CPDF_Rect EditToVT(const CPDF_Rect& rect) const; + + void EnableRefresh(FX_BOOL bRefresh); + 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 RefreshWordRange(const CPVT_WordRange& wr); + + void SetCaret(int32_t nPos); + void SetCaret(const CPVT_WordPlace& place); + void SetCaretInfo(); + void SetCaretOrigin(); + void SetCaretChange(); + + CPVT_WordRange GetWholeWordRange() const; + CPVT_WordRange GetVisibleWordRange() const; + CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace& place) const; + CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1, + const CPVT_WordRange& wr2); + CPVT_WordRange GetSelectWordRange() const; + + void EnableUndo(FX_BOOL bUndo); + void EnableOprNotify(FX_BOOL bNotify); + + FX_BOOL IsTextFull() const; + FX_BOOL IsTextOverflow() const; + FX_BOOL CanUndo() const; + FX_BOOL CanRedo() const; + FX_BOOL IsModified() const; + + void BeginGroupUndo(const CFX_WideString& sTitle); + void EndGroupUndo(); + void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem); + void AddUndoItem(IFX_Edit_UndoItem* pUndoItem); + + void SetPageInfo(const CPVT_WordPlace& place); + CPVT_WordPlace SearchPageEndPlace(const CPVT_WordPlace& wpPageBegin, + const CPDF_Point& point) const; + FX_FLOAT GetLineTop(const CPVT_WordPlace& place) const; + FX_FLOAT GetLineBottom(const CPVT_WordPlace& place) const; + + private: + IPDF_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; + + CPDF_Point m_ptScrollPos; + CPDF_Point m_ptRefreshScrollPos; + FX_BOOL m_bEnableScroll; + IFX_Edit_Iterator* m_pIterator; + CFX_Edit_Refresh m_Refresh; + CPDF_Point m_ptCaret; + CFX_Edit_Undo m_Undo; + int32_t m_nAlignment; + FX_BOOL m_bNotifyFlag; + FX_BOOL m_bEnableOverflow; + FX_BOOL m_bEnableRefresh; + CPDF_Rect m_rcOldContent; + FX_BOOL m_bEnableUndo; + FX_BOOL m_bNotify; + FX_BOOL m_bOprNotify; + CFX_Edit_GroupUndoItem* m_pGroupUndoItem; }; /* ------------------------- CFX_Edit_Iterator ---------------------------- */ -class CFX_Edit_Iterator : public IFX_Edit_Iterator -{ -public: - CFX_Edit_Iterator(CFX_Edit * pEdit,IPDF_VariableText_Iterator * pVTIterator); - virtual ~CFX_Edit_Iterator(); - - FX_BOOL NextWord(); - FX_BOOL NextLine(); - FX_BOOL NextSection(); - FX_BOOL PrevWord(); - FX_BOOL PrevLine(); - FX_BOOL PrevSection(); - - FX_BOOL GetWord(CPVT_Word & word) const; - FX_BOOL GetLine(CPVT_Line & line) const; - FX_BOOL GetSection(CPVT_Section & section) const; - void SetAt(int32_t nWordIndex); - void SetAt(const CPVT_WordPlace & place); - const CPVT_WordPlace & GetAt() const; - IFX_Edit* GetEdit() const; - -private: - CFX_Edit * m_pEdit; - IPDF_VariableText_Iterator* m_pVTIterator; +class CFX_Edit_Iterator : public IFX_Edit_Iterator { + public: + CFX_Edit_Iterator(CFX_Edit* pEdit, IPDF_VariableText_Iterator* pVTIterator); + virtual ~CFX_Edit_Iterator(); + + FX_BOOL NextWord(); + FX_BOOL NextLine(); + FX_BOOL NextSection(); + FX_BOOL PrevWord(); + FX_BOOL PrevLine(); + FX_BOOL PrevSection(); + + FX_BOOL GetWord(CPVT_Word& word) const; + FX_BOOL GetLine(CPVT_Line& line) const; + FX_BOOL GetSection(CPVT_Section& section) const; + void SetAt(int32_t nWordIndex); + void SetAt(const CPVT_WordPlace& place); + const CPVT_WordPlace& GetAt() const; + IFX_Edit* GetEdit() const; + + private: + CFX_Edit* m_pEdit; + IPDF_VariableText_Iterator* m_pVTIterator; }; -class CFX_Edit_Provider : public IPDF_VariableText_Provider -{ -public: - CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap); - virtual ~CFX_Edit_Provider(); +class CFX_Edit_Provider : public IPDF_VariableText_Provider { + public: + CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap); + virtual ~CFX_Edit_Provider(); - IFX_Edit_FontMap* GetFontMap(); + IFX_Edit_FontMap* GetFontMap(); - int32_t GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle); - int32_t GetTypeAscent(int32_t nFontIndex); - int32_t GetTypeDescent(int32_t nFontIndex); - int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); - int32_t GetDefaultFontIndex(); - FX_BOOL IsLatinWord(FX_WORD word); + int32_t GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle); + int32_t GetTypeAscent(int32_t nFontIndex); + int32_t GetTypeDescent(int32_t nFontIndex); + int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); + int32_t GetDefaultFontIndex(); + FX_BOOL IsLatinWord(FX_WORD word); -private: - IFX_Edit_FontMap* m_pFontMap; + private: + IFX_Edit_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 index fe75b0fc35..4aa35684cf 100644 --- a/fpdfsdk/include/fxedit/fxet_list.h +++ b/fpdfsdk/include/fxedit/fxet_list.h @@ -12,353 +12,337 @@ 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_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 CPDF_Rect -{ -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 CPDF_Rect & rect) - { - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; - } - - void Default() - { - left = top = right = bottom = 0.0f; - } - - const CLST_Rect operator = (const CPDF_Rect & rect) - { - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; - - return *this; - } - - FX_BOOL operator == (const CLST_Rect & rect) const - { - return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0; - } - - FX_BOOL operator != (const CLST_Rect & rect) const - { - return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) != 0; - } - - FX_FLOAT Width() const - { - return right - left; - } - - FX_FLOAT Height() const - { - if (top > bottom) - return top - bottom; - return bottom - top; - } - - CPDF_Point LeftTop() const - { - return CPDF_Point(left,top); - } - - CPDF_Point RightBottom() const - { - return CPDF_Point(right,bottom); - } - - const CLST_Rect operator += (const CPDF_Point & point) - { - left += point.x; - right += point.x; - top += point.y; - bottom += point.y; - - return *this; - } - - const CLST_Rect operator -= (const CPDF_Point & point) - { - left -= point.x; - right -= point.x; - top -= point.y; - bottom -= point.y; - - return *this; - } - - CLST_Rect operator + (const CPDF_Point & point) const - { - return CLST_Rect(left + point.x, - top + point.y, - right + point.x, - bottom + point.y); - } - - CLST_Rect operator - (const CPDF_Point & point) const - { - return CLST_Rect(left - point.x, - top - point.y, - right - point.x, - bottom - point.y); - } +class CLST_Rect : public CPDF_Rect { + 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 CPDF_Rect& rect) { + left = rect.left; + top = rect.top; + right = rect.right; + bottom = rect.bottom; + } + + void Default() { left = top = right = bottom = 0.0f; } + + const CLST_Rect operator=(const CPDF_Rect& rect) { + left = rect.left; + top = rect.top; + right = rect.right; + bottom = rect.bottom; + + return *this; + } + + FX_BOOL operator==(const CLST_Rect& rect) const { + return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0; + } + + FX_BOOL operator!=(const CLST_Rect& rect) const { + return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) != 0; + } + + FX_FLOAT Width() const { return right - left; } + + FX_FLOAT Height() const { + if (top > bottom) + return top - bottom; + return bottom - top; + } + + CPDF_Point LeftTop() const { return CPDF_Point(left, top); } + + CPDF_Point RightBottom() const { return CPDF_Point(right, bottom); } + + const CLST_Rect operator+=(const CPDF_Point& point) { + left += point.x; + right += point.x; + top += point.y; + bottom += point.y; + + return *this; + } + + const CLST_Rect operator-=(const CPDF_Point& point) { + left -= point.x; + right -= point.x; + top -= point.y; + bottom -= point.y; + + return *this; + } + + CLST_Rect operator+(const CPDF_Point& point) const { + return CLST_Rect(left + point.x, top + point.y, right + point.x, + bottom + point.y); + } + + CLST_Rect operator-(const CPDF_Point& 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(IFX_Edit_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; - FX_WORD GetFirstChar() const; - -private: - IFX_Edit* m_pEdit; - FX_BOOL m_bSelected; - FX_BOOL m_bCaret; - CLST_Rect m_rcListItem; +class CFX_ListItem { + public: + CFX_ListItem(); + virtual ~CFX_ListItem(); + + void SetFontMap(IFX_Edit_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; + FX_WORD 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 CPDF_Rect & rect){m_rcPlate = rect;} - CPDF_Rect GetPlateRect() const{return m_rcPlate;} - void SetContentRect(const CLST_Rect & rect){m_rcContent = rect;} - CLST_Rect GetContentRect() const{return m_rcContent;} - CPDF_Point GetBTPoint() const{return CPDF_Point(m_rcPlate.left,m_rcPlate.top);} - CPDF_Point GetETPoint() const{return CPDF_Point(m_rcPlate.right,m_rcPlate.bottom);} -public: - CPDF_Point InnerToOuter(const CPDF_Point & point) const{return CPDF_Point(point.x + GetBTPoint().x,GetBTPoint().y - point.y);} - CPDF_Point OuterToInner(const CPDF_Point & point) const{return CPDF_Point(point.x - GetBTPoint().x,GetBTPoint().y - point.y);} - CPDF_Rect InnerToOuter(const CLST_Rect & rect) const{CPDF_Point ptLeftTop = InnerToOuter(CPDF_Point(rect.left,rect.top)); - CPDF_Point ptRightBottom = InnerToOuter(CPDF_Point(rect.right,rect.bottom)); - return CPDF_Rect(ptLeftTop.x,ptRightBottom.y,ptRightBottom.x,ptLeftTop.y);} - CLST_Rect OuterToInner(const CPDF_Rect & rect) const{CPDF_Point ptLeftTop = OuterToInner(CPDF_Point(rect.left,rect.top)); - CPDF_Point ptRightBottom = OuterToInner(CPDF_Point(rect.right,rect.bottom)); - return CLST_Rect(ptLeftTop.x,ptLeftTop.y,ptRightBottom.x,ptRightBottom.y);} -private: - CPDF_Rect m_rcPlate; - CLST_Rect m_rcContent; //positive forever! +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 CPDF_Rect& rect) { m_rcPlate = rect; } + CPDF_Rect GetPlateRect() const { return m_rcPlate; } + void SetContentRect(const CLST_Rect& rect) { m_rcContent = rect; } + CLST_Rect GetContentRect() const { return m_rcContent; } + CPDF_Point GetBTPoint() const { + return CPDF_Point(m_rcPlate.left, m_rcPlate.top); + } + CPDF_Point GetETPoint() const { + return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom); + } + + public: + CPDF_Point InnerToOuter(const CPDF_Point& point) const { + return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y); + } + CPDF_Point OuterToInner(const CPDF_Point& point) const { + return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y); + } + CPDF_Rect InnerToOuter(const CLST_Rect& rect) const { + CPDF_Point ptLeftTop = InnerToOuter(CPDF_Point(rect.left, rect.top)); + CPDF_Point ptRightBottom = + InnerToOuter(CPDF_Point(rect.right, rect.bottom)); + return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, + ptLeftTop.y); + } + CLST_Rect OuterToInner(const CPDF_Rect& rect) const { + CPDF_Point ptLeftTop = OuterToInner(CPDF_Point(rect.left, rect.top)); + CPDF_Point ptRightBottom = + OuterToInner(CPDF_Point(rect.right, rect.bottom)); + return CLST_Rect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, + ptRightBottom.y); + } + + private: + CPDF_Rect m_rcPlate; + CLST_Rect m_rcContent; // positive forever! }; -template class CLST_ArrayTemplate : public CFX_ArrayTemplate -{ -public: - FX_BOOL IsEmpty() { return CFX_ArrayTemplate::GetSize() <= 0; } - TYPE GetAt(int32_t nIndex) const { if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) return CFX_ArrayTemplate::GetAt(nIndex); return NULL;} - void RemoveAt(int32_t nIndex){if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) CFX_ArrayTemplate::RemoveAt(nIndex);} +template +class CLST_ArrayTemplate : public CFX_ArrayTemplate { + public: + FX_BOOL IsEmpty() { return CFX_ArrayTemplate::GetSize() <= 0; } + TYPE GetAt(int32_t nIndex) const { + if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) + return CFX_ArrayTemplate::GetAt(nIndex); + return NULL; + } + void RemoveAt(int32_t nIndex) { + if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) + CFX_ArrayTemplate::RemoveAt(nIndex); + } }; -class CFX_List : protected CFX_ListContainer , public IFX_List -{ -public: - CFX_List(); - virtual ~CFX_List(); +class CFX_List : protected CFX_ListContainer, public IFX_List { + public: + CFX_List(); + virtual ~CFX_List(); -public: - virtual void SetFontMap(IFX_Edit_FontMap * pFontMap); - virtual void SetFontSize(FX_FLOAT fFontSize); + public: + virtual void SetFontMap(IFX_Edit_FontMap* pFontMap); + virtual void SetFontSize(FX_FLOAT fFontSize); - virtual CPDF_Rect GetPlateRect() const; - virtual CPDF_Rect GetContentRect() const; + virtual CPDF_Rect GetPlateRect() const; + virtual CPDF_Rect GetContentRect() const; - virtual FX_FLOAT GetFontSize() const; - virtual IFX_Edit* GetItemEdit(int32_t nIndex) const; - virtual int32_t GetCount() const; - virtual FX_BOOL IsItemSelected(int32_t nIndex) const; - virtual FX_FLOAT GetFirstHeight() const; + virtual FX_FLOAT GetFontSize() const; + virtual IFX_Edit* GetItemEdit(int32_t nIndex) const; + virtual int32_t GetCount() const; + virtual FX_BOOL IsItemSelected(int32_t nIndex) const; + virtual FX_FLOAT GetFirstHeight() const; - virtual void SetMultipleSel(FX_BOOL bMultiple); - virtual FX_BOOL IsMultipleSel() const; - virtual FX_BOOL IsValid(int32_t nItemIndex) const; - virtual int32_t FindNext(int32_t nIndex,FX_WCHAR nChar) const; + virtual void SetMultipleSel(FX_BOOL bMultiple); + virtual FX_BOOL IsMultipleSel() const; + virtual FX_BOOL IsValid(int32_t nItemIndex) const; + virtual int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const; -protected: - virtual void Empty(); + protected: + virtual void Empty(); - void AddItem(const FX_WCHAR* str); - virtual void ReArrange(int32_t nItemIndex); + void AddItem(const FX_WCHAR* str); + virtual void ReArrange(int32_t nItemIndex); - virtual CPDF_Rect GetItemRect(int32_t nIndex) const; - CFX_WideString GetItemText(int32_t nIndex) const; + virtual CPDF_Rect GetItemRect(int32_t nIndex) const; + CFX_WideString GetItemText(int32_t nIndex) const; - void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected); - void SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret); + void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected); + void SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret); - virtual int32_t GetItemIndex(const CPDF_Point & point) const; - int32_t GetFirstSelected() const; - int32_t GetLastSelected() const; - FX_WCHAR Toupper(FX_WCHAR c) const; + virtual int32_t GetItemIndex(const CPDF_Point& point) const; + int32_t GetFirstSelected() const; + int32_t GetLastSelected() const; + FX_WCHAR Toupper(FX_WCHAR c) const; -private: - CLST_ArrayTemplate m_aListItems; - FX_FLOAT m_fFontSize; - IFX_Edit_FontMap* m_pFontMap; - FX_BOOL m_bMultiple; + private: + CLST_ArrayTemplate m_aListItems; + FX_FLOAT m_fFontSize; + IFX_Edit_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; - } +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 + 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 m_aItems; +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 m_aItems; }; -class CFX_ListCtrl : public CFX_List -{ -public: - CFX_ListCtrl(); - virtual ~CFX_ListCtrl(); - -public: - void SetNotify(IFX_List_Notify * pNotify); - - void OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK(int32_t nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl); - FX_BOOL OnChar(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl); - - virtual CPDF_Point InToOut(const CPDF_Point & point) const; - virtual CPDF_Point OutToIn(const CPDF_Point & point) const; - virtual CPDF_Rect InToOut(const CPDF_Rect & rect) const; - virtual CPDF_Rect OutToIn(const CPDF_Rect & rect) const; - - virtual void SetPlateRect(const CPDF_Rect & rect); - void SetScrollPos(const CPDF_Point & point); - void ScrollToListItem(int32_t nItemIndex); - virtual CPDF_Rect GetItemRect(int32_t nIndex) const; - int32_t GetCaret() const {return m_nCaretIndex;} - int32_t GetSelect() const {return m_nSelItem;} - int32_t GetTopItem() const; - virtual CPDF_Rect GetContentRect() const; - virtual int32_t GetItemIndex(const CPDF_Point & point) const; - - void AddString(const FX_WCHAR* string); - void SetTopItem(int32_t nIndex); - void Select(int32_t nItemIndex); - virtual void SetCaret(int32_t nItemIndex); - virtual void Empty(); - virtual void Cancel(); - CFX_WideString GetText() 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); - virtual void ReArrange(int32_t nItemIndex); - -private: - IFX_List_Notify* m_pNotify; - FX_BOOL m_bNotifyFlag; - CPDF_Point 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 +class CFX_ListCtrl : public CFX_List { + public: + CFX_ListCtrl(); + virtual ~CFX_ListCtrl(); + + public: + void SetNotify(IFX_List_Notify* pNotify); + + void OnMouseDown(const CPDF_Point& point, FX_BOOL bShift, FX_BOOL bCtrl); + void OnMouseMove(const CPDF_Point& point, FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl); + FX_BOOL OnChar(FX_WORD nChar, FX_BOOL bShift, FX_BOOL bCtrl); + + virtual CPDF_Point InToOut(const CPDF_Point& point) const; + virtual CPDF_Point OutToIn(const CPDF_Point& point) const; + virtual CPDF_Rect InToOut(const CPDF_Rect& rect) const; + virtual CPDF_Rect OutToIn(const CPDF_Rect& rect) const; + + virtual void SetPlateRect(const CPDF_Rect& rect); + void SetScrollPos(const CPDF_Point& point); + void ScrollToListItem(int32_t nItemIndex); + virtual CPDF_Rect GetItemRect(int32_t nIndex) const; + int32_t GetCaret() const { return m_nCaretIndex; } + int32_t GetSelect() const { return m_nSelItem; } + int32_t GetTopItem() const; + virtual CPDF_Rect GetContentRect() const; + virtual int32_t GetItemIndex(const CPDF_Point& point) const; + + void AddString(const FX_WCHAR* string); + void SetTopItem(int32_t nIndex); + void Select(int32_t nItemIndex); + virtual void SetCaret(int32_t nItemIndex); + virtual void Empty(); + virtual void Cancel(); + CFX_WideString GetText() 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); + virtual void ReArrange(int32_t nItemIndex); + + private: + IFX_List_Notify* m_pNotify; + FX_BOOL m_bNotifyFlag; + CPDF_Point 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/javascript/Consts.h b/fpdfsdk/include/javascript/Consts.h index d04cc6b54c..c0abe4c7d4 100644 --- a/fpdfsdk/include/javascript/Consts.h +++ b/fpdfsdk/include/javascript/Consts.h @@ -11,117 +11,108 @@ /* ------------------------------ border ------------------------------ */ -class CJS_Border : public CJS_Object -{ -public: - CJS_Border(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Border(void){}; +class CJS_Border : public CJS_Object { + public: + CJS_Border(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Border(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ display ------------------------------ */ -class CJS_Display : public CJS_Object -{ -public: - CJS_Display(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Display(void){}; +class CJS_Display : public CJS_Object { + public: + CJS_Display(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Display(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ font ------------------------------ */ -class CJS_Font : public CJS_Object -{ -public: - CJS_Font(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Font(void){}; +class CJS_Font : public CJS_Object { + public: + CJS_Font(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Font(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ highlight ------------------------------ */ -class CJS_Highlight : public CJS_Object -{ -public: - CJS_Highlight(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Highlight(void){}; +class CJS_Highlight : public CJS_Object { + public: + CJS_Highlight(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Highlight(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ position ------------------------------ */ -class CJS_Position : public CJS_Object -{ -public: - CJS_Position(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Position(void){}; +class CJS_Position : public CJS_Object { + public: + CJS_Position(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Position(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ scaleHow ------------------------------ */ -class CJS_ScaleHow : public CJS_Object -{ -public: - CJS_ScaleHow(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_ScaleHow(void){}; +class CJS_ScaleHow : public CJS_Object { + public: + CJS_ScaleHow(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_ScaleHow(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ scaleWhen ------------------------------ */ -class CJS_ScaleWhen : public CJS_Object -{ -public: - CJS_ScaleWhen(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_ScaleWhen(void){}; +class CJS_ScaleWhen : public CJS_Object { + public: + CJS_ScaleWhen(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_ScaleWhen(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ style ------------------------------ */ -class CJS_Style : public CJS_Object -{ -public: - CJS_Style(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Style(void){}; +class CJS_Style : public CJS_Object { + public: + CJS_Style(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Style(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; /* ------------------------------ zoomtype ------------------------------ */ -class CJS_Zoomtype : public CJS_Object -{ -public: - CJS_Zoomtype(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Zoomtype(void){}; +class CJS_Zoomtype : public CJS_Object { + public: + CJS_Zoomtype(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Zoomtype(void){}; - DECLARE_JS_CLASS_CONST(); + DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ CJS_GlobalConsts ------------------------------ */ +/* ------------------------------ CJS_GlobalConsts + * ------------------------------ */ -class CJS_GlobalConsts : public CJS_Object -{ -public: - static int Init(IJS_Runtime* pRuntime); +class CJS_GlobalConsts : public CJS_Object { + public: + static int Init(IJS_Runtime* pRuntime); }; -/* ------------------------------ CJS_GlobalArrays ------------------------------ */ +/* ------------------------------ CJS_GlobalArrays + * ------------------------------ */ -class CJS_GlobalArrays : public CJS_Object -{ -public: - static int Init(IJS_Runtime* pRuntime); +class CJS_GlobalArrays : public CJS_Object { + public: + static int Init(IJS_Runtime* pRuntime); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_CONSTS_H_ diff --git a/fpdfsdk/include/javascript/Document.h b/fpdfsdk/include/javascript/Document.h index b6447fda2a..7d0e05fc43 100644 --- a/fpdfsdk/include/javascript/Document.h +++ b/fpdfsdk/include/javascript/Document.h @@ -9,266 +9,398 @@ #include "JS_Define.h" -class PrintParamsObj : public CJS_EmbedObj -{ -public: - PrintParamsObj(CJS_Object* pJSObject); - virtual ~PrintParamsObj(){} +class PrintParamsObj : public CJS_EmbedObj { + public: + PrintParamsObj(CJS_Object* pJSObject); + virtual ~PrintParamsObj() {} -public: - FX_BOOL bUI; - int nStart; - int nEnd; - FX_BOOL bSilent; - FX_BOOL bShrinkToFit; - FX_BOOL bPrintAsImage; - FX_BOOL bReverse; - FX_BOOL bAnnotations; + public: + FX_BOOL bUI; + int nStart; + int nEnd; + FX_BOOL bSilent; + FX_BOOL bShrinkToFit; + FX_BOOL bPrintAsImage; + FX_BOOL bReverse; + FX_BOOL bAnnotations; }; -class CJS_PrintParamsObj : public CJS_Object -{ -public: - CJS_PrintParamsObj(JSFXObject pObject) : CJS_Object(pObject) {} - virtual ~CJS_PrintParamsObj(){} +class CJS_PrintParamsObj : public CJS_Object { + public: + CJS_PrintParamsObj(JSFXObject pObject) : CJS_Object(pObject) {} + virtual ~CJS_PrintParamsObj() {} - DECLARE_JS_CLASS(CJS_PrintParamsObj); + DECLARE_JS_CLASS(CJS_PrintParamsObj); }; - class Icon; class Field; -struct IconElement -{ - IconElement() : IconName(L""), NextIcon(NULL), IconStream(NULL) {} - virtual ~IconElement() - { - } - CFX_WideString IconName; - IconElement* NextIcon; - Icon* IconStream; +struct IconElement { + IconElement() : IconName(L""), NextIcon(NULL), IconStream(NULL) {} + virtual ~IconElement() {} + CFX_WideString IconName; + IconElement* NextIcon; + Icon* IconStream; }; -class IconTree -{ -public: - IconTree():m_pHead(NULL), m_pEnd(NULL), m_iLength(0) - { - - } +class IconTree { + public: + IconTree() : m_pHead(NULL), m_pEnd(NULL), m_iLength(0) {} - virtual ~IconTree() - { - } + virtual ~IconTree() {} -public: - void InsertIconElement(IconElement* pNewIcon); - void DeleteIconTree(); - int GetLength(); - IconElement* operator[](int iIndex); + public: + void InsertIconElement(IconElement* pNewIcon); + void DeleteIconTree(); + int GetLength(); + IconElement* operator[](int iIndex); -private: - IconElement* m_pHead; - IconElement* m_pEnd; - int m_iLength; + private: + IconElement* m_pHead; + IconElement* m_pEnd; + int m_iLength; }; struct CJS_DelayData; struct CJS_DelayAnnot; struct CJS_AnnotObj; -class Document : public CJS_EmbedObj -{ -public: - Document(CJS_Object* pJSObject); - virtual ~Document(); +class Document : public CJS_EmbedObj { + public: + Document(CJS_Object* pJSObject); + virtual ~Document(); -public: - FX_BOOL ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + public: + FX_BOOL ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL bookmarkRoot(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL calculate(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL creationDate(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL documentFileName(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL external(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL filesize(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL keywords(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL numFields(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL numPages(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL pageWindowRect(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL producer(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL zoomType(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); - FX_BOOL addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL calculateNow(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL createDataObject(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL deletePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL exportAsText(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL extractPages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL importTextData(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL insertPages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL removeField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL replacePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); + FX_BOOL addAnnot(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL addField(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL addLink(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL addIcon(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL calculateNow(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL closeDoc(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL createDataObject(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL deletePages(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL exportAsText(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL exportAsFDF(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL exportAsXFDF(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL extractPages(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getAnnot(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getAnnots(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getAnnot3D(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getAnnots3D(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getField(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getIcon(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getLinks(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getNthFieldName(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getOCGs(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getPageBox(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getPageNthWord(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getPageNthWordQuads(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getPageNumWords(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getPrintParams(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getURL(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL importAnFDF(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL importAnXFDF(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL importTextData(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL insertPages(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL mailForm(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL print(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL removeField(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL replacePages(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL resetForm(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL saveAs(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL submitForm(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL mailDoc(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL removeIcon(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); -public: - void AttachDoc(CPDFSDK_Document* pDoc); - CPDFSDK_Document* GetReaderDoc(); - static FX_BOOL ExtractFileName(CPDFSDK_Document* pDoc, CFX_ByteString& strFileName); - static FX_BOOL ExtractFolderName(CPDFSDK_Document* pDoc, CFX_ByteString& strFolderName); - void AddDelayData(CJS_DelayData* pData); - void DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex); - void AddDelayAnnotData(CJS_AnnotObj *pData); - void DoAnnotDelay(); - void SetIsolate(v8::Isolate* isolate) {m_isolate = isolate;} - CJS_Document* GetCJSDoc() const; + public: + void AttachDoc(CPDFSDK_Document* pDoc); + CPDFSDK_Document* GetReaderDoc(); + static FX_BOOL ExtractFileName(CPDFSDK_Document* pDoc, + CFX_ByteString& strFileName); + static FX_BOOL ExtractFolderName(CPDFSDK_Document* pDoc, + CFX_ByteString& strFolderName); + void AddDelayData(CJS_DelayData* pData); + void DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex); + void AddDelayAnnotData(CJS_AnnotObj* pData); + void DoAnnotDelay(); + void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; } + CJS_Document* GetCJSDoc() const; -private: - CFX_WideString ReversalStr(CFX_WideString cbFrom); - CFX_WideString CutString(CFX_WideString cbFrom); - bool IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect); - int CountWords(CPDF_TextObject* pTextObj); - CFX_WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex); - FX_BOOL ParserParams(JSObject *pObj,CJS_AnnotObj& annotobj); + private: + CFX_WideString ReversalStr(CFX_WideString cbFrom); + CFX_WideString CutString(CFX_WideString cbFrom); + bool IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect); + int CountWords(CPDF_TextObject* pTextObj); + CFX_WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex); + FX_BOOL ParserParams(JSObject* pObj, CJS_AnnotObj& annotobj); - v8::Isolate* m_isolate; - IconTree* m_pIconTree; - CPDFSDK_Document* m_pDocument; - CFX_WideString m_cwBaseURL; - bool m_bDelay; - CFX_ArrayTemplate m_DelayData; - CFX_ArrayTemplate m_DelayAnnotData; + v8::Isolate* m_isolate; + IconTree* m_pIconTree; + CPDFSDK_Document* m_pDocument; + CFX_WideString m_cwBaseURL; + bool m_bDelay; + CFX_ArrayTemplate m_DelayData; + CFX_ArrayTemplate m_DelayAnnotData; }; -class CJS_Document : public CJS_Object -{ -public: - CJS_Document(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Document(){}; +class CJS_Document : public CJS_Object { + public: + CJS_Document(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Document(){}; - virtual FX_BOOL InitInstance(IFXJS_Context* cc); + virtual FX_BOOL InitInstance(IFXJS_Context* cc); - DECLARE_JS_CLASS(CJS_Document); + DECLARE_JS_CLASS(CJS_Document); - JS_STATIC_PROP(ADBE, Document); - JS_STATIC_PROP(author, Document); - JS_STATIC_PROP(baseURL, Document); - JS_STATIC_PROP(bookmarkRoot, Document); - JS_STATIC_PROP(calculate, Document); - JS_STATIC_PROP(Collab, Document); - JS_STATIC_PROP(creationDate, Document); - JS_STATIC_PROP(creator, Document); - JS_STATIC_PROP(delay, Document); - JS_STATIC_PROP(dirty, Document); - JS_STATIC_PROP(documentFileName, Document); - JS_STATIC_PROP(external, Document); - JS_STATIC_PROP(filesize, Document); - JS_STATIC_PROP(icons, Document); - JS_STATIC_PROP(info, Document); - JS_STATIC_PROP(keywords, Document); - JS_STATIC_PROP(layout, Document); - JS_STATIC_PROP(media, Document); - JS_STATIC_PROP(modDate, Document); - JS_STATIC_PROP(mouseX, Document); - JS_STATIC_PROP(mouseY, Document); - JS_STATIC_PROP(numFields, Document); - JS_STATIC_PROP(numPages, Document); - JS_STATIC_PROP(pageNum, Document); - JS_STATIC_PROP(pageWindowRect, Document); - JS_STATIC_PROP(path, Document); - JS_STATIC_PROP(producer, Document); - JS_STATIC_PROP(subject, Document); - JS_STATIC_PROP(title, Document); - JS_STATIC_PROP(zoom, Document); - JS_STATIC_PROP(zoomType, Document); + JS_STATIC_PROP(ADBE, Document); + JS_STATIC_PROP(author, Document); + JS_STATIC_PROP(baseURL, Document); + JS_STATIC_PROP(bookmarkRoot, Document); + JS_STATIC_PROP(calculate, Document); + JS_STATIC_PROP(Collab, Document); + JS_STATIC_PROP(creationDate, Document); + JS_STATIC_PROP(creator, Document); + JS_STATIC_PROP(delay, Document); + JS_STATIC_PROP(dirty, Document); + JS_STATIC_PROP(documentFileName, Document); + JS_STATIC_PROP(external, Document); + JS_STATIC_PROP(filesize, Document); + JS_STATIC_PROP(icons, Document); + JS_STATIC_PROP(info, Document); + JS_STATIC_PROP(keywords, Document); + JS_STATIC_PROP(layout, Document); + JS_STATIC_PROP(media, Document); + JS_STATIC_PROP(modDate, Document); + JS_STATIC_PROP(mouseX, Document); + JS_STATIC_PROP(mouseY, Document); + JS_STATIC_PROP(numFields, Document); + JS_STATIC_PROP(numPages, Document); + JS_STATIC_PROP(pageNum, Document); + JS_STATIC_PROP(pageWindowRect, Document); + JS_STATIC_PROP(path, Document); + JS_STATIC_PROP(producer, Document); + JS_STATIC_PROP(subject, Document); + JS_STATIC_PROP(title, Document); + JS_STATIC_PROP(zoom, Document); + JS_STATIC_PROP(zoomType, Document); - JS_STATIC_METHOD(addAnnot,Document); - JS_STATIC_METHOD(addField, Document); - JS_STATIC_METHOD(addLink, Document); - JS_STATIC_METHOD(addIcon, Document); - JS_STATIC_METHOD(calculateNow, Document); - JS_STATIC_METHOD(closeDoc, Document); - JS_STATIC_METHOD(createDataObject, Document); - JS_STATIC_METHOD(deletePages, Document); - JS_STATIC_METHOD(exportAsText, Document); - JS_STATIC_METHOD(exportAsFDF, Document); - JS_STATIC_METHOD(exportAsXFDF, Document); - JS_STATIC_METHOD(extractPages, Document); - JS_STATIC_METHOD(getAnnot, Document); - JS_STATIC_METHOD(getAnnots, Document); - JS_STATIC_METHOD(getAnnot3D, Document); - JS_STATIC_METHOD(getAnnots3D, Document); - JS_STATIC_METHOD(getField, Document); - JS_STATIC_METHOD(getIcon, Document); - JS_STATIC_METHOD(getLinks, Document); - JS_STATIC_METHOD(getNthFieldName, Document); - JS_STATIC_METHOD(getOCGs, Document); - JS_STATIC_METHOD(getPageBox, Document); - JS_STATIC_METHOD(getPageNthWord, Document); - JS_STATIC_METHOD(getPageNthWordQuads, Document); - JS_STATIC_METHOD(getPageNumWords, Document); - JS_STATIC_METHOD(getPrintParams, Document); - JS_STATIC_METHOD(getURL, Document); - JS_STATIC_METHOD(importAnFDF, Document); - JS_STATIC_METHOD(importAnXFDF, Document); - JS_STATIC_METHOD(importTextData, Document); - JS_STATIC_METHOD(insertPages, Document); - JS_STATIC_METHOD(mailForm, Document); - JS_STATIC_METHOD(print, Document); - JS_STATIC_METHOD(removeField, Document); - JS_STATIC_METHOD(replacePages, Document); - JS_STATIC_METHOD(removeIcon, Document); - JS_STATIC_METHOD(resetForm, Document); - JS_STATIC_METHOD(saveAs, Document); - JS_STATIC_METHOD(submitForm, Document); - JS_STATIC_METHOD(mailDoc, Document); + JS_STATIC_METHOD(addAnnot, Document); + JS_STATIC_METHOD(addField, Document); + JS_STATIC_METHOD(addLink, Document); + JS_STATIC_METHOD(addIcon, Document); + JS_STATIC_METHOD(calculateNow, Document); + JS_STATIC_METHOD(closeDoc, Document); + JS_STATIC_METHOD(createDataObject, Document); + JS_STATIC_METHOD(deletePages, Document); + JS_STATIC_METHOD(exportAsText, Document); + JS_STATIC_METHOD(exportAsFDF, Document); + JS_STATIC_METHOD(exportAsXFDF, Document); + JS_STATIC_METHOD(extractPages, Document); + JS_STATIC_METHOD(getAnnot, Document); + JS_STATIC_METHOD(getAnnots, Document); + JS_STATIC_METHOD(getAnnot3D, Document); + JS_STATIC_METHOD(getAnnots3D, Document); + JS_STATIC_METHOD(getField, Document); + JS_STATIC_METHOD(getIcon, Document); + JS_STATIC_METHOD(getLinks, Document); + JS_STATIC_METHOD(getNthFieldName, Document); + JS_STATIC_METHOD(getOCGs, Document); + JS_STATIC_METHOD(getPageBox, Document); + JS_STATIC_METHOD(getPageNthWord, Document); + JS_STATIC_METHOD(getPageNthWordQuads, Document); + JS_STATIC_METHOD(getPageNumWords, Document); + JS_STATIC_METHOD(getPrintParams, Document); + JS_STATIC_METHOD(getURL, Document); + JS_STATIC_METHOD(importAnFDF, Document); + JS_STATIC_METHOD(importAnXFDF, Document); + JS_STATIC_METHOD(importTextData, Document); + JS_STATIC_METHOD(insertPages, Document); + JS_STATIC_METHOD(mailForm, Document); + JS_STATIC_METHOD(print, Document); + JS_STATIC_METHOD(removeField, Document); + JS_STATIC_METHOD(replacePages, Document); + JS_STATIC_METHOD(removeIcon, Document); + JS_STATIC_METHOD(resetForm, Document); + JS_STATIC_METHOD(saveAs, Document); + JS_STATIC_METHOD(submitForm, Document); + JS_STATIC_METHOD(mailDoc, Document); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_DOCUMENT_H_ diff --git a/fpdfsdk/include/javascript/Field.h b/fpdfsdk/include/javascript/Field.h index 70d1d39b48..afbf783bf2 100644 --- a/fpdfsdk/include/javascript/Field.h +++ b/fpdfsdk/include/javascript/Field.h @@ -14,346 +14,611 @@ class Document; -enum FIELD_PROP -{ - FP_ALIGNMENT, - FP_BORDERSTYLE, - FP_BUTTONALIGNX, - FP_BUTTONALIGNY, - FP_BUTTONFITBOUNDS, - FP_BUTTONPOSITION, - FP_BUTTONSCALEHOW, - FP_BUTTONSCALEWHEN, - FP_CALCORDERINDEX, - FP_CHARLIMIT, - FP_COMB, - FP_COMMITONSELCHANGE, - FP_CURRENTVALUEINDICES, - FP_DEFAULTVALUE, - FP_DONOTSCROLL, - FP_DISPLAY, - FP_FILLCOLOR, - FP_HIDDEN, - FP_HIGHLIGHT, - FP_LINEWIDTH, - FP_MULTILINE, - FP_MULTIPLESELECTION, - FP_PASSWORD, - FP_RECT, - FP_RICHTEXT, - FP_RICHVALUE, - FP_ROTATION, - FP_STROKECOLOR, - FP_STYLE, - FP_TEXTCOLOR, - FP_TEXTFONT, - FP_TEXTSIZE, - FP_USERNAME, - FP_VALUE +enum FIELD_PROP { + FP_ALIGNMENT, + FP_BORDERSTYLE, + FP_BUTTONALIGNX, + FP_BUTTONALIGNY, + FP_BUTTONFITBOUNDS, + FP_BUTTONPOSITION, + FP_BUTTONSCALEHOW, + FP_BUTTONSCALEWHEN, + FP_CALCORDERINDEX, + FP_CHARLIMIT, + FP_COMB, + FP_COMMITONSELCHANGE, + FP_CURRENTVALUEINDICES, + FP_DEFAULTVALUE, + FP_DONOTSCROLL, + FP_DISPLAY, + FP_FILLCOLOR, + FP_HIDDEN, + FP_HIGHLIGHT, + FP_LINEWIDTH, + FP_MULTILINE, + FP_MULTIPLESELECTION, + FP_PASSWORD, + FP_RECT, + FP_RICHTEXT, + FP_RICHVALUE, + FP_ROTATION, + FP_STROKECOLOR, + FP_STYLE, + FP_TEXTCOLOR, + FP_TEXTFONT, + FP_TEXTSIZE, + FP_USERNAME, + FP_VALUE }; -class CJS_WideStringArray -{ -public: - CJS_WideStringArray(){} - virtual ~CJS_WideStringArray() - { - for (int i=0,sz=m_Data.GetSize(); i m_Data; +class CJS_WideStringArray { + public: + CJS_WideStringArray() {} + virtual ~CJS_WideStringArray() { + for (int i = 0, sz = m_Data.GetSize(); i < sz; i++) + delete m_Data.GetAt(i); + m_Data.RemoveAll(); + } + + void Add(const CFX_WideString& string) { + m_Data.Add(new CFX_WideString(string)); + } + + int GetSize() const { return m_Data.GetSize(); } + + CFX_WideString GetAt(int i) const { return *m_Data.GetAt(i); } + + private: + CFX_ArrayTemplate m_Data; }; -struct CJS_DelayData -{ - CFX_WideString sFieldName; - int nControlIndex; - enum FIELD_PROP eProp; - int32_t num; - bool b; - CFX_ByteString string; - CFX_WideString widestring; - CPDF_Rect rect; - CPWL_Color color; - CFX_DWordArray wordarray; - CJS_WideStringArray widestringarray; +struct CJS_DelayData { + CFX_WideString sFieldName; + int nControlIndex; + enum FIELD_PROP eProp; + int32_t num; + bool b; + CFX_ByteString string; + CFX_WideString widestring; + CPDF_Rect rect; + CPWL_Color color; + CFX_DWordArray wordarray; + CJS_WideStringArray widestringarray; }; -class Field : public CJS_EmbedObj -{ -public: - Field(CJS_Object* pJSObject); - virtual ~Field(void); - - FX_BOOL alignment(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL borderStyle(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL buttonAlignX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL buttonAlignY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL buttonFitBounds(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL buttonPosition(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL buttonScaleHow(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL buttonScaleWhen(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL calcOrderIndex(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL charLimit(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL comb(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL commitOnSelChange(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL currentValueIndices(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL defaultStyle(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL defaultValue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL doNotScroll(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL doNotSpellCheck(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL display(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL doc(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL editable(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL exportValues(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL fileSelect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL fillColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL hidden(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL highlight(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL lineWidth(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL multiline(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL multipleSelection(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL numItems(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL page(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL password(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL print(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL radiosInUnison(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL readonly(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL rect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL required(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL richText(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL richValue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL rotation(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL strokeColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL style(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL submitName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL textColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL textFont(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL textSize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL type(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL userName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL valueAsString(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL source(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - - FX_BOOL browseForFileToSubmit(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL buttonGetCaption(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL buttonGetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL buttonImportIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL buttonSetCaption(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL buttonSetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL checkThisBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL clearItems(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL defaultIsChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL deleteItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getArray(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL getLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL insertItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL isBoxChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL isDefaultChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL setAction(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL setFocus(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL setItems(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL setLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL signatureGetModifications(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL signatureGetSeedValue(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL signatureInfo(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL signatureSetSeedValue(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL signatureSign(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL signatureValidate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - -public: - static void SetAlignment(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetBorderStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetButtonAlignX(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonAlignY(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonFitBounds(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetButtonPosition(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonScaleHow(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonScaleWhen(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetCalcOrderIndex(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetCharLimit(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetComb(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetCommitOnSelChange(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetCurrentValueIndices(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_DWordArray& array); - static void SetDefaultStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex); - static void SetDefaultValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_WideString& string); - static void SetDoNotScroll(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetDisplay(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetFillColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color); - static void SetHidden(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetHighlight(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetLineWidth(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetMultiline(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetMultipleSelection(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetPassword(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetRect(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPDF_Rect& rect); - static void SetRichText(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetRichValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex); - static void SetRotation(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetStrokeColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color); - static void SetStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetTextColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color); - static void SetTextFont(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetTextSize(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetUserName(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_WideString& string); - static void SetValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CJS_WideStringArray& strArray); - -public: - static void AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType, - const CFX_WideString& sName, const CPDF_Rect& rcCoords); -public: - static void UpdateFormField(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, - FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh); - static void UpdateFormControl(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl, - FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh); - - static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl); - static void GetFormFields(CPDFSDK_Document* pDocument, const CFX_WideString& csFieldName, CFX_PtrArray& FieldsArray); - - static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData); - -public: - FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName); - void SetDelay(FX_BOOL bDelay); - void SetIsolate(v8::Isolate* isolate) {m_isolate = isolate;} -protected: - void ParseFieldName(const std::wstring &strFieldNameParsed,std::wstring &strFieldName,int & iControlNo); - void GetFormFields(const CFX_WideString& csFieldName, CFX_PtrArray& FieldsArray); - CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField); - FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel); - - void AddDelay_Int(enum FIELD_PROP prop, int32_t n); - void AddDelay_Bool(enum FIELD_PROP prop,bool b); - void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string); - void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string); - void AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect); - void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color); - void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array); - void AddDelay_WideStringArray(enum FIELD_PROP prop, const CJS_WideStringArray& array); - - void DoDelay(); -public: - Document* m_pJSDoc; - CPDFSDK_Document* m_pDocument; - CFX_WideString m_FieldName; - int m_nFormControlIndex; - FX_BOOL m_bCanSet; - - FX_BOOL m_bDelay; - v8::Isolate* m_isolate; +class Field : public CJS_EmbedObj { + public: + Field(CJS_Object* pJSObject); + virtual ~Field(void); + + FX_BOOL alignment(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL borderStyle(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL buttonAlignX(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL buttonAlignY(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL buttonFitBounds(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL buttonPosition(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL buttonScaleHow(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL buttonScaleWhen(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL calcOrderIndex(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL charLimit(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL comb(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL commitOnSelChange(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL currentValueIndices(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL defaultStyle(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL defaultValue(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL doNotScroll(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL doNotSpellCheck(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL display(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL doc(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL editable(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL exportValues(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL fileSelect(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL fillColor(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL hidden(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL highlight(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL lineWidth(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL multiline(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL multipleSelection(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL numItems(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL page(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL password(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL print(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL radiosInUnison(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL readonly(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL rect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL required(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL richText(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL richValue(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL rotation(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL strokeColor(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL style(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL submitName(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL textColor(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL textFont(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL textSize(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL type(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL userName(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL valueAsString(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL source(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + + FX_BOOL browseForFileToSubmit(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL buttonGetCaption(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL buttonGetIcon(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL buttonImportIcon(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL buttonSetCaption(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL buttonSetIcon(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL checkThisBox(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL clearItems(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL defaultIsChecked(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL deleteItemAt(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getArray(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getItemAt(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL getLock(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL insertItemAt(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL isBoxChecked(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL isDefaultChecked(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL setAction(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL setFocus(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL setItems(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL setLock(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL signatureGetModifications(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL signatureGetSeedValue(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL signatureInfo(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL signatureSetSeedValue(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL signatureSign(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL signatureValidate(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + + public: + static void SetAlignment(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_ByteString& string); + static void SetBorderStyle(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_ByteString& string); + static void SetButtonAlignX(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetButtonAlignY(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetButtonFitBounds(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetButtonPosition(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetButtonScaleHow(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetButtonScaleWhen(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetCalcOrderIndex(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetCharLimit(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetComb(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetCommitOnSelChange(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetCurrentValueIndices(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_DWordArray& array); + static void SetDefaultStyle(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex); + static void SetDefaultValue(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_WideString& string); + static void SetDoNotScroll(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetDisplay(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetFillColor(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CPWL_Color& color); + static void SetHidden(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetHighlight(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_ByteString& string); + static void SetLineWidth(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetMultiline(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetMultipleSelection(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetPassword(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetRect(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CPDF_Rect& rect); + static void SetRichText(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + bool b); + static void SetRichValue(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex); + static void SetRotation(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetStrokeColor(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CPWL_Color& color); + static void SetStyle(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_ByteString& string); + static void SetTextColor(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CPWL_Color& color); + static void SetTextFont(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_ByteString& string); + static void SetTextSize(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + int number); + static void SetUserName(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CFX_WideString& string); + static void SetValue(CPDFSDK_Document* pDocument, + const CFX_WideString& swFieldName, + int nControlIndex, + const CJS_WideStringArray& strArray); + + public: + static void AddField(CPDFSDK_Document* pDocument, + int nPageIndex, + int nFieldType, + const CFX_WideString& sName, + const CPDF_Rect& rcCoords); + + public: + static void UpdateFormField(CPDFSDK_Document* pDocument, + CPDF_FormField* pFormField, + FX_BOOL bChangeMark, + FX_BOOL bResetAP, + FX_BOOL bRefresh); + static void UpdateFormControl(CPDFSDK_Document* pDocument, + CPDF_FormControl* pFormControl, + FX_BOOL bChangeMark, + FX_BOOL bResetAP, + FX_BOOL bRefresh); + + static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument, + CPDF_FormControl* pFormControl); + static void GetFormFields(CPDFSDK_Document* pDocument, + const CFX_WideString& csFieldName, + CFX_PtrArray& FieldsArray); + + static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData); + + public: + FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName); + void SetDelay(FX_BOOL bDelay); + void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; } + + protected: + void ParseFieldName(const std::wstring& strFieldNameParsed, + std::wstring& strFieldName, + int& iControlNo); + void GetFormFields(const CFX_WideString& csFieldName, + CFX_PtrArray& FieldsArray); + CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField); + FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel); + + void AddDelay_Int(enum FIELD_PROP prop, int32_t n); + void AddDelay_Bool(enum FIELD_PROP prop, bool b); + void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string); + void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string); + void AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect); + void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color); + void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array); + void AddDelay_WideStringArray(enum FIELD_PROP prop, + const CJS_WideStringArray& array); + + void DoDelay(); + + public: + Document* m_pJSDoc; + CPDFSDK_Document* m_pDocument; + CFX_WideString m_FieldName; + int m_nFormControlIndex; + FX_BOOL m_bCanSet; + + FX_BOOL m_bDelay; + v8::Isolate* m_isolate; }; -class CJS_Field : public CJS_Object -{ -public: - CJS_Field(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Field(void){}; - - virtual FX_BOOL InitInstance(IFXJS_Context* cc); - - DECLARE_JS_CLASS(CJS_Field); - - JS_STATIC_PROP(alignment, Field); - JS_STATIC_PROP(borderStyle, Field); - JS_STATIC_PROP(buttonAlignX, Field); - JS_STATIC_PROP(buttonAlignY, Field); - JS_STATIC_PROP(buttonFitBounds, Field); - JS_STATIC_PROP(buttonPosition, Field); - JS_STATIC_PROP(buttonScaleHow, Field); - JS_STATIC_PROP(buttonScaleWhen, Field); - JS_STATIC_PROP(calcOrderIndex, Field); - JS_STATIC_PROP(charLimit, Field); - JS_STATIC_PROP(comb, Field); - JS_STATIC_PROP(commitOnSelChange, Field); - JS_STATIC_PROP(currentValueIndices, Field); - JS_STATIC_PROP(defaultStyle, Field); - JS_STATIC_PROP(defaultValue, Field); - JS_STATIC_PROP(doNotScroll, Field); - JS_STATIC_PROP(doNotSpellCheck, Field); - JS_STATIC_PROP(delay, Field); - JS_STATIC_PROP(display, Field); - JS_STATIC_PROP(doc, Field); - JS_STATIC_PROP(editable, Field); - JS_STATIC_PROP(exportValues, Field); - JS_STATIC_PROP(fileSelect, Field); - JS_STATIC_PROP(fillColor, Field); - JS_STATIC_PROP(hidden, Field); - JS_STATIC_PROP(highlight, Field); - JS_STATIC_PROP(lineWidth, Field); - JS_STATIC_PROP(multiline, Field); - JS_STATIC_PROP(multipleSelection, Field); - JS_STATIC_PROP(name, Field); - JS_STATIC_PROP(numItems, Field); - JS_STATIC_PROP(page, Field); - JS_STATIC_PROP(password, Field); - JS_STATIC_PROP(print, Field); - JS_STATIC_PROP(radiosInUnison, Field); - JS_STATIC_PROP(readonly, Field); - JS_STATIC_PROP(rect, Field); - JS_STATIC_PROP(required, Field); - JS_STATIC_PROP(richText, Field); - JS_STATIC_PROP(richValue, Field); - JS_STATIC_PROP(rotation, Field); - JS_STATIC_PROP(strokeColor, Field); - JS_STATIC_PROP(style, Field); - JS_STATIC_PROP(submitName, Field); - JS_STATIC_PROP(textColor, Field); - JS_STATIC_PROP(textFont, Field); - JS_STATIC_PROP(textSize, Field); - JS_STATIC_PROP(type, Field); - JS_STATIC_PROP(userName, Field); - JS_STATIC_PROP(value, Field); - JS_STATIC_PROP(valueAsString, Field); - JS_STATIC_PROP(source, Field); - - JS_STATIC_METHOD(browseForFileToSubmit, Field); - JS_STATIC_METHOD(buttonGetCaption, Field); - JS_STATIC_METHOD(buttonGetIcon, Field); - JS_STATIC_METHOD(buttonImportIcon, Field); - JS_STATIC_METHOD(buttonSetCaption, Field); - JS_STATIC_METHOD(buttonSetIcon, Field); - JS_STATIC_METHOD(checkThisBox, Field); - JS_STATIC_METHOD(clearItems, Field); - JS_STATIC_METHOD(defaultIsChecked, Field); - JS_STATIC_METHOD(deleteItemAt, Field); - JS_STATIC_METHOD(getArray, Field); - JS_STATIC_METHOD(getItemAt, Field); - JS_STATIC_METHOD(getLock, Field); - JS_STATIC_METHOD(insertItemAt, Field); - JS_STATIC_METHOD(isBoxChecked, Field); - JS_STATIC_METHOD(isDefaultChecked, Field); - JS_STATIC_METHOD(setAction, Field); - JS_STATIC_METHOD(setFocus, Field); - JS_STATIC_METHOD(setItems, Field); - JS_STATIC_METHOD(setLock, Field); - JS_STATIC_METHOD(signatureGetModifications, Field); - JS_STATIC_METHOD(signatureGetSeedValue, Field); - JS_STATIC_METHOD(signatureInfo, Field); - JS_STATIC_METHOD(signatureSetSeedValue, Field); - JS_STATIC_METHOD(signatureSign, Field); - JS_STATIC_METHOD(signatureValidate, Field); +class CJS_Field : public CJS_Object { + public: + CJS_Field(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Field(void){}; + + virtual FX_BOOL InitInstance(IFXJS_Context* cc); + + DECLARE_JS_CLASS(CJS_Field); + + JS_STATIC_PROP(alignment, Field); + JS_STATIC_PROP(borderStyle, Field); + JS_STATIC_PROP(buttonAlignX, Field); + JS_STATIC_PROP(buttonAlignY, Field); + JS_STATIC_PROP(buttonFitBounds, Field); + JS_STATIC_PROP(buttonPosition, Field); + JS_STATIC_PROP(buttonScaleHow, Field); + JS_STATIC_PROP(buttonScaleWhen, Field); + JS_STATIC_PROP(calcOrderIndex, Field); + JS_STATIC_PROP(charLimit, Field); + JS_STATIC_PROP(comb, Field); + JS_STATIC_PROP(commitOnSelChange, Field); + JS_STATIC_PROP(currentValueIndices, Field); + JS_STATIC_PROP(defaultStyle, Field); + JS_STATIC_PROP(defaultValue, Field); + JS_STATIC_PROP(doNotScroll, Field); + JS_STATIC_PROP(doNotSpellCheck, Field); + JS_STATIC_PROP(delay, Field); + JS_STATIC_PROP(display, Field); + JS_STATIC_PROP(doc, Field); + JS_STATIC_PROP(editable, Field); + JS_STATIC_PROP(exportValues, Field); + JS_STATIC_PROP(fileSelect, Field); + JS_STATIC_PROP(fillColor, Field); + JS_STATIC_PROP(hidden, Field); + JS_STATIC_PROP(highlight, Field); + JS_STATIC_PROP(lineWidth, Field); + JS_STATIC_PROP(multiline, Field); + JS_STATIC_PROP(multipleSelection, Field); + JS_STATIC_PROP(name, Field); + JS_STATIC_PROP(numItems, Field); + JS_STATIC_PROP(page, Field); + JS_STATIC_PROP(password, Field); + JS_STATIC_PROP(print, Field); + JS_STATIC_PROP(radiosInUnison, Field); + JS_STATIC_PROP(readonly, Field); + JS_STATIC_PROP(rect, Field); + JS_STATIC_PROP(required, Field); + JS_STATIC_PROP(richText, Field); + JS_STATIC_PROP(richValue, Field); + JS_STATIC_PROP(rotation, Field); + JS_STATIC_PROP(strokeColor, Field); + JS_STATIC_PROP(style, Field); + JS_STATIC_PROP(submitName, Field); + JS_STATIC_PROP(textColor, Field); + JS_STATIC_PROP(textFont, Field); + JS_STATIC_PROP(textSize, Field); + JS_STATIC_PROP(type, Field); + JS_STATIC_PROP(userName, Field); + JS_STATIC_PROP(value, Field); + JS_STATIC_PROP(valueAsString, Field); + JS_STATIC_PROP(source, Field); + + JS_STATIC_METHOD(browseForFileToSubmit, Field); + JS_STATIC_METHOD(buttonGetCaption, Field); + JS_STATIC_METHOD(buttonGetIcon, Field); + JS_STATIC_METHOD(buttonImportIcon, Field); + JS_STATIC_METHOD(buttonSetCaption, Field); + JS_STATIC_METHOD(buttonSetIcon, Field); + JS_STATIC_METHOD(checkThisBox, Field); + JS_STATIC_METHOD(clearItems, Field); + JS_STATIC_METHOD(defaultIsChecked, Field); + JS_STATIC_METHOD(deleteItemAt, Field); + JS_STATIC_METHOD(getArray, Field); + JS_STATIC_METHOD(getItemAt, Field); + JS_STATIC_METHOD(getLock, Field); + JS_STATIC_METHOD(insertItemAt, Field); + JS_STATIC_METHOD(isBoxChecked, Field); + JS_STATIC_METHOD(isDefaultChecked, Field); + JS_STATIC_METHOD(setAction, Field); + JS_STATIC_METHOD(setFocus, Field); + JS_STATIC_METHOD(setItems, Field); + JS_STATIC_METHOD(setLock, Field); + JS_STATIC_METHOD(signatureGetModifications, Field); + JS_STATIC_METHOD(signatureGetSeedValue, Field); + JS_STATIC_METHOD(signatureInfo, Field); + JS_STATIC_METHOD(signatureSetSeedValue, Field); + JS_STATIC_METHOD(signatureSign, Field); + JS_STATIC_METHOD(signatureValidate, Field); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_FIELD_H_ diff --git a/fpdfsdk/include/javascript/IJavaScript.h b/fpdfsdk/include/javascript/IJavaScript.h index 783b249ff6..53a4225aed 100644 --- a/fpdfsdk/include/javascript/IJavaScript.h +++ b/fpdfsdk/include/javascript/IJavaScript.h @@ -15,99 +15,155 @@ class CPDF_FormField; class CPDFSDK_Annot; class CPDFSDK_Document; -class IFXJS_Context -{ -public: - virtual ~IFXJS_Context() { } - virtual FX_BOOL Compile(const CFX_WideString& script, CFX_WideString& info) = 0; - virtual FX_BOOL RunScript(const CFX_WideString& script, CFX_WideString& info) = 0; - - virtual void OnApp_Init() = 0; - - virtual void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName) = 0; - virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0; - - virtual void OnPage_Open(CPDFSDK_Document* pTarget) = 0; - virtual void OnPage_Close(CPDFSDK_Document* pTarget) = 0; - virtual void OnPage_InView(CPDFSDK_Document* pTarget) = 0; - virtual void OnPage_OutView(CPDFSDK_Document* pTarget) = 0; - - virtual void OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value) = 0; - virtual void OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value) = 0; - - virtual void OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc) = 0; - virtual void OnField_Format(CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit) = 0; - virtual void OnField_Keystroke(CFX_WideString& strChange, const CFX_WideString& strChangeEx, - FX_BOOL KeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift, - CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, - FX_BOOL bFieldFull, FX_BOOL &bRc) = 0; - virtual void OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, - FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc) = 0; - - virtual void OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - - virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0; - virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0; - - virtual void OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString &) = 0; - virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0; - virtual void OnConsole_Exec() = 0; - virtual void OnExternal_Exec() = 0; - - virtual void EnableMessageBox(FX_BOOL bEnable) = 0; +class IFXJS_Context { + public: + virtual ~IFXJS_Context() {} + virtual FX_BOOL Compile(const CFX_WideString& script, + CFX_WideString& info) = 0; + virtual FX_BOOL RunScript(const CFX_WideString& script, + CFX_WideString& info) = 0; + + virtual void OnApp_Init() = 0; + + virtual void OnDoc_Open(CPDFSDK_Document* pDoc, + const CFX_WideString& strTargetName) = 0; + virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0; + virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0; + virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0; + virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0; + virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0; + + virtual void OnPage_Open(CPDFSDK_Document* pTarget) = 0; + virtual void OnPage_Close(CPDFSDK_Document* pTarget) = 0; + virtual void OnPage_InView(CPDFSDK_Document* pTarget) = 0; + virtual void OnPage_OutView(CPDFSDK_Document* pTarget) = 0; + + virtual void OnField_MouseDown(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget) = 0; + virtual void OnField_MouseEnter(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget) = 0; + virtual void OnField_MouseExit(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget) = 0; + virtual void OnField_MouseUp(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget) = 0; + virtual void OnField_Focus(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + const CFX_WideString& Value) = 0; + virtual void OnField_Blur(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + const CFX_WideString& Value) = 0; + + virtual void OnField_Calculate(CPDF_FormField* pSource, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL& bRc) = 0; + virtual void OnField_Format(CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL bWillCommit) = 0; + virtual void OnField_Keystroke(CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL KeyDown, + FX_BOOL bModifier, + int& nSelEnd, + int& nSelStart, + FX_BOOL bShift, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL bWillCommit, + FX_BOOL bFieldFull, + FX_BOOL& bRc) = 0; + virtual void OnField_Validate(CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL bKeyDown, + FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL& bRc) = 0; + + virtual void OnScreen_Focus(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_Blur(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_Open(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_Close(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_MouseDown(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_MouseUp(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_MouseEnter(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_MouseExit(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_InView(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + virtual void OnScreen_OutView(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen) = 0; + + virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0; + virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0; + + virtual void OnMenu_Exec(CPDFSDK_Document* pTarget, + const CFX_WideString&) = 0; + virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0; + virtual void OnConsole_Exec() = 0; + virtual void OnExternal_Exec() = 0; + + virtual void EnableMessageBox(FX_BOOL bEnable) = 0; }; -class IFXJS_Runtime -{ -public: - virtual IFXJS_Context* NewContext() = 0; - virtual void ReleaseContext(IFXJS_Context * pContext) = 0; - virtual IFXJS_Context* GetCurrentContext() = 0; +class IFXJS_Runtime { + public: + virtual IFXJS_Context* NewContext() = 0; + virtual void ReleaseContext(IFXJS_Context* pContext) = 0; + virtual IFXJS_Context* GetCurrentContext() = 0; - virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; - virtual CPDFSDK_Document* GetReaderDocument() = 0; + virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; + virtual CPDFSDK_Document* GetReaderDocument() = 0; -protected: - ~IFXJS_Runtime() { } + protected: + ~IFXJS_Runtime() {} }; class CPDFDoc_Environment; class CJS_GlobalData; -class CJS_RuntimeFactory -{ -public: - CJS_RuntimeFactory():m_bInit(FALSE),m_nRef(0),m_pGlobalData(NULL),m_nGlobalDataCount(0) {} - ~CJS_RuntimeFactory(); - IFXJS_Runtime* NewJSRuntime(CPDFDoc_Environment* pApp); - void DeleteJSRuntime(IFXJS_Runtime* pRuntime); - void AddRef(); - void Release(); - - CJS_GlobalData* NewGlobalData(CPDFDoc_Environment* pApp); - void ReleaseGlobalData(); -private: - FX_BOOL m_bInit; - int m_nRef; - CJS_GlobalData* m_pGlobalData; - int32_t m_nGlobalDataCount; +class CJS_RuntimeFactory { + public: + CJS_RuntimeFactory() + : m_bInit(FALSE), m_nRef(0), m_pGlobalData(NULL), m_nGlobalDataCount(0) {} + ~CJS_RuntimeFactory(); + IFXJS_Runtime* NewJSRuntime(CPDFDoc_Environment* pApp); + void DeleteJSRuntime(IFXJS_Runtime* pRuntime); + void AddRef(); + void Release(); + + CJS_GlobalData* NewGlobalData(CPDFDoc_Environment* pApp); + void ReleaseGlobalData(); + + private: + FX_BOOL m_bInit; + int m_nRef; + CJS_GlobalData* m_pGlobalData; + int32_t m_nGlobalDataCount; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ diff --git a/fpdfsdk/include/javascript/Icon.h b/fpdfsdk/include/javascript/Icon.h index 0298005f00..0b549ec613 100644 --- a/fpdfsdk/include/javascript/Icon.h +++ b/fpdfsdk/include/javascript/Icon.h @@ -9,32 +9,30 @@ #include "JS_Define.h" -class Icon : public CJS_EmbedObj -{ -public: - Icon(CJS_Object* pJSObject); - virtual ~Icon(); - FX_BOOL name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - void SetStream(CPDF_Stream* pIconStream); - CPDF_Stream* GetStream(); - void SetIconName(CFX_WideString name); - CFX_WideString GetIconName(); - -private: - CPDF_Stream* m_pIconStream; - CFX_WideString m_swIconName; +class Icon : public CJS_EmbedObj { + public: + Icon(CJS_Object* pJSObject); + virtual ~Icon(); + FX_BOOL name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + void SetStream(CPDF_Stream* pIconStream); + CPDF_Stream* GetStream(); + void SetIconName(CFX_WideString name); + CFX_WideString GetIconName(); + + private: + CPDF_Stream* m_pIconStream; + CFX_WideString m_swIconName; }; -class CJS_Icon : public CJS_Object -{ -public: - CJS_Icon(JSFXObject pObject) : CJS_Object(pObject){}; - virtual ~CJS_Icon(){}; +class CJS_Icon : public CJS_Object { + public: + CJS_Icon(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Icon(){}; -public: - DECLARE_JS_CLASS(CJS_Icon); + public: + DECLARE_JS_CLASS(CJS_Icon); - JS_STATIC_PROP(name, Icon); + JS_STATIC_PROP(name, Icon); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_ICON_H_ diff --git a/fpdfsdk/include/javascript/JS_Context.h b/fpdfsdk/include/javascript/JS_Context.h index 2e2cf37a5e..f61f37cdc6 100644 --- a/fpdfsdk/include/javascript/JS_Context.h +++ b/fpdfsdk/include/javascript/JS_Context.h @@ -14,84 +14,138 @@ class CJS_EventHandler; class CJS_Runtime; -class CJS_Context : public IFXJS_Context -{ -public: - CJS_Context(CJS_Runtime* pRuntime); - virtual ~CJS_Context(); - -public: - virtual FX_BOOL Compile(const CFX_WideString& script, CFX_WideString& info); - virtual FX_BOOL RunScript(const CFX_WideString& script, CFX_WideString& info); - -public: - virtual void OnApp_Init(); - - virtual void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName); - virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc); - virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc); - virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc); - virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc); - virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc); - - virtual void OnPage_Open(CPDFSDK_Document* pTarget); - virtual void OnPage_Close(CPDFSDK_Document* pTarget); - virtual void OnPage_InView(CPDFSDK_Document* pTarget); - virtual void OnPage_OutView(CPDFSDK_Document* pTarget); - - virtual void OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - virtual void OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - - virtual void OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - virtual void OnField_Format(CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit); - virtual void OnField_Keystroke(CFX_WideString& strChange, const CFX_WideString& strChangeEx, - FX_BOOL bKeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift, - CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, - FX_BOOL bFieldFull, FX_BOOL &bRc); - virtual void OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, - FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - - virtual void OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - - virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark); - virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget); - - virtual void OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName); - virtual void OnBatchExec(CPDFSDK_Document* pTarget); - virtual void OnConsole_Exec(); - virtual void OnExternal_Exec(); - - virtual void EnableMessageBox(FX_BOOL bEnable) {m_bMsgBoxEnable = bEnable;} - FX_BOOL IsMsgBoxEnabled() const {return m_bMsgBoxEnable;} - -public: - CPDFDoc_Environment* GetReaderApp(); - CJS_Runtime* GetJSRuntime(){return m_pRuntime;} - - FX_BOOL DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info); - - CJS_EventHandler* GetEventHandler(){return m_pEventHandler;}; - CPDFSDK_Document* GetReaderDocument(); - -private: - CJS_Runtime* m_pRuntime; - CJS_EventHandler* m_pEventHandler; - - FX_BOOL m_bBusy; - FX_BOOL m_bMsgBoxEnable; +class CJS_Context : public IFXJS_Context { + public: + CJS_Context(CJS_Runtime* pRuntime); + virtual ~CJS_Context(); + + public: + virtual FX_BOOL Compile(const CFX_WideString& script, CFX_WideString& info); + virtual FX_BOOL RunScript(const CFX_WideString& script, CFX_WideString& info); + + public: + virtual void OnApp_Init(); + + virtual void OnDoc_Open(CPDFSDK_Document* pDoc, + const CFX_WideString& strTargetName); + virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc); + virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc); + virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc); + virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc); + virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc); + + virtual void OnPage_Open(CPDFSDK_Document* pTarget); + virtual void OnPage_Close(CPDFSDK_Document* pTarget); + virtual void OnPage_InView(CPDFSDK_Document* pTarget); + virtual void OnPage_OutView(CPDFSDK_Document* pTarget); + + virtual void OnField_MouseDown(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + virtual void OnField_MouseEnter(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + virtual void OnField_MouseExit(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + virtual void OnField_MouseUp(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + virtual void OnField_Focus(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + const CFX_WideString& Value); + virtual void OnField_Blur(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + const CFX_WideString& Value); + + virtual void OnField_Calculate(CPDF_FormField* pSource, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL& bRc); + virtual void OnField_Format(CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL bWillCommit); + virtual void OnField_Keystroke(CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL bKeyDown, + FX_BOOL bModifier, + int& nSelEnd, + int& nSelStart, + FX_BOOL bShift, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL bWillCommit, + FX_BOOL bFieldFull, + FX_BOOL& bRc); + virtual void OnField_Validate(CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL bKeyDown, + FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL& bRc); + + virtual void OnScreen_Focus(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_Blur(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_Open(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_Close(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_MouseDown(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_MouseUp(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_MouseEnter(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_MouseExit(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_InView(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + virtual void OnScreen_OutView(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + + virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark); + virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget); + + virtual void OnMenu_Exec(CPDFSDK_Document* pTarget, + const CFX_WideString& strTargetName); + virtual void OnBatchExec(CPDFSDK_Document* pTarget); + virtual void OnConsole_Exec(); + virtual void OnExternal_Exec(); + + virtual void EnableMessageBox(FX_BOOL bEnable) { m_bMsgBoxEnable = bEnable; } + FX_BOOL IsMsgBoxEnabled() const { return m_bMsgBoxEnable; } + + public: + CPDFDoc_Environment* GetReaderApp(); + CJS_Runtime* GetJSRuntime() { return m_pRuntime; } + + FX_BOOL DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info); + + CJS_EventHandler* GetEventHandler() { return m_pEventHandler; }; + CPDFSDK_Document* GetReaderDocument(); + + private: + CJS_Runtime* m_pRuntime; + CJS_EventHandler* m_pEventHandler; + + FX_BOOL m_bBusy; + FX_BOOL m_bMsgBoxEnable; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_CONTEXT_H_ diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index f1b36bf3d0..0c020b6734 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -12,46 +12,70 @@ #include "JS_Object.h" #include "JS_Value.h" -struct JSConstSpec -{ - const wchar_t* pName; - double number; - const wchar_t* string; - uint8_t t; //0:double 1:str +struct JSConstSpec { + const wchar_t* pName; + double number; + const wchar_t* string; + uint8_t t; // 0:double 1:str }; -struct JSPropertySpec -{ - const wchar_t* pName; - v8::AccessorGetterCallback pPropGet; - v8::AccessorSetterCallback pPropPut; +struct JSPropertySpec { + const wchar_t* pName; + v8::AccessorGetterCallback pPropGet; + v8::AccessorSetterCallback pPropPut; }; -struct JSMethodSpec -{ - const wchar_t* pName; - v8::FunctionCallback pMethodCall; +struct JSMethodSpec { + const wchar_t* pName; + v8::FunctionCallback pMethodCall; }; -/* ====================================== PUBLIC DEFINE SPEC ============================================== */ -#define JS_WIDESTRING(widestring) L###widestring - -#define BEGIN_JS_STATIC_CONST(js_class_name) JSConstSpec js_class_name::JS_Class_Consts[] = { -#define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) {JS_WIDESTRING(const_name), pValue, L"", 0}, -#define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) {JS_WIDESTRING(const_name), 0, JS_WIDESTRING(pValue), 1}, -#define END_JS_STATIC_CONST() {0, 0, 0, 0}}; - -#define BEGIN_JS_STATIC_PROP(js_class_name) JSPropertySpec js_class_name::JS_Class_Properties[] = { -#define JS_STATIC_PROP_ENTRY(prop_name) {JS_WIDESTRING(prop_name), get_##prop_name##_static, set_##prop_name##_static}, -#define END_JS_STATIC_PROP() {0, 0, 0}}; - -#define BEGIN_JS_STATIC_METHOD(js_class_name) JSMethodSpec js_class_name::JS_Class_Methods[] = { -#define JS_STATIC_METHOD_ENTRY(method_name) {JS_WIDESTRING(method_name), method_name##_static}, -#define END_JS_STATIC_METHOD() {0, 0}}; - -/* ======================================== PROP CALLBACK ============================================ */ - -template +/* ====================================== PUBLIC DEFINE SPEC + * ============================================== */ +#define JS_WIDESTRING(widestring) L## #widestring + +#define BEGIN_JS_STATIC_CONST(js_class_name) \ + JSConstSpec js_class_name::JS_Class_Consts[] = { +#define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) \ + { JS_WIDESTRING(const_name), pValue, L"", 0 } \ + , +#define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) \ + { JS_WIDESTRING(const_name), 0, JS_WIDESTRING(pValue), 1 } \ + , +#define END_JS_STATIC_CONST() \ + { 0, 0, 0, 0 } \ + } \ + ; + +#define BEGIN_JS_STATIC_PROP(js_class_name) \ + JSPropertySpec js_class_name::JS_Class_Properties[] = { +#define JS_STATIC_PROP_ENTRY(prop_name) \ + { \ + JS_WIDESTRING(prop_name), get_##prop_name##_static, set_##prop_name##_static \ + } \ + , +#define END_JS_STATIC_PROP() \ + { 0, 0, 0 } \ + } \ + ; + +#define BEGIN_JS_STATIC_METHOD(js_class_name) \ + JSMethodSpec js_class_name::JS_Class_Methods[] = { +#define JS_STATIC_METHOD_ENTRY(method_name) \ + { JS_WIDESTRING(method_name), method_name##_static } \ + , +#define END_JS_STATIC_METHOD() \ + { 0, 0 } \ + } \ + ; + +/* ======================================== PROP CALLBACK + * ============================================ */ + +template void JSPropGetter(const char* prop_name_string, const char* class_name_string, v8::Local property, @@ -62,19 +86,23 @@ void JSPropGetter(const char* prop_name_string, v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pContext = pRuntime->GetCurrentContext(); - CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder()); + CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast(pJSObj->GetEmbedObject()); CFX_WideString sError; CJS_PropValue value(isolate); value.StartGetting(); if (!(pObj->*M)(pContext, value, sError)) { - JS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError)); + JS_Error(isolate, + JSFormatErrorString(class_name_string, prop_name_string, sError)); return; } info.GetReturnValue().Set((v8::Local)value); } -template +template void JSPropSetter(const char* prop_name_string, const char* class_name_string, v8::Local property, @@ -86,34 +114,39 @@ void JSPropSetter(const char* prop_name_string, v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pContext = pRuntime->GetCurrentContext(); - CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder()); + CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast(pJSObj->GetEmbedObject()); CFX_WideString sError; CJS_PropValue propValue(CJS_Value(isolate, value, VT_unknown)); propValue.StartSetting(); if (!(pObj->*M)(pContext, propValue, sError)) { - JS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError)); + JS_Error(isolate, + JSFormatErrorString(class_name_string, prop_name_string, sError)); } } -#define JS_STATIC_PROP(prop_name, class_name) \ - static void get_##prop_name##_static( \ - v8::Local property, \ - const v8::PropertyCallbackInfo& info) { \ - JSPropGetter( \ - #prop_name, #class_name, property, info); \ - } \ - static void set_##prop_name##_static( \ - v8::Local property, \ - v8::Local value, \ - const v8::PropertyCallbackInfo& info) { \ - JSPropSetter( \ - #prop_name, #class_name, property, value, info); \ +#define JS_STATIC_PROP(prop_name, class_name) \ + static void get_##prop_name##_static( \ + v8::Local property, \ + const v8::PropertyCallbackInfo& info) { \ + JSPropGetter(#prop_name, #class_name, \ + property, info); \ + } \ + static void set_##prop_name##_static( \ + v8::Local property, v8::Local value, \ + const v8::PropertyCallbackInfo& info) { \ + JSPropSetter(#prop_name, #class_name, \ + property, value, info); \ } -/* ========================================= METHOD CALLBACK =========================================== */ +/* ========================================= METHOD CALLBACK + * =========================================== */ -template +template void JSMethod(const char* method_name_string, const char* class_name_string, const v8::FunctionCallbackInfo& info) { @@ -124,121 +157,140 @@ void JSMethod(const char* method_name_string, IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; - for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { + for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); } CJS_Value valueRes(isolate); - CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); + CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast(pJSObj->GetEmbedObject()); CFX_WideString sError; if (!(pObj->*M)(cc, parameters, valueRes, sError)) { - JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string, sError)); + JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string, + sError)); return; } info.GetReturnValue().Set(valueRes.ToV8Value()); } -#define JS_STATIC_METHOD(method_name, class_name) \ - static void method_name##_static( \ - const v8::FunctionCallbackInfo& info) { \ - JSMethod( \ - #method_name, #class_name, info); \ +#define JS_STATIC_METHOD(method_name, class_name) \ + static void method_name##_static( \ + const v8::FunctionCallbackInfo& info) { \ + JSMethod(#method_name, #class_name, \ + info); \ } #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ - static void method_name##_static( \ - const v8::FunctionCallbackInfo& info) { \ - JSMethod( \ - #method_name, #class_name, info); \ + static void method_name##_static( \ + const v8::FunctionCallbackInfo& info) { \ + JSMethod( \ + #method_name, #class_name, info); \ } -/* ===================================== JS CLASS =============================================== */ - -#define DECLARE_JS_CLASS(js_class_name) \ - static void JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject global);\ - static void JSDestructor(JSFXObject obj);\ - static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ - static JSConstSpec JS_Class_Consts[];\ - static JSPropertySpec JS_Class_Properties[];\ - static JSMethodSpec JS_Class_Methods[];\ - static const wchar_t* m_pClassName - -#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ -const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ -void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObject global)\ -{\ - CJS_Object* pObj = new js_class_name(obj);\ - pObj->SetEmbedObject(new class_alternate(pObj));\ - JS_SetPrivate(NULL,obj,(void*)pObj); \ - pObj->InitInstance(cc);\ -}\ -\ -void js_class_name::JSDestructor(JSFXObject obj) \ -{\ - js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ - ASSERT(pObj != NULL);\ - pObj->ExitInstance();\ - delete pObj;\ -}\ -\ -int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\ -{\ - int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, JSConstructor, JSDestructor);\ - if (nObjDefnID >= 0)\ - {\ - for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertySpec)-1; jSetEmbedObject(new class_alternate(pObj)); \ + JS_SetPrivate(NULL, obj, (void*)pObj); \ + pObj->InitInstance(cc); \ + } \ + \ + void js_class_name::JSDestructor(JSFXObject obj) { \ + js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ + ASSERT(pObj != NULL); \ + pObj->ExitInstance(); \ + delete pObj; \ + } \ + \ + int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType) { \ + int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, \ + eObjType, JSConstructor, JSDestructor); \ + if (nObjDefnID >= 0) { \ + for (int j = 0, \ + szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \ + j < szj; j++) { \ + if (JS_DefineObjProperty(pRuntime, nObjDefnID, \ + JS_Class_Properties[j].pName, \ + JS_Class_Properties[j].pPropGet, \ + JS_Class_Properties[j].pPropPut) < 0) \ + return -1; \ + } \ + for (int k = 0, \ + szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \ + k < szk; k++) { \ + if (JS_DefineObjMethod(pRuntime, nObjDefnID, \ + JS_Class_Methods[k].pName, \ + JS_Class_Methods[k].pMethodCall) < 0) \ + return -1; \ + } \ + return nObjDefnID; \ + } \ + return -1; \ + } -#define IMPLEMENT_JS_CLASS(js_class_name, class_name) IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name) - -/* ======================================== CONST CLASS ============================================ */ - -#define DECLARE_JS_CLASS_CONST() \ - static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ - static JSConstSpec JS_Class_Consts[];\ - static const wchar_t* m_pClassName - -#define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \ -const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ -int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\ -{\ - int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, NULL, NULL);\ - if (nObjDefnID >=0)\ - {\ - for (int i=0, sz=sizeof(JS_Class_Consts)/sizeof(JSConstSpec)-1; i= 0) { \ + for (int i = 0, sz = sizeof(JS_Class_Consts) / sizeof(JSConstSpec) - 1; \ + i < sz; i++) { \ + if (JS_Class_Consts[i].t == 0) { \ + if (JS_DefineObjConst( \ + pRuntime, nObjDefnID, JS_Class_Consts[i].pName, \ + JS_NewNumber(pRuntime, JS_Class_Consts[i].number)) < 0) \ + return -1; \ + } else { \ + if (JS_DefineObjConst( \ + pRuntime, nObjDefnID, JS_Class_Consts[i].pName, \ + JS_NewString(pRuntime, JS_Class_Consts[i].string)) < 0) \ + return -1; \ + } \ + } \ + return nObjDefnID; \ + } \ + return -1; \ + } -/* ===================================== SPECIAL JS CLASS =============================================== */ +/* ===================================== SPECIAL JS CLASS + * =============================================== */ template -void JSSpecialPropQuery(const char *, v8::Local property,const v8::PropertyCallbackInfo& info) { +void JSSpecialPropQuery(const char*, + v8::Local property, + const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); v8::String::Utf8Value utf8_value(property); - CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); - CJS_Object* pJSObj = reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); + CFX_WideString propname = + CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); + CJS_Object* pJSObj = + reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); Alt* pObj = reinterpret_cast(pJSObj->GetEmbedObject()); FX_BOOL bRet = pObj->QueryProperty(propname.c_str()); info.GetReturnValue().Set(bRet ? 4 : 0); @@ -254,16 +306,18 @@ void JSSpecialPropGet(const char* class_name, v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); - CJS_Object* pJSObj = reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); + CJS_Object* pJSObj = + reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); Alt* pObj = reinterpret_cast(pJSObj->GetEmbedObject()); v8::String::Utf8Value utf8_value(property); - CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); + CFX_WideString propname = + CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); CFX_WideString sError; CJS_PropValue value(isolate); value.StartGetting(); if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) { - JS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError)); - return; + JS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError)); + return; } info.GetReturnValue().Set((v8::Local)value); } @@ -279,15 +333,17 @@ void JSSpecialPropPut(const char* class_name, v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); - CJS_Object* pJSObj = reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); + CJS_Object* pJSObj = + reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); Alt* pObj = reinterpret_cast(pJSObj->GetEmbedObject()); v8::String::Utf8Value utf8_value(property); - CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); + CFX_WideString propname = + CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); CFX_WideString sError; - CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown)); + CJS_PropValue PropValue(CJS_Value(isolate, value, VT_unknown)); PropValue.StartSetting(); if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) { - JS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError)); + JS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError)); } } @@ -301,10 +357,12 @@ void JSSpecialPropDel(const char* class_name, v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); - CJS_Object* pJSObj = reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); + CJS_Object* pJSObj = + reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); Alt* pObj = reinterpret_cast(pJSObj->GetEmbedObject()); v8::String::Utf8Value utf8_value(property); - CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); + CFX_WideString propname = + CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); CFX_WideString sError; if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { CFX_ByteString cbName; @@ -313,77 +371,110 @@ void JSSpecialPropDel(const char* class_name, } } -#define DECLARE_SPECIAL_JS_CLASS(js_class_name) \ - static void JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObject global);\ - static void JSDestructor(JSFXObject obj);\ - static JSConstSpec JS_Class_Consts[];\ - static JSPropertySpec JS_Class_Properties[];\ - static JSMethodSpec JS_Class_Methods[];\ - static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ - static const wchar_t* m_pClassName;\ - static void queryprop_##js_class_name##_static(v8::Local property,const v8::PropertyCallbackInfo& info);\ - static void getprop_##js_class_name##_static(v8::Local property, const v8::PropertyCallbackInfo& info);\ - static void putprop_##js_class_name##_static(v8::Local property,v8::Local value,const v8::PropertyCallbackInfo& info);\ - static void delprop_##js_class_name##_static(v8::Local property,const v8::PropertyCallbackInfo& info) +#define DECLARE_SPECIAL_JS_CLASS(js_class_name) \ + static void JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ + JSFXObject global); \ + static void JSDestructor(JSFXObject obj); \ + static JSConstSpec JS_Class_Consts[]; \ + static JSPropertySpec JS_Class_Properties[]; \ + static JSMethodSpec JS_Class_Methods[]; \ + static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType); \ + static const wchar_t* m_pClassName; \ + static void queryprop_##js_class_name##_static( \ + v8::Local property, \ + const v8::PropertyCallbackInfo& info); \ + static void getprop_##js_class_name##_static( \ + v8::Local property, \ + const v8::PropertyCallbackInfo& info); \ + static void putprop_##js_class_name##_static( \ + v8::Local property, v8::Local value, \ + const v8::PropertyCallbackInfo& info); \ + static void delprop_##js_class_name##_static( \ + v8::Local property, \ + const v8::PropertyCallbackInfo& info) #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \ -const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ -void js_class_name::queryprop_##js_class_name##_static(v8::Local property,const v8::PropertyCallbackInfo& info) { \ - JSSpecialPropQuery(#class_name, property, info); \ -}\ -void js_class_name::getprop_##js_class_name##_static(v8::Local property, const v8::PropertyCallbackInfo& info) { \ - JSSpecialPropGet(#class_name, property, info); \ -} \ -void js_class_name::putprop_##js_class_name##_static(v8::Local property,v8::Local value,const v8::PropertyCallbackInfo& info) {\ - JSSpecialPropPut(#class_name, property, value, info); \ -}\ -void js_class_name::delprop_##js_class_name##_static(v8::Local property,const v8::PropertyCallbackInfo& info) { \ - JSSpecialPropDel(#class_name, property, info); \ -} \ -void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject global)\ -{\ - CJS_Object* pObj = new js_class_name(obj);\ - pObj->SetEmbedObject(new class_alternate(pObj));\ - JS_SetPrivate(NULL,obj, (void*)pObj); \ - pObj->InitInstance(cc);\ -}\ -\ -void js_class_name::JSDestructor(JSFXObject obj) \ -{\ - js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ - ASSERT(pObj != NULL);\ - pObj->ExitInstance();\ - delete pObj;\ -}\ -\ -int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\ -{\ -\ - int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, JSConstructor, JSDestructor);\ -\ - if (nObjDefnID >= 0)\ - {\ - for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertySpec)-1; j property, \ + const v8::PropertyCallbackInfo& info) { \ + JSSpecialPropQuery(#class_name, property, info); \ + } \ + void js_class_name::getprop_##js_class_name##_static( \ + v8::Local property, \ + const v8::PropertyCallbackInfo& info) { \ + JSSpecialPropGet(#class_name, property, info); \ + } \ + void js_class_name::putprop_##js_class_name##_static( \ + v8::Local property, v8::Local value, \ + const v8::PropertyCallbackInfo& info) { \ + JSSpecialPropPut(#class_name, property, value, info); \ + } \ + void js_class_name::delprop_##js_class_name##_static( \ + v8::Local property, \ + const v8::PropertyCallbackInfo& info) { \ + JSSpecialPropDel(#class_name, property, info); \ + } \ + void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ + JSFXObject global) { \ + CJS_Object* pObj = new js_class_name(obj); \ + pObj->SetEmbedObject(new class_alternate(pObj)); \ + JS_SetPrivate(NULL, obj, (void*)pObj); \ + pObj->InitInstance(cc); \ + } \ + \ + void js_class_name::JSDestructor(JSFXObject obj) { \ + js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ + ASSERT(pObj != NULL); \ + pObj->ExitInstance(); \ + delete pObj; \ + } \ + \ + int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType) { \ + int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, \ + eObjType, JSConstructor, JSDestructor); \ + \ + if (nObjDefnID >= 0) { \ + for (int j = 0, \ + szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \ + j < szj; j++) { \ + if (JS_DefineObjProperty(pRuntime, nObjDefnID, \ + JS_Class_Properties[j].pName, \ + JS_Class_Properties[j].pPropGet, \ + JS_Class_Properties[j].pPropPut) < 0) \ + return -1; \ + } \ + \ + for (int k = 0, \ + szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \ + k < szk; k++) { \ + if (JS_DefineObjMethod(pRuntime, nObjDefnID, \ + JS_Class_Methods[k].pName, \ + JS_Class_Methods[k].pMethodCall) < 0) \ + return -1; \ + } \ + if (JS_DefineObjAllProperties( \ + pRuntime, nObjDefnID, \ + js_class_name::queryprop_##js_class_name##_static, \ + js_class_name::getprop_##js_class_name##_static, \ + js_class_name::putprop_##js_class_name##_static, \ + js_class_name::delprop_##js_class_name##_static) < 0) \ + return -1; \ + \ + return nObjDefnID; \ + } \ + \ + return -1; \ + } -/* ======================================== GLOBAL METHODS ============================================ */ +/* ======================================== GLOBAL METHODS + * ============================================ */ -template -void JSGlobalFunc(const char *func_name_string, +template +void JSGlobalFunc(const char* func_name_string, const v8::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); @@ -392,76 +483,83 @@ void JSGlobalFunc(const char *func_name_string, IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; - for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { + for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); } CJS_Value valueRes(isolate); CFX_WideString sError; - if (!(*F)(cc, parameters, valueRes, sError)) - { - JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); + if (!(*F)(cc, parameters, valueRes, sError)) { + JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); return; } info.GetReturnValue().Set(valueRes.ToV8Value()); } -#define JS_STATIC_GLOBAL_FUN(fun_name) \ - static void fun_name##_static(const v8::FunctionCallbackInfo& info) { \ - JSGlobalFunc(#fun_name, info); \ +#define JS_STATIC_GLOBAL_FUN(fun_name) \ + static void fun_name##_static( \ + const v8::FunctionCallbackInfo& info) { \ + JSGlobalFunc(#fun_name, info); \ } -#define JS_STATIC_DECLARE_GLOBAL_FUN() \ -static JSMethodSpec global_methods[]; \ -static int Init(IJS_Runtime* pRuntime) +#define JS_STATIC_DECLARE_GLOBAL_FUN() \ + static JSMethodSpec global_methods[]; \ + static int Init(IJS_Runtime* pRuntime) #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \ -JSMethodSpec js_class_name::global_methods[] = { - -#define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) JS_STATIC_METHOD_ENTRY(method_name) + JSMethodSpec js_class_name::global_methods[] = { +#define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) \ + JS_STATIC_METHOD_ENTRY(method_name) #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD() -#define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ -int js_class_name::Init(IJS_Runtime* pRuntime)\ -{\ - for (int i=0, sz=sizeof(js_class_name::global_methods)/sizeof(JSMethodSpec)-1; i p); diff --git a/fpdfsdk/include/javascript/JS_EventHandler.h b/fpdfsdk/include/javascript/JS_EventHandler.h index 62afb829e7..5e4982c1df 100644 --- a/fpdfsdk/include/javascript/JS_EventHandler.h +++ b/fpdfsdk/include/javascript/JS_EventHandler.h @@ -17,157 +17,204 @@ class CPDF_Bookmark; class CPDF_FormField; class Field; -enum JS_EVENT_T -{ - JET_UNKNOWN, - JET_APP_INIT, - JET_DOC_OPEN, - JET_DOC_WILLPRINT, - JET_DOC_DIDPRINT, - JET_DOC_WILLSAVE, - JET_DOC_DIDSAVE, - JET_DOC_WILLCLOSE, - JET_PAGE_OPEN, - JET_PAGE_CLOSE, - JET_PAGE_INVIEW, - JET_PAGE_OUTVIEW, - JET_FIELD_MOUSEDOWN, - JET_FIELD_MOUSEUP, - JET_FIELD_MOUSEENTER, - JET_FIELD_MOUSEEXIT, - JET_FIELD_FOCUS, - JET_FIELD_BLUR, - JET_FIELD_KEYSTROKE, - JET_FIELD_VALIDATE, - JET_FIELD_CALCULATE, - JET_FIELD_FORMAT, - JET_SCREEN_FOCUS, - JET_SCREEN_BLUR, - JET_SCREEN_OPEN, - JET_SCREEN_CLOSE, - JET_SCREEN_MOUSEDOWN, - JET_SCREEN_MOUSEUP, - JET_SCREEN_MOUSEENTER, - JET_SCREEN_MOUSEEXIT, - JET_SCREEN_INVIEW, - JET_SCREEN_OUTVIEW, - JET_BATCH_EXEC, - JET_MENU_EXEC, - JET_CONSOLE_EXEC, - JET_EXTERNAL_EXEC, - JET_BOOKMARK_MOUSEUP, - JET_LINK_MOUSEUP +enum JS_EVENT_T { + JET_UNKNOWN, + JET_APP_INIT, + JET_DOC_OPEN, + JET_DOC_WILLPRINT, + JET_DOC_DIDPRINT, + JET_DOC_WILLSAVE, + JET_DOC_DIDSAVE, + JET_DOC_WILLCLOSE, + JET_PAGE_OPEN, + JET_PAGE_CLOSE, + JET_PAGE_INVIEW, + JET_PAGE_OUTVIEW, + JET_FIELD_MOUSEDOWN, + JET_FIELD_MOUSEUP, + JET_FIELD_MOUSEENTER, + JET_FIELD_MOUSEEXIT, + JET_FIELD_FOCUS, + JET_FIELD_BLUR, + JET_FIELD_KEYSTROKE, + JET_FIELD_VALIDATE, + JET_FIELD_CALCULATE, + JET_FIELD_FORMAT, + JET_SCREEN_FOCUS, + JET_SCREEN_BLUR, + JET_SCREEN_OPEN, + JET_SCREEN_CLOSE, + JET_SCREEN_MOUSEDOWN, + JET_SCREEN_MOUSEUP, + JET_SCREEN_MOUSEENTER, + JET_SCREEN_MOUSEEXIT, + JET_SCREEN_INVIEW, + JET_SCREEN_OUTVIEW, + JET_BATCH_EXEC, + JET_MENU_EXEC, + JET_CONSOLE_EXEC, + JET_EXTERNAL_EXEC, + JET_BOOKMARK_MOUSEUP, + JET_LINK_MOUSEUP }; -class CJS_EventHandler -{ -public: - CJS_EventHandler(CJS_Context * pContext); - virtual ~CJS_EventHandler(); - - void OnApp_Init(); - - void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName); - void OnDoc_WillPrint(CPDFSDK_Document* pDoc); - void OnDoc_DidPrint(CPDFSDK_Document* pDoc); - void OnDoc_WillSave(CPDFSDK_Document* pDoc); - void OnDoc_DidSave(CPDFSDK_Document* pDoc); - void OnDoc_WillClose(CPDFSDK_Document* pDoc); - - void OnPage_Open(CPDFSDK_Document* pDoc); - void OnPage_Close(CPDFSDK_Document* pDoc); - void OnPage_InView(CPDFSDK_Document* pTarget); - void OnPage_OutView(CPDFSDK_Document* pTarget); - - void OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - void OnField_Format(CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit); - void OnField_Keystroke(CFX_WideString& strChange, const CFX_WideString& strChangeEx, - FX_BOOL KeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift, - CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, - FX_BOOL bFieldFull, FX_BOOL &bRc); - void OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, - FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - - void OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - void OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - - void OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - - void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark); - void OnLink_MouseUp(CPDFSDK_Document* pTarget); - - void OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName); - void OnBatchExec(CPDFSDK_Document *pTarget); - void OnConsole_Exec(); - void OnExternal_Exec(); - -public: - void Initial(JS_EVENT_T type); - void Destroy(); - FX_BOOL IsValid(); - - - CFX_WideString& Change(); - CFX_WideString ChangeEx(); - int CommitKey(); - FX_BOOL FieldFull(); - FX_BOOL KeyDown(); - FX_BOOL Modifier(); - const FX_WCHAR* Name(); - const FX_WCHAR* Type(); - FX_BOOL& Rc(); - int& SelEnd(); - int& SelStart(); - FX_BOOL Shift(); - Field* Source(); - Field* Target_Field(); - CFX_WideString& Value(); - FX_BOOL WillCommit(); - CFX_WideString TargetName(); - - JS_EVENT_T EventType() {return m_eEventType;}; - -public: - CJS_Context* m_pJSContext; - JS_EVENT_T m_eEventType; - FX_BOOL m_bValid; - - CFX_WideString m_strTargetName; - CFX_WideString m_strSourceName; - CFX_WideString* m_pWideStrChange; - CFX_WideString m_WideStrChangeDu; - CFX_WideString m_WideStrChangeEx; - int m_nCommitKey; - FX_BOOL m_bKeyDown; - FX_BOOL m_bModifier; - FX_BOOL m_bShift; - int* m_pISelEnd; - int m_nSelEndDu; - int* m_pISelStart; - int m_nSelStartDu; - FX_BOOL m_bWillCommit; - CFX_WideString* m_pValue; - FX_BOOL m_bFieldFull; - FX_BOOL* m_pbRc; - FX_BOOL m_bRcDu; - - CPDFSDK_Document* m_pSourceDoc; - CPDF_Bookmark* m_pTargetBookMark; - CPDFSDK_Document* m_pTargetDoc; - CPDFSDK_Annot* m_pTargetAnnot; +class CJS_EventHandler { + public: + CJS_EventHandler(CJS_Context* pContext); + virtual ~CJS_EventHandler(); + + void OnApp_Init(); + + void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName); + void OnDoc_WillPrint(CPDFSDK_Document* pDoc); + void OnDoc_DidPrint(CPDFSDK_Document* pDoc); + void OnDoc_WillSave(CPDFSDK_Document* pDoc); + void OnDoc_DidSave(CPDFSDK_Document* pDoc); + void OnDoc_WillClose(CPDFSDK_Document* pDoc); + + void OnPage_Open(CPDFSDK_Document* pDoc); + void OnPage_Close(CPDFSDK_Document* pDoc); + void OnPage_InView(CPDFSDK_Document* pTarget); + void OnPage_OutView(CPDFSDK_Document* pTarget); + + void OnField_Calculate(CPDF_FormField* pSource, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL& bRc); + void OnField_Format(CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL bWillCommit); + void OnField_Keystroke(CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL KeyDown, + FX_BOOL bModifier, + int& nSelEnd, + int& nSelStart, + FX_BOOL bShift, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL bWillCommit, + FX_BOOL bFieldFull, + FX_BOOL& bRc); + void OnField_Validate(CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + FX_BOOL bKeyDown, + FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + CFX_WideString& Value, + FX_BOOL& bRc); + + void OnField_MouseDown(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + void OnField_MouseEnter(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + void OnField_MouseExit(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + void OnField_MouseUp(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget); + void OnField_Blur(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + const CFX_WideString& Value); + void OnField_Focus(FX_BOOL bModifier, + FX_BOOL bShift, + CPDF_FormField* pTarget, + const CFX_WideString& Value); + + void OnScreen_Focus(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + void OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); + void OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); + void OnScreen_Close(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + void OnScreen_MouseDown(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + void OnScreen_MouseUp(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + void OnScreen_MouseEnter(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + void OnScreen_MouseExit(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + void OnScreen_InView(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + void OnScreen_OutView(FX_BOOL bModifier, + FX_BOOL bShift, + CPDFSDK_Annot* pScreen); + + void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark); + void OnLink_MouseUp(CPDFSDK_Document* pTarget); + + void OnMenu_Exec(CPDFSDK_Document* pTarget, + const CFX_WideString& strTargetName); + void OnBatchExec(CPDFSDK_Document* pTarget); + void OnConsole_Exec(); + void OnExternal_Exec(); + + public: + void Initial(JS_EVENT_T type); + void Destroy(); + FX_BOOL IsValid(); + + CFX_WideString& Change(); + CFX_WideString ChangeEx(); + int CommitKey(); + FX_BOOL FieldFull(); + FX_BOOL KeyDown(); + FX_BOOL Modifier(); + const FX_WCHAR* Name(); + const FX_WCHAR* Type(); + FX_BOOL& Rc(); + int& SelEnd(); + int& SelStart(); + FX_BOOL Shift(); + Field* Source(); + Field* Target_Field(); + CFX_WideString& Value(); + FX_BOOL WillCommit(); + CFX_WideString TargetName(); + + JS_EVENT_T EventType() { return m_eEventType; }; + + public: + CJS_Context* m_pJSContext; + JS_EVENT_T m_eEventType; + FX_BOOL m_bValid; + + CFX_WideString m_strTargetName; + CFX_WideString m_strSourceName; + CFX_WideString* m_pWideStrChange; + CFX_WideString m_WideStrChangeDu; + CFX_WideString m_WideStrChangeEx; + int m_nCommitKey; + FX_BOOL m_bKeyDown; + FX_BOOL m_bModifier; + FX_BOOL m_bShift; + int* m_pISelEnd; + int m_nSelEndDu; + int* m_pISelStart; + int m_nSelStartDu; + FX_BOOL m_bWillCommit; + CFX_WideString* m_pValue; + FX_BOOL m_bFieldFull; + FX_BOOL* m_pbRc; + FX_BOOL m_bRcDu; + + CPDFSDK_Document* m_pSourceDoc; + CPDF_Bookmark* m_pTargetBookMark; + CPDFSDK_Document* m_pTargetDoc; + CPDFSDK_Annot* m_pTargetAnnot; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_EVENTHANDLER_H_ diff --git a/fpdfsdk/include/javascript/JS_GlobalData.h b/fpdfsdk/include/javascript/JS_GlobalData.h index b3637b93d5..607eec79bd 100644 --- a/fpdfsdk/include/javascript/JS_GlobalData.h +++ b/fpdfsdk/include/javascript/JS_GlobalData.h @@ -9,89 +9,94 @@ #include "../../../core/include/fxcrt/fx_basic.h" -#define JS_GLOBALDATA_TYPE_NUMBER 0 -#define JS_GLOBALDATA_TYPE_BOOLEAN 1 -#define JS_GLOBALDATA_TYPE_STRING 2 -#define JS_GLOBALDATA_TYPE_OBJECT 3 -#define JS_GLOBALDATA_TYPE_NULL 4 +#define JS_GLOBALDATA_TYPE_NUMBER 0 +#define JS_GLOBALDATA_TYPE_BOOLEAN 1 +#define JS_GLOBALDATA_TYPE_STRING 2 +#define JS_GLOBALDATA_TYPE_OBJECT 3 +#define JS_GLOBALDATA_TYPE_NULL 4 class CJS_KeyValue; class CPDFDoc_Environment; -class CJS_GlobalVariableArray -{ -public: - CJS_GlobalVariableArray(); - virtual ~CJS_GlobalVariableArray(); +class CJS_GlobalVariableArray { + public: + CJS_GlobalVariableArray(); + virtual ~CJS_GlobalVariableArray(); - void Add(CJS_KeyValue* p); - int Count() const; - CJS_KeyValue* GetAt(int index) const; - void Copy(const CJS_GlobalVariableArray& array); + void Add(CJS_KeyValue* p); + int Count() const; + CJS_KeyValue* GetAt(int index) const; + void Copy(const CJS_GlobalVariableArray& array); - void Empty(); + void Empty(); -private: - CFX_ArrayTemplate array; + private: + CFX_ArrayTemplate array; }; -class CJS_KeyValue -{ -public: - CJS_KeyValue(){} - virtual ~CJS_KeyValue(){} - - CFX_ByteString sKey; - int nType; //0:int 1:bool 2:string 3:obj - double dData; - bool bData; - CFX_ByteString sData; - CJS_GlobalVariableArray objData; +class CJS_KeyValue { + public: + CJS_KeyValue() {} + virtual ~CJS_KeyValue() {} + + CFX_ByteString sKey; + int nType; // 0:int 1:bool 2:string 3:obj + double dData; + bool bData; + CFX_ByteString sData; + CJS_GlobalVariableArray objData; }; -class CJS_GlobalData_Element -{ -public: - CJS_GlobalData_Element(){} - virtual ~CJS_GlobalData_Element(){} +class CJS_GlobalData_Element { + public: + CJS_GlobalData_Element() {} + virtual ~CJS_GlobalData_Element() {} - CJS_KeyValue data; - FX_BOOL bPersistent; + CJS_KeyValue data; + FX_BOOL bPersistent; }; -class CJS_GlobalData -{ -public: - CJS_GlobalData(CPDFDoc_Environment* pApp); - virtual ~CJS_GlobalData(); - -public: - void SetGlobalVariableNumber(const FX_CHAR* propname, double dData); - void SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData); - void SetGlobalVariableString(const FX_CHAR* propname, const CFX_ByteString& sData); - void SetGlobalVariableObject(const FX_CHAR* propname, const CJS_GlobalVariableArray& array); - void SetGlobalVariableNull(const FX_CHAR* propname); - - FX_BOOL SetGlobalVariablePersistent(const FX_CHAR* propname, FX_BOOL bPersistent); - FX_BOOL DeleteGlobalVariable(const FX_CHAR* propname); - - int32_t GetSize() const; - CJS_GlobalData_Element* GetAt(int index) const; - -private: - void LoadGlobalPersistentVariables(); - void SaveGlobalPersisitentVariables(); - - CJS_GlobalData_Element* GetGlobalVariable(const FX_CHAR* propname); - int FindGlobalVariable(const FX_CHAR* propname); - - void LoadFileBuffer(const FX_WCHAR* sFilePath, uint8_t*& pBuffer, int32_t& nLength); - void WriteFileBuffer(const FX_WCHAR* sFilePath, const FX_CHAR* pBuffer, int32_t nLength); - void MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pData, CFX_BinaryBuf& sData); - -private: - CFX_ArrayTemplate m_arrayGlobalData; - CFX_WideString m_sFilePath; +class CJS_GlobalData { + public: + CJS_GlobalData(CPDFDoc_Environment* pApp); + virtual ~CJS_GlobalData(); + + public: + void SetGlobalVariableNumber(const FX_CHAR* propname, double dData); + void SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData); + void SetGlobalVariableString(const FX_CHAR* propname, + const CFX_ByteString& sData); + void SetGlobalVariableObject(const FX_CHAR* propname, + const CJS_GlobalVariableArray& array); + void SetGlobalVariableNull(const FX_CHAR* propname); + + FX_BOOL SetGlobalVariablePersistent(const FX_CHAR* propname, + FX_BOOL bPersistent); + FX_BOOL DeleteGlobalVariable(const FX_CHAR* propname); + + int32_t GetSize() const; + CJS_GlobalData_Element* GetAt(int index) const; + + private: + void LoadGlobalPersistentVariables(); + void SaveGlobalPersisitentVariables(); + + CJS_GlobalData_Element* GetGlobalVariable(const FX_CHAR* propname); + int FindGlobalVariable(const FX_CHAR* propname); + + void LoadFileBuffer(const FX_WCHAR* sFilePath, + uint8_t*& pBuffer, + int32_t& nLength); + void WriteFileBuffer(const FX_WCHAR* sFilePath, + const FX_CHAR* pBuffer, + int32_t nLength); + void MakeByteString(const CFX_ByteString& name, + CJS_KeyValue* pData, + CFX_BinaryBuf& sData); + + private: + CFX_ArrayTemplate m_arrayGlobalData; + CFX_WideString m_sFilePath; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_GLOBALDATA_H_ diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h index 3898d184d1..fd63d98cbc 100644 --- a/fpdfsdk/include/javascript/JS_Object.h +++ b/fpdfsdk/include/javascript/JS_Object.h @@ -7,8 +7,8 @@ #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ -#include "../fsdk_define.h" // For FX_UINT -#include "../fsdk_mgr.h" // For CPDFDoc_Environment +#include "../fsdk_define.h" // For FX_UINT +#include "../fsdk_mgr.h" // For CPDFDoc_Environment #include "../fx_systemhandler.h" // For IFX_SystemHandler #include "../jsapi/fxjs_v8.h" @@ -17,279 +17,228 @@ class CJS_Object; class CJS_Timer; class CJS_Context; -class CJS_EmbedObj -{ -public: - CJS_EmbedObj(CJS_Object* pJSObject); - virtual ~CJS_EmbedObj(); +class CJS_EmbedObj { + public: + CJS_EmbedObj(CJS_Object* pJSObject); + virtual ~CJS_EmbedObj(); - virtual void TimerProc(CJS_Timer* pTimer){}; + virtual void TimerProc(CJS_Timer* pTimer){}; - CJS_Timer* BeginTimer(CPDFDoc_Environment * pApp, FX_UINT nElapse); - void EndTimer(CJS_Timer* pTimer); + CJS_Timer* BeginTimer(CPDFDoc_Environment* pApp, FX_UINT nElapse); + void EndTimer(CJS_Timer* pTimer); - CJS_Object* GetJSObject(){return m_pJSObject;}; - operator CJS_Object* (){return m_pJSObject;}; + CJS_Object* GetJSObject() { return m_pJSObject; }; + operator CJS_Object*() { return m_pJSObject; }; - CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc); - int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX_WCHAR* swMsg, const FX_WCHAR* swTitle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0); - void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); + CPDFSDK_PageView* JSGetPageView(IFXJS_Context* cc); + int MsgBox(CPDFDoc_Environment* pApp, + CPDFSDK_PageView* pPageView, + const FX_WCHAR* swMsg, + const FX_WCHAR* swTitle = NULL, + FX_UINT nType = 0, + FX_UINT nIcon = 0); + void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); -protected: - CJS_Object* m_pJSObject; + protected: + CJS_Object* m_pJSObject; }; -class CJS_Object -{ -public: - CJS_Object(JSFXObject pObject); - virtual ~CJS_Object(void); +class CJS_Object { + public: + CJS_Object(JSFXObject pObject); + virtual ~CJS_Object(void); - void MakeWeak(); - void Dispose(); + void MakeWeak(); + void Dispose(); - virtual FX_BOOL IsType(const FX_CHAR* sClassName){return TRUE;}; - virtual CFX_ByteString GetClassName(){return "";}; + virtual FX_BOOL IsType(const FX_CHAR* sClassName) { return TRUE; }; + virtual CFX_ByteString GetClassName() { return ""; }; - virtual FX_BOOL InitInstance(IFXJS_Context* cc){return TRUE;}; - virtual FX_BOOL ExitInstance(){return TRUE;}; + virtual FX_BOOL InitInstance(IFXJS_Context* cc) { return TRUE; }; + virtual FX_BOOL ExitInstance() { return TRUE; }; - operator JSFXObject () {return v8::Local::New(m_pIsolate, m_pObject);} - operator CJS_EmbedObj* (){return m_pEmbedObj;}; + operator JSFXObject() { + return v8::Local::New(m_pIsolate, m_pObject); + } + operator CJS_EmbedObj*() { return m_pEmbedObj; }; - void SetEmbedObject(CJS_EmbedObj* pObj){m_pEmbedObj = pObj;}; - CJS_EmbedObj * GetEmbedObject(){return m_pEmbedObj;}; + void SetEmbedObject(CJS_EmbedObj* pObj) { m_pEmbedObj = pObj; }; + CJS_EmbedObj* GetEmbedObject() { return m_pEmbedObj; }; - static CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc); - static int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX_WCHAR* swMsg, const FX_WCHAR* swTitle = NULL, FX_UINT nType = 0,FX_UINT nIcon = 0); - static void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); + static CPDFSDK_PageView* JSGetPageView(IFXJS_Context* cc); + static int MsgBox(CPDFDoc_Environment* pApp, + CPDFSDK_PageView* pPageView, + const FX_WCHAR* swMsg, + const FX_WCHAR* swTitle = NULL, + FX_UINT nType = 0, + FX_UINT nIcon = 0); + static void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); - v8::Isolate* GetIsolate() {return m_pIsolate;} -protected: - CJS_EmbedObj * m_pEmbedObj; - v8::Global m_pObject; - v8::Isolate* m_pIsolate; + v8::Isolate* GetIsolate() { return m_pIsolate; } + + protected: + CJS_EmbedObj* m_pEmbedObj; + v8::Global m_pObject; + v8::Isolate* m_pIsolate; }; -struct JS_TIMER_MAP -{ - FX_UINT nID; - CJS_Timer * pTimer; +struct JS_TIMER_MAP { + FX_UINT nID; + CJS_Timer* pTimer; }; -typedef CFX_ArrayTemplate CTimerMapArray; - -struct JS_TIMER_MAPARRAY -{ -public: - JS_TIMER_MAPARRAY() - { - } - - ~JS_TIMER_MAPARRAY() - { - Reset(); - } - - void Reset() - { - for (int i=0,sz=m_Array.GetSize(); i=0) - { - if (JS_TIMER_MAP * pMap = m_Array.GetAt(i)) - pMap->pTimer = pTimer; - } - else - { - if (JS_TIMER_MAP * pMap = new JS_TIMER_MAP) - { - pMap->nID = nIndex; - pMap->pTimer = pTimer; - m_Array.Add(pMap); - } - } - } - - CJS_Timer * GetAt(FX_UINT nIndex) - { - int i = Find(nIndex); - - if (i>=0) - { - if (JS_TIMER_MAP * pMap = m_Array.GetAt(i)) - return pMap->pTimer; - } - return NULL; - } - - void RemoveAt(FX_UINT nIndex) - { - int i = Find(nIndex); - - if (i>=0) - { - delete m_Array.GetAt(i); - m_Array.RemoveAt(i); - } - //To prevent potential fake memory leak reported by vc6. - if(m_Array.GetSize() == 0) - m_Array.RemoveAll(); - } - - int Find(FX_UINT nIndex) - { - for (int i=0,sz=m_Array.GetSize(); inID == nIndex) - return i; - } - } - - return -1; - } - - CTimerMapArray m_Array; +typedef CFX_ArrayTemplate CTimerMapArray; + +struct JS_TIMER_MAPARRAY { + public: + JS_TIMER_MAPARRAY() {} + + ~JS_TIMER_MAPARRAY() { Reset(); } + + void Reset() { + for (int i = 0, sz = m_Array.GetSize(); i < sz; i++) + delete m_Array.GetAt(i); + + m_Array.RemoveAll(); + } + + void SetAt(FX_UINT nIndex, CJS_Timer* pTimer) { + int i = Find(nIndex); + + if (i >= 0) { + if (JS_TIMER_MAP* pMap = m_Array.GetAt(i)) + pMap->pTimer = pTimer; + } else { + if (JS_TIMER_MAP* pMap = new JS_TIMER_MAP) { + pMap->nID = nIndex; + pMap->pTimer = pTimer; + m_Array.Add(pMap); + } + } + } + + CJS_Timer* GetAt(FX_UINT nIndex) { + int i = Find(nIndex); + + if (i >= 0) { + if (JS_TIMER_MAP* pMap = m_Array.GetAt(i)) + return pMap->pTimer; + } + return NULL; + } + + void RemoveAt(FX_UINT nIndex) { + int i = Find(nIndex); + + if (i >= 0) { + delete m_Array.GetAt(i); + m_Array.RemoveAt(i); + } + // To prevent potential fake memory leak reported by vc6. + if (m_Array.GetSize() == 0) + m_Array.RemoveAll(); + } + + int Find(FX_UINT nIndex) { + for (int i = 0, sz = m_Array.GetSize(); i < sz; i++) { + if (JS_TIMER_MAP* pMap = m_Array.GetAt(i)) { + if (pMap->nID == nIndex) + return i; + } + } + + return -1; + } + + CTimerMapArray m_Array; }; JS_TIMER_MAPARRAY& GetTimeMap(); class CJS_Runtime; -class CJS_Timer -{ -public: - CJS_Timer(CJS_EmbedObj * pObj,CPDFDoc_Environment* pApp): - m_nTimerID(0), - m_pEmbedObj(pObj), - m_bProcessing(FALSE), - m_dwStartTime(0), - m_dwTimeOut(0), - m_dwElapse(0), - m_pRuntime(NULL), - m_nType(0), - m_pApp(pApp) - { - } - - virtual ~CJS_Timer() - { - KillJSTimer(); - } - -public: - FX_UINT SetJSTimer(FX_UINT nElapse) - { - if (m_nTimerID)KillJSTimer(); - IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); - m_nTimerID = pHandler->SetTimer(nElapse,TimerProc); - GetTimeMap().SetAt(m_nTimerID,this); - m_dwElapse = nElapse; - return m_nTimerID; - }; - - void KillJSTimer() - { - if (m_nTimerID) - { - IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); - pHandler->KillTimer(m_nTimerID); - GetTimeMap().RemoveAt(m_nTimerID); - m_nTimerID = 0; - } - }; - - void SetType(int nType) - { - m_nType = nType; - } - - int GetType() const - { - return m_nType; - } - - void SetStartTime(FX_DWORD dwStartTime) - { - m_dwStartTime = dwStartTime; - } - - FX_DWORD GetStartTime() const - { - return m_dwStartTime; - } - - void SetTimeOut(FX_DWORD dwTimeOut) - { - m_dwTimeOut = dwTimeOut; - } - - FX_DWORD GetTimeOut() const - { - return m_dwTimeOut; - } - - void SetRuntime(CJS_Runtime* pRuntime) - { - m_pRuntime = pRuntime; - } - - CJS_Runtime* GetRuntime() const - { - return m_pRuntime; - } - - void SetJScript(const CFX_WideString& script) - { - m_swJScript = script; - } - - CFX_WideString GetJScript() const - { - return m_swJScript; - } - - static void TimerProc(int idEvent) - { - if (CJS_Timer * pTimer = GetTimeMap().GetAt(idEvent)) - { - if (!pTimer->m_bProcessing) - { - pTimer->m_bProcessing = TRUE; - if (pTimer->m_pEmbedObj) pTimer->m_pEmbedObj->TimerProc(pTimer); - pTimer->m_bProcessing = FALSE; - } - else - { - // TRACE(L"BUSY!\n"); - } - } - }; - -private: - FX_UINT m_nTimerID; - CJS_EmbedObj* m_pEmbedObj; - FX_BOOL m_bProcessing; - - //data - FX_DWORD m_dwStartTime; - FX_DWORD m_dwTimeOut; - FX_DWORD m_dwElapse; - CJS_Runtime* m_pRuntime; - CFX_WideString m_swJScript; - int m_nType; //0:Interval; 1:TimeOut - - CPDFDoc_Environment* m_pApp; +class CJS_Timer { + public: + CJS_Timer(CJS_EmbedObj* pObj, CPDFDoc_Environment* pApp) + : m_nTimerID(0), + m_pEmbedObj(pObj), + m_bProcessing(FALSE), + m_dwStartTime(0), + m_dwTimeOut(0), + m_dwElapse(0), + m_pRuntime(NULL), + m_nType(0), + m_pApp(pApp) {} + + virtual ~CJS_Timer() { KillJSTimer(); } + + public: + FX_UINT SetJSTimer(FX_UINT nElapse) { + if (m_nTimerID) + KillJSTimer(); + IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); + m_nTimerID = pHandler->SetTimer(nElapse, TimerProc); + GetTimeMap().SetAt(m_nTimerID, this); + m_dwElapse = nElapse; + return m_nTimerID; + }; + + void KillJSTimer() { + if (m_nTimerID) { + IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); + pHandler->KillTimer(m_nTimerID); + GetTimeMap().RemoveAt(m_nTimerID); + m_nTimerID = 0; + } + }; + + void SetType(int nType) { m_nType = nType; } + + int GetType() const { return m_nType; } + + void SetStartTime(FX_DWORD dwStartTime) { m_dwStartTime = dwStartTime; } + + FX_DWORD GetStartTime() const { return m_dwStartTime; } + + void SetTimeOut(FX_DWORD dwTimeOut) { m_dwTimeOut = dwTimeOut; } + + FX_DWORD GetTimeOut() const { return m_dwTimeOut; } + + void SetRuntime(CJS_Runtime* pRuntime) { m_pRuntime = pRuntime; } + + CJS_Runtime* GetRuntime() const { return m_pRuntime; } + + void SetJScript(const CFX_WideString& script) { m_swJScript = script; } + + CFX_WideString GetJScript() const { return m_swJScript; } + + static void TimerProc(int idEvent) { + if (CJS_Timer* pTimer = GetTimeMap().GetAt(idEvent)) { + if (!pTimer->m_bProcessing) { + pTimer->m_bProcessing = TRUE; + if (pTimer->m_pEmbedObj) + pTimer->m_pEmbedObj->TimerProc(pTimer); + pTimer->m_bProcessing = FALSE; + } else { + // TRACE(L"BUSY!\n"); + } + } + }; + + private: + FX_UINT m_nTimerID; + CJS_EmbedObj* m_pEmbedObj; + FX_BOOL m_bProcessing; + + // data + FX_DWORD m_dwStartTime; + FX_DWORD m_dwTimeOut; + FX_DWORD m_dwElapse; + CJS_Runtime* m_pRuntime; + CFX_WideString m_swJScript; + int m_nType; // 0:Interval; 1:TimeOut + + CPDFDoc_Environment* m_pApp; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h index 8fdfa8b733..f4dabf017e 100644 --- a/fpdfsdk/include/javascript/JS_Runtime.h +++ b/fpdfsdk/include/javascript/JS_Runtime.h @@ -16,59 +16,60 @@ class CJS_Context; class CJS_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; + void* Allocate(size_t length) override; + void* AllocateUninitialized(size_t length) override; + void Free(void* data, size_t length) override; }; -class CJS_FieldEvent -{ -public: - CFX_WideString sTargetName; - JS_EVENT_T eEventType; - CJS_FieldEvent* pNext; +class CJS_FieldEvent { + public: + CFX_WideString sTargetName; + JS_EVENT_T eEventType; + CJS_FieldEvent* pNext; }; -class CJS_Runtime : public IFXJS_Runtime -{ -public: - CJS_Runtime(CPDFDoc_Environment * pApp); - virtual ~CJS_Runtime(); +class CJS_Runtime : public IFXJS_Runtime { + public: + CJS_Runtime(CPDFDoc_Environment* pApp); + virtual ~CJS_Runtime(); - virtual IFXJS_Context * NewContext(); - virtual void ReleaseContext(IFXJS_Context * pContext); - virtual IFXJS_Context* GetCurrentContext(); + virtual IFXJS_Context* NewContext(); + virtual void ReleaseContext(IFXJS_Context* pContext); + virtual IFXJS_Context* GetCurrentContext(); - virtual void SetReaderDocument(CPDFSDK_Document *pReaderDoc); - virtual CPDFSDK_Document * GetReaderDocument(){return m_pDocument;} + virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc); + virtual CPDFSDK_Document* GetReaderDocument() { return m_pDocument; } - CPDFDoc_Environment * GetReaderApp(){return m_pApp;} + CPDFDoc_Environment* GetReaderApp() { return m_pApp; } - FX_BOOL InitJSObjects(); + FX_BOOL InitJSObjects(); - FX_BOOL AddEventToLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType); - void RemoveEventInLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType); - void RemoveEventsInLoop(CJS_FieldEvent* pStart); + FX_BOOL AddEventToLoop(const CFX_WideString& sTargetName, + JS_EVENT_T eEventType); + void RemoveEventInLoop(const CFX_WideString& sTargetName, + JS_EVENT_T eEventType); + void RemoveEventsInLoop(CJS_FieldEvent* pStart); - void BeginBlock(){m_bBlocking = TRUE;} - void EndBlock(){m_bBlocking = FALSE;} - FX_BOOL IsBlocking(){return m_bBlocking;} + void BeginBlock() { m_bBlocking = TRUE; } + void EndBlock() { m_bBlocking = FALSE; } + FX_BOOL IsBlocking() { return m_bBlocking; } - operator IJS_Runtime*() {return (IJS_Runtime*)m_isolate;} - v8::Isolate* GetIsolate(){return m_isolate;}; - void SetIsolate(v8::Isolate* isolate){m_isolate = isolate;} + operator IJS_Runtime*() { return (IJS_Runtime*)m_isolate; } + v8::Isolate* GetIsolate() { return m_isolate; }; + void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; } - v8::Local NewJSContext(); -protected: - CFX_ArrayTemplate m_ContextArray; - CPDFDoc_Environment* m_pApp; - CPDFSDK_Document* m_pDocument; - FX_BOOL m_bBlocking; - CJS_FieldEvent* m_pFieldEventPath; + v8::Local NewJSContext(); - v8::Isolate* m_isolate; - nonstd::unique_ptr m_pArrayBufferAllocator; - v8::Global m_context; + protected: + CFX_ArrayTemplate m_ContextArray; + CPDFDoc_Environment* m_pApp; + CPDFSDK_Document* m_pDocument; + FX_BOOL m_bBlocking; + CJS_FieldEvent* m_pFieldEventPath; + + v8::Isolate* m_isolate; + nonstd::unique_ptr m_pArrayBufferAllocator; + v8::Global m_context; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ diff --git a/fpdfsdk/include/javascript/JS_Value.h b/fpdfsdk/include/javascript/JS_Value.h index 6186817fa5..1606fb5396 100644 --- a/fpdfsdk/include/javascript/JS_Value.h +++ b/fpdfsdk/include/javascript/JS_Value.h @@ -15,175 +15,179 @@ class CJS_Date; class CJS_Document; class CJS_Object; -class CJS_Value -{ -public: - CJS_Value(v8::Isolate* isolate); - CJS_Value(v8::Isolate* isolate, v8::Local pValue,FXJSVALUETYPE t); - CJS_Value(v8::Isolate* isolate, const int &iValue); - CJS_Value(v8::Isolate* isolate, const double &dValue); - CJS_Value(v8::Isolate* isolate, const float &fValue); - CJS_Value(v8::Isolate* isolate, const bool &bValue); - CJS_Value(v8::Isolate* isolate, JSFXObject); - CJS_Value(v8::Isolate* isolate, CJS_Object*); - CJS_Value(v8::Isolate* isolate, CJS_Document*); - CJS_Value(v8::Isolate* isolate, const FX_CHAR* pStr); - CJS_Value(v8::Isolate* isolate, const FX_WCHAR* pWstr); - CJS_Value(v8::Isolate* isolate, CJS_Array& array); - - ~CJS_Value(); - - void SetNull(); - void Attach(v8::Local pValue,FXJSVALUETYPE t); - void Attach(CJS_Value *pValue); - void Detach(); - - - int ToInt() const; - bool ToBool() const; - double ToDouble() const; - float ToFloat() const; - CJS_Object* ToCJSObject() const; - CFX_WideString ToCFXWideString() const; - CFX_ByteString ToCFXByteString() const; - v8::Local ToV8Object() const; - v8::Local ToV8Array() const; - v8::Local ToV8Value() const; - - void operator = (int iValue); - void operator = (bool bValue); - void operator = (double); - void operator = (float); - void operator = (CJS_Object*); - void operator = (CJS_Document*); - void operator = (v8::Local); - void operator = (CJS_Array &); - void operator = (CJS_Date &); - void operator = (const FX_WCHAR* pWstr); - void operator = (const FX_CHAR* pStr); - void operator = (CJS_Value value); - - FX_BOOL IsArrayObject() const; - FX_BOOL IsDateObject() const; - FXJSVALUETYPE GetType() const; - - FX_BOOL ConvertToArray(CJS_Array &) const; - FX_BOOL ConvertToDate(CJS_Date &) const; - - v8::Isolate* GetIsolate() {return m_isolate;} -protected: - v8::Local m_pValue; - FXJSVALUETYPE m_eType; - v8::Isolate* m_isolate; +class CJS_Value { + public: + CJS_Value(v8::Isolate* isolate); + CJS_Value(v8::Isolate* isolate, v8::Local pValue, FXJSVALUETYPE t); + CJS_Value(v8::Isolate* isolate, const int& iValue); + CJS_Value(v8::Isolate* isolate, const double& dValue); + CJS_Value(v8::Isolate* isolate, const float& fValue); + CJS_Value(v8::Isolate* isolate, const bool& bValue); + CJS_Value(v8::Isolate* isolate, JSFXObject); + CJS_Value(v8::Isolate* isolate, CJS_Object*); + CJS_Value(v8::Isolate* isolate, CJS_Document*); + CJS_Value(v8::Isolate* isolate, const FX_CHAR* pStr); + CJS_Value(v8::Isolate* isolate, const FX_WCHAR* pWstr); + CJS_Value(v8::Isolate* isolate, CJS_Array& array); + + ~CJS_Value(); + + void SetNull(); + void Attach(v8::Local pValue, FXJSVALUETYPE t); + void Attach(CJS_Value* pValue); + void Detach(); + + int ToInt() const; + bool ToBool() const; + double ToDouble() const; + float ToFloat() const; + CJS_Object* ToCJSObject() const; + CFX_WideString ToCFXWideString() const; + CFX_ByteString ToCFXByteString() const; + v8::Local ToV8Object() const; + v8::Local ToV8Array() const; + v8::Local ToV8Value() const; + + void operator=(int iValue); + void operator=(bool bValue); + void operator=(double); + void operator=(float); + void operator=(CJS_Object*); + void operator=(CJS_Document*); + void operator=(v8::Local); + void operator=(CJS_Array&); + void operator=(CJS_Date&); + void operator=(const FX_WCHAR* pWstr); + void operator=(const FX_CHAR* pStr); + void operator=(CJS_Value value); + + FX_BOOL IsArrayObject() const; + FX_BOOL IsDateObject() const; + FXJSVALUETYPE GetType() const; + + FX_BOOL ConvertToArray(CJS_Array&) const; + FX_BOOL ConvertToDate(CJS_Date&) const; + + v8::Isolate* GetIsolate() { return m_isolate; } + + protected: + v8::Local m_pValue; + FXJSVALUETYPE m_eType; + v8::Isolate* m_isolate; }; -class CJS_Parameters : public CFX_ArrayTemplate -{ -public: - void push_back(const CJS_Value& newElement) { - CFX_ArrayTemplate::Add(newElement); - } - int size() const { - return CFX_ArrayTemplate::GetSize(); - } +class CJS_Parameters : public CFX_ArrayTemplate { + public: + void push_back(const CJS_Value& newElement) { + CFX_ArrayTemplate::Add(newElement); + } + int size() const { return CFX_ArrayTemplate::GetSize(); } }; -class CJS_PropValue: public CJS_Value -{ -public: - CJS_PropValue(const CJS_Value&); - CJS_PropValue(v8::Isolate* isolate); - ~CJS_PropValue(); -public: - FX_BOOL IsSetting(); - FX_BOOL IsGetting(); - void operator<<(int); - void operator>>(int&) const; - void operator<<(bool); - void operator>>(bool&) const; - void operator<<(double); - void operator>>(double&) const; - void operator<<(CJS_Object* pObj); - void operator>>(CJS_Object*& ppObj) const; - void operator<<(CJS_Document* pJsDoc); - void operator>>(CJS_Document*& ppJsDoc) const; - void operator<<(CFX_ByteString); - void operator>>(CFX_ByteString&) const; - void operator<<(CFX_WideString); - void operator>>(CFX_WideString&) const; - void operator<<(const FX_WCHAR* c_string); - void operator<<(JSFXObject); - void operator>>(JSFXObject&) const; - void operator>>(CJS_Array& array) const; - void operator<<(CJS_Array& array); - void operator<<(CJS_Date& date); - void operator>>(CJS_Date& date) const; - operator v8::Local() const; - void StartSetting(); - void StartGetting(); -private: - FX_BOOL m_bIsSetting; +class CJS_PropValue : public CJS_Value { + public: + CJS_PropValue(const CJS_Value&); + CJS_PropValue(v8::Isolate* isolate); + ~CJS_PropValue(); + + public: + FX_BOOL IsSetting(); + FX_BOOL IsGetting(); + void operator<<(int); + void operator>>(int&) const; + void operator<<(bool); + void operator>>(bool&) const; + void operator<<(double); + void operator>>(double&) const; + void operator<<(CJS_Object* pObj); + void operator>>(CJS_Object*& ppObj) const; + void operator<<(CJS_Document* pJsDoc); + void operator>>(CJS_Document*& ppJsDoc) const; + void operator<<(CFX_ByteString); + void operator>>(CFX_ByteString&) const; + void operator<<(CFX_WideString); + void operator>>(CFX_WideString&) const; + void operator<<(const FX_WCHAR* c_string); + void operator<<(JSFXObject); + void operator>>(JSFXObject&) const; + void operator>>(CJS_Array& array) const; + void operator<<(CJS_Array& array); + void operator<<(CJS_Date& date); + void operator>>(CJS_Date& date) const; + operator v8::Local() const; + void StartSetting(); + void StartGetting(); + + private: + FX_BOOL m_bIsSetting; }; -class CJS_Array -{ -public: - CJS_Array(v8::Isolate* isolate); - virtual ~CJS_Array(); - - void Attach(v8::Local pArray); - void GetElement(unsigned index,CJS_Value &value); - void SetElement(unsigned index,CJS_Value value); - int GetLength(); - FX_BOOL IsAttached(); - operator v8::Local(); - - v8::Isolate* GetIsolate() {return m_isolate;} -private: - v8::Local m_pArray; - v8::Isolate* m_isolate; +class CJS_Array { + public: + CJS_Array(v8::Isolate* isolate); + virtual ~CJS_Array(); + + void Attach(v8::Local pArray); + void GetElement(unsigned index, CJS_Value& value); + void SetElement(unsigned index, CJS_Value value); + int GetLength(); + FX_BOOL IsAttached(); + operator v8::Local(); + + v8::Isolate* GetIsolate() { return m_isolate; } + + private: + v8::Local m_pArray; + v8::Isolate* m_isolate; }; -class CJS_Date -{ -friend class CJS_Value; -public: - CJS_Date(v8::Isolate* isolate); - CJS_Date(v8::Isolate* isolate,double dMsec_time); - CJS_Date(v8::Isolate* isolate,int year, int mon, int day,int hour, int min, int sec); - virtual ~CJS_Date(); - void Attach(v8::Local pDate); +class CJS_Date { + friend class CJS_Value; + + public: + CJS_Date(v8::Isolate* isolate); + CJS_Date(v8::Isolate* isolate, double dMsec_time); + CJS_Date(v8::Isolate* isolate, + int year, + int mon, + int day, + int hour, + int min, + int sec); + virtual ~CJS_Date(); + void Attach(v8::Local pDate); - int GetYear(); - void SetYear(int iYear); + int GetYear(); + void SetYear(int iYear); - int GetMonth(); - void SetMonth(int iMonth); + int GetMonth(); + void SetMonth(int iMonth); - int GetDay(); - void SetDay(int iDay); + int GetDay(); + void SetDay(int iDay); - int GetHours(); - void SetHours(int iHours); + int GetHours(); + void SetHours(int iHours); - int GetMinutes(); - void SetMinutes(int minutes); + int GetMinutes(); + void SetMinutes(int minutes); - int GetSeconds(); - void SetSeconds(int seconds); + int GetSeconds(); + void SetSeconds(int seconds); - operator v8::Local(); - operator double() const; + operator v8::Local(); + operator double() const; - CFX_WideString ToString() const; + CFX_WideString ToString() const; - static double MakeDate(int year, int mon, int mday,int hour, int min, int sec,int ms); + static double + MakeDate(int year, int mon, int mday, int hour, int min, int sec, int ms); - FX_BOOL IsValidDate(); + FX_BOOL IsValidDate(); -protected: - v8::Local m_pDate; - v8::Isolate* m_isolate; + protected: + v8::Local m_pDate; + v8::Isolate* m_isolate; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_VALUE_H_ diff --git a/fpdfsdk/include/javascript/PublicMethods.h b/fpdfsdk/include/javascript/PublicMethods.h index cff9e11479..c5d5ea6d46 100644 --- a/fpdfsdk/include/javascript/PublicMethods.h +++ b/fpdfsdk/include/javascript/PublicMethods.h @@ -9,95 +9,177 @@ #include "JS_Define.h" -class CJS_PublicMethods : public CJS_Object -{ -public: - CJS_PublicMethods(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_PublicMethods(void){}; +class CJS_PublicMethods : public CJS_Object { + public: + CJS_PublicMethods(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_PublicMethods(void){}; -public: - static FX_BOOL AFNumber_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFPercent_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFDate_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFDate_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFDate_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFTime_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); // - static FX_BOOL AFTime_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFTime_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFTime_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFSpecial_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError);// - static FX_BOOL AFSimple(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFSimple_Calculate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFRange_Validate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFMergeChange(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - static FX_BOOL AFExtractNums(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); + public: + static FX_BOOL AFNumber_Format(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFNumber_Keystroke(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFPercent_Format(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFPercent_Keystroke(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFDate_FormatEx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFDate_KeystrokeEx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFDate_Format(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFDate_Keystroke(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFTime_FormatEx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); // + static FX_BOOL AFTime_KeystrokeEx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFTime_Format(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFTime_Keystroke(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFSpecial_Format(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFSpecial_Keystroke(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFSpecial_KeystrokeEx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); // + static FX_BOOL AFSimple(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFMakeNumber(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFSimple_Calculate(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFRange_Validate(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFMergeChange(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFParseDateEx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + static FX_BOOL AFExtractNums(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); -public: - JS_STATIC_GLOBAL_FUN(AFNumber_Format); - JS_STATIC_GLOBAL_FUN(AFNumber_Keystroke); - JS_STATIC_GLOBAL_FUN(AFPercent_Format); - JS_STATIC_GLOBAL_FUN(AFPercent_Keystroke); - JS_STATIC_GLOBAL_FUN(AFDate_FormatEx); - JS_STATIC_GLOBAL_FUN(AFDate_KeystrokeEx); - JS_STATIC_GLOBAL_FUN(AFDate_Format); - JS_STATIC_GLOBAL_FUN(AFDate_Keystroke); - JS_STATIC_GLOBAL_FUN(AFTime_FormatEx); - JS_STATIC_GLOBAL_FUN(AFTime_KeystrokeEx); - JS_STATIC_GLOBAL_FUN(AFTime_Format); - JS_STATIC_GLOBAL_FUN(AFTime_Keystroke); - JS_STATIC_GLOBAL_FUN(AFSpecial_Format); - JS_STATIC_GLOBAL_FUN(AFSpecial_Keystroke); - JS_STATIC_GLOBAL_FUN(AFSpecial_KeystrokeEx); - JS_STATIC_GLOBAL_FUN(AFSimple); - JS_STATIC_GLOBAL_FUN(AFMakeNumber); - JS_STATIC_GLOBAL_FUN(AFSimple_Calculate); - JS_STATIC_GLOBAL_FUN(AFRange_Validate); - JS_STATIC_GLOBAL_FUN(AFMergeChange); - JS_STATIC_GLOBAL_FUN(AFParseDateEx); - JS_STATIC_GLOBAL_FUN(AFExtractNums); + public: + JS_STATIC_GLOBAL_FUN(AFNumber_Format); + JS_STATIC_GLOBAL_FUN(AFNumber_Keystroke); + JS_STATIC_GLOBAL_FUN(AFPercent_Format); + JS_STATIC_GLOBAL_FUN(AFPercent_Keystroke); + JS_STATIC_GLOBAL_FUN(AFDate_FormatEx); + JS_STATIC_GLOBAL_FUN(AFDate_KeystrokeEx); + JS_STATIC_GLOBAL_FUN(AFDate_Format); + JS_STATIC_GLOBAL_FUN(AFDate_Keystroke); + JS_STATIC_GLOBAL_FUN(AFTime_FormatEx); + JS_STATIC_GLOBAL_FUN(AFTime_KeystrokeEx); + JS_STATIC_GLOBAL_FUN(AFTime_Format); + JS_STATIC_GLOBAL_FUN(AFTime_Keystroke); + JS_STATIC_GLOBAL_FUN(AFSpecial_Format); + JS_STATIC_GLOBAL_FUN(AFSpecial_Keystroke); + JS_STATIC_GLOBAL_FUN(AFSpecial_KeystrokeEx); + JS_STATIC_GLOBAL_FUN(AFSimple); + JS_STATIC_GLOBAL_FUN(AFMakeNumber); + JS_STATIC_GLOBAL_FUN(AFSimple_Calculate); + JS_STATIC_GLOBAL_FUN(AFRange_Validate); + JS_STATIC_GLOBAL_FUN(AFMergeChange); + JS_STATIC_GLOBAL_FUN(AFParseDateEx); + JS_STATIC_GLOBAL_FUN(AFExtractNums); - JS_STATIC_DECLARE_GLOBAL_FUN(); + JS_STATIC_DECLARE_GLOBAL_FUN(); -public: - static int ParseStringInteger(const CFX_WideString & string,int nStart,int & nSkip, int nMaxStep); - static CFX_WideString ParseStringString(const CFX_WideString& string, int nStart, int& nSkip); - static double MakeRegularDate(const CFX_WideString & value,const CFX_WideString & format, FX_BOOL& bWrongFormat); - static CFX_WideString MakeFormatDate(double dDate,const CFX_WideString & format); - static FX_BOOL ConvertStringToNumber(const FX_WCHAR* swSource, double & dRet, FX_BOOL & bDot); - static double ParseStringToNumber(const FX_WCHAR* swSource); - static double ParseNormalDate(const CFX_WideString & value, FX_BOOL& bWrongFormat); - static double MakeInterDate(CFX_WideString strValue); - static double ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDigits, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS); + public: + static int ParseStringInteger(const CFX_WideString& string, + int nStart, + int& nSkip, + int nMaxStep); + static CFX_WideString ParseStringString(const CFX_WideString& string, + int nStart, + int& nSkip); + static double MakeRegularDate(const CFX_WideString& value, + const CFX_WideString& format, + FX_BOOL& bWrongFormat); + static CFX_WideString MakeFormatDate(double dDate, + const CFX_WideString& format); + static FX_BOOL ConvertStringToNumber(const FX_WCHAR* swSource, + double& dRet, + FX_BOOL& bDot); + static double ParseStringToNumber(const FX_WCHAR* swSource); + static double ParseNormalDate(const CFX_WideString& value, + FX_BOOL& bWrongFormat); + static double MakeInterDate(CFX_WideString strValue); + static double ParseNumber(const FX_WCHAR* swSource, + FX_BOOL& bAllDigits, + FX_BOOL& bDot, + FX_BOOL& bSign, + FX_BOOL& bKXJS); -public: - static CFX_WideString StrLTrim(const FX_WCHAR* pStr); - static CFX_WideString StrRTrim(const FX_WCHAR* pStr); - static CFX_WideString StrTrim(const FX_WCHAR* pStr); + public: + static CFX_WideString StrLTrim(const FX_WCHAR* pStr); + static CFX_WideString StrRTrim(const FX_WCHAR* pStr); + static CFX_WideString StrTrim(const FX_WCHAR* pStr); - static CFX_ByteString StrLTrim(const FX_CHAR* pStr); - static CFX_ByteString StrRTrim(const FX_CHAR* pStr); - static CFX_ByteString StrTrim(const FX_CHAR* pStr); + static CFX_ByteString StrLTrim(const FX_CHAR* pStr); + static CFX_ByteString StrRTrim(const FX_CHAR* pStr); + static CFX_ByteString StrTrim(const FX_CHAR* pStr); - static FX_BOOL IsNumber(const FX_CHAR* string); - static FX_BOOL IsNumber(const FX_WCHAR* string); + static FX_BOOL IsNumber(const FX_CHAR* string); + static FX_BOOL IsNumber(const FX_WCHAR* string); - static FX_BOOL IsDigit(char ch); - static FX_BOOL IsDigit(wchar_t ch); - static FX_BOOL IsAlphabetic(wchar_t ch); - static FX_BOOL IsAlphaNumeric(wchar_t ch); + static FX_BOOL IsDigit(char ch); + static FX_BOOL IsDigit(wchar_t ch); + static FX_BOOL IsAlphabetic(wchar_t ch); + static FX_BOOL IsAlphaNumeric(wchar_t ch); - static FX_BOOL maskSatisfied(wchar_t c_Change,wchar_t c_Mask); - static FX_BOOL isReservedMaskChar(wchar_t ch); + static FX_BOOL maskSatisfied(wchar_t c_Change, wchar_t c_Mask); + static FX_BOOL isReservedMaskChar(wchar_t ch); - static double AF_Simple(const FX_WCHAR* sFuction, double dValue1, double dValue2); - static CJS_Array AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Value val); + static double AF_Simple(const FX_WCHAR* sFuction, + double dValue1, + double dValue2); + static CJS_Array AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Value val); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_PUBLICMETHODS_H_ diff --git a/fpdfsdk/include/javascript/app.h b/fpdfsdk/include/javascript/app.h index ac90e62b0d..221a7c1d89 100644 --- a/fpdfsdk/include/javascript/app.h +++ b/fpdfsdk/include/javascript/app.h @@ -15,35 +15,33 @@ class CJS_Runtime; class CJS_Timer; -class TimerObj : public CJS_EmbedObj -{ -public: - TimerObj(CJS_Object* pJSObject); - virtual ~TimerObj(); - -public: - void SetTimer(CJS_Timer* pTimer); - CJS_Timer* GetTimer() const; - -private: - CJS_Timer* m_pTimer; -}; +class TimerObj : public CJS_EmbedObj { + public: + TimerObj(CJS_Object* pJSObject); + virtual ~TimerObj(); -class CJS_TimerObj : public CJS_Object -{ -public: - CJS_TimerObj(JSFXObject pObject) : CJS_Object(pObject) {} - virtual ~CJS_TimerObj(){} + public: + void SetTimer(CJS_Timer* pTimer); + CJS_Timer* GetTimer() const; - DECLARE_JS_CLASS(CJS_TimerObj); + private: + CJS_Timer* m_pTimer; }; +class CJS_TimerObj : public CJS_Object { + public: + CJS_TimerObj(JSFXObject pObject) : CJS_Object(pObject) {} + virtual ~CJS_TimerObj() {} + + DECLARE_JS_CLASS(CJS_TimerObj); +}; // struct APP_MENUITEM_ARRAY; // // struct APP_MENUITEM // { -// APP_MENUITEM() : oSubMenu(NULL), cName(L""), cReturn(L""), bMarked(false), bEnabled(true) +// APP_MENUITEM() : oSubMenu(NULL), cName(L""), cReturn(L""), +// bMarked(false), bEnabled(true) // { // } // CFX_WideString cName; @@ -103,121 +101,206 @@ public: // HMENU hMenu; // }; -class app : public CJS_EmbedObj -{ -public: - app(CJS_Object * pJSObject); - virtual ~app(); - -public: - FX_BOOL activeDocs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL formsVersion(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL fullscreen(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL language(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL platform(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL runtimeHighlight(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL viewerType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL viewerVariation(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL viewerVersion(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - - - FX_BOOL alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL browseForDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL clearInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL clearTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL execMenuItem(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL findComponent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL goBack(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL goForward(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL launchURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL newFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL newDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL openDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL openFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL popUpMenuEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL popUpMenu(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL response(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL setTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - -private: -// FX_DWORD AppGetTickCount(); - void TimerProc(CJS_Timer* pTimer); - void RunJsScript(CJS_Runtime * pRuntime,const CFX_WideString & wsScript); -// void ParsePopupMenuObj(APP_MENUITEM * ppMenuItem,JSObject * pObj); -// void DeleteMenuItems(APP_MENUITEM_ARRAY * pMenuItems); -// void AddMenuItem(APP_MENUITEM_ARRAY * pMenuItems, HMENU hMenu, MENUITEMINFO MenuItemInfo); -// void InitMenuItemInfo(MENUITEMINFO& MenuItemInfo); -// void DestroyPopUpMenu(); - -// void ParserMenuItem(APP_MENU* pHead, const CJS_Parameters¶ms); -// void AddItemToMenu(APP_MENU* pHead, HMENU hMenu, MENUITEMINFO MenuItemInfo); -// void DestroyMenuItems(APP_MENU* pHead); - -public: - static CFX_WideString SysPathToPDFPath(const CFX_WideString& sOldPath); - -private: - - bool m_bCalculate; - bool m_bRuntimeHighLight; - - CFX_ArrayTemplate m_aTimer; -// APP_MENU* m_pMenuHead; - -public: -// static CReader_App* s_App; +class app : public CJS_EmbedObj { + public: + app(CJS_Object* pJSObject); + virtual ~app(); + + public: + FX_BOOL activeDocs(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL calculate(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL formsVersion(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL fullscreen(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL language(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL platform(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL runtimeHighlight(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL viewerType(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL viewerVariation(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL viewerVersion(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + + FX_BOOL alert(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL beep(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL browseForDoc(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL clearInterval(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL clearTimeOut(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL execDialog(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL execMenuItem(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL findComponent(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL goBack(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL goForward(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL launchURL(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL mailMsg(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL newFDF(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL newDoc(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL openDoc(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL openFDF(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL popUpMenuEx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL popUpMenu(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL response(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL setInterval(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL setTimeOut(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + + private: + // FX_DWORD AppGetTickCount(); + void TimerProc(CJS_Timer* pTimer); + void RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript); + // void ParsePopupMenuObj(APP_MENUITEM * + //ppMenuItem,JSObject * pObj); + // void DeleteMenuItems(APP_MENUITEM_ARRAY * + //pMenuItems); + // void AddMenuItem(APP_MENUITEM_ARRAY * pMenuItems, HMENU + // hMenu, MENUITEMINFO MenuItemInfo); + // void InitMenuItemInfo(MENUITEMINFO& + // MenuItemInfo); + // void DestroyPopUpMenu(); + + // void ParserMenuItem(APP_MENU* pHead, const + // CJS_Parameters¶ms); + // void AddItemToMenu(APP_MENU* pHead, HMENU hMenu, + // MENUITEMINFO MenuItemInfo); + // void DestroyMenuItems(APP_MENU* + // pHead); + + public: + static CFX_WideString SysPathToPDFPath(const CFX_WideString& sOldPath); + + private: + bool m_bCalculate; + bool m_bRuntimeHighLight; + + CFX_ArrayTemplate m_aTimer; + // APP_MENU* m_pMenuHead; + + public: + // static CReader_App* s_App; }; -class CJS_App : public CJS_Object -{ -public: - CJS_App(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_App(void){}; - - DECLARE_JS_CLASS(CJS_App); - - JS_STATIC_PROP(activeDocs, app); - JS_STATIC_PROP(calculate, app); - JS_STATIC_PROP(formsVersion, app); - JS_STATIC_PROP(fs, app); - JS_STATIC_PROP(fullscreen, app); - JS_STATIC_PROP(language, app); - JS_STATIC_PROP(media, app); - JS_STATIC_PROP(platform, app); - JS_STATIC_PROP(runtimeHighlight, app); - JS_STATIC_PROP(viewerType, app); - JS_STATIC_PROP(viewerVariation, app); - JS_STATIC_PROP(viewerVersion, app); - - JS_STATIC_METHOD(alert, app); - JS_STATIC_METHOD(beep, app); - JS_STATIC_METHOD(browseForDoc, app); - JS_STATIC_METHOD(clearInterval, app); - JS_STATIC_METHOD(clearTimeOut, app); - JS_STATIC_METHOD(execDialog, app); - JS_STATIC_METHOD(execMenuItem, app); - JS_STATIC_METHOD(findComponent, app); - JS_STATIC_METHOD(goBack, app); - JS_STATIC_METHOD(goForward, app); - JS_STATIC_METHOD(launchURL, app); - JS_STATIC_METHOD(mailMsg, app); - JS_STATIC_METHOD(newFDF, app); - JS_STATIC_METHOD(newDoc, app); - JS_STATIC_METHOD(openDoc, app); - JS_STATIC_METHOD(openFDF, app); - JS_STATIC_METHOD(popUpMenuEx, app); - JS_STATIC_METHOD(popUpMenu, app); - JS_STATIC_METHOD(response, app); - JS_STATIC_METHOD(setInterval, app); - JS_STATIC_METHOD(setTimeOut, app); - +class CJS_App : public CJS_Object { + public: + CJS_App(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_App(void){}; + + DECLARE_JS_CLASS(CJS_App); + + JS_STATIC_PROP(activeDocs, app); + JS_STATIC_PROP(calculate, app); + JS_STATIC_PROP(formsVersion, app); + JS_STATIC_PROP(fs, app); + JS_STATIC_PROP(fullscreen, app); + JS_STATIC_PROP(language, app); + JS_STATIC_PROP(media, app); + JS_STATIC_PROP(platform, app); + JS_STATIC_PROP(runtimeHighlight, app); + JS_STATIC_PROP(viewerType, app); + JS_STATIC_PROP(viewerVariation, app); + JS_STATIC_PROP(viewerVersion, app); + + JS_STATIC_METHOD(alert, app); + JS_STATIC_METHOD(beep, app); + JS_STATIC_METHOD(browseForDoc, app); + JS_STATIC_METHOD(clearInterval, app); + JS_STATIC_METHOD(clearTimeOut, app); + JS_STATIC_METHOD(execDialog, app); + JS_STATIC_METHOD(execMenuItem, app); + JS_STATIC_METHOD(findComponent, app); + JS_STATIC_METHOD(goBack, app); + JS_STATIC_METHOD(goForward, app); + JS_STATIC_METHOD(launchURL, app); + JS_STATIC_METHOD(mailMsg, app); + JS_STATIC_METHOD(newFDF, app); + JS_STATIC_METHOD(newDoc, app); + JS_STATIC_METHOD(openDoc, app); + JS_STATIC_METHOD(openFDF, app); + JS_STATIC_METHOD(popUpMenuEx, app); + JS_STATIC_METHOD(popUpMenu, app); + JS_STATIC_METHOD(response, app); + JS_STATIC_METHOD(setInterval, app); + JS_STATIC_METHOD(setTimeOut, app); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_APP_H_ diff --git a/fpdfsdk/include/javascript/color.h b/fpdfsdk/include/javascript/color.h index df863b552f..45704efa80 100644 --- a/fpdfsdk/include/javascript/color.h +++ b/fpdfsdk/include/javascript/color.h @@ -10,71 +10,76 @@ #include "JS_Define.h" // TODO(tsepez): include CPWL_Color.h once its own IWYU is fixed. -class color : public CJS_EmbedObj -{ -public: - color(CJS_Object* pJSObject); - virtual ~color(void); +class color : public CJS_EmbedObj { + public: + color(CJS_Object* pJSObject); + virtual ~color(void); - FX_BOOL black(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL blue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL cyan(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL dkGray(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL gray(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL green(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL ltGray(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL magenta(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL red(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL transparent(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL white(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL yellow(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL black(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL blue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL cyan(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL dkGray(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL gray(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL green(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL ltGray(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL magenta(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL red(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL transparent(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL white(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL yellow(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL convert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL equal(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); + FX_BOOL convert(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL equal(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); -public: - static void ConvertPWLColorToArray(const CPWL_Color& color, CJS_Array& array); - static void ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color); + public: + static void ConvertPWLColorToArray(const CPWL_Color& color, CJS_Array& array); + static void ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color); -private: - CPWL_Color m_crTransparent; - CPWL_Color m_crBlack; - CPWL_Color m_crWhite; - CPWL_Color m_crRed; - CPWL_Color m_crGreen; - CPWL_Color m_crBlue; - CPWL_Color m_crCyan; - CPWL_Color m_crMagenta; - CPWL_Color m_crYellow; - CPWL_Color m_crDKGray; - CPWL_Color m_crGray; - CPWL_Color m_crLTGray; + private: + CPWL_Color m_crTransparent; + CPWL_Color m_crBlack; + CPWL_Color m_crWhite; + CPWL_Color m_crRed; + CPWL_Color m_crGreen; + CPWL_Color m_crBlue; + CPWL_Color m_crCyan; + CPWL_Color m_crMagenta; + CPWL_Color m_crYellow; + CPWL_Color m_crDKGray; + CPWL_Color m_crGray; + CPWL_Color m_crLTGray; }; -class CJS_Color : public CJS_Object -{ -public: - CJS_Color(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Color(void){}; +class CJS_Color : public CJS_Object { + public: + CJS_Color(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Color(void){}; - DECLARE_JS_CLASS(CJS_Color); + DECLARE_JS_CLASS(CJS_Color); - JS_STATIC_PROP(black, color); - JS_STATIC_PROP(blue, color); - JS_STATIC_PROP(cyan, color); - JS_STATIC_PROP(dkGray, color); - JS_STATIC_PROP(gray, color); - JS_STATIC_PROP(green, color); - JS_STATIC_PROP(ltGray, color); - JS_STATIC_PROP(magenta, color); - JS_STATIC_PROP(red, color); - JS_STATIC_PROP(transparent, color); - JS_STATIC_PROP(white, color); - JS_STATIC_PROP(yellow, color); - - JS_STATIC_METHOD(convert,color); - JS_STATIC_METHOD(equal,color); + JS_STATIC_PROP(black, color); + JS_STATIC_PROP(blue, color); + JS_STATIC_PROP(cyan, color); + JS_STATIC_PROP(dkGray, color); + JS_STATIC_PROP(gray, color); + JS_STATIC_PROP(green, color); + JS_STATIC_PROP(ltGray, color); + JS_STATIC_PROP(magenta, color); + JS_STATIC_PROP(red, color); + JS_STATIC_PROP(transparent, color); + JS_STATIC_PROP(white, color); + JS_STATIC_PROP(yellow, color); + JS_STATIC_METHOD(convert, color); + JS_STATIC_METHOD(equal, color); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_COLOR_H_ diff --git a/fpdfsdk/include/javascript/console.h b/fpdfsdk/include/javascript/console.h index 0cbc291b44..a04d87b007 100644 --- a/fpdfsdk/include/javascript/console.h +++ b/fpdfsdk/include/javascript/console.h @@ -9,31 +9,41 @@ #include "JS_Define.h" -class console : public CJS_EmbedObj -{ -public: - console(CJS_Object* pJSObject); - virtual ~console(void); - -public: - FX_BOOL clear(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL hide(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL println(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL show(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); +class console : public CJS_EmbedObj { + public: + console(CJS_Object* pJSObject); + virtual ~console(void); + + public: + FX_BOOL clear(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL hide(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL println(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL show(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); }; -class CJS_Console : public CJS_Object -{ -public: - CJS_Console(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Console(void){}; +class CJS_Console : public CJS_Object { + public: + CJS_Console(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Console(void){}; - DECLARE_JS_CLASS(CJS_Console); + DECLARE_JS_CLASS(CJS_Console); - JS_STATIC_METHOD(clear, console); - JS_STATIC_METHOD(hide, console); - JS_STATIC_METHOD(println, console); - JS_STATIC_METHOD(show, console); + JS_STATIC_METHOD(clear, console); + JS_STATIC_METHOD(hide, console); + JS_STATIC_METHOD(println, console); + JS_STATIC_METHOD(show, console); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_CONSOLE_H_ diff --git a/fpdfsdk/include/javascript/event.h b/fpdfsdk/include/javascript/event.h index 91a38ba487..c7c899e69d 100644 --- a/fpdfsdk/include/javascript/event.h +++ b/fpdfsdk/include/javascript/event.h @@ -9,64 +9,81 @@ #include "JS_Define.h" -class event : public CJS_EmbedObj -{ -public: - event(CJS_Object * pJSObject); - virtual ~event(void); - -public: - FX_BOOL change(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL changeEx(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL commitKey(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL fieldFull(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL keyDown(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL modifier(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL rc(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL richChange(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL richChangeEx(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL richValue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL selEnd(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL selStart(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL shift(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL source(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL target(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL targetName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL type(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); - FX_BOOL willCommit(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); +class event : public CJS_EmbedObj { + public: + event(CJS_Object* pJSObject); + virtual ~event(void); + public: + FX_BOOL change(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL changeEx(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL commitKey(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL fieldFull(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL keyDown(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL modifier(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL rc(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL richChange(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL richChangeEx(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL richValue(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL selEnd(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL selStart(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL shift(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL source(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL target(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL targetName(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL type(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); + FX_BOOL willCommit(IFXJS_Context* cc, + CJS_PropValue& vp, + CFX_WideString& sError); }; -class CJS_Event : public CJS_Object -{ -public: - CJS_Event(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Event(void){}; +class CJS_Event : public CJS_Object { + public: + CJS_Event(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Event(void){}; - DECLARE_JS_CLASS(CJS_Event); + DECLARE_JS_CLASS(CJS_Event); - JS_STATIC_PROP(change, event); - JS_STATIC_PROP(changeEx, event); - JS_STATIC_PROP(commitKey, event); - JS_STATIC_PROP(fieldFull, event); - JS_STATIC_PROP(keyDown, event); - JS_STATIC_PROP(modifier, event); - JS_STATIC_PROP(name, event); - JS_STATIC_PROP(rc, event); - JS_STATIC_PROP(richChange, event); - JS_STATIC_PROP(richChangeEx, event); - JS_STATIC_PROP(richValue, event); - JS_STATIC_PROP(selEnd, event); - JS_STATIC_PROP(selStart, event); - JS_STATIC_PROP(shift, event); - JS_STATIC_PROP(source, event); - JS_STATIC_PROP(target, event); - JS_STATIC_PROP(targetName, event); - JS_STATIC_PROP(type, event); - JS_STATIC_PROP(value, event); - JS_STATIC_PROP(willCommit, event); + JS_STATIC_PROP(change, event); + JS_STATIC_PROP(changeEx, event); + JS_STATIC_PROP(commitKey, event); + JS_STATIC_PROP(fieldFull, event); + JS_STATIC_PROP(keyDown, event); + JS_STATIC_PROP(modifier, event); + JS_STATIC_PROP(name, event); + JS_STATIC_PROP(rc, event); + JS_STATIC_PROP(richChange, event); + JS_STATIC_PROP(richChangeEx, event); + JS_STATIC_PROP(richValue, event); + JS_STATIC_PROP(selEnd, event); + JS_STATIC_PROP(selStart, event); + JS_STATIC_PROP(shift, event); + JS_STATIC_PROP(source, event); + JS_STATIC_PROP(target, event); + JS_STATIC_PROP(targetName, event); + JS_STATIC_PROP(type, event); + JS_STATIC_PROP(value, event); + JS_STATIC_PROP(willCommit, event); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_EVENT_H_ diff --git a/fpdfsdk/include/javascript/global.h b/fpdfsdk/include/javascript/global.h index 83e07f67c3..303ac76a3e 100644 --- a/fpdfsdk/include/javascript/global.h +++ b/fpdfsdk/include/javascript/global.h @@ -13,77 +13,82 @@ class CJS_GlobalData; class CJS_GlobalVariableArray; class CJS_KeyValue; -struct js_global_data -{ - js_global_data() - { - nType = 0; - dData = 0; - bData = FALSE; - sData = ""; - bPersistent = FALSE; - bDeleted = FALSE; - } - - ~js_global_data() - { - pData.Reset(); - } - int nType; //0:int 1:bool 2:string 3:obj - double dData; - bool bData; - CFX_ByteString sData; - v8::Global pData; - bool bPersistent; - bool bDeleted; +struct js_global_data { + js_global_data() { + nType = 0; + dData = 0; + bData = FALSE; + sData = ""; + bPersistent = FALSE; + bDeleted = FALSE; + } + + ~js_global_data() { pData.Reset(); } + int nType; // 0:int 1:bool 2:string 3:obj + double dData; + bool bData; + CFX_ByteString sData; + v8::Global pData; + bool bPersistent; + bool bDeleted; }; -class global_alternate : public CJS_EmbedObj -{ -public: - global_alternate(CJS_Object* pJSObject); - virtual ~global_alternate(); - -public: - FX_BOOL setPersistent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - -public: - FX_BOOL QueryProperty(const FX_WCHAR* propname); - FX_BOOL DoProperty(IFXJS_Context* cc, const FX_WCHAR* propname, CJS_PropValue & vp, CFX_WideString & sError); - FX_BOOL DelProperty(IFXJS_Context* cc, const FX_WCHAR* propname, CFX_WideString & sError); - - void Initial(CPDFDoc_Environment* pApp); - -private: - void UpdateGlobalPersistentVariables(); - void CommitGlobalPersisitentVariables(); - void DestroyGlobalPersisitentVariables(); - FX_BOOL SetGlobalVariables(const FX_CHAR* propname, int nType, - double dData, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPersistent); - - void ObjectToArray(v8::Local pObj, CJS_GlobalVariableArray& array); - void PutObjectProperty(v8::Local obj, CJS_KeyValue* pData); - -private: - CFX_MapByteStringToPtr m_mapGlobal; - CFX_WideString m_sFilePath; - CJS_GlobalData* m_pGlobalData; - CPDFDoc_Environment* m_pApp; +class global_alternate : public CJS_EmbedObj { + public: + global_alternate(CJS_Object* pJSObject); + virtual ~global_alternate(); + + public: + FX_BOOL setPersistent(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + + public: + FX_BOOL QueryProperty(const FX_WCHAR* propname); + FX_BOOL DoProperty(IFXJS_Context* cc, + const FX_WCHAR* propname, + CJS_PropValue& vp, + CFX_WideString& sError); + FX_BOOL DelProperty(IFXJS_Context* cc, + const FX_WCHAR* propname, + CFX_WideString& sError); + + void Initial(CPDFDoc_Environment* pApp); + + private: + void UpdateGlobalPersistentVariables(); + void CommitGlobalPersisitentVariables(); + void DestroyGlobalPersisitentVariables(); + FX_BOOL SetGlobalVariables(const FX_CHAR* propname, + int nType, + double dData, + bool bData, + const CFX_ByteString& sData, + JSObject pData, + bool bDefaultPersistent); + + void ObjectToArray(v8::Local pObj, + CJS_GlobalVariableArray& array); + void PutObjectProperty(v8::Local obj, CJS_KeyValue* pData); + + private: + CFX_MapByteStringToPtr m_mapGlobal; + CFX_WideString m_sFilePath; + CJS_GlobalData* m_pGlobalData; + CPDFDoc_Environment* m_pApp; }; +class CJS_Global : public CJS_Object { + public: + CJS_Global(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Global(void){}; -class CJS_Global : public CJS_Object -{ -public: - CJS_Global(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Global(void){}; + virtual FX_BOOL InitInstance(IFXJS_Context* cc); - virtual FX_BOOL InitInstance(IFXJS_Context* cc); - - DECLARE_SPECIAL_JS_CLASS(CJS_Global); - - JS_SPECIAL_STATIC_METHOD(setPersistent, global_alternate, global); + DECLARE_SPECIAL_JS_CLASS(CJS_Global); + JS_SPECIAL_STATIC_METHOD(setPersistent, global_alternate, global); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ diff --git a/fpdfsdk/include/javascript/report.h b/fpdfsdk/include/javascript/report.h index 56f742ce08..a9004fd46a 100644 --- a/fpdfsdk/include/javascript/report.h +++ b/fpdfsdk/include/javascript/report.h @@ -9,28 +9,32 @@ #include "JS_Define.h" -class Report : public CJS_EmbedObj -{ -public: - Report(CJS_Object * pJSObject); - virtual ~Report(); - -public: - FX_BOOL save(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL writeText(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); +class Report : public CJS_EmbedObj { + public: + Report(CJS_Object* pJSObject); + virtual ~Report(); + + public: + FX_BOOL save(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL writeText(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); }; -class CJS_Report : public CJS_Object -{ -public: - CJS_Report(JSFXObject pObject) : CJS_Object(pObject){}; - virtual ~CJS_Report(){}; +class CJS_Report : public CJS_Object { + public: + CJS_Report(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Report(){}; -public: - DECLARE_JS_CLASS(CJS_Report); + public: + DECLARE_JS_CLASS(CJS_Report); - JS_STATIC_METHOD(save, Report) - JS_STATIC_METHOD(writeText, Report); + JS_STATIC_METHOD(save, Report) + JS_STATIC_METHOD(writeText, Report); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_REPORT_H_ diff --git a/fpdfsdk/include/javascript/resource.h b/fpdfsdk/include/javascript/resource.h index 433785984d..80629cf2ae 100644 --- a/fpdfsdk/include/javascript/resource.h +++ b/fpdfsdk/include/javascript/resource.h @@ -8,28 +8,28 @@ #define FPDFSDK_INCLUDE_JAVASCRIPT_RESOURCE_H_ #include "../../../core/include/fxcrt/fx_string.h" // For CFX_WideString. -#include "../fsdk_define.h" // For FX_UINT. +#include "../fsdk_define.h" // For FX_UINT. class CJS_Context; -#define IDS_STRING_JSALERT 25613 -#define IDS_STRING_JSPARAMERROR 25614 +#define IDS_STRING_JSALERT 25613 +#define IDS_STRING_JSPARAMERROR 25614 #define IDS_STRING_JSAFNUMBER_KEYSTROKE 25615 -#define IDS_STRING_JSPARAM_TOOLONG 25617 -#define IDS_STRING_JSPARSEDATE 25618 -#define IDS_STRING_JSRANGE1 25619 -#define IDS_STRING_JSRANGE2 25620 -#define IDS_STRING_JSRANGE3 25621 -#define IDS_STRING_NOTSUPPORT 25627 -#define IDS_STRING_JSBUSY 25628 -#define IDS_STRING_JSEVENT 25629 -#define IDS_STRING_RUN 25630 -#define IDS_STRING_JSPRINT1 25632 -#define IDS_STRING_JSPRINT2 25633 -#define IDS_STRING_JSNOGLOBAL 25635 -#define IDS_STRING_JSREADONLY 25636 -#define IDS_STRING_JSTYPEERROR 25637 -#define IDS_STRING_JSVALUEERROR 25638 +#define IDS_STRING_JSPARAM_TOOLONG 25617 +#define IDS_STRING_JSPARSEDATE 25618 +#define IDS_STRING_JSRANGE1 25619 +#define IDS_STRING_JSRANGE2 25620 +#define IDS_STRING_JSRANGE3 25621 +#define IDS_STRING_NOTSUPPORT 25627 +#define IDS_STRING_JSBUSY 25628 +#define IDS_STRING_JSEVENT 25629 +#define IDS_STRING_RUN 25630 +#define IDS_STRING_JSPRINT1 25632 +#define IDS_STRING_JSPRINT2 25633 +#define IDS_STRING_JSNOGLOBAL 25635 +#define IDS_STRING_JSREADONLY 25636 +#define IDS_STRING_JSTYPEERROR 25637 +#define IDS_STRING_JSVALUEERROR 25638 CFX_WideString JSGetStringFromID(CJS_Context* pContext, FX_UINT id); CFX_WideString JSFormatErrorString(const char* class_name, diff --git a/fpdfsdk/include/javascript/util.h b/fpdfsdk/include/javascript/util.h index ca4db349da..2e65bd3f58 100644 --- a/fpdfsdk/include/javascript/util.h +++ b/fpdfsdk/include/javascript/util.h @@ -11,40 +11,58 @@ #include "JS_Define.h" -class util : public CJS_EmbedObj -{ -public: - util(CJS_Object * pJSObject); - virtual ~util(void); - -public: - FX_BOOL printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL printx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL scand(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - FX_BOOL byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - -public: - static void printd(const std::wstring &cFormat,CJS_Date Date,bool bXFAPicture, std::wstring &cPurpose); - static void printx(const std::string &cFormat,const std::string &cSource, std::string &cPurpose); - static int ParstDataType(std::wstring* sFormat); +class util : public CJS_EmbedObj { + public: + util(CJS_Object* pJSObject); + virtual ~util(void); + + public: + FX_BOOL printd(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL printf(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL printx(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL scand(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + FX_BOOL byteToChar(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError); + + public: + static void printd(const std::wstring& cFormat, + CJS_Date Date, + bool bXFAPicture, + std::wstring& cPurpose); + static void printx(const std::string& cFormat, + const std::string& cSource, + std::string& cPurpose); + static int ParstDataType(std::wstring* sFormat); }; -class CJS_Util : public CJS_Object -{ -public: - CJS_Util(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Util(void){}; +class CJS_Util : public CJS_Object { + public: + CJS_Util(JSFXObject pObject) : CJS_Object(pObject){}; + virtual ~CJS_Util(void){}; - DECLARE_JS_CLASS(CJS_Util); + DECLARE_JS_CLASS(CJS_Util); - JS_STATIC_METHOD(printd, util); - JS_STATIC_METHOD(printf, util); - JS_STATIC_METHOD(printx, util); - JS_STATIC_METHOD(scand, util); - JS_STATIC_METHOD(byteToChar, util); + JS_STATIC_METHOD(printd, util); + JS_STATIC_METHOD(printf, util); + JS_STATIC_METHOD(printx, util); + JS_STATIC_METHOD(scand, util); + JS_STATIC_METHOD(byteToChar, util); }; -int64_t FX_atoi64(const char *nptr); +int64_t FX_atoi64(const char* nptr); #endif // FPDFSDK_INCLUDE_JAVASCRIPT_UTIL_H_ diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h index e291898701..72f2a5de01 100644 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ b/fpdfsdk/include/jsapi/fxjs_v8.h @@ -13,127 +13,202 @@ #include #include "../../../core/include/fxcrt/fx_string.h" // For CFX_WideString -typedef v8::Value JSValue; -typedef v8::Local JSObject; -typedef v8::Local JSFXObject; - -enum FXJSOBJTYPE -{ - JS_DYNAMIC = 0, - JS_STATIC = 1, +typedef v8::Value JSValue; +typedef v8::Local JSObject; +typedef v8::Local JSFXObject; + +enum FXJSOBJTYPE { + JS_DYNAMIC = 0, + JS_STATIC = 1, }; -enum FXJSVALUETYPE -{ - VT_unknown, - VT_string, - VT_number, - VT_boolean, - VT_date, - VT_object, - VT_fxobject, - VT_null, - VT_undefined +enum FXJSVALUETYPE { + VT_unknown, + VT_string, + VT_number, + VT_boolean, + VT_date, + VT_object, + VT_fxobject, + VT_null, + VT_undefined }; -struct FXJSErr -{ - const wchar_t* message; - const wchar_t* srcline; - unsigned linnum; +struct FXJSErr { + const wchar_t* message; + const wchar_t* srcline; + unsigned linnum; }; -/* --------------------------------------------- API --------------------------------------------- */ +/* --------------------------------------------- API + * --------------------------------------------- */ typedef v8::Isolate IJS_Runtime; class IFXJS_Context; class IFXJS_Runtime; -typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, v8::Local obj, v8::Local global); +typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, + v8::Local obj, + v8::Local global); typedef void (*LP_DESTRUCTOR)(v8::Local obj); - -int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor); -int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall); -int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut); -int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallback pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterCallback pPropPut, v8::NamedPropertyDeleterCallback pPropDel); -int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Local pDefault); -int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall); -int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Local pDefault); - -void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Global& v8PersistentContext); -void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Global& v8PersistentContext); -void JS_Initial(unsigned int embedderDataSlot); -void JS_Release(); -int JS_Parse(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror); -int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror); -v8::Local JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID); -v8::Local JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID); -void JS_SetThisObj(IJS_Runtime* pJSRuntime, int nThisObjID); -v8::Local JS_GetThisObj(IJS_Runtime * pJSRuntime); -int JS_GetObjDefnID(v8::Local pObj); -IJS_Runtime* JS_GetRuntime(v8::Local pObj); -int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName); -void JS_Error(v8::Isolate* isolate, const CFX_WideString& message); -unsigned JS_CalcHash(const wchar_t* main, unsigned nLen); -unsigned JS_CalcHash(const wchar_t* main); -const wchar_t* JS_GetTypeof(v8::Local pObj); -void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Local pObj, void* p); -void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Local pObj); -void JS_SetPrivate(v8::Local pObj, void* p); -void* JS_GetPrivate(v8::Local pObj); -void JS_FreePrivate(void* p); -void JS_FreePrivate(v8::Local pObj); -v8::Local JS_GetObjectValue(v8::Local pObj); -v8::Local JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Local pObj,const wchar_t* PropertyName); -v8::Local JS_GetObjectElementNames(IJS_Runtime* pJSRuntime, v8::Local pObj); -void JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, const wchar_t* sValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, int nValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, float fValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, double dValue); -void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, bool bValue); -void JS_PutObjectObject(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, v8::Local pPut); -void JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName); -unsigned JS_PutArrayElement(IJS_Runtime* pJSRuntime, v8::Local pArray,unsigned index,v8::Local pValue,FXJSVALUETYPE eType); -v8::Local JS_GetArrayElement(IJS_Runtime* pJSRuntime, v8::Local pArray,unsigned index); -unsigned JS_GetArrayLength(v8::Local pArray); -v8::Local JS_GetListValue(IJS_Runtime* pJSRuntime, v8::Local pList, int index); - - -v8::Local JS_NewArray(IJS_Runtime* pJSRuntime); -v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,int number); -v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,double number); -v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,float number); -v8::Local JS_NewBoolean(IJS_Runtime* pJSRuntime,bool b); -v8::Local JS_NewObject(IJS_Runtime* pJSRuntime,v8::Local pObj); -v8::Local JS_NewObject2(IJS_Runtime* pJSRuntime,v8::Local pObj); -v8::Local JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string); -v8::Local JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen); -v8::Local JS_NewNull(); -v8::Local JS_NewDate(IJS_Runtime* pJSRuntime,double d); -v8::Local JS_NewValue(IJS_Runtime* pJSRuntime); - - -int JS_ToInt32(IJS_Runtime* pJSRuntime, v8::Local pValue); -bool JS_ToBoolean(IJS_Runtime* pJSRuntime, v8::Local pValue); -double JS_ToNumber(IJS_Runtime* pJSRuntime, v8::Local pValue); -v8::Local JS_ToObject(IJS_Runtime* pJSRuntime, v8::Local pValue); -CFX_WideString JS_ToString(IJS_Runtime* pJSRuntime, v8::Local pValue); -v8::Local JS_ToArray(IJS_Runtime* pJSRuntime, v8::Local pValue); -void JS_ValueCopy(v8::Local& pTo, v8::Local pFrom); - -double JS_GetDateTime(); -int JS_GetYearFromTime(double dt); -int JS_GetMonthFromTime(double dt); -int JS_GetDayFromTime(double dt); -int JS_GetHourFromTime(double dt); -int JS_GetMinFromTime(double dt); -int JS_GetSecFromTime(double dt); -double JS_DateParse(const wchar_t* string); -double JS_MakeDay(int nYear, int nMonth, int nDay); -double JS_MakeTime(int nHour, int nMin, int nSec, int nMs); -double JS_MakeDate(double day, double time); -bool JS_PortIsNan(double d); -double JS_LocalTime(double d); +int JS_DefineObj(IJS_Runtime* pJSRuntime, + const wchar_t* sObjName, + FXJSOBJTYPE eObjType, + LP_CONSTRUCTOR pConstructor, + LP_DESTRUCTOR pDestructor); +int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, + int nObjDefnID, + const wchar_t* sMethodName, + v8::FunctionCallback pMethodCall); +int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, + int nObjDefnID, + const wchar_t* sPropName, + v8::AccessorGetterCallback pPropGet, + v8::AccessorSetterCallback pPropPut); +int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, + int nObjDefnID, + v8::NamedPropertyQueryCallback pPropQurey, + v8::NamedPropertyGetterCallback pPropGet, + v8::NamedPropertySetterCallback pPropPut, + v8::NamedPropertyDeleterCallback pPropDel); +int JS_DefineObjConst(IJS_Runtime* pJSRuntime, + int nObjDefnID, + const wchar_t* sConstName, + v8::Local pDefault); +int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, + const wchar_t* sMethodName, + v8::FunctionCallback pMethodCall); +int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, + const wchar_t* sConstName, + v8::Local pDefault); + +void JS_InitialRuntime(IJS_Runtime* pJSRuntime, + IFXJS_Runtime* pFXRuntime, + IFXJS_Context* context, + v8::Global& v8PersistentContext); +void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, + v8::Global& v8PersistentContext); +void JS_Initial(unsigned int embedderDataSlot); +void JS_Release(); +int JS_Parse(IJS_Runtime* pJSRuntime, + IFXJS_Context* pJSContext, + const wchar_t* script, + long length, + FXJSErr* perror); +int JS_Execute(IJS_Runtime* pJSRuntime, + IFXJS_Context* pJSContext, + const wchar_t* script, + long length, + FXJSErr* perror); +v8::Local JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, + IFXJS_Context* pJSContext, + int nObjDefnID); +v8::Local JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID); +void JS_SetThisObj(IJS_Runtime* pJSRuntime, int nThisObjID); +v8::Local JS_GetThisObj(IJS_Runtime* pJSRuntime); +int JS_GetObjDefnID(v8::Local pObj); +IJS_Runtime* JS_GetRuntime(v8::Local pObj); +int JS_GetObjDefnID(IJS_Runtime* pJSRuntime, const wchar_t* pObjName); +void JS_Error(v8::Isolate* isolate, const CFX_WideString& message); +unsigned JS_CalcHash(const wchar_t* main, unsigned nLen); +unsigned JS_CalcHash(const wchar_t* main); +const wchar_t* JS_GetTypeof(v8::Local pObj); +void JS_SetPrivate(IJS_Runtime* pJSRuntime, + v8::Local pObj, + void* p); +void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Local pObj); +void JS_SetPrivate(v8::Local pObj, void* p); +void* JS_GetPrivate(v8::Local pObj); +void JS_FreePrivate(void* p); +void JS_FreePrivate(v8::Local pObj); +v8::Local JS_GetObjectValue(v8::Local pObj); +v8::Local JS_GetObjectElement(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName); +v8::Local JS_GetObjectElementNames(IJS_Runtime* pJSRuntime, + v8::Local pObj); +void JS_PutObjectString(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName, + const wchar_t* sValue); +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName, + int nValue); +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName, + float fValue); +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName, + double dValue); +void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName, + bool bValue); +void JS_PutObjectObject(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName, + v8::Local pPut); +void JS_PutObjectNull(IJS_Runtime* pJSRuntime, + v8::Local pObj, + const wchar_t* PropertyName); +unsigned JS_PutArrayElement(IJS_Runtime* pJSRuntime, + v8::Local pArray, + unsigned index, + v8::Local pValue, + FXJSVALUETYPE eType); +v8::Local JS_GetArrayElement(IJS_Runtime* pJSRuntime, + v8::Local pArray, + unsigned index); +unsigned JS_GetArrayLength(v8::Local pArray); +v8::Local JS_GetListValue(IJS_Runtime* pJSRuntime, + v8::Local pList, + int index); + +v8::Local JS_NewArray(IJS_Runtime* pJSRuntime); +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime, int number); +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime, double number); +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime, float number); +v8::Local JS_NewBoolean(IJS_Runtime* pJSRuntime, bool b); +v8::Local JS_NewObject(IJS_Runtime* pJSRuntime, + v8::Local pObj); +v8::Local JS_NewObject2(IJS_Runtime* pJSRuntime, + v8::Local pObj); +v8::Local JS_NewString(IJS_Runtime* pJSRuntime, + const wchar_t* string); +v8::Local JS_NewString(IJS_Runtime* pJSRuntime, + const wchar_t* string, + unsigned nLen); +v8::Local JS_NewNull(); +v8::Local JS_NewDate(IJS_Runtime* pJSRuntime, double d); +v8::Local JS_NewValue(IJS_Runtime* pJSRuntime); + +int JS_ToInt32(IJS_Runtime* pJSRuntime, v8::Local pValue); +bool JS_ToBoolean(IJS_Runtime* pJSRuntime, v8::Local pValue); +double JS_ToNumber(IJS_Runtime* pJSRuntime, v8::Local pValue); +v8::Local JS_ToObject(IJS_Runtime* pJSRuntime, + v8::Local pValue); +CFX_WideString JS_ToString(IJS_Runtime* pJSRuntime, + v8::Local pValue); +v8::Local JS_ToArray(IJS_Runtime* pJSRuntime, + v8::Local pValue); +void JS_ValueCopy(v8::Local& pTo, v8::Local pFrom); + +double JS_GetDateTime(); +int JS_GetYearFromTime(double dt); +int JS_GetMonthFromTime(double dt); +int JS_GetDayFromTime(double dt); +int JS_GetHourFromTime(double dt); +int JS_GetMinFromTime(double dt); +int JS_GetSecFromTime(double dt); +double JS_DateParse(const wchar_t* string); +double JS_MakeDay(int nYear, int nMonth, int nDay); +double JS_MakeTime(int nHour, int nMin, int nSec, int nMs); +double JS_MakeDate(double day, double time); +bool JS_PortIsNan(double d); +double JS_LocalTime(double d); #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Button.h b/fpdfsdk/include/pdfwindow/PWL_Button.h index 4937841819..363556762f 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Button.h +++ b/fpdfsdk/include/pdfwindow/PWL_Button.h @@ -9,19 +9,18 @@ #include "PWL_Wnd.h" -class CPWL_Button : public CPWL_Wnd -{ -public: - CPWL_Button(); - virtual ~CPWL_Button(); +class CPWL_Button : public CPWL_Wnd { + public: + CPWL_Button(); + virtual ~CPWL_Button(); - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); + virtual CFX_ByteString GetClassName() const; + virtual void OnCreate(PWL_CREATEPARAM& cp); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); -protected: - FX_BOOL m_bMouseDown; + protected: + FX_BOOL m_bMouseDown; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_BUTTON_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Caret.h b/fpdfsdk/include/pdfwindow/PWL_Caret.h index 6838bc49e7..7e61eeb66e 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Caret.h +++ b/fpdfsdk/include/pdfwindow/PWL_Caret.h @@ -9,45 +9,43 @@ #include "PWL_Wnd.h" -struct PWL_CARET_INFO -{ -public: - PWL_CARET_INFO() : bVisible(FALSE), ptHead(0,0), ptFoot(0,0) - { - } - - FX_BOOL bVisible; - CPDF_Point ptHead; - CPDF_Point ptFoot; -}; +struct PWL_CARET_INFO { + public: + PWL_CARET_INFO() : bVisible(FALSE), ptHead(0, 0), ptFoot(0, 0) {} + FX_BOOL bVisible; + CPDF_Point ptHead; + CPDF_Point ptFoot; +}; -class CPWL_Caret : public CPWL_Wnd -{ -public: - CPWL_Caret(); - virtual ~CPWL_Caret(); - - virtual CFX_ByteString GetClassName() const; - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void InvalidateRect(CPDF_Rect * pRect = NULL); - virtual void SetVisible(FX_BOOL bVisible) {} - virtual void TimerProc(); - void SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot); - CFX_ByteString GetCaretAppearanceStream(const CPDF_Point & ptOffset); - void SetInvalidRect(CPDF_Rect rc) {m_rcInvalid = rc;} - -private: - void GetCaretApp(CFX_ByteTextBuf & sAppStream,const CPDF_Point & ptOffset); - CPDF_Rect GetCaretRect() const; - - FX_BOOL m_bFlash; - CPDF_Point m_ptHead; - CPDF_Point m_ptFoot; - FX_FLOAT m_fWidth; - int32_t m_nDelay; - CPDF_Rect m_rcInvalid; +class CPWL_Caret : public CPWL_Wnd { + public: + CPWL_Caret(); + virtual ~CPWL_Caret(); + + virtual CFX_ByteString GetClassName() const; + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual void InvalidateRect(CPDF_Rect* pRect = NULL); + virtual void SetVisible(FX_BOOL bVisible) {} + virtual void TimerProc(); + void SetCaret(FX_BOOL bVisible, + const CPDF_Point& ptHead, + const CPDF_Point& ptFoot); + CFX_ByteString GetCaretAppearanceStream(const CPDF_Point& ptOffset); + void SetInvalidRect(CPDF_Rect rc) { m_rcInvalid = rc; } + + private: + void GetCaretApp(CFX_ByteTextBuf& sAppStream, const CPDF_Point& ptOffset); + CPDF_Rect GetCaretRect() const; + + FX_BOOL m_bFlash; + CPDF_Point m_ptHead; + CPDF_Point m_ptFoot; + FX_FLOAT m_fWidth; + int32_t m_nDelay; + CPDF_Rect m_rcInvalid; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_CARET_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_ComboBox.h b/fpdfsdk/include/pdfwindow/PWL_ComboBox.h index 7a86ccd0c2..98ae7ca986 100644 --- a/fpdfsdk/include/pdfwindow/PWL_ComboBox.h +++ b/fpdfsdk/include/pdfwindow/PWL_ComboBox.h @@ -11,108 +11,108 @@ #include "PWL_ListBox.h" #include "PWL_Wnd.h" -class CPWL_CBEdit : public CPWL_Edit -{ -public: - CPWL_CBEdit(){}; - virtual ~CPWL_CBEdit(){}; +class CPWL_CBEdit : public CPWL_Edit { + public: + CPWL_CBEdit(){}; + virtual ~CPWL_CBEdit(){}; }; -class CPWL_CBListBox : public CPWL_ListBox -{ -public: - CPWL_CBListBox(){}; - virtual ~CPWL_CBListBox(){}; +class CPWL_CBListBox : public CPWL_ListBox { + public: + CPWL_CBListBox(){}; + virtual ~CPWL_CBListBox(){}; -public: - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); + public: + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); - FX_BOOL OnKeyDownWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag); - FX_BOOL OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag); + FX_BOOL OnKeyDownWithExit(FX_WORD nChar, FX_BOOL& bExit, FX_DWORD nFlag); + FX_BOOL OnCharWithExit(FX_WORD nChar, FX_BOOL& bExit, FX_DWORD nFlag); }; -#define PWL_COMBOBOX_BUTTON_WIDTH 13 +#define PWL_COMBOBOX_BUTTON_WIDTH 13 -class CPWL_CBButton : public CPWL_Wnd -{ -public: - CPWL_CBButton(){}; - virtual ~CPWL_CBButton(){}; +class CPWL_CBButton : public CPWL_Wnd { + public: + CPWL_CBButton(){}; + virtual ~CPWL_CBButton(){}; -public: - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); + public: + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); }; -class CPWL_ComboBox : public CPWL_Wnd -{ -public: - CPWL_ComboBox(); - operator CPWL_Edit* () {return m_pEdit;} +class CPWL_ComboBox : public CPWL_Wnd { + public: + CPWL_ComboBox(); + operator CPWL_Edit*() { return m_pEdit; } + + public: + virtual CFX_ByteString GetClassName() const; + virtual void OnCreate(PWL_CREATEPARAM& cp); -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); + virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); + virtual CPDF_Rect GetFocusRect() const; - virtual CPDF_Rect GetFocusRect() const; + virtual void SetFocus(); + virtual void KillFocus(); - virtual void SetFocus(); - virtual void KillFocus(); + FX_BOOL IsModified() const; - FX_BOOL IsModified() const; + public: + void SetFillerNotify(IPWL_Filler_Notify* pNotify); -public: - void SetFillerNotify(IPWL_Filler_Notify* pNotify); + CFX_WideString GetText() const; + void SetText(const FX_WCHAR* text); - CFX_WideString GetText() const; - void SetText(const FX_WCHAR* text); + void AddString(const FX_WCHAR* string); + int32_t GetSelect() const; + void SetSelect(int32_t nItemIndex); - void AddString(const FX_WCHAR* string); - int32_t GetSelect() const; - void SetSelect(int32_t nItemIndex); + void SetEditSel(int32_t nStartChar, int32_t nEndChar); + void GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const; + void Clear(); + void SelectAll(); + FX_BOOL IsPopup() const; - void SetEditSel(int32_t nStartChar,int32_t nEndChar); - void GetEditSel(int32_t & nStartChar, int32_t & nEndChar ) const; - void Clear(); - void SelectAll(); - FX_BOOL IsPopup() const; + void SetSelectText(); - void SetSelectText(); + private: + void CreateEdit(const PWL_CREATEPARAM& cp); + void CreateButton(const PWL_CREATEPARAM& cp); + void CreateListBox(const PWL_CREATEPARAM& cp); -private: - void CreateEdit(const PWL_CREATEPARAM & cp); - void CreateButton(const PWL_CREATEPARAM & cp); - void CreateListBox(const PWL_CREATEPARAM & cp); + void SetPopup(FX_BOOL bPopup); - void SetPopup(FX_BOOL bPopup); + private: + CPWL_CBEdit* m_pEdit; + CPWL_CBButton* m_pButton; + CPWL_CBListBox* m_pList; -private: - CPWL_CBEdit* m_pEdit; - CPWL_CBButton* m_pButton; - CPWL_CBListBox* m_pList; + FX_BOOL m_bPopup; + CPDF_Rect m_rcOldWindow; + int32_t m_nPopupWhere; + int32_t m_nSelectItem; + IPWL_Filler_Notify* m_pFillerNotify; - FX_BOOL m_bPopup; - CPDF_Rect m_rcOldWindow; - int32_t m_nPopupWhere; - int32_t m_nSelectItem; - IPWL_Filler_Notify* m_pFillerNotify; + public: + void AttachFFLData(void* pData) { m_pFormFiller = pData; } -public: - void AttachFFLData(void* pData) {m_pFormFiller = pData;} -private: - void* m_pFormFiller; + private: + void* m_pFormFiller; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_COMBOBOX_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Edit.h b/fpdfsdk/include/pdfwindow/PWL_Edit.h index 5c90ff704b..ea1b3ef636 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Edit.h +++ b/fpdfsdk/include/pdfwindow/PWL_Edit.h @@ -15,128 +15,164 @@ class CPWL_Edit; class IPWL_Filler_Notify; class IPWL_SpellCheck; -class IPWL_Filler_Notify -{ -public: - virtual ~IPWL_Filler_Notify() { } - virtual void QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, - int32_t & nRet, FX_FLOAT & fPopupRet) = 0; //nRet: (0:bottom 1:top) - virtual void OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode, - CFX_WideString & strChange, const CFX_WideString& strChangeEx, - int nSelStart, int nSelEnd, - FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) = 0; - virtual void OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) = 0; +class IPWL_Filler_Notify { + public: + virtual ~IPWL_Filler_Notify() {} + virtual void QueryWherePopup( + void* pPrivateData, + FX_FLOAT fPopupMin, + FX_FLOAT fPopupMax, + int32_t& nRet, + FX_FLOAT& fPopupRet) = 0; // nRet: (0:bottom 1:top) + virtual void OnBeforeKeyStroke(FX_BOOL bEditOrList, + void* pPrivateData, + int32_t nKeyCode, + CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + int nSelStart, + int nSelEnd, + FX_BOOL bKeyDown, + FX_BOOL& bRC, + FX_BOOL& bExit, + FX_DWORD nFlag) = 0; + virtual void OnAfterKeyStroke(FX_BOOL bEditOrList, + void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag) = 0; }; -class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify -{ -public: - CPWL_Edit(); - virtual ~CPWL_Edit(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnDestroy(); - virtual void OnCreated(); - virtual void RePosChildWnd(); - virtual CPDF_Rect GetClientRect() const; - - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - - virtual CPDF_Rect GetFocusRect() const; - -public: - void SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat = PEAH_LEFT, FX_BOOL bPaint = TRUE); //0:left 1:right 2:middle - void SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat = PEAV_TOP, FX_BOOL bPaint = TRUE); //0:top 1:bottom 2:center - - void SetCharArray(int32_t nCharArray); - void SetLimitChar(int32_t nLimitChar); - - void SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint = TRUE); - void SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint = TRUE); - - void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE); - - void EnableSpellCheck(FX_BOOL bEnabled); - - FX_BOOL CanSelectAll() const; - FX_BOOL CanClear() const; - FX_BOOL CanCopy() const; - FX_BOOL CanCut() const; - FX_BOOL CanPaste() const; - - virtual void CopyText(); - virtual void PasteText(); - virtual void CutText(); - - virtual void SetText(const FX_WCHAR* csText); - void ReplaceSel(const FX_WCHAR* csText); - - CFX_ByteString GetTextAppearanceStream(const CPDF_Point & ptOffset) const; - CFX_ByteString GetCaretAppearanceStream(const CPDF_Point & ptOffset) const; - CFX_ByteString GetSelectAppearanceStream(const CPDF_Point & ptOffset) const; - - FX_BOOL IsTextFull() const; - - static FX_FLOAT GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, int32_t nCharArray); - - void SetFillerNotify(IPWL_Filler_Notify* pNotify) {m_pFillerNotify = pNotify;} - - void GeneratePageObjects(CPDF_PageObjects* pPageObjects, - const CPDF_Point& ptOffset, CFX_ArrayTemplate& ObjArray); - void GeneratePageObjects(CPDF_PageObjects* pPageObjects, - const CPDF_Point& ptOffset); - -protected: - virtual void OnSetFocus(); - virtual void OnKillFocus(); - -protected: - virtual void OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnAddUndo(IFX_Edit_UndoItem* pUndoItem); - -private: - CPVT_WordRange GetSelectWordRange() const; - virtual void ShowVScrollBar(FX_BOOL bShow); - FX_BOOL IsVScrollBarVisible() const; - void SetParamByFlag(); - - FX_FLOAT GetCharArrayAutoFontSize(int32_t nCharArray); - CPDF_Point GetWordRightBottomPoint(const CPVT_WordPlace& wpWord); - - CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2); - CPVT_WordRange GetLatinWordsRange(const CPDF_Point & point) const; - CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace & place) const; - CPVT_WordRange GetArabicWordsRange(const CPVT_WordPlace & place) const; - CPVT_WordRange GetSameWordsRange(const CPVT_WordPlace & place, FX_BOOL bLatin, FX_BOOL bArabic) const; - - void AjustArabicWords(const CPVT_WordRange& wr); -public: - FX_BOOL IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag); -private: - IPWL_Filler_Notify* m_pFillerNotify; - IPWL_SpellCheck* m_pSpellCheck; - FX_BOOL m_bFocus; - CPDF_Rect m_rcOldWindow; -public: - void AttachFFLData(void* pData) {m_pFormFiller = pData;} -private: - void* m_pFormFiller; +class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify { + public: + CPWL_Edit(); + virtual ~CPWL_Edit(); + + public: + virtual CFX_ByteString GetClassName() const; + virtual void OnDestroy(); + virtual void OnCreated(); + virtual void RePosChildWnd(); + virtual CPDF_Rect GetClientRect() const; + + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonDblClk(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseWheel(short zDelta, + const CPDF_Point& point, + FX_DWORD nFlag); + + virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); + + virtual CPDF_Rect GetFocusRect() const; + + public: + void SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat = PEAH_LEFT, + FX_BOOL bPaint = TRUE); // 0:left 1:right 2:middle + void SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat = PEAV_TOP, + FX_BOOL bPaint = TRUE); // 0:top 1:bottom 2:center + + void SetCharArray(int32_t nCharArray); + void SetLimitChar(int32_t nLimitChar); + + void SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint = TRUE); + void SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint = TRUE); + + void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE); + + void EnableSpellCheck(FX_BOOL bEnabled); + + FX_BOOL CanSelectAll() const; + FX_BOOL CanClear() const; + FX_BOOL CanCopy() const; + FX_BOOL CanCut() const; + FX_BOOL CanPaste() const; + + virtual void CopyText(); + virtual void PasteText(); + virtual void CutText(); + + virtual void SetText(const FX_WCHAR* csText); + void ReplaceSel(const FX_WCHAR* csText); + + CFX_ByteString GetTextAppearanceStream(const CPDF_Point& ptOffset) const; + CFX_ByteString GetCaretAppearanceStream(const CPDF_Point& ptOffset) const; + CFX_ByteString GetSelectAppearanceStream(const CPDF_Point& ptOffset) const; + + FX_BOOL IsTextFull() const; + + static FX_FLOAT GetCharArrayAutoFontSize(CPDF_Font* pFont, + const CPDF_Rect& rcPlate, + int32_t nCharArray); + + void SetFillerNotify(IPWL_Filler_Notify* pNotify) { + m_pFillerNotify = pNotify; + } + + void GeneratePageObjects(CPDF_PageObjects* pPageObjects, + const CPDF_Point& ptOffset, + CFX_ArrayTemplate& ObjArray); + void GeneratePageObjects(CPDF_PageObjects* pPageObjects, + const CPDF_Point& ptOffset); + + protected: + virtual void OnSetFocus(); + virtual void OnKillFocus(); + + protected: + virtual void OnInsertWord(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace); + virtual void OnInsertReturn(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace); + virtual void OnBackSpace(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace); + virtual void OnDelete(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace); + virtual void OnClear(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace); + virtual void OnSetText(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace); + virtual void OnInsertText(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace); + virtual void OnAddUndo(IFX_Edit_UndoItem* pUndoItem); + + private: + CPVT_WordRange GetSelectWordRange() const; + virtual void ShowVScrollBar(FX_BOOL bShow); + FX_BOOL IsVScrollBarVisible() const; + void SetParamByFlag(); + + FX_FLOAT GetCharArrayAutoFontSize(int32_t nCharArray); + CPDF_Point GetWordRightBottomPoint(const CPVT_WordPlace& wpWord); + + CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1, + const CPVT_WordRange& wr2); + CPVT_WordRange GetLatinWordsRange(const CPDF_Point& point) const; + CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace& place) const; + CPVT_WordRange GetArabicWordsRange(const CPVT_WordPlace& place) const; + CPVT_WordRange GetSameWordsRange(const CPVT_WordPlace& place, + FX_BOOL bLatin, + FX_BOOL bArabic) const; + + void AjustArabicWords(const CPVT_WordRange& wr); + + public: + FX_BOOL IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag); + + private: + IPWL_Filler_Notify* m_pFillerNotify; + IPWL_SpellCheck* m_pSpellCheck; + FX_BOOL m_bFocus; + CPDF_Rect m_rcOldWindow; + + public: + void AttachFFLData(void* pData) { m_pFormFiller = pData; } + + private: + void* m_pFormFiller; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDIT_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_EditCtrl.h b/fpdfsdk/include/pdfwindow/PWL_EditCtrl.h index 273b3842c8..784ec61140 100644 --- a/fpdfsdk/include/pdfwindow/PWL_EditCtrl.h +++ b/fpdfsdk/include/pdfwindow/PWL_EditCtrl.h @@ -18,159 +18,172 @@ class IFX_Edit; class IPWL_Edit_Notify; struct CPVT_WordPlace; -enum PWL_EDIT_ALIGNFORMAT_H -{ - PEAH_LEFT = 0, - PEAH_MIDDLE, - PEAH_RIGHT +enum PWL_EDIT_ALIGNFORMAT_H { PEAH_LEFT = 0, PEAH_MIDDLE, PEAH_RIGHT }; + +enum PWL_EDIT_ALIGNFORMAT_V { PEAV_TOP = 0, PEAV_CENTER, PEAV_BOTTOM }; + +class IPWL_Edit_Notify { + public: + virtual ~IPWL_Edit_Notify() {} + // when the position of caret is changed in edit + virtual void OnCaretMove(int32_t x1, int32_t y1, int32_t x2, int32_t y2) {} + virtual void OnContentChange(const CPDF_Rect& rcContent) {} + // OprType: 0 InsertWord + // 1 InsertReturn + // 2 BackSpace + // 3 Delete + // 4 Clear + // 5 InsertText + // 6 SetText + virtual void OnInsertWord(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace) {} + virtual void OnInsertReturn(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace) {} + virtual void OnBackSpace(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace) {} + virtual void OnDelete(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace) {} + virtual void OnClear(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace) {} + virtual void OnInsertText(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace) {} + virtual void OnSetText(const CPVT_WordPlace& place, + const CPVT_WordPlace& oldplace) {} + virtual void OnAddUndo(CPWL_Edit* pEdit) {} }; -enum PWL_EDIT_ALIGNFORMAT_V -{ - PEAV_TOP = 0, - PEAV_CENTER, - PEAV_BOTTOM -}; - -class IPWL_Edit_Notify -{ -public: - virtual ~IPWL_Edit_Notify() { } - //when the position of caret is changed in edit - virtual void OnCaretMove(int32_t x1, int32_t y1, int32_t x2, int32_t y2) {} - virtual void OnContentChange(const CPDF_Rect& rcContent){} - //OprType: 0 InsertWord - //1 InsertReturn - //2 BackSpace - //3 Delete - //4 Clear - //5 InsertText - //6 SetText - virtual void OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnAddUndo(CPWL_Edit* pEdit) {} -}; - -class CPWL_EditCtrl : public CPWL_Wnd, public IFX_Edit_Notify -{ - friend class CPWL_Edit_Notify; - -public: - CPWL_EditCtrl(); - virtual ~CPWL_EditCtrl(); - -public: - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void OnCreated(); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - virtual void SetFontSize(FX_FLOAT fFontSize); - virtual FX_FLOAT GetFontSize() const; - -public: - virtual void SetText(const FX_WCHAR* csText); - - virtual void CopyText(); - virtual void PasteText(); - virtual void CutText(); - - CPDF_Rect GetContentRect() const; - void GetCaretPos(int32_t& x, int32_t& y) const; - FX_BOOL IsModified() const; - - CFX_WideString GetText() const; - void SetSel(int32_t nStartChar,int32_t nEndChar); - void GetSel(int32_t & nStartChar, int32_t & nEndChar ) const; - void GetTextRange(const CPDF_Rect& rect, int32_t & nStartChar, int32_t & nEndChar) const; - CFX_WideString GetText(int32_t & nStartChar, int32_t & nEndChar) const; - void Clear(); - void SelectAll(); - - int32_t GetCaret() const; - void SetCaret(int32_t nPos); - int32_t GetTotalWords() const; - - void Paint(); - - void EnableRefresh(FX_BOOL bRefresh); - CPDF_Point GetScrollPos() const; - void SetScrollPos(const CPDF_Point& point); - - void SetEditNotify(IPWL_Edit_Notify* pNotify) {m_pEditNotify = pNotify;} - - void SetCharSet(uint8_t nCharSet){m_nCharSet = nCharSet;} - int32_t GetCharSet() const; - - void SetCodePage(int32_t nCodePage){m_nCodePage = nCodePage;} - int32_t GetCodePage() const {return m_nCodePage;} - - CPDF_Font * GetCaretFont() const; - FX_FLOAT GetCaretFontSize() const; - - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - void Redo(); - void Undo(); - - void SetReadyToInput(); -protected: - virtual void ShowVScrollBar(FX_BOOL bShow); - - virtual void InsertWord(FX_WORD word, int32_t nCharset); - virtual void InsertReturn(); - virtual void InsertText(const FX_WCHAR* csText); - - virtual void SetCursor(); - FX_BOOL IsWndHorV(); - - void Delete(); - void Backspace(); - -protected: - void GetCaretInfo(CPDF_Point & ptHead, CPDF_Point & ptFoot) const; - void SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot); - - void SetEditCaret(FX_BOOL bVisible); - -protected: - virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep){} - virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep); - virtual void IOnSetScrollPosX(FX_FLOAT fx){} - virtual void IOnSetScrollPosY(FX_FLOAT fy); - virtual void IOnSetCaret(FX_BOOL bVisible,const CPDF_Point & ptHead,const CPDF_Point & ptFoot, const CPVT_WordPlace& place); - virtual void IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps); - virtual void IOnContentChange(const CPDF_Rect& rcContent); - virtual void IOnInvalidateRect(CPDF_Rect * pRect); - -private: - void CreateEditCaret(const PWL_CREATEPARAM & cp); - -protected: - IFX_Edit* m_pEdit; - CPWL_Caret* m_pEditCaret; - FX_BOOL m_bMouseDown; - IPWL_Edit_Notify* m_pEditNotify; - -private: - int32_t m_nCharSet; - int32_t m_nCodePage; +class CPWL_EditCtrl : public CPWL_Wnd, public IFX_Edit_Notify { + friend class CPWL_Edit_Notify; + + public: + CPWL_EditCtrl(); + virtual ~CPWL_EditCtrl(); + + public: + virtual void OnCreate(PWL_CREATEPARAM& cp); + virtual void OnCreated(); + + virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag); + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + virtual void RePosChildWnd(); + virtual void SetFontSize(FX_FLOAT fFontSize); + virtual FX_FLOAT GetFontSize() const; + + public: + virtual void SetText(const FX_WCHAR* csText); + + virtual void CopyText(); + virtual void PasteText(); + virtual void CutText(); + + CPDF_Rect GetContentRect() const; + void GetCaretPos(int32_t& x, int32_t& y) const; + FX_BOOL IsModified() const; + + CFX_WideString GetText() const; + void SetSel(int32_t nStartChar, int32_t nEndChar); + void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; + void GetTextRange(const CPDF_Rect& rect, + int32_t& nStartChar, + int32_t& nEndChar) const; + CFX_WideString GetText(int32_t& nStartChar, int32_t& nEndChar) const; + void Clear(); + void SelectAll(); + + int32_t GetCaret() const; + void SetCaret(int32_t nPos); + int32_t GetTotalWords() const; + + void Paint(); + + void EnableRefresh(FX_BOOL bRefresh); + CPDF_Point GetScrollPos() const; + void SetScrollPos(const CPDF_Point& point); + + void SetEditNotify(IPWL_Edit_Notify* pNotify) { m_pEditNotify = pNotify; } + + void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } + int32_t GetCharSet() const; + + void SetCodePage(int32_t nCodePage) { m_nCodePage = nCodePage; } + int32_t GetCodePage() const { return m_nCodePage; } + + CPDF_Font* GetCaretFont() const; + FX_FLOAT GetCaretFontSize() const; + + FX_BOOL CanUndo() const; + FX_BOOL CanRedo() const; + void Redo(); + void Undo(); + + void SetReadyToInput(); + + protected: + virtual void ShowVScrollBar(FX_BOOL bShow); + + virtual void InsertWord(FX_WORD word, int32_t nCharset); + virtual void InsertReturn(); + virtual void InsertText(const FX_WCHAR* csText); + + virtual void SetCursor(); + FX_BOOL IsWndHorV(); + + void Delete(); + void Backspace(); + + protected: + void GetCaretInfo(CPDF_Point& ptHead, CPDF_Point& ptFoot) const; + void SetCaret(FX_BOOL bVisible, + const CPDF_Point& ptHead, + const CPDF_Point& ptFoot); + + void SetEditCaret(FX_BOOL bVisible); + + protected: + virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, + FX_FLOAT fPlateMax, + FX_FLOAT fContentMin, + FX_FLOAT fContentMax, + FX_FLOAT fSmallStep, + FX_FLOAT fBigStep) {} + virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, + FX_FLOAT fPlateMax, + FX_FLOAT fContentMin, + FX_FLOAT fContentMax, + FX_FLOAT fSmallStep, + FX_FLOAT fBigStep); + virtual void IOnSetScrollPosX(FX_FLOAT fx) {} + virtual void IOnSetScrollPosY(FX_FLOAT fy); + virtual void IOnSetCaret(FX_BOOL bVisible, + const CPDF_Point& ptHead, + const CPDF_Point& ptFoot, + const CPVT_WordPlace& place); + virtual void IOnCaretChange(const CPVT_SecProps& secProps, + const CPVT_WordProps& wordProps); + virtual void IOnContentChange(const CPDF_Rect& rcContent); + virtual void IOnInvalidateRect(CPDF_Rect* pRect); + + private: + void CreateEditCaret(const PWL_CREATEPARAM& cp); + + protected: + IFX_Edit* m_pEdit; + CPWL_Caret* m_pEditCaret; + FX_BOOL m_bMouseDown; + IPWL_Edit_Notify* m_pEditNotify; + + private: + int32_t m_nCharSet; + int32_t m_nCodePage; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_FontMap.h b/fpdfsdk/include/pdfwindow/PWL_FontMap.h index 562d5df9c1..0f5124ca02 100644 --- a/fpdfsdk/include/pdfwindow/PWL_FontMap.h +++ b/fpdfsdk/include/pdfwindow/PWL_FontMap.h @@ -13,118 +13,127 @@ class CPDF_Document; class IFX_SystemHandler; -struct CPWL_FontMap_Data -{ - CPDF_Font* pFont; - int32_t nCharset; - CFX_ByteString sFontName; +struct CPWL_FontMap_Data { + CPDF_Font* pFont; + int32_t nCharset; + CFX_ByteString sFontName; }; -struct CPWL_FontMap_Native -{ - int32_t nCharset; - CFX_ByteString sFontName; +struct CPWL_FontMap_Native { + int32_t nCharset; + CFX_ByteString sFontName; }; #ifndef ANSI_CHARSET -#define ANSI_CHARSET 0 -#define DEFAULT_CHARSET 1 -#define SYMBOL_CHARSET 2 -#define SHIFTJIS_CHARSET 128 -#define HANGEUL_CHARSET 129 -#define HANGUL_CHARSET 129 -#define GB2312_CHARSET 134 -#define CHINESEBIG5_CHARSET 136 -#define OEM_CHARSET 255 -#define JOHAB_CHARSET 130 -#define HEBREW_CHARSET 177 -#define ARABIC_CHARSET 178 -#define GREEK_CHARSET 161 -#define TURKISH_CHARSET 162 -#define VIETNAMESE_CHARSET 163 -#define THAI_CHARSET 222 -#define EASTEUROPE_CHARSET 238 -#define RUSSIAN_CHARSET 204 -#define BALTIC_CHARSET 186 +#define ANSI_CHARSET 0 +#define DEFAULT_CHARSET 1 +#define SYMBOL_CHARSET 2 +#define SHIFTJIS_CHARSET 128 +#define HANGEUL_CHARSET 129 +#define HANGUL_CHARSET 129 +#define GB2312_CHARSET 134 +#define CHINESEBIG5_CHARSET 136 +#define OEM_CHARSET 255 +#define JOHAB_CHARSET 130 +#define HEBREW_CHARSET 177 +#define ARABIC_CHARSET 178 +#define GREEK_CHARSET 161 +#define TURKISH_CHARSET 162 +#define VIETNAMESE_CHARSET 163 +#define THAI_CHARSET 222 +#define EASTEUROPE_CHARSET 238 +#define RUSSIAN_CHARSET 204 +#define BALTIC_CHARSET 186 #endif -class CPWL_FontMap : public IFX_Edit_FontMap -{ -public: - CPWL_FontMap(IFX_SystemHandler* pSystemHandler); - virtual ~CPWL_FontMap(); - - virtual CPDF_Font* GetPDFFont(int32_t nFontIndex); - virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex); - virtual int32_t GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t nFontIndex); - virtual int32_t CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word); - virtual int32_t CharSetFromUnicode(FX_WORD word, int32_t nOldCharset); - -public: - virtual void Initial(const FX_CHAR* fontname = NULL); - void SetSystemHandler(IFX_SystemHandler* pSystemHandler); - - int32_t GetFontMapCount() const; - const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const; - -public: - static int32_t GetNativeCharset(); - CFX_ByteString GetNativeFontName(int32_t nCharset); - - static CFX_ByteString GetDefaultFontByCharset(int32_t nCharset); - - CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, CFX_ByteString& sFontName, uint8_t nCharset); - static FX_BOOL IsStandardFont(const CFX_ByteString& sFontName); - CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); - CPDF_Font* AddSystemFont(CPDF_Document* pDoc, CFX_ByteString& sFontName, - uint8_t nCharset); - -protected: - virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t nCharset); - virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); - FX_BOOL KnowWord(int32_t nFontIndex, FX_WORD word); - - virtual CPDF_Document* GetDocument(); - - void Empty(); - int32_t GetFontIndex(const CFX_ByteString& sFontName, int32_t nCharset, FX_BOOL bFind); - int32_t GetPWLFontIndex(FX_WORD word, int32_t nCharset); - int32_t AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, int32_t nCharset = DEFAULT_CHARSET); - - CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, int32_t nCharset); - CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); - -private: - CFX_ByteString GetFontName(int32_t nFontIndex); - int32_t FindFont(const CFX_ByteString& sFontName, int32_t nCharset = DEFAULT_CHARSET); - - CFX_ByteString GetNativeFont(int32_t nCharset); - -public: - using CharsetFontMap = FPDF_CharsetFontMap; - static const CharsetFontMap defaultTTFMap[]; - -protected: - CFX_ArrayTemplate m_aData; - CFX_ArrayTemplate m_aNativeFont; - -private: - CPDF_Document* m_pPDFDoc; - IFX_SystemHandler* m_pSystemHandler; +class CPWL_FontMap : public IFX_Edit_FontMap { + public: + CPWL_FontMap(IFX_SystemHandler* pSystemHandler); + virtual ~CPWL_FontMap(); + + virtual CPDF_Font* GetPDFFont(int32_t nFontIndex); + virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex); + virtual int32_t GetWordFontIndex(FX_WORD word, + int32_t nCharset, + int32_t nFontIndex); + virtual int32_t CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word); + virtual int32_t CharSetFromUnicode(FX_WORD word, int32_t nOldCharset); + + public: + virtual void Initial(const FX_CHAR* fontname = NULL); + void SetSystemHandler(IFX_SystemHandler* pSystemHandler); + + int32_t GetFontMapCount() const; + const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const; + + public: + static int32_t GetNativeCharset(); + CFX_ByteString GetNativeFontName(int32_t nCharset); + + static CFX_ByteString GetDefaultFontByCharset(int32_t nCharset); + + CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, + CFX_ByteString& sFontName, + uint8_t nCharset); + static FX_BOOL IsStandardFont(const CFX_ByteString& sFontName); + CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); + CPDF_Font* AddSystemFont(CPDF_Document* pDoc, + CFX_ByteString& sFontName, + uint8_t nCharset); + + protected: + virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, + int32_t nCharset); + virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); + FX_BOOL KnowWord(int32_t nFontIndex, FX_WORD word); + + virtual CPDF_Document* GetDocument(); + + void Empty(); + int32_t GetFontIndex(const CFX_ByteString& sFontName, + int32_t nCharset, + FX_BOOL bFind); + int32_t GetPWLFontIndex(FX_WORD word, int32_t nCharset); + int32_t AddFontData(CPDF_Font* pFont, + const CFX_ByteString& sFontAlias, + int32_t nCharset = DEFAULT_CHARSET); + + CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, + int32_t nCharset); + CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); + + private: + CFX_ByteString GetFontName(int32_t nFontIndex); + int32_t FindFont(const CFX_ByteString& sFontName, + int32_t nCharset = DEFAULT_CHARSET); + + CFX_ByteString GetNativeFont(int32_t nCharset); + + public: + using CharsetFontMap = FPDF_CharsetFontMap; + static const CharsetFontMap defaultTTFMap[]; + + protected: + CFX_ArrayTemplate m_aData; + CFX_ArrayTemplate m_aNativeFont; + + private: + CPDF_Document* m_pPDFDoc; + IFX_SystemHandler* m_pSystemHandler; }; -class CPWL_DocFontMap : public CPWL_FontMap -{ -public: - CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, CPDF_Document* pAttachedDoc); - virtual ~CPWL_DocFontMap(); +class CPWL_DocFontMap : public CPWL_FontMap { + public: + CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, + CPDF_Document* pAttachedDoc); + virtual ~CPWL_DocFontMap(); - virtual CPDF_Document* GetDocument(); + virtual CPDF_Document* GetDocument(); -private: - CPDF_Document* m_pAttachedDoc; + private: + CPDF_Document* m_pAttachedDoc; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_FONTMAP_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Icon.h b/fpdfsdk/include/pdfwindow/PWL_Icon.h index cff4e8ca69..7183f0245c 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Icon.h +++ b/fpdfsdk/include/pdfwindow/PWL_Icon.h @@ -10,51 +10,48 @@ #include "../../../core/include/fxcrt/fx_string.h" #include "PWL_Wnd.h" -class CPWL_Image : public CPWL_Wnd -{ -public: - CPWL_Image(); - virtual ~CPWL_Image(); - - virtual CFX_ByteString GetImageAppStream(); - - virtual void GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale); - virtual void GetImageOffset(FX_FLOAT & x,FX_FLOAT & y); - virtual CPDF_Stream * GetPDFStream(); - -public: - void SetPDFStream(CPDF_Stream* pStream); - void GetImageSize(FX_FLOAT & fWidth,FX_FLOAT & fHeight); - CPDF_Matrix GetImageMatrix(); - CFX_ByteString GetImageAlias(); - void SetImageAlias(const FX_CHAR* sImageAlias); - -protected: - CPDF_Stream* m_pPDFStream; - CFX_ByteString m_sImageAlias; +class CPWL_Image : public CPWL_Wnd { + public: + CPWL_Image(); + virtual ~CPWL_Image(); + + virtual CFX_ByteString GetImageAppStream(); + + virtual void GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale); + virtual void GetImageOffset(FX_FLOAT& x, FX_FLOAT& y); + virtual CPDF_Stream* GetPDFStream(); + + public: + void SetPDFStream(CPDF_Stream* pStream); + void GetImageSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight); + CPDF_Matrix GetImageMatrix(); + CFX_ByteString GetImageAlias(); + void SetImageAlias(const FX_CHAR* sImageAlias); + + protected: + CPDF_Stream* m_pPDFStream; + CFX_ByteString m_sImageAlias; }; -class CPWL_Icon : public CPWL_Image -{ -public: - CPWL_Icon(); - virtual ~CPWL_Icon(); +class CPWL_Icon : public CPWL_Image { + public: + CPWL_Icon(); + virtual ~CPWL_Icon(); - virtual CPDF_IconFit * GetIconFit(){return m_pIconFit;}; + virtual CPDF_IconFit* GetIconFit() { return m_pIconFit; }; - virtual void GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale); - virtual void GetImageOffset(FX_FLOAT & x,FX_FLOAT & y); + virtual void GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale); + virtual void GetImageOffset(FX_FLOAT& x, FX_FLOAT& y); - int32_t GetScaleMethod(); - FX_BOOL IsProportionalScale(); - void GetIconPosition(FX_FLOAT & fLeft, FX_FLOAT & fBottom); - FX_BOOL GetFittingBounds(); + int32_t GetScaleMethod(); + FX_BOOL IsProportionalScale(); + void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); + FX_BOOL GetFittingBounds(); - void SetIconFit(CPDF_IconFit * pIconFit){m_pIconFit = pIconFit;}; + void SetIconFit(CPDF_IconFit* pIconFit) { m_pIconFit = pIconFit; }; -private: - CPDF_IconFit * m_pIconFit; + private: + CPDF_IconFit* m_pIconFit; }; - #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_ICON_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_IconList.h b/fpdfsdk/include/pdfwindow/PWL_IconList.h index b8bc3d2957..30a12dcd9b 100644 --- a/fpdfsdk/include/pdfwindow/PWL_IconList.h +++ b/fpdfsdk/include/pdfwindow/PWL_IconList.h @@ -17,112 +17,114 @@ class CPWL_IconList_Content; class CPWL_IconList; class CPWL_Label; -class IPWL_IconList_Notify -{ -public: - virtual ~IPWL_IconList_Notify() { } - virtual void OnNoteListSelChanged(int32_t nItemIndex) = 0; +class IPWL_IconList_Notify { + public: + virtual ~IPWL_IconList_Notify() {} + virtual void OnNoteListSelChanged(int32_t nItemIndex) = 0; }; -class CPWL_IconList_Item : public CPWL_Wnd -{ -public: - CPWL_IconList_Item(); - virtual ~CPWL_IconList_Item(); - - virtual CFX_ByteString GetClassName() const; - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - - void SetSelect(FX_BOOL bSelected); - FX_BOOL IsSelected() const; - void SetData(void* pData); - void SetIcon(int32_t nIconIndex); - void SetText(const CFX_WideString& str); - void SetIconFillColor(const CPWL_Color& color); - CFX_WideString GetText() const; - -protected: - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual void OnEnabled(); - virtual void OnDisabled(); - -private: - int32_t m_nIconIndex; - void* m_pData; - FX_BOOL m_bSelected; - CPWL_Label* m_pText; - CPWL_Color m_crIcon; +class CPWL_IconList_Item : public CPWL_Wnd { + public: + CPWL_IconList_Item(); + virtual ~CPWL_IconList_Item(); + + virtual CFX_ByteString GetClassName() const; + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + virtual void RePosChildWnd(); + + void SetSelect(FX_BOOL bSelected); + FX_BOOL IsSelected() const; + void SetData(void* pData); + void SetIcon(int32_t nIconIndex); + void SetText(const CFX_WideString& str); + void SetIconFillColor(const CPWL_Color& color); + CFX_WideString GetText() const; + + protected: + virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + + virtual void OnEnabled(); + virtual void OnDisabled(); + + private: + int32_t m_nIconIndex; + void* m_pData; + FX_BOOL m_bSelected; + CPWL_Label* m_pText; + CPWL_Color m_crIcon; }; -class CPWL_IconList_Content : public CPWL_ListCtrl -{ -public: - CPWL_IconList_Content(int32_t nListCount); - virtual ~CPWL_IconList_Content(); - - void SetSelect(int32_t nIndex); - int32_t GetSelect() const; - void SetNotify(IPWL_IconList_Notify* pNotify); - void EnableNotify(FX_BOOL bNotify); - void SetListData(int32_t nItemIndex, void* pData); - void SetListIcon(int32_t nItemIndex, int32_t nIconIndex); - void SetListString(int32_t nItemIndex, const CFX_WideString& str); - void SetIconFillColor(const CPWL_Color& color); - CFX_WideString GetListString(int32_t nItemIndex) const; - IPWL_IconList_Notify* GetNotify() const; - void ScrollToItem(int32_t nItemIndex); - -protected: - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - -private: - CPWL_IconList_Item* GetListItem(int32_t nItemIndex) const; - void SelectItem(int32_t nItemIndex, FX_BOOL bSelect); - int32_t FindItemIndex(const CPDF_Point& point); - - int32_t m_nSelectIndex; - IPWL_IconList_Notify* m_pNotify; - FX_BOOL m_bEnableNotify; - FX_BOOL m_bMouseDown; - int32_t m_nListCount; +class CPWL_IconList_Content : public CPWL_ListCtrl { + public: + CPWL_IconList_Content(int32_t nListCount); + virtual ~CPWL_IconList_Content(); + + void SetSelect(int32_t nIndex); + int32_t GetSelect() const; + void SetNotify(IPWL_IconList_Notify* pNotify); + void EnableNotify(FX_BOOL bNotify); + void SetListData(int32_t nItemIndex, void* pData); + void SetListIcon(int32_t nItemIndex, int32_t nIconIndex); + void SetListString(int32_t nItemIndex, const CFX_WideString& str); + void SetIconFillColor(const CPWL_Color& color); + CFX_WideString GetListString(int32_t nItemIndex) const; + IPWL_IconList_Notify* GetNotify() const; + void ScrollToItem(int32_t nItemIndex); + + protected: + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); + + private: + CPWL_IconList_Item* GetListItem(int32_t nItemIndex) const; + void SelectItem(int32_t nItemIndex, FX_BOOL bSelect); + int32_t FindItemIndex(const CPDF_Point& point); + + int32_t m_nSelectIndex; + IPWL_IconList_Notify* m_pNotify; + FX_BOOL m_bEnableNotify; + FX_BOOL m_bMouseDown; + int32_t m_nListCount; }; -class CPWL_IconList : public CPWL_Wnd -{ -public: - CPWL_IconList(int32_t nListCount); - virtual ~CPWL_IconList(); - - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - - void SetSelect(int32_t nIndex); - void SetTopItem(int32_t nIndex); - int32_t GetSelect() const; - void SetNotify(IPWL_IconList_Notify* pNotify); - void EnableNotify(FX_BOOL bNotify); - void SetListData(int32_t nItemIndex, void* pData); - void SetListIcon(int32_t nItemIndex, int32_t nIconIndex); - void SetListString(int32_t nItemIndex, const CFX_WideString& str); - void SetIconFillColor(const CPWL_Color& color); - CFX_WideString GetListString(int32_t nItemIndex) const; - -protected: - virtual void OnCreated(); - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - -private: - CPWL_IconList_Content* m_pListContent; - int32_t m_nListCount; +class CPWL_IconList : public CPWL_Wnd { + public: + CPWL_IconList(int32_t nListCount); + virtual ~CPWL_IconList(); + + virtual FX_BOOL OnMouseWheel(short zDelta, + const CPDF_Point& point, + FX_DWORD nFlag); + + void SetSelect(int32_t nIndex); + void SetTopItem(int32_t nIndex); + int32_t GetSelect() const; + void SetNotify(IPWL_IconList_Notify* pNotify); + void EnableNotify(FX_BOOL bNotify); + void SetListData(int32_t nItemIndex, void* pData); + void SetListIcon(int32_t nItemIndex, int32_t nIconIndex); + void SetListString(int32_t nItemIndex, const CFX_WideString& str); + void SetIconFillColor(const CPWL_Color& color); + CFX_WideString GetListString(int32_t nItemIndex) const; + + protected: + virtual void OnCreated(); + virtual void RePosChildWnd(); + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + + private: + CPWL_IconList_Content* m_pListContent; + int32_t m_nListCount; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_ICONLIST_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Label.h b/fpdfsdk/include/pdfwindow/PWL_Label.h index 3df547e0b2..b6cb7f557c 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Label.h +++ b/fpdfsdk/include/pdfwindow/PWL_Label.h @@ -11,35 +11,35 @@ class IFX_Edit; -class CPWL_Label : public CPWL_Wnd -{ -public: - CPWL_Label(); - virtual ~CPWL_Label(); - - virtual CFX_ByteString GetClassName() const; - virtual void SetFontSize(FX_FLOAT fFontSize); - virtual FX_FLOAT GetFontSize() const; - - void SetText(const FX_WCHAR* csText); - CFX_WideString GetText() const; - void SetLimitChar(int32_t nLimitChar); - void SetHorzScale(int32_t nHorzScale); - void SetCharSpace(FX_FLOAT fCharSpace); - CPDF_Rect GetContentRect() const; - int32_t GetTotalWords(); - CFX_ByteString GetTextAppearanceStream(const CPDF_Point & ptOffset) const; - -protected: - virtual void OnCreated(); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void RePosChildWnd(); - -private: - void SetParamByFlag(); - - IFX_Edit* m_pEdit; +class CPWL_Label : public CPWL_Wnd { + public: + CPWL_Label(); + virtual ~CPWL_Label(); + + virtual CFX_ByteString GetClassName() const; + virtual void SetFontSize(FX_FLOAT fFontSize); + virtual FX_FLOAT GetFontSize() const; + + void SetText(const FX_WCHAR* csText); + CFX_WideString GetText() const; + void SetLimitChar(int32_t nLimitChar); + void SetHorzScale(int32_t nHorzScale); + void SetCharSpace(FX_FLOAT fCharSpace); + CPDF_Rect GetContentRect() const; + int32_t GetTotalWords(); + CFX_ByteString GetTextAppearanceStream(const CPDF_Point& ptOffset) const; + + protected: + virtual void OnCreated(); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void RePosChildWnd(); + + private: + void SetParamByFlag(); + + IFX_Edit* m_pEdit; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_LABEL_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_ListBox.h b/fpdfsdk/include/pdfwindow/PWL_ListBox.h index 7c37fb30ef..b9372eff9c 100644 --- a/fpdfsdk/include/pdfwindow/PWL_ListBox.h +++ b/fpdfsdk/include/pdfwindow/PWL_ListBox.h @@ -15,89 +15,107 @@ class CPWL_List_Notify; class CPWL_ListBox; class IPWL_Filler_Notify; -class CPWL_List_Notify : public IFX_List_Notify -{ -public: - CPWL_List_Notify(CPWL_ListBox * pList); - virtual ~CPWL_List_Notify(); - - void IOnSetScrollInfoX(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep){} - void IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep); - void IOnSetScrollPosX(FX_FLOAT fx){} - void IOnSetScrollPosY(FX_FLOAT fy); - void IOnSetCaret(FX_BOOL bVisible,const CPDF_Point & ptHead,const CPDF_Point & ptFoot, const CPVT_WordPlace& place); - void IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps); - void IOnInvalidateRect(CPDF_Rect * pRect); - -private: - CPWL_ListBox* m_pList; +class CPWL_List_Notify : public IFX_List_Notify { + public: + CPWL_List_Notify(CPWL_ListBox* pList); + virtual ~CPWL_List_Notify(); + + void IOnSetScrollInfoX(FX_FLOAT fPlateMin, + FX_FLOAT fPlateMax, + FX_FLOAT fContentMin, + FX_FLOAT fContentMax, + FX_FLOAT fSmallStep, + FX_FLOAT fBigStep) {} + void IOnSetScrollInfoY(FX_FLOAT fPlateMin, + FX_FLOAT fPlateMax, + FX_FLOAT fContentMin, + FX_FLOAT fContentMax, + FX_FLOAT fSmallStep, + FX_FLOAT fBigStep); + void IOnSetScrollPosX(FX_FLOAT fx) {} + void IOnSetScrollPosY(FX_FLOAT fy); + void IOnSetCaret(FX_BOOL bVisible, + const CPDF_Point& ptHead, + const CPDF_Point& ptFoot, + const CPVT_WordPlace& place); + void IOnCaretChange(const CPVT_SecProps& secProps, + const CPVT_WordProps& wordProps); + void IOnInvalidateRect(CPDF_Rect* pRect); + + private: + CPWL_ListBox* m_pList; }; -class CPWL_ListBox : public CPWL_Wnd -{ -public: - CPWL_ListBox(); - virtual ~CPWL_ListBox(); - - virtual CFX_ByteString GetClassName() const; - virtual void OnCreated(); - virtual void OnDestroy(); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - virtual void KillFocus(); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - virtual void RePosChildWnd(); - virtual CFX_WideString GetText() const; - virtual CPDF_Rect GetFocusRect() const; - virtual void SetFontSize(FX_FLOAT fFontSize); - virtual FX_FLOAT GetFontSize() const; - - void OnNotifySelChanged(FX_BOOL bKeyDown, FX_BOOL & bExit , FX_DWORD nFlag); - - void AddString(const FX_WCHAR* string); - void SetTopVisibleIndex(int32_t nItemIndex); - void ScrollToListItem(int32_t nItemIndex); - void ResetContent(); - void Reset(); - void Select(int32_t nItemIndex); - void SetCaret(int32_t nItemIndex); - void SetHoverSel(FX_BOOL bHoverSel); - - int32_t GetCount() const; - FX_BOOL IsMultipleSel() const; - int32_t GetCaretIndex() const; - int32_t GetCurSel() const; - FX_BOOL IsItemSelected(int32_t nItemIndex) const; - int32_t GetTopVisibleIndex() const; - int32_t FindNext(int32_t nIndex,FX_WCHAR nChar) const; - CPDF_Rect GetContentRect() const; - FX_FLOAT GetFirstHeight() const; - CPDF_Rect GetListRect() const; - - void SetFillerNotify(IPWL_Filler_Notify* pNotify) {m_pFillerNotify = pNotify;} - -protected: - IFX_List* m_pList; - CPWL_List_Notify* m_pListNotify; - FX_BOOL m_bMouseDown; - FX_BOOL m_bHoverSel; - IPWL_Filler_Notify* m_pFillerNotify; -public: - void AttachFFLData(void* pData) {m_pFormFiller = pData;} -private: - void* m_pFormFiller; +class CPWL_ListBox : public CPWL_Wnd { + public: + CPWL_ListBox(); + virtual ~CPWL_ListBox(); + + virtual CFX_ByteString GetClassName() const; + virtual void OnCreated(); + virtual void OnDestroy(); + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + + virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseWheel(short zDelta, + const CPDF_Point& point, + FX_DWORD nFlag); + virtual void KillFocus(); + + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + virtual void RePosChildWnd(); + virtual CFX_WideString GetText() const; + virtual CPDF_Rect GetFocusRect() const; + virtual void SetFontSize(FX_FLOAT fFontSize); + virtual FX_FLOAT GetFontSize() const; + + void OnNotifySelChanged(FX_BOOL bKeyDown, FX_BOOL& bExit, FX_DWORD nFlag); + + void AddString(const FX_WCHAR* string); + void SetTopVisibleIndex(int32_t nItemIndex); + void ScrollToListItem(int32_t nItemIndex); + void ResetContent(); + void Reset(); + void Select(int32_t nItemIndex); + void SetCaret(int32_t nItemIndex); + void SetHoverSel(FX_BOOL bHoverSel); + + int32_t GetCount() const; + FX_BOOL IsMultipleSel() const; + int32_t GetCaretIndex() const; + int32_t GetCurSel() const; + FX_BOOL IsItemSelected(int32_t nItemIndex) const; + int32_t GetTopVisibleIndex() const; + int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const; + CPDF_Rect GetContentRect() const; + FX_FLOAT GetFirstHeight() const; + CPDF_Rect GetListRect() const; + + void SetFillerNotify(IPWL_Filler_Notify* pNotify) { + m_pFillerNotify = pNotify; + } + + protected: + IFX_List* m_pList; + CPWL_List_Notify* m_pListNotify; + FX_BOOL m_bMouseDown; + FX_BOOL m_bHoverSel; + IPWL_Filler_Notify* m_pFillerNotify; + + public: + void AttachFFLData(void* pData) { m_pFormFiller = pData; } + + private: + void* m_pFormFiller; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_LISTBOX_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_ListCtrl.h b/fpdfsdk/include/pdfwindow/PWL_ListCtrl.h index c107a0cf5e..cd90692150 100644 --- a/fpdfsdk/include/pdfwindow/PWL_ListCtrl.h +++ b/fpdfsdk/include/pdfwindow/PWL_ListCtrl.h @@ -9,39 +9,39 @@ #include "PWL_Wnd.h" -class CPWL_ListCtrl : public CPWL_Wnd -{ -public: - CPWL_ListCtrl(); - virtual ~CPWL_ListCtrl(); - - void SetScrollPos(const CPDF_Point& point); - CPDF_Point GetScrollPos() const; - CPDF_Rect GetScrollArea() const; - void SetItemSpace(FX_FLOAT fSpace); - void SetTopSpace(FX_FLOAT fSpace); - void SetBottomSpace(FX_FLOAT fSpace); - void ResetFace(); - void ResetContent(int32_t nStart); - int32_t GetItemIndex(CPWL_Wnd* pItem); - FX_FLOAT GetContentsHeight(FX_FLOAT fLimitWidth); - CPDF_Point InToOut(const CPDF_Point& point) const; - CPDF_Point OutToIn(const CPDF_Point& point) const; - CPDF_Rect InToOut(const CPDF_Rect& rect) const; - CPDF_Rect OutToIn(const CPDF_Rect& rect) const; - -protected: - virtual void RePosChildWnd(); - virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - -private: - void ResetAll(FX_BOOL bMove,int32_t nStart); - - CPDF_Rect m_rcContent; - CPDF_Point m_ptScroll; - FX_FLOAT m_fItemSpace; - FX_FLOAT m_fTopSpace; - FX_FLOAT m_fBottomSpace; +class CPWL_ListCtrl : public CPWL_Wnd { + public: + CPWL_ListCtrl(); + virtual ~CPWL_ListCtrl(); + + void SetScrollPos(const CPDF_Point& point); + CPDF_Point GetScrollPos() const; + CPDF_Rect GetScrollArea() const; + void SetItemSpace(FX_FLOAT fSpace); + void SetTopSpace(FX_FLOAT fSpace); + void SetBottomSpace(FX_FLOAT fSpace); + void ResetFace(); + void ResetContent(int32_t nStart); + int32_t GetItemIndex(CPWL_Wnd* pItem); + FX_FLOAT GetContentsHeight(FX_FLOAT fLimitWidth); + CPDF_Point InToOut(const CPDF_Point& point) const; + CPDF_Point OutToIn(const CPDF_Point& point) const; + CPDF_Rect InToOut(const CPDF_Rect& rect) const; + CPDF_Rect OutToIn(const CPDF_Rect& rect) const; + + protected: + virtual void RePosChildWnd(); + virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + + private: + void ResetAll(FX_BOOL bMove, int32_t nStart); + + CPDF_Rect m_rcContent; + CPDF_Point m_ptScroll; + FX_FLOAT m_fItemSpace; + FX_FLOAT m_fTopSpace; + FX_FLOAT m_fBottomSpace; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_LISTCTRL_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Note.h b/fpdfsdk/include/pdfwindow/PWL_Note.h index 29b7857e20..4f18fa20d0 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Note.h +++ b/fpdfsdk/include/pdfwindow/PWL_Note.h @@ -28,333 +28,342 @@ class IPWL_NoteItem; class IPWL_NoteNotify; class IPopup_Note; -class IPWL_NoteNotify -{ -public: - virtual ~IPWL_NoteNotify() { } - virtual void OnNoteMove(const FX_RECT& rtWin) = 0; - virtual void OnNoteShow(FX_BOOL bShow) = 0; - virtual void OnNoteActivate(FX_BOOL bActive) = 0; - virtual void OnNoteClose() = 0; - virtual void OnItemCreate(IPWL_NoteItem* pItem) = 0; - virtual void OnItemDelete(IPWL_NoteItem* pItem) = 0; - virtual void OnSetAuthorName(IPWL_NoteItem* pItem) = 0; - virtual void OnSetBkColor(IPWL_NoteItem* pItem) = 0; - virtual void OnSetContents(IPWL_NoteItem* pItem) = 0; - virtual void OnSetDateTime(IPWL_NoteItem* pItem) = 0; - virtual void OnSetSubjectName(IPWL_NoteItem* pItem) = 0; - virtual void OnPopupMenu(int32_t x, int32_t y) = 0; - virtual void OnPopupMenu(IPWL_NoteItem* pItem, int32_t x, int32_t y) = 0; +class IPWL_NoteNotify { + public: + virtual ~IPWL_NoteNotify() {} + virtual void OnNoteMove(const FX_RECT& rtWin) = 0; + virtual void OnNoteShow(FX_BOOL bShow) = 0; + virtual void OnNoteActivate(FX_BOOL bActive) = 0; + virtual void OnNoteClose() = 0; + virtual void OnItemCreate(IPWL_NoteItem* pItem) = 0; + virtual void OnItemDelete(IPWL_NoteItem* pItem) = 0; + virtual void OnSetAuthorName(IPWL_NoteItem* pItem) = 0; + virtual void OnSetBkColor(IPWL_NoteItem* pItem) = 0; + virtual void OnSetContents(IPWL_NoteItem* pItem) = 0; + virtual void OnSetDateTime(IPWL_NoteItem* pItem) = 0; + virtual void OnSetSubjectName(IPWL_NoteItem* pItem) = 0; + virtual void OnPopupMenu(int32_t x, int32_t y) = 0; + virtual void OnPopupMenu(IPWL_NoteItem* pItem, int32_t x, int32_t y) = 0; }; -class IPWL_NoteHandler -{ -public: - virtual ~IPWL_NoteHandler() { } - virtual void OnNoteColorChanged(const CPWL_Color& color) = 0; +class IPWL_NoteHandler { + public: + virtual ~IPWL_NoteHandler() {} + virtual void OnNoteColorChanged(const CPWL_Color& color) = 0; }; -class IPWL_NoteItem -{ -public: - virtual ~IPWL_NoteItem() { } - virtual void SetPrivateData(void* pData) = 0; - virtual void SetBkColor(const CPWL_Color& color) = 0; - virtual void SetSubjectName(const CFX_WideString& sName) = 0; - virtual void SetAuthorName(const CFX_WideString& sName) = 0; - virtual void SetDateTime(FX_SYSTEMTIME time) = 0; - virtual void SetContents(const CFX_WideString& sContents) = 0; - - virtual IPWL_NoteItem* CreateSubItem() = 0; - virtual int32_t CountSubItems() const = 0; - virtual IPWL_NoteItem* GetSubItems(int32_t index) const = 0; - virtual void DeleteSubItem(IPWL_NoteItem* pNoteItem) = 0; - virtual void SetFocus() = 0; - - virtual IPWL_NoteItem* GetParentItem() const = 0; - virtual void* GetPrivateData() const = 0; - virtual CFX_WideString GetAuthorName() const = 0; - virtual CPWL_Color GetBkColor() const = 0; - virtual CFX_WideString GetContents() const = 0; - virtual FX_SYSTEMTIME GetDateTime() const = 0; - virtual CFX_WideString GetSubjectName() const = 0; - - virtual CPWL_Edit* GetEdit() const = 0; +class IPWL_NoteItem { + public: + virtual ~IPWL_NoteItem() {} + virtual void SetPrivateData(void* pData) = 0; + virtual void SetBkColor(const CPWL_Color& color) = 0; + virtual void SetSubjectName(const CFX_WideString& sName) = 0; + virtual void SetAuthorName(const CFX_WideString& sName) = 0; + virtual void SetDateTime(FX_SYSTEMTIME time) = 0; + virtual void SetContents(const CFX_WideString& sContents) = 0; + + virtual IPWL_NoteItem* CreateSubItem() = 0; + virtual int32_t CountSubItems() const = 0; + virtual IPWL_NoteItem* GetSubItems(int32_t index) const = 0; + virtual void DeleteSubItem(IPWL_NoteItem* pNoteItem) = 0; + virtual void SetFocus() = 0; + + virtual IPWL_NoteItem* GetParentItem() const = 0; + virtual void* GetPrivateData() const = 0; + virtual CFX_WideString GetAuthorName() const = 0; + virtual CPWL_Color GetBkColor() const = 0; + virtual CFX_WideString GetContents() const = 0; + virtual FX_SYSTEMTIME GetDateTime() const = 0; + virtual CFX_WideString GetSubjectName() const = 0; + + virtual CPWL_Edit* GetEdit() const = 0; }; -class CPWL_Note_Icon : public CPWL_Wnd -{ -public: - CPWL_Note_Icon(); - virtual ~CPWL_Note_Icon(); +class CPWL_Note_Icon : public CPWL_Wnd { + public: + CPWL_Note_Icon(); + virtual ~CPWL_Note_Icon(); - void SetIconType(int32_t nType); + void SetIconType(int32_t nType); -public: + public: + protected: + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - -private: - int32_t m_nType; + private: + int32_t m_nType; }; -class CPWL_Note_CloseBox : public CPWL_Button -{ -public: - CPWL_Note_CloseBox(); - virtual ~CPWL_Note_CloseBox(); +class CPWL_Note_CloseBox : public CPWL_Button { + public: + CPWL_Note_CloseBox(); + virtual ~CPWL_Note_CloseBox(); -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); + protected: + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); -private: - FX_BOOL m_bMouseDown; + private: + FX_BOOL m_bMouseDown; }; -class CPWL_Note_LBBox : public CPWL_Wnd -{ -public: - CPWL_Note_LBBox(); - virtual ~CPWL_Note_LBBox(); +class CPWL_Note_LBBox : public CPWL_Wnd { + public: + CPWL_Note_LBBox(); + virtual ~CPWL_Note_LBBox(); -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); + protected: + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); }; -class CPWL_Note_RBBox : public CPWL_Wnd -{ -public: - CPWL_Note_RBBox(); - virtual ~CPWL_Note_RBBox(); +class CPWL_Note_RBBox : public CPWL_Wnd { + public: + CPWL_Note_RBBox(); + virtual ~CPWL_Note_RBBox(); -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); + protected: + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); }; -class CPWL_Note_Edit : public CPWL_Edit -{ -public: - CPWL_Note_Edit(); - virtual ~CPWL_Note_Edit(); - - void EnableNotify(FX_BOOL bEnable) {m_bEnableNotify = bEnable;} - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); - FX_FLOAT GetItemLeftMargin(); - FX_FLOAT GetItemRightMargin(); - - virtual void SetText(const FX_WCHAR* csText); - -protected: - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - virtual void RePosChildWnd(); - virtual void OnSetFocus(); - virtual void OnKillFocus(); - -private: - FX_BOOL m_bEnableNotify; - FX_FLOAT m_fOldItemHeight; - FX_BOOL m_bSizeChanged; - FX_FLOAT m_fOldMin; - FX_FLOAT m_fOldMax; +class CPWL_Note_Edit : public CPWL_Edit { + public: + CPWL_Note_Edit(); + virtual ~CPWL_Note_Edit(); + + void EnableNotify(FX_BOOL bEnable) { m_bEnableNotify = bEnable; } + virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); + FX_FLOAT GetItemLeftMargin(); + FX_FLOAT GetItemRightMargin(); + + virtual void SetText(const FX_WCHAR* csText); + + protected: + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + virtual void RePosChildWnd(); + virtual void OnSetFocus(); + virtual void OnKillFocus(); + + private: + FX_BOOL m_bEnableNotify; + FX_FLOAT m_fOldItemHeight; + FX_BOOL m_bSizeChanged; + FX_FLOAT m_fOldMin; + FX_FLOAT m_fOldMax; }; -class CPWL_Note_Options : public CPWL_Wnd -{ -public: - CPWL_Note_Options(); - virtual ~CPWL_Note_Options(); +class CPWL_Note_Options : public CPWL_Wnd { + public: + CPWL_Note_Options(); + virtual ~CPWL_Note_Options(); - CPDF_Rect GetContentRect() const; - virtual void SetTextColor(const CPWL_Color & color); - void SetText(const CFX_WideString& sText); + CPDF_Rect GetContentRect() const; + virtual void SetTextColor(const CPWL_Color& color); + void SetText(const CFX_WideString& sText); -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); + protected: + virtual void RePosChildWnd(); + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); -private: - CPWL_Label* m_pText; + private: + CPWL_Label* m_pText; }; -class CPWL_Note_Contents : public CPWL_ListCtrl -{ -public: - CPWL_Note_Contents(); - virtual ~CPWL_Note_Contents(); +class CPWL_Note_Contents : public CPWL_ListCtrl { + public: + CPWL_Note_Contents(); + virtual ~CPWL_Note_Contents(); - virtual CFX_ByteString GetClassName() const; - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual CFX_ByteString GetClassName() const; + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); - void SetEditFocus(FX_BOOL bLast); - CPWL_Edit* GetEdit() const; + void SetEditFocus(FX_BOOL bLast); + CPWL_Edit* GetEdit() const; -public: - void SetText(const CFX_WideString& sText); - CFX_WideString GetText() const; + public: + void SetText(const CFX_WideString& sText); + CFX_WideString GetText() const; - CPWL_NoteItem* CreateSubItem(); - void DeleteSubItem(IPWL_NoteItem* pNoteItem); - int32_t CountSubItems() const; - IPWL_NoteItem* GetSubItems(int32_t index) const; + CPWL_NoteItem* CreateSubItem(); + void DeleteSubItem(IPWL_NoteItem* pNoteItem); + int32_t CountSubItems() const; + IPWL_NoteItem* GetSubItems(int32_t index) const; - virtual IPWL_NoteItem* GetHitNoteItem(const CPDF_Point& point); - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); + virtual IPWL_NoteItem* GetHitNoteItem(const CPDF_Point& point); + void EnableRead(FX_BOOL bEnabled); + void EnableModify(FX_BOOL bEnabled); -protected: - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); + protected: + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); -private: - CPWL_Note_Edit* m_pEdit; + private: + CPWL_Note_Edit* m_pEdit; }; -class CPWL_NoteItem : public CPWL_Wnd, public IPWL_NoteItem -{ -public: - CPWL_NoteItem(); - virtual ~CPWL_NoteItem(); - -public: - virtual void SetPrivateData(void* pData); - virtual void SetBkColor(const CPWL_Color& color); - virtual void SetSubjectName(const CFX_WideString& sName); - virtual void SetAuthorName(const CFX_WideString& sName); - virtual void SetDateTime(FX_SYSTEMTIME time); - virtual void SetContents(const CFX_WideString& sContents); - - virtual IPWL_NoteItem* CreateSubItem(); - virtual int32_t CountSubItems() const; - virtual IPWL_NoteItem* GetSubItems(int32_t index) const; - virtual void DeleteSubItem(IPWL_NoteItem* pNoteItem); - virtual void SetFocus(){SetNoteFocus(FALSE);} - - virtual IPWL_NoteItem* GetParentItem() const; - virtual void* GetPrivateData() const; - virtual CFX_WideString GetAuthorName() const; - virtual CPWL_Color GetBkColor() const; - virtual CFX_WideString GetContents() const; - virtual FX_SYSTEMTIME GetDateTime() const; - virtual CFX_WideString GetSubjectName() const; - virtual FX_BOOL IsTopItem() const { return FALSE;} - virtual CPWL_Edit* GetEdit() const; - -public: - virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual CFX_ByteString GetClassName() const; - virtual IPWL_NoteItem* GetHitNoteItem(const CPDF_Point& point); - virtual IPWL_NoteItem* GetFocusedNoteItem() const; - - virtual void ResetSubjectName(int32_t nItemIndex); - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); - -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - -public: - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); - virtual FX_FLOAT GetItemLeftMargin(); - virtual FX_FLOAT GetItemRightMargin(); - CPWL_NoteItem* CreateNoteItem(); - CPWL_NoteItem* GetParentNoteItem() const; - - void SetNoteFocus(FX_BOOL bLast); - void OnContentsValidate(); - - void OnCreateNoteItem(); - -protected: - void PopupNoteItemMenu(const CPDF_Point& point); - - virtual const CPWL_Note* GetNote() const; - virtual IPWL_NoteNotify* GetNoteNotify() const; - -protected: - CPWL_Label* m_pSubject; - CPWL_Label* m_pDateTime; - CPWL_Note_Contents* m_pContents; - -private: - void* m_pPrivateData; - FX_SYSTEMTIME m_dtNote; - CFX_WideString m_sAuthor; - - FX_FLOAT m_fOldItemHeight; - FX_BOOL m_bSizeChanged; - FX_BOOL m_bAllowModify; +class CPWL_NoteItem : public CPWL_Wnd, public IPWL_NoteItem { + public: + CPWL_NoteItem(); + virtual ~CPWL_NoteItem(); + + public: + virtual void SetPrivateData(void* pData); + virtual void SetBkColor(const CPWL_Color& color); + virtual void SetSubjectName(const CFX_WideString& sName); + virtual void SetAuthorName(const CFX_WideString& sName); + virtual void SetDateTime(FX_SYSTEMTIME time); + virtual void SetContents(const CFX_WideString& sContents); + + virtual IPWL_NoteItem* CreateSubItem(); + virtual int32_t CountSubItems() const; + virtual IPWL_NoteItem* GetSubItems(int32_t index) const; + virtual void DeleteSubItem(IPWL_NoteItem* pNoteItem); + virtual void SetFocus() { SetNoteFocus(FALSE); } + + virtual IPWL_NoteItem* GetParentItem() const; + virtual void* GetPrivateData() const; + virtual CFX_WideString GetAuthorName() const; + virtual CPWL_Color GetBkColor() const; + virtual CFX_WideString GetContents() const; + virtual FX_SYSTEMTIME GetDateTime() const; + virtual CFX_WideString GetSubjectName() const; + virtual FX_BOOL IsTopItem() const { return FALSE; } + virtual CPWL_Edit* GetEdit() const; + + public: + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual CFX_ByteString GetClassName() const; + virtual IPWL_NoteItem* GetHitNoteItem(const CPDF_Point& point); + virtual IPWL_NoteItem* GetFocusedNoteItem() const; + + virtual void ResetSubjectName(int32_t nItemIndex); + void EnableRead(FX_BOOL bEnabled); + void EnableModify(FX_BOOL bEnabled); + + protected: + virtual void RePosChildWnd(); + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + + public: + virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); + virtual FX_FLOAT GetItemLeftMargin(); + virtual FX_FLOAT GetItemRightMargin(); + CPWL_NoteItem* CreateNoteItem(); + CPWL_NoteItem* GetParentNoteItem() const; + + void SetNoteFocus(FX_BOOL bLast); + void OnContentsValidate(); + + void OnCreateNoteItem(); + + protected: + void PopupNoteItemMenu(const CPDF_Point& point); + + virtual const CPWL_Note* GetNote() const; + virtual IPWL_NoteNotify* GetNoteNotify() const; + + protected: + CPWL_Label* m_pSubject; + CPWL_Label* m_pDateTime; + CPWL_Note_Contents* m_pContents; + + private: + void* m_pPrivateData; + FX_SYSTEMTIME m_dtNote; + CFX_WideString m_sAuthor; + + FX_FLOAT m_fOldItemHeight; + FX_BOOL m_bSizeChanged; + FX_BOOL m_bAllowModify; }; -class CPWL_Note : public CPWL_NoteItem -{ -public: - CPWL_Note(IPopup_Note* pPopupNote, IPWL_NoteNotify* pNoteNotify, IPWL_NoteHandler* pNoteHandler); - virtual ~CPWL_Note(); - -public: - virtual void SetSubjectName(const CFX_WideString& sName); - virtual void SetAuthorName(const CFX_WideString& sName); - virtual CFX_WideString GetAuthorName() const; - virtual void SetBkColor(const CPWL_Color& color); - virtual void ResetSubjectName(int32_t nItemIndex){} - virtual FX_BOOL IsTopItem() const {return TRUE;} - virtual const CPWL_Note* GetNote() const; - virtual IPWL_NoteNotify* GetNoteNotify() const; - -public: - IPWL_NoteItem* Reply(); - void EnableNotify(FX_BOOL bEnabled); - void SetIconType(int32_t nType); - void SetOptionsText(const CFX_WideString& sText); - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); - - CFX_WideString GetReplyString() const; - void SetReplyString(const CFX_WideString& string); - - //0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close / 5-options - int32_t NoteHitTest(const CPDF_Point& point) const; - CPDF_Rect GetCaptionRect() const {return m_rcCaption;} - IPopup_Note* GetPopupNote() const {return m_pPopupNote;} - -public: - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - - FX_BOOL ResetScrollBar(); - void RePosNoteChildren(); - FX_BOOL ScrollBarShouldVisible(); - -private: - CPWL_Label* m_pAuthor; - CPWL_Note_Icon* m_pIcon; - CPWL_Note_CloseBox* m_pCloseBox; - CPWL_Note_LBBox* m_pLBBox; - CPWL_Note_RBBox* m_pRBBox; - CPWL_ScrollBar* m_pContentsBar; - CPWL_Note_Options* m_pOptions; - IPWL_NoteNotify* m_pNoteNotify; - FX_BOOL m_bResizing; - PWL_SCROLL_INFO m_OldScrollInfo; - CPDF_Rect m_rcCaption; - FX_BOOL m_bEnalbleNotify; - IPopup_Note* m_pPopupNote; - CFX_WideString m_sReplyString; +class CPWL_Note : public CPWL_NoteItem { + public: + CPWL_Note(IPopup_Note* pPopupNote, + IPWL_NoteNotify* pNoteNotify, + IPWL_NoteHandler* pNoteHandler); + virtual ~CPWL_Note(); + + public: + virtual void SetSubjectName(const CFX_WideString& sName); + virtual void SetAuthorName(const CFX_WideString& sName); + virtual CFX_WideString GetAuthorName() const; + virtual void SetBkColor(const CPWL_Color& color); + virtual void ResetSubjectName(int32_t nItemIndex) {} + virtual FX_BOOL IsTopItem() const { return TRUE; } + virtual const CPWL_Note* GetNote() const; + virtual IPWL_NoteNotify* GetNoteNotify() const; + + public: + IPWL_NoteItem* Reply(); + void EnableNotify(FX_BOOL bEnabled); + void SetIconType(int32_t nType); + void SetOptionsText(const CFX_WideString& sText); + void EnableRead(FX_BOOL bEnabled); + void EnableModify(FX_BOOL bEnabled); + + CFX_WideString GetReplyString() const; + void SetReplyString(const CFX_WideString& string); + + // 0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close + // / 5-options + int32_t NoteHitTest(const CPDF_Point& point) const; + CPDF_Rect GetCaptionRect() const { return m_rcCaption; } + IPopup_Note* GetPopupNote() const { return m_pPopupNote; } + + public: + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseWheel(short zDelta, + const CPDF_Point& point, + FX_DWORD nFlag); + + protected: + virtual void RePosChildWnd(); + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + + FX_BOOL ResetScrollBar(); + void RePosNoteChildren(); + FX_BOOL ScrollBarShouldVisible(); + + private: + CPWL_Label* m_pAuthor; + CPWL_Note_Icon* m_pIcon; + CPWL_Note_CloseBox* m_pCloseBox; + CPWL_Note_LBBox* m_pLBBox; + CPWL_Note_RBBox* m_pRBBox; + CPWL_ScrollBar* m_pContentsBar; + CPWL_Note_Options* m_pOptions; + IPWL_NoteNotify* m_pNoteNotify; + FX_BOOL m_bResizing; + PWL_SCROLL_INFO m_OldScrollInfo; + CPDF_Rect m_rcCaption; + FX_BOOL m_bEnalbleNotify; + IPopup_Note* m_pPopupNote; + CFX_WideString m_sReplyString; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_NOTE_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_ScrollBar.h b/fpdfsdk/include/pdfwindow/PWL_ScrollBar.h index 0390222545..a149a01416 100644 --- a/fpdfsdk/include/pdfwindow/PWL_ScrollBar.h +++ b/fpdfsdk/include/pdfwindow/PWL_ScrollBar.h @@ -12,155 +12,150 @@ class CPWL_SBButton; class CPWL_ScrollBar; -struct PWL_SCROLL_INFO -{ -public: - PWL_SCROLL_INFO() : fContentMin(0.0f), fContentMax(0.0f), fPlateWidth(0.0f), fBigStep(0.0f), fSmallStep(0.0f) - { - } - FX_FLOAT fContentMin; - FX_FLOAT fContentMax; - FX_FLOAT fPlateWidth; - FX_FLOAT fBigStep; - FX_FLOAT fSmallStep; +struct PWL_SCROLL_INFO { + public: + PWL_SCROLL_INFO() + : fContentMin(0.0f), + fContentMax(0.0f), + fPlateWidth(0.0f), + fBigStep(0.0f), + fSmallStep(0.0f) {} + FX_FLOAT fContentMin; + FX_FLOAT fContentMax; + FX_FLOAT fPlateWidth; + FX_FLOAT fBigStep; + FX_FLOAT fSmallStep; }; -enum PWL_SCROLLBAR_TYPE -{ - SBT_HSCROLL, - SBT_VSCROLL -}; +enum PWL_SCROLLBAR_TYPE { SBT_HSCROLL, SBT_VSCROLL }; -enum PWL_SBBUTTON_TYPE -{ - PSBT_MIN, - PSBT_MAX, - PSBT_POS -}; +enum PWL_SBBUTTON_TYPE { PSBT_MIN, PSBT_MAX, PSBT_POS }; + +class CPWL_SBButton : public CPWL_Wnd { + public: + CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, + PWL_SBBUTTON_TYPE eButtonType); + virtual ~CPWL_SBButton(); -class CPWL_SBButton : public CPWL_Wnd -{ -public: - CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,PWL_SBBUTTON_TYPE eButtonType); - virtual ~CPWL_SBButton(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - -protected: - PWL_SCROLLBAR_TYPE m_eScrollBarType; - PWL_SBBUTTON_TYPE m_eSBButtonType; - - FX_BOOL m_bMouseDown; + public: + virtual CFX_ByteString GetClassName() const; + virtual void OnCreate(PWL_CREATEPARAM& cp); + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag); + + protected: + PWL_SCROLLBAR_TYPE m_eScrollBarType; + PWL_SBBUTTON_TYPE m_eSBButtonType; + + FX_BOOL m_bMouseDown; }; -struct PWL_FLOATRANGE -{ -public: - PWL_FLOATRANGE(); - PWL_FLOATRANGE(FX_FLOAT min,FX_FLOAT max); - void Default(); - void Set(FX_FLOAT min,FX_FLOAT max); - FX_BOOL In(FX_FLOAT x) const; - FX_FLOAT GetWidth() const; - - FX_FLOAT fMin,fMax; +struct PWL_FLOATRANGE { + public: + PWL_FLOATRANGE(); + PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max); + void Default(); + void Set(FX_FLOAT min, FX_FLOAT max); + FX_BOOL In(FX_FLOAT x) const; + FX_FLOAT GetWidth() const; + + FX_FLOAT fMin, fMax; }; -struct PWL_SCROLL_PRIVATEDATA -{ -public: - PWL_SCROLL_PRIVATEDATA(); - - void Default(); - void SetScrollRange(FX_FLOAT min,FX_FLOAT max); - void SetClientWidth(FX_FLOAT width); - void SetSmallStep(FX_FLOAT step); - void SetBigStep(FX_FLOAT step); - FX_BOOL SetPos(FX_FLOAT pos); - - void AddSmall(); - void SubSmall(); - void AddBig(); - void SubBig(); - - PWL_FLOATRANGE ScrollRange; - FX_FLOAT fClientWidth; - FX_FLOAT fScrollPos; - FX_FLOAT fBigStep; - FX_FLOAT fSmallStep; +struct PWL_SCROLL_PRIVATEDATA { + public: + PWL_SCROLL_PRIVATEDATA(); + + void Default(); + void SetScrollRange(FX_FLOAT min, FX_FLOAT max); + void SetClientWidth(FX_FLOAT width); + void SetSmallStep(FX_FLOAT step); + void SetBigStep(FX_FLOAT step); + FX_BOOL SetPos(FX_FLOAT pos); + + void AddSmall(); + void SubSmall(); + void AddBig(); + void SubBig(); + + PWL_FLOATRANGE ScrollRange; + FX_FLOAT fClientWidth; + FX_FLOAT fScrollPos; + FX_FLOAT fBigStep; + FX_FLOAT fSmallStep; }; -class CPWL_ScrollBar : public CPWL_Wnd -{ -public: - CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType = SBT_HSCROLL); - virtual ~CPWL_ScrollBar(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - FX_FLOAT GetScrollBarWidth() const; - PWL_SCROLLBAR_TYPE GetScrollBarType() const {return m_sbType;}; - - void SetNotifyForever(FX_BOOL bForever) {m_bNotifyForever = bForever;} - -protected: - void SetScrollRange(FX_FLOAT fMin,FX_FLOAT fMax,FX_FLOAT fClientWidth); - void SetScrollPos(FX_FLOAT fPos); - void MovePosButton(FX_BOOL bRefresh); - void SetScrollStep(FX_FLOAT fBigStep,FX_FLOAT fSmallStep); - void NotifyScrollWindow(); - CPDF_Rect GetScrollArea() const; - -private: - void CreateButtons(const PWL_CREATEPARAM & cp); - - void OnMinButtonLBDown(const CPDF_Point & point); - void OnMinButtonLBUp(const CPDF_Point & point); - void OnMinButtonMouseMove(const CPDF_Point & point); - - void OnMaxButtonLBDown(const CPDF_Point & point); - void OnMaxButtonLBUp(const CPDF_Point & point); - void OnMaxButtonMouseMove(const CPDF_Point & point); - - void OnPosButtonLBDown(const CPDF_Point & point); - void OnPosButtonLBUp(const CPDF_Point & point); - void OnPosButtonMouseMove(const CPDF_Point & point); - - FX_FLOAT TrueToFace(FX_FLOAT); - FX_FLOAT FaceToTrue(FX_FLOAT); - - virtual void TimerProc(); - -private: - PWL_SCROLLBAR_TYPE m_sbType; - PWL_SCROLL_INFO m_OriginInfo; - CPWL_SBButton* m_pMinButton; - CPWL_SBButton* m_pMaxButton; - CPWL_SBButton* m_pPosButton; - PWL_SCROLL_PRIVATEDATA m_sData; - FX_BOOL m_bMouseDown; - FX_BOOL m_bMinOrMax; - FX_BOOL m_bNotifyForever; - FX_FLOAT m_nOldPos; - FX_FLOAT m_fOldPosButton; +class CPWL_ScrollBar : public CPWL_Wnd { + public: + CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType = SBT_HSCROLL); + virtual ~CPWL_ScrollBar(); + + public: + virtual CFX_ByteString GetClassName() const; + virtual void OnCreate(PWL_CREATEPARAM& cp); + virtual void RePosChildWnd(); + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + + FX_FLOAT GetScrollBarWidth() const; + PWL_SCROLLBAR_TYPE GetScrollBarType() const { return m_sbType; }; + + void SetNotifyForever(FX_BOOL bForever) { m_bNotifyForever = bForever; } + + protected: + void SetScrollRange(FX_FLOAT fMin, FX_FLOAT fMax, FX_FLOAT fClientWidth); + void SetScrollPos(FX_FLOAT fPos); + void MovePosButton(FX_BOOL bRefresh); + void SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep); + void NotifyScrollWindow(); + CPDF_Rect GetScrollArea() const; + + private: + void CreateButtons(const PWL_CREATEPARAM& cp); + + void OnMinButtonLBDown(const CPDF_Point& point); + void OnMinButtonLBUp(const CPDF_Point& point); + void OnMinButtonMouseMove(const CPDF_Point& point); + + void OnMaxButtonLBDown(const CPDF_Point& point); + void OnMaxButtonLBUp(const CPDF_Point& point); + void OnMaxButtonMouseMove(const CPDF_Point& point); + + void OnPosButtonLBDown(const CPDF_Point& point); + void OnPosButtonLBUp(const CPDF_Point& point); + void OnPosButtonMouseMove(const CPDF_Point& point); + + FX_FLOAT TrueToFace(FX_FLOAT); + FX_FLOAT FaceToTrue(FX_FLOAT); + + virtual void TimerProc(); + + private: + PWL_SCROLLBAR_TYPE m_sbType; + PWL_SCROLL_INFO m_OriginInfo; + CPWL_SBButton* m_pMinButton; + CPWL_SBButton* m_pMaxButton; + CPWL_SBButton* m_pPosButton; + PWL_SCROLL_PRIVATEDATA m_sData; + FX_BOOL m_bMouseDown; + FX_BOOL m_bMinOrMax; + FX_BOOL m_bNotifyForever; + FX_FLOAT m_nOldPos; + FX_FLOAT m_fOldPosButton; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_SCROLLBAR_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Signature.h b/fpdfsdk/include/pdfwindow/PWL_Signature.h index d9be322a7d..c48d4e9708 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Signature.h +++ b/fpdfsdk/include/pdfwindow/PWL_Signature.h @@ -13,55 +13,55 @@ class CFX_DIBSource; class CPWL_Label; -class CPWL_Signature_Image : public CPWL_Image -{ -public: - CPWL_Signature_Image(); - virtual ~CPWL_Signature_Image(); +class CPWL_Signature_Image : public CPWL_Image { + public: + CPWL_Signature_Image(); + virtual ~CPWL_Signature_Image(); - void SetImage(CFX_DIBSource* pImage); - CFX_DIBSource* GetImage(); + void SetImage(CFX_DIBSource* pImage); + CFX_DIBSource* GetImage(); -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); + protected: + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); - virtual void GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale); + virtual void GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale); -private: - CFX_DIBSource* m_pImage; + private: + CFX_DIBSource* m_pImage; }; -class CPWL_Signature : public CPWL_Wnd -{ -public: - CPWL_Signature(); - virtual ~CPWL_Signature(); +class CPWL_Signature : public CPWL_Wnd { + public: + CPWL_Signature(); + virtual ~CPWL_Signature(); - void SetText(const FX_WCHAR* sText); - void SetDescription(const FX_WCHAR* string); - void SetImage(CFX_DIBSource* pImage); - void SetImageStream(CPDF_Stream * pStream, const FX_CHAR* sImageAlias); + void SetText(const FX_WCHAR* sText); + void SetDescription(const FX_WCHAR* string); + void SetImage(CFX_DIBSource* pImage); + void SetImageStream(CPDF_Stream* pStream, const FX_CHAR* sImageAlias); - void SetTextFlag(FX_BOOL bTextExist); - void SetImageFlag(FX_BOOL bImageExist); - void SetFoxitFlag(FX_BOOL bFlagExist); + void SetTextFlag(FX_BOOL bTextExist); + void SetImageFlag(FX_BOOL bImageExist); + void SetFoxitFlag(FX_BOOL bFlagExist); -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); + protected: + virtual void RePosChildWnd(); + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); -private: - CPWL_Label* m_pText; - CPWL_Label* m_pDescription; - CPWL_Signature_Image* m_pImage; + private: + CPWL_Label* m_pText; + CPWL_Label* m_pDescription; + CPWL_Signature_Image* m_pImage; - FX_BOOL m_bTextExist; - FX_BOOL m_bImageExist; - FX_BOOL m_bFlagExist; + FX_BOOL m_bTextExist; + FX_BOOL m_bImageExist; + FX_BOOL m_bFlagExist; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_SIGNATURE_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h b/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h index 31787d79ed..8cfe819a67 100644 --- a/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h +++ b/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h @@ -9,48 +9,45 @@ #include "PWL_Button.h" -class CPWL_PushButton : public CPWL_Button -{ -public: - CPWL_PushButton(); - virtual ~CPWL_PushButton(); - - virtual CFX_ByteString GetClassName() const; - virtual CPDF_Rect GetFocusRect() const; +class CPWL_PushButton : public CPWL_Button { + public: + CPWL_PushButton(); + virtual ~CPWL_PushButton(); + + virtual CFX_ByteString GetClassName() const; + virtual CPDF_Rect GetFocusRect() const; }; -class CPWL_CheckBox : public CPWL_Button -{ -public: - CPWL_CheckBox(); - virtual ~CPWL_CheckBox(); +class CPWL_CheckBox : public CPWL_Button { + public: + CPWL_CheckBox(); + virtual ~CPWL_CheckBox(); - virtual CFX_ByteString GetClassName() const; - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); + virtual CFX_ByteString GetClassName() const; + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - void SetCheck(FX_BOOL bCheck); - FX_BOOL IsChecked() const; + void SetCheck(FX_BOOL bCheck); + FX_BOOL IsChecked() const; -private: - FX_BOOL m_bChecked; + private: + FX_BOOL m_bChecked; }; -class CPWL_RadioButton : public CPWL_Button -{ -public: - CPWL_RadioButton(); - virtual ~CPWL_RadioButton(); +class CPWL_RadioButton : public CPWL_Button { + public: + CPWL_RadioButton(); + virtual ~CPWL_RadioButton(); - virtual CFX_ByteString GetClassName() const; - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); + virtual CFX_ByteString GetClassName() const; + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - void SetCheck(FX_BOOL bCheck); - FX_BOOL IsChecked() const; + void SetCheck(FX_BOOL bCheck); + FX_BOOL IsChecked() const; -private: - FX_BOOL m_bChecked; + private: + FX_BOOL m_bChecked; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_SPECIALBUTTON_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Utils.h b/fpdfsdk/include/pdfwindow/PWL_Utils.h index b58f30e399..e797510d50 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Utils.h +++ b/fpdfsdk/include/pdfwindow/PWL_Utils.h @@ -8,236 +8,406 @@ #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ #include "../../../core/include/fpdfapi/fpdf_parser.h" // For CPDF_Point. -#include "../../../core/include/fpdfdoc/fpdf_vt.h" // For CPVT_WordRange. +#include "../../../core/include/fpdfdoc/fpdf_vt.h" // For CPVT_WordRange. #include "../fxedit/fx_edit.h" #include "PWL_Wnd.h" class CFX_PathData; struct CPWL_Color; -template T PWL_MIN (const T & i, const T & j) { return ((i < j) ? i : j); } -template T PWL_MAX (const T & i, const T & j) { return ((i > j) ? i : j); } - -#define PWL_PDF2WIN(color) (uint8_t(color*255)) -#define PWL_WIN2PDF(color) ((FX_FLOAT)((FX_FLOAT)color/255.0f)) - -#define PWL_MAKEDWORD(low,high) ((FX_DWORD)((FX_WORD)(low) | (FX_DWORD)(((FX_WORD)(high))<<16))) -#define PWL_GETLOWWORD(dword) ((FX_WORD)(dword)) -#define PWL_GETHIGHWORD(dword) ((FX_WORD)(dword>>16)) - -#define PWL_ICONTYPE_CHECKMARK 0 -#define PWL_ICONTYPE_CIRCLE 1 -#define PWL_ICONTYPE_COMMENT 2 -#define PWL_ICONTYPE_CROSS 3 -#define PWL_ICONTYPE_HELP 4 -#define PWL_ICONTYPE_INSERTTEXT 5 -#define PWL_ICONTYPE_KEY 6 -#define PWL_ICONTYPE_NEWPARAGRAPH 7 -#define PWL_ICONTYPE_TEXTNOTE 8 -#define PWL_ICONTYPE_PARAGRAPH 9 -#define PWL_ICONTYPE_RIGHTARROW 10 -#define PWL_ICONTYPE_RIGHTPOINTER 11 -#define PWL_ICONTYPE_STAR 12 -#define PWL_ICONTYPE_UPARROW 13 -#define PWL_ICONTYPE_UPLEFTARROW 14 - -#define PWL_ICONTYPE_GRAPH 15 -#define PWL_ICONTYPE_PAPERCLIP 16 -#define PWL_ICONTYPE_ATTACHMENT 17 -#define PWL_ICONTYPE_TAG 18 - -#define PWL_ICONTYPE_FOXIT 19 - -#define PWL_ICONTYPE_UNKNOWN -1 - -//checkbox & radiobutton style -#define PCS_CHECK 0 -#define PCS_CIRCLE 1 -#define PCS_CROSS 2 -#define PCS_DIAMOND 3 -#define PCS_SQUARE 4 -#define PCS_STAR 5 - -#define PWL_PI 3.14159265358979f -#define PWL_BEZIER 0.5522847498308f - -//pushbutton layout style -#define PPBL_LABEL 0 -#define PPBL_ICON 1 -#define PPBL_ICONTOPLABELBOTTOM 2 -#define PPBL_LABELTOPICONBOTTOM 3 -#define PPBL_ICONLEFTLABELRIGHT 4 -#define PPBL_LABELLEFTICONRIGHT 5 -#define PPBL_LABELOVERICON 6 - -class CPWL_Point : public CPDF_Point -{ -public: - CPWL_Point() : CPDF_Point(0.0f,0.0f){} - CPWL_Point(FX_FLOAT fx, FX_FLOAT fy) : CPDF_Point(fx,fy) {} - CPWL_Point(const CPWL_Point& point) : CPDF_Point(point.x, point.y) {} +template +T PWL_MIN(const T& i, const T& j) { + return ((i < j) ? i : j); +} +template +T PWL_MAX(const T& i, const T& j) { + return ((i > j) ? i : j); +} + +#define PWL_PDF2WIN(color) (uint8_t(color * 255)) +#define PWL_WIN2PDF(color) ((FX_FLOAT)((FX_FLOAT)color / 255.0f)) + +#define PWL_MAKEDWORD(low, high) \ + ((FX_DWORD)((FX_WORD)(low) | (FX_DWORD)(((FX_WORD)(high)) << 16))) +#define PWL_GETLOWWORD(dword) ((FX_WORD)(dword)) +#define PWL_GETHIGHWORD(dword) ((FX_WORD)(dword >> 16)) + +#define PWL_ICONTYPE_CHECKMARK 0 +#define PWL_ICONTYPE_CIRCLE 1 +#define PWL_ICONTYPE_COMMENT 2 +#define PWL_ICONTYPE_CROSS 3 +#define PWL_ICONTYPE_HELP 4 +#define PWL_ICONTYPE_INSERTTEXT 5 +#define PWL_ICONTYPE_KEY 6 +#define PWL_ICONTYPE_NEWPARAGRAPH 7 +#define PWL_ICONTYPE_TEXTNOTE 8 +#define PWL_ICONTYPE_PARAGRAPH 9 +#define PWL_ICONTYPE_RIGHTARROW 10 +#define PWL_ICONTYPE_RIGHTPOINTER 11 +#define PWL_ICONTYPE_STAR 12 +#define PWL_ICONTYPE_UPARROW 13 +#define PWL_ICONTYPE_UPLEFTARROW 14 + +#define PWL_ICONTYPE_GRAPH 15 +#define PWL_ICONTYPE_PAPERCLIP 16 +#define PWL_ICONTYPE_ATTACHMENT 17 +#define PWL_ICONTYPE_TAG 18 + +#define PWL_ICONTYPE_FOXIT 19 + +#define PWL_ICONTYPE_UNKNOWN -1 + +// checkbox & radiobutton style +#define PCS_CHECK 0 +#define PCS_CIRCLE 1 +#define PCS_CROSS 2 +#define PCS_DIAMOND 3 +#define PCS_SQUARE 4 +#define PCS_STAR 5 + +#define PWL_PI 3.14159265358979f +#define PWL_BEZIER 0.5522847498308f + +// pushbutton layout style +#define PPBL_LABEL 0 +#define PPBL_ICON 1 +#define PPBL_ICONTOPLABELBOTTOM 2 +#define PPBL_LABELTOPICONBOTTOM 3 +#define PPBL_ICONLEFTLABELRIGHT 4 +#define PPBL_LABELLEFTICONRIGHT 5 +#define PPBL_LABELOVERICON 6 + +class CPWL_Point : public CPDF_Point { + public: + CPWL_Point() : CPDF_Point(0.0f, 0.0f) {} + CPWL_Point(FX_FLOAT fx, FX_FLOAT fy) : CPDF_Point(fx, fy) {} + CPWL_Point(const CPWL_Point& point) : CPDF_Point(point.x, point.y) {} }; -enum PWL_PATHDATA_TYPE -{ - PWLPT_MOVETO, - PWLPT_LINETO, - PWLPT_BEZIERTO, - PWLPT_UNKNOWN +enum PWL_PATHDATA_TYPE { + PWLPT_MOVETO, + PWLPT_LINETO, + PWLPT_BEZIERTO, + PWLPT_UNKNOWN }; -enum PWL_PATH_TYPE -{ - PWLPT_PATHDATA, - PWLPT_STREAM -}; +enum PWL_PATH_TYPE { PWLPT_PATHDATA, PWLPT_STREAM }; -class CPWL_PathData -{ -public: - CPWL_PathData() : point(), type(PWLPT_UNKNOWN){} - CPWL_PathData(const CPWL_Point& pt, PWL_PATHDATA_TYPE tp) : point(pt), type(tp) {} +class CPWL_PathData { + public: + CPWL_PathData() : point(), type(PWLPT_UNKNOWN) {} + CPWL_PathData(const CPWL_Point& pt, PWL_PATHDATA_TYPE tp) + : point(pt), type(tp) {} - CPWL_Point point; - PWL_PATHDATA_TYPE type; + CPWL_Point point; + PWL_PATHDATA_TYPE type; }; class IPWL_SpellCheck; -class CPWL_Utils -{ -public: - static CPDF_Rect InflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); - static CPDF_Rect DeflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); - static FX_BOOL IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); - static FX_BOOL ContainsRect(const CPDF_Rect& rcParent, const CPDF_Rect& rcChild); - static CPDF_Rect ScaleRect(const CPDF_Rect& rcRect,FX_FLOAT fScale); - static CPVT_WordRange OverlapWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2); - static CPDF_Rect GetCenterSquare(const CPDF_Rect & rect); - static CPWL_Color SubstractColor(const CPWL_Color & sColor,FX_FLOAT fColorSub); - static CPWL_Color DevideColor(const CPWL_Color & sColor,FX_FLOAT fColorDevide); - static CPDF_Rect MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2); - static CPDF_Rect OffsetRect(const CPDF_Rect & rect,FX_FLOAT x,FX_FLOAT y); - static CPDF_Point OffsetPoint(const CPDF_Point & point,FX_FLOAT x,FX_FLOAT y); - static FX_COLORREF PWLColorToFXColor(const CPWL_Color& color, int32_t nTransparancy = 255); - static FX_BOOL IsBlackOrWhite(const CPWL_Color& color); - static CPWL_Color GetReverseColor(const CPWL_Color& color); - - static CFX_ByteString GetColorAppStream(const CPWL_Color & color,const FX_BOOL & bFillOrStroke = TRUE); - static CFX_ByteString GetBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth, - const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, - int32_t nStyle, const CPWL_Dash & dash); - static CFX_ByteString GetCircleBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth, - const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, - int32_t nStyle, const CPWL_Dash & dash); - static CFX_ByteString GetRectFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color); - static CFX_ByteString GetCircleFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color); - - static CFX_ByteString GetPushButtonAppStream(const CPDF_Rect & rcBBox, - IFX_Edit_FontMap * pFontMap, - CPDF_Stream * pIconStream, - CPDF_IconFit & IconFit, - const CFX_WideString & sLabel, - const CPWL_Color & crText, - FX_FLOAT fFontSize, - int32_t nLayOut); - static CFX_ByteString GetCheckBoxAppStream(const CPDF_Rect & rcBBox, - int32_t nStyle, - const CPWL_Color & crText); - static CFX_ByteString GetRadioButtonAppStream(const CPDF_Rect & rcBBox, - int32_t nStyle, - const CPWL_Color & crText); - - static CFX_ByteString GetEditAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, const CPVT_WordRange * pRange = NULL, - FX_BOOL bContinuous = TRUE, FX_WORD SubWord = 0); - static CFX_ByteString GetEditSelAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, - const CPVT_WordRange * pRange = NULL); - static CFX_ByteString GetSpellCheckAppStream(IFX_Edit* pEdit, IPWL_SpellCheck* pSpellCheck, - const CPDF_Point & ptOffset, - const CPVT_WordRange * pRange = NULL); - static CFX_ByteString GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_FontMap * pFontMap, - const CFX_WideString & sText, int32_t nAlignmentH, int32_t nAlignmentV, - FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL bAutoReturn, const CPWL_Color & crText); - static CFX_ByteString GetDropButtonAppStream(const CPDF_Rect & rcBBox); - - static void DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect, - const CPWL_Color & color, int32_t nTransparancy); - static void DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect & rect,const FX_COLORREF & color); - static void DrawStrokeRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect, - const FX_COLORREF & color, FX_FLOAT fWidth); - static void DrawStrokeLine(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Point & ptMoveTo, const CPDF_Point & ptLineTo, const FX_COLORREF & color, FX_FLOAT fWidth); - static void DrawBorder(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect & rect, FX_FLOAT fWidth, - const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, - int32_t nStyle, const CPWL_Dash & dash, int32_t nTransparancy); - static void DrawFillArea(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Point* pPts, int32_t nCount, const FX_COLORREF& color); - static void DrawShadow(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_BOOL bVertical, FX_BOOL bHorizontal, CPDF_Rect rect, - int32_t nTransparancy, int32_t nStartGray, int32_t nEndGray); - static void DrawEditSpellCheck(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, - IPWL_SpellCheck* pSpellCheck); -public: - static void ConvertCMYK2RGB(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB); - static void ConvertRGB2CMYK(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK); - - static void ConvertRGB2GRAY(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dGray); - static void ConvertGRAY2RGB(FX_FLOAT dGray,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB); - - static void ConvertCMYK2GRAY(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dGray); - static void ConvertGRAY2CMYK(FX_FLOAT dGray,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK); - - static void PWLColorToARGB(const CPWL_Color& color, int32_t& alpha, FX_FLOAT& red, FX_FLOAT& green, FX_FLOAT& blue); - -public: - static CFX_ByteString GetIconAppStream(int32_t nType, const CPDF_Rect& rect, const CPWL_Color& crFill, - const CPWL_Color& crStroke = PWL_DEFAULT_BLACKCOLOR); - static void DrawIconAppStream(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - int32_t nType, const CPDF_Rect & rect, const CPWL_Color& crFill, - const CPWL_Color& crStroke, const int32_t nTransparancy); - -private: - static CFX_ByteString GetAppStreamFromArray(const CPWL_PathData* pPathData, int32_t nCount); - static void GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, int32_t nCount); - - static CFX_ByteString GetAppStream_Check(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Circle(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Cross(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Diamond(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Square(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Star(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - - static CFX_ByteString GetAP_Check(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Circle(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Cross(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Diamond(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Square(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Star(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_HalfCircle(const CPDF_Rect & crBBox,FX_FLOAT fRotate); - - static void GetGraphics_Checkmark(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Circle(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Comment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Cross(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Help(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_InsertText(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Key(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_NewParagraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_TextNote(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Paragraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_RightArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_RightPointer(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Star(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_UpArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Graph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Paperclip(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Attachment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Tag(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Foxit(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); +class CPWL_Utils { + public: + static CPDF_Rect InflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); + static CPDF_Rect DeflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); + static FX_BOOL IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); + static FX_BOOL ContainsRect(const CPDF_Rect& rcParent, + const CPDF_Rect& rcChild); + static CPDF_Rect ScaleRect(const CPDF_Rect& rcRect, FX_FLOAT fScale); + static CPVT_WordRange OverlapWordRange(const CPVT_WordRange& wr1, + const CPVT_WordRange& wr2); + static CPDF_Rect GetCenterSquare(const CPDF_Rect& rect); + static CPWL_Color SubstractColor(const CPWL_Color& sColor, + FX_FLOAT fColorSub); + static CPWL_Color DevideColor(const CPWL_Color& sColor, + FX_FLOAT fColorDevide); + static CPDF_Rect MaxRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); + static CPDF_Rect OffsetRect(const CPDF_Rect& rect, FX_FLOAT x, FX_FLOAT y); + static CPDF_Point OffsetPoint(const CPDF_Point& point, + FX_FLOAT x, + FX_FLOAT y); + static FX_COLORREF PWLColorToFXColor(const CPWL_Color& color, + int32_t nTransparancy = 255); + static FX_BOOL IsBlackOrWhite(const CPWL_Color& color); + static CPWL_Color GetReverseColor(const CPWL_Color& color); + + static CFX_ByteString GetColorAppStream(const CPWL_Color& color, + const FX_BOOL& bFillOrStroke = TRUE); + static CFX_ByteString GetBorderAppStream(const CPDF_Rect& rect, + FX_FLOAT fWidth, + const CPWL_Color& color, + const CPWL_Color& crLeftTop, + const CPWL_Color& crRightBottom, + int32_t nStyle, + const CPWL_Dash& dash); + static CFX_ByteString GetCircleBorderAppStream( + const CPDF_Rect& rect, + FX_FLOAT fWidth, + const CPWL_Color& color, + const CPWL_Color& crLeftTop, + const CPWL_Color& crRightBottom, + int32_t nStyle, + const CPWL_Dash& dash); + static CFX_ByteString GetRectFillAppStream(const CPDF_Rect& rect, + const CPWL_Color& color); + static CFX_ByteString GetCircleFillAppStream(const CPDF_Rect& rect, + const CPWL_Color& color); + + static CFX_ByteString GetPushButtonAppStream(const CPDF_Rect& rcBBox, + IFX_Edit_FontMap* pFontMap, + CPDF_Stream* pIconStream, + CPDF_IconFit& IconFit, + const CFX_WideString& sLabel, + const CPWL_Color& crText, + FX_FLOAT fFontSize, + int32_t nLayOut); + static CFX_ByteString GetCheckBoxAppStream(const CPDF_Rect& rcBBox, + int32_t nStyle, + const CPWL_Color& crText); + static CFX_ByteString GetRadioButtonAppStream(const CPDF_Rect& rcBBox, + int32_t nStyle, + const CPWL_Color& crText); + + static CFX_ByteString GetEditAppStream(IFX_Edit* pEdit, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange = NULL, + FX_BOOL bContinuous = TRUE, + FX_WORD SubWord = 0); + static CFX_ByteString GetEditSelAppStream( + IFX_Edit* pEdit, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange = NULL); + static CFX_ByteString GetSpellCheckAppStream( + IFX_Edit* pEdit, + IPWL_SpellCheck* pSpellCheck, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange = NULL); + static CFX_ByteString GetTextAppStream(const CPDF_Rect& rcBBox, + IFX_Edit_FontMap* pFontMap, + const CFX_WideString& sText, + int32_t nAlignmentH, + int32_t nAlignmentV, + FX_FLOAT fFontSize, + FX_BOOL bMultiLine, + FX_BOOL bAutoReturn, + const CPWL_Color& crText); + static CFX_ByteString GetDropButtonAppStream(const CPDF_Rect& rcBBox); + + static void DrawFillRect(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Rect& rect, + const CPWL_Color& color, + int32_t nTransparancy); + static void DrawFillRect(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Rect& rect, + const FX_COLORREF& color); + static void DrawStrokeRect(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Rect& rect, + const FX_COLORREF& color, + FX_FLOAT fWidth); + static void DrawStrokeLine(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Point& ptMoveTo, + const CPDF_Point& ptLineTo, + const FX_COLORREF& color, + FX_FLOAT fWidth); + static void DrawBorder(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Rect& rect, + FX_FLOAT fWidth, + const CPWL_Color& color, + const CPWL_Color& crLeftTop, + const CPWL_Color& crRightBottom, + int32_t nStyle, + const CPWL_Dash& dash, + int32_t nTransparancy); + static void DrawFillArea(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + const CPDF_Point* pPts, + int32_t nCount, + const FX_COLORREF& color); + static void DrawShadow(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + FX_BOOL bVertical, + FX_BOOL bHorizontal, + CPDF_Rect rect, + int32_t nTransparancy, + int32_t nStartGray, + int32_t nEndGray); + static void DrawEditSpellCheck(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + IFX_Edit* pEdit, + const CPDF_Rect& rcClip, + const CPDF_Point& ptOffset, + const CPVT_WordRange* pRange, + IPWL_SpellCheck* pSpellCheck); + + public: + static void ConvertCMYK2RGB(FX_FLOAT dC, + FX_FLOAT dM, + FX_FLOAT dY, + FX_FLOAT dK, + FX_FLOAT& dR, + FX_FLOAT& dG, + FX_FLOAT& dB); + static void ConvertRGB2CMYK(FX_FLOAT dR, + FX_FLOAT dG, + FX_FLOAT dB, + FX_FLOAT& dC, + FX_FLOAT& dM, + FX_FLOAT& dY, + FX_FLOAT& dK); + + static void ConvertRGB2GRAY(FX_FLOAT dR, + FX_FLOAT dG, + FX_FLOAT dB, + FX_FLOAT& dGray); + static void ConvertGRAY2RGB(FX_FLOAT dGray, + FX_FLOAT& dR, + FX_FLOAT& dG, + FX_FLOAT& dB); + + static void ConvertCMYK2GRAY(FX_FLOAT dC, + FX_FLOAT dM, + FX_FLOAT dY, + FX_FLOAT dK, + FX_FLOAT& dGray); + static void ConvertGRAY2CMYK(FX_FLOAT dGray, + FX_FLOAT& dC, + FX_FLOAT& dM, + FX_FLOAT& dY, + FX_FLOAT& dK); + + static void PWLColorToARGB(const CPWL_Color& color, + int32_t& alpha, + FX_FLOAT& red, + FX_FLOAT& green, + FX_FLOAT& blue); + + public: + static CFX_ByteString GetIconAppStream( + int32_t nType, + const CPDF_Rect& rect, + const CPWL_Color& crFill, + const CPWL_Color& crStroke = PWL_DEFAULT_BLACKCOLOR); + static void DrawIconAppStream(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + int32_t nType, + const CPDF_Rect& rect, + const CPWL_Color& crFill, + const CPWL_Color& crStroke, + const int32_t nTransparancy); + + private: + static CFX_ByteString GetAppStreamFromArray(const CPWL_PathData* pPathData, + int32_t nCount); + static void GetPathDataFromArray(CFX_PathData& path, + const CPWL_PathData* pPathData, + int32_t nCount); + + static CFX_ByteString GetAppStream_Check(const CPDF_Rect& rcBBox, + const CPWL_Color& crText); + static CFX_ByteString GetAppStream_Circle(const CPDF_Rect& rcBBox, + const CPWL_Color& crText); + static CFX_ByteString GetAppStream_Cross(const CPDF_Rect& rcBBox, + const CPWL_Color& crText); + static CFX_ByteString GetAppStream_Diamond(const CPDF_Rect& rcBBox, + const CPWL_Color& crText); + static CFX_ByteString GetAppStream_Square(const CPDF_Rect& rcBBox, + const CPWL_Color& crText); + static CFX_ByteString GetAppStream_Star(const CPDF_Rect& rcBBox, + const CPWL_Color& crText); + + static CFX_ByteString GetAP_Check(const CPDF_Rect& crBBox); + static CFX_ByteString GetAP_Circle(const CPDF_Rect& crBBox); + static CFX_ByteString GetAP_Cross(const CPDF_Rect& crBBox); + static CFX_ByteString GetAP_Diamond(const CPDF_Rect& crBBox); + static CFX_ByteString GetAP_Square(const CPDF_Rect& crBBox); + static CFX_ByteString GetAP_Star(const CPDF_Rect& crBBox); + static CFX_ByteString GetAP_HalfCircle(const CPDF_Rect& crBBox, + FX_FLOAT fRotate); + + static void GetGraphics_Checkmark(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Circle(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Comment(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Cross(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Help(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_InsertText(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Key(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_NewParagraph(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_TextNote(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Paragraph(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_RightArrow(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_RightPointer(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Star(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_UpArrow(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Graph(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Paperclip(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Attachment(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Tag(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); + static void GetGraphics_Foxit(CFX_ByteString& sPathData, + CFX_PathData& path, + const CPDF_Rect& crBBox, + const PWL_PATH_TYPE type); }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ diff --git a/fpdfsdk/include/pdfwindow/PWL_Wnd.h b/fpdfsdk/include/pdfwindow/PWL_Wnd.h index f2b996c747..63fd28b6d1 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/include/pdfwindow/PWL_Wnd.h @@ -21,443 +21,454 @@ class IFX_SystemHandler; class IPWL_Provider; class IPWL_SpellCheck; -//window styles -#define PWS_CHILD 0x80000000L -#define PWS_BORDER 0x40000000L -#define PWS_BACKGROUND 0x20000000L -#define PWS_HSCROLL 0x10000000L -#define PWS_VSCROLL 0x08000000L -#define PWS_VISIBLE 0x04000000L -#define PWS_DISABLE 0x02000000L -#define PWS_READONLY 0x01000000L -#define PWS_AUTOFONTSIZE 0x00800000L -#define PWS_AUTOTRANSPARENT 0x00400000L -#define PWS_NOREFRESHCLIP 0x00200000L - -//edit and label styles -#define PES_MULTILINE 0x0001L -#define PES_PASSWORD 0x0002L -#define PES_LEFT 0x0004L -#define PES_RIGHT 0x0008L -#define PES_MIDDLE 0x0010L -#define PES_TOP 0x0020L -#define PES_BOTTOM 0x0040L -#define PES_CENTER 0x0080L -#define PES_CHARARRAY 0x0100L -#define PES_AUTOSCROLL 0x0200L -#define PES_AUTORETURN 0x0400L -#define PES_UNDO 0x0800L -#define PES_RICH 0x1000L -#define PES_SPELLCHECK 0x2000L -#define PES_TEXTOVERFLOW 0x4000L -#define PES_NOREAD 0x8000L - -//listbox styles -#define PLBS_MULTIPLESEL 0x0001L -#define PLBS_HOVERSEL 0x0008L - -//combobox styles -#define PCBS_ALLOWCUSTOMTEXT 0x0001L - -//richedit styles -#define PRES_MULTILINE 0x0001L -#define PRES_AUTORETURN 0x0002L -#define PRES_AUTOSCROLL 0x0004L -#define PRES_SPELLCHECK 0x0008L -#define PRES_UNDO 0x0100L -#define PRES_MULTIPAGES 0x0200L -#define PRES_TEXTOVERFLOW 0x0400L - -//border style -#define PBS_SOLID 0 -#define PBS_DASH 1 -#define PBS_BEVELED 2 -#define PBS_INSET 3 -#define PBS_UNDERLINED 4 -#define PBS_SHADOW 5 - -//notification messages -#define PNM_ADDCHILD 0x00000000L -#define PNM_REMOVECHILD 0x00000001L -#define PNM_SETSCROLLINFO 0x00000002L -#define PNM_SETSCROLLPOS 0x00000003L -#define PNM_SCROLLWINDOW 0x00000004L -#define PNM_LBUTTONDOWN 0x00000005L -#define PNM_LBUTTONUP 0x00000006L -#define PNM_MOUSEMOVE 0x00000007L -#define PNM_NOTERESET 0x00000008L -#define PNM_SETCARETINFO 0x00000009L -#define PNM_SELCHANGED 0x0000000AL -#define PNM_NOTEEDITCHANGED 0x0000000BL - -#define PWL_CLASSNAME_EDIT "CPWL_Edit" - -struct CPWL_Dash -{ - CPWL_Dash(int32_t dash, int32_t gap, int32_t phase) : nDash(dash), nGap(gap), nPhase(phase) - {} - - int32_t nDash; - int32_t nGap; - int32_t nPhase; +// window styles +#define PWS_CHILD 0x80000000L +#define PWS_BORDER 0x40000000L +#define PWS_BACKGROUND 0x20000000L +#define PWS_HSCROLL 0x10000000L +#define PWS_VSCROLL 0x08000000L +#define PWS_VISIBLE 0x04000000L +#define PWS_DISABLE 0x02000000L +#define PWS_READONLY 0x01000000L +#define PWS_AUTOFONTSIZE 0x00800000L +#define PWS_AUTOTRANSPARENT 0x00400000L +#define PWS_NOREFRESHCLIP 0x00200000L + +// edit and label styles +#define PES_MULTILINE 0x0001L +#define PES_PASSWORD 0x0002L +#define PES_LEFT 0x0004L +#define PES_RIGHT 0x0008L +#define PES_MIDDLE 0x0010L +#define PES_TOP 0x0020L +#define PES_BOTTOM 0x0040L +#define PES_CENTER 0x0080L +#define PES_CHARARRAY 0x0100L +#define PES_AUTOSCROLL 0x0200L +#define PES_AUTORETURN 0x0400L +#define PES_UNDO 0x0800L +#define PES_RICH 0x1000L +#define PES_SPELLCHECK 0x2000L +#define PES_TEXTOVERFLOW 0x4000L +#define PES_NOREAD 0x8000L + +// listbox styles +#define PLBS_MULTIPLESEL 0x0001L +#define PLBS_HOVERSEL 0x0008L + +// combobox styles +#define PCBS_ALLOWCUSTOMTEXT 0x0001L + +// richedit styles +#define PRES_MULTILINE 0x0001L +#define PRES_AUTORETURN 0x0002L +#define PRES_AUTOSCROLL 0x0004L +#define PRES_SPELLCHECK 0x0008L +#define PRES_UNDO 0x0100L +#define PRES_MULTIPAGES 0x0200L +#define PRES_TEXTOVERFLOW 0x0400L + +// border style +#define PBS_SOLID 0 +#define PBS_DASH 1 +#define PBS_BEVELED 2 +#define PBS_INSET 3 +#define PBS_UNDERLINED 4 +#define PBS_SHADOW 5 + +// notification messages +#define PNM_ADDCHILD 0x00000000L +#define PNM_REMOVECHILD 0x00000001L +#define PNM_SETSCROLLINFO 0x00000002L +#define PNM_SETSCROLLPOS 0x00000003L +#define PNM_SCROLLWINDOW 0x00000004L +#define PNM_LBUTTONDOWN 0x00000005L +#define PNM_LBUTTONUP 0x00000006L +#define PNM_MOUSEMOVE 0x00000007L +#define PNM_NOTERESET 0x00000008L +#define PNM_SETCARETINFO 0x00000009L +#define PNM_SELCHANGED 0x0000000AL +#define PNM_NOTEEDITCHANGED 0x0000000BL + +#define PWL_CLASSNAME_EDIT "CPWL_Edit" + +struct CPWL_Dash { + CPWL_Dash(int32_t dash, int32_t gap, int32_t phase) + : nDash(dash), nGap(gap), nPhase(phase) {} + + int32_t nDash; + int32_t nGap; + int32_t nPhase; }; -struct CPWL_Color -{ - CPWL_Color(int32_t type = COLORTYPE_TRANSPARENT, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f) - : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4) - {} - - CPWL_Color(int32_t r, int32_t g, int32_t b) : - nColorType(COLORTYPE_RGB), fColor1(r/255.0f), fColor2(g/255.0f), fColor3(b/255.0f), fColor4(0) - {} - - void ConvertColorType(int32_t other_nColorType); - - /* - COLORTYPE_TRANSPARENT - COLORTYPE_RGB - COLORTYPE_CMYK - COLORTYPE_GRAY - */ - int32_t nColorType; - FX_FLOAT fColor1,fColor2,fColor3,fColor4; +struct CPWL_Color { + CPWL_Color(int32_t type = COLORTYPE_TRANSPARENT, + FX_FLOAT color1 = 0.0f, + FX_FLOAT color2 = 0.0f, + FX_FLOAT color3 = 0.0f, + FX_FLOAT color4 = 0.0f) + : nColorType(type), + fColor1(color1), + fColor2(color2), + fColor3(color3), + fColor4(color4) {} + + CPWL_Color(int32_t r, int32_t g, int32_t b) + : nColorType(COLORTYPE_RGB), + fColor1(r / 255.0f), + fColor2(g / 255.0f), + fColor3(b / 255.0f), + fColor4(0) {} + + void ConvertColorType(int32_t other_nColorType); + + /* + COLORTYPE_TRANSPARENT + COLORTYPE_RGB + COLORTYPE_CMYK + COLORTYPE_GRAY + */ + int32_t nColorType; + FX_FLOAT fColor1, fColor2, fColor3, fColor4; }; -inline FX_BOOL operator == (const CPWL_Color &c1, const CPWL_Color &c2) -{ - return c1.nColorType == c2.nColorType && - c1.fColor1 - c2.fColor1 < 0.0001 && c1.fColor1 - c2.fColor1 > -0.0001 && - c1.fColor2 - c2.fColor2 < 0.0001 && c1.fColor2 - c2.fColor2 > -0.0001 && - c1.fColor3 - c2.fColor3 < 0.0001 && c1.fColor3 - c2.fColor3 > -0.0001 && - c1.fColor4 - c2.fColor4 < 0.0001 && c1.fColor4 - c2.fColor4 > -0.0001; +inline FX_BOOL operator==(const CPWL_Color& c1, const CPWL_Color& c2) { + return c1.nColorType == c2.nColorType && c1.fColor1 - c2.fColor1 < 0.0001 && + c1.fColor1 - c2.fColor1 > -0.0001 && + c1.fColor2 - c2.fColor2 < 0.0001 && + c1.fColor2 - c2.fColor2 > -0.0001 && + c1.fColor3 - c2.fColor3 < 0.0001 && + c1.fColor3 - c2.fColor3 > -0.0001 && + c1.fColor4 - c2.fColor4 < 0.0001 && c1.fColor4 - c2.fColor4 > -0.0001; } -inline FX_BOOL operator != (const CPWL_Color &c1, const CPWL_Color &c2) -{ - return !operator == (c1, c2); +inline FX_BOOL operator!=(const CPWL_Color& c1, const CPWL_Color& c2) { + return !operator==(c1, c2); } -#define PWL_SCROLLBAR_WIDTH 12.0f -#define PWL_SCROLLBAR_BUTTON_WIDTH 9.0f -#define PWL_SCROLLBAR_POSBUTTON_MINWIDTH 2.0f -#define PWL_SCROLLBAR_TRANSPARANCY 150 -#define PWL_SCROLLBAR_BKCOLOR CPWL_Color(COLORTYPE_RGB,220.0f/255.0f,220.0f/255.0f,220.0f/255.0f) -#define PWL_DEFAULT_SELTEXTCOLOR CPWL_Color(COLORTYPE_RGB,1,1,1) -#define PWL_DEFAULT_SELBACKCOLOR CPWL_Color(COLORTYPE_RGB,0,51.0f/255.0f,113.0f/255.0f) -#define PWL_DEFAULT_BACKCOLOR PWL_DEFAULT_SELTEXTCOLOR -#define PWL_DEFAULT_TEXTCOLOR CPWL_Color(COLORTYPE_RGB,0,0,0) -#define PWL_DEFAULT_FONTSIZE 9.0f -#define PWL_DEFAULT_BLACKCOLOR CPWL_Color(COLORTYPE_GRAY,0) -#define PWL_DEFAULT_WHITECOLOR CPWL_Color(COLORTYPE_GRAY,1) -#define PWL_DEFAULT_HEAVYGRAYCOLOR CPWL_Color(COLORTYPE_GRAY,0.50) -#define PWL_DEFAULT_LIGHTGRAYCOLOR CPWL_Color(COLORTYPE_GRAY,0.75) -#define PWL_TRIANGLE_HALFLEN 2.0f -#define PWL_CBBUTTON_TRIANGLE_HALFLEN 3.0f -#define PWL_INVALIDATE_INFLATE 2 - -class IPWL_SpellCheck -{ -public: - virtual ~IPWL_SpellCheck() { } - virtual FX_BOOL CheckWord(const FX_CHAR* sWord) = 0; - virtual void SuggestWords(const FX_CHAR* sWord, CFX_ByteStringArray & sSuggest) = 0; +#define PWL_SCROLLBAR_WIDTH 12.0f +#define PWL_SCROLLBAR_BUTTON_WIDTH 9.0f +#define PWL_SCROLLBAR_POSBUTTON_MINWIDTH 2.0f +#define PWL_SCROLLBAR_TRANSPARANCY 150 +#define PWL_SCROLLBAR_BKCOLOR \ + CPWL_Color(COLORTYPE_RGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f) +#define PWL_DEFAULT_SELTEXTCOLOR CPWL_Color(COLORTYPE_RGB, 1, 1, 1) +#define PWL_DEFAULT_SELBACKCOLOR \ + CPWL_Color(COLORTYPE_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f) +#define PWL_DEFAULT_BACKCOLOR PWL_DEFAULT_SELTEXTCOLOR +#define PWL_DEFAULT_TEXTCOLOR CPWL_Color(COLORTYPE_RGB, 0, 0, 0) +#define PWL_DEFAULT_FONTSIZE 9.0f +#define PWL_DEFAULT_BLACKCOLOR CPWL_Color(COLORTYPE_GRAY, 0) +#define PWL_DEFAULT_WHITECOLOR CPWL_Color(COLORTYPE_GRAY, 1) +#define PWL_DEFAULT_HEAVYGRAYCOLOR CPWL_Color(COLORTYPE_GRAY, 0.50) +#define PWL_DEFAULT_LIGHTGRAYCOLOR CPWL_Color(COLORTYPE_GRAY, 0.75) +#define PWL_TRIANGLE_HALFLEN 2.0f +#define PWL_CBBUTTON_TRIANGLE_HALFLEN 3.0f +#define PWL_INVALIDATE_INFLATE 2 + +class IPWL_SpellCheck { + public: + virtual ~IPWL_SpellCheck() {} + virtual FX_BOOL CheckWord(const FX_CHAR* sWord) = 0; + virtual void SuggestWords(const FX_CHAR* sWord, + CFX_ByteStringArray& sSuggest) = 0; }; -class IPWL_Provider -{ -public: - virtual ~IPWL_Provider() { } - - //get a matrix which map user space to CWnd client space - virtual CPDF_Matrix GetWindowMatrix(void* pAttachedData) = 0; - - /* - 0 L"&Undo\tCtrl+Z" - 1 L"&Redo\tCtrl+Shift+Z" - 2 L"Cu&t\tCtrl+X" - 3 L"&Copy\tCtrl+C" - 4 L"&Paste\tCtrl+V" - 5 L"&Delete" - 6 L"&Select All\tCtrl+A" - */ - virtual CFX_WideString LoadPopupMenuString(int32_t nIndex) = 0; +class IPWL_Provider { + public: + virtual ~IPWL_Provider() {} + + // get a matrix which map user space to CWnd client space + virtual CPDF_Matrix GetWindowMatrix(void* pAttachedData) = 0; + + /* + 0 L"&Undo\tCtrl+Z" + 1 L"&Redo\tCtrl+Shift+Z" + 2 L"Cu&t\tCtrl+X" + 3 L"&Copy\tCtrl+C" + 4 L"&Paste\tCtrl+V" + 5 L"&Delete" + 6 L"&Select All\tCtrl+A" + */ + virtual CFX_WideString LoadPopupMenuString(int32_t nIndex) = 0; }; -class IPWL_FocusHandler -{ -public: - virtual ~IPWL_FocusHandler() { } - virtual void OnSetFocus(CPWL_Wnd* pWnd) = 0; - virtual void OnKillFocus(CPWL_Wnd* pWnd) = 0; +class IPWL_FocusHandler { + public: + virtual ~IPWL_FocusHandler() {} + virtual void OnSetFocus(CPWL_Wnd* pWnd) = 0; + virtual void OnKillFocus(CPWL_Wnd* pWnd) = 0; }; -struct PWL_CREATEPARAM -{ -public: - PWL_CREATEPARAM() : rcRectWnd(0,0,0,0), - pSystemHandler(NULL), - pFontMap(NULL), - pProvider(NULL), - pFocusHandler(NULL), - dwFlags(0), - sBackgroundColor(), - hAttachedWnd(NULL), - pSpellCheck(NULL), - nBorderStyle(PBS_SOLID), - dwBorderWidth(1), - sBorderColor(), - sTextColor(), - sTextStrokeColor(), - nTransparency(255), - fFontSize(PWL_DEFAULT_FONTSIZE), - sDash(3,0,0), - pAttachedData(NULL), - pParentWnd(NULL), - pMsgControl(NULL), - eCursorType(FXCT_ARROW), - mtChild(1,0,0,1,0,0) - { - } - - CPDF_Rect rcRectWnd; //required - IFX_SystemHandler* pSystemHandler; //required - IFX_Edit_FontMap* pFontMap; //required for text window - IPWL_Provider* pProvider; //required for self coordinate - IPWL_FocusHandler* pFocusHandler; //optional - FX_DWORD dwFlags; //optional - CPWL_Color sBackgroundColor; //optional - FX_HWND hAttachedWnd; //required for no-reader framework - IPWL_SpellCheck* pSpellCheck; //required for spellchecking - int32_t nBorderStyle; //optional - int32_t dwBorderWidth; //optional - CPWL_Color sBorderColor; //optional - CPWL_Color sTextColor; //optional - CPWL_Color sTextStrokeColor; //optional - int32_t nTransparency; //optional - FX_FLOAT fFontSize; //optional - CPWL_Dash sDash; //optional - void* pAttachedData; //optional - CPWL_Wnd* pParentWnd; //ignore - CPWL_MsgControl* pMsgControl; //ignore - int32_t eCursorType; //ignore - CPDF_Matrix mtChild; //ignore +struct PWL_CREATEPARAM { + public: + PWL_CREATEPARAM() + : rcRectWnd(0, 0, 0, 0), + pSystemHandler(NULL), + pFontMap(NULL), + pProvider(NULL), + pFocusHandler(NULL), + dwFlags(0), + sBackgroundColor(), + hAttachedWnd(NULL), + pSpellCheck(NULL), + nBorderStyle(PBS_SOLID), + dwBorderWidth(1), + sBorderColor(), + sTextColor(), + sTextStrokeColor(), + nTransparency(255), + fFontSize(PWL_DEFAULT_FONTSIZE), + sDash(3, 0, 0), + pAttachedData(NULL), + pParentWnd(NULL), + pMsgControl(NULL), + eCursorType(FXCT_ARROW), + mtChild(1, 0, 0, 1, 0, 0) {} + + CPDF_Rect rcRectWnd; // required + IFX_SystemHandler* pSystemHandler; // required + IFX_Edit_FontMap* pFontMap; // required for text window + IPWL_Provider* pProvider; // required for self coordinate + IPWL_FocusHandler* pFocusHandler; // optional + FX_DWORD dwFlags; // optional + CPWL_Color sBackgroundColor; // optional + FX_HWND hAttachedWnd; // required for no-reader framework + IPWL_SpellCheck* pSpellCheck; // required for spellchecking + int32_t nBorderStyle; // optional + int32_t dwBorderWidth; // optional + CPWL_Color sBorderColor; // optional + CPWL_Color sTextColor; // optional + CPWL_Color sTextStrokeColor; // optional + int32_t nTransparency; // optional + FX_FLOAT fFontSize; // optional + CPWL_Dash sDash; // optional + void* pAttachedData; // optional + CPWL_Wnd* pParentWnd; // ignore + CPWL_MsgControl* pMsgControl; // ignore + int32_t eCursorType; // ignore + CPDF_Matrix mtChild; // ignore }; -class CPWL_Timer -{ -public: - CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler); - virtual ~CPWL_Timer(); +class CPWL_Timer { + public: + CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler); + virtual ~CPWL_Timer(); - int32_t SetPWLTimer(int32_t nElapse); - void KillPWLTimer(); - static void TimerProc(int32_t idEvent); + int32_t SetPWLTimer(int32_t nElapse); + void KillPWLTimer(); + static void TimerProc(int32_t idEvent); -private: - int32_t m_nTimerID; - CPWL_TimerHandler* m_pAttached; - IFX_SystemHandler* m_pSystemHandler; + private: + int32_t m_nTimerID; + CPWL_TimerHandler* m_pAttached; + IFX_SystemHandler* m_pSystemHandler; }; -class CPWL_TimerHandler -{ -public: - CPWL_TimerHandler(); - virtual ~CPWL_TimerHandler(); +class CPWL_TimerHandler { + public: + CPWL_TimerHandler(); + virtual ~CPWL_TimerHandler(); - void BeginTimer(int32_t nElapse); - void EndTimer(); - virtual void TimerProc(); - virtual IFX_SystemHandler* GetSystemHandler() const = 0; + void BeginTimer(int32_t nElapse); + void EndTimer(); + virtual void TimerProc(); + virtual IFX_SystemHandler* GetSystemHandler() const = 0; -private: - CPWL_Timer* m_pTimer; + private: + CPWL_Timer* m_pTimer; }; -class CPWL_Wnd : public CPWL_TimerHandler -{ - friend class CPWL_MsgControl; -public: - CPWL_Wnd(); - virtual ~CPWL_Wnd(); - - void Create(const PWL_CREATEPARAM & cp); - virtual CFX_ByteString GetClassName() const; - void Destroy(); - void Move(const CPDF_Rect & rcNew,FX_BOOL bReset,FX_BOOL bRefresh); - virtual void InvalidateRect(CPDF_Rect* pRect = NULL); - - void GetAppearanceStream(CFX_ByteString & sAppStream); - void DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnKeyUp(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - - virtual void SetFocus(); - virtual void KillFocus(); - void SetCapture(); - void ReleaseCapture(); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); - virtual void SetTextColor(const CPWL_Color & color); - virtual void SetTextStrokeColor(const CPWL_Color & color); - virtual void SetVisible(FX_BOOL bVisible); - - virtual CPDF_Rect GetFocusRect() const; - virtual CPWL_Color GetBackgroundColor() const; - virtual CPWL_Color GetBorderColor() const; - virtual CPWL_Color GetTextColor() const; - virtual CPWL_Color GetTextStrokeColor() const; - virtual FX_FLOAT GetFontSize() const; - virtual int32_t GetInnerBorderWidth() const; - virtual CPWL_Color GetBorderLeftTopColor(int32_t nBorderStyle) const; - virtual CPWL_Color GetBorderRightBottomColor(int32_t nBorderStyle) const; - - virtual FX_BOOL IsModified() const {return FALSE;} - - virtual void SetFontSize(FX_FLOAT fFontSize); - - void SetBackgroundColor(const CPWL_Color & color); - void SetBorderColor(const CPWL_Color & color); - void SetBorderWidth(int32_t nBorderWidth); - void SetClipRect(const CPDF_Rect & rect); - void SetBorderStyle(int32_t eBorderStyle); - void SetBorderDash(const CPWL_Dash & sDash); - - CPDF_Rect GetOriginWindowRect() const; - virtual CPDF_Rect GetWindowRect() const; - virtual CPDF_Rect GetClientRect() const; - CPDF_Point GetCenterPoint() const; - CPDF_Rect GetClientCenterSquare() const; - CPDF_Rect GetWindowCenterSquare() const; - int32_t GetBorderWidth() const; - FX_BOOL IsVisible() const {return m_bVisible;} - FX_BOOL HasFlag(FX_DWORD dwFlags) const; - void AddFlag(FX_DWORD dwFlags); - void RemoveFlag(FX_DWORD dwFlags); - CPDF_Rect GetClipRect() const; - CPWL_Wnd* GetParentWindow() const; - int32_t GetBorderStyle() const; - CPWL_Dash GetBorderDash() const; - void* GetAttachedData() const; - - FX_BOOL WndHitTest(const CPDF_Point & point) const; - FX_BOOL ClientHitTest(const CPDF_Point & point) const; - FX_BOOL IsCaptureMouse() const; - - const CPWL_Wnd* GetFocused() const; - FX_BOOL IsFocused() const; - FX_BOOL IsReadOnly() const; - CPWL_ScrollBar* GetVScrollBar() const; - - IFX_Edit_FontMap* GetFontMap() const; - IPWL_Provider* GetProvider() const; - virtual IFX_SystemHandler* GetSystemHandler() const; - IPWL_FocusHandler* GetFocusHandler() const; - - int32_t GetTransparency(); - void SetTransparency(int32_t nTransparency); - - CPDF_Matrix GetChildToRoot() const; - CPDF_Matrix GetChildMatrix() const; - void SetChildMatrix(const CPDF_Matrix& mt); - CPDF_Matrix GetWindowMatrix() const; - - virtual CPDF_Point ChildToParent(const CPDF_Point& point) const; - virtual CPDF_Rect ChildToParent(const CPDF_Rect& rect) const; - virtual CPDF_Point ParentToChild(const CPDF_Point& point) const; - virtual CPDF_Rect ParentToChild(const CPDF_Rect& rect) const; - - //those methods only implemented by listctrl item - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth) {return 0;} - virtual FX_FLOAT GetItemLeftMargin() {return 0;} - virtual FX_FLOAT GetItemRightMargin() {return 0;} - - void EnableWindow(FX_BOOL bEnable); - FX_BOOL IsEnabled(); - virtual void SetCursor(); - -protected: - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - void GetAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream); - - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void OnCreated(); - virtual void OnDestroy(); - - virtual void OnSetFocus(); - virtual void OnKillFocus(); - - virtual void OnEnabled(); - virtual void OnDisabled(); - - void SetNotifyFlag(FX_BOOL bNotifying = TRUE){m_bNotifying = bNotifying;}; - - FX_BOOL IsValid() const; - PWL_CREATEPARAM GetCreationParam() const; - FX_BOOL IsNotifying() const {return m_bNotifying;} - - void InvalidateRectMove(const CPDF_Rect & rcOld, const CPDF_Rect & rcNew); - - void PWLtoWnd(const CPDF_Point & point, int32_t& x, int32_t& y) const; - FX_RECT PWLtoWnd(const CPDF_Rect & rect) const; - FX_HWND GetAttachedHWnd() const; - - FX_BOOL IsWndCaptureMouse(const CPWL_Wnd * pWnd) const; - FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const; - const CPWL_Wnd* GetRootWnd() const; - - FX_BOOL IsCTRLpressed(FX_DWORD nFlag) const; - FX_BOOL IsSHIFTpressed(FX_DWORD nFlag) const; - FX_BOOL IsALTpressed(FX_DWORD nFlag) const; - FX_BOOL IsINSERTpressed(FX_DWORD nFlag) const; - -private: - void AddChild(CPWL_Wnd * pWnd); - void RemoveChild(CPWL_Wnd * pWnd); - - void CreateScrollBar(const PWL_CREATEPARAM & cp); - void CreateVScrollBar(const PWL_CREATEPARAM & cp); - - void AjustStyle(); - void CreateMsgControl(); - void DestroyMsgControl(); - - CPWL_MsgControl* GetMsgControl() const; - -protected: - CFX_ArrayTemplate m_aChildren; +class CPWL_Wnd : public CPWL_TimerHandler { + friend class CPWL_MsgControl; + + public: + CPWL_Wnd(); + virtual ~CPWL_Wnd(); + + void Create(const PWL_CREATEPARAM& cp); + virtual CFX_ByteString GetClassName() const; + void Destroy(); + void Move(const CPDF_Rect& rcNew, FX_BOOL bReset, FX_BOOL bRefresh); + virtual void InvalidateRect(CPDF_Rect* pRect = NULL); + + void GetAppearanceStream(CFX_ByteString& sAppStream); + void DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); + + virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnKeyUp(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonDblClk(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMButtonDblClk(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnRButtonDown(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag); + virtual FX_BOOL OnMouseWheel(short zDelta, + const CPDF_Point& point, + FX_DWORD nFlag); + + virtual void SetFocus(); + virtual void KillFocus(); + void SetCapture(); + void ReleaseCapture(); + + virtual void OnNotify(CPWL_Wnd* pWnd, + FX_DWORD msg, + intptr_t wParam = 0, + intptr_t lParam = 0); + virtual void SetTextColor(const CPWL_Color& color); + virtual void SetTextStrokeColor(const CPWL_Color& color); + virtual void SetVisible(FX_BOOL bVisible); + + virtual CPDF_Rect GetFocusRect() const; + virtual CPWL_Color GetBackgroundColor() const; + virtual CPWL_Color GetBorderColor() const; + virtual CPWL_Color GetTextColor() const; + virtual CPWL_Color GetTextStrokeColor() const; + virtual FX_FLOAT GetFontSize() const; + virtual int32_t GetInnerBorderWidth() const; + virtual CPWL_Color GetBorderLeftTopColor(int32_t nBorderStyle) const; + virtual CPWL_Color GetBorderRightBottomColor(int32_t nBorderStyle) const; + + virtual FX_BOOL IsModified() const { return FALSE; } + + virtual void SetFontSize(FX_FLOAT fFontSize); + + void SetBackgroundColor(const CPWL_Color& color); + void SetBorderColor(const CPWL_Color& color); + void SetBorderWidth(int32_t nBorderWidth); + void SetClipRect(const CPDF_Rect& rect); + void SetBorderStyle(int32_t eBorderStyle); + void SetBorderDash(const CPWL_Dash& sDash); + + CPDF_Rect GetOriginWindowRect() const; + virtual CPDF_Rect GetWindowRect() const; + virtual CPDF_Rect GetClientRect() const; + CPDF_Point GetCenterPoint() const; + CPDF_Rect GetClientCenterSquare() const; + CPDF_Rect GetWindowCenterSquare() const; + int32_t GetBorderWidth() const; + FX_BOOL IsVisible() const { return m_bVisible; } + FX_BOOL HasFlag(FX_DWORD dwFlags) const; + void AddFlag(FX_DWORD dwFlags); + void RemoveFlag(FX_DWORD dwFlags); + CPDF_Rect GetClipRect() const; + CPWL_Wnd* GetParentWindow() const; + int32_t GetBorderStyle() const; + CPWL_Dash GetBorderDash() const; + void* GetAttachedData() const; + + FX_BOOL WndHitTest(const CPDF_Point& point) const; + FX_BOOL ClientHitTest(const CPDF_Point& point) const; + FX_BOOL IsCaptureMouse() const; + + const CPWL_Wnd* GetFocused() const; + FX_BOOL IsFocused() const; + FX_BOOL IsReadOnly() const; + CPWL_ScrollBar* GetVScrollBar() const; + + IFX_Edit_FontMap* GetFontMap() const; + IPWL_Provider* GetProvider() const; + virtual IFX_SystemHandler* GetSystemHandler() const; + IPWL_FocusHandler* GetFocusHandler() const; + + int32_t GetTransparency(); + void SetTransparency(int32_t nTransparency); + + CPDF_Matrix GetChildToRoot() const; + CPDF_Matrix GetChildMatrix() const; + void SetChildMatrix(const CPDF_Matrix& mt); + CPDF_Matrix GetWindowMatrix() const; + + virtual CPDF_Point ChildToParent(const CPDF_Point& point) const; + virtual CPDF_Rect ChildToParent(const CPDF_Rect& rect) const; + virtual CPDF_Point ParentToChild(const CPDF_Point& point) const; + virtual CPDF_Rect ParentToChild(const CPDF_Rect& rect) const; + + // those methods only implemented by listctrl item + virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth) { return 0; } + virtual FX_FLOAT GetItemLeftMargin() { return 0; } + virtual FX_FLOAT GetItemRightMargin() { return 0; } + + void EnableWindow(FX_BOOL bEnable); + FX_BOOL IsEnabled(); + virtual void SetCursor(); + + protected: + virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); + virtual void RePosChildWnd(); + void GetAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); + virtual void GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream); + + virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device); + + virtual void OnCreate(PWL_CREATEPARAM& cp); + virtual void OnCreated(); + virtual void OnDestroy(); + + virtual void OnSetFocus(); + virtual void OnKillFocus(); + + virtual void OnEnabled(); + virtual void OnDisabled(); + + void SetNotifyFlag(FX_BOOL bNotifying = TRUE) { m_bNotifying = bNotifying; }; + + FX_BOOL IsValid() const; + PWL_CREATEPARAM GetCreationParam() const; + FX_BOOL IsNotifying() const { return m_bNotifying; } + + void InvalidateRectMove(const CPDF_Rect& rcOld, const CPDF_Rect& rcNew); + + void PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const; + FX_RECT PWLtoWnd(const CPDF_Rect& rect) const; + FX_HWND GetAttachedHWnd() const; + + FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const; + FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const; + const CPWL_Wnd* GetRootWnd() const; + + FX_BOOL IsCTRLpressed(FX_DWORD nFlag) const; + FX_BOOL IsSHIFTpressed(FX_DWORD nFlag) const; + FX_BOOL IsALTpressed(FX_DWORD nFlag) const; + FX_BOOL IsINSERTpressed(FX_DWORD nFlag) const; + + private: + void AddChild(CPWL_Wnd* pWnd); + void RemoveChild(CPWL_Wnd* pWnd); + + void CreateScrollBar(const PWL_CREATEPARAM& cp); + void CreateVScrollBar(const PWL_CREATEPARAM& cp); + + void AjustStyle(); + void CreateMsgControl(); + void DestroyMsgControl(); + + CPWL_MsgControl* GetMsgControl() const; + + protected: + CFX_ArrayTemplate m_aChildren; -private: - PWL_CREATEPARAM m_sPrivateParam; + private: + PWL_CREATEPARAM m_sPrivateParam; - CPWL_ScrollBar* m_pVScrollBar; + CPWL_ScrollBar* m_pVScrollBar; - CPDF_Rect m_rcWindow; - CPDF_Rect m_rcClip; + CPDF_Rect m_rcWindow; + CPDF_Rect m_rcClip; - FX_BOOL m_bCreated; - FX_BOOL m_bVisible; - FX_BOOL m_bNotifying; - FX_BOOL m_bEnabled; + FX_BOOL m_bCreated; + FX_BOOL m_bVisible; + FX_BOOL m_bNotifying; + FX_BOOL m_bEnabled; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_WND_H_ -- cgit v1.2.3