diff options
Diffstat (limited to 'fpdfsdk/formfiller')
-rw-r--r-- | fpdfsdk/formfiller/cba_fontmap.cpp (renamed from fpdfsdk/formfiller/FFL_CBA_Fontmap.cpp) | 2 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cba_fontmap.h | 46 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_checkbox.cpp (renamed from fpdfsdk/formfiller/FFL_CheckBox.cpp) | 4 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_checkbox.h | 32 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_combobox.cpp (renamed from fpdfsdk/formfiller/FFL_ComboBox.cpp) | 8 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_combobox.h | 69 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.cpp (renamed from fpdfsdk/formfiller/FFL_FormFiller.cpp) | 4 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.h | 203 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_iformfiller.cpp (renamed from fpdfsdk/formfiller/FFL_IFormFiller.cpp) | 16 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_iformfiller.h | 186 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_listbox.cpp (renamed from fpdfsdk/formfiller/FFL_ListBox.cpp) | 8 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_listbox.h | 45 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_pushbutton.cpp (renamed from fpdfsdk/formfiller/FFL_PushButton.cpp) | 4 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_pushbutton.h | 28 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_radiobutton.cpp (renamed from fpdfsdk/formfiller/FFL_RadioButton.cpp) | 4 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_radiobutton.h | 32 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_textfield.cpp (renamed from fpdfsdk/formfiller/FFL_TextField.cpp) | 4 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_textfield.h | 69 |
18 files changed, 737 insertions, 27 deletions
diff --git a/fpdfsdk/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index d7488d1592..0923c4d1ca 100644 --- a/fpdfsdk/formfiller/FFL_CBA_Fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" +#include "fpdfsdk/formfiller/cba_fontmap.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" diff --git a/fpdfsdk/formfiller/cba_fontmap.h b/fpdfsdk/formfiller/cba_fontmap.h new file mode 100644 index 0000000000..b576d01fc2 --- /dev/null +++ b/fpdfsdk/formfiller/cba_fontmap.h @@ -0,0 +1,46 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CBA_FONTMAP_H_ +#define FPDFSDK_FORMFILLER_CBA_FONTMAP_H_ + +#include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" + +class CPDF_Dictionary; +class CPDFSDK_Annot; + +class CBA_FontMap : public CPWL_FontMap { + public: + CBA_FontMap(CPDFSDK_Annot* pAnnot, IFX_SystemHandler* pSystemHandler); + ~CBA_FontMap() override; + + void SetDefaultFont(CPDF_Font* pFont, const CFX_ByteString& sFontName); + + void Reset(); + void SetAPType(const CFX_ByteString& sAPType); + + private: + // CPWL_FontMap: + void Initialize() override; + CPDF_Document* GetDocument() override; + CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, + int32_t nCharset) override; + void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias) override; + + 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); + + CPDF_Document* m_pDocument; + CPDF_Dictionary* m_pAnnotDict; + CPDF_Font* m_pDefaultFont; + CFX_ByteString m_sDefaultFontName; + CFX_ByteString m_sAPType; +}; + +#endif // FPDFSDK_FORMFILLER_CBA_FONTMAP_H_ diff --git a/fpdfsdk/formfiller/FFL_CheckBox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp index 485f86ba75..c0e3008508 100644 --- a/fpdfsdk/formfiller/FFL_CheckBox.cpp +++ b/fpdfsdk/formfiller/cffl_checkbox.cpp @@ -4,9 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_CheckBox.h" +#include "fpdfsdk/formfiller/cffl_checkbox.h" -#include "fpdfsdk/include/formfiller/FFL_FormFiller.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h" #include "public/fpdf_fwlevent.h" diff --git a/fpdfsdk/formfiller/cffl_checkbox.h b/fpdfsdk/formfiller/cffl_checkbox.h new file mode 100644 index 0000000000..01f6e3bee4 --- /dev/null +++ b/fpdfsdk/formfiller/cffl_checkbox.h @@ -0,0 +1,32 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_CHECKBOX_H_ +#define FPDFSDK_FORMFILLER_CFFL_CHECKBOX_H_ + +#include "fpdfsdk/formfiller/cffl_formfiller.h" + +class CFFL_CheckBox : public CFFL_Button { + public: + CFFL_CheckBox(CPDFDoc_Environment* pApp, CPDFSDK_Widget* pWidget); + ~CFFL_CheckBox() override; + + // CFFL_Button + CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView) override; + FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, + FX_UINT nKeyCode, + FX_UINT nFlags) override; + FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) override; + FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView) override; + void SaveData(CPDFSDK_PageView* pPageView) override; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_CHECKBOX_H_ diff --git a/fpdfsdk/formfiller/FFL_ComboBox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index 5e88a5d133..6a24df0dd9 100644 --- a/fpdfsdk/formfiller/FFL_ComboBox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_ComboBox.h" +#include "fpdfsdk/formfiller/cffl_combobox.h" -#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" -#include "fpdfsdk/include/formfiller/FFL_FormFiller.h" -#include "fpdfsdk/include/formfiller/FFL_IFormFiller.h" +#include "fpdfsdk/formfiller/cba_fontmap.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/formfiller/cffl_iformfiller.h" #include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/pdfwindow/PWL_ComboBox.h" diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h new file mode 100644 index 0000000000..b59f22bf36 --- /dev/null +++ b/fpdfsdk/formfiller/cffl_combobox.h @@ -0,0 +1,69 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_ +#define FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_ + +#include "core/include/fxcrt/fx_string.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" + +class CBA_FontMap; + +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); + ~CFFL_ComboBox() override; + + // CFFL_FormFiller: + PWL_CREATEPARAM GetCreateParam() override; + CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView) override; + FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) override; + FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView) override; + void SaveData(CPDFSDK_PageView* pPageView) override; + void GetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& fa) override; + void SetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& fa) override; + FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& faOld, + const PDFSDK_FieldAction& faNew) override; + void SaveState(CPDFSDK_PageView* pPageView) override; + void RestoreState(CPDFSDK_PageView* pPageView) override; + CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, + FX_BOOL bRestoreValue) override; + + // IPWL_FocusHandler: + void OnSetFocus(CPWL_Wnd* pWnd) override; + void OnKillFocus(CPWL_Wnd* pWnd) override; + + // IPWL_Edit_Notify: + void OnAddUndo(CPWL_Edit* pEdit) override; + +#ifdef PDF_ENABLE_XFA + // CFFL_FormFiller: + FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView) override; +#endif // PDF_ENABLE_XFA + + private: + CFX_WideString GetSelectExportText(); + + CBA_FontMap* m_pFontMap; + FFL_ComboBoxState m_State; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_ diff --git a/fpdfsdk/formfiller/FFL_FormFiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index e764c19270..732ea86c4e 100644 --- a/fpdfsdk/formfiller/FFL_FormFiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_FormFiller.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" -#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" +#include "fpdfsdk/formfiller/cba_fontmap.h" #include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" diff --git a/fpdfsdk/formfiller/cffl_formfiller.h b/fpdfsdk/formfiller/cffl_formfiller.h new file mode 100644 index 0000000000..b7d8a9dad6 --- /dev/null +++ b/fpdfsdk/formfiller/cffl_formfiller.h @@ -0,0 +1,203 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ +#define FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ + +#include <map> + +#include "fpdfsdk/formfiller/cba_fontmap.h" +#include "fpdfsdk/formfiller/cffl_iformfiller.h" +#include "fpdfsdk/include/fsdk_baseform.h" + +class CPDFDoc_Environment; +class CPDFSDK_Annot; +class CPDFSDK_PageView; +class CPDFSDK_Widget; + +class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler { + public: + CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + ~CFFL_FormFiller() override; + + virtual FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + FX_DWORD dwFlags); + virtual void OnDrawDeactive(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_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 CFX_FloatPoint& point); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + short zDelta, + const CFX_FloatPoint& point); + virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& 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); + + void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); + void KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); + + // CPWL_TimerHandler + void TimerProc() override; + IFX_SystemHandler* GetSystemHandler() const override; + + // IPWL_Provider + CFX_Matrix GetWindowMatrix(void* pAttachedData) override; + CFX_WideString LoadPopupMenuString(int nIndex) override; + + 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); + + CFX_Matrix GetCurMatrix(); + + CFX_FloatRect FFLtoPWL(const CFX_FloatRect& rect); + CFX_FloatRect PWLtoFFL(const CFX_FloatRect& rect); + CFX_FloatPoint FFLtoPWL(const CFX_FloatPoint& point); + CFX_FloatPoint PWLtoFFL(const CFX_FloatPoint& point); + + CFX_FloatPoint WndtoPWL(CPDFSDK_PageView* pPageView, + const CFX_FloatPoint& pt); + CFX_FloatRect FFLtoWnd(CPDFSDK_PageView* pPageView, + const CFX_FloatRect& rect); + + void SetWindowRect(CPDFSDK_PageView* pPageView, + const CFX_FloatRect& rcWindow); + CFX_FloatRect 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); + +#ifdef PDF_ENABLE_XFA + virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView); +#endif // PDF_ENABLE_XFA + + 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 CFX_FloatRect GetFocusBox(CPDFSDK_PageView* pPageView); + + FX_BOOL IsValid() const; + CFX_FloatRect 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<CPDFSDK_PageView*, CPWL_Wnd*>; + + CPDFDoc_Environment* m_pApp; + CPDFSDK_Widget* m_pWidget; + CPDFSDK_Annot* m_pAnnot; + + FX_BOOL m_bValid; + CFFL_PageView2PDFWindow m_Maps; + CFX_FloatPoint m_ptOldPos; +}; + +class CFFL_Button : public CFFL_FormFiller { + public: + CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); + ~CFFL_Button() override; + + // CFFL_FormFiller + void OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot) override; + void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) override; + FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point) override; + void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + FX_DWORD dwFlags) override; + void OnDrawDeactive(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + FX_DWORD dwFlags) override; + + protected: + FX_BOOL m_bMouseIn; + FX_BOOL m_bMouseDown; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_FORMFILLER_H_ diff --git a/fpdfsdk/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp index 8cc7b40c9f..09d10996a0 100644 --- a/fpdfsdk/formfiller/FFL_IFormFiller.cpp +++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp @@ -4,17 +4,17 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_IFormFiller.h" +#include "fpdfsdk/formfiller/cffl_iformfiller.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" -#include "fpdfsdk/include/formfiller/FFL_CheckBox.h" -#include "fpdfsdk/include/formfiller/FFL_ComboBox.h" -#include "fpdfsdk/include/formfiller/FFL_FormFiller.h" -#include "fpdfsdk/include/formfiller/FFL_ListBox.h" -#include "fpdfsdk/include/formfiller/FFL_PushButton.h" -#include "fpdfsdk/include/formfiller/FFL_RadioButton.h" -#include "fpdfsdk/include/formfiller/FFL_TextField.h" +#include "fpdfsdk/formfiller/cffl_checkbox.h" +#include "fpdfsdk/formfiller/cffl_combobox.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/formfiller/cffl_listbox.h" +#include "fpdfsdk/formfiller/cffl_pushbutton.h" +#include "fpdfsdk/formfiller/cffl_radiobutton.h" +#include "fpdfsdk/formfiller/cffl_textfield.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" diff --git a/fpdfsdk/formfiller/cffl_iformfiller.h b/fpdfsdk/formfiller/cffl_iformfiller.h new file mode 100644 index 0000000000..a966158625 --- /dev/null +++ b/fpdfsdk/formfiller/cffl_iformfiller.h @@ -0,0 +1,186 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_IFORMFILLER_H_ +#define FPDFSDK_FORMFILLER_CFFL_IFORMFILLER_H_ + +#include <map> + +#include "fpdfsdk/include/fsdk_define.h" +#include "fpdfsdk/include/pdfwindow/PWL_Edit.h" + +class CFFL_FormFiller; +class CPDFDoc_Environment; +class CPDFSDK_Annot; +class CPDFSDK_PageView; +class CPDFSDK_Widget; + +class CFFL_IFormFiller : public IPWL_Filler_Notify { + public: + explicit CFFL_IFormFiller(CPDFDoc_Environment* pApp); + ~CFFL_IFormFiller() override; + + virtual FX_BOOL Annot_HitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_FloatPoint point); + virtual FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_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, + 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 CFX_FloatPoint& point); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + short zDelta, + const CFX_FloatPoint& point); + virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point); + virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& 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); + + 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); +#ifdef PDF_ENABLE_XFA + void OnClick(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); + void OnFull(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); + void OnPreOpen(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); + void OnPostOpen(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); +#endif // PDF_ENABLE_XFA + + private: + using CFFL_Widget2Filler = std::map<CPDFSDK_Annot*, CFFL_FormFiller*>; + + // IPWL_Filler_Notify: + void QueryWherePopup(void* pPrivateData, + FX_FLOAT fPopupMin, + FX_FLOAT fPopupMax, + int32_t& nRet, + FX_FLOAT& fPopupRet) override; + void OnBeforeKeyStroke(void* pPrivateData, + CFX_WideString& strChange, + const CFX_WideString& strChangeEx, + int nSelStart, + int nSelEnd, + FX_BOOL bKeyDown, + FX_BOOL& bRC, + FX_BOOL& bExit, + FX_DWORD nFlag) override; +#ifdef PDF_ENABLE_XFA + void OnPopupPreOpen(void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag) override; + void OnPopupPostOpen(void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag) override; + void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, + FX_BOOL bSameField, + FX_BOOL bNext); +#endif // PDF_ENABLE_XFA + 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; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_IFORMFILLER_H_ diff --git a/fpdfsdk/formfiller/FFL_ListBox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp index 638618f784..f5c777743c 100644 --- a/fpdfsdk/formfiller/FFL_ListBox.cpp +++ b/fpdfsdk/formfiller/cffl_listbox.cpp @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_ListBox.h" +#include "fpdfsdk/formfiller/cffl_listbox.h" -#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" -#include "fpdfsdk/include/formfiller/FFL_FormFiller.h" -#include "fpdfsdk/include/formfiller/FFL_IFormFiller.h" +#include "fpdfsdk/formfiller/cba_fontmap.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/formfiller/cffl_iformfiller.h" #include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/pdfwindow/PWL_ListBox.h" diff --git a/fpdfsdk/formfiller/cffl_listbox.h b/fpdfsdk/formfiller/cffl_listbox.h new file mode 100644 index 0000000000..43fbab6642 --- /dev/null +++ b/fpdfsdk/formfiller/cffl_listbox.h @@ -0,0 +1,45 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_LISTBOX_H_ +#define FPDFSDK_FORMFILLER_CFFL_LISTBOX_H_ + +#include <set> + +#include "fpdfsdk/formfiller/cffl_formfiller.h" + +class CBA_FontMap; + +class CFFL_ListBox : public CFFL_FormFiller { + public: + CFFL_ListBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); + ~CFFL_ListBox() override; + + // CFFL_FormFiller + PWL_CREATEPARAM GetCreateParam() override; + CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView) override; + FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) override; + FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView) override; + void SaveData(CPDFSDK_PageView* pPageView) override; + void GetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& fa) override; + void SetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& fa) override; + void SaveState(CPDFSDK_PageView* pPageView) override; + void RestoreState(CPDFSDK_PageView* pPageView) override; + CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, + FX_BOOL bRestoreValue) override; + + private: + CBA_FontMap* m_pFontMap; + std::set<int> m_OriginSelections; + CFX_ArrayTemplate<int> m_State; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_LISTBOX_H_ diff --git a/fpdfsdk/formfiller/FFL_PushButton.cpp b/fpdfsdk/formfiller/cffl_pushbutton.cpp index d5bd509718..9a90f0aca2 100644 --- a/fpdfsdk/formfiller/FFL_PushButton.cpp +++ b/fpdfsdk/formfiller/cffl_pushbutton.cpp @@ -4,9 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_PushButton.h" +#include "fpdfsdk/formfiller/cffl_pushbutton.h" -#include "fpdfsdk/include/formfiller/FFL_FormFiller.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h" CFFL_PushButton::CFFL_PushButton(CPDFDoc_Environment* pApp, diff --git a/fpdfsdk/formfiller/cffl_pushbutton.h b/fpdfsdk/formfiller/cffl_pushbutton.h new file mode 100644 index 0000000000..0d9d82ea0a --- /dev/null +++ b/fpdfsdk/formfiller/cffl_pushbutton.h @@ -0,0 +1,28 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_PUSHBUTTON_H_ +#define FPDFSDK_FORMFILLER_CFFL_PUSHBUTTON_H_ + +#include "fpdfsdk/formfiller/cffl_formfiller.h" + +class CFFL_PushButton : public CFFL_Button { + public: + CFFL_PushButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + ~CFFL_PushButton() override; + + // CFFL_Button + CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView) override; + FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) override; + void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + FX_DWORD dwFlags) override; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_PUSHBUTTON_H_ diff --git a/fpdfsdk/formfiller/FFL_RadioButton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp index 029bcf1a17..08263601bb 100644 --- a/fpdfsdk/formfiller/FFL_RadioButton.cpp +++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp @@ -4,9 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_RadioButton.h" +#include "fpdfsdk/formfiller/cffl_radiobutton.h" -#include "fpdfsdk/include/formfiller/FFL_FormFiller.h" +#include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h" diff --git a/fpdfsdk/formfiller/cffl_radiobutton.h b/fpdfsdk/formfiller/cffl_radiobutton.h new file mode 100644 index 0000000000..f008d1b40f --- /dev/null +++ b/fpdfsdk/formfiller/cffl_radiobutton.h @@ -0,0 +1,32 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_RADIOBUTTON_H_ +#define FPDFSDK_FORMFILLER_CFFL_RADIOBUTTON_H_ + +#include "fpdfsdk/formfiller/cffl_formfiller.h" + +class CFFL_RadioButton : public CFFL_Button { + public: + CFFL_RadioButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + ~CFFL_RadioButton() override; + + // CFFL_Button + CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView) override; + FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, + FX_UINT nKeyCode, + FX_UINT nFlags) override; + FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) override; + FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_UINT nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView) override; + void SaveData(CPDFSDK_PageView* pPageView) override; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_RADIOBUTTON_H_ diff --git a/fpdfsdk/formfiller/FFL_TextField.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index 42f2aad48f..7399651234 100644 --- a/fpdfsdk/formfiller/FFL_TextField.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -4,9 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/formfiller/FFL_TextField.h" +#include "fpdfsdk/formfiller/cffl_textfield.h" -#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" +#include "fpdfsdk/formfiller/cba_fontmap.h" #include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_mgr.h" diff --git a/fpdfsdk/formfiller/cffl_textfield.h b/fpdfsdk/formfiller/cffl_textfield.h new file mode 100644 index 0000000000..d7bfc9ee8d --- /dev/null +++ b/fpdfsdk/formfiller/cffl_textfield.h @@ -0,0 +1,69 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_ +#define FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_ + +#include "fpdfsdk/formfiller/cffl_formfiller.h" + +#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; +}; + +class CFFL_TextField : public CFFL_FormFiller, + public IPWL_FocusHandler, + public IPWL_Edit_Notify { + public: + CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); + ~CFFL_TextField() override; + + // CFFL_FormFiller: + PWL_CREATEPARAM GetCreateParam() override; + CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, + CPDFSDK_PageView* pPageView) override; + FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) override; + FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView) override; + void SaveData(CPDFSDK_PageView* pPageView) override; + void GetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + PDFSDK_FieldAction& fa) override; + void SetActionData(CPDFSDK_PageView* pPageView, + CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& fa) override; + FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& faOld, + const PDFSDK_FieldAction& faNew) override; + void SaveState(CPDFSDK_PageView* pPageView) override; + void RestoreState(CPDFSDK_PageView* pPageView) override; + CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, + FX_BOOL bRestoreValue) override; + + // IPWL_FocusHandler: + void OnSetFocus(CPWL_Wnd* pWnd) override; + void OnKillFocus(CPWL_Wnd* pWnd) override; + + // IPWL_Edit_Notify: + void OnAddUndo(CPWL_Edit* pEdit) override; + +#ifdef PDF_ENABLE_XFA + // CFFL_FormFiller: + FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView) override; +#endif // PDF_ENABLE_XFA + + private: + CBA_FontMap* m_pFontMap; + FFL_TextFieldState m_State; +}; + +#endif // FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_ |