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_caption.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_caption.h"
8
9#include "fxjs/xfa/cjx_node.h"
10#include "xfa/fxfa/parser/cxfa_document.h"
11#include "xfa/fxfa/parser/cxfa_font.h"
12#include "xfa/fxfa/parser/cxfa_margin.h"
13#include "xfa/fxfa/parser/cxfa_measurement.h"
14#include "xfa/fxfa/parser/cxfa_value.h"
15
16namespace {
17
18const CXFA_Node::PropertyData kCaptionPropertyData[] = {
19 {XFA_Element::Margin, 1, {}}, {XFA_Element::Para, 1, {}},
20 {XFA_Element::Font, 1, {}}, {XFA_Element::Value, 1, {}},
21 {XFA_Element::Extras, 1, {}},
22};
23
24const CXFA_Node::AttributeData kCaptionAttributeData[] = {
27 {XFA_Attribute::Reserve, XFA_AttributeType::Measure, (void*)L"-1un"},
29 (void*)XFA_AttributeValue::Visible},
30 {XFA_Attribute::Usehref, XFA_AttributeType::CData, nullptr},
32 (void*)XFA_AttributeValue::Left},
33};
34
35} // namespace
36
37CXFA_Caption::CXFA_Caption(CXFA_Document* doc, XFA_PacketType packet)
38 : CXFA_Node(doc,
39 packet,
40 {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
41 XFA_ObjectType::Node,
42 XFA_Element::Caption,
43 kCaptionPropertyData,
44 kCaptionAttributeData,
45 cppgc::MakeGarbageCollected<CJX_Node>(
46 doc->GetHeap()->GetAllocationHandle(),
47 this)) {}
48
49CXFA_Caption::~CXFA_Caption() = default;
50
51bool CXFA_Caption::IsVisible() {
52 auto value = JSObject()->TryEnum(XFA_Attribute::Presence, true);
53 return !value.has_value() || value.value() == XFA_AttributeValue::Visible;
54}
55
56bool CXFA_Caption::IsHidden() {
57 auto value = JSObject()->TryEnum(XFA_Attribute::Presence, true);
58 return !value.has_value() || value.value() == XFA_AttributeValue::Hidden;
59}
60
62 auto value = JSObject()->TryEnum(XFA_Attribute::Placement, true);
63 return value.value_or(XFA_AttributeValue::Left);
64}
65
66float CXFA_Caption::GetReserve() const {
67 return JSObject()->GetMeasureInUnit(XFA_Attribute::Reserve, XFA_Unit::Pt);
68}
69
70CXFA_Margin* CXFA_Caption::GetMarginIfExists() {
71 return GetChild<CXFA_Margin>(0, XFA_Element::Margin, false);
72}
73
74CXFA_Font* CXFA_Caption::GetFontIfExists() {
75 return GetChild<CXFA_Font>(0, XFA_Element::Font, false);
76}
77
78CXFA_Value* CXFA_Caption::GetValueIfExists() {
79 return GetChild<CXFA_Value>(0, XFA_Element::Value, false);
80}
float GetReserve() const
~CXFA_Caption() override
CXFA_Font * GetFontIfExists()
CXFA_Margin * GetMarginIfExists()
CXFA_Value * GetValueIfExists()
XFA_AttributeValue GetPlacementType()
XFA_Unit
Definition fxfa_basic.h:91
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