1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/fxfa/parser/cxfa_submit.h"
8
9 #include "fxjs/xfa/cjx_submit.h"
10 #include "third_party/base/ptr_util.h"
11
12 namespace {
13
14 const CXFA_Node::PropertyData kPropertyData[] = {{XFA_Element::Encrypt, 1, 0},
15 {XFA_Element::Unknown, 0, 0}};
16 const CXFA_Node::AttributeData kAttributeData[] = {
17 {XFA_Attribute::Id, XFA_AttributeType::CData, nullptr},
18 {XFA_Attribute::Use, XFA_AttributeType::CData, nullptr},
19 {XFA_Attribute::Format, XFA_AttributeType::Enum,
20 (void*)XFA_AttributeEnum::Xdp},
21 {XFA_Attribute::EmbedPDF, XFA_AttributeType::Boolean, (void*)0},
22 {XFA_Attribute::Usehref, XFA_AttributeType::CData, nullptr},
23 {XFA_Attribute::Target, XFA_AttributeType::CData, nullptr},
24 {XFA_Attribute::TextEncoding, XFA_AttributeType::CData, nullptr},
25 {XFA_Attribute::XdpContent, XFA_AttributeType::CData, nullptr},
26 {XFA_Attribute::Unknown, XFA_AttributeType::Integer, nullptr}};
27
28 constexpr wchar_t kName[] = L"submit";
29
30 } // namespace
31
CXFA_Submit(CXFA_Document * doc,XFA_PacketType packet)32 CXFA_Submit::CXFA_Submit(CXFA_Document* doc, XFA_PacketType packet)
33 : CXFA_Node(doc,
34 packet,
35 (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
36 XFA_ObjectType::Node,
37 XFA_Element::Submit,
38 kPropertyData,
39 kAttributeData,
40 kName,
41 pdfium::MakeUnique<CJX_Submit>(this)) {}
42
~CXFA_Submit()43 CXFA_Submit::~CXFA_Submit() {}
44
IsSubmitEmbedPDF()45 bool CXFA_Submit::IsSubmitEmbedPDF() {
46 return JSObject()->GetBoolean(XFA_Attribute::EmbedPDF);
47 }
48
GetSubmitFormat()49 XFA_AttributeEnum CXFA_Submit::GetSubmitFormat() {
50 return JSObject()->GetEnum(XFA_Attribute::Format);
51 }
52
GetSubmitTarget()53 WideString CXFA_Submit::GetSubmitTarget() {
54 return JSObject()->GetCData(XFA_Attribute::Target);
55 }
56
GetSubmitXDPContent()57 WideString CXFA_Submit::GetSubmitXDPContent() {
58 return JSObject()->GetCData(XFA_Attribute::XdpContent);
59 }
60