From c8be4ce787252eaf3b03270bc99fe1e9e9044543 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 7 Nov 2017 20:08:31 +0000 Subject: Rename CXFA_Event to CXFA_EventData This CL renames CXFA_Event to CXFA_EventData to make it clear it's part of the Data hierarchy. Change-Id: I3659dfba66498d07ce75fd5e8322732f9898e688 Reviewed-on: https://pdfium-review.googlesource.com/17980 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- BUILD.gn | 4 +-- xfa/fxfa/cxfa_widgetacc.cpp | 12 ++++----- xfa/fxfa/cxfa_widgetacc.h | 5 ++-- xfa/fxfa/parser/cxfa_event.cpp | 50 ------------------------------------- xfa/fxfa/parser/cxfa_event.h | 31 ----------------------- xfa/fxfa/parser/cxfa_eventdata.cpp | 50 +++++++++++++++++++++++++++++++++++++ xfa/fxfa/parser/cxfa_eventdata.h | 31 +++++++++++++++++++++++ xfa/fxfa/parser/cxfa_widgetdata.cpp | 8 +++--- 8 files changed, 96 insertions(+), 95 deletions(-) delete mode 100644 xfa/fxfa/parser/cxfa_event.cpp delete mode 100644 xfa/fxfa/parser/cxfa_event.h create mode 100644 xfa/fxfa/parser/cxfa_eventdata.cpp create mode 100644 xfa/fxfa/parser/cxfa_eventdata.h diff --git a/BUILD.gn b/BUILD.gn index 4f5f8e26b6..70eb37edc1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1819,8 +1819,8 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_document_parser.cpp", "xfa/fxfa/parser/cxfa_document_parser.h", "xfa/fxfa/parser/cxfa_edgedata.h", - "xfa/fxfa/parser/cxfa_event.cpp", - "xfa/fxfa/parser/cxfa_event.h", + "xfa/fxfa/parser/cxfa_eventdata.cpp", + "xfa/fxfa/parser/cxfa_eventdata.h", "xfa/fxfa/parser/cxfa_exdata.cpp", "xfa/fxfa/parser/cxfa_exdata.h", "xfa/fxfa/parser/cxfa_fill.cpp", diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 9be0bdb203..ea262f874d 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -287,7 +287,7 @@ int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, bool first = true; int32_t iRet = XFA_EVENTERROR_NotExist; for (CXFA_Node* pNode : eventArray) { - int32_t result = ProcessEvent(CXFA_Event(pNode), pEventParam); + int32_t result = ProcessEvent(CXFA_EventData(pNode), pEventParam); if (first || result == XFA_EVENTERROR_Success) iRet = result; first = false; @@ -295,21 +295,21 @@ int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, return iRet; } -int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_Event& event, +int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_EventData& eventData, CXFA_EventParam* pEventParam) { - if (!event) + if (!eventData) return XFA_EVENTERROR_NotExist; - switch (event.GetEventType()) { + switch (eventData.GetEventType()) { case XFA_Element::Execute: break; case XFA_Element::Script: - return ExecuteScript(event.GetScript(), pEventParam); + return ExecuteScript(eventData.GetScript(), pEventParam); case XFA_Element::SignData: break; case XFA_Element::Submit: return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(), - event.GetSubmit()); + eventData.GetSubmit()); default: break; } diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index 718dcf3a63..4d66ff3b5a 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -15,7 +15,7 @@ #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_dib.h" #include "xfa/fxfa/parser/cxfa_boxdata.h" -#include "xfa/fxfa/parser/cxfa_event.h" +#include "xfa/fxfa/parser/cxfa_eventdata.h" #include "xfa/fxfa/parser/cxfa_image.h" #include "xfa/fxfa/parser/cxfa_margin.h" #include "xfa/fxfa/parser/cxfa_script.h" @@ -45,7 +45,8 @@ class CXFA_WidgetAcc : public CXFA_WidgetData { bool ProcessValueChanged(); int32_t ProcessEvent(int32_t iActivity, CXFA_EventParam* pEventParam); - int32_t ProcessEvent(const CXFA_Event& event, CXFA_EventParam* pEventParam); + int32_t ProcessEvent(const CXFA_EventData& eventData, + CXFA_EventParam* pEventParam); int32_t ProcessCalculate(); int32_t ProcessValidate(int32_t iFlags); int32_t ExecuteScript(CXFA_Script script, CXFA_EventParam* pEventParam); diff --git a/xfa/fxfa/parser/cxfa_event.cpp b/xfa/fxfa/parser/cxfa_event.cpp deleted file mode 100644 index 8ba68fb294..0000000000 --- a/xfa/fxfa/parser/cxfa_event.cpp +++ /dev/null @@ -1,50 +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_event.h" - -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {} - -int32_t CXFA_Event::GetActivity() { - return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Activity); -} - -XFA_Element CXFA_Event::GetEventType() const { - CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChild) { - XFA_Element eType = pChild->GetElementType(); - if (eType != XFA_Element::Extras) - return eType; - - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - } - return XFA_Element::Unknown; -} - -void CXFA_Event::GetRef(WideStringView& wsRef) { - m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Ref, wsRef, true); -} - -CXFA_Script CXFA_Event::GetScript() const { - return CXFA_Script(m_pNode->GetChild(0, XFA_Element::Script, false)); -} - -CXFA_Submit CXFA_Event::GetSubmit() const { - return CXFA_Submit(m_pNode->GetChild(0, XFA_Element::Submit, false)); -} - -void CXFA_Event::GetSignDataTarget(WideString& wsTarget) { - CXFA_Node* pNode = - m_pNode->JSNode()->GetProperty(0, XFA_Element::SignData, true); - if (!pNode) - return; - - WideStringView wsCData; - pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Target, wsCData, true); - wsTarget = wsCData; -} diff --git a/xfa/fxfa/parser/cxfa_event.h b/xfa/fxfa/parser/cxfa_event.h deleted file mode 100644 index 3835454c28..0000000000 --- a/xfa/fxfa/parser/cxfa_event.h +++ /dev/null @@ -1,31 +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_EVENT_H_ -#define XFA_FXFA_PARSER_CXFA_EVENT_H_ - -#include - -#include "core/fxcrt/fx_string.h" -#include "xfa/fxfa/parser/cxfa_data.h" -#include "xfa/fxfa/parser/cxfa_script.h" -#include "xfa/fxfa/parser/cxfa_submit.h" - -class CXFA_Node; - -class CXFA_Event : public CXFA_Data { - public: - explicit CXFA_Event(CXFA_Node* pNode); - - int32_t GetActivity(); - XFA_Element GetEventType() const; - CXFA_Script GetScript() const; - CXFA_Submit GetSubmit() const; - void GetRef(WideStringView& wsRef); - void GetSignDataTarget(WideString& wsTarget); -}; - -#endif // XFA_FXFA_PARSER_CXFA_EVENT_H_ diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp new file mode 100644 index 0000000000..5b48df6d88 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_eventdata.cpp @@ -0,0 +1,50 @@ +// 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_eventdata.h" + +#include "xfa/fxfa/parser/cxfa_node.h" + +CXFA_EventData::CXFA_EventData(CXFA_Node* pNode) : CXFA_Data(pNode) {} + +int32_t CXFA_EventData::GetActivity() { + return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Activity); +} + +XFA_Element CXFA_EventData::GetEventType() const { + CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChild) { + XFA_Element eType = pChild->GetElementType(); + if (eType != XFA_Element::Extras) + return eType; + + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + } + return XFA_Element::Unknown; +} + +void CXFA_EventData::GetRef(WideStringView& wsRef) { + m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Ref, wsRef, true); +} + +CXFA_Script CXFA_EventData::GetScript() const { + return CXFA_Script(m_pNode->GetChild(0, XFA_Element::Script, false)); +} + +CXFA_Submit CXFA_EventData::GetSubmit() const { + return CXFA_Submit(m_pNode->GetChild(0, XFA_Element::Submit, false)); +} + +void CXFA_EventData::GetSignDataTarget(WideString& wsTarget) { + CXFA_Node* pNode = + m_pNode->JSNode()->GetProperty(0, XFA_Element::SignData, true); + if (!pNode) + return; + + WideStringView wsCData; + pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Target, wsCData, true); + wsTarget = wsCData; +} diff --git a/xfa/fxfa/parser/cxfa_eventdata.h b/xfa/fxfa/parser/cxfa_eventdata.h new file mode 100644 index 0000000000..b6fdc48e99 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_eventdata.h @@ -0,0 +1,31 @@ +// 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_EVENTDATA_H_ +#define XFA_FXFA_PARSER_CXFA_EVENTDATA_H_ + +#include + +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/parser/cxfa_data.h" +#include "xfa/fxfa/parser/cxfa_script.h" +#include "xfa/fxfa/parser/cxfa_submit.h" + +class CXFA_Node; + +class CXFA_EventData : public CXFA_Data { + public: + explicit CXFA_EventData(CXFA_Node* pNode); + + int32_t GetActivity(); + XFA_Element GetEventType() const; + CXFA_Script GetScript() const; + CXFA_Submit GetSubmit() const; + void GetRef(WideStringView& wsRef); + void GetSignDataTarget(WideString& wsTarget); +}; + +#endif // XFA_FXFA_PARSER_CXFA_EVENTDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index ccce8cf501..362f0b5e54 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -12,7 +12,7 @@ #include "third_party/base/stl_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_event.h" +#include "xfa/fxfa/parser/cxfa_eventdata.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -311,11 +311,11 @@ std::vector CXFA_WidgetData::GetEventByActivity(int32_t iActivity, bool bIsFormReady) { std::vector events; for (CXFA_Node* pNode : GetEventList()) { - CXFA_Event event(pNode); - if (event.GetActivity() == iActivity) { + CXFA_EventData eventData(pNode); + if (eventData.GetActivity() == iActivity) { if (iActivity == XFA_ATTRIBUTEENUM_Ready) { WideStringView wsRef; - event.GetRef(wsRef); + eventData.GetRef(wsRef); if (bIsFormReady) { if (wsRef == WideStringView(L"$form")) events.push_back(pNode); -- cgit v1.2.3