From ef55c79650768a731c22038acd36b2a741706ed6 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 9 Jan 2018 10:47:23 -0500 Subject: 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 Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffbarcode.cpp | 48 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'xfa/fxfa/cxfa_ffbarcode.cpp') 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(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(m_pNormalWidget.get()); + pBarCodeWidget->SetType(info->eBCType); - CXFA_WidgetAcc* pAcc = GetNode()->GetWidgetAcc(); Optional encoding = - pAcc->GetBarcodeAttribute_CharEncoding(); + node->GetBarcodeAttribute_CharEncoding(); if (encoding) pBarCodeWidget->SetCharEncoding(*encoding); - Optional calcChecksum = pAcc->GetBarcodeAttribute_Checksum(); + Optional calcChecksum = node->GetBarcodeAttribute_Checksum(); if (calcChecksum) pBarCodeWidget->SetCalChecksum(*calcChecksum); - Optional dataLen = pAcc->GetBarcodeAttribute_DataLength(); + Optional dataLen = node->GetBarcodeAttribute_DataLength(); if (dataLen) pBarCodeWidget->SetDataLength(*dataLen); - Optional startChar = pAcc->GetBarcodeAttribute_StartChar(); + Optional startChar = node->GetBarcodeAttribute_StartChar(); if (startChar) pBarCodeWidget->SetStartChar(*startChar); - Optional endChar = pAcc->GetBarcodeAttribute_EndChar(); + Optional endChar = node->GetBarcodeAttribute_EndChar(); if (endChar) pBarCodeWidget->SetEndChar(*endChar); - Optional ecLevel = pAcc->GetBarcodeAttribute_ECLevel(); + Optional ecLevel = node->GetBarcodeAttribute_ECLevel(); if (ecLevel) pBarCodeWidget->SetErrorCorrectionLevel(*ecLevel); - Optional width = pAcc->GetBarcodeAttribute_ModuleWidth(); + Optional width = node->GetBarcodeAttribute_ModuleWidth(); if (width) pBarCodeWidget->SetModuleWidth(*width); - Optional height = pAcc->GetBarcodeAttribute_ModuleHeight(); + Optional height = node->GetBarcodeAttribute_ModuleHeight(); if (height) pBarCodeWidget->SetModuleHeight(*height); - Optional printCheck = pAcc->GetBarcodeAttribute_PrintChecksum(); + Optional printCheck = node->GetBarcodeAttribute_PrintChecksum(); if (printCheck) pBarCodeWidget->SetPrintChecksum(*printCheck); - Optional textLoc = pAcc->GetBarcodeAttribute_TextLocation(); + Optional textLoc = node->GetBarcodeAttribute_TextLocation(); if (textLoc) pBarCodeWidget->SetTextLocation(*textLoc); - Optional truncate = pAcc->GetBarcodeAttribute_Truncate(); + Optional truncate = node->GetBarcodeAttribute_Truncate(); if (truncate) pBarCodeWidget->SetTruncated(*truncate); - Optional ratio = pAcc->GetBarcodeAttribute_WideNarrowRatio(); + Optional 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); } } -- cgit v1.2.3