summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_ffbarcode.cpp
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/cxfa_ffbarcode.cpp
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/cxfa_ffbarcode.cpp')
-rw-r--r--xfa/fxfa/cxfa_ffbarcode.cpp48
1 files changed, 23 insertions, 25 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);
}
}