7#include "xfa/fxfa/parser/cxfa_barcode.h"
9#include "fxjs/xfa/cjx_node.h"
10#include "xfa/fxfa/parser/cxfa_document.h"
11#include "xfa/fxfa/parser/cxfa_measurement.h"
48 ?
static_cast<CXFA_Barcode*>(pNode)
52CXFA_Barcode::CXFA_Barcode(CXFA_Document* doc,
XFA_PacketType packet)
55 {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
59 kBarcodeAttributeData,
60 cppgc::MakeGarbageCollected<CJX_Node>(
61 doc->GetHeap()->GetAllocationHandle(),
75 return JSObject()->TryCData(
XFA_Attribute::CharEncoding,
true);
79 absl::optional<XFA_AttributeValue> checksum =
80 JSObject()->TryEnum(XFA_Attribute::Checksum,
true);
81 if (!checksum.has_value())
84 switch (checksum.value()) {
85 case XFA_AttributeValue::None:
87 case XFA_AttributeValue::Auto:
89 case XFA_AttributeValue::Checksum_1mod10:
90 case XFA_AttributeValue::Checksum_1mod10_1mod11:
91 case XFA_AttributeValue::Checksum_2mod10:
99 absl::optional<WideString> wsDataLength =
100 JSObject()->TryCData(XFA_Attribute::DataLength,
true);
101 if (!wsDataLength.has_value())
102 return absl::nullopt;
104 return FXSYS_wtoi(wsDataLength->c_str());
108 absl::optional<WideString> wsStartEndChar =
109 JSObject()->TryCData(XFA_Attribute::StartChar,
true);
110 if (!wsStartEndChar.has_value() || wsStartEndChar->IsEmpty())
111 return absl::nullopt;
113 return static_cast<
char>(wsStartEndChar.value()[0]);
117 absl::optional<WideString> wsStartEndChar =
118 JSObject()->TryCData(XFA_Attribute::EndChar,
true);
119 if (!wsStartEndChar.has_value() || wsStartEndChar->IsEmpty())
120 return absl::nullopt;
122 return static_cast<
char>(wsStartEndChar.value()[0]);
126 absl::optional<WideString> wsECLevel =
127 JSObject()->TryCData(XFA_Attribute::ErrorCorrectionLevel,
true);
128 if (!wsECLevel.has_value())
129 return absl::nullopt;
130 return FXSYS_wtoi(wsECLevel->c_str());
134 absl::optional<CXFA_Measurement> moduleWidthHeight =
135 JSObject()->TryMeasure(XFA_Attribute::ModuleWidth,
true);
136 if (!moduleWidthHeight.has_value())
137 return absl::nullopt;
139 return static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt));
143 absl::optional<CXFA_Measurement> moduleWidthHeight =
144 JSObject()->TryMeasure(XFA_Attribute::ModuleHeight,
true);
145 if (!moduleWidthHeight.has_value())
146 return absl::nullopt;
148 return static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt));
152 return JSObject()->TryBoolean(
XFA_Attribute::PrintCheckDigit,
true);
156 return JSObject()->TryEnum(
XFA_Attribute::TextLocation,
true);
160 return JSObject()->TryBoolean(
XFA_Attribute::Truncate,
true);
164 absl::optional<WideString> wsWideNarrowRatio =
165 JSObject()->TryCData(XFA_Attribute::WideNarrowRatio,
true);
166 if (!wsWideNarrowRatio.has_value())
167 return absl::nullopt;
169 absl::optional<size_t> ptPos = wsWideNarrowRatio->Find(
':');
170 if (!ptPos.has_value())
171 return static_cast<int8_t>(FXSYS_wtoi(wsWideNarrowRatio->c_str()));
173 int32_t fB = FXSYS_wtoi(
175 ->Last(wsWideNarrowRatio->GetLength() - (ptPos.value() + 1))
180 int32_t fA = FXSYS_wtoi(wsWideNarrowRatio->First(ptPos.value()).c_str());
181 float result =
static_cast<
float>(fA) /
static_cast<
float>(fB);
182 return static_cast<int8_t>(result);
absl::optional< WideString > GetCharEncoding()
static CXFA_Barcode * FromNode(CXFA_Node *pNode)
absl::optional< bool > GetChecksum()
XFA_FFWidgetType GetDefaultFFWidgetType() const override
absl::optional< XFA_AttributeValue > GetTextLocation()
WideString GetBarcodeType()
absl::optional< int32_t > GetModuleWidth()
absl::optional< int32_t > GetDataLength()
absl::optional< char > GetEndChar()
absl::optional< bool > GetTruncate()
absl::optional< int32_t > GetModuleHeight()
absl::optional< bool > GetPrintChecksum()
absl::optional< int32_t > GetECLevel()
absl::optional< int8_t > GetWideNarrowRatio()
absl::optional< char > GetStartChar()
XFA_Element GetElementType() const