Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_calculate.cpp
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
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_calculate.h"
8
9#include "fxjs/xfa/cjx_node.h"
10#include "xfa/fxfa/parser/cxfa_document.h"
11#include "xfa/fxfa/parser/cxfa_message.h"
12#include "xfa/fxfa/parser/cxfa_script.h"
13#include "xfa/fxfa/parser/cxfa_text.h"
14
15namespace {
16
17const CXFA_Node::PropertyData kCalculatePropertyData[] = {
18 {XFA_Element::Message, 1, {}},
19 {XFA_Element::Script, 1, {}},
20 {XFA_Element::Extras, 1, {}},
21};
22
23const CXFA_Node::AttributeData kCalculateAttributeData[] = {
26 {XFA_Attribute::Usehref, XFA_AttributeType::CData, nullptr},
28 (void*)XFA_AttributeValue::Error},
29};
30
31} // namespace
32
33CXFA_Calculate::CXFA_Calculate(CXFA_Document* doc, XFA_PacketType packet)
34 : CXFA_Node(doc,
35 packet,
36 {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
37 XFA_ObjectType::Node,
38 XFA_Element::Calculate,
39 kCalculatePropertyData,
40 kCalculateAttributeData,
41 cppgc::MakeGarbageCollected<CJX_Node>(
42 doc->GetHeap()->GetAllocationHandle(),
43 this)) {}
44
45CXFA_Calculate::~CXFA_Calculate() = default;
46
48 return JSObject()
49 ->TryEnum(XFA_Attribute::Override, false)
50 .value_or(XFA_AttributeValue::Error);
51}
52
53CXFA_Script* CXFA_Calculate::GetScriptIfExists() {
54 return GetChild<CXFA_Script>(0, XFA_Element::Script, false);
55}
56
57WideString CXFA_Calculate::GetMessageText() const {
58 const auto* pNode = GetChild<CXFA_Message>(0, XFA_Element::Message, false);
59 if (!pNode)
60 return WideString();
61
62 const auto* text = pNode->GetChild<CXFA_Text>(0, XFA_Element::Text, false);
63 return text ? text->GetContent() : WideString();
64}
~CXFA_Calculate() override
CXFA_Script * GetScriptIfExists()
XFA_AttributeValue GetOverride()
WideString GetMessageText() const
XFA_AttributeType
Definition fxfa_basic.h:83
XFA_Attribute
Definition fxfa_basic.h:67
XFA_Element
Definition fxfa_basic.h:75
XFA_AttributeValue
Definition fxfa_basic.h:60
XFA_PacketType
Definition fxfa_basic.h:44