CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations(
    CBC_ReedSolomonGF256Poly* errorLocator,
    int32_t& e) {
  int32_t numErrors = errorLocator->GetDegree();
  if (numErrors == 1) {
    CBC_AutoPtr<CFX_Int32Array> temp(new CFX_Int32Array);
    temp->Add(errorLocator->GetCoefficients(1));
    return temp.release();
  }
  CFX_Int32Array* tempT = new CFX_Int32Array;
  tempT->SetSize(numErrors);
  CBC_AutoPtr<CFX_Int32Array> result(tempT);
  int32_t ie = 0;
  for (int32_t i = 1; i < 256 && ie < numErrors; i++) {
    if (errorLocator->EvaluateAt(i) == 0) {
      (*result)[ie] = m_field->Inverse(i, ie);
      BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
      ie++;
    }
  }
  if (ie != numErrors) {
    e = BCExceptionDegreeNotMatchRoots;
    BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
  }
  return result.release();
}
Exemplo n.º 2
0
FX_BOOL CXFA_FFListBox::LoadWidget() {
  CFWL_ListBox* pListBox = CFWL_ListBox::Create();
  pListBox->Initialize();
  pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground,
                         0xFFFFFFFF);
  m_pNormalWidget = (CFWL_Widget*)pListBox;
  IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
  m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
  pNoteDriver->RegisterEventTarget(pWidget, pWidget);
  m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
  m_pNormalWidget->LockUpdate();
  CFX_WideStringArray wsLabelArray;
  m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE);
  int32_t iItems = wsLabelArray.GetSize();
  for (int32_t i = 0; i < iItems; i++) {
    pListBox->AddString(wsLabelArray[i]);
  }
  FX_DWORD dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus;
  if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
    dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection;
  }
  dwExtendedStyle |= GetAlignment();
  m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF);
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  for (int32_t j = 0; j < iSelCount; j++) {
    FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]);
    pListBox->SetSelItem(item, TRUE);
  }
  m_pNormalWidget->UnlockUpdate();
  return CXFA_FFField::LoadWidget();
}
Exemplo n.º 3
0
bool CXFA_FFComboBox::LoadWidget() {
  CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp());
  pComboBox->Initialize();
  m_pNormalWidget = (CFWL_Widget*)pComboBox;
  m_pNormalWidget->SetLayoutItem(this);

  IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
  CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
  pNoteDriver->RegisterEventTarget(pWidget, pWidget);

  m_pOldDelegate = m_pNormalWidget->GetDelegate();
  m_pNormalWidget->SetDelegate(this);
  m_pNormalWidget->LockUpdate();

  CFX_WideStringArray wsLabelArray;
  m_pDataAcc->GetChoiceListItems(wsLabelArray, false);
  int32_t iItems = wsLabelArray.GetSize();
  for (int32_t i = 0; i < iItems; i++) {
    pComboBox->AddString(wsLabelArray[i].AsStringC());
  }
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  if (iSelCount > 0) {
    pComboBox->SetCurSel(iSelArray[0]);
  } else {
    CFX_WideString wsText;
    m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw);
    pComboBox->SetEditText(wsText);
  }
  UpdateWidgetProperty();
  m_pNormalWidget->UnlockUpdate();
  return CXFA_FFField::LoadWidget();
}
CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
    CBC_ReedSolomonGF256Poly* errorEvaluator,
    CFX_Int32Array* errorLocations,
    FX_BOOL dataMatrix,
    int32_t& e) {
  int32_t s = errorLocations->GetSize();
  CFX_Int32Array* temp = new CFX_Int32Array;
  temp->SetSize(s);
  CBC_AutoPtr<CFX_Int32Array> result(temp);
  for (int32_t i = 0; i < s; i++) {
    int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e);
    BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
    int32_t denominator = 1;
    for (int32_t j = 0; j < s; j++) {
      if (i != j) {
        denominator = m_field->Multiply(
            denominator, CBC_ReedSolomonGF256::AddOrSubtract(
                             1, m_field->Multiply(errorLocations->operator[](j),
                                                  xiInverse)));
      }
    }
    int32_t temp = m_field->Inverse(denominator, temp);
    BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
    (*result)[i] =
        m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp);
  }
  return result.release();
}
Exemplo n.º 5
0
int32_t CBC_PDF417Common::getBitCountSum(CFX_Int32Array& moduleBitCount) {
  int32_t bitCountSum = 0;
  for (int32_t i = 0; i < moduleBitCount.GetSize(); i++) {
    int32_t count = moduleBitCount.GetAt(i);
    bitCountSum += count;
  }
  return bitCountSum;
}
Exemplo n.º 6
0
CFX_Int32Array* CBC_Detector::findGuardPattern(CBC_CommonBitMatrix* matrix,
                                               int32_t column,
                                               int32_t row,
                                               int32_t width,
                                               FX_BOOL whiteFirst,
                                               int32_t* pattern,
                                               int32_t patternLength,
                                               CFX_Int32Array& counters) {
  for (int32_t i = 0; i < counters.GetSize(); i++) {
    counters.SetAt(i, 0);
  }
  FX_BOOL isWhite = whiteFirst;
  int32_t patternStart = column;
  int32_t pixelDrift = 0;
  CFX_Int32Array* intarray = new CFX_Int32Array;
  while (matrix->Get(patternStart, row) && patternStart > 0 &&
         pixelDrift++ < MAX_PIXEL_DRIFT) {
    patternStart--;
  }
  int32_t x = patternStart;
  int32_t counterPosition = 0;
  for (; x < width; x++) {
    FX_BOOL pixel = matrix->Get(x, row);
    if (pixel ^ isWhite) {
      counters[counterPosition]++;
    } else {
      if (counterPosition == patternLength - 1) {
        if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) <
            MAX_AVG_VARIANCE) {
          intarray->Add(patternStart);
          intarray->Add(x);
          return intarray;
        }
        patternStart += counters[0] + counters[1];
        for (int32_t l = 2, k = 0; l < patternLength; l++, k++) {
          counters.SetAt(k, counters.GetAt(l));
        }
        counters.SetAt(patternLength - 2, 0);
        counters.SetAt(patternLength - 1, 0);
        counterPosition--;
      } else {
        counterPosition++;
      }
      counters[counterPosition] = 1;
      isWhite = !isWhite;
    }
  }
  if (counterPosition == patternLength - 1) {
    if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) <
        MAX_AVG_VARIANCE) {
      intarray->Add(patternStart);
      intarray->Add(x - 1);
      return intarray;
    }
  }
  delete intarray;
  return NULL;
}
Exemplo n.º 7
0
int32_t CBC_PDF417CodewordDecoder::getBitValue(CFX_Int32Array& moduleBitCount) {
  int64_t result = 0;
  for (int32_t i = 0; i < moduleBitCount.GetSize(); i++) {
    for (int32_t bit = 0; bit < moduleBitCount.GetAt(i); bit++) {
      result = (result << 1) | (i % 2 == 0 ? 1 : 0);
    }
  }
  return (int32_t)result;
}
Exemplo n.º 8
0
bool CXFA_FFListBox::CommitData() {
  CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget);
  int32_t iSels = pListBox->CountSelItems();
  CFX_Int32Array iSelArray;
  for (int32_t i = 0; i < iSels; ++i)
    iSelArray.Add(pListBox->GetSelIndex(i));
  m_pDataAcc->SetSelectedItems(iSelArray, true, false, true);
  return true;
}
int32_t CBC_DecodedBitStreamPaser::textCompaction(CFX_Int32Array& codewords,
                                                  int32_t codeIndex,
                                                  CFX_ByteString& result) {
  CFX_Int32Array textCompactionData;
  textCompactionData.SetSize((codewords[0] - codeIndex) << 1);
  CFX_Int32Array byteCompactionData;
  byteCompactionData.SetSize((codewords[0] - codeIndex) << 1);
  int32_t index = 0;
  FX_BOOL end = FALSE;
  while ((codeIndex < codewords[0]) && !end) {
    int32_t code = codewords[codeIndex++];
    if (code < TEXT_COMPACTION_MODE_LATCH) {
      textCompactionData[index] = code / 30;
      textCompactionData[index + 1] = code % 30;
      index += 2;
    } else {
      switch (code) {
        case TEXT_COMPACTION_MODE_LATCH:
          textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH;
          break;
        case BYTE_COMPACTION_MODE_LATCH:
          codeIndex--;
          end = TRUE;
          break;
        case NUMERIC_COMPACTION_MODE_LATCH:
          codeIndex--;
          end = TRUE;
          break;
        case BEGIN_MACRO_PDF417_CONTROL_BLOCK:
          codeIndex--;
          end = TRUE;
          break;
        case BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
          codeIndex--;
          end = TRUE;
          break;
        case MACRO_PDF417_TERMINATOR:
          codeIndex--;
          end = TRUE;
          break;
        case MODE_SHIFT_TO_BYTE_COMPACTION_MODE:
          textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE;
          code = codewords[codeIndex++];
          byteCompactionData[index] = code;
          index++;
          break;
        case BYTE_COMPACTION_MODE_LATCH_6:
          codeIndex--;
          end = TRUE;
          break;
      }
    }
  }
  decodeTextCompaction(textCompactionData, byteCompactionData, index, result);
  return codeIndex;
}
Exemplo n.º 10
0
FX_BOOL CXFA_FFListBox::CommitData() {
  CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget);
  int32_t iSels = pListBox->CountSelItems();
  CFX_Int32Array iSelArray;
  for (int32_t i = 0; i < iSels; i++) {
    iSelArray.Add(pListBox->GetSelIndex(i));
  }
  m_pDataAcc->SetSelectdItems(iSelArray, TRUE);
  return TRUE;
}
Exemplo n.º 11
0
int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_PopStack(
    CFX_Int32Array& stack) {
  int32_t nType = -1;
  int32_t iSize = stack.GetSize() - 1;
  if (iSize > -1) {
    nType = stack[iSize];
    stack.RemoveAt(iSize, 1);
  }
  return nType;
}
CBC_CommonDecoderResult* CBC_DataMatrixDecodedBitStreamParser::Decode(
    CFX_ByteArray& bytes,
    int32_t& e) {
  CBC_CommonBitSource bits(&bytes);
  CFX_ByteString result;
  CFX_ByteString resultTrailer;
  CFX_Int32Array byteSegments;
  int32_t mode = ASCII_ENCODE;
  do {
    if (mode == 1) {
      mode = DecodeAsciiSegment(&bits, result, resultTrailer, e);
      BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
    } else {
      switch (mode) {
        case 2:
          DecodeC40Segment(&bits, result, e);
          BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
          break;
        case 3:
          DecodeTextSegment(&bits, result, e);
          BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
          break;
        case 4:
          DecodeAnsiX12Segment(&bits, result, e);
          BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
          break;
        case 5:
          DecodeEdifactSegment(&bits, result, e);
          BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
          break;
        case 6:
          DecodeBase256Segment(&bits, result, byteSegments, e);
          BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
          break;
        default:
          NULL;
          e = BCExceptionFormatException;
          return NULL;
      }
      mode = ASCII_ENCODE;
    }
  } while (mode != PAD_ENCODE && bits.Available() > 0);
  if (resultTrailer.GetLength() > 0) {
    result += resultTrailer;
  }
  CBC_CommonDecoderResult* tempCp = new CBC_CommonDecoderResult();
  tempCp->Init(bytes, result,
               (byteSegments.GetSize() <= 0) ? CFX_Int32Array() : byteSegments,
               NULL, e);
  BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
  return tempCp;
}
Exemplo n.º 13
0
void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
                                    int32_t twoS,
                                    int32_t& e) {
  CBC_ReedSolomonGF256Poly poly;
  poly.Init(m_field, received, e);
  BC_EXCEPTION_CHECK_ReturnVoid(e);
  CFX_Int32Array syndromeCoefficients;
  syndromeCoefficients.SetSize(twoS);
  FX_BOOL dataMatrix = FALSE;
  FX_BOOL noError = TRUE;
  for (int32_t i = 0; i < twoS; i++) {
    int32_t eval = poly.EvaluateAt(m_field->Exp(dataMatrix ? i + 1 : i));
    syndromeCoefficients[twoS - 1 - i] = eval;
    if (eval != 0) {
      noError = FALSE;
    }
  }
  if (noError) {
    return;
  }
  CBC_ReedSolomonGF256Poly syndrome;
  syndrome.Init(m_field, &syndromeCoefficients, e);
  BC_EXCEPTION_CHECK_ReturnVoid(e);
  CBC_ReedSolomonGF256Poly* rsg = m_field->BuildMonomial(twoS, 1, e);
  BC_EXCEPTION_CHECK_ReturnVoid(e);
  CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg);
  CFX_PtrArray* pa = RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e);
  BC_EXCEPTION_CHECK_ReturnVoid(e);
  CBC_AutoPtr<CFX_PtrArray> sigmaOmega(pa);
  CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(
      (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]);
  CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(
      (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]);
  CFX_Int32Array* ia1 = FindErrorLocations(sigma.get(), e);
  BC_EXCEPTION_CHECK_ReturnVoid(e);
  CBC_AutoPtr<CFX_Int32Array> errorLocations(ia1);
  CFX_Int32Array* ia2 =
      FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e);
  BC_EXCEPTION_CHECK_ReturnVoid(e);
  CBC_AutoPtr<CFX_Int32Array> errorMagnitudes(ia2);
  for (int32_t k = 0; k < errorLocations->GetSize(); k++) {
    int32_t position =
        received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e);
    BC_EXCEPTION_CHECK_ReturnVoid(e);
    if (position < 0) {
      e = BCExceptionBadErrorLocation;
      BC_EXCEPTION_CHECK_ReturnVoid(e);
    }
    (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract(
        (*received)[position], (*errorMagnitudes)[k]);
  }
}
Exemplo n.º 14
0
int32_t CBC_OnedEAN8Reader::DecodeMiddle(CBC_CommonBitArray* row,
                                         CFX_Int32Array* startRange,
                                         CFX_ByteString& resultResult,
                                         int32_t& e) {
  CFX_Int32Array counters;
  counters.Add(0);
  counters.Add(0);
  counters.Add(0);
  counters.Add(0);
  int32_t end = row->GetSize();
  int32_t rowOffset = (*startRange)[1];
  int32_t rowOffsetLeft = rowOffset;
  for (int32_t x = 0; x < 4 && rowOffset < end; x++) {
    int32_t bestMatch =
        DecodeDigit(row, &counters, rowOffset,
                    &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e);
    BC_EXCEPTION_CHECK_ReturnValue(e, 0);
    resultResult += (FX_CHAR)('0' + bestMatch);
    for (int32_t i = 0; i < counters.GetSize(); i++) {
      rowOffset += counters[i];
    }
  }
  int32_t RowOffsetLen = (rowOffset - rowOffsetLeft) / 4;
  CFX_Int32Array result;
  result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]);
  result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]);
  result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]);
  result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]);
  result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]);
  CFX_Int32Array* middleRange =
      FindGuardPattern(row, rowOffset, TRUE, &result, e);
  BC_EXCEPTION_CHECK_ReturnValue(e, 0);
  int32_t rowOffsetMid = rowOffset;
  rowOffset = (*middleRange)[1];
  if ((rowOffset - rowOffsetMid) > RowOffsetLen) {
    e = BCExceptionNotFound;
    BC_EXCEPTION_CHECK_ReturnValue(e, 0);
  }
  if (middleRange != NULL) {
    delete middleRange;
    middleRange = NULL;
  }
  for (int32_t y = 0; y < 4 && rowOffset < end; y++) {
    int32_t bestMatch =
        DecodeDigit(row, &counters, rowOffset,
                    &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e);
    BC_EXCEPTION_CHECK_ReturnValue(e, 0);
    resultResult += (FX_CHAR)('0' + bestMatch);
    for (int32_t i = 0; i < counters.GetSize(); i++) {
      rowOffset += counters[i];
    }
  }
  return rowOffset;
}
Exemplo n.º 15
0
void CBC_QRCoderDecoder::CorrectErrors(CFX_ByteArray* codewordBytes,
                                       int32_t numDataCodewords,
                                       int32_t& e) {
  int32_t numCodewords = codewordBytes->GetSize();
  CFX_Int32Array codewordsInts;
  codewordsInts.SetSize(numCodewords);
  for (int32_t i = 0; i < numCodewords; i++) {
    codewordsInts[i] = (int32_t)((*codewordBytes)[i] & 0xff);
  }
  int32_t numECCodewords = codewordBytes->GetSize() - numDataCodewords;
  m_rsDecoder->Decode(&codewordsInts, numECCodewords, e);
  BC_EXCEPTION_CHECK_ReturnVoid(e);
  for (int32_t k = 0; k < numDataCodewords; k++) {
    (*codewordBytes)[k] = (uint8_t)codewordsInts[k];
  }
}
Exemplo n.º 16
0
bool CXFA_FFListBox::IsDataChanged() {
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iOldSels = iSelArray.GetSize();
  CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
  int32_t iSels = pListBox->CountSelItems();
  if (iOldSels != iSels)
    return true;

  for (int32_t i = 0; i < iSels; ++i) {
    CFWL_ListItem* hlistItem = pListBox->GetItem(iSelArray[i]);
    if (!(pListBox->GetItemStates(hlistItem) & FWL_ITEMSTATE_LTB_Selected))
      return true;
  }
  return false;
}
Exemplo n.º 17
0
int32_t CBC_Detector::patternMatchVariance(CFX_Int32Array& counters,
                                           int32_t* pattern,
                                           int32_t maxIndividualVariance) {
  int32_t numCounters = counters.GetSize();
  int32_t total = 0;
  int32_t patternLength = 0;
  for (int32_t i = 0; i < numCounters; i++) {
    total += counters[i];
    patternLength += pattern[i];
  }
  if (total < patternLength) {
    return INTERGER_MAX;
  }
  int32_t unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength;
  maxIndividualVariance =
      (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT;
  int32_t totalVariance = 0;
  for (int32_t x = 0; x < numCounters; x++) {
    int32_t counter = counters[x] << INTEGER_MATH_SHIFT;
    int32_t scaledPattern = pattern[x] * unitBarWidth;
    int32_t variance = counter > scaledPattern ? counter - scaledPattern
                                               : scaledPattern - counter;
    if (variance > maxIndividualVariance) {
      return INTERGER_MAX;
    }
    totalVariance += variance;
  }
  return totalVariance / total;
}
Exemplo n.º 18
0
CFX_Int32Array* CBC_PDF417::determineDimensions(
    int32_t sourceCodeWords,
    int32_t errorCorrectionCodeWords,
    int32_t& e) {
  FX_FLOAT ratio = 0.0f;
  CFX_Int32Array* dimension = nullptr;
  for (int32_t cols = m_minCols; cols <= m_maxCols; cols++) {
    int32_t rows =
        calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols);
    if (rows < m_minRows) {
      break;
    }
    if (rows > m_maxRows) {
      continue;
    }
    FX_FLOAT newRatio =
        ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT);
    if (dimension &&
        fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) {
      continue;
    }
    ratio = newRatio;
    delete dimension;
    dimension = new CFX_Int32Array;
    dimension->Add(cols);
    dimension->Add(rows);
  }
  if (!dimension) {
    int32_t rows = calculateNumberOfRows(sourceCodeWords,
                                         errorCorrectionCodeWords, m_minCols);
    if (rows < m_minRows) {
      dimension = new CFX_Int32Array;
      dimension->Add(m_minCols);
      dimension->Add(m_minRows);
    } else if (rows >= 3 && rows <= 90) {
      dimension = new CFX_Int32Array;
      dimension->Add(m_minCols);
      dimension->Add(rows);
    }
  }
  if (!dimension) {
    e = BCExceptionUnableToFitMessageInColumns;
    return nullptr;
  }
  return dimension;
}
Exemplo n.º 19
0
bool CXFA_FFComboBox::UpdateFWLData() {
  if (!m_pNormalWidget) {
    return false;
  }
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  if (iSelCount > 0) {
    ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]);
  } else {
    CFX_WideString wsText;
    ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1);
    m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw);
    ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText);
  }
  m_pNormalWidget->Update();
  return true;
}
Exemplo n.º 20
0
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar,
                                                             int32_t& e) {
  if (scalar == 0)
    return m_field->GetZero()->Clone(e);
  if (scalar == 1)
    return Clone(e);

  int32_t size = m_coefficients.GetSize();
  CFX_Int32Array product;
  product.SetSize(size);
  for (int32_t i = 0; i < size; i++) {
    product[i] = m_field->Multiply(m_coefficients[i], scalar);
  }
  CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
  temp->Init(m_field, &product, e);
  BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
  return temp;
}
int32_t CBC_DecodedBitStreamPaser::decodeMacroBlock(
    CFX_Int32Array& codewords,
    int32_t codeIndex,
    CBC_PDF417ResultMetadata* resultMetadata,
    int32_t& e) {
  if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) {
    e = BCExceptionFormatInstance;
    return -1;
  }
  CFX_Int32Array segmentIndexArray;
  segmentIndexArray.SetSize(NUMBER_OF_SEQUENCE_CODEWORDS);
  for (int32_t i = 0; i < NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) {
    segmentIndexArray.SetAt(i, codewords[codeIndex]);
  }
  CFX_ByteString str =
      decodeBase900toBase10(segmentIndexArray, NUMBER_OF_SEQUENCE_CODEWORDS, e);
  BC_EXCEPTION_CHECK_ReturnValue(e, -1);
  resultMetadata->setSegmentIndex(atoi(str.GetBuffer(str.GetLength())));
  CFX_ByteString fileId;
  codeIndex = textCompaction(codewords, codeIndex, fileId);
  resultMetadata->setFileId(fileId);
  if (codewords[codeIndex] == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) {
    codeIndex++;
    CFX_Int32Array additionalOptionCodeWords;
    additionalOptionCodeWords.SetSize(codewords[0] - codeIndex);
    int32_t additionalOptionCodeWordsIndex = 0;
    FX_BOOL end = FALSE;
    while ((codeIndex < codewords[0]) && !end) {
      int32_t code = codewords[codeIndex++];
      if (code < TEXT_COMPACTION_MODE_LATCH) {
        additionalOptionCodeWords[additionalOptionCodeWordsIndex++] = code;
      } else {
        switch (code) {
          case MACRO_PDF417_TERMINATOR:
            resultMetadata->setLastSegment(TRUE);
            codeIndex++;
            end = TRUE;
            break;
          default:
            e = BCExceptionFormatInstance;
            return -1;
        }
      }
    }
    CFX_Int32Array array;
    array.SetSize(additionalOptionCodeWordsIndex);
    array.Copy(additionalOptionCodeWords);
    resultMetadata->setOptionalData(array);
  } else if (codewords[codeIndex] == MACRO_PDF417_TERMINATOR) {
    resultMetadata->setLastSegment(TRUE);
    codeIndex++;
  }
  return codeIndex;
}
CFX_Int32Array* CBC_DetectionResultRowIndicatorColumn::getRowHeights(
    int32_t& e) {
  CBC_BarcodeMetadata* barcodeMetadata = getBarcodeMetadata();
  if (barcodeMetadata == NULL) {
    e = BCExceptionCannotMetadata;
    return NULL;
  }
  adjustIncompleteIndicatorColumnRowNumbers(*barcodeMetadata);
  CFX_Int32Array* result = new CFX_Int32Array;
  result->SetSize(barcodeMetadata->getRowCount());
  for (int32_t i = 0; i < getCodewords()->GetSize(); i++) {
    CBC_Codeword* codeword = (CBC_Codeword*)getCodewords()->GetAt(i);
    if (codeword != NULL) {
      result->SetAt(codeword->getRowNumber(),
                    result->GetAt(codeword->getRowNumber()) + 1);
    }
  }
  return result;
}
Exemplo n.º 23
0
FX_BOOL CXFA_FFListBox::IsDataChanged() {
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iOldSels = iSelArray.GetSize();
  CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
  int32_t iSels = pListBox->CountSelItems();
  if (iOldSels == iSels) {
    int32_t iIndex = 0;
    for (; iIndex < iSels; iIndex++) {
      FWL_HLISTITEM hlistItem = pListBox->GetItem(iSelArray[iIndex]);
      if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) {
        break;
      }
    }
    if (iIndex == iSels) {
      return FALSE;
    }
  }
  return TRUE;
}
Exemplo n.º 24
0
FX_BOOL CXFA_FFListBox::UpdateFWLData() {
  if (!m_pNormalWidget) {
    return FALSE;
  }
  CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget);
  CFX_ArrayTemplate<FWL_HLISTITEM> selItemArray;
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  for (int32_t j = 0; j < iSelCount; j++) {
    FWL_HLISTITEM lpItemSel = pListBox->GetSelItem(iSelArray[j]);
    selItemArray.Add(lpItemSel);
  }
  pListBox->SetSelItem(pListBox->GetSelItem(-1), FALSE);
  for (int32_t i = 0; i < iSelCount; i++) {
    ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], TRUE);
  }
  m_pNormalWidget->Update();
  return TRUE;
}
Exemplo n.º 25
0
CFX_Int32Array* CBC_PDF417CodewordDecoder::sampleBitCounts(
    CFX_Int32Array& moduleBitCount) {
  FX_FLOAT bitCountSum =
      (FX_FLOAT)CBC_PDF417Common::getBitCountSum(moduleBitCount);
  CFX_Int32Array* bitCount = new CFX_Int32Array();
  bitCount->SetSize(CBC_PDF417Common::BARS_IN_MODULE);
  int32_t bitCountIndex = 0;
  int32_t sumPreviousBits = 0;
  for (int32_t i = 0; i < CBC_PDF417Common::MODULES_IN_CODEWORD; i++) {
    FX_FLOAT sampleIndex =
        bitCountSum / (2 * CBC_PDF417Common::MODULES_IN_CODEWORD) +
        (i * bitCountSum) / CBC_PDF417Common::MODULES_IN_CODEWORD;
    if (sumPreviousBits + moduleBitCount.GetAt(bitCountIndex) <= sampleIndex) {
      sumPreviousBits += moduleBitCount.GetAt(bitCountIndex);
      bitCountIndex++;
    }
    bitCount->SetAt(bitCountIndex, bitCount->GetAt(bitCountIndex) + 1);
  }
  return bitCount;
}
Exemplo n.º 26
0
void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes,
                                          int32_t numDataCodewords,
                                          int32_t& e) {
  int32_t numCodewords = codewordBytes.GetSize();
  CFX_Int32Array codewordsInts;
  codewordsInts.SetSize(numCodewords);
  int32_t i;
  for (i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int32_t numECCodewords = codewordBytes.GetSize() - numDataCodewords;
  m_rsDecoder->Decode(&codewordsInts, numECCodewords, e);
  if (e != BCExceptionNO) {
    e = BCExceptionChecksumException;
    return;
  }
  for (i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (uint8_t)codewordsInts[i];
  }
}
Exemplo n.º 27
0
bool CXFA_FFListBox::UpdateFWLData() {
  if (!m_pNormalWidget) {
    return false;
  }
  CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget);
  CFX_ArrayTemplate<CFWL_ListItem*> selItemArray;
  CFX_Int32Array iSelArray;
  m_pDataAcc->GetSelectedItems(iSelArray);
  int32_t iSelCount = iSelArray.GetSize();
  for (int32_t j = 0; j < iSelCount; j++) {
    CFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]);
    selItemArray.Add(lpItemSel);
  }
  pListBox->SetSelItem(pListBox->GetSelItem(-1), false);
  for (int32_t i = 0; i < iSelCount; i++) {
    ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], true);
  }
  m_pNormalWidget->Update();
  return true;
}
Exemplo n.º 28
0
CBC_PDF417ECModulusGF::CBC_PDF417ECModulusGF(int32_t modulus,
                                             int32_t generator,
                                             int32_t& e) {
  m_modulus = modulus;
  m_expTable.SetSize(modulus);
  m_logTable.SetSize(modulus);
  int32_t x = 1;
  for (int32_t i = 0; i < modulus; i++) {
    m_expTable[i] = x;
    x = (x * generator) % modulus;
  }
  for (int32_t j = 0; j < modulus - 1; j++) {
    m_logTable[m_expTable[j]] = j;
  }
  CFX_Int32Array zero;
  zero.Add(0);
  m_zero = new CBC_PDF417ECModulusPoly(this, zero, e);
  CFX_Int32Array one;
  one.Add(1);
  m_one = new CBC_PDF417ECModulusPoly(this, one, e);
}
void CBC_DataMatrixDecodedBitStreamParser::DecodeAnsiX12Segment(
    CBC_CommonBitSource* bits,
    CFX_ByteString& result,
    int32_t& e) {
  CFX_Int32Array cValues;
  cValues.SetSize(3);
  do {
    if (bits->Available() == 8) {
      return;
    }
    int32_t firstByte = bits->ReadBits(8, e);
    BC_EXCEPTION_CHECK_ReturnVoid(e);
    if (firstByte == 254) {
      return;
    }
    int32_t iTemp1 = bits->ReadBits(8, e);
    BC_EXCEPTION_CHECK_ReturnVoid(e);
    ParseTwoBytes(firstByte, iTemp1, cValues);
    int32_t i;
    for (i = 0; i < 3; i++) {
      int32_t cValue = cValues[i];
      if (cValue == 0) {
        BC_FX_ByteString_Append(result, 1, '\r');
      } else if (cValue == 1) {
        BC_FX_ByteString_Append(result, 1, '*');
      } else if (cValue == 2) {
        BC_FX_ByteString_Append(result, 1, '>');
      } else if (cValue == 3) {
        BC_FX_ByteString_Append(result, 1, ' ');
      } else if (cValue < 14) {
        BC_FX_ByteString_Append(result, 1, (FX_CHAR)(cValue + 44));
      } else if (cValue < 40) {
        BC_FX_ByteString_Append(result, 1, (FX_CHAR)(cValue + 51));
      } else {
        e = BCExceptionFormatException;
        return;
      }
    }
  } while (bits->Available() > 0);
}
Exemplo n.º 30
0
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(
    CBC_ReedSolomonGF256Poly* other,
    int32_t& e) {
  if (IsZero() || other->IsZero()) {
    CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e);
    BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
    return temp;
  }
  CFX_Int32Array aCoefficients;
  aCoefficients.Copy(m_coefficients);
  int32_t aLength = m_coefficients.GetSize();
  CFX_Int32Array bCoefficients;
  bCoefficients.Copy(*(other->GetCoefficients()));
  int32_t bLength = other->GetCoefficients()->GetSize();
  CFX_Int32Array product;
  product.SetSize(aLength + bLength - 1);
  for (int32_t i = 0; i < aLength; i++) {
    int32_t aCoeff = m_coefficients[i];
    for (int32_t j = 0; j < bLength; j++) {
      product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract(
          product[i + j],
          m_field->Multiply(aCoeff, other->GetCoefficients()->operator[](j)));
    }
  }
  CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
  temp->Init(m_field, &product, e);
  BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
  return temp;
}