From 6aec70bc09cb65b169fe6ca1af65e8929aeea43a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 23 Nov 2017 17:02:23 +0000 Subject: Cleanup CXFA_WidgetData This CL cleans up return values, out-params and changes simple methods to boolean checks where possible in CXFA_WidgetData. Change-Id: I29daa67993730f3e9d61cb6fdf918a886cc9120e Reviewed-on: https://pdfium-review.googlesource.com/19230 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffbarcode.cpp | 85 +++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 34 deletions(-) (limited to 'xfa/fxfa/cxfa_ffbarcode.cpp') diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp index 726f89176f..29c6d85e89 100644 --- a/xfa/fxfa/cxfa_ffbarcode.cpp +++ b/xfa/fxfa/cxfa_ffbarcode.cpp @@ -129,9 +129,7 @@ bool CXFA_FFBarcode::LoadWidget() { m_pNormalWidget->SetDelegate(this); m_pNormalWidget->LockUpdate(); - WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pFWLBarcode->SetText(wsText); + pFWLBarcode->SetText(m_pDataAcc->GetValue(XFA_VALUEPICTURE_Display)); UpdateWidgetProperty(); m_pNormalWidget->UnlockUpdate(); return CXFA_FFField::LoadWidget(); @@ -168,37 +166,56 @@ void CXFA_FFBarcode::UpdateWidgetProperty() { pBarCodeWidget->SetType(pBarcodeInfo->eBCType); CXFA_WidgetAcc* pAcc = GetDataAcc(); - int32_t intVal; - if (pAcc->GetBarcodeAttribute_CharEncoding(&intVal)) - pBarCodeWidget->SetCharEncoding((BC_CHAR_ENCODING)intVal); - - bool boolVal; - if (pAcc->GetBarcodeAttribute_Checksum(&boolVal)) - pBarCodeWidget->SetCalChecksum(boolVal); - if (pAcc->GetBarcodeAttribute_DataLength(&intVal)) - pBarCodeWidget->SetDataLength(intVal); - - char charVal; - if (pAcc->GetBarcodeAttribute_StartChar(&charVal)) - pBarCodeWidget->SetStartChar(charVal); - if (pAcc->GetBarcodeAttribute_EndChar(&charVal)) - pBarCodeWidget->SetEndChar(charVal); - if (pAcc->GetBarcodeAttribute_ECLevel(&intVal)) - pBarCodeWidget->SetErrorCorrectionLevel(intVal); - if (pAcc->GetBarcodeAttribute_ModuleWidth(&intVal)) - pBarCodeWidget->SetModuleWidth(intVal); - if (pAcc->GetBarcodeAttribute_ModuleHeight(&intVal)) - pBarCodeWidget->SetModuleHeight(intVal); - if (pAcc->GetBarcodeAttribute_PrintChecksum(&boolVal)) - pBarCodeWidget->SetPrintChecksum(boolVal); - if (pAcc->GetBarcodeAttribute_TextLocation(&intVal)) - pBarCodeWidget->SetTextLocation((BC_TEXT_LOC)intVal); - if (pAcc->GetBarcodeAttribute_Truncate(&boolVal)) - pBarCodeWidget->SetTruncated(boolVal); - - float floatVal; - if (pAcc->GetBarcodeAttribute_WideNarrowRatio(&floatVal)) - pBarCodeWidget->SetWideNarrowRatio(static_cast(floatVal)); + pdfium::Optional encoding = + pAcc->GetBarcodeAttribute_CharEncoding(); + if (encoding) + pBarCodeWidget->SetCharEncoding(*encoding); + + pdfium::Optional calcChecksum = pAcc->GetBarcodeAttribute_Checksum(); + if (calcChecksum) + pBarCodeWidget->SetCalChecksum(*calcChecksum); + + pdfium::Optional dataLen = pAcc->GetBarcodeAttribute_DataLength(); + if (dataLen) + pBarCodeWidget->SetDataLength(*dataLen); + + pdfium::Optional startChar = pAcc->GetBarcodeAttribute_StartChar(); + if (startChar) + pBarCodeWidget->SetStartChar(*startChar); + + pdfium::Optional endChar = pAcc->GetBarcodeAttribute_EndChar(); + if (endChar) + pBarCodeWidget->SetEndChar(*endChar); + + pdfium::Optional ecLevel = pAcc->GetBarcodeAttribute_ECLevel(); + if (ecLevel) + pBarCodeWidget->SetErrorCorrectionLevel(*ecLevel); + + pdfium::Optional width = pAcc->GetBarcodeAttribute_ModuleWidth(); + if (width) + pBarCodeWidget->SetModuleWidth(*width); + + pdfium::Optional height = pAcc->GetBarcodeAttribute_ModuleHeight(); + if (height) + pBarCodeWidget->SetModuleHeight(*height); + + pdfium::Optional printCheck = pAcc->GetBarcodeAttribute_PrintChecksum(); + if (printCheck) + pBarCodeWidget->SetPrintChecksum(*printCheck); + + pdfium::Optional textLoc = + pAcc->GetBarcodeAttribute_TextLocation(); + if (textLoc) + pBarCodeWidget->SetTextLocation(*textLoc); + + pdfium::Optional truncate = pAcc->GetBarcodeAttribute_Truncate(); + if (truncate) + pBarCodeWidget->SetTruncated(*truncate); + + pdfium::Optional ratio = pAcc->GetBarcodeAttribute_WideNarrowRatio(); + if (ratio) + pBarCodeWidget->SetWideNarrowRatio(*ratio); + if (pBarcodeInfo->eName == BarcodeType::code3Of9 || pBarcodeInfo->eName == BarcodeType::ean8 || pBarcodeInfo->eName == BarcodeType::ean13 || -- cgit v1.2.3