From c5e0f66f5f2e0645f2beab70b44690fe510a9f2d Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 14 Dec 2017 20:20:33 +0000 Subject: Fold CXFA_SubmitData into CXFA_Submit CXFA_SubmitData is a thin wrapper around CXFA_Submit. This CL folds the two classes together. Change-Id: I867b6db067786d232df2a25c1ba7b29d6d454f8e Reviewed-on: https://pdfium-review.googlesource.com/21190 Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima --- BUILD.gn | 2 -- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 18 +++++++++--------- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h | 16 ++-------------- xfa/fxfa/cxfa_widgetacc.cpp | 4 ++-- xfa/fxfa/fxfa.h | 3 ++- xfa/fxfa/parser/cxfa_eventdata.cpp | 6 ++++-- xfa/fxfa/parser/cxfa_eventdata.h | 4 ++-- xfa/fxfa/parser/cxfa_submit.cpp | 16 ++++++++++++++++ xfa/fxfa/parser/cxfa_submit.h | 6 ++++++ xfa/fxfa/parser/cxfa_submitdata.cpp | 27 --------------------------- xfa/fxfa/parser/cxfa_submitdata.h | 26 -------------------------- 11 files changed, 43 insertions(+), 85 deletions(-) delete mode 100644 xfa/fxfa/parser/cxfa_submitdata.cpp delete mode 100644 xfa/fxfa/parser/cxfa_submitdata.h diff --git a/BUILD.gn b/BUILD.gn index 430a244bdb..a56b709dad 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -2663,8 +2663,6 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_subjectdns.h", "xfa/fxfa/parser/cxfa_submit.cpp", "xfa/fxfa/parser/cxfa_submit.h", - "xfa/fxfa/parser/cxfa_submitdata.cpp", - "xfa/fxfa/parser/cxfa_submitdata.h", "xfa/fxfa/parser/cxfa_submitformat.cpp", "xfa/fxfa/parser/cxfa_submitformat.h", "xfa/fxfa/parser/cxfa_submiturl.cpp", diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index fdf0d31ea2..071fe34bdd 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -22,6 +22,7 @@ #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" #include "xfa/fxfa/cxfa_widgetacciterator.h" +#include "xfa/fxfa/parser/cxfa_submit.h" #define IDS_XFA_Validate_Input \ "At least one required field was empty. Please fill in the required " \ @@ -684,13 +685,12 @@ void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() { m_pContext->GetXFADocView()->UpdateDocView(); } -bool CPDFXFA_DocEnvironment::SubmitData(CXFA_FFDoc* hDoc, - CXFA_SubmitData submitData) { +bool CPDFXFA_DocEnvironment::Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) { if (!NotifySubmit(true) || !m_pContext->GetXFADocView()) return false; m_pContext->GetXFADocView()->UpdateDocView(); - bool ret = SubmitDataInternal(hDoc, submitData); + bool ret = SubmitInternal(hDoc, submit); NotifySubmit(false); return ret; } @@ -893,13 +893,13 @@ bool CPDFXFA_DocEnvironment::MailToInfo(WideString& csURL, return true; } -bool CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, - CXFA_SubmitData submitData) { +bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc, + CXFA_Submit* submit) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); if (!pFormFillEnv) return false; - WideString csURL = submitData.GetSubmitTarget(); + WideString csURL = submit->GetSubmitTarget(); if (csURL.IsEmpty()) { WideString ws = WideString::FromLocal("Submit cancelled."); ByteString bs = ws.UTF16LE_Encode(); @@ -912,15 +912,15 @@ bool CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, FPDF_FILEHANDLER* pFileHandler = nullptr; int fileFlag = -1; - switch (submitData.GetSubmitFormat()) { + switch (submit->GetSubmitFormat()) { case XFA_AttributeEnum::Xdp: { - WideString csContent = submitData.GetSubmitXDPContent(); + WideString csContent = submit->GetSubmitXDPContent(); csContent.Trim(); WideString space = WideString::FromLocal(" "); csContent = space + csContent + space; FPDF_DWORD flag = 0; - if (submitData.IsSubmitEmbedPDF()) + if (submit->IsSubmitEmbedPDF()) flag |= FXFA_PDF; ToXFAContentFlags(csContent, flag); diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h index f487c46bd9..7933da33e4 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h @@ -64,19 +64,7 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { uint32_t dwOptions) override; FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; - /** - *Submit data to email, http, ftp. - * @param[in] hDoc The document handler. - * @param[in] eFormat Determines the format in which the data will be - *submitted. XFA_AttributeEnum::Xdp, XFA_AttributeEnum::Xml... - * @param[in] wsTarget The URL to which the data will be submitted. - * @param[in] eEncoding The encoding of text content. - * @param[in] pXDPContent Controls what subset of the data is submitted, used - *only when the format property is xdp. - * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted - *content or not. - */ - bool SubmitData(CXFA_FFDoc* hDoc, CXFA_SubmitData submitData) override; + bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override; bool GetGlobalProperty(CXFA_FFDoc* hDoc, const ByteStringView& szPropName, @@ -93,7 +81,7 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { bool OnBeforeNotifySubmit(); void OnAfterNotifySubmit(); bool NotifySubmit(bool bPrevOrPost); - bool SubmitDataInternal(CXFA_FFDoc* hDoc, CXFA_SubmitData submitData); + bool SubmitInternal(CXFA_FFDoc* hDoc, CXFA_Submit* submit); bool MailToInfo(WideString& csURL, WideString& csToAddress, WideString& csCCAddress, diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index f8ea037bf3..755821ef6b 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -311,8 +311,8 @@ int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_EventData& eventData, case XFA_Element::SignData: break; case XFA_Element::Submit: - return GetDoc()->GetDocEnvironment()->SubmitData( - GetDoc(), eventData.GetSubmitData()); + return GetDoc()->GetDocEnvironment()->Submit(GetDoc(), + eventData.GetSubmit()); default: break; } diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index c81a9c2b5f..d7c8c651ca 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -14,6 +14,7 @@ #include "xfa/fxfa/fxfa_basic.h" class CXFA_FFPageView; +class CXFA_Submit; class CXFA_WidgetAcc; class IFWL_AdapterTimerMgr; class IFX_SeekableReadStream; @@ -248,7 +249,7 @@ class IXFA_DocEnvironment { uint32_t dwOptions) = 0; virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) = 0; - virtual bool SubmitData(CXFA_FFDoc* hDoc, CXFA_SubmitData submitData) = 0; + virtual bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) = 0; virtual bool GetGlobalProperty(CXFA_FFDoc* hDoc, const ByteStringView& szPropName, CFXJSE_Value* pValue) = 0; diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp index 0250346d85..062d881cda 100644 --- a/xfa/fxfa/parser/cxfa_eventdata.cpp +++ b/xfa/fxfa/parser/cxfa_eventdata.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/parser/cxfa_eventdata.h" #include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_submit.h" CXFA_EventData::CXFA_EventData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} @@ -34,6 +35,7 @@ CXFA_ScriptData CXFA_EventData::GetScriptData() const { return CXFA_ScriptData(m_pNode->GetChild(0, XFA_Element::Script, false)); } -CXFA_SubmitData CXFA_EventData::GetSubmitData() const { - return CXFA_SubmitData(m_pNode->GetChild(0, XFA_Element::Submit, false)); +CXFA_Submit* CXFA_EventData::GetSubmit() const { + return static_cast( + m_pNode->GetChild(0, XFA_Element::Submit, false)); } diff --git a/xfa/fxfa/parser/cxfa_eventdata.h b/xfa/fxfa/parser/cxfa_eventdata.h index 4e386430dc..63349690ab 100644 --- a/xfa/fxfa/parser/cxfa_eventdata.h +++ b/xfa/fxfa/parser/cxfa_eventdata.h @@ -12,9 +12,9 @@ #include "core/fxcrt/fx_string.h" #include "xfa/fxfa/parser/cxfa_datadata.h" #include "xfa/fxfa/parser/cxfa_scriptdata.h" -#include "xfa/fxfa/parser/cxfa_submitdata.h" class CXFA_Node; +class CXFA_Submit; class CXFA_EventData : public CXFA_DataData { public: @@ -23,7 +23,7 @@ class CXFA_EventData : public CXFA_DataData { XFA_AttributeEnum GetActivity(); XFA_Element GetEventType() const; CXFA_ScriptData GetScriptData() const; - CXFA_SubmitData GetSubmitData() const; + CXFA_Submit* GetSubmit() const; WideString GetRef() const; }; diff --git a/xfa/fxfa/parser/cxfa_submit.cpp b/xfa/fxfa/parser/cxfa_submit.cpp index 04255f8dc5..e4558e865a 100644 --- a/xfa/fxfa/parser/cxfa_submit.cpp +++ b/xfa/fxfa/parser/cxfa_submit.cpp @@ -41,3 +41,19 @@ CXFA_Submit::CXFA_Submit(CXFA_Document* doc, XFA_PacketType packet) pdfium::MakeUnique(this)) {} CXFA_Submit::~CXFA_Submit() {} + +bool CXFA_Submit::IsSubmitEmbedPDF() { + return JSObject()->GetBoolean(XFA_Attribute::EmbedPDF); +} + +XFA_AttributeEnum CXFA_Submit::GetSubmitFormat() { + return JSObject()->GetEnum(XFA_Attribute::Format); +} + +WideString CXFA_Submit::GetSubmitTarget() { + return JSObject()->GetCData(XFA_Attribute::Target); +} + +WideString CXFA_Submit::GetSubmitXDPContent() { + return JSObject()->GetCData(XFA_Attribute::XdpContent); +} diff --git a/xfa/fxfa/parser/cxfa_submit.h b/xfa/fxfa/parser/cxfa_submit.h index 2b9b5e8c69..24d5f11796 100644 --- a/xfa/fxfa/parser/cxfa_submit.h +++ b/xfa/fxfa/parser/cxfa_submit.h @@ -7,12 +7,18 @@ #ifndef XFA_FXFA_PARSER_CXFA_SUBMIT_H_ #define XFA_FXFA_PARSER_CXFA_SUBMIT_H_ +#include "core/fxcrt/widestring.h" #include "xfa/fxfa/parser/cxfa_node.h" class CXFA_Submit : public CXFA_Node { public: CXFA_Submit(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Submit() override; + + bool IsSubmitEmbedPDF(); + XFA_AttributeEnum GetSubmitFormat(); + WideString GetSubmitTarget(); + WideString GetSubmitXDPContent(); }; #endif // XFA_FXFA_PARSER_CXFA_SUBMIT_H_ diff --git a/xfa/fxfa/parser/cxfa_submitdata.cpp b/xfa/fxfa/parser/cxfa_submitdata.cpp deleted file mode 100644 index 20dce38652..0000000000 --- a/xfa/fxfa/parser/cxfa_submitdata.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// 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/parser/cxfa_submitdata.h" - -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_SubmitData::CXFA_SubmitData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} - -bool CXFA_SubmitData::IsSubmitEmbedPDF() const { - return m_pNode->JSObject()->GetBoolean(XFA_Attribute::EmbedPDF); -} - -XFA_AttributeEnum CXFA_SubmitData::GetSubmitFormat() const { - return m_pNode->JSObject()->GetEnum(XFA_Attribute::Format); -} - -WideString CXFA_SubmitData::GetSubmitTarget() const { - return m_pNode->JSObject()->GetCData(XFA_Attribute::Target); -} - -WideString CXFA_SubmitData::GetSubmitXDPContent() const { - return m_pNode->JSObject()->GetCData(XFA_Attribute::XdpContent); -} diff --git a/xfa/fxfa/parser/cxfa_submitdata.h b/xfa/fxfa/parser/cxfa_submitdata.h deleted file mode 100644 index 55f06f945a..0000000000 --- a/xfa/fxfa/parser/cxfa_submitdata.h +++ /dev/null @@ -1,26 +0,0 @@ -// 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_PARSER_CXFA_SUBMITDATA_H_ -#define XFA_FXFA_PARSER_CXFA_SUBMITDATA_H_ - -#include "core/fxcrt/fx_string.h" -#include "core/fxcrt/fx_system.h" -#include "xfa/fxfa/parser/cxfa_datadata.h" - -class CXFA_Node; - -class CXFA_SubmitData : public CXFA_DataData { - public: - explicit CXFA_SubmitData(CXFA_Node* pNode); - - bool IsSubmitEmbedPDF() const; - XFA_AttributeEnum GetSubmitFormat() const; - WideString GetSubmitTarget() const; - WideString GetSubmitXDPContent() const; -}; - -#endif // XFA_FXFA_PARSER_CXFA_SUBMITDATA_H_ -- cgit v1.2.3