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"
47 ?
static_cast<CXFA_Barcode*>(pNode)
51CXFA_Barcode::CXFA_Barcode(CXFA_Document* doc,
XFA_PacketType packet)
54 {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
58 kBarcodeAttributeData,
59 cppgc::MakeGarbageCollected<CJX_Node>(
60 doc->GetHeap()->GetAllocationHandle(),
75 JSObject()->TryEnum(XFA_Attribute::Checksum,
true);
76 if (!checksum.has_value())
79 switch (checksum.value()) {
95 JSObject()->TryCData(XFA_Attribute::DataLength,
true);
96 if (!wsDataLength.has_value())
99 return FXSYS_wtoi(wsDataLength->c_str());
104 JSObject()->TryCData(XFA_Attribute::StartChar,
true);
105 if (!wsStartEndChar.has_value() || wsStartEndChar->IsEmpty())
108 return static_cast<
char>(wsStartEndChar.value()[0]);
113 JSObject()->TryCData(XFA_Attribute::EndChar,
true);
114 if (!wsStartEndChar.has_value() || wsStartEndChar->IsEmpty())
117 return static_cast<
char>(wsStartEndChar.value()[0]);
122 JSObject()->TryCData(XFA_Attribute::ErrorCorrectionLevel,
true);
123 if (!wsECLevel.has_value())
125 return FXSYS_wtoi(wsECLevel->c_str());
130 JSObject()->TryMeasure(XFA_Attribute::ModuleWidth,
true);
131 if (!moduleWidthHeight.has_value())
134 return static_cast<int32_t>(moduleWidthHeight->ToUnit(
XFA_Unit::Pt));
139 JSObject()->TryMeasure(XFA_Attribute::ModuleHeight,
true);
140 if (!moduleWidthHeight.has_value())
143 return static_cast<int32_t>(moduleWidthHeight->ToUnit(
XFA_Unit::Pt));
147 return JSObject()->TryBoolean(
XFA_Attribute::PrintCheckDigit,
true);
151 return JSObject()->TryEnum(
XFA_Attribute::TextLocation,
true);
155 return JSObject()->TryBoolean(
XFA_Attribute::Truncate,
true);
160 JSObject()->TryCData(XFA_Attribute::WideNarrowRatio,
true);
161 if (!wsWideNarrowRatio.has_value())
164 std::optional<size_t> ptPos = wsWideNarrowRatio->Find(
':');
165 if (!ptPos.has_value())
166 return static_cast<int8_t>(FXSYS_wtoi(wsWideNarrowRatio->c_str()));
168 int32_t fB = FXSYS_wtoi(
170 ->Last(wsWideNarrowRatio->GetLength() - (ptPos.value() + 1))
175 int32_t fA = FXSYS_wtoi(wsWideNarrowRatio->First(ptPos.value()).c_str());
176 float result =
static_cast<
float>(fA) /
static_cast<
float>(fB);
177 return static_cast<int8_t>(result);
std::optional< int32_t > GetDataLength()
std::optional< int32_t > GetModuleWidth()
std::optional< bool > GetPrintChecksum()
std::optional< bool > GetTruncate()
std::optional< bool > GetChecksum()
static CXFA_Barcode * FromNode(CXFA_Node *pNode)
XFA_FFWidgetType GetDefaultFFWidgetType() const override
WideString GetBarcodeType()
std::optional< char > GetStartChar()
std::optional< int32_t > GetECLevel()
std::optional< int32_t > GetModuleHeight()
std::optional< int8_t > GetWideNarrowRatio()
std::optional< char > GetEndChar()
std::optional< XFA_AttributeValue > GetTextLocation()
XFA_Element GetElementType() const
fxcrt::WideString WideString