summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-09 10:47:23 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-09 17:58:39 +0000
commitef55c79650768a731c22038acd36b2a741706ed6 (patch)
tree496a6f9a063e950006d43d91c774a2e364791a4a /xfa/fxfa
parent95bb9748c9292d282e2425d4500f15f5c48c2b34 (diff)
downloadpdfium-ef55c79650768a731c22038acd36b2a741706ed6.tar.xz
Move barcode code from WidgetAcc to Node
This CL moves the barcode related code from CXFA_WidgetAcc to CXFA_Node. Change-Id: Id3f5f30222535a69a0bf4d59416e57d452c7d8e8 Reviewed-on: https://pdfium-review.googlesource.com/22551 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffbarcode.cpp48
-rw-r--r--xfa/fxfa/cxfa_ffbarcode.h2
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp6
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp145
-rw-r--r--xfa/fxfa/cxfa_widgetacc.h15
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp156
-rw-r--r--xfa/fxfa/parser/cxfa_node.h16
7 files changed, 198 insertions, 190 deletions
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp
index c18344f3d4..005fe402fb 100644
--- a/xfa/fxfa/cxfa_ffbarcode.cpp
+++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -96,16 +96,16 @@ const BarCodeInfo g_BarCodeData[] = {
// static
const BarCodeInfo* CXFA_FFBarcode::GetBarcodeTypeByName(
- const WideStringView& wsName) {
+ const WideString& wsName) {
if (wsName.IsEmpty())
return nullptr;
auto* it = std::lower_bound(
std::begin(g_BarCodeData), std::end(g_BarCodeData),
- FX_HashCode_GetW(wsName, true),
+ FX_HashCode_GetW(wsName.AsStringView(), true),
[](const BarCodeInfo& arg, uint32_t hash) { return arg.uHash < hash; });
- if (it != std::end(g_BarCodeData) && wsName == it->pName)
+ if (it != std::end(g_BarCodeData) && wsName.AsStringView() == it->pName)
return it;
return nullptr;
@@ -158,68 +158,66 @@ void CXFA_FFBarcode::RenderWidget(CXFA_Graphics* pGS,
void CXFA_FFBarcode::UpdateWidgetProperty() {
CXFA_FFTextEdit::UpdateWidgetProperty();
- auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get());
- WideString wsType = GetNode()->GetWidgetAcc()->GetBarcodeType();
- const BarCodeInfo* pBarcodeInfo = GetBarcodeTypeByName(wsType.AsStringView());
- if (!pBarcodeInfo)
+ auto* node = GetNode()->GetWidgetAcc()->GetNode();
+ const BarCodeInfo* info = GetBarcodeTypeByName(node->GetBarcodeType());
+ if (!info)
return;
- pBarCodeWidget->SetType(pBarcodeInfo->eBCType);
+ auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get());
+ pBarCodeWidget->SetType(info->eBCType);
- CXFA_WidgetAcc* pAcc = GetNode()->GetWidgetAcc();
Optional<BC_CHAR_ENCODING> encoding =
- pAcc->GetBarcodeAttribute_CharEncoding();
+ node->GetBarcodeAttribute_CharEncoding();
if (encoding)
pBarCodeWidget->SetCharEncoding(*encoding);
- Optional<bool> calcChecksum = pAcc->GetBarcodeAttribute_Checksum();
+ Optional<bool> calcChecksum = node->GetBarcodeAttribute_Checksum();
if (calcChecksum)
pBarCodeWidget->SetCalChecksum(*calcChecksum);
- Optional<int32_t> dataLen = pAcc->GetBarcodeAttribute_DataLength();
+ Optional<int32_t> dataLen = node->GetBarcodeAttribute_DataLength();
if (dataLen)
pBarCodeWidget->SetDataLength(*dataLen);
- Optional<char> startChar = pAcc->GetBarcodeAttribute_StartChar();
+ Optional<char> startChar = node->GetBarcodeAttribute_StartChar();
if (startChar)
pBarCodeWidget->SetStartChar(*startChar);
- Optional<char> endChar = pAcc->GetBarcodeAttribute_EndChar();
+ Optional<char> endChar = node->GetBarcodeAttribute_EndChar();
if (endChar)
pBarCodeWidget->SetEndChar(*endChar);
- Optional<int32_t> ecLevel = pAcc->GetBarcodeAttribute_ECLevel();
+ Optional<int32_t> ecLevel = node->GetBarcodeAttribute_ECLevel();
if (ecLevel)
pBarCodeWidget->SetErrorCorrectionLevel(*ecLevel);
- Optional<int32_t> width = pAcc->GetBarcodeAttribute_ModuleWidth();
+ Optional<int32_t> width = node->GetBarcodeAttribute_ModuleWidth();
if (width)
pBarCodeWidget->SetModuleWidth(*width);
- Optional<int32_t> height = pAcc->GetBarcodeAttribute_ModuleHeight();
+ Optional<int32_t> height = node->GetBarcodeAttribute_ModuleHeight();
if (height)
pBarCodeWidget->SetModuleHeight(*height);
- Optional<bool> printCheck = pAcc->GetBarcodeAttribute_PrintChecksum();
+ Optional<bool> printCheck = node->GetBarcodeAttribute_PrintChecksum();
if (printCheck)
pBarCodeWidget->SetPrintChecksum(*printCheck);
- Optional<BC_TEXT_LOC> textLoc = pAcc->GetBarcodeAttribute_TextLocation();
+ Optional<BC_TEXT_LOC> textLoc = node->GetBarcodeAttribute_TextLocation();
if (textLoc)
pBarCodeWidget->SetTextLocation(*textLoc);
- Optional<bool> truncate = pAcc->GetBarcodeAttribute_Truncate();
+ Optional<bool> truncate = node->GetBarcodeAttribute_Truncate();
if (truncate)
pBarCodeWidget->SetTruncated(*truncate);
- Optional<int8_t> ratio = pAcc->GetBarcodeAttribute_WideNarrowRatio();
+ Optional<int8_t> ratio = node->GetBarcodeAttribute_WideNarrowRatio();
if (ratio)
pBarCodeWidget->SetWideNarrowRatio(*ratio);
- if (pBarcodeInfo->eName == BarcodeType::code3Of9 ||
- pBarcodeInfo->eName == BarcodeType::ean8 ||
- pBarcodeInfo->eName == BarcodeType::ean13 ||
- pBarcodeInfo->eName == BarcodeType::upcA) {
+ if (info->eName == BarcodeType::code3Of9 ||
+ info->eName == BarcodeType::ean8 || info->eName == BarcodeType::ean13 ||
+ info->eName == BarcodeType::upcA) {
pBarCodeWidget->SetPrintChecksum(true);
}
}
diff --git a/xfa/fxfa/cxfa_ffbarcode.h b/xfa/fxfa/cxfa_ffbarcode.h
index 85140a10bf..93984700da 100644
--- a/xfa/fxfa/cxfa_ffbarcode.h
+++ b/xfa/fxfa/cxfa_ffbarcode.h
@@ -85,7 +85,7 @@ struct BarCodeInfo {
class CXFA_FFBarcode : public CXFA_FFTextEdit {
public:
- static const BarCodeInfo* GetBarcodeTypeByName(const WideStringView& wsName);
+ static const BarCodeInfo* GetBarcodeTypeByName(const WideString& wsName);
explicit CXFA_FFBarcode(CXFA_Node* pNode);
~CXFA_FFBarcode() override;
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 8f84b185ca..706a9a84cf 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -273,10 +273,8 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
}
} else if (m_pNode->GetWidgetAcc()->GetUIType() == XFA_Element::Barcode) {
int32_t nDataLen = 0;
- if (eType == XFA_VALUEPICTURE_Edit) {
- nDataLen =
- m_pNode->GetWidgetAcc()->GetBarcodeAttribute_DataLength().value_or(0);
- }
+ if (eType == XFA_VALUEPICTURE_Edit)
+ nDataLen = m_pNode->GetBarcodeAttribute_DataLength().value_or(0);
pEdit->SetLimit(nDataLen);
bUpdate = true;
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 870dc53ff9..0531c0fcb0 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -2124,151 +2124,6 @@ Optional<int32_t> CXFA_WidgetAcc::GetNumberOfCells() {
return {};
}
-WideString CXFA_WidgetAcc::GetBarcodeType() {
- CXFA_Node* pUIChild = GetUIChild();
- return pUIChild
- ? WideString(pUIChild->JSObject()->GetCData(XFA_Attribute::Type))
- : WideString();
-}
-
-Optional<BC_CHAR_ENCODING> CXFA_WidgetAcc::GetBarcodeAttribute_CharEncoding() {
- Optional<WideString> wsCharEncoding =
- GetUIChild()->JSObject()->TryCData(XFA_Attribute::CharEncoding, true);
- if (!wsCharEncoding)
- return {};
- if (wsCharEncoding->CompareNoCase(L"UTF-16"))
- return {CHAR_ENCODING_UNICODE};
- if (wsCharEncoding->CompareNoCase(L"UTF-8"))
- return {CHAR_ENCODING_UTF8};
- return {};
-}
-
-Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_Checksum() {
- Optional<XFA_AttributeEnum> checksum =
- GetUIChild()->JSObject()->TryEnum(XFA_Attribute::Checksum, true);
- if (!checksum)
- return {};
-
- switch (*checksum) {
- case XFA_AttributeEnum::None:
- return {false};
- case XFA_AttributeEnum::Auto:
- return {true};
- case XFA_AttributeEnum::Checksum_1mod10:
- case XFA_AttributeEnum::Checksum_1mod10_1mod11:
- case XFA_AttributeEnum::Checksum_2mod10:
- default:
- break;
- }
- return {};
-}
-
-Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_DataLength() {
- Optional<WideString> wsDataLength =
- GetUIChild()->JSObject()->TryCData(XFA_Attribute::DataLength, true);
- if (!wsDataLength)
- return {};
-
- return {FXSYS_wtoi(wsDataLength->c_str())};
-}
-
-Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_StartChar() {
- Optional<WideString> wsStartEndChar =
- GetUIChild()->JSObject()->TryCData(XFA_Attribute::StartChar, true);
- if (!wsStartEndChar || wsStartEndChar->IsEmpty())
- return {};
-
- return {static_cast<char>((*wsStartEndChar)[0])};
-}
-
-Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_EndChar() {
- Optional<WideString> wsStartEndChar =
- GetUIChild()->JSObject()->TryCData(XFA_Attribute::EndChar, true);
- if (!wsStartEndChar || wsStartEndChar->IsEmpty())
- return {};
-
- return {static_cast<char>((*wsStartEndChar)[0])};
-}
-
-Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ECLevel() {
- Optional<WideString> wsECLevel = GetUIChild()->JSObject()->TryCData(
- XFA_Attribute::ErrorCorrectionLevel, true);
- if (!wsECLevel)
- return {};
- return {FXSYS_wtoi(wsECLevel->c_str())};
-}
-
-Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleWidth() {
- Optional<CXFA_Measurement> moduleWidthHeight =
- GetUIChild()->JSObject()->TryMeasure(XFA_Attribute::ModuleWidth, true);
- if (!moduleWidthHeight)
- return {};
-
- return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))};
-}
-
-Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleHeight() {
- Optional<CXFA_Measurement> moduleWidthHeight =
- GetUIChild()->JSObject()->TryMeasure(XFA_Attribute::ModuleHeight, true);
- if (!moduleWidthHeight)
- return {};
-
- return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))};
-}
-
-Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_PrintChecksum() {
- return GetUIChild()->JSObject()->TryBoolean(XFA_Attribute::PrintCheckDigit,
- true);
-}
-
-Optional<BC_TEXT_LOC> CXFA_WidgetAcc::GetBarcodeAttribute_TextLocation() {
- Optional<XFA_AttributeEnum> textLocation =
- GetUIChild()->JSObject()->TryEnum(XFA_Attribute::TextLocation, true);
- if (!textLocation)
- return {};
-
- switch (*textLocation) {
- case XFA_AttributeEnum::None:
- return {BC_TEXT_LOC_NONE};
- case XFA_AttributeEnum::Above:
- return {BC_TEXT_LOC_ABOVE};
- case XFA_AttributeEnum::Below:
- return {BC_TEXT_LOC_BELOW};
- case XFA_AttributeEnum::AboveEmbedded:
- return {BC_TEXT_LOC_ABOVEEMBED};
- case XFA_AttributeEnum::BelowEmbedded:
- return {BC_TEXT_LOC_BELOWEMBED};
- default:
- break;
- }
- return {};
-}
-
-Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_Truncate() {
- return GetUIChild()->JSObject()->TryBoolean(XFA_Attribute::Truncate, true);
-}
-
-Optional<int8_t> CXFA_WidgetAcc::GetBarcodeAttribute_WideNarrowRatio() {
- Optional<WideString> wsWideNarrowRatio =
- GetUIChild()->JSObject()->TryCData(XFA_Attribute::WideNarrowRatio, true);
- if (!wsWideNarrowRatio)
- return {};
-
- Optional<size_t> ptPos = wsWideNarrowRatio->Find(':');
- if (!ptPos)
- return {static_cast<int8_t>(FXSYS_wtoi(wsWideNarrowRatio->c_str()))};
-
- int32_t fB = FXSYS_wtoi(
- wsWideNarrowRatio->Right(wsWideNarrowRatio->GetLength() - (*ptPos + 1))
- .c_str());
- if (!fB)
- return {0};
-
- int32_t fA = FXSYS_wtoi(wsWideNarrowRatio->Left(*ptPos).c_str());
- float result = static_cast<float>(fA) / static_cast<float>(fB);
- return {static_cast<int8_t>(result)};
-}
-
WideString CXFA_WidgetAcc::GetPasswordChar() {
CXFA_Node* pUIChild = GetUIChild();
return pUIChild ? pUIChild->JSObject()->GetCData(XFA_Attribute::PasswordChar)
diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h
index 6031d9be26..f21ace9d95 100644
--- a/xfa/fxfa/cxfa_widgetacc.h
+++ b/xfa/fxfa/cxfa_widgetacc.h
@@ -17,7 +17,6 @@
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
-#include "fxbarcode/BC_Library.h"
#include "xfa/fxfa/fxfa_basic.h"
enum XFA_CHECKSTATE {
@@ -174,20 +173,6 @@ class CXFA_WidgetAcc {
WideString GetFormatDataValue(const WideString& wsValue);
WideString NormalizeNumStr(const WideString& wsValue);
- WideString GetBarcodeType();
- Optional<BC_CHAR_ENCODING> GetBarcodeAttribute_CharEncoding();
- Optional<bool> GetBarcodeAttribute_Checksum();
- Optional<int32_t> GetBarcodeAttribute_DataLength();
- Optional<char> GetBarcodeAttribute_StartChar();
- Optional<char> GetBarcodeAttribute_EndChar();
- Optional<int32_t> GetBarcodeAttribute_ECLevel();
- Optional<int32_t> GetBarcodeAttribute_ModuleWidth();
- Optional<int32_t> GetBarcodeAttribute_ModuleHeight();
- Optional<bool> GetBarcodeAttribute_PrintChecksum();
- Optional<BC_TEXT_LOC> GetBarcodeAttribute_TextLocation();
- Optional<bool> GetBarcodeAttribute_Truncate();
- Optional<int8_t> GetBarcodeAttribute_WideNarrowRatio();
-
WideString GetPasswordChar();
std::pair<XFA_Element, int32_t> GetMaxChars();
int32_t GetFracDigits();
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 8c8f0c69f2..1da6f56781 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2054,3 +2054,159 @@ std::pair<int32_t, bool> CXFA_Node::ExecuteBoolScript(
return {iRet, pTmpRetValue->IsBoolean() ? pTmpRetValue->ToBoolean() : false};
}
+
+WideString CXFA_Node::GetBarcodeType() {
+ CXFA_Node* pUIChild = GetWidgetAcc()->GetUIChild();
+ return pUIChild
+ ? WideString(pUIChild->JSObject()->GetCData(XFA_Attribute::Type))
+ : WideString();
+}
+
+Optional<BC_CHAR_ENCODING> CXFA_Node::GetBarcodeAttribute_CharEncoding() {
+ Optional<WideString> wsCharEncoding =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
+ XFA_Attribute::CharEncoding, true);
+ if (!wsCharEncoding)
+ return {};
+ if (wsCharEncoding->CompareNoCase(L"UTF-16"))
+ return {CHAR_ENCODING_UNICODE};
+ if (wsCharEncoding->CompareNoCase(L"UTF-8"))
+ return {CHAR_ENCODING_UTF8};
+ return {};
+}
+
+Optional<bool> CXFA_Node::GetBarcodeAttribute_Checksum() {
+ Optional<XFA_AttributeEnum> checksum =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryEnum(XFA_Attribute::Checksum,
+ true);
+ if (!checksum)
+ return {};
+
+ switch (*checksum) {
+ case XFA_AttributeEnum::None:
+ return {false};
+ case XFA_AttributeEnum::Auto:
+ return {true};
+ case XFA_AttributeEnum::Checksum_1mod10:
+ case XFA_AttributeEnum::Checksum_1mod10_1mod11:
+ case XFA_AttributeEnum::Checksum_2mod10:
+ default:
+ break;
+ }
+ return {};
+}
+
+Optional<int32_t> CXFA_Node::GetBarcodeAttribute_DataLength() {
+ Optional<WideString> wsDataLength =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
+ XFA_Attribute::DataLength, true);
+ if (!wsDataLength)
+ return {};
+
+ return {FXSYS_wtoi(wsDataLength->c_str())};
+}
+
+Optional<char> CXFA_Node::GetBarcodeAttribute_StartChar() {
+ Optional<WideString> wsStartEndChar =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
+ XFA_Attribute::StartChar, true);
+ if (!wsStartEndChar || wsStartEndChar->IsEmpty())
+ return {};
+
+ return {static_cast<char>((*wsStartEndChar)[0])};
+}
+
+Optional<char> CXFA_Node::GetBarcodeAttribute_EndChar() {
+ Optional<WideString> wsStartEndChar =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(XFA_Attribute::EndChar,
+ true);
+ if (!wsStartEndChar || wsStartEndChar->IsEmpty())
+ return {};
+
+ return {static_cast<char>((*wsStartEndChar)[0])};
+}
+
+Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ECLevel() {
+ Optional<WideString> wsECLevel =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
+ XFA_Attribute::ErrorCorrectionLevel, true);
+ if (!wsECLevel)
+ return {};
+ return {FXSYS_wtoi(wsECLevel->c_str())};
+}
+
+Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleWidth() {
+ Optional<CXFA_Measurement> moduleWidthHeight =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryMeasure(
+ XFA_Attribute::ModuleWidth, true);
+ if (!moduleWidthHeight)
+ return {};
+
+ return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))};
+}
+
+Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleHeight() {
+ Optional<CXFA_Measurement> moduleWidthHeight =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryMeasure(
+ XFA_Attribute::ModuleHeight, true);
+ if (!moduleWidthHeight)
+ return {};
+
+ return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))};
+}
+
+Optional<bool> CXFA_Node::GetBarcodeAttribute_PrintChecksum() {
+ return GetWidgetAcc()->GetUIChild()->JSObject()->TryBoolean(
+ XFA_Attribute::PrintCheckDigit, true);
+}
+
+Optional<BC_TEXT_LOC> CXFA_Node::GetBarcodeAttribute_TextLocation() {
+ Optional<XFA_AttributeEnum> textLocation =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryEnum(
+ XFA_Attribute::TextLocation, true);
+ if (!textLocation)
+ return {};
+
+ switch (*textLocation) {
+ case XFA_AttributeEnum::None:
+ return {BC_TEXT_LOC_NONE};
+ case XFA_AttributeEnum::Above:
+ return {BC_TEXT_LOC_ABOVE};
+ case XFA_AttributeEnum::Below:
+ return {BC_TEXT_LOC_BELOW};
+ case XFA_AttributeEnum::AboveEmbedded:
+ return {BC_TEXT_LOC_ABOVEEMBED};
+ case XFA_AttributeEnum::BelowEmbedded:
+ return {BC_TEXT_LOC_BELOWEMBED};
+ default:
+ break;
+ }
+ return {};
+}
+
+Optional<bool> CXFA_Node::GetBarcodeAttribute_Truncate() {
+ return GetWidgetAcc()->GetUIChild()->JSObject()->TryBoolean(
+ XFA_Attribute::Truncate, true);
+}
+
+Optional<int8_t> CXFA_Node::GetBarcodeAttribute_WideNarrowRatio() {
+ Optional<WideString> wsWideNarrowRatio =
+ GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
+ XFA_Attribute::WideNarrowRatio, true);
+ if (!wsWideNarrowRatio)
+ return {};
+
+ Optional<size_t> ptPos = wsWideNarrowRatio->Find(':');
+ if (!ptPos)
+ return {static_cast<int8_t>(FXSYS_wtoi(wsWideNarrowRatio->c_str()))};
+
+ int32_t fB = FXSYS_wtoi(
+ wsWideNarrowRatio->Right(wsWideNarrowRatio->GetLength() - (*ptPos + 1))
+ .c_str());
+ if (!fB)
+ return {0};
+
+ int32_t fA = FXSYS_wtoi(wsWideNarrowRatio->Left(*ptPos).c_str());
+ float result = static_cast<float>(fA) / static_cast<float>(fB);
+ return {static_cast<int8_t>(result)};
+}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 7bf0654b58..1f11a2372f 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -15,6 +15,7 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/ifx_locale.h"
#include "core/fxge/fx_dib.h"
+#include "fxbarcode/BC_Library.h"
#include "fxjs/xfa/cjx_node.h"
#include "third_party/base/optional.h"
#include "xfa/fxfa/parser/cxfa_object.h"
@@ -279,6 +280,21 @@ class CXFA_Node : public CXFA_Object {
CXFA_Script* script,
CXFA_EventParam* pEventParam);
+ // TODO(dsinclair): Figure out how to move this to cxfa_barcode.
+ WideString GetBarcodeType();
+ Optional<BC_CHAR_ENCODING> GetBarcodeAttribute_CharEncoding();
+ Optional<bool> GetBarcodeAttribute_Checksum();
+ Optional<int32_t> GetBarcodeAttribute_DataLength();
+ Optional<char> GetBarcodeAttribute_StartChar();
+ Optional<char> GetBarcodeAttribute_EndChar();
+ Optional<int32_t> GetBarcodeAttribute_ECLevel();
+ Optional<int32_t> GetBarcodeAttribute_ModuleWidth();
+ Optional<int32_t> GetBarcodeAttribute_ModuleHeight();
+ Optional<bool> GetBarcodeAttribute_PrintChecksum();
+ Optional<BC_TEXT_LOC> GetBarcodeAttribute_TextLocation();
+ Optional<bool> GetBarcodeAttribute_Truncate();
+ Optional<int8_t> GetBarcodeAttribute_WideNarrowRatio();
+
protected:
CXFA_Node(CXFA_Document* pDoc,
XFA_PacketType ePacket,