mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
C25STANDARD/C25INTER/C25IATA/C25LOGIC/C25IND: add check digit option (#216)
This commit is contained in:
parent
29d761c795
commit
f3a94f0c0c
238
backend/2of5.c
238
backend/2of5.c
@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -34,162 +34,121 @@
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#define inline _inline
|
||||
#endif
|
||||
|
||||
static const char *C25MatrixTable[10] = {
|
||||
"113311", "311131", "131131", "331111", "113131", "313111",
|
||||
"133111", "111331", "311311", "131311"
|
||||
"113311", "311131", "131131", "331111", "113131",
|
||||
"313111", "133111", "111331", "311311", "131311"
|
||||
};
|
||||
|
||||
static const char *C25MatrixStartStop[2] = { "411111", "41111" };
|
||||
|
||||
static const char *C25IndustTable[10] = {
|
||||
"1111313111", "3111111131", "1131111131", "3131111111", "1111311131",
|
||||
"3111311111", "1131311111", "1111113131", "3111113111", "1131113111"
|
||||
};
|
||||
|
||||
static const char *C25IndustStartStop[2] = { "313111", "31113" };
|
||||
|
||||
static const char *C25IataLogicStartStop[2] = { "1111", "311" };
|
||||
|
||||
static const char *C25InterTable[10] = {
|
||||
"11331", "31113", "13113", "33111", "11313", "31311", "13311", "11133",
|
||||
"31131", "13131"
|
||||
"11331", "31113", "13113", "33111", "11313",
|
||||
"31311", "13311", "11133", "31131", "13131"
|
||||
};
|
||||
|
||||
static inline char check_digit(unsigned int count) {
|
||||
static inline char check_digit(const unsigned int count) {
|
||||
return itoc((10 - (count % 10)) % 10);
|
||||
}
|
||||
|
||||
/* Calculate the check digit - the same method used for EAN-13 (GS1 General Specifications 7.9.1) */
|
||||
static unsigned int gs1_checksum(const unsigned char source[], const int length) {
|
||||
int i;
|
||||
unsigned int count = 0;
|
||||
int factor = length & 1 ? 3 : 1;
|
||||
for (i = 0; i < length; i++) {
|
||||
count += factor * ctoi(source[i]);
|
||||
factor = factor == 1 ? 3 : 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Common to Standard (Matrix), Industrial, IATA, and Data Logic */
|
||||
static int c25_common(struct zint_symbol *symbol, const unsigned char source[], int length, const int max,
|
||||
const char *table[10], const char *start_stop[2], const int error_base) {
|
||||
|
||||
int i, error_number;
|
||||
char dest[512]; /* Largest destination 6 + (80 + 1) * 6 + 5 + 1 = 498 */
|
||||
unsigned char temp[80 + 1 + 1]; /* Largest maximum 80 */
|
||||
int have_checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
|
||||
|
||||
if (length > max) {
|
||||
sprintf(symbol->errtxt, "%d: Input too long (maximum %d)", error_base, max);
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
sprintf(symbol->errtxt, "%d: Invalid characters in data", error_base + 1);
|
||||
return error_number;
|
||||
}
|
||||
|
||||
ustrcpy(temp, source);
|
||||
|
||||
if (have_checkdigit) {
|
||||
/* Add standard GS1 check digit */
|
||||
temp[length] = check_digit(gs1_checksum(source, length));
|
||||
temp[++length] = '\0';
|
||||
}
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, start_stop[0]);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
lookup(NEON, table, temp[i], dest);
|
||||
}
|
||||
|
||||
/* Stop character */
|
||||
strcat(dest, start_stop[1]);
|
||||
|
||||
expand(symbol, dest);
|
||||
|
||||
ustrcpy(symbol->text, temp);
|
||||
if (symbol->option_2 == 2) {
|
||||
/* Remove check digit from HRT */
|
||||
symbol->text[length - 1] = '\0';
|
||||
}
|
||||
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Code 2 of 5 Standard (Code 2 of 5 Matrix) */
|
||||
INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, error_number;
|
||||
char dest[512]; /* 6 + 80 * 6 + 5 + 1 = 492 */
|
||||
|
||||
if (length > 80) {
|
||||
strcpy(symbol->errtxt, "301: Input too long");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "302: Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, "411111");
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
lookup(NEON, C25MatrixTable, source[i], dest);
|
||||
}
|
||||
|
||||
/* Stop character */
|
||||
strcat(dest, "41111");
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
return c25_common(symbol, source, length, 80, C25MatrixTable, C25MatrixStartStop, 301);
|
||||
}
|
||||
|
||||
/* Code 2 of 5 Industrial */
|
||||
INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, error_number;
|
||||
char dest[512]; /* 6 + 45 * 10 + 5 + 1 = 462 */
|
||||
|
||||
if (length > 45) {
|
||||
strcpy(symbol->errtxt, "303: Input too long");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "304: Invalid character in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, "313111");
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
lookup(NEON, C25IndustTable, source[i], dest);
|
||||
}
|
||||
|
||||
/* Stop character */
|
||||
strcat(dest, "31113");
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
return c25_common(symbol, source, length, 45, C25IndustTable, C25IndustStartStop, 303);
|
||||
}
|
||||
|
||||
/* Code 2 of 5 IATA */
|
||||
INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number;
|
||||
char dest[512]; /* 4 + 45 * 10 + 3 + 1 = 458 */
|
||||
|
||||
if (length > 45) {
|
||||
strcpy(symbol->errtxt, "305: Input too long");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "306: Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* start */
|
||||
strcpy(dest, "1111");
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
lookup(NEON, C25IndustTable, source[i], dest);
|
||||
}
|
||||
|
||||
/* stop */
|
||||
strcat(dest, "311");
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
return c25_common(symbol, source, length, 45, C25IndustTable, C25IataLogicStartStop, 305);
|
||||
}
|
||||
|
||||
/* Code 2 of 5 Data Logic */
|
||||
INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, error_number;
|
||||
char dest[512]; /* 4 + 80 * 6 + 3 + 1 = 488 */
|
||||
|
||||
if (length > 80) {
|
||||
strcpy(symbol->errtxt, "307: Input too long");
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
error_number = is_sane(NEON, source, length);
|
||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||
strcpy(symbol->errtxt, "308: Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, "1111");
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
lookup(NEON, C25MatrixTable, source[i], dest);
|
||||
}
|
||||
|
||||
/* Stop character */
|
||||
strcat(dest, "311");
|
||||
|
||||
expand(symbol, dest);
|
||||
ustrcpy(symbol->text, source);
|
||||
return error_number;
|
||||
return c25_common(symbol, source, length, 80, C25MatrixTable, C25IataLogicStartStop, 307);
|
||||
}
|
||||
|
||||
/* Code 2 of 5 Interleaved */
|
||||
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, j, error_number;
|
||||
char bars[7], spaces[7], mixed[14], dest[512]; /* 4 + 90 * 5 + 3 + 1 = 458 */
|
||||
#ifndef _MSC_VER
|
||||
unsigned char temp[length + 2];
|
||||
#else
|
||||
unsigned char* temp = (unsigned char *) _alloca((length + 2) * sizeof (unsigned char));
|
||||
#endif
|
||||
char bars[7], spaces[7], mixed[14], dest[512]; /* 4 + (90 + 2) * 5 + 3 + 1 = 468 */
|
||||
unsigned char temp[90 + 2 + 1];
|
||||
int have_checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
|
||||
|
||||
if (length > 90) {
|
||||
strcpy(symbol->errtxt, "309: Input too long");
|
||||
@ -203,13 +162,20 @@ INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char s
|
||||
|
||||
temp[0] = '\0';
|
||||
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
|
||||
if an odd number of characters has been entered then add a leading zero */
|
||||
if (length & 1) {
|
||||
if an odd number of characters has been entered and no check digit or an even number and have check digit
|
||||
then add a leading zero */
|
||||
if (((length & 1) && !have_checkdigit) || (!(length & 1) && have_checkdigit)) {
|
||||
ustrcpy(temp, "0");
|
||||
length++;
|
||||
}
|
||||
ustrncat(temp, source, length);
|
||||
|
||||
if (have_checkdigit) {
|
||||
/* Add standard GS1 check digit */
|
||||
temp[length] = check_digit(gs1_checksum(temp, length));
|
||||
temp[++length] = '\0';
|
||||
}
|
||||
|
||||
/* start character */
|
||||
strcpy(dest, "1111");
|
||||
|
||||
@ -236,17 +202,20 @@ INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char s
|
||||
strcat(dest, "311");
|
||||
|
||||
expand(symbol, dest);
|
||||
|
||||
ustrcpy(symbol->text, temp);
|
||||
if (symbol->option_2 == 2) {
|
||||
/* Remove check digit from HRT */
|
||||
symbol->text[length - 1] = '\0';
|
||||
}
|
||||
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Interleaved 2-of-5 (ITF) */
|
||||
INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number, zeroes;
|
||||
unsigned int count;
|
||||
char localstr[16];
|
||||
|
||||
count = 0;
|
||||
unsigned char localstr[16] = {0};
|
||||
|
||||
if (length > 13) {
|
||||
strcpy(symbol->errtxt, "311: Input too long");
|
||||
@ -267,14 +236,7 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
ustrcpy(localstr + zeroes, source);
|
||||
|
||||
/* Calculate the check digit - the same method used for EAN-13 */
|
||||
for (i = 12; i >= 0; i--) {
|
||||
count += ctoi(localstr[i]);
|
||||
|
||||
if (!(i & 1)) {
|
||||
count += 2 * ctoi(localstr[i]);
|
||||
}
|
||||
}
|
||||
localstr[13] = check_digit(count);
|
||||
localstr[13] = check_digit(gs1_checksum(localstr, 13));
|
||||
localstr[14] = '\0';
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, 14);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
@ -295,7 +257,7 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number;
|
||||
unsigned int count;
|
||||
char localstr[16];
|
||||
unsigned char localstr[16] = {0};
|
||||
int zeroes;
|
||||
|
||||
count = 0;
|
||||
@ -323,7 +285,7 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
}
|
||||
localstr[13] = check_digit(count);
|
||||
localstr[14] = '\0';
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, 14);
|
||||
error_number = interleaved_two_of_five(symbol, localstr, 14);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
return error_number;
|
||||
}
|
||||
@ -332,7 +294,7 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number, zeroes;
|
||||
unsigned int count;
|
||||
char localstr[16];
|
||||
unsigned char localstr[16] = {0};
|
||||
|
||||
count = 0;
|
||||
if (length > 11) {
|
||||
@ -359,7 +321,7 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
}
|
||||
localstr[11] = check_digit(count);
|
||||
localstr[12] = '\0';
|
||||
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, 12);
|
||||
error_number = interleaved_two_of_five(symbol, localstr, 12);
|
||||
ustrcpy(symbol->text, localstr);
|
||||
return error_number;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ static void test_large(int index, int debug) {
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
char *pattern;
|
||||
int length;
|
||||
int ret;
|
||||
@ -46,22 +47,32 @@ static void test_large(int index, int debug) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_C25STANDARD, "1", 80, 0, 1, 817 },
|
||||
/* 1*/ { BARCODE_C25STANDARD, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { BARCODE_C25INTER, "1", 90, 0, 1, 819 },
|
||||
/* 3*/ { BARCODE_C25INTER, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { BARCODE_C25IATA, "1", 45, 0, 1, 639 },
|
||||
/* 5*/ { BARCODE_C25IATA, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 6*/ { BARCODE_C25LOGIC, "1", 80, 0, 1, 809 },
|
||||
/* 7*/ { BARCODE_C25LOGIC, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 8*/ { BARCODE_C25IND, "1", 45, 0, 1, 649 },
|
||||
/* 9*/ { BARCODE_C25IND, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 10*/ { BARCODE_DPLEIT, "1", 13, 0, 1, 135 },
|
||||
/* 11*/ { BARCODE_DPLEIT, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 12*/ { BARCODE_DPIDENT, "1", 11, 0, 1, 117 },
|
||||
/* 13*/ { BARCODE_DPIDENT, "1", 12, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 14*/ { BARCODE_ITF14, "1", 13, 0, 1, 135 },
|
||||
/* 15*/ { BARCODE_ITF14, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 0*/ { BARCODE_C25STANDARD, -1, "1", 80, 0, 1, 817 },
|
||||
/* 1*/ { BARCODE_C25STANDARD, -1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { BARCODE_C25STANDARD, 1, "1", 80, 0, 1, 827 },
|
||||
/* 3*/ { BARCODE_C25STANDARD, 1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { BARCODE_C25INTER, -1, "1", 90, 0, 1, 819 },
|
||||
/* 5*/ { BARCODE_C25INTER, -1, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 6*/ { BARCODE_C25INTER, 1, "1", 90, 0, 1, 837 },
|
||||
/* 7*/ { BARCODE_C25INTER, 1, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 8*/ { BARCODE_C25IATA, -1, "1", 45, 0, 1, 639 },
|
||||
/* 9*/ { BARCODE_C25IATA, -1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 10*/ { BARCODE_C25IATA, 1, "1", 45, 0, 1, 653 },
|
||||
/* 11*/ { BARCODE_C25IATA, 1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 12*/ { BARCODE_C25LOGIC, -1, "1", 80, 0, 1, 809 },
|
||||
/* 13*/ { BARCODE_C25LOGIC, -1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 14*/ { BARCODE_C25LOGIC, 1, "1", 80, 0, 1, 819 },
|
||||
/* 15*/ { BARCODE_C25LOGIC, 1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 16*/ { BARCODE_C25IND, -1, "1", 45, 0, 1, 649 },
|
||||
/* 17*/ { BARCODE_C25IND, -1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 18*/ { BARCODE_C25IND, 1, "1", 45, 0, 1, 663 },
|
||||
/* 19*/ { BARCODE_C25IND, 1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 20*/ { BARCODE_DPLEIT, -1, "1", 13, 0, 1, 135 },
|
||||
/* 21*/ { BARCODE_DPLEIT, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 22*/ { BARCODE_DPIDENT, -1, "1", 11, 0, 1, 117 },
|
||||
/* 23*/ { BARCODE_DPIDENT, -1, "1", 12, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 24*/ { BARCODE_ITF14, -1, "1", 13, 0, 1, 135 },
|
||||
/* 25*/ { BARCODE_ITF14, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
@ -77,7 +88,7 @@ static void test_large(int index, int debug) {
|
||||
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
|
||||
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
|
||||
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@ -100,22 +111,36 @@ static void test_hrt(int index, int debug) {
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
char *data;
|
||||
char *expected;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_C25STANDARD, "123456789", "123456789" },
|
||||
/* 1*/ { BARCODE_C25INTER, "123456789", "0123456789" }, // Adds leading zero if odd
|
||||
/* 2*/ { BARCODE_C25IATA, "123456789", "123456789" },
|
||||
/* 3*/ { BARCODE_C25LOGIC, "123456789", "123456789" },
|
||||
/* 4*/ { BARCODE_C25IND, "123456789", "123456789" },
|
||||
/* 5*/ { BARCODE_DPLEIT, "123456789", "00001234567890" }, // Leading zeroes added to make 13 + appended checksum
|
||||
/* 6*/ { BARCODE_DPLEIT, "1234567890123", "12345678901236" },
|
||||
/* 7*/ { BARCODE_DPIDENT, "123456789", "001234567890" }, // Leading zeroes added to make 11 + appended checksum
|
||||
/* 8*/ { BARCODE_DPIDENT, "12345678901", "123456789016" },
|
||||
/* 9*/ { BARCODE_ITF14, "123456789", "00001234567895" }, // Leading zeroes added to make 13 + appended checksum
|
||||
/* 10*/ { BARCODE_ITF14, "1234567890123", "12345678901231" },
|
||||
/* 0*/ { BARCODE_C25STANDARD, -1, "123456789", "123456789" },
|
||||
/* 1*/ { BARCODE_C25STANDARD, 1, "123456789", "1234567895" },
|
||||
/* 2*/ { BARCODE_C25STANDARD, 2, "123456789", "123456789" }, // Suppresses printing of check digit
|
||||
/* 3*/ { BARCODE_C25INTER, -1, "123456789", "0123456789" }, // Adds leading zero if odd
|
||||
/* 4*/ { BARCODE_C25INTER, 1, "123456789", "1234567895" }, // Unless check digit added when it becomes even
|
||||
/* 5*/ { BARCODE_C25INTER, 2, "123456789", "123456789" },
|
||||
/* 6*/ { BARCODE_C25INTER, -1, "1234567890", "1234567890" }, // No leading zero if even
|
||||
/* 7*/ { BARCODE_C25INTER, 1, "1234567890", "012345678905" }, // Unless check digit added when it becomes odd
|
||||
/* 8*/ { BARCODE_C25INTER, 2, "1234567890", "01234567890" },
|
||||
/* 9*/ { BARCODE_C25IATA, -1, "123456789", "123456789" },
|
||||
/* 10*/ { BARCODE_C25IATA, 1, "123456789", "1234567895" },
|
||||
/* 11*/ { BARCODE_C25IATA, 2, "123456789", "123456789" },
|
||||
/* 12*/ { BARCODE_C25LOGIC, -1, "123456789", "123456789" },
|
||||
/* 13*/ { BARCODE_C25LOGIC, 1, "123456789", "1234567895" },
|
||||
/* 14*/ { BARCODE_C25LOGIC, 2, "123456789", "123456789" },
|
||||
/* 15*/ { BARCODE_C25IND, -1, "123456789", "123456789" },
|
||||
/* 16*/ { BARCODE_C25IND, 1, "123456789", "1234567895" },
|
||||
/* 17*/ { BARCODE_C25IND, 2, "123456789", "123456789" },
|
||||
/* 18*/ { BARCODE_DPLEIT, -1, "123456789", "00001234567890" }, // Leading zeroes added to make 13 + appended checksum
|
||||
/* 19*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345678901236" },
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "123456789", "001234567890" }, // Leading zeroes added to make 11 + appended checksum
|
||||
/* 21*/ { BARCODE_DPIDENT, -1, "12345678901", "123456789016" },
|
||||
/* 22*/ { BARCODE_ITF14, -1, "123456789", "00001234567895" }, // Leading zeroes added to make 13 + appended checksum
|
||||
/* 23*/ { BARCODE_ITF14, -1, "1234567890123", "12345678901231" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
|
||||
@ -126,7 +151,7 @@ static void test_hrt(int index, int debug) {
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
@ -196,6 +221,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
char *data;
|
||||
int ret;
|
||||
|
||||
@ -206,46 +232,67 @@ static void test_encode(int index, int generate, int debug) {
|
||||
};
|
||||
// BARCODE_ITF14 examples verified manually against GS1 General Specifications 21.0.1
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_C25STANDARD, "87654321", 0, 1, 97, "Standard Code 2 of 5; note zint uses 4X start/end wides while BWIPP uses 3X",
|
||||
/* 0*/ { BARCODE_C25STANDARD, -1, "87654321", 0, 1, 97, "Standard Code 2 of 5; note zint uses 4X start/end wides while BWIPP uses 3X",
|
||||
"1111010101110100010101000111010001110101110111010101110111011100010101000101110111010111011110101"
|
||||
},
|
||||
/* 1*/ { BARCODE_C25INTER, "87654321", 0, 1, 81, "Interleaved Code 2 of 5; verified manually against tec-it",
|
||||
/* 1*/ { BARCODE_C25STANDARD, 1, "87654321", 0, 1, 107, "With check digit",
|
||||
"11110101011101000101010001110100011101011101110101011101110111000101010001011101110101110100010111011110101"
|
||||
},
|
||||
/* 2*/ { BARCODE_C25INTER, -1, "87654321", 0, 1, 81, "Interleaved Code 2 of 5, even; verified manually against tec-it",
|
||||
"101011101010111000100010001110111000101010001000111010111010001110101011100011101"
|
||||
},
|
||||
/* 2*/ { BARCODE_C25INTER, "602003", 0, 1, 63, "DX cartridge barcode https://en.wikipedia.org/wiki/Interleaved_2_of_5 example",
|
||||
/* 3*/ { BARCODE_C25INTER, 1, "87654321", 0, 1, 99, "With check digit",
|
||||
"101010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101"
|
||||
},
|
||||
/* 4*/ { BARCODE_C25INTER, -1, "7654321", 0, 1, 81, "Interleaved Code 2 of 5, odd",
|
||||
"101010101110111000100010001110111000101010001000111010111010001110101011100011101"
|
||||
},
|
||||
/* 5*/ { BARCODE_C25INTER, 1, "7654321", 0, 1, 81, "With check digit",
|
||||
"101010100010001110111011101011100010100011101110001010100011101010001000111011101"
|
||||
},
|
||||
/* 6*/ { BARCODE_C25INTER, -1, "602003", 0, 1, 63, "DX cartridge barcode https://en.wikipedia.org/wiki/Interleaved_2_of_5 example",
|
||||
"101010111011100010001010111010001000111010001000111011101011101"
|
||||
},
|
||||
/* 3*/ { BARCODE_C25IATA, "87654321", 0, 1, 121, "IATA Code 2 of 5; verified manually against tec-it",
|
||||
/* 7*/ { BARCODE_C25IATA, -1, "87654321", 0, 1, 121, "IATA Code 2 of 5; verified manually against tec-it",
|
||||
"1010111010101110101010101110111010111011101010111010111010101010111010111011101110101010101110101011101110101010111011101"
|
||||
},
|
||||
/* 4*/ { BARCODE_C25LOGIC, "87654321", 0, 1, 89, "Code 2 of 5 Data Logic; verified manually against tec-it",
|
||||
/* 8*/ { BARCODE_C25IATA, 1, "87654321", 0, 1, 135, "With check digit",
|
||||
"101011101010111010101010111011101011101110101011101011101010101011101011101110111010101010111010101110111010101011101011101010111011101"
|
||||
},
|
||||
/* 9*/ { BARCODE_C25LOGIC, -1, "87654321", 0, 1, 89, "Code 2 of 5 Data Logic; verified manually against tec-it",
|
||||
"10101110100010101000111010001110101110111010101110111011100010101000101110111010111011101"
|
||||
},
|
||||
/* 5*/ { BARCODE_C25IND, "87654321", 0, 1, 131, "Industrial Code 2 of 5; verified manually against tec-it",
|
||||
/* 10*/ { BARCODE_C25LOGIC, 1, "87654321", 0, 1, 99, "With check digit",
|
||||
"101011101000101010001110100011101011101110101011101110111000101010001011101110101110100010111011101"
|
||||
},
|
||||
/* 11*/ { BARCODE_C25IND, -1, "87654321", 0, 1, 131, "Industrial Code 2 of 5; verified manually against tec-it",
|
||||
"11101110101110101011101010101011101110101110111010101110101110101010101110101110111011101010101011101010111011101010101110111010111"
|
||||
},
|
||||
/* 6*/ { BARCODE_DPLEIT, "0000087654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against tec-it",
|
||||
/* 12*/ { BARCODE_C25IND, 1, "87654321", 0, 1, 145, "With check digit",
|
||||
"1110111010111010101110101010101110111010111011101010111010111010101010111010111011101110101010101110101011101110101010111010111010101110111010111"
|
||||
},
|
||||
/* 13*/ { BARCODE_DPLEIT, -1, "0000087654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against tec-it",
|
||||
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
||||
},
|
||||
/* 7*/ { BARCODE_DPLEIT, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
/* 14*/ { BARCODE_DPLEIT, -1, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
"101011101011100010001011101000101110100011101110100010001010101110111000100010100011101110100011101010001110001010001011100011101011101"
|
||||
},
|
||||
/* 8*/ { BARCODE_DPIDENT, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it",
|
||||
/* 15*/ { BARCODE_DPIDENT, -1, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it",
|
||||
"101010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
|
||||
},
|
||||
/* 9*/ { BARCODE_DPIDENT, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
/* 16*/ { BARCODE_DPIDENT, -1, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
|
||||
"101011101110001010001010111011100010001011100010001010111011100010001010111010001011101011100010101110001000111011101"
|
||||
},
|
||||
/* 10*/ { BARCODE_ITF14, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it",
|
||||
/* 17*/ { BARCODE_ITF14, -1, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it",
|
||||
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101"
|
||||
},
|
||||
/* 11*/ { BARCODE_ITF14, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
|
||||
/* 18*/ { BARCODE_ITF14, -1, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
|
||||
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001010001000111011101011101"
|
||||
},
|
||||
/* 12*/ { BARCODE_ITF14, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
|
||||
/* 19*/ { BARCODE_ITF14, -1, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
|
||||
"101011100010100010111010101110001000111010001011101110100010001011101011100010001110101000111011101010111000100010001110001110101011101"
|
||||
},
|
||||
/* 13*/ { BARCODE_ITF14, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
|
||||
/* 20*/ { BARCODE_ITF14, -1, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
|
||||
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001011101010001000111011101"
|
||||
},
|
||||
};
|
||||
@ -262,14 +309,14 @@ static void test_encode(int index, int generate, int debug) {
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (generate) {
|
||||
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||
testUtilModulesPrint(symbol, " ", "\n");
|
||||
printf(" },\n");
|
||||
@ -282,8 +329,8 @@ static void test_encode(int index, int generate, int debug) {
|
||||
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
|
||||
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
|
||||
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
|
@ -1758,12 +1758,12 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
|
||||
static const struct item data[] = {
|
||||
{ "", -1, 0, 0, 0, 0, 0, 0, },
|
||||
{ "code11", BARCODE_CODE11, 1, 0, 1, 0, 0, 0, },
|
||||
{ "matrix2of5", BARCODE_C25STANDARD, 2, 0, 0, 0, 0, 0, },
|
||||
{ "interleaved2of5", BARCODE_C25INTER, 3, 0, 0, 0, 0, 0, },
|
||||
{ "iata2of5", BARCODE_C25IATA, 4, 0, 0, 0, 0, 0, },
|
||||
{ "matrix2of5", BARCODE_C25STANDARD, 2, 0, 1, 0, 0, 0, },
|
||||
{ "interleaved2of5", BARCODE_C25INTER, 3, 0, 1, 0, 0, 0, },
|
||||
{ "iata2of5", BARCODE_C25IATA, 4, 0, 1, 0, 0, 0, },
|
||||
{ "", -1, 5, 0, 0, 0, 0, 0, },
|
||||
{ "datalogic2of5", BARCODE_C25LOGIC, 6, 0, 0, 0, 0, 0, },
|
||||
{ "industrial2of5", BARCODE_C25IND, 7, 0, 0, 0, 0, 0, },
|
||||
{ "datalogic2of5", BARCODE_C25LOGIC, 6, 0, 1, 0, 0, 0, },
|
||||
{ "industrial2of5", BARCODE_C25IND, 7, 0, 1, 0, 0, 0, },
|
||||
{ "code39", BARCODE_CODE39, 8, 0, 1, 0, 0, 0, },
|
||||
{ "code39ext", BARCODE_EXCODE39, 9, 0, 1, 0, 0, 0, },
|
||||
{ "", -1, 10, 0, 0, 0, 0, 0, },
|
||||
@ -2239,7 +2239,13 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
||||
bwipp_opts = bwipp_opts_buf;
|
||||
}
|
||||
|
||||
if (symbology == BARCODE_CODE93) {
|
||||
if (symbology == BARCODE_C25STANDARD || symbology == BARCODE_C25INTER || symbology == BARCODE_C25IATA
|
||||
|| symbology == BARCODE_C25LOGIC || symbology == BARCODE_C25IND) {
|
||||
if (option_2 == 1 || option_2 == 2) { // Add check digit without or with HRT suppression
|
||||
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sincludecheck", strlen(bwipp_opts_buf) ? " " : "");
|
||||
bwipp_opts = bwipp_opts_buf;
|
||||
}
|
||||
} else if (symbology == BARCODE_CODE93) {
|
||||
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sincludecheck", strlen(bwipp_opts_buf) ? " " : "");
|
||||
if (parse) {
|
||||
bwipp_barcode = "code93ext";
|
||||
|
@ -1434,29 +1434,39 @@ before using these standards.
|
||||
----------------------------
|
||||
Also known as Code 2 of 5 Matrix this is a self-checking code used in industrial
|
||||
applications and photo development. Standard Code 2 of 5 will encode any length
|
||||
numeric input (digits 0-9).
|
||||
numeric input (digits 0-9). No check digit is added by default. To add a check
|
||||
digit, set option_2 = 1 or --vers=1. To add a check digit but not show it in
|
||||
the human readable text, set option_2 = 2 or --vers=2.
|
||||
|
||||
6.1.2.2 IATA Code 2 of 5
|
||||
------------------------
|
||||
Used for baggage handling in the air-transport industry by the International
|
||||
Air Transport Agency, this self-checking code will encode any length numeric
|
||||
input (digits 0-9) and does not include a check digit.
|
||||
input (digits 0-9). No check digit is added by default. To add a check digit,
|
||||
set option_2 = 1 or --vers=1. To add a check digit but not show it in the human
|
||||
readable text, set option_2 = 2 or --vers=2.
|
||||
|
||||
6.1.2.3 Industrial Code 2 of 5
|
||||
------------------------------
|
||||
Industrial Code 2 of 5 can encode any length numeric input (digits 0-9) and
|
||||
does not include a check digit.
|
||||
Industrial Code 2 of 5 can encode any length numeric input (digits 0-9). No
|
||||
check digit is added by default. To add a check digit, set option_2 = 1 or
|
||||
--vers=1. To add a check digit but not show it in the human readable text, set
|
||||
option_2 = 2 or --vers=2.
|
||||
|
||||
6.1.2.4 Interleaved Code 2 of 5
|
||||
-------------------------------
|
||||
This self-checking symbology encodes pairs of numbers, and so can only encode
|
||||
an even number of digits (0-9). If an odd number of digits is entered a leading
|
||||
zero is added by Zint. No check digit is added.
|
||||
zero is added by Zint. No check digit is added by default. To add a check digit,
|
||||
set option_2 = 1 or --vers=1. To add a check digit but not show it in the human
|
||||
readable text, set option_2 = 2 or --vers=2.
|
||||
|
||||
6.1.2.5 Code 2 of 5 Data Logic
|
||||
------------------------------
|
||||
Data Logic does not include a check digit and can encode any length numeric
|
||||
input (digits 0-9).
|
||||
Data Logic does not include a check digit by default and can encode any length
|
||||
numeric input (digits 0-9). To add a check digit, set option_2 = 1 or --vers=1.
|
||||
To add a check digit but not show it in the human readable text, set option_2 =
|
||||
2 or --vers=2.
|
||||
|
||||
6.1.2.6 ITF-14
|
||||
--------------
|
||||
|
@ -16,11 +16,11 @@ else()
|
||||
qt5_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
|
||||
qt5_add_resources(zint-qt_SRCS resources.qrc)
|
||||
endif()
|
||||
# grpAztec.ui grpC49.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpUPCEAN.ui
|
||||
# grpC11.ui grpChannel.ui grpDM.ui grpMaxicode.ui grpQR.ui grpVIN.ui
|
||||
# grpC128.ui grpCodabar.ui grpDotCode.ui grpMicroPDF.ui grpRMQR.ui
|
||||
# grpC16k.ui grpCodablockF.ui grpGrid.ui grpMQR.ui grpUltra.ui
|
||||
# grpC39.ui grpCodeOne.ui grpHX.ui grpMSICheck.ui grpUPCA.ui
|
||||
# grpAztec.ui grpC39.ui grpCodeOne.ui grpHX.ui grpMSICheck.ui grpUPCA.ui
|
||||
# grpC11.ui grpC49.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpUPCEAN.ui
|
||||
# grpC128.ui grpChannel.ui grpDM.ui grpMaxicode.ui grpQR.ui grpVIN.ui
|
||||
# grpC16k.ui grpCodabar.ui grpDotCode.ui grpMicroPDF.ui grpRMQR.ui
|
||||
# grpC25.ui grpCodablockF.ui grpGrid.ui grpMQR.ui grpUltra.ui
|
||||
|
||||
add_executable(zint-qt ${zint-qt_SRCS})
|
||||
add_dependencies(zint-qt zint)
|
||||
|
@ -65,6 +65,7 @@ FORMS += extData.ui \
|
||||
grpC11.ui \
|
||||
grpC128.ui \
|
||||
grpC16k.ui \
|
||||
grpC25.ui \
|
||||
grpC39.ui \
|
||||
grpC49.ui \
|
||||
grpChannel.ui \
|
||||
|
@ -18,6 +18,7 @@ FORMS += extData.ui \
|
||||
grpC11.ui \
|
||||
grpC128.ui \
|
||||
grpC16k.ui \
|
||||
grpC25.ui \
|
||||
grpC39.ui \
|
||||
grpC49.ui \
|
||||
grpChannel.ui \
|
||||
|
77
frontend_qt/grpC25.ui
Normal file
77
frontend_qt/grpC25.ui
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>grpC25</class>
|
||||
<widget class="QWidget" name="grpC25">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>254</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radC25Stand">
|
||||
<property name="text">
|
||||
<string>&No Check Digit</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>No check digit added</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="radC25Check">
|
||||
<property name="text">
|
||||
<string>&Check Digit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add standard GS1 mod-10 weighted check digit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radC25CheckHide">
|
||||
<property name="text">
|
||||
<string>Check Digit, Not Shown in &Text</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add standard GS1 check digit but do not display in Human Readable Text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -37,7 +37,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QWidget(parent, fl), m_optionWidget(NULL), m_symbology(0)
|
||||
: QWidget(parent, fl), m_optionWidget(nullptr), m_symbology(0)
|
||||
{
|
||||
m_bc.bc.setDebug(QCoreApplication::arguments().contains("--verbose")); // Undocumented command line debug flag
|
||||
|
||||
@ -713,6 +713,21 @@ void MainWindow::change_options()
|
||||
connect(m_optionWidget->findChild<QObject*>("radC11NoCheckDigits"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
}
|
||||
|
||||
if (symbology == BARCODE_C25STANDARD || symbology == BARCODE_C25INTER || symbology == BARCODE_C25IATA
|
||||
|| symbology == BARCODE_C25LOGIC || symbology == BARCODE_C25IND)
|
||||
{
|
||||
QFile file(":/grpC25.ui");
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
m_optionWidget = uiload.load(&file);
|
||||
file.close();
|
||||
static const char *names[] = { "Standard (Matrix)", "Interleaved", "IATA", "", "Data Logic", "Industrial" };
|
||||
tabMain->insertTab(1, m_optionWidget, tr("Cod&e 2 of 5 %1").arg(names[symbology - BARCODE_C25STANDARD]));
|
||||
connect(m_optionWidget->findChild<QObject*>("radC25Stand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("radC25Check"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
connect(m_optionWidget->findChild<QObject*>("radC25CheckHide"), SIGNAL(clicked( bool )), SLOT(update_preview()));
|
||||
}
|
||||
}
|
||||
|
||||
if ((symbology == BARCODE_CODE39) || (symbology == BARCODE_EXCODE39))
|
||||
{
|
||||
QFile file(":/grpC39.ui");
|
||||
@ -1334,6 +1349,15 @@ void MainWindow::update_preview()
|
||||
}
|
||||
break;
|
||||
|
||||
case BARCODE_C25STANDARD:
|
||||
case BARCODE_C25INTER:
|
||||
case BARCODE_C25IATA:
|
||||
case BARCODE_C25LOGIC:
|
||||
case BARCODE_C25IND:
|
||||
m_bc.bc.setSymbol(symbology);
|
||||
m_bc.bc.setOption2(get_button_group_index(QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide"));
|
||||
break;
|
||||
|
||||
case BARCODE_CODE39:
|
||||
if(m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->isChecked())
|
||||
m_bc.bc.setSymbol(BARCODE_HIBC_39);
|
||||
@ -1809,6 +1833,7 @@ const char *MainWindow::get_setting_name(int symbology) {
|
||||
|
||||
/* Helper to return index of selected radio button in group, checking for NULL */
|
||||
int MainWindow::get_button_group_index(const QStringList &children) {
|
||||
if (m_optionWidget) {
|
||||
QRadioButton *radioButton;
|
||||
for (int index = 0; index < children.size(); index++) {
|
||||
radioButton = m_optionWidget->findChild<QRadioButton*>(children[index]);
|
||||
@ -1816,11 +1841,13 @@ int MainWindow::get_button_group_index(const QStringList &children) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper to set radio button in group from index in settings, checking for NULL */
|
||||
void MainWindow::set_radiobutton_from_setting(QSettings &settings, const QString &setting, const QStringList &children, int default_val) {
|
||||
if (m_optionWidget) {
|
||||
int index = settings.value(setting, default_val).toInt();
|
||||
QRadioButton *radioButton;
|
||||
if (index >= 0 && index < children.size()) {
|
||||
@ -1832,16 +1859,17 @@ void MainWindow::set_radiobutton_from_setting(QSettings &settings, const QString
|
||||
radioButton->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Helper to return index of selected item in combobox, checking for NULL */
|
||||
int MainWindow::get_combobox_index(const QString &child) {
|
||||
QComboBox *comboBox = m_optionWidget->findChild<QComboBox*>(child);
|
||||
QComboBox *comboBox = m_optionWidget ? m_optionWidget->findChild<QComboBox*>(child) : nullptr;
|
||||
return comboBox ? comboBox->currentIndex() : 0;
|
||||
}
|
||||
|
||||
/* Helper to set item in combobox from index in settings, checking for NULL */
|
||||
void MainWindow::set_combobox_from_setting(QSettings &settings, const QString &setting, const QString &child, int default_val) {
|
||||
QComboBox *comboBox = m_optionWidget->findChild<QComboBox*>(child);
|
||||
QComboBox *comboBox = m_optionWidget ? m_optionWidget->findChild<QComboBox*>(child) : nullptr;
|
||||
if (comboBox) {
|
||||
comboBox->setCurrentIndex(settings.value(setting, default_val).toInt());
|
||||
}
|
||||
@ -1849,13 +1877,13 @@ void MainWindow::set_combobox_from_setting(QSettings &settings, const QString &s
|
||||
|
||||
/* Helper to return if checkbox checked, checking for NULL */
|
||||
int MainWindow::get_checkbox_val(const QString &child) {
|
||||
QCheckBox *checkBox = m_optionWidget->findChild<QCheckBox*>(child);
|
||||
QCheckBox *checkBox = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(child) : nullptr;
|
||||
return checkBox && checkBox->isChecked() ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Helper to set checkbox from settings, checking for NULL */
|
||||
void MainWindow::set_checkbox_from_setting(QSettings &settings, const QString &setting, const QString &child, int default_val) {
|
||||
QCheckBox *checkBox = m_optionWidget->findChild<QCheckBox*>(child);
|
||||
QCheckBox *checkBox = m_optionWidget ? m_optionWidget->findChild<QCheckBox*>(child) : nullptr;
|
||||
if (checkBox) {
|
||||
checkBox->setChecked(settings.value(setting, default_val).toInt() ? true : false);
|
||||
}
|
||||
@ -1863,13 +1891,13 @@ void MainWindow::set_checkbox_from_setting(QSettings &settings, const QString &s
|
||||
|
||||
/* Helper to return text of line edit, checking for NULL */
|
||||
QString MainWindow::get_lineedit_val(const QString &child) {
|
||||
QLineEdit *lineEdit = m_optionWidget->findChild<QLineEdit*>(child);
|
||||
QLineEdit *lineEdit = m_optionWidget ? m_optionWidget->findChild<QLineEdit*>(child) : nullptr;
|
||||
return lineEdit ? lineEdit->text() : "";
|
||||
}
|
||||
|
||||
/* Helper to set line edit from settings, checking for NULL */
|
||||
void MainWindow::set_lineedit_from_setting(QSettings &settings, const QString &setting, const QString &child, const char *default_val) {
|
||||
QLineEdit *lineEdit = m_optionWidget->findChild<QLineEdit*>(child);
|
||||
QLineEdit *lineEdit = m_optionWidget ? m_optionWidget->findChild<QLineEdit*>(child) : nullptr;
|
||||
if (lineEdit) {
|
||||
lineEdit->setText(settings.value(setting, default_val).toString());
|
||||
}
|
||||
@ -1877,13 +1905,13 @@ void MainWindow::set_lineedit_from_setting(QSettings &settings, const QString &s
|
||||
|
||||
/* Helper to return value of spin box, checking for NULL */
|
||||
int MainWindow::get_spinbox_val(const QString &child) {
|
||||
QSpinBox *spinBox = m_optionWidget->findChild<QSpinBox*>(child);
|
||||
QSpinBox *spinBox = m_optionWidget ? m_optionWidget->findChild<QSpinBox*>(child) : nullptr;
|
||||
return spinBox ? spinBox->value() : 0;
|
||||
}
|
||||
|
||||
/* Helper to set spin box from settings, checking for NULL */
|
||||
void MainWindow::set_spinbox_from_setting(QSettings &settings, const QString &setting, const QString &child, int default_val) {
|
||||
QSpinBox *spinBox = m_optionWidget->findChild<QSpinBox*>(child);
|
||||
QSpinBox *spinBox = m_optionWidget ? m_optionWidget->findChild<QSpinBox*>(child) : nullptr;
|
||||
if (spinBox) {
|
||||
spinBox->setValue(settings.value(setting, default_val).toInt());
|
||||
}
|
||||
@ -1982,6 +2010,22 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) {
|
||||
settings.setValue("studio/bc/code11/check_digit", get_button_group_index(QStringList() << "radC11TwoCheckDigits" << "radC11OneCheckDigit" << "radC11NoCheckDigits"));
|
||||
break;
|
||||
|
||||
case BARCODE_C25STANDARD:
|
||||
settings.setValue("studio/bc/c25standard/check_digit", get_button_group_index(QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide"));
|
||||
break;
|
||||
case BARCODE_C25INTER:
|
||||
settings.setValue("studio/bc/c25inter/check_digit", get_button_group_index(QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide"));
|
||||
break;
|
||||
case BARCODE_C25IATA:
|
||||
settings.setValue("studio/bc/c25iata/check_digit", get_button_group_index(QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide"));
|
||||
break;
|
||||
case BARCODE_C25LOGIC:
|
||||
settings.setValue("studio/bc/c25logic/check_digit", get_button_group_index(QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide"));
|
||||
break;
|
||||
case BARCODE_C25IND:
|
||||
settings.setValue("studio/bc/c25ind/check_digit", get_button_group_index(QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide"));
|
||||
break;
|
||||
|
||||
case BARCODE_CODE39:
|
||||
case BARCODE_HIBC_39:
|
||||
settings.setValue("studio/bc/code39/check_digit", get_button_group_index(QStringList() << "radC39Stand" << "radC39Check" << "radC39HIBC"));
|
||||
@ -2212,6 +2256,22 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) {
|
||||
set_radiobutton_from_setting(settings, "studio/bc/code11/check_digit", QStringList() << "radC11TwoCheckDigits" << "radC11OneCheckDigit" << "radC11NoCheckDigits");
|
||||
break;
|
||||
|
||||
case BARCODE_C25STANDARD:
|
||||
set_radiobutton_from_setting(settings, "studio/bc/c25standard/check_digit", QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide");
|
||||
break;
|
||||
case BARCODE_C25INTER:
|
||||
set_radiobutton_from_setting(settings, "studio/bc/c25inter/check_digit", QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide");
|
||||
break;
|
||||
case BARCODE_C25IATA:
|
||||
set_radiobutton_from_setting(settings, "studio/bc/c25iata/check_digit", QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide");
|
||||
break;
|
||||
case BARCODE_C25LOGIC:
|
||||
set_radiobutton_from_setting(settings, "studio/bc/c25logic/check_digit", QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide");
|
||||
break;
|
||||
case BARCODE_C25IND:
|
||||
set_radiobutton_from_setting(settings, "studio/bc/c25ind/check_digit", QStringList() << "radC25Stand" << "radC25Check" << "radC25CheckHide");
|
||||
break;
|
||||
|
||||
case BARCODE_CODE39:
|
||||
case BARCODE_HIBC_39:
|
||||
set_radiobutton_from_setting(settings, "studio/bc/code39/check_digit", QStringList() << "radC39Stand" << "radC39Check" << "radC39HIBC");
|
||||
|
@ -6,6 +6,7 @@
|
||||
<file>images/zoomin.png</file>
|
||||
<file>grpAztec.ui</file>
|
||||
<file>grpC11.ui</file>
|
||||
<file>grpC25.ui</file>
|
||||
<file>grpC39.ui</file>
|
||||
<file>grpDM.ui</file>
|
||||
<file>grpMSICheck.ui</file>
|
||||
|
Loading…
Reference in New Issue
Block a user