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_value.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_value.h"
8
9#include "fxjs/xfa/cjx_node.h"
10#include "fxjs/xfa/cjx_object.h"
11#include "xfa/fxfa/parser/cxfa_arc.h"
12#include "xfa/fxfa/parser/cxfa_document.h"
13#include "xfa/fxfa/parser/cxfa_exdata.h"
14#include "xfa/fxfa/parser/cxfa_image.h"
15#include "xfa/fxfa/parser/cxfa_line.h"
16#include "xfa/fxfa/parser/cxfa_rectangle.h"
17
18namespace {
19
20constexpr CXFA_Node::PropertyData kValuePropertyData[] = {
34};
35
36constexpr CXFA_Node::AttributeData kValueAttributeData[] = {
39 {XFA_Attribute::Relevant, XFA_AttributeType::CData, nullptr},
40 {XFA_Attribute::Usehref, XFA_AttributeType::CData, nullptr},
41 {XFA_Attribute::Override, XFA_AttributeType::Boolean, (void*)0},
42};
43
44} // namespace
45
46CXFA_Value::CXFA_Value(CXFA_Document* doc, XFA_PacketType packet)
47 : CXFA_Node(doc,
48 packet,
49 {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
50 XFA_ObjectType::Node,
51 XFA_Element::Value,
52 kValuePropertyData,
53 kValueAttributeData,
54 cppgc::MakeGarbageCollected<CJX_Node>(
55 doc->GetHeap()->GetAllocationHandle(),
56 this)) {}
57
58CXFA_Value::~CXFA_Value() = default;
59
60XFA_Element CXFA_Value::GetChildValueClassID() const {
61 CXFA_Node* pNode = GetFirstChild();
62 return pNode ? pNode->GetElementType() : XFA_Element::Unknown;
63}
64
65WideString CXFA_Value::GetChildValueContent() const {
66 CXFA_Node* pNode = GetFirstChild();
67 return pNode
68 ? pNode->JSObject()->TryContent(false, true).value_or(WideString())
69 : WideString();
70}
71
72CXFA_Arc* CXFA_Value::GetArcIfExists() const {
73 return CXFA_Arc::FromNode(GetFirstChild());
74}
75
76CXFA_Line* CXFA_Value::GetLineIfExists() const {
77 return CXFA_Line::FromNode(GetFirstChild());
78}
79
81 return CXFA_Rectangle::FromNode(GetFirstChild());
82}
83
84CXFA_Text* CXFA_Value::GetTextIfExists() const {
85 return CXFA_Text::FromNode(GetFirstChild());
86}
87
88CXFA_ExData* CXFA_Value::GetExDataIfExists() const {
89 return CXFA_ExData::FromNode(GetFirstChild());
90}
91
92CXFA_Image* CXFA_Value::GetImageIfExists() const {
93 return CXFA_Image::FromNode(GetFirstChild());
94}
static CXFA_Arc * FromNode(CXFA_Node *pNode)
Definition cxfa_arc.cpp:33
static CXFA_ExData * FromNode(CXFA_Node *pNode)
static CXFA_Image * FromNode(CXFA_Node *pNode)
static CXFA_Line * FromNode(CXFA_Node *pNode)
Definition cxfa_line.cpp:33
XFA_Element GetElementType() const
Definition cxfa_object.h:91
static CXFA_Rectangle * FromNode(CXFA_Node *pNode)
static CXFA_Text * FromNode(CXFA_Node *pNode)
Definition cxfa_text.cpp:26
~CXFA_Value() override
CXFA_ExData * GetExDataIfExists() const
CXFA_Text * GetTextIfExists() const
WideString GetChildValueContent() const
CXFA_Image * GetImageIfExists() const
XFA_Element GetChildValueClassID() const
CXFA_Arc * GetArcIfExists() const
CXFA_Line * GetLineIfExists() const
CXFA_Rectangle * GetRectangleIfExists() const
XFA_PropertyFlag
Definition cxfa_node.h:88
XFA_AttributeType
Definition fxfa_basic.h:83
XFA_Attribute
Definition fxfa_basic.h:67
XFA_Element
Definition fxfa_basic.h:75
XFA_PacketType
Definition fxfa_basic.h:44