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_margin.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_margin.h"
8
9#include "fxjs/xfa/cjx_node.h"
10#include "xfa/fxfa/parser/cxfa_document.h"
11
12namespace {
13
14const CXFA_Node::PropertyData kMarginPropertyData[] = {
15 {XFA_Element::Extras, 1, {}},
16};
17
18const CXFA_Node::AttributeData kMarginAttributeData[] = {
21 {XFA_Attribute::LeftInset, XFA_AttributeType::Measure, (void*)L"0in"},
22 {XFA_Attribute::BottomInset, XFA_AttributeType::Measure, (void*)L"0in"},
23 {XFA_Attribute::TopInset, XFA_AttributeType::Measure, (void*)L"0in"},
24 {XFA_Attribute::RightInset, XFA_AttributeType::Measure, (void*)L"0in"},
25 {XFA_Attribute::Usehref, XFA_AttributeType::CData, nullptr},
26};
27
28} // namespace
29
30CXFA_Margin::CXFA_Margin(CXFA_Document* doc, XFA_PacketType packet)
31 : CXFA_Node(doc,
32 packet,
33 {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
34 XFA_ObjectType::Node,
35 XFA_Element::Margin,
36 kMarginPropertyData,
37 kMarginAttributeData,
38 cppgc::MakeGarbageCollected<CJX_Node>(
39 doc->GetHeap()->GetAllocationHandle(),
40 this)) {}
41
42CXFA_Margin::~CXFA_Margin() = default;
43
44float CXFA_Margin::GetLeftInset() const {
45 return TryLeftInset().value_or(0);
46}
47
48float CXFA_Margin::GetTopInset() const {
49 return TryTopInset().value_or(0);
50}
51
52float CXFA_Margin::GetRightInset() const {
53 return TryRightInset().value_or(0);
54}
55
56float CXFA_Margin::GetBottomInset() const {
57 return TryBottomInset().value_or(0);
58}
59
60absl::optional<float> CXFA_Margin::TryLeftInset() const {
61 return JSObject()->TryMeasureAsFloat(XFA_Attribute::LeftInset);
62}
63
64absl::optional<float> CXFA_Margin::TryTopInset() const {
65 return JSObject()->TryMeasureAsFloat(XFA_Attribute::TopInset);
66}
67
68absl::optional<float> CXFA_Margin::TryRightInset() const {
69 return JSObject()->TryMeasureAsFloat(XFA_Attribute::RightInset);
70}
71
72absl::optional<float> CXFA_Margin::TryBottomInset() const {
73 return JSObject()->TryMeasureAsFloat(XFA_Attribute::BottomInset);
74}
float GetBottomInset() const
~CXFA_Margin() override
absl::optional< float > TryTopInset() const
absl::optional< float > TryBottomInset() const
absl::optional< float > TryRightInset() const
absl::optional< float > TryLeftInset() const
float GetLeftInset() const
float GetTopInset() const
float GetRightInset() const
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