Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cxfa_occur.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_occur.h"
8
9
#
include
"fxjs/xfa/cjx_occur.h"
10
#
include
"xfa/fxfa/parser/cxfa_document.h"
11
12
namespace
{
13
14
const
CXFA_Node
::
PropertyData
kOccurPropertyData[] = {
15
{
XFA_Element
::Extras, 1, {}},
16
};
17
18
const
CXFA_Node
::
AttributeData
kOccurAttributeData[] = {
19
{
XFA_Attribute
::Id,
XFA_AttributeType
::
CData
,
nullptr
},
20
{
XFA_Attribute
::Max,
XFA_AttributeType
::
Integer
, (
void
*)1},
21
{
XFA_Attribute
::Min,
XFA_AttributeType
::
Integer
, (
void
*)1},
22
{
XFA_Attribute
::Use,
XFA_AttributeType
::
CData
,
nullptr
},
23
{
XFA_Attribute
::Initial,
XFA_AttributeType
::
Integer
, (
void
*)1},
24
{
XFA_Attribute
::Usehref,
XFA_AttributeType
::
CData
,
nullptr
},
25
};
26
27
}
// namespace
28
29
CXFA_Occur::CXFA_Occur(CXFA_Document* doc,
XFA_PacketType
packet)
30
: CXFA_Node(doc,
31
packet,
32
{XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
33
XFA_ObjectType::Node,
34
XFA_Element::Occur,
35
kOccurPropertyData,
36
kOccurAttributeData,
37
cppgc::MakeGarbageCollected<CJX_Occur>(
38
doc->GetHeap()->GetAllocationHandle(),
39
this
)) {}
40
41
CXFA_Occur::~
CXFA_Occur
() =
default
;
42
43
int32_t CXFA_Occur::
GetMax
() {
44
std
::optional<int32_t> max = JSObject()->TryInteger(XFA_Attribute::Max,
true
);
45
return
max.has_value() ? max.value() :
GetMin
(
)
;
46
}
47
48
int32_t CXFA_Occur::
GetMin
() {
49
std
::optional<int32_t> min = JSObject()->TryInteger(XFA_Attribute::Min,
true
);
50
return
min.has_value() && min.value() >= 0 ? min.value() : 1;
51
}
52
53
std
::tuple<int32_t, int32_t, int32_t> CXFA_Occur::
GetOccurInfo
() {
54
int32_t iMin =
GetMin
(
)
;
55
int32_t iMax =
GetMax
(
)
;
56
57
std
::optional<int32_t> init =
58
JSObject()->TryInteger(XFA_Attribute::Initial,
false
);
59
return
{iMin, iMax,
60
init.has_value() && init.value() >= iMin ? init.value() : iMin};
61
}
62
63
void
CXFA_Occur::
SetMax
(int32_t iMax) {
64
iMax = (iMax != -1 && iMax < 1) ? 1 : iMax;
65
JSObject()->SetInteger(
XFA_Attribute
::Max, iMax,
false
);
66
67
int32_t iMin =
GetMin
(
)
;
68
if
(iMax != -1 && iMax < iMin) {
69
iMin = iMax;
70
JSObject()->SetInteger(
XFA_Attribute
::Min, iMin,
false
);
71
}
72
}
73
74
void
CXFA_Occur::
SetMin
(int32_t iMin) {
75
iMin = (iMin < 0) ? 1 : iMin;
76
JSObject()->SetInteger(
XFA_Attribute
::Min, iMin,
false
);
77
78
int32_t iMax =
GetMax
(
)
;
79
if
(iMax > 0 && iMax < iMin) {
80
iMax = iMin;
81
JSObject()->SetInteger(
XFA_Attribute
::Max, iMax,
false
);
82
}
83
}
CXFA_Node
Definition
cxfa_node.h:94
CXFA_Occur::SetMax
void SetMax(int32_t iMax)
Definition
cxfa_occur.cpp:63
CXFA_Occur::GetOccurInfo
std::tuple< int32_t, int32_t, int32_t > GetOccurInfo()
Definition
cxfa_occur.cpp:53
CXFA_Occur::GetMax
int32_t GetMax()
Definition
cxfa_occur.cpp:43
CXFA_Occur::SetMin
void SetMin(int32_t iMin)
Definition
cxfa_occur.cpp:74
CXFA_Occur::GetMin
int32_t GetMin()
Definition
cxfa_occur.cpp:48
CXFA_Occur::~CXFA_Occur
~CXFA_Occur() override
XFA_AttributeType
XFA_AttributeType
Definition
fxfa_basic.h:83
XFA_AttributeType::Integer
@ Integer
Definition
fxfa_basic.h:87
XFA_AttributeType::CData
@ CData
Definition
fxfa_basic.h:85
XFA_Attribute
XFA_Attribute
Definition
fxfa_basic.h:67
XFA_Element
XFA_Element
Definition
fxfa_basic.h:75
XFA_PacketType
XFA_PacketType
Definition
fxfa_basic.h:44
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
CXFA_Node::AttributeData
Definition
cxfa_node.h:110
CXFA_Node::PropertyData
Definition
cxfa_node.h:96
qtwebengine
src
3rdparty
chromium
third_party
pdfium
xfa
fxfa
parser
cxfa_occur.cpp
Generated on
for Qt by
1.18.0