diff options
66 files changed, 986 insertions, 652 deletions
@@ -1123,7 +1123,6 @@ if (pdf_enable_xfa) { "xfa/fxbarcode/BC_BinaryBitmap.h", "xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp", "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h", - "xfa/fxbarcode/BC_DecoderResult.h", "xfa/fxbarcode/BC_Dimension.cpp", "xfa/fxbarcode/BC_Dimension.h", "xfa/fxbarcode/BC_Library.cpp", @@ -1376,6 +1375,7 @@ if (pdf_enable_xfa) { "xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp", "xfa/fxbarcode/qrcode/BC_QRGridSampler.h", "xfa/fxbarcode/utils.h", + "xfa/fxfa/app/cxfa_eventparam.cpp", "xfa/fxfa/app/xfa_checksum.cpp", "xfa/fxfa/app/xfa_ffapp.cpp", "xfa/fxfa/app/xfa_ffbarcode.cpp", @@ -1438,6 +1438,7 @@ if (pdf_enable_xfa) { "xfa/fxfa/fm2js/xfa_program.h", "xfa/fxfa/fm2js/xfa_simpleexpression.cpp", "xfa/fxfa/fm2js/xfa_simpleexpression.h", + "xfa/fxfa/include/cxfa_eventparam.h", "xfa/fxfa/include/fxfa.h", "xfa/fxfa/include/fxfa_basic.h", "xfa/fxfa/include/fxfa_widget.h", diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index d63bdb895a..04ca7b26c2 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -37,6 +37,10 @@ void RGB2BGR(uint8_t* buffer, int width = 1) { } // namespace +CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::CFXCODEC_WeightTable() {} + +CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::~CFXCODEC_WeightTable() {} + void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, int dest_min, int dest_max, @@ -136,6 +140,10 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, } } +CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::CFXCODEC_HorzTable() {} + +CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::~CFXCODEC_HorzTable() {} + void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) { @@ -189,6 +197,10 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, } } +CCodec_ProgressiveDecoder::CFXCODEC_VertTable::CFXCODEC_VertTable() {} + +CCodec_ProgressiveDecoder::CFXCODEC_VertTable::~CFXCODEC_VertTable() {} + void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, int src_len) { double scale = (double)dest_len / (double)src_len; diff --git a/core/fxcodec/codec/include/ccodec_progressivedecoder.h b/core/fxcodec/codec/include/ccodec_progressivedecoder.h index 5df2c4f733..04b21da5ee 100644 --- a/core/fxcodec/codec/include/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/include/ccodec_progressivedecoder.h @@ -76,8 +76,8 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_WeightTable { public: - CFXCODEC_WeightTable() {} - ~CFXCODEC_WeightTable() {} + CFXCODEC_WeightTable(); + ~CFXCODEC_WeightTable(); void Calc(int dest_len, int dest_min, @@ -98,8 +98,8 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_HorzTable { public: - CFXCODEC_HorzTable() {} - ~CFXCODEC_HorzTable() {} + CFXCODEC_HorzTable(); + ~CFXCODEC_HorzTable(); void Calc(int dest_len, int src_len, FX_BOOL bInterpol); PixelWeight* GetPixelWeight(int pixel) { @@ -113,8 +113,9 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_VertTable { public: - CFXCODEC_VertTable() {} - ~CFXCODEC_VertTable() {} + CFXCODEC_VertTable(); + ~CFXCODEC_VertTable(); + void Calc(int dest_len, int src_len); PixelWeight* GetPixelWeight(int pixel) { return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() + diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp index c63ee0e8c4..827c44a102 100644 --- a/fpdfsdk/formfiller/cffl_iformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp @@ -662,7 +662,6 @@ void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); pFormFiller->SaveState(pPageView); - PDFSDK_FieldAction faOld = fa; pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); bRC = fa.bRC; @@ -693,7 +692,6 @@ void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget, pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); pFormFiller->SaveState(pPageView); - PDFSDK_FieldAction faOld = fa; pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); bRC = fa.bRC; diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index c9c2c39476..60e9e52915 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -22,7 +22,6 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" -#include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffpageview.h" #include "xfa/fxfa/include/xfa_ffwidget.h" diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index 36f553e556..2a468f3f65 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -23,6 +23,7 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" #include "public/fpdf_formfill.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_checksum.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_ffdocview.h" diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 9847f15c60..43ca3183f9 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -104,6 +104,10 @@ FX_BOOL CFPDF_FileStream::IsEOF() { return m_nCurPos >= GetSize(); } +FX_FILESIZE CFPDF_FileStream::GetPosition() { + return m_nCurPos; +} + FX_BOOL CFPDF_FileStream::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { @@ -167,6 +171,10 @@ CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) { } #ifdef PDF_ENABLE_XFA +CFX_ByteString CPDF_CustomAccess::GetFullPath() { + return ""; +} + FX_BOOL CPDF_CustomAccess::GetByte(uint32_t pos, uint8_t& ch) { if (pos >= m_FileAccess.m_FileLen) return FALSE; @@ -194,6 +202,14 @@ FX_BOOL CPDF_CustomAccess::GetBlock(uint32_t pos, } #endif // PDF_ENABLE_XFA +FX_FILESIZE CPDF_CustomAccess::GetSize() { + return m_FileAccess.m_FileLen; +} + +void CPDF_CustomAccess::Release() { + delete this; +} + FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp index ffc4e5363a..5fe114a64c 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp @@ -5,11 +5,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" -#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" + #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "public/fpdf_formfill.h" #include "xfa/fxbarcode/include/BC_Library.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_fontmgr.h" @@ -94,10 +93,20 @@ void CPDFXFA_App::GetAppName(CFX_WideString& wsName) { } } +void CPDFXFA_App::GetFoxitAppName(CFX_WideString& wsFoxitName) { + wsFoxitName = L"Foxit"; +} + void CPDFXFA_App::SetAppType(const CFX_WideStringC& wsAppType) { m_csAppType = wsAppType; } +void CPDFXFA_App::SetFoxitAppType(const CFX_WideStringC& wsFoxitAppType) {} + +void CPDFXFA_App::GetFoxitAppType(CFX_WideString& wsFoxitAppType) { + wsFoxitAppType.clear(); +} + void CPDFXFA_App::GetLanguage(CFX_WideString& wsLanguage) { CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); if (pEnv) { @@ -120,6 +129,10 @@ void CPDFXFA_App::GetVersion(CFX_WideString& wsVersion) { wsVersion = JS_STR_VIEWERVERSION_XFA; } +void CPDFXFA_App::GetFoxitVersion(CFX_WideString& wsFoxitVersion) { + wsFoxitVersion = L"7.0"; +} + void CPDFXFA_App::Beep(uint32_t dwType) { CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); if (pEnv) { diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index c8aca0d5b0..42dad4557e 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -17,11 +17,13 @@ #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_formfill.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffpageview.h" #include "xfa/fxfa/include/xfa_ffwidget.h" +#include "xfa/fxfa/include/xfa_ffwidgethandler.h" #define IDS_XFA_Validate_Input \ "At least one required field was empty. Please fill in the required " \ @@ -238,12 +240,6 @@ void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { } } -FX_BOOL CPDFXFA_Document::GetChangeMark(CXFA_FFDoc* hDoc) { - if (hDoc == m_pXFADoc && m_pSDKDoc) - return m_pSDKDoc->GetChangeMark(); - return FALSE; -} - void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, const CFX_RectF& rt, uint32_t dwFlags /* = 0 */) { @@ -268,30 +264,6 @@ void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, rcPage.right, rcPage.top); } -void CPDFXFA_Document::InvalidateRect(CXFA_FFWidget* hWidget, - uint32_t dwFlags /* = 0 */) { - if (!hWidget) - return; - - if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) - return; - - if (m_iDocType != DOCTYPE_DYNAMIC_XFA) - return; - - CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); - if (!pWidgetHandler) - return; - - CXFA_FFPageView* pPageView = hWidget->GetPageView(); - if (!pPageView) - return; - - CFX_RectF rect; - hWidget->GetRect(rect); - InvalidateRect(pPageView, rect, dwFlags); -} - void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, FX_BOOL bVisible, const CFX_RectF* pRtAnchor) { @@ -552,6 +524,13 @@ void CPDFXFA_Document::WidgetPreRemove(CXFA_FFWidget* hWidget, pSdkPageView->DeleteAnnot(pAnnot); } +FX_BOOL CPDFXFA_Document::RenderCustomWidget(CXFA_FFWidget* hWidget, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + const CFX_RectF& rtUI) { + return FALSE; +} + int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { if (hDoc == m_pXFADoc && m_pSDKDoc) return GetPageCount(); @@ -789,6 +768,49 @@ void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, dwOptions & XFA_PRINTOPT_PrintAnnot); } +int32_t CPDFXFA_Document::AbsPageCountInBatch(CXFA_FFDoc* hDoc) { + return 0; +} + +int32_t CPDFXFA_Document::AbsPageInBatch(CXFA_FFDoc* hDoc, + CXFA_FFWidget* hWidget) { + return 0; +} + +int32_t CPDFXFA_Document::SheetCountInBatch(CXFA_FFDoc* hDoc) { + return 0; +} + +int32_t CPDFXFA_Document::SheetInBatch(CXFA_FFDoc* hDoc, + CXFA_FFWidget* hWidget) { + return 0; +} + +int32_t CPDFXFA_Document::Verify(CXFA_FFDoc* hDoc, + CXFA_Node* pSigNode, + FX_BOOL bUsed) { + return 0; +} + +FX_BOOL CPDFXFA_Document::Sign(CXFA_FFDoc* hDoc, + CXFA_NodeList* pNodeList, + const CFX_WideStringC& wsExpression, + const CFX_WideStringC& wsXMLIdent, + const CFX_WideStringC& wsValue, + FX_BOOL bUsed) { + return 0; +} + +CXFA_NodeList* CPDFXFA_Document::Enumerate(CXFA_FFDoc* hDoc) { + return 0; +} + +FX_BOOL CPDFXFA_Document::Clear(CXFA_FFDoc* hDoc, + CXFA_Node* pSigNode, + FX_BOOL bCleared) { + return 0; +} + void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { if (hDoc != m_pXFADoc) return; @@ -905,6 +927,18 @@ FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { return ret; } +FX_BOOL CPDFXFA_Document::CheckWord(CXFA_FFDoc* hDoc, + const CFX_ByteStringC& sWord) { + return FALSE; +} + +FX_BOOL CPDFXFA_Document::GetSuggestWords( + CXFA_FFDoc* hDoc, + const CFX_ByteStringC& sWord, + std::vector<CFX_ByteString>& sSuggest) { + return FALSE; +} + IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, const CFX_WideString& wsLink) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); @@ -1242,3 +1276,9 @@ FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, pValue); } + +CPDF_Document* CPDFXFA_Document::OpenPDF(CXFA_FFDoc* hDoc, + IFX_FileRead* pFile, + FX_BOOL bTakeOverFile) { + return nullptr; +} diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp index 8dbbf4e07c..8c4301f248 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp @@ -6,7 +6,6 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" -#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_app.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_app.h index f24c700434..993d4b4254 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_app.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_app.h @@ -36,19 +36,17 @@ class CPDFXFA_App : public IXFA_AppProvider { // IFXA_AppProvider: void GetAppType(CFX_WideString& wsAppType) override; void SetAppType(const CFX_WideStringC& wsAppType) override; + void SetFoxitAppType(const CFX_WideStringC& wsFoxitAppType) override; + void GetFoxitAppType(CFX_WideString& wsFoxitAppType) override; void GetLanguage(CFX_WideString& wsLanguage) override; void GetPlatform(CFX_WideString& wsPlatform) override; void GetVariation(CFX_WideString& wsVariation) override; void GetVersion(CFX_WideString& wsVersion) override; - void GetFoxitVersion(CFX_WideString& wsFoxitVersion) override { - wsFoxitVersion = L"7.0"; - } + void GetFoxitVersion(CFX_WideString& wsFoxitVersion) override; void GetAppName(CFX_WideString& wsName) override; - void GetFoxitAppName(CFX_WideString& wsFoxitName) override { - wsFoxitName = L"Foxit"; - } + void GetFoxitAppName(CFX_WideString& wsFoxitName) override; void Beep(uint32_t dwType) override; int32_t MsgBox(const CFX_WideString& wsMessage, diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h index 90ef6f36b3..21a5b13cfa 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h @@ -7,11 +7,12 @@ #ifndef FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ #define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ +#include "xfa/fxfa/include/xfa_ffdoc.h" + #include <vector> #include "public/fpdfview.h" #include "xfa/fxfa/include/fxfa.h" -#include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/include/xfa_ffdochandler.h" class CPDFXFA_App; @@ -26,7 +27,7 @@ class CXFA_FFDocHandler; class CPDFXFA_Document : public IXFA_DocProvider { public: CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider); - ~CPDFXFA_Document(); + ~CPDFXFA_Document() override; FX_BOOL LoadXFADoc(); CPDFXFA_App* GetApp() { return m_pApp; } @@ -46,99 +47,85 @@ class CPDFXFA_Document : public IXFA_DocProvider { void FXRect2PDFRect(const CFX_RectF& fxRectF, CFX_FloatRect& pdfRect); - virtual void SetChangeMark(CXFA_FFDoc* hDoc); - virtual FX_BOOL GetChangeMark(CXFA_FFDoc* hDoc); + // IXFA_DocProvider + void SetChangeMark(CXFA_FFDoc* hDoc) override; // used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. - virtual void InvalidateRect(CXFA_FFPageView* pPageView, - const CFX_RectF& rt, - uint32_t dwFlags = 0); - // used in static xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. - virtual void InvalidateRect(CXFA_FFWidget* hWidget, uint32_t dwFlags = 0); + void InvalidateRect(CXFA_FFPageView* pPageView, + const CFX_RectF& rt, + uint32_t dwFlags = 0) override; // show or hide caret - virtual void DisplayCaret(CXFA_FFWidget* hWidget, - FX_BOOL bVisible, - const CFX_RectF* pRtAnchor); + void DisplayCaret(CXFA_FFWidget* hWidget, + FX_BOOL bVisible, + const CFX_RectF* pRtAnchor) override; // dwPos: (0:bottom 1:top) - virtual FX_BOOL GetPopupPos(CXFA_FFWidget* hWidget, - FX_FLOAT fMinPopup, - FX_FLOAT fMaxPopup, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); - virtual FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, - CFX_PointF ptPopup, - const CFX_RectF* pRectExclude = nullptr); + FX_BOOL GetPopupPos(CXFA_FFWidget* hWidget, + FX_FLOAT fMinPopup, + FX_FLOAT fMaxPopup, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup) override; + FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, + CFX_PointF ptPopup, + const CFX_RectF* pRectExclude = nullptr) override; // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing - virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags); - virtual void WidgetPostAdd(CXFA_FFWidget* hWidget, - CXFA_WidgetAcc* pWidgetData); - virtual void WidgetPreRemove(CXFA_FFWidget* hWidget, - CXFA_WidgetAcc* pWidgetData); + void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) override; + void WidgetPostAdd(CXFA_FFWidget* hWidget, + CXFA_WidgetAcc* pWidgetData) override; + void WidgetPreRemove(CXFA_FFWidget* hWidget, + CXFA_WidgetAcc* pWidgetData) override; // return true if render it. - virtual FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - const CFX_RectF& rtUI) { - return FALSE; - } - - // host method - virtual int32_t CountPages(CXFA_FFDoc* hDoc); - virtual int32_t GetCurrentPage(CXFA_FFDoc* hDoc); - virtual void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage); - virtual FX_BOOL IsCalculationsEnabled(CXFA_FFDoc* hDoc); - virtual void SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled); - virtual void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle); - virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle); - virtual void ExportData(CXFA_FFDoc* hDoc, - const CFX_WideString& wsFilePath, - FX_BOOL bXDP = TRUE); - virtual void ImportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath); - virtual void GotoURL(CXFA_FFDoc* hDoc, - const CFX_WideString& bsURL, - FX_BOOL bAppend = TRUE); - virtual FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc); - virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled); - virtual void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget); - virtual void Print(CXFA_FFDoc* hDoc, - int32_t nStartPage, - int32_t nEndPage, - uint32_t dwOptions); + FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + const CFX_RectF& rtUI) override; + + // Host method + int32_t CountPages(CXFA_FFDoc* hDoc) override; + int32_t GetCurrentPage(CXFA_FFDoc* hDoc) override; + void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) override; + FX_BOOL IsCalculationsEnabled(CXFA_FFDoc* hDoc) override; + void SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; + void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) override; + void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) override; + void ExportData(CXFA_FFDoc* hDoc, + const CFX_WideString& wsFilePath, + FX_BOOL bXDP = TRUE) override; + void ImportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath) override; + void GotoURL(CXFA_FFDoc* hDoc, + const CFX_WideString& bsURL, + FX_BOOL bAppend = TRUE) override; + FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) override; + void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; + void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; + void Print(CXFA_FFDoc* hDoc, + int32_t nStartPage, + int32_t nEndPage, + uint32_t dwOptions) override; // LayoutPseudo method - virtual int32_t AbsPageCountInBatch(CXFA_FFDoc* hDoc) { return 0; } - virtual int32_t AbsPageInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) { - return 0; - } - virtual int32_t SheetCountInBatch(CXFA_FFDoc* hDoc) { return 0; } - virtual int32_t SheetInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) { - return 0; - } - - virtual int32_t Verify(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bUsed = TRUE) { - return 0; - } - virtual FX_BOOL Sign(CXFA_FFDoc* hDoc, - CXFA_NodeList* pNodeList, - const CFX_WideStringC& wsExpression, - const CFX_WideStringC& wsXMLIdent, - const CFX_WideStringC& wsValue = FX_WSTRC(L"open"), - FX_BOOL bUsed = TRUE) { - return 0; - } - virtual CXFA_NodeList* Enumerate(CXFA_FFDoc* hDoc) { return 0; } - virtual FX_BOOL Clear(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bCleared = TRUE) { - return 0; - } + int32_t AbsPageCountInBatch(CXFA_FFDoc* hDoc) override; + int32_t AbsPageInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; + int32_t SheetCountInBatch(CXFA_FFDoc* hDoc) override; + int32_t SheetInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; + + int32_t Verify(CXFA_FFDoc* hDoc, + CXFA_Node* pSigNode, + FX_BOOL bUsed = TRUE) override; + FX_BOOL Sign(CXFA_FFDoc* hDoc, + CXFA_NodeList* pNodeList, + const CFX_WideStringC& wsExpression, + const CFX_WideStringC& wsXMLIdent, + const CFX_WideStringC& wsValue = FX_WSTRC(L"open"), + FX_BOOL bUsed = TRUE) override; + CXFA_NodeList* Enumerate(CXFA_FFDoc* hDoc) override; + FX_BOOL Clear(CXFA_FFDoc* hDoc, + CXFA_Node* pSigNode, + FX_BOOL bCleared = TRUE) override; // Get document path - virtual void GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL); - virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc); + void GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) override; + FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; /** *Submit data to email, http, ftp. @@ -152,36 +139,30 @@ class CPDFXFA_Document : public IXFA_DocProvider { * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted *content or not. */ - virtual FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit); + FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) override; - virtual FX_BOOL CheckWord(CXFA_FFDoc* hDoc, const CFX_ByteStringC& sWord) { - return FALSE; - } - virtual FX_BOOL GetSuggestWords(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& sWord, - std::vector<CFX_ByteString>& sSuggest) { - return FALSE; - } + FX_BOOL CheckWord(CXFA_FFDoc* hDoc, const CFX_ByteStringC& sWord) override; + FX_BOOL GetSuggestWords(CXFA_FFDoc* hDoc, + const CFX_ByteStringC& sWord, + std::vector<CFX_ByteString>& sSuggest) override; // Get PDF javascript object, set the object to pValue. - virtual FX_BOOL GetPDFScriptObject(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& utf8Name, - CFXJSE_Value* pValue); - - virtual FX_BOOL GetGlobalProperty(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, - CFXJSE_Value* pValue); - virtual FX_BOOL SetGlobalProperty(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& szPropName, - CFXJSE_Value* pValue); - virtual CPDF_Document* OpenPDF(CXFA_FFDoc* hDoc, - IFX_FileRead* pFile, - FX_BOOL bTakeOverFile) { - return nullptr; - } - - virtual IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc, - const CFX_WideString& wsLink); + FX_BOOL GetPDFScriptObject(CXFA_FFDoc* hDoc, + const CFX_ByteStringC& utf8Name, + CFXJSE_Value* pValue) override; + + FX_BOOL GetGlobalProperty(CXFA_FFDoc* hDoc, + const CFX_ByteStringC& szPropName, + CFXJSE_Value* pValue) override; + FX_BOOL SetGlobalProperty(CXFA_FFDoc* hDoc, + const CFX_ByteStringC& szPropName, + CFXJSE_Value* pValue) override; + CPDF_Document* OpenPDF(CXFA_FFDoc* hDoc, + IFX_FileRead* pFile, + FX_BOOL bTakeOverFile) override; + + IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc, + const CFX_WideString& wsLink) override; FX_BOOL _OnBeforeNotifySumbit(); void _OnAfterNotifySumbit(); diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_page.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_page.h index 2e08f580ed..7b60c669cc 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_page.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_page.h @@ -9,12 +9,11 @@ #include <memory> -#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" -#include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_system.h" +class CFX_Matrix; class CPDFXFA_Document; +class CPDF_Dictionary; class CPDF_Page; class CXFA_FFPageView; diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp index 38e5bfe00d..499bdcb2e3 100644 --- a/fpdfsdk/fsdk_actionhandler.cpp +++ b/fpdfsdk/fsdk_actionhandler.cpp @@ -18,6 +18,8 @@ CPDFSDK_ActionHandler::CPDFSDK_ActionHandler() : m_pFormActionHandler(new CPDFSDK_FormActionHandler) {} +CPDFSDK_ActionHandler::~CPDFSDK_ActionHandler() {} + FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument) { std::set<CPDF_Dictionary*> visited; diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp index c3bc1953f1..b4942fdace 100644 --- a/fpdfsdk/fsdk_annothandler.cpp +++ b/fpdfsdk/fsdk_annothandler.cpp @@ -21,6 +21,9 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" #include "xfa/fwl/core/include/fwl_widgethit.h" #include "xfa/fxfa/include/xfa_ffwidget.h" +#include "xfa/fxfa/include/xfa_ffdocview.h" +#include "xfa/fxfa/include/xfa_ffpageview.h" +#include "xfa/fxfa/include/xfa_ffwidgethandler.h" #include "xfa/fxgraphics/include/cfx_graphics.h" #endif // PDF_ENABLE_XFA @@ -397,6 +400,19 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, #endif // PDF_ENABLE_XFA } +CPDFSDK_BFAnnotHandler::CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) + : m_pApp(pApp), m_pFormFiller(nullptr) {} + +CPDFSDK_BFAnnotHandler::~CPDFSDK_BFAnnotHandler() {} + +CFX_ByteString CPDFSDK_BFAnnotHandler::GetType() { + return CFX_ByteString("Widget"); +} + +CFX_ByteString CPDFSDK_BFAnnotHandler::GetName() { + return CFX_ByteString("WidgetHandler"); +} + FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { ASSERT(pAnnot->GetType() == "Widget"); if (pAnnot->GetSubType() == BFFT_SIGNATURE) @@ -457,6 +473,8 @@ void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { pInterForm->RemoveMap(pControl); } +void CPDFSDK_BFAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} + void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, @@ -474,6 +492,17 @@ void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, } } +void CPDFSDK_BFAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + const CFX_FloatRect& rcWindow, + uint32_t dwFlags) {} + +void CPDFSDK_BFAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_BFAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} + void CPDFSDK_BFAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlag) { @@ -602,6 +631,13 @@ FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, return FALSE; } +FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + return FALSE; +} + FX_BOOL CPDFSDK_BFAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) { @@ -700,6 +736,15 @@ FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, return TRUE; } +#ifdef PDF_ENABLE_XFA + +FX_BOOL CPDFSDK_BFAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, + CPDFSDK_Annot* pNewAnnot) { + return TRUE; +} + +#endif // PDF_ENABLE_XFA + CFX_FloatRect CPDFSDK_BFAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { CFX_ByteString sSubType = pAnnot->GetSubType(); @@ -724,6 +769,25 @@ FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp) : m_pApp(pApp) {} +CPDFSDK_XFAAnnotHandler::~CPDFSDK_XFAAnnotHandler() {} + +CFX_ByteString CPDFSDK_XFAAnnotHandler::GetType() { + return FSDK_XFAWIDGET_TYPENAME; +} + +CFX_ByteString CPDFSDK_XFAAnnotHandler::GetName() { + return "XFAWidgetHandler"; +} + +FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { + return !!pAnnot->GetXFAWidget(); +} + +CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, + CPDFSDK_PageView* pPage) { + return nullptr; +} + CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CXFA_FFWidget* pAnnot, CPDFSDK_PageView* pPage) { CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); @@ -733,10 +797,6 @@ CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CXFA_FFWidget* pAnnot, return pWidget; } -FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { - return !!pAnnot->GetXFAWidget(); -} - void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, @@ -763,6 +823,21 @@ void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, // to do highlight and shadow } +void CPDFSDK_XFAAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + const CFX_FloatRect& rcWindow, + uint32_t dwFlags) {} + +void CPDFSDK_XFAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_XFAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_XFAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_XFAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} + void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { CPDFSDK_XFAWidget* pWidget = (CPDFSDK_XFAWidget*)pAnnot; CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); @@ -771,6 +846,8 @@ void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { delete pWidget; } +void CPDFSDK_XFAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} + CFX_FloatRect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { ASSERT(pAnnot); @@ -968,6 +1045,10 @@ FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, GetFWLFlags(nFlag)); } +void CPDFSDK_XFAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} + +void CPDFSDK_XFAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} + FX_BOOL CPDFSDK_XFAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { return TRUE; diff --git a/fpdfsdk/fsdk_baseannot.cpp b/fpdfsdk/fsdk_baseannot.cpp index 21d85500bd..9b214738d8 100644 --- a/fpdfsdk/fsdk_baseannot.cpp +++ b/fpdfsdk/fsdk_baseannot.cpp @@ -430,10 +430,60 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds) { CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {} +CPDFSDK_Annot::~CPDFSDK_Annot() {} + +#ifdef PDF_ENABLE_XFA + +FX_BOOL CPDFSDK_Annot::IsXFAField() { + return FALSE; +} + +CXFA_FFWidget* CPDFSDK_Annot::GetXFAWidget() const { + return nullptr; +} + +#endif // PDF_ENABLE_XFA + +FX_FLOAT CPDFSDK_Annot::GetMinWidth() const { + return kMinWidth; +} + +FX_FLOAT CPDFSDK_Annot::GetMinHeight() const { + return kMinHeight; +} + +int CPDFSDK_Annot::GetLayoutOrder() const { + return 5; +} + +CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot() const { + return nullptr; +} + +CFX_ByteString CPDFSDK_Annot::GetType() const { + return ""; +} + +CFX_ByteString CPDFSDK_Annot::GetSubType() const { + return ""; +} + +void CPDFSDK_Annot::SetRect(const CFX_FloatRect& rect) {} + +CFX_FloatRect CPDFSDK_Annot::GetRect() const { + return CFX_FloatRect(); +} + +void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + CPDF_RenderOptions* pOptions) {} + CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) {} +CPDFSDK_BAAnnot::~CPDFSDK_BAAnnot() {} + CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const { return m_pAnnot; } @@ -446,7 +496,6 @@ void CPDFSDK_Annot::SetSelected(FX_BOOL bSelected) { m_bSelected = bSelected; } -// Tab Order int CPDFSDK_Annot::GetTabOrder() { return m_nTabOrder; } @@ -776,14 +825,6 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, FALSE); } -FX_FLOAT CPDFSDK_Annot::GetMinWidth() const { - return kMinWidth; -} - -FX_FLOAT CPDFSDK_Annot::GetMinHeight() const { - return kMinHeight; -} - FX_BOOL CPDFSDK_BAAnnot::CreateFormFiller() { return TRUE; } @@ -838,12 +879,6 @@ CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { return CPDF_Action(); } -#ifdef PDF_ENABLE_XFA -FX_BOOL CPDFSDK_BAAnnot::IsXFAField() { - return FALSE; -} -#endif // PDF_ENABLE_XFA - void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, CPDF_RenderOptions* pOptions) { @@ -865,7 +900,9 @@ CPDF_Page* CPDFSDK_Annot::GetPDFPage() { } #ifdef PDF_ENABLE_XFA + CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { return m_pPageView ? m_pPageView->GetPDFXFAPage() : nullptr; } + #endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp index 65be7c8c5d..90ff144759 100644 --- a/fpdfsdk/fsdk_baseform.cpp +++ b/fpdfsdk/fsdk_baseform.cpp @@ -29,9 +29,23 @@ #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" +#include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffwidget.h" +#include "xfa/fxfa/include/xfa_ffwidgethandler.h" #endif // PDF_ENABLE_XFA +PDFSDK_FieldAction::PDFSDK_FieldAction() + : bModifier(FALSE), + bShift(FALSE), + nCommitKey(0), + bKeyDown(FALSE), + nSelEnd(0), + nSelStart(0), + bWillCommit(FALSE), + bFieldFull(FALSE), + bRC(TRUE) {} + CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm) @@ -485,6 +499,10 @@ FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { return CPDFSDK_BAAnnot::IsAppearanceValid(); } +int CPDFSDK_Widget::GetLayoutOrder() const { + return 2; +} + int CPDFSDK_Widget::GetFieldFlags() const { CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); CPDF_FormControl* pFormControl = @@ -1954,10 +1972,18 @@ FX_BOOL CPDFSDK_XFAWidget::IsXFAField() { return TRUE; } +CXFA_FFWidget* CPDFSDK_XFAWidget::GetXFAWidget() const { + return m_hXFAWidget; +} + CFX_ByteString CPDFSDK_XFAWidget::GetType() const { return FSDK_XFAWIDGET_TYPENAME; } +CFX_ByteString CPDFSDK_XFAWidget::GetSubType() const { + return ""; +} + CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { CFX_RectF rcBBox; GetXFAWidget()->GetRect(rcBBox); diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index c4c0384b44..6500e302ec 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -24,6 +24,9 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" +#include "xfa/fxfa/include/xfa_ffdocview.h" +#include "xfa/fxfa/include/xfa_ffpageview.h" +#include "xfa/fxfa/include/xfa_ffwidgethandler.h" #include "xfa/fxfa/include/xfa_rendercontext.h" #include "xfa/fxgraphics/include/cfx_graphics.h" #endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 589ac1bd41..1a3289b26d 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -364,6 +364,30 @@ void CFX_Edit_Undo::Reset() { m_UndoItemStack.RemoveAll(); } +CFX_Edit_UndoItem::CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} + +CFX_Edit_UndoItem::~CFX_Edit_UndoItem() {} + +CFX_WideString CFX_Edit_UndoItem::GetUndoTitle() { + return L""; +} + +void CFX_Edit_UndoItem::SetFirst(FX_BOOL bFirst) { + m_bFirst = bFirst; +} + +FX_BOOL CFX_Edit_UndoItem::IsFirst() { + return m_bFirst; +} + +void CFX_Edit_UndoItem::SetLast(FX_BOOL bLast) { + m_bLast = bLast; +} + +FX_BOOL CFX_Edit_UndoItem::IsLast() { + return m_bLast; +} + CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) : m_sTitle(sTitle) {} @@ -2979,3 +3003,121 @@ void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { if (m_bOprNotify && m_pOprNotify) m_pOprNotify->OnAddUndo(pUndoItem); } + +CFX_Edit_LineRectArray::CFX_Edit_LineRectArray() {} + +CFX_Edit_LineRectArray::~CFX_Edit_LineRectArray() { + Empty(); +} + +void CFX_Edit_LineRectArray::Empty() { + for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++) + delete m_LineRects.GetAt(i); + + m_LineRects.RemoveAll(); +} + +void CFX_Edit_LineRectArray::RemoveAll() { + m_LineRects.RemoveAll(); +} + +void CFX_Edit_LineRectArray::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 CFX_Edit_LineRectArray::Add(const CPVT_WordRange& wrLine, + const CFX_FloatRect& rcLine) { + m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine)); +} + +int32_t CFX_Edit_LineRectArray::GetSize() const { + return m_LineRects.GetSize(); +} + +CFX_Edit_LineRect* CFX_Edit_LineRectArray::GetAt(int32_t nIndex) const { + if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) + return nullptr; + + return m_LineRects.GetAt(nIndex); +} + +CFX_Edit_Select::CFX_Edit_Select() {} + +CFX_Edit_Select::CFX_Edit_Select(const CPVT_WordPlace& begin, + const CPVT_WordPlace& end) { + Set(begin, end); +} + +CFX_Edit_Select::CFX_Edit_Select(const CPVT_WordRange& range) { + Set(range.BeginPos, range.EndPos); +} + +CPVT_WordRange CFX_Edit_Select::ConvertToWordRange() const { + return CPVT_WordRange(BeginPos, EndPos); +} + +void CFX_Edit_Select::Default() { + BeginPos.Default(); + EndPos.Default(); +} + +void CFX_Edit_Select::Set(const CPVT_WordPlace& begin, + const CPVT_WordPlace& end) { + BeginPos = begin; + EndPos = end; +} + +void CFX_Edit_Select::SetBeginPos(const CPVT_WordPlace& begin) { + BeginPos = begin; +} + +void CFX_Edit_Select::SetEndPos(const CPVT_WordPlace& end) { + EndPos = end; +} + +FX_BOOL CFX_Edit_Select::IsExist() const { + return BeginPos != EndPos; +} + +FX_BOOL CFX_Edit_Select::operator!=(const CPVT_WordRange& wr) const { + return wr.BeginPos != BeginPos || wr.EndPos != EndPos; +} + +CFX_Edit_RectArray::CFX_Edit_RectArray() {} + +CFX_Edit_RectArray::~CFX_Edit_RectArray() { + Empty(); +} + +void CFX_Edit_RectArray::Empty() { + for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) + delete m_Rects.GetAt(i); + + m_Rects.RemoveAll(); +} + +void CFX_Edit_RectArray::Add(const CFX_FloatRect& rect) { + // check for overlapped area + for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { + CFX_FloatRect* pRect = m_Rects.GetAt(i); + if (pRect && pRect->Contains(rect)) + return; + } + + m_Rects.Add(new CFX_FloatRect(rect)); +} + +int32_t CFX_Edit_RectArray::GetSize() const { + return m_Rects.GetSize(); +} + +CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { + if (nIndex < 0 || nIndex >= m_Rects.GetSize()) + return nullptr; + + return m_Rects.GetAt(nIndex); +} diff --git a/fpdfsdk/fxedit/fxet_list.cpp b/fpdfsdk/fxedit/fxet_list.cpp index 1385d57680..662a64b00a 100644 --- a/fpdfsdk/fxedit/fxet_list.cpp +++ b/fpdfsdk/fxedit/fxet_list.cpp @@ -73,6 +73,14 @@ CFX_WideString CFX_ListItem::GetText() const { return m_pEdit->GetText(); } +CFX_ListContainer::CFX_ListContainer() {} + +CFX_ListContainer::~CFX_ListContainer() {} + +void CFX_ListContainer::SetPlateRect(const CFX_FloatRect& rect) { + m_rcPlate = rect; +} + CFX_List::CFX_List() : m_fFontSize(0.0f), m_pFontMap(nullptr), m_bMultiple(FALSE) {} @@ -561,6 +569,14 @@ CFX_FloatRect CFX_ListCtrl::GetItemRect(int32_t nIndex) const { return InToOut(CFX_List::GetItemRect(nIndex)); } +int32_t CFX_ListCtrl::GetCaret() const { + return m_nCaretIndex; +} + +int32_t CFX_ListCtrl::GetSelect() const { + return m_nSelItem; +} + void CFX_ListCtrl::AddString(const FX_WCHAR* str) { AddItem(str); ReArrange(GetCount() - 1); diff --git a/fpdfsdk/fxedit/include/fxet_edit.h b/fpdfsdk/fxedit/include/fxet_edit.h index 71431de90a..aab26556b8 100644 --- a/fpdfsdk/fxedit/include/fxet_edit.h +++ b/fpdfsdk/fxedit/include/fxet_edit.h @@ -73,76 +73,33 @@ struct CFX_Edit_LineRect { class CFX_Edit_LineRectArray { public: - CFX_Edit_LineRectArray() {} + CFX_Edit_LineRectArray(); + virtual ~CFX_Edit_LineRectArray(); - virtual ~CFX_Edit_LineRectArray() { Empty(); } + void Empty(); + void RemoveAll(); + void operator=(CFX_Edit_LineRectArray& rects); + void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine); - void Empty() { - for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++) - delete m_LineRects.GetAt(i); - - m_LineRects.RemoveAll(); - } - - void RemoveAll() { m_LineRects.RemoveAll(); } - - void operator=(CFX_Edit_LineRectArray& rects) { - Empty(); - for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++) - m_LineRects.Add(rects.GetAt(i)); - - rects.RemoveAll(); - } - - void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine) { - m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine)); - } - - int32_t GetSize() const { return m_LineRects.GetSize(); } - - CFX_Edit_LineRect* GetAt(int32_t nIndex) const { - if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) - return nullptr; - - return m_LineRects.GetAt(nIndex); - } + int32_t GetSize() const; + CFX_Edit_LineRect* GetAt(int32_t nIndex) const; + private: CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; }; class CFX_Edit_RectArray { public: - CFX_Edit_RectArray() {} - - virtual ~CFX_Edit_RectArray() { Empty(); } - - void Empty() { - for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) - delete m_Rects.GetAt(i); + CFX_Edit_RectArray(); + virtual ~CFX_Edit_RectArray(); - m_Rects.RemoveAll(); - } - - void Add(const CFX_FloatRect& rect) { - // check for overlapped area - for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { - CFX_FloatRect* pRect = m_Rects.GetAt(i); - if (pRect && pRect->Contains(rect)) - return; - } - - m_Rects.Add(new CFX_FloatRect(rect)); - } + void Empty(); + void Add(const CFX_FloatRect& rect); - int32_t GetSize() const { return m_Rects.GetSize(); } - - CFX_FloatRect* GetAt(int32_t nIndex) const { - if (nIndex < 0 || nIndex >= m_Rects.GetSize()) - return nullptr; - - return m_Rects.GetAt(nIndex); - } + int32_t GetSize() const; + CFX_FloatRect* GetAt(int32_t nIndex) const; + private: CFX_ArrayTemplate<CFX_FloatRect*> m_Rects; }; @@ -167,39 +124,18 @@ class CFX_Edit_Refresh { class CFX_Edit_Select { public: - CFX_Edit_Select() {} - - CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { - Set(begin, end); - } - - explicit CFX_Edit_Select(const CPVT_WordRange& range) { - Set(range.BeginPos, range.EndPos); - } - - CPVT_WordRange ConvertToWordRange() const { - return CPVT_WordRange(BeginPos, EndPos); - } - - void Default() { - BeginPos.Default(); - EndPos.Default(); - } - - void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { - BeginPos = begin; - EndPos = end; - } + CFX_Edit_Select(); + CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); + explicit CFX_Edit_Select(const CPVT_WordRange& range); - void SetBeginPos(const CPVT_WordPlace& begin) { BeginPos = begin; } + void Default(); + void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); + void SetBeginPos(const CPVT_WordPlace& begin); + void SetEndPos(const CPVT_WordPlace& end); - 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_WordRange ConvertToWordRange() const; + FX_BOOL IsExist() const; + FX_BOOL operator!=(const CPVT_WordRange& wr) const; CPVT_WordPlace BeginPos, EndPos; }; @@ -244,15 +180,15 @@ class CFX_Edit_Undo { class CFX_Edit_UndoItem : public IFX_Edit_UndoItem { public: - CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} - ~CFX_Edit_UndoItem() override {} + CFX_Edit_UndoItem(); + ~CFX_Edit_UndoItem() override; - CFX_WideString GetUndoTitle() override { return L""; } + CFX_WideString GetUndoTitle() override; - 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; } + void SetFirst(FX_BOOL bFirst); + FX_BOOL IsFirst(); + void SetLast(FX_BOOL bLast); + FX_BOOL IsLast(); private: FX_BOOL m_bFirst; @@ -264,6 +200,7 @@ class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); ~CFX_Edit_GroupUndoItem() override; + // IFX_Edit_UndoItem void Undo() override; void Redo() override; CFX_WideString GetUndoTitle() override; diff --git a/fpdfsdk/fxedit/include/fxet_list.h b/fpdfsdk/fxedit/include/fxet_list.h index ab4605169b..a763db52da 100644 --- a/fpdfsdk/fxedit/include/fxet_list.h +++ b/fpdfsdk/fxedit/include/fxet_list.h @@ -142,11 +142,10 @@ class CFX_ListItem final { class CFX_ListContainer { public: - CFX_ListContainer() - : m_rcPlate(0.0f, 0.0f, 0.0f, 0.0f), - m_rcContent(0.0f, 0.0f, 0.0f, 0.0f) {} - virtual ~CFX_ListContainer() {} - virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; } + CFX_ListContainer(); + virtual ~CFX_ListContainer(); + virtual void SetPlateRect(const CFX_FloatRect& rect); + CFX_FloatRect GetPlateRect() const { return m_rcPlate; } void SetContentRect(const CLST_Rect& rect) { m_rcContent = rect; } CLST_Rect GetContentRect() const { return m_rcContent; } @@ -297,8 +296,8 @@ class CFX_ListCtrl : public CFX_List { void SetScrollPos(const CFX_FloatPoint& point) override; void ScrollToListItem(int32_t nItemIndex) override; CFX_FloatRect GetItemRect(int32_t nIndex) const override; - int32_t GetCaret() const override { return m_nCaretIndex; } - int32_t GetSelect() const override { return m_nSelItem; } + int32_t GetCaret() const override; + int32_t GetSelect() const override; int32_t GetTopItem() const override; CFX_FloatRect GetContentRect() const override; int32_t GetItemIndex(const CFX_FloatPoint& point) const override; diff --git a/fpdfsdk/include/fsdk_actionhandler.h b/fpdfsdk/include/fsdk_actionhandler.h index bf2ebd3eba..45ff5571a5 100644 --- a/fpdfsdk/include/fsdk_actionhandler.h +++ b/fpdfsdk/include/fsdk_actionhandler.h @@ -33,6 +33,7 @@ class CPDFSDK_FormActionHandler { class CPDFSDK_ActionHandler { public: CPDFSDK_ActionHandler(); + ~CPDFSDK_ActionHandler(); FX_BOOL DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument); diff --git a/fpdfsdk/include/fsdk_annothandler.h b/fpdfsdk/include/fsdk_annothandler.h index b36fe372b2..179843da8a 100644 --- a/fpdfsdk/include/fsdk_annothandler.h +++ b/fpdfsdk/include/fsdk_annothandler.h @@ -14,11 +14,6 @@ #include "core/fxcrt/include/fx_coordinates.h" #ifdef PDF_ENABLE_XFA -#include "xfa/fxfa/include/fxfa.h" -#include "xfa/fxfa/include/xfa_ffdocview.h" -#include "xfa/fxfa/include/xfa_ffpageview.h" -#include "xfa/fxfa/include/xfa_ffwidgethandler.h" - #define FSDK_XFAWIDGET_TYPENAME "XFAWidget" #endif // PDF_ENABLE_XFA @@ -30,17 +25,18 @@ class CPDFSDK_PageView; class CPDF_Annot; class CFX_Matrix; class CFX_FloatPoint; +#ifdef PDF_ENABLE_XFA +class CXFA_FFWidget; +class CXFA_FFWidgetHandler; +#endif // PDF_ENABLE_XFA 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; @@ -50,22 +46,17 @@ class IPDFSDK_AnnotHandler { #endif // PDF_ENABLE_XFA virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; - virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; - virtual CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) = 0; - virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, const CFX_FloatPoint& point) = 0; - virtual void OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, uint32_t dwFlags) = 0; - virtual void OnDrawSleep(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, @@ -74,20 +65,15 @@ class IPDFSDK_AnnotHandler { uint32_t 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, uint32_t nFlag) = 0; virtual void OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlag) = 0; - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlags, @@ -121,16 +107,13 @@ class IPDFSDK_AnnotHandler { CPDFSDK_Annot* pAnnot, uint32_t nFlags, const CFX_FloatPoint& point) = 0; - // by wjm. virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t 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, uint32_t nFlag) = 0; virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, uint32_t nFlag) = 0; #ifdef PDF_ENABLE_XFA @@ -141,13 +124,12 @@ class IPDFSDK_AnnotHandler { class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { public: - explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) - : m_pApp(pApp), m_pFormFiller(nullptr) {} - ~CPDFSDK_BFAnnotHandler() override {} + explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp); + ~CPDFSDK_BFAnnotHandler() override; // IPDFSDK_AnnotHandler - CFX_ByteString GetType() override { return CFX_ByteString("Widget"); } - CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } + CFX_ByteString GetType() override; + CFX_ByteString GetName() override; FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; #ifdef PDF_ENABLE_XFA @@ -155,7 +137,7 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { CPDFSDK_PageView* pPage) override; #endif // PDF_ENABLE_XFA void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; - void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} + void DeleteAnnot(CPDFSDK_Annot* pAnnot) override; CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) override; FX_BOOL HitTest(CPDFSDK_PageView* pPageView, @@ -171,11 +153,11 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, const CFX_FloatRect& rcWindow, - uint32_t dwFlags) override {} + uint32_t dwFlags) override; void OnCreate(CPDFSDK_Annot* pAnnot) override; void OnLoad(CPDFSDK_Annot* pAnnot) override; - void OnDelete(CPDFSDK_Annot* pAnnot) override {} - void OnRelease(CPDFSDK_Annot* pAnnot) override {} + void OnDelete(CPDFSDK_Annot* pAnnot) override; + void OnRelease(CPDFSDK_Annot* pAnnot) override; void OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlag) override; @@ -214,9 +196,7 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlags, - const CFX_FloatPoint& point) override { - return FALSE; - } + const CFX_FloatPoint& point) override; FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override; @@ -228,9 +208,7 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, uint32_t nFlag) override; #ifdef PDF_ENABLE_XFA FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, - CPDFSDK_Annot* pNewAnnot) override { - return TRUE; - } + CPDFSDK_Annot* pNewAnnot) override; #endif // PDF_ENABLE_XFA void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } @@ -245,108 +223,87 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { class CPDFSDK_XFAAnnotHandler : public IPDFSDK_AnnotHandler { public: explicit CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp); - ~CPDFSDK_XFAAnnotHandler() {} + ~CPDFSDK_XFAAnnotHandler() override; - public: - virtual CFX_ByteString GetType() { return FSDK_XFAWIDGET_TYPENAME; } - - virtual CFX_ByteString GetName() { return "XFAWidgetHandler"; } - - virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot); - - virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) { - return nullptr; - } - - virtual CPDFSDK_Annot* NewAnnot(CXFA_FFWidget* pAnnot, - CPDFSDK_PageView* pPage); - - virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); - - virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {} - - virtual CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot); - - virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, + // IPDFSDK_AnnotHandler + CFX_ByteString GetType() override; + CFX_ByteString GetName() override; + FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; + CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; + CPDFSDK_Annot* NewAnnot(CXFA_FFWidget* pAnnot, + CPDFSDK_PageView* pPage) override; + void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; + void DeleteAnnot(CPDFSDK_Annot* pAnnot) override; + CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot) override; + FX_BOOL HitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + const CFX_FloatPoint& point) override; + void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + uint32_t dwFlags) override; + void OnDrawSleep(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + const CFX_FloatRect& rcWindow, + uint32_t dwFlags) override; + void OnCreate(CPDFSDK_Annot* pAnnot) override; + void OnLoad(CPDFSDK_Annot* pAnnot) override; + void OnDelete(CPDFSDK_Annot* pAnnot) override; + void OnRelease(CPDFSDK_Annot* pAnnot) override; + void OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlag) override; + void OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlag) override; + FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, - const CFX_FloatPoint& point); - - virtual void OnDraw(CPDFSDK_PageView* pPageView, + uint32_t nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - uint32_t dwFlags); - - virtual void OnDrawSleep(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - const CFX_FloatRect& rcWindow, - uint32_t 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, - uint32_t nFlag); - virtual void OnMouseExit(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlag); - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point); - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point); - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point); - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - short zDelta, - const CFX_FloatPoint& point); - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point); - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point); - virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point); - // by wjm. - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, - uint32_t nChar, - uint32_t 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, uint32_t nFlag); - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, uint32_t nFlag); - virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, - CPDFSDK_Annot* pNewAnnot); + uint32_t nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + short zDelta, + const CFX_FloatPoint& point) override; + FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) override; + FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, + uint32_t nChar, + uint32_t nFlags) override; + FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; + FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; + void OnDeSelected(CPDFSDK_Annot* pAnnot) override; + void OnSelected(CPDFSDK_Annot* pAnnot) override; + FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, uint32_t nFlag) override; + FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, uint32_t nFlag) override; + FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, + CPDFSDK_Annot* pNewAnnot) override; private: CXFA_FFWidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot); diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h index 752d91a903..95d49ae272 100644 --- a/fpdfsdk/include/fsdk_baseannot.h +++ b/fpdfsdk/include/fsdk_baseannot.h @@ -29,9 +29,9 @@ class CFX_RenderDevice; class CPDFSDK_DateTime { public: CPDFSDK_DateTime(); - CPDFSDK_DateTime(const CFX_ByteString& dtStr); + explicit CPDFSDK_DateTime(const CFX_ByteString& dtStr); + explicit CPDFSDK_DateTime(const FX_SYSTEMTIME& st); 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); @@ -64,32 +64,26 @@ class CPDFSDK_DateTime { class CPDFSDK_Annot { public: explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView); - virtual ~CPDFSDK_Annot() {} + virtual ~CPDFSDK_Annot(); #ifdef PDF_ENABLE_XFA - virtual FX_BOOL IsXFAField() { return FALSE; } + virtual FX_BOOL IsXFAField(); + virtual CXFA_FFWidget* GetXFAWidget() const; #endif // PDF_ENABLE_XFA virtual FX_FLOAT GetMinWidth() const; virtual FX_FLOAT GetMinHeight() const; // define layout order to 5. - virtual int GetLayoutOrder() const { return 5; } - - virtual CPDF_Annot* GetPDFAnnot() const { return nullptr; } - -#ifdef PDF_ENABLE_XFA - virtual CXFA_FFWidget* GetXFAWidget() const { return nullptr; } -#endif // PDF_ENABLE_XFA - - virtual CFX_ByteString GetType() const { return ""; } - virtual CFX_ByteString GetSubType() const { return ""; } - - virtual void SetRect(const CFX_FloatRect& rect) {} - virtual CFX_FloatRect GetRect() const { return CFX_FloatRect(); } + virtual int GetLayoutOrder() const; + virtual CPDF_Annot* GetPDFAnnot() const; + virtual CFX_ByteString GetType() const; + virtual CFX_ByteString GetSubType() const; + virtual CFX_FloatRect GetRect() const; + virtual void SetRect(const CFX_FloatRect& rect); virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, - CPDF_RenderOptions* pOptions) {} + CPDF_RenderOptions* pOptions); UnderlyingPageType* GetUnderlyingPage(); CPDF_Page* GetPDFPage(); @@ -97,7 +91,7 @@ class CPDFSDK_Annot { CPDFXFA_Page* GetPDFXFAPage(); #endif // PDF_ENABLE_XFA - void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; } + void SetPage(CPDFSDK_PageView* pPageView); CPDFSDK_PageView* GetPageView() const { return m_pPageView; } // Tab Order @@ -117,12 +111,9 @@ class CPDFSDK_Annot { class CPDFSDK_BAAnnot : public CPDFSDK_Annot { public: CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); - ~CPDFSDK_BAAnnot() override {} - -#ifdef PDF_ENABLE_XFA - FX_BOOL IsXFAField() override; -#endif // PDF_ENABLE_XFA + ~CPDFSDK_BAAnnot() override; + // CPDFSDK_Annot CFX_ByteString GetType() const override; CFX_ByteString GetSubType() const override; void SetRect(const CFX_FloatRect& rect) override; @@ -173,13 +164,13 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot { void RemoveAAction(); virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); - virtual FX_BOOL IsAppearanceValid(); virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode); virtual void DrawAppearance(CFX_RenderDevice* pDevice, const CFX_Matrix* pUser2Device, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions); + void DrawBorder(CFX_RenderDevice* pDevice, const CFX_Matrix* pUser2Device, const CPDF_RenderOptions* pOptions); diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index c7a7e742d3..f6df689984 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -15,10 +15,6 @@ #include "core/fxge/include/fx_dib.h" #include "fpdfsdk/include/fsdk_baseannot.h" -#ifdef PDF_ENABLE_XFA -#include "xfa/fxfa/include/xfa_ffwidgethandler.h" -#endif // PDF_ENABLE_XFA - #if _FX_OS_ == _FX_ANDROID_ #include "time.h" #else @@ -34,6 +30,8 @@ class CPDF_FormField; struct CPWL_Color; #ifdef PDF_ENABLE_XFA +class CXFA_FFWidgetHandler; + typedef enum _PDFSDK_XFAAActionType { PDFSDK_XFA_Click = 0, PDFSDK_XFA_Full, @@ -43,16 +41,8 @@ typedef enum _PDFSDK_XFAAActionType { #endif // PDF_ENABLE_XFA struct PDFSDK_FieldAction { - PDFSDK_FieldAction() { - bModifier = FALSE; - bShift = FALSE; - nCommitKey = 0; - bKeyDown = FALSE; - nSelEnd = nSelStart = 0; - bWillCommit = FALSE; - bFieldFull = FALSE; - bRC = TRUE; - } + PDFSDK_FieldAction(); + PDFSDK_FieldAction(const PDFSDK_FieldAction& other) = delete; FX_BOOL bModifier; // in FX_BOOL bShift; // in @@ -104,7 +94,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override; FX_BOOL IsAppearanceValid() override; - int GetLayoutOrder() const override { return 2; } + int GetLayoutOrder() const override; int GetFieldType() const; @@ -232,9 +222,9 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot { ~CPDFSDK_XFAWidget() override {} FX_BOOL IsXFAField() override; - CXFA_FFWidget* GetXFAWidget() const override { return m_hXFAWidget; } + CXFA_FFWidget* GetXFAWidget() const override; CFX_ByteString GetType() const override; - CFX_ByteString GetSubType() const override { return ""; } + CFX_ByteString GetSubType() const override; CFX_FloatRect GetRect() const override; CPDFSDK_InterForm* GetInterForm() { return m_pInterForm; } diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index 4a470206d3..89c3e739a7 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -40,12 +40,12 @@ class CPDF_CustomAccess final : public IFX_FileRead { ~CPDF_CustomAccess() override {} // IFX_FileRead - FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; } - void Release() override { delete this; } + FX_FILESIZE GetSize() override; + void Release() override; FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; #ifdef PDF_ENABLE_XFA - virtual CFX_ByteString GetFullPath() { return ""; } + virtual CFX_ByteString GetFullPath(); virtual FX_BOOL GetByte(uint32_t pos, uint8_t& ch); virtual FX_BOOL GetBlock(uint32_t pos, uint8_t* pBuf, uint32_t size); #endif // PDF_ENABLE_XFA @@ -69,7 +69,7 @@ class CFPDF_FileStream : public IFX_FileStream { void Release() override; FX_FILESIZE GetSize() override; FX_BOOL IsEOF() override; - FX_FILESIZE GetPosition() override { return m_nCurPos; } + FX_FILESIZE GetPosition() override; FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; size_t ReadBlock(void* buffer, size_t size) override; FX_BOOL WriteBlock(const void* buffer, diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index ecf4f5a7e2..8d7fe1b186 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -114,6 +114,13 @@ END_JS_STATIC_METHOD() IMPLEMENT_JS_CLASS(CJS_Field, Field) +CJS_DelayData::CJS_DelayData(FIELD_PROP prop, + int idx, + const CFX_WideString& name) + : eProp(prop), nControlIndex(idx), sFieldName(name) {} + +CJS_DelayData::~CJS_DelayData() {} + void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) { CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); Field* pField = static_cast<Field*>(GetEmbedObject()); diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h index f5a7e1b846..84bba6862d 100644 --- a/fpdfsdk/javascript/Field.h +++ b/fpdfsdk/javascript/Field.h @@ -54,8 +54,8 @@ enum FIELD_PROP { }; struct CJS_DelayData { - CJS_DelayData(FIELD_PROP prop, int idx, const CFX_WideString& name) - : eProp(prop), nControlIndex(idx), sFieldName(name) {} + CJS_DelayData(FIELD_PROP prop, int idx, const CFX_WideString& name); + ~CJS_DelayData(); FIELD_PROP eProp; int nControlIndex; diff --git a/fpdfsdk/javascript/JS_GlobalData.cpp b/fpdfsdk/javascript/JS_GlobalData.cpp index aaa25ff474..14c36530d5 100644 --- a/fpdfsdk/javascript/JS_GlobalData.cpp +++ b/fpdfsdk/javascript/JS_GlobalData.cpp @@ -453,3 +453,7 @@ void CJS_GlobalData::MakeByteString(const CFX_ByteString& name, break; } } + +CJS_KeyValue::CJS_KeyValue() {} + +CJS_KeyValue::~CJS_KeyValue() {} diff --git a/fpdfsdk/javascript/JS_GlobalData.h b/fpdfsdk/javascript/JS_GlobalData.h index d9f4f0989b..8273c0838c 100644 --- a/fpdfsdk/javascript/JS_GlobalData.h +++ b/fpdfsdk/javascript/JS_GlobalData.h @@ -39,8 +39,8 @@ class CJS_GlobalVariableArray { class CJS_KeyValue { public: - CJS_KeyValue() {} - virtual ~CJS_KeyValue() {} + CJS_KeyValue(); + virtual ~CJS_KeyValue(); CFX_ByteString sKey; int nType; // 0:int 1:bool 2:string 3:obj diff --git a/fpdfsdk/javascript/JS_Object.cpp b/fpdfsdk/javascript/JS_Object.cpp index 6339bb7359..0d190a7fa4 100644 --- a/fpdfsdk/javascript/JS_Object.cpp +++ b/fpdfsdk/javascript/JS_Object.cpp @@ -75,6 +75,18 @@ void CJS_Object::Dispose() { m_pV8Object.Reset(); } +FX_BOOL CJS_Object::IsType(const FX_CHAR* sClassName) { + return TRUE; +} + +CFX_ByteString CJS_Object::GetClassName() { + return ""; +} + +void CJS_Object::InitInstance(IJS_Runtime* pIRuntime) {} + +void CJS_Object::ExitInstance() {} + int CJS_Object::MsgBox(CPDFDoc_Environment* pApp, const FX_WCHAR* swMsg, const FX_WCHAR* swTitle, diff --git a/fpdfsdk/javascript/JS_Object.h b/fpdfsdk/javascript/JS_Object.h index 49c078d927..908645ce33 100644 --- a/fpdfsdk/javascript/JS_Object.h +++ b/fpdfsdk/javascript/JS_Object.h @@ -46,11 +46,11 @@ class CJS_Object { 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); + virtual CFX_ByteString GetClassName(); - virtual void InitInstance(IJS_Runtime* pIRuntime) {} - virtual void ExitInstance() {} + virtual void InitInstance(IJS_Runtime* pIRuntime); + virtual void ExitInstance(); v8::Local<v8::Object> ToV8Object() { return m_pV8Object.Get(m_pIsolate); } diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 1b8964bd00..53d6d59833 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -82,6 +82,8 @@ CJS_Value::CJS_Value(CJS_Runtime* pRuntime, CJS_Array& array) CJS_Value::~CJS_Value() {} +CJS_Value::CJS_Value(const CJS_Value& other) = default; + void CJS_Value::Attach(v8::Local<v8::Value> pValue, Type t) { m_pValue = pValue; m_eType = t; @@ -410,6 +412,8 @@ CJS_Array::CJS_Array(CJS_Runtime* pRuntime) : m_pJSRuntime(pRuntime) {} CJS_Array::~CJS_Array() {} +CJS_Array::CJS_Array(const CJS_Array& other) = default; + void CJS_Array::Attach(v8::Local<v8::Array> pArray) { m_pArray = pArray; } diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h index 8adec4b1d1..958c5e070e 100644 --- a/fpdfsdk/javascript/JS_Value.h +++ b/fpdfsdk/javascript/JS_Value.h @@ -46,6 +46,7 @@ class CJS_Value { CJS_Value(CJS_Runtime* pRuntime, CJS_Array& array); ~CJS_Value(); + CJS_Value(const CJS_Value& other); void SetNull(); void Attach(v8::Local<v8::Value> pValue, Type t); @@ -137,6 +138,7 @@ class CJS_Array { public: CJS_Array(CJS_Runtime* pRuntime); virtual ~CJS_Array(); + CJS_Array(const CJS_Array& other); void Attach(v8::Local<v8::Array> pArray); void GetElement(unsigned index, CJS_Value& value); diff --git a/fpdfsdk/javascript/cjs_context.cpp b/fpdfsdk/javascript/cjs_context.cpp index b844dc6e5c..3833b166b6 100644 --- a/fpdfsdk/javascript/cjs_context.cpp +++ b/fpdfsdk/javascript/cjs_context.cpp @@ -268,6 +268,10 @@ void CJS_Context::OnExternal_Exec() { m_pEventHandler->OnExternal_Exec(); } +void CJS_Context::EnableMessageBox(FX_BOOL bEnable) { + m_bMsgBoxEnable = bEnable; +} + void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) { m_pEventHandler->OnBatchExec(pTarget); } diff --git a/fpdfsdk/javascript/cjs_context.h b/fpdfsdk/javascript/cjs_context.h index 64b97d616e..84fdf1d3e1 100644 --- a/fpdfsdk/javascript/cjs_context.h +++ b/fpdfsdk/javascript/cjs_context.h @@ -119,13 +119,13 @@ class CJS_Context : public IJS_Context { void OnBatchExec(CPDFSDK_Document* pTarget) override; void OnConsole_Exec() override; void OnExternal_Exec() override; - void EnableMessageBox(FX_BOOL bEnable) override { m_bMsgBoxEnable = bEnable; } + void EnableMessageBox(FX_BOOL bEnable) override; FX_BOOL IsMsgBoxEnabled() const { return m_bMsgBoxEnable; } - - CPDFDoc_Environment* GetReaderApp(); CJS_Runtime* GetJSRuntime() const { return m_pRuntime; } CJS_EventHandler* GetEventHandler() const { return m_pEventHandler; } + + CPDFDoc_Environment* GetReaderApp(); CPDFSDK_Document* GetReaderDocument(); private: diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp index 020472e584..2bcdc2293b 100644 --- a/fpdfsdk/javascript/cjs_runtime.cpp +++ b/fpdfsdk/javascript/cjs_runtime.cpp @@ -210,6 +210,10 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) { } } +CPDFSDK_Document* CJS_Runtime::GetReaderDocument() { + return m_pDocument; +} + int CJS_Runtime::Execute(const CFX_WideString& script, CFX_WideString* info) { FXJSErr error = {}; int nRet = FXJS_Execute(m_isolate, script, &error); diff --git a/fpdfsdk/javascript/cjs_runtime.h b/fpdfsdk/javascript/cjs_runtime.h index 4181bd21c9..2668367c1b 100644 --- a/fpdfsdk/javascript/cjs_runtime.h +++ b/fpdfsdk/javascript/cjs_runtime.h @@ -42,7 +42,7 @@ class CJS_Runtime : public IJS_Runtime { void ReleaseContext(IJS_Context* pContext) override; IJS_Context* GetCurrentContext() override; void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override; - CPDFSDK_Document* GetReaderDocument() override { return m_pDocument; } + CPDFSDK_Document* GetReaderDocument() override; int Execute(const CFX_WideString& script, CFX_WideString* info) override; CPDFDoc_Environment* GetReaderApp() const { return m_pApp; } diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp index 32498e474c..c3fc548a73 100644 --- a/fpdfsdk/javascript/global.cpp +++ b/fpdfsdk/javascript/global.cpp @@ -93,6 +93,18 @@ void CJS_Global::InitInstance(IJS_Runtime* pIRuntime) { pGlobal->Initial(pRuntime->GetReaderApp()); } +JSGlobalData::JSGlobalData() + : nType(0), + dData(0), + bData(FALSE), + sData(""), + bPersistent(FALSE), + bDeleted(FALSE) {} + +JSGlobalData::~JSGlobalData() { + pData.Reset(); +} + JSGlobalAlternate::JSGlobalAlternate(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), m_pApp(nullptr) {} diff --git a/fpdfsdk/javascript/global.h b/fpdfsdk/javascript/global.h index 02c51d98a9..eca9aa12d1 100644 --- a/fpdfsdk/javascript/global.h +++ b/fpdfsdk/javascript/global.h @@ -17,16 +17,9 @@ class CJS_GlobalVariableArray; class CJS_KeyValue; struct JSGlobalData { - JSGlobalData() { - nType = 0; - dData = 0; - bData = FALSE; - sData = ""; - bPersistent = FALSE; - bDeleted = FALSE; - } + JSGlobalData(); + ~JSGlobalData(); - ~JSGlobalData() { pData.Reset(); } int nType; // 0:int 1:bool 2:string 3:obj double dData; bool bData; diff --git a/fpdfsdk/jsapi/fxjs_v8.cpp b/fpdfsdk/jsapi/fxjs_v8.cpp index 790d10b602..c63ef7ae89 100644 --- a/fpdfsdk/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/jsapi/fxjs_v8.cpp @@ -190,6 +190,17 @@ size_t FXJS_GlobalIsolateRefCount() { return g_isolate_ref_count; } +V8TemplateMap::V8TemplateMap(v8::Isolate* isolate) : m_map(isolate) {} + +V8TemplateMap::~V8TemplateMap() {} + +void V8TemplateMap::set(void* key, v8::Local<v8::Object> handle) { + ASSERT(!m_map.Contains(key)); + m_map.Set(key, handle); +} + +FXJS_PerIsolateData::~FXJS_PerIsolateData() {} + // static void FXJS_PerIsolateData::SetUp(v8::Isolate* pIsolate) { if (!pIsolate->GetData(g_embedderDataSlot)) @@ -202,6 +213,13 @@ FXJS_PerIsolateData* FXJS_PerIsolateData::Get(v8::Isolate* pIsolate) { pIsolate->GetData(g_embedderDataSlot)); } +#ifndef PDF_ENABLE_XFA +FXJS_PerIsolateData::FXJS_PerIsolateData() : m_pDynamicObjsMap(nullptr) {} +#else // PDF_ENABLE_XFA +FXJS_PerIsolateData::FXJS_PerIsolateData() + : m_pFXJSERuntimeData(nullptr), m_pDynamicObjsMap(nullptr) {} +#endif // PDF_ENABLE_XFA + int FXJS_DefineObj(v8::Isolate* pIsolate, const wchar_t* sObjName, FXJSOBJTYPE eObjType, diff --git a/fpdfsdk/jsapi/include/fxjs_v8.h b/fpdfsdk/jsapi/include/fxjs_v8.h index 60389d2e1a..3ae1d5e0ca 100644 --- a/fpdfsdk/jsapi/include/fxjs_v8.h +++ b/fpdfsdk/jsapi/include/fxjs_v8.h @@ -81,11 +81,11 @@ class V8TemplateMap { public: typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; - void set(void* key, v8::Local<v8::Object> handle) { - ASSERT(!m_map.Contains(key)); - m_map.Set(key, handle); - } - explicit V8TemplateMap(v8::Isolate* isolate) : m_map(isolate) {} + explicit V8TemplateMap(v8::Isolate* isolate); + ~V8TemplateMap(); + + void set(void* key, v8::Local<v8::Object> handle); + friend class V8TemplateMapTraits; private: @@ -94,8 +94,11 @@ class V8TemplateMap { class FXJS_PerIsolateData { public: + ~FXJS_PerIsolateData(); + static void SetUp(v8::Isolate* pIsolate); static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); + void CreateDynamicObjsMap(v8::Isolate* pIsolate) { if (!m_pDynamicObjsMap) m_pDynamicObjsMap = new V8TemplateMap(pIsolate); @@ -112,12 +115,7 @@ class FXJS_PerIsolateData { V8TemplateMap* m_pDynamicObjsMap; protected: -#ifndef PDF_ENABLE_XFA - FXJS_PerIsolateData() : m_pDynamicObjsMap(nullptr) {} -#else // PDF_ENABLE_XFA - FXJS_PerIsolateData() - : m_pFXJSERuntimeData(nullptr), m_pDynamicObjsMap(nullptr) {} -#endif // PDF_ENABLE_XFA + FXJS_PerIsolateData(); }; extern const wchar_t kFXJSValueNameString[]; diff --git a/fpdfsdk/pdfwindow/PWL_Icon.cpp b/fpdfsdk/pdfwindow/PWL_Icon.cpp index 9c2e5cbf69..6689aa644e 100644 --- a/fpdfsdk/pdfwindow/PWL_Icon.cpp +++ b/fpdfsdk/pdfwindow/PWL_Icon.cpp @@ -112,6 +112,10 @@ CPWL_Icon::CPWL_Icon() : m_pIconFit(nullptr) {} CPWL_Icon::~CPWL_Icon() {} +CPDF_IconFit* CPWL_Icon::GetIconFit() { + return m_pIconFit; +} + int32_t CPWL_Icon::GetScaleMethod() { if (m_pIconFit) return m_pIconFit->GetScaleMethod(); diff --git a/fpdfsdk/pdfwindow/PWL_Icon.h b/fpdfsdk/pdfwindow/PWL_Icon.h index a5bd907012..04d13a1411 100644 --- a/fpdfsdk/pdfwindow/PWL_Icon.h +++ b/fpdfsdk/pdfwindow/PWL_Icon.h @@ -38,7 +38,7 @@ class CPWL_Icon : public CPWL_Image { CPWL_Icon(); ~CPWL_Icon() override; - virtual CPDF_IconFit* GetIconFit() { return m_pIconFit; } + virtual CPDF_IconFit* GetIconFit(); // CPWL_Image void GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) override; diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp index 2a0a0aabbb..e680652bb3 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -16,6 +16,31 @@ static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() { return *timeMap; } +PWL_CREATEPARAM::PWL_CREATEPARAM() + : rcRectWnd(0, 0, 0, 0), + pSystemHandler(nullptr), + pFontMap(nullptr), + pProvider(nullptr), + pFocusHandler(nullptr), + dwFlags(0), + sBackgroundColor(), + hAttachedWnd(nullptr), + nBorderStyle(BorderStyle::SOLID), + dwBorderWidth(1), + sBorderColor(), + sTextColor(), + sTextStrokeColor(), + nTransparency(255), + fFontSize(PWL_DEFAULT_FONTSIZE), + sDash(3, 0, 0), + pAttachedData(nullptr), + pParentWnd(nullptr), + pMsgControl(nullptr), + eCursorType(FXCT_ARROW), + mtChild(1, 0, 0, 1, 0, 0) {} + +PWL_CREATEPARAM::PWL_CREATEPARAM(const PWL_CREATEPARAM& other) = default; + CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, CFX_SystemHandler* pSystemHandler) : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) { @@ -930,6 +955,18 @@ CFX_FloatRect CPWL_Wnd::ParentToChild(const CFX_FloatRect& rect) const { return rc; } +FX_FLOAT CPWL_Wnd::GetItemHeight(FX_FLOAT fLimitWidth) { + return 0; +} + +FX_FLOAT CPWL_Wnd::GetItemLeftMargin() { + return 0; +} + +FX_FLOAT CPWL_Wnd::GetItemRightMargin() { + return 0; +} + CFX_Matrix CPWL_Wnd::GetChildToRoot() const { CFX_Matrix mt(1, 0, 0, 1, 0, 0); if (HasFlag(PWS_CHILD)) { diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h index c393d2730e..197bdf0023 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/pdfwindow/PWL_Wnd.h @@ -85,6 +85,7 @@ class IPWL_Provider; #define PWL_CLASSNAME_EDIT "CPWL_Edit" struct CPWL_Dash { + CPWL_Dash() : nDash(0), nGap(0), nPhase(0) {} CPWL_Dash(int32_t dash, int32_t gap, int32_t phase) : nDash(dash), nGap(gap), nPhase(phase) {} @@ -186,28 +187,8 @@ class IPWL_FocusHandler { struct PWL_CREATEPARAM { public: - PWL_CREATEPARAM() - : rcRectWnd(0, 0, 0, 0), - pSystemHandler(nullptr), - pFontMap(nullptr), - pProvider(nullptr), - pFocusHandler(nullptr), - dwFlags(0), - sBackgroundColor(), - hAttachedWnd(nullptr), - nBorderStyle(BorderStyle::SOLID), - dwBorderWidth(1), - sBorderColor(), - sTextColor(), - sTextStrokeColor(), - nTransparency(255), - fFontSize(PWL_DEFAULT_FONTSIZE), - sDash(3, 0, 0), - pAttachedData(nullptr), - pParentWnd(nullptr), - pMsgControl(nullptr), - eCursorType(FXCT_ARROW), - mtChild(1, 0, 0, 1, 0, 0) {} + PWL_CREATEPARAM(); + PWL_CREATEPARAM(const PWL_CREATEPARAM& other); CFX_FloatRect rcRectWnd; // required CFX_SystemHandler* pSystemHandler; // required @@ -364,9 +345,9 @@ class CPWL_Wnd : public CPWL_TimerHandler { virtual CFX_FloatRect ParentToChild(const CFX_FloatRect& 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; } + virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); + virtual FX_FLOAT GetItemLeftMargin(); + virtual FX_FLOAT GetItemRightMargin(); void EnableWindow(FX_BOOL bEnable); FX_BOOL IsEnabled(); @@ -46,6 +46,7 @@ "fxjse/runtime.h", "fxjse/scope_inline.h", "fxjse/value.cpp", + "xfa/fxfa/include/cxfa_eventparam.h", "xfa/fxfa/include/fxfa.h", "xfa/fxfa/include/fxfa_basic.h", "xfa/fxfa/include/fxfa_widget.h", @@ -519,7 +520,6 @@ "xfa/fxbarcode/BC_Binarizer.h", "xfa/fxbarcode/BC_BinaryBitmap.h", "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h", - "xfa/fxbarcode/BC_DecoderResult.h", "xfa/fxbarcode/BC_Dimension.h", "xfa/fxbarcode/BC_LuminanceSource.h", "xfa/fxbarcode/BC_Reader.h", @@ -529,6 +529,7 @@ "xfa/fxbarcode/BC_UtilRSS.h", "xfa/fxbarcode/BC_Writer.h", "xfa/fxbarcode/utils.h", + "xfa/fxfa/app/cxfa_eventparam.cpp", "xfa/fxfa/app/xfa_checksum.cpp", "xfa/fxfa/app/xfa_ffapp.cpp", "xfa/fxfa/app/xfa_ffbarcode.cpp", diff --git a/xfa/fwl/basewidget/ifwl_spinbutton.h b/xfa/fwl/basewidget/ifwl_spinbutton.h index 0b433d407a..2e81aeb9f2 100644 --- a/xfa/fwl/basewidget/ifwl_spinbutton.h +++ b/xfa/fwl/basewidget/ifwl_spinbutton.h @@ -7,7 +7,7 @@ #ifndef XFA_FWL_BASEWIDGET_IFWL_SPINBUTTON_H_ #define XFA_FWL_BASEWIDGET_IFWL_SPINBUTTON_H_ -#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #define FWL_CLASS_SpinButton L"FWL_SPINBUTTON" #define FWL_STYLEEXE_SPB_Vert (1L << 0) diff --git a/xfa/fxbarcode/BC_DecoderResult.h b/xfa/fxbarcode/BC_DecoderResult.h deleted file mode 100644 index e4170c8955..0000000000 --- a/xfa/fxbarcode/BC_DecoderResult.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_BC_DECODERRESULT_H_ -#define XFA_FXBARCODE_BC_DECODERRESULT_H_ - -#include "core/fxcrt/include/fx_basic.h" - -class CBC_DecoderResult { - public: - CBC_DecoderResult(CFX_ByteArray* rawBytes, - CFX_ByteString text, - CFX_ByteString ecLevel); - virtual ~CBC_DecoderResult(); - - CFX_ByteArray* getRawBytes(); - CFX_ByteString getText(); - CFX_ByteString getECLevel(); - int32_t getErrorsCorrected(); - void setErrorsCorrected(int32_t errorsCorrected); - int32_t getErasures(); - void setErasures(int32_t erasures); - void* getOther(); - void setOther(void* other); - - private: - CFX_ByteArray* m_rawBytes; - CFX_ByteString m_text; - CFX_ByteString m_ecLevel; - int32_t m_errorsCorrected; - int32_t m_erasures; - void* m_other; -}; - -#endif // XFA_FXBARCODE_BC_DECODERRESULT_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp index 64ebbe13af..30632a494a 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp @@ -25,7 +25,6 @@ #include <stdlib.h> #include "third_party/bigint/BigIntegerLibrary.hh" -#include "xfa/fxbarcode/BC_DecoderResult.h" #include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" #include "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h" #include "xfa/fxbarcode/utils.h" diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp index 894b5d3fad..7d1779657c 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp @@ -26,7 +26,6 @@ #include "xfa/fxbarcode/BC_BinaryBitmap.h" #include "xfa/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/fxbarcode/BC_DecoderResult.h" #include "xfa/fxbarcode/BC_Reader.h" #include "xfa/fxbarcode/BC_ResultPoint.h" #include "xfa/fxbarcode/common/BC_CommonBitArray.h" diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp index 479b65970e..fb33fe0d3f 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp @@ -22,7 +22,6 @@ #include <memory> -#include "xfa/fxbarcode/BC_DecoderResult.h" #include "xfa/fxbarcode/BC_ResultPoint.h" #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" diff --git a/xfa/fxfa/app/cxfa_eventparam.cpp b/xfa/fxfa/app/cxfa_eventparam.cpp new file mode 100644 index 0000000000..5f9d752969 --- /dev/null +++ b/xfa/fxfa/app/cxfa_eventparam.cpp @@ -0,0 +1,48 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/include/cxfa_eventparam.h" + +#include "xfa/fxfa/include/fxfa.h" + +CXFA_EventParam::CXFA_EventParam() + : m_pTarget(nullptr), + m_eType(XFA_EVENT_Unknown), + m_bCancelAction(FALSE), + m_iCommitKey(0), + m_bKeyDown(FALSE), + m_bModifier(FALSE), + m_bReenter(FALSE), + m_iSelEnd(0), + m_iSelStart(0), + m_bShift(FALSE), + m_bIsFormReady(FALSE), + m_iValidateActivities(XFA_VALIDATE_preSubmit) {} + +CXFA_EventParam::~CXFA_EventParam() {} + +CXFA_EventParam::CXFA_EventParam(const CXFA_EventParam& other) = default; + +void CXFA_EventParam::Reset() { + m_wsChange.clear(); + m_bCancelAction = FALSE; + m_iCommitKey = 0; + m_wsFullText.clear(); + m_bKeyDown = FALSE; + m_bModifier = FALSE; + m_wsNewContentType.clear(); + m_wsNewText.clear(); + m_wsPrevContentType.clear(); + m_wsPrevText.clear(); + m_bReenter = FALSE; + m_iSelEnd = 0; + m_iSelStart = 0; + m_bShift = FALSE; + m_wsSoapFaultCode.clear(); + m_wsSoapFaultString.clear(); + m_bIsFormReady = FALSE; + m_iValidateActivities = XFA_VALIDATE_preSubmit; +} diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index 4258eef29b..4987b5ba23 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -13,6 +13,7 @@ #include "xfa/fwl/lightwidget/cfwl_listbox.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffpageview.h" diff --git a/xfa/fxfa/app/xfa_ffnotify.h b/xfa/fxfa/app/xfa_ffnotify.h index 6dd400859b..e9e8721df3 100644 --- a/xfa/fxfa/app/xfa_ffnotify.h +++ b/xfa/fxfa/app/xfa_ffnotify.h @@ -7,6 +7,7 @@ #ifndef XFA_FXFA_APP_XFA_FFNOTIFY_H_ #define XFA_FXFA_APP_XFA_FFNOTIFY_H_ +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/parser/xfa_document.h" class CXFA_FFWidgetHandler; diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index 35ed84810f..171fe8dd36 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -17,6 +17,7 @@ #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/include/xfa_ffdocview.h" diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index fb9ab5f580..fb4dc8ea6b 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -13,6 +13,8 @@ #include "core/fxcodec/codec/include/ccodec_progressivedecoder.h" #include "core/fxcodec/include/fx_codec.h" #include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxfa/include/fxfa_widget.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/include/xfa_ffdocview.h" diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 6a4a1f4f6f..9eeccdbb44 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -17,6 +17,7 @@ #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/include/xfa_ffdocview.h" diff --git a/xfa/fxfa/include/cxfa_eventparam.h b/xfa/fxfa/include/cxfa_eventparam.h new file mode 100644 index 0000000000..9bc46fdc66 --- /dev/null +++ b/xfa/fxfa/include/cxfa_eventparam.h @@ -0,0 +1,79 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_INCLUDE_CXFA_EVENTPARAM_H_ +#define XFA_FXFA_INCLUDE_CXFA_EVENTPARAM_H_ + +#include "xfa/fxfa/include/fxfa_basic.h" + +class CXFA_WidgetAcc; + +enum XFA_EVENTTYPE { + XFA_EVENT_Click, + XFA_EVENT_Change, + XFA_EVENT_DocClose, + XFA_EVENT_DocReady, + XFA_EVENT_Enter, + XFA_EVENT_Exit, + XFA_EVENT_Full, + XFA_EVENT_IndexChange, + XFA_EVENT_Initialize, + XFA_EVENT_MouseDown, + XFA_EVENT_MouseEnter, + XFA_EVENT_MouseExit, + XFA_EVENT_MouseUp, + XFA_EVENT_PostExecute, + XFA_EVENT_PostOpen, + XFA_EVENT_PostPrint, + XFA_EVENT_PostSave, + XFA_EVENT_PostSign, + XFA_EVENT_PostSubmit, + XFA_EVENT_PreExecute, + XFA_EVENT_PreOpen, + XFA_EVENT_PrePrint, + XFA_EVENT_PreSave, + XFA_EVENT_PreSign, + XFA_EVENT_PreSubmit, + XFA_EVENT_Ready, + XFA_EVENT_InitCalculate, + XFA_EVENT_InitVariables, + XFA_EVENT_Calculate, + XFA_EVENT_Validate, + XFA_EVENT_Unknown, +}; + +class CXFA_EventParam { + public: + CXFA_EventParam(); + ~CXFA_EventParam(); + CXFA_EventParam(const CXFA_EventParam& other); + + void Reset(); + + CXFA_WidgetAcc* m_pTarget; + XFA_EVENTTYPE m_eType; + CFX_WideString m_wsResult; + FX_BOOL m_bCancelAction; + int32_t m_iCommitKey; + FX_BOOL m_bKeyDown; + FX_BOOL m_bModifier; + FX_BOOL m_bReenter; + int32_t m_iSelEnd; + int32_t m_iSelStart; + FX_BOOL m_bShift; + CFX_WideString m_wsChange; + CFX_WideString m_wsFullText; + CFX_WideString m_wsNewContentType; + CFX_WideString m_wsNewText; + CFX_WideString m_wsPrevContentType; + CFX_WideString m_wsPrevText; + CFX_WideString m_wsSoapFaultCode; + CFX_WideString m_wsSoapFaultString; + FX_BOOL m_bIsFormReady; + int32_t m_iValidateActivities; +}; + +#endif // XFA_FXFA_INCLUDE_CXFA_EVENTPARAM_H_ diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h index 981fcabffc..c62e916a97 100644 --- a/xfa/fxfa/include/fxfa.h +++ b/xfa/fxfa/include/fxfa.h @@ -143,40 +143,6 @@ enum XFA_WidgetStatus { XFA_WidgetStatus_Visible = 1 << 9 }; -enum XFA_EVENTTYPE { - XFA_EVENT_Click, - XFA_EVENT_Change, - XFA_EVENT_DocClose, - XFA_EVENT_DocReady, - XFA_EVENT_Enter, - XFA_EVENT_Exit, - XFA_EVENT_Full, - XFA_EVENT_IndexChange, - XFA_EVENT_Initialize, - XFA_EVENT_MouseDown, - XFA_EVENT_MouseEnter, - XFA_EVENT_MouseExit, - XFA_EVENT_MouseUp, - XFA_EVENT_PostExecute, - XFA_EVENT_PostOpen, - XFA_EVENT_PostPrint, - XFA_EVENT_PostSave, - XFA_EVENT_PostSign, - XFA_EVENT_PostSubmit, - XFA_EVENT_PreExecute, - XFA_EVENT_PreOpen, - XFA_EVENT_PrePrint, - XFA_EVENT_PreSave, - XFA_EVENT_PreSign, - XFA_EVENT_PreSubmit, - XFA_EVENT_Ready, - XFA_EVENT_InitCalculate, - XFA_EVENT_InitVariables, - XFA_EVENT_Calculate, - XFA_EVENT_Validate, - XFA_EVENT_Unknown, -}; - enum XFA_WIDGETORDER { XFA_WIDGETORDER_PreOrder, }; @@ -434,56 +400,6 @@ class IXFA_DocProvider { const CFX_WideString& wsLink) = 0; }; -class CXFA_EventParam { - public: - CXFA_EventParam() { - m_pTarget = NULL; - m_eType = XFA_EVENT_Unknown; - m_wsResult.clear(); - Reset(); - } - void Reset() { - m_wsChange.clear(); - m_iCommitKey = 0; - m_wsFullText.clear(); - m_bKeyDown = FALSE; - m_bModifier = FALSE; - m_wsNewContentType.clear(); - m_wsNewText.clear(); - m_wsPrevContentType.clear(); - m_wsPrevText.clear(); - m_bReenter = FALSE; - m_iSelEnd = 0; - m_iSelStart = 0; - m_bShift = FALSE; - m_wsSoapFaultCode.clear(); - m_wsSoapFaultString.clear(); - m_bIsFormReady = FALSE; - m_iValidateActivities = XFA_VALIDATE_preSubmit; - } - CXFA_WidgetAcc* m_pTarget; - XFA_EVENTTYPE m_eType; - CFX_WideString m_wsResult; - FX_BOOL m_bCancelAction; - int32_t m_iCommitKey; - FX_BOOL m_bKeyDown; - FX_BOOL m_bModifier; - FX_BOOL m_bReenter; - int32_t m_iSelEnd; - int32_t m_iSelStart; - FX_BOOL m_bShift; - CFX_WideString m_wsChange; - CFX_WideString m_wsFullText; - CFX_WideString m_wsNewContentType; - CFX_WideString m_wsNewText; - CFX_WideString m_wsPrevContentType; - CFX_WideString m_wsPrevText; - CFX_WideString m_wsSoapFaultCode; - CFX_WideString m_wsSoapFaultString; - FX_BOOL m_bIsFormReady; - int32_t m_iValidateActivities; -}; - class CXFA_RenderOptions { public: CXFA_RenderOptions() : m_bPrint(FALSE), m_bHighlight(TRUE) {} diff --git a/xfa/fxfa/include/xfa_ffdocview.h b/xfa/fxfa/include/xfa_ffdocview.h index b8ff562940..bc2373d155 100644 --- a/xfa/fxfa/include/xfa_ffdocview.h +++ b/xfa/fxfa/include/xfa_ffdocview.h @@ -10,6 +10,7 @@ #include <map> #include <memory> +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffdoc.h" class CXFA_FFWidgetHandler; diff --git a/xfa/fxfa/include/xfa_ffwidgethandler.h b/xfa/fxfa/include/xfa_ffwidgethandler.h index 8159d87cf0..4a6687e8c7 100644 --- a/xfa/fxfa/include/xfa_ffwidgethandler.h +++ b/xfa/fxfa/include/xfa_ffwidgethandler.h @@ -9,6 +9,7 @@ #include <vector> +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/fxfa.h" #include "xfa/fxfa/parser/xfa_document.h" diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp index d4ef935ada..e1bfd6b326 100644 --- a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp @@ -8,6 +8,7 @@ #include "fxjse/include/cfxjse_arguments.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffwidgethandler.h" #include "xfa/fxfa/parser/xfa_doclayout.h" #include "xfa/fxfa/parser/xfa_document.h" diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index 723a9aec7a..7a97899c96 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -11,6 +11,7 @@ #include "fxjse/include/cfxjse_class.h" #include "fxjse/include/cfxjse_value.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/parser/xfa_doclayout.h" #include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" diff --git a/xfa/fxfa/parser/xfa_script_imp.h b/xfa/fxfa/parser/xfa_script_imp.h index d36e468b50..08be85f7c9 100644 --- a/xfa/fxfa/parser/xfa_script_imp.h +++ b/xfa/fxfa/parser/xfa_script_imp.h @@ -13,6 +13,7 @@ #include "fxjse/include/cfxjse_arguments.h" #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" +#include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_script.h" |