diff options
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cxfa_event.cpp | 30 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_event.h | 9 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_eventdata.cpp | 41 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_eventdata.h | 30 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.h | 1 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 24 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.h | 6 |
7 files changed, 53 insertions, 88 deletions
diff --git a/xfa/fxfa/parser/cxfa_event.cpp b/xfa/fxfa/parser/cxfa_event.cpp index b3ee47b4df..2675761bc6 100644 --- a/xfa/fxfa/parser/cxfa_event.cpp +++ b/xfa/fxfa/parser/cxfa_event.cpp @@ -8,6 +8,8 @@ #include "fxjs/xfa/cjx_event.h" #include "third_party/base/ptr_util.h" +#include "xfa/fxfa/parser/cxfa_script.h" +#include "xfa/fxfa/parser/cxfa_submit.h" namespace { @@ -46,3 +48,31 @@ CXFA_Event::CXFA_Event(CXFA_Document* doc, XFA_PacketType packet) pdfium::MakeUnique<CJX_Event>(this)) {} CXFA_Event::~CXFA_Event() {} + +XFA_AttributeEnum CXFA_Event::GetActivity() { + return JSObject()->GetEnum(XFA_Attribute::Activity); +} + +XFA_Element CXFA_Event::GetEventType() const { + CXFA_Node* pChild = 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; +} + +WideString CXFA_Event::GetRef() { + return JSObject()->GetCData(XFA_Attribute::Ref); +} + +CXFA_Script* CXFA_Event::GetScript() { + return GetChild<CXFA_Script>(0, XFA_Element::Script, false); +} + +CXFA_Submit* CXFA_Event::GetSubmit() { + return GetChild<CXFA_Submit>(0, XFA_Element::Submit, false); +} diff --git a/xfa/fxfa/parser/cxfa_event.h b/xfa/fxfa/parser/cxfa_event.h index 655e776b85..a2b2fb804a 100644 --- a/xfa/fxfa/parser/cxfa_event.h +++ b/xfa/fxfa/parser/cxfa_event.h @@ -9,10 +9,19 @@ #include "xfa/fxfa/parser/cxfa_node.h" +class CXFA_Script; +class CXFA_Submit; + class CXFA_Event : public CXFA_Node { public: CXFA_Event(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Event() override; + + XFA_AttributeEnum GetActivity(); + XFA_Element GetEventType() const; + CXFA_Script* GetScript(); + CXFA_Submit* GetSubmit(); + WideString GetRef(); }; #endif // XFA_FXFA_PARSER_CXFA_EVENT_H_ diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp deleted file mode 100644 index 89dcb4ed2a..0000000000 --- a/xfa/fxfa/parser/cxfa_eventdata.cpp +++ /dev/null @@ -1,41 +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_eventdata.h" - -#include "xfa/fxfa/parser/cxfa_node.h" -#include "xfa/fxfa/parser/cxfa_script.h" -#include "xfa/fxfa/parser/cxfa_submit.h" - -CXFA_EventData::CXFA_EventData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} - -XFA_AttributeEnum CXFA_EventData::GetActivity() { - return m_pNode->JSObject()->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; -} - -WideString CXFA_EventData::GetRef() const { - return m_pNode->JSObject()->GetCData(XFA_Attribute::Ref); -} - -CXFA_Script* CXFA_EventData::GetScript() const { - return m_pNode->GetChild<CXFA_Script>(0, XFA_Element::Script, false); -} - -CXFA_Submit* CXFA_EventData::GetSubmit() const { - return m_pNode->GetChild<CXFA_Submit>(0, XFA_Element::Submit, false); -} diff --git a/xfa/fxfa/parser/cxfa_eventdata.h b/xfa/fxfa/parser/cxfa_eventdata.h deleted file mode 100644 index 8338767fe0..0000000000 --- a/xfa/fxfa/parser/cxfa_eventdata.h +++ /dev/null @@ -1,30 +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_EVENTDATA_H_ -#define XFA_FXFA_PARSER_CXFA_EVENTDATA_H_ - -#include <stdint.h> - -#include "core/fxcrt/fx_string.h" -#include "xfa/fxfa/parser/cxfa_datadata.h" - -class CXFA_Node; -class CXFA_Script; -class CXFA_Submit; - -class CXFA_EventData : public CXFA_DataData { - public: - explicit CXFA_EventData(CXFA_Node* pNode); - - XFA_AttributeEnum GetActivity(); - XFA_Element GetEventType() const; - CXFA_Script* GetScript() const; - CXFA_Submit* GetSubmit() const; - WideString GetRef() const; -}; - -#endif // XFA_FXFA_PARSER_CXFA_EVENTDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 81d0bfc359..b41a27ef01 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -167,6 +167,7 @@ class CXFA_Node : public CXFA_Object { CXFA_Node* Clone(bool bRecursive); CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const; CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_ObjectType eType) const; + std::vector<CXFA_Node*> GetNodeList(uint32_t dwTypeFilter, XFA_Element eTypeFilter); CXFA_Node* CreateSamePacketNode(XFA_Element eType); diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 4a8817812f..5833655156 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -17,7 +17,7 @@ #include "xfa/fxfa/parser/cxfa_comb.h" #include "xfa/fxfa/parser/cxfa_decimal.h" #include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_eventdata.h" +#include "xfa/fxfa/parser/cxfa_event.h" #include "xfa/fxfa/parser/cxfa_font.h" #include "xfa/fxfa/parser/cxfa_format.h" #include "xfa/fxfa/parser/cxfa_items.h" @@ -287,28 +287,24 @@ CXFA_Para* CXFA_WidgetData::GetPara() { false); } -std::vector<CXFA_Node*> CXFA_WidgetData::GetEventList() { - return m_pNode->GetNodeList(0, XFA_Element::Event); -} - -std::vector<CXFA_Node*> CXFA_WidgetData::GetEventByActivity( +std::vector<CXFA_Event*> CXFA_WidgetData::GetEventByActivity( XFA_AttributeEnum iActivity, bool bIsFormReady) { - std::vector<CXFA_Node*> events; - for (CXFA_Node* pNode : GetEventList()) { - CXFA_EventData eventData(pNode); - if (eventData.GetActivity() == iActivity) { + std::vector<CXFA_Event*> events; + for (CXFA_Node* node : m_pNode->GetNodeList(0, XFA_Element::Event)) { + auto* event = static_cast<CXFA_Event*>(node); + if (event->GetActivity() == iActivity) { if (iActivity == XFA_AttributeEnum::Ready) { - WideString wsRef = eventData.GetRef(); + WideString wsRef = event->GetRef(); if (bIsFormReady) { if (wsRef == WideStringView(L"$form")) - events.push_back(pNode); + events.push_back(event); } else { if (wsRef == WideStringView(L"$layout")) - events.push_back(pNode); + events.push_back(event); } } else { - events.push_back(pNode); + events.push_back(event); } } } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index 30d64a09c5..57e6939f37 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -33,6 +33,7 @@ class CXFA_Bind; class CXFA_Border; class CXFA_Calculate; class CXFA_Caption; +class CXFA_Event; class CXFA_Font; class CXFA_Margin; class CXFA_Node; @@ -70,8 +71,8 @@ class CXFA_WidgetData : public CXFA_DataData { CXFA_Validate* GetValidate(bool bModified); CXFA_Border* GetUIBorder(); - std::vector<CXFA_Node*> GetEventByActivity(XFA_AttributeEnum iActivity, - bool bIsFormReady); + std::vector<CXFA_Event*> GetEventByActivity(XFA_AttributeEnum iActivity, + bool bIsFormReady); pdfium::Optional<float> TryWidth(); pdfium::Optional<float> TryHeight(); @@ -182,7 +183,6 @@ class CXFA_WidgetData : public CXFA_DataData { WideString FormatNumStr(const WideString& wsValue, IFX_Locale* pLocale); CXFA_Node* GetExclGroupNode(); void GetItemLabel(const WideStringView& wsValue, WideString& wsLabel); - std::vector<CXFA_Node*> GetEventList(); bool m_bIsNull; bool m_bPreNull; |