GUI: add CLI equivalent dialog (#163); use spinboxes in Sequence dialog

and restrict sequence to max 10,000, add button icons;
   make Export dialog sizable and show every 100 results, add button icon;
   fix saving CHANNEL option, fix Export painting main window (Windows), fix
   guard descent not-resetting
 qzint: add getAsCLI(), warnLevel(), extra isStackable()/isComposite() etc
 Add ZBarcode_BarcodeName()
 manual: doc above, some fixes, tweaks
This commit is contained in:
gitlost
2021-11-23 19:12:48 +00:00
parent 9d85c425f4
commit 739a64a6ff
34 changed files with 2264 additions and 1199 deletions

View File

@ -31,49 +31,39 @@
/* Qt 5.7 did not require it. */
#include <QPainterPath>
// Shorthand
#define QSL QStringLiteral
namespace Zint {
static const char *fontStyle = "Helvetica";
static const char *fontStyleError = "Helvetica";
static const int fontSizeError = 14; /* Point size */
QZint::QZint() {
m_zintSymbol = NULL;
m_symbol = BARCODE_CODE128;
m_height = 0.0f;
m_borderType = 0;
m_borderWidth = 0;
m_fontSetting = 0;
m_option_1 = -1;
m_option_2 = 0;
m_option_3 = 0;
m_fgColor = Qt::black;
m_bgColor = Qt::white;
m_cmyk = false;
m_error = 0;
m_input_mode = UNICODE_MODE;
m_scale = 1.0f;
m_show_hrt = 1;
m_eci = 0;
m_dotty = false;
m_dot_size = 4.0f / 5.0f;
m_guardDescent = 5.0f;
QZint::QZint()
: m_zintSymbol(NULL), m_symbol(BARCODE_CODE128), m_input_mode(UNICODE_MODE),
m_height(0.0f),
m_option_1(-1), m_option_2(0), m_option_3(0),
m_scale(1.0f),
m_dotty(false), m_dot_size(4.0f / 5.0f),
m_guardDescent(5.0f),
m_fgColor(Qt::black), m_bgColor(Qt::white), m_cmyk(false),
m_borderType(0), m_borderWidth(0),
m_whitespace(0), m_vwhitespace(0),
m_fontSetting(0),
m_show_hrt(true),
m_gssep(false),
m_quiet_zones(false), m_no_quiet_zones(false),
m_compliant_height(false),
m_rotate_angle(0),
m_eci(0),
m_gs1parens(false), m_gs1nocheck(false),
m_reader_init(false),
m_warn_level(WARN_DEFAULT), m_debug(false),
m_encodedWidth(0), m_encodedRows(0),
m_error(0),
target_size_horiz(0), target_size_vert(0) // Legacy
{
memset(&m_structapp, 0, sizeof(m_structapp));
m_whitespace = 0;
m_vwhitespace = 0;
m_gs1parens = false;
m_gs1nocheck = false;
m_gssep = false;
m_quiet_zones = false;
m_no_quiet_zones = false;
m_compliant_height = false;
m_reader_init = false;
m_rotate_angle = 0;
m_debug = false;
m_encodedWidth = 0;
m_encodedRows = 0;
target_size_horiz = 0; /* Legacy */
target_size_vert = 0; /* Legacy */
}
QZint::~QZint() {
@ -127,16 +117,19 @@ namespace Zint {
if (m_reader_init) {
m_zintSymbol->output_options |= READER_INIT;
}
if (m_warn_level) {
m_zintSymbol->warn_level = m_warn_level;
}
if (m_debug) {
m_zintSymbol->debug |= ZINT_DEBUG_PRINT;
}
strcpy(m_zintSymbol->fgcolour, m_fgColor.name().toLatin1().right(6));
if (m_fgColor.alpha() != 0xff) {
if (m_fgColor.alpha() != 0xFF) {
strcat(m_zintSymbol->fgcolour, m_fgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
strcpy(m_zintSymbol->bgcolour, m_bgColor.name().toLatin1().right(6));
if (m_bgColor.alpha() != 0xff) {
if (m_bgColor.alpha() != 0xFF) {
strcat(m_zintSymbol->bgcolour, m_bgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
if (m_cmyk) {
@ -507,6 +500,14 @@ namespace Zint {
m_reader_init = readerInit;
}
int QZint::warnLevel() const {
return m_warn_level;
}
void QZint::setWarnLevel(int warnLevel) {
m_warn_level = warnLevel;
}
bool QZint::debug() const {
return m_debug;
}
@ -541,10 +542,18 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_HRT);
}
bool QZint::isStackable(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_STACKABLE);
}
bool QZint::isExtendable(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_EXTENDABLE);
}
bool QZint::isComposite(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_COMPOSITE);
}
bool QZint::supportsECI(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_ECI);
}
@ -553,6 +562,10 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_GS1);
}
bool QZint::isDotty(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_DOTTY);
}
bool QZint::hasDefaultQuietZones(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_QUIET_ZONES);
}
@ -561,14 +574,22 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_FIXED_RATIO);
}
bool QZint::isDotty(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_DOTTY);
}
bool QZint::supportsReaderInit(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_READER_INIT);
}
bool QZint::supportsFullMultibyte(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_FULL_MULTIBYTE);
}
bool QZint::hasMask(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_MASK);
}
bool QZint::supportsStructApp(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_STRUCTAPP);
}
bool QZint::hasCompliantHeight(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_COMPLIANT_HEIGHT);
}
@ -589,7 +610,7 @@ namespace Zint {
return ZBarcode_Version();
}
bool QZint::save_to_file(QString filename) {
bool QZint::save_to_file(const QString &filename) {
resetSymbol();
strcpy(m_zintSymbol->outfile, filename.toLatin1().left(255));
QByteArray bstr = m_text.toUtf8();
@ -796,4 +817,239 @@ namespace Zint {
painter.restore();
}
/* Translate settings into Command Line equivalent. Set `win` to use Windows escaping of data.
If `autoHeight` set then `--height=` option will not be emitted.
If HEIGHTPERROW_MODE set and non-zero `heightPerRow` given then use that for height instead of internal
height */
QString QZint::getAsCLI(const bool win, const bool longOptOnly, const bool barcodeNames,
const bool autoHeight, const float heightPerRow, const QString &outfile) const {
QString cmd(win ? QSL("zint.exe") : QSL("zint"));
char name_buf[32];
if (barcodeNames && ZBarcode_BarcodeName(m_symbol, name_buf) == 0) {
QString name(name_buf + 8); // Strip "BARCODE_" prefix
arg_str(cmd, longOptOnly ? "--barcode=" : "-b ", name);
} else {
arg_int(cmd, longOptOnly ? "--barcode=" : "-b ", m_symbol);
}
if (isExtendable()) {
arg_int(cmd, "--addongap=", option2());
}
if (bgColor() != Qt::white && bgColor() != QColor(0xFF, 0xFF, 0xFF, 0)) {
arg_color(cmd, "--bg=", bgColor());
}
arg_bool(cmd, "--binary", (inputMode() & 0x07) == DATA_MODE);
arg_bool(cmd, "--bind", (borderType() & BARCODE_BIND) && !(borderType() & BARCODE_BOX));
arg_bool(cmd, "--bold", fontSetting() & BOLD_TEXT);
arg_int(cmd, "--border=", borderWidth());
arg_bool(cmd, "--box", borderType() & BARCODE_BOX);
arg_bool(cmd, "--cmyk", cmyk());
if (m_symbol == BARCODE_DBAR_EXPSTK || m_symbol == BARCODE_DBAR_EXPSTK_CC
|| m_symbol == BARCODE_PDF417 || m_symbol == BARCODE_PDF417COMP || m_symbol == BARCODE_HIBC_PDF
|| m_symbol == BARCODE_MICROPDF417 || m_symbol == BARCODE_HIBC_MICPDF
|| m_symbol == BARCODE_DOTCODE || m_symbol == BARCODE_CODABLOCKF || m_symbol == BARCODE_HIBC_BLOCKF) {
arg_int(cmd, "--cols=", option2());
}
arg_bool(cmd, "--compliantheight", hasCompliantHeight() && compliantHeight());
arg_data(cmd, longOptOnly ? "--data=" : "-d ", text(), win);
if (m_symbol == BARCODE_DATAMATRIX || m_symbol == BARCODE_HIBC_DM) {
arg_bool(cmd, "--dmre", option3() == DM_DMRE);
}
if ((m_symbol == BARCODE_DOTCODE || (isDotty() && dotty())) && dotSize() != 0.8f) {
arg_float(cmd, "--dotsize=", dotSize());
}
if (m_symbol != BARCODE_DOTCODE && isDotty() && dotty()) {
arg_bool(cmd, "--dotty", dotty());
}
if (supportsECI()) {
arg_int(cmd, "--eci=", eci());
}
arg_bool(cmd, "--esc", inputMode() & ESCAPE_MODE);
if (fgColor() != Qt::black) {
arg_color(cmd, "--fg=", fgColor());
}
arg_bool(cmd, "--fullmultibyte", supportsFullMultibyte() && (option3() & 0xFF) == ZINT_FULL_MULTIBYTE);
if (supportsGS1()) {
arg_bool(cmd, "--gs1", (inputMode() & 0x07) == GS1_MODE);
arg_bool(cmd, "--gs1parens", gs1Parens());
arg_bool(cmd, "--gs1nocheck", gs1NoCheck());
arg_bool(cmd, "--gssep", gsSep());
}
if (isExtendable() && guardDescent() != 5.0f) {
arg_float(cmd, "--guarddescent=", guardDescent(), true /*allowZero*/);
}
if (!autoHeight && !isFixedRatio()) {
if (inputMode() & HEIGHTPERROW_MODE) {
arg_float(cmd, "--height=", heightPerRow ? heightPerRow : height());
arg_bool(cmd, "--heightperrow", true);
} else {
arg_float(cmd, "--height=", height());
}
}
arg_bool(cmd, "--init", supportsReaderInit() && readerInit());
if (hasMask()) {
arg_int(cmd, "--mask=", (option3() >> 8) - 1, true /*allowZero*/);
}
if (m_symbol == BARCODE_MAXICODE || isComposite()) {
arg_int(cmd, "--mode=", option1());
}
arg_bool(cmd, "--nobackground", bgColor() == QColor(0xFF, 0xFF, 0xFF, 0));
arg_bool(cmd, "--noquietzones", hasDefaultQuietZones() && noQuietZones());
arg_bool(cmd, "--notext", hasHRT() && !showText());
arg_data(cmd, longOptOnly ? "--output=" : "-o ", outfile, win);
if (m_symbol == BARCODE_MAXICODE || isComposite()) {
arg_data(cmd, "--primary=", primaryMessage(), win);
}
arg_bool(cmd, "--quietzones", !hasDefaultQuietZones() && quietZones());
arg_int(cmd, "--rotate=", rotateAngle());
if (m_symbol == BARCODE_CODE16K || m_symbol == BARCODE_CODABLOCKF || m_symbol == BARCODE_HIBC_BLOCKF
|| m_symbol == BARCODE_CODE49) {
arg_int(cmd, "--rows=", option1());
} else if (m_symbol == BARCODE_DBAR_EXPSTK || m_symbol == BARCODE_DBAR_EXPSTK_CC
|| m_symbol == BARCODE_PDF417 || m_symbol == BARCODE_PDF417COMP || m_symbol == BARCODE_HIBC_PDF) {
arg_int(cmd, "--rows=", option3());
}
if (scale() != 1.0f) {
arg_float(cmd, "--scale=", scale());
}
if (m_symbol == BARCODE_MAXICODE) {
arg_int(cmd, "--scmvv=", option2() - 1, true /*allowZero*/);
}
if (m_symbol == BARCODE_PDF417 || m_symbol == BARCODE_PDF417COMP || m_symbol == BARCODE_HIBC_PDF
|| m_symbol == BARCODE_AZTEC || m_symbol == BARCODE_HIBC_AZTEC
|| m_symbol == BARCODE_QRCODE || m_symbol == BARCODE_HIBC_QR || m_symbol == BARCODE_MICROQR
|| m_symbol == BARCODE_RMQR || m_symbol == BARCODE_GRIDMATRIX || m_symbol == BARCODE_HANXIN
|| m_symbol == BARCODE_ULTRA) {
arg_int(cmd, "--secure=", option1());
}
if (m_symbol == BARCODE_CODE16K || m_symbol == BARCODE_CODABLOCKF || m_symbol == BARCODE_HIBC_BLOCKF
|| m_symbol == BARCODE_CODE49) {
arg_int(cmd, "--separator=", option3());
}
arg_bool(cmd, "--small", fontSetting() & SMALL_TEXT);
if (m_symbol == BARCODE_DATAMATRIX || m_symbol == BARCODE_HIBC_DM) {
arg_bool(cmd, "--square", option3() == DM_SQUARE);
}
if (supportsStructApp()) {
arg_structapp(cmd, "--structapp=", structAppCount(), structAppIndex(), structAppID(), win);
}
arg_bool(cmd, "--verbose", debug());
if (m_symbol == BARCODE_AZTEC || m_symbol == BARCODE_HIBC_AZTEC
|| m_symbol == BARCODE_MSI_PLESSEY || m_symbol == BARCODE_CODE11
|| m_symbol == BARCODE_C25STANDARD || m_symbol == BARCODE_C25INTER || m_symbol == BARCODE_C25IATA
|| m_symbol == BARCODE_C25LOGIC || m_symbol == BARCODE_C25IND
|| m_symbol == BARCODE_CODE39 || m_symbol == BARCODE_HIBC_39 || m_symbol == BARCODE_EXCODE39
|| m_symbol == BARCODE_LOGMARS || m_symbol == BARCODE_CODABAR
|| m_symbol == BARCODE_DATAMATRIX || m_symbol == BARCODE_HIBC_DM
|| m_symbol == BARCODE_QRCODE || m_symbol == BARCODE_HIBC_QR || m_symbol == BARCODE_MICROQR
|| m_symbol == BARCODE_RMQR || m_symbol == BARCODE_GRIDMATRIX || m_symbol == BARCODE_HANXIN
|| m_symbol == BARCODE_CHANNEL || m_symbol == BARCODE_CODEONE || m_symbol == BARCODE_CODE93
|| m_symbol == BARCODE_ULTRA || m_symbol == BARCODE_VIN) {
arg_int(cmd, "--vers=", option2());
} else if (m_symbol == BARCODE_DAFT && option2() != 250) {
arg_int(cmd, "--vers=", option2());
}
arg_int(cmd, "--vwhitesp=", vWhitespace());
arg_int(cmd, longOptOnly ? "--whitesp=" : "-w ", whitespace());
arg_bool(cmd, "--werror", warnLevel() == WARN_FAIL_ALL);
return cmd;
}
/* `getAsCLI()` helpers */
void QZint::arg_str(QString &cmd, const char *const opt, const QString &val) {
if (!val.isEmpty()) {
QByteArray bstr = val.toUtf8();
cmd += QString::asprintf(" %s%.*s", opt, bstr.length(), bstr.data());
}
}
void QZint::arg_int(QString &cmd, const char *const opt, const int val, const bool allowZero) {
if (val > 0 || (val == 0 && allowZero)) {
cmd += QString::asprintf(" %s%d", opt, val);
}
}
void QZint::arg_bool(QString &cmd, const char *const opt, const bool val) {
if (val) {
cmd += QString::asprintf(" %s", opt);
}
}
void QZint::arg_color(QString &cmd, const char *const opt, const QColor val) {
if (val.alpha() != 0xFF) {
cmd += QString::asprintf(" %s%02X%02X%02X%02X", opt, val.red(), val.green(), val.blue(), val.alpha());
} else {
cmd += QString::asprintf(" %s%02X%02X%02X", opt, val.red(), val.green(), val.blue());
}
}
void QZint::arg_data(QString &cmd, const char *const opt, const QString &val, const bool win) {
if (!val.isEmpty()) {
QString text(val);
const char delim = win ? '"' : '\'';
if (win) {
// Difficult (impossible?) to fully escape strings on Windows, e.g. "blah%PATH%" will substitute
// env var PATH, so just doing basic escaping here
text.replace("\\\\", "\\\\\\\\"); // Double-up backslashed backslash `\\` -> `\\\\`
text.replace("\"", "\\\""); // Backslash quote `"` -> `\"`
QByteArray bstr = text.toUtf8();
cmd += QString::asprintf(" %s%c%.*s%c", opt, delim, bstr.length(), bstr.data(), delim);
} else {
text.replace("'", "'\\''"); // Single quote `'` -> `'\''`
QByteArray bstr = text.toUtf8();
cmd += QString::asprintf(" %s%c%.*s%c", opt, delim, bstr.length(), bstr.data(), delim);
}
}
}
void QZint::arg_float(QString &cmd, const char *const opt, const float val, const bool allowZero) {
if (val > 0 || (val == 0 && allowZero)) {
cmd += QString::asprintf(" %s%g", opt, val);
}
}
void QZint::arg_structapp(QString &cmd, const char *const opt, const int count, const int index,
const QString &id, const bool win) {
if (count >= 2 && index >= 1) {
if (id.isEmpty()) {
cmd += QString::asprintf(" %s%d,%d", opt, index, count);
} else {
QByteArray bstr = id.toUtf8();
arg_data(cmd, opt, QString::asprintf("%d,%d,%.*s", index, count, bstr.length(), bstr.data()), win);
}
}
}
} /* namespace Zint */

View File

@ -136,6 +136,9 @@ public:
bool readerInit() const;
void setReaderInit(bool readerInit);
int warnLevel() const;
void setWarnLevel(int warnLevel);
bool debug() const;
void setDebug(bool debug);
@ -155,13 +158,18 @@ public:
/* Test capabilities - ZBarcode_Cap() */
bool hasHRT(int symbology = 0) const;
bool isStackable(int symbology = 0) const;
bool isExtendable(int symbology = 0) const;
bool isComposite(int symbology = 0) const;
bool supportsECI(int symbology = 0) const;
bool supportsGS1(int symbology = 0) const;
bool isDotty(int symbology = 0) const;
bool hasDefaultQuietZones(int symbology = 0) const;
bool isFixedRatio(int symbology = 0) const;
bool isDotty(int symbology = 0) const;
bool supportsReaderInit(int symbology = 0) const;
bool supportsFullMultibyte(int symbology = 0) const;
bool hasMask(int symbology = 0) const;
bool supportsStructApp(int symbology = 0) const;
bool hasCompliantHeight(int symbology = 0) const;
int getError() const;
@ -169,13 +177,20 @@ public:
const QString& lastError() const;
bool hasErrors() const;
bool save_to_file(QString filename);
bool save_to_file(const QString &filename);
/* Note: legacy argument `mode` is not used */
void render(QPainter& painter, const QRectF& paintRect, AspectRatioMode mode = IgnoreAspectRatio);
int getVersion() const;
/* Translate settings into Command Line equivalent. Set `win` to use Windows escaping of data.
If `autoHeight` set then `--height=` option will not be emitted.
If HEIGHTPERROW_MODE set and non-zero `heightPerRow` given then use that for height instead of internal
height */
QString getAsCLI(const bool win, const bool longOptOnly = false, const bool barcodeNames = false,
const bool autoHeight = false, const float heightPerRow = 0.0f, const QString &outfile = "") const;
signals:
void encoded();
void errored();
@ -185,44 +200,55 @@ private:
void encode();
static Qt::GlobalColor colourToQtColor(int colour);
/* `getAsCLI()` helpers */
static void arg_str(QString &cmd, const char *const opt, const QString &val);
static void arg_int(QString &cmd, const char *const opt, const int val, const bool allowZero = false);
static void arg_bool(QString &cmd, const char *const opt, const bool val);
static void arg_color(QString &cmd, const char *const opt, const QColor val);
static void arg_data(QString &cmd, const char *const opt, const QString &val, const bool win);
static void arg_float(QString &cmd, const char *const opt, const float val, const bool allowZero = false);
static void arg_structapp(QString &cmd, const char *const opt, const int count, const int index,
const QString &id, const bool win);
private:
zint_symbol *m_zintSymbol;
int m_symbol;
int m_input_mode;
QString m_text;
QString m_primaryMessage;
float m_height;
int m_borderType;
int m_borderWidth;
int m_fontSetting;
int m_option_1;
int m_option_2;
int m_option_3;
int m_input_mode;
QColor m_fgColor;
QColor m_bgColor;
bool m_cmyk;
QString m_lastError;
int m_error;
int m_whitespace;
int m_vwhitespace;
zint_symbol * m_zintSymbol;
float m_scale;
bool m_show_hrt;
int m_eci;
int m_rotate_angle;
bool m_dotty;
float m_dot_size;
float m_guardDescent;
struct zint_structapp m_structapp;
bool m_gs1parens;
bool m_gs1nocheck;
QColor m_fgColor;
QColor m_bgColor;
bool m_cmyk;
int m_borderType;
int m_borderWidth;
int m_whitespace;
int m_vwhitespace;
int m_fontSetting;
bool m_show_hrt;
bool m_gssep;
bool m_quiet_zones;
bool m_no_quiet_zones;
bool m_compliant_height;
int m_rotate_angle;
int m_eci;
bool m_gs1parens;
bool m_gs1nocheck;
bool m_reader_init;
int m_warn_level;
bool m_debug;
int m_encodedWidth;
int m_encodedRows;
QString m_lastError;
int m_error;
int target_size_horiz; /* Legacy */
int target_size_vert; /* Legacy */

View File

@ -220,6 +220,10 @@ private slots:
bc.setReaderInit(readerInit);
QCOMPARE(bc.readerInit(), readerInit);
int warnLevel = WARN_FAIL_ALL;
bc.setWarnLevel(warnLevel);
QCOMPARE(bc.warnLevel(), warnLevel);
bool debug = true;
bc.setDebug(debug);
QCOMPARE(bc.debug(), debug);
@ -286,10 +290,19 @@ private slots:
QTest::addColumn<int>("symbology");
QTest::addColumn<int>("cap_flag");
QTest::newRow("BARCODE_CODE11") << BARCODE_CODE11 << (ZINT_CAP_HRT);
QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << (ZINT_CAP_HRT | ZINT_CAP_READER_INIT);
QTest::newRow("BARCODE_EANX") << BARCODE_EANX << (ZINT_CAP_HRT | ZINT_CAP_EXTENDABLE | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT);
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << (ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO);
QTest::newRow("BARCODE_CODE11") << BARCODE_CODE11
<< (ZINT_CAP_HRT | ZINT_CAP_STACKABLE);
QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128
<< (ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_READER_INIT);
QTest::newRow("BARCODE_EANX") << BARCODE_EANX
<< (ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_QUIET_ZONES
| ZINT_CAP_COMPLIANT_HEIGHT);
QTest::newRow("BARCODE_EANX_CC") << BARCODE_EANX_CC
<< (ZINT_CAP_HRT | ZINT_CAP_EXTENDABLE | ZINT_CAP_COMPOSITE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES
| ZINT_CAP_COMPLIANT_HEIGHT);
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE
<< (ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE
| ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP);
}
void capTest()
@ -301,13 +314,18 @@ private slots:
bc.setSymbol(symbology);
QCOMPARE(bc.hasHRT(), (cap_flag & ZINT_CAP_HRT) != 0);
QCOMPARE(bc.isStackable(), (cap_flag & ZINT_CAP_STACKABLE) != 0);
QCOMPARE(bc.isExtendable(), (cap_flag & ZINT_CAP_EXTENDABLE) != 0);
QCOMPARE(bc.isComposite(), (cap_flag & ZINT_CAP_COMPOSITE) != 0);
QCOMPARE(bc.supportsECI(), (cap_flag & ZINT_CAP_ECI) != 0);
QCOMPARE(bc.supportsGS1(), (cap_flag & ZINT_CAP_GS1) != 0);
QCOMPARE(bc.isDotty(), (cap_flag & ZINT_CAP_DOTTY) != 0);
QCOMPARE(bc.hasDefaultQuietZones(), (cap_flag & ZINT_CAP_QUIET_ZONES) != 0);
QCOMPARE(bc.isFixedRatio(), (cap_flag & ZINT_CAP_FIXED_RATIO) != 0);
QCOMPARE(bc.isDotty(), (cap_flag & ZINT_CAP_DOTTY) != 0);
QCOMPARE(bc.supportsReaderInit(), (cap_flag & ZINT_CAP_READER_INIT) != 0);
QCOMPARE(bc.supportsFullMultibyte(), (cap_flag & ZINT_CAP_FULL_MULTIBYTE) != 0);
QCOMPARE(bc.hasMask(), (cap_flag & ZINT_CAP_MASK) != 0);
QCOMPARE(bc.supportsStructApp(), (cap_flag & ZINT_CAP_STRUCTAPP) != 0);
QCOMPARE(bc.hasCompliantHeight(), (cap_flag & ZINT_CAP_COMPLIANT_HEIGHT) != 0);
}
@ -409,6 +427,453 @@ private slots:
QCOMPARE(ret, 0);
}
}
void getAsCLITest_data()
{
QTest::addColumn<bool>("autoHeight");
QTest::addColumn<float>("heightPerRow");
QTest::addColumn<QString>("outfile");
QTest::addColumn<int>("symbology");
QTest::addColumn<int>("inputMode");
QTest::addColumn<QString>("text");
QTest::addColumn<QString>("primary");
QTest::addColumn<float>("height");
QTest::addColumn<int>("option1");
QTest::addColumn<int>("option2");
QTest::addColumn<int>("option3");
QTest::addColumn<float>("scale");
QTest::addColumn<bool>("dotty");
QTest::addColumn<float>("dotSize");
QTest::addColumn<float>("guardDescent");
QTest::addColumn<int>("structAppCount");
QTest::addColumn<int>("structAppIndex");
QTest::addColumn<QString>("structAppID");
QTest::addColumn<QColor>("fgColor");
QTest::addColumn<QColor>("bgColor");
QTest::addColumn<bool>("cmyk");
QTest::addColumn<int>("borderTypeIndex");
QTest::addColumn<int>("borderWidth");
QTest::addColumn<int>("whitespace");
QTest::addColumn<int>("vWhitespace");
QTest::addColumn<int>("fontSetting");
QTest::addColumn<bool>("showText");
QTest::addColumn<bool>("gsSep");
QTest::addColumn<bool>("quietZones");
QTest::addColumn<bool>("noQuietZones");
QTest::addColumn<bool>("compliantHeight");
QTest::addColumn<int>("rotateAngle");
QTest::addColumn<int>("eci");
QTest::addColumn<bool>("gs1Parens");
QTest::addColumn<bool>("gs1NoCheck");
QTest::addColumn<bool>("readerInit");
QTest::addColumn<int>("warnLevel");
QTest::addColumn<bool>("debug");
QTest::addColumn<QString>("expected_cmd");
QTest::addColumn<QString>("expected_win");
QTest::addColumn<QString>("expected_longOptOnly");
QTest::addColumn<QString>("expected_barcodeNames");
QTest::newRow("BARCODE_AUSPOST") << true << 0.0f << ""
<< BARCODE_AUSPOST << DATA_MODE // symbology-inputMode
<< "12345678" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 63 --binary --compliantheight -d '12345678'"
<< "zint.exe -b 63 --binary --compliantheight -d \"12345678\""
<< "zint --barcode=63 --binary --compliantheight --data='12345678'"
<< "zint -b AUSPOST --binary --compliantheight -d '12345678'";
QTest::newRow("BARCODE_AZTEC") << false << 0.0f << ""
<< BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode
<< "12345678Ж0%var%" << "" // text-primary
<< 0.0f << 1 << 0 << 0 << 4.0f << true << 0.9f // height-dotSize
<< 5.0f << 2 << 1 << "as\"dfa'sdf" << QColor(Qt::blue) << QColor(Qt::white) // guardDescent-bgColor
<< true << 0 << 0 << 2 << 3 << 0 // cmyk-fontSetting
<< true << false << false << false << false << 0 // showText-rotateAngle
<< 7 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 92 --cmyk -d '12345678Ж0%var%' --dotsize=0.9 --dotty --eci=7 --fg=0000FF --scale=4"
" --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2"
<< "zint.exe -b 92 --cmyk -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty --eci=7 --fg=0000FF --scale=4"
" --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2"
<< "" << "";
QTest::newRow("BARCODE_C25INTER") << true << 0.0f << ""
<< BARCODE_C25INTER << UNICODE_MODE // symbology-inputMode
<< "12345" << "" // text-primary
<< 0.0f << -1 << 2 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 3 --compliantheight -d '12345' --small --vers=2"
<< "zint.exe -b 3 --compliantheight -d \"12345\" --small --vers=2"
<< "" << "";
QTest::newRow("BARCODE_CHANNEL") << false << 0.0f << ""
<< BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
<< "453678" << "" // text-primary
<< 19.7f << -1 << 7 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(255, 255, 255, 0) // guardDescent-bgColor
<< false << 1 << 2 << 0 << 0 << BOLD_TEXT // cmyk-fontSetting
<< true << false << true << false << false << 90 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << true // eci-debug
<< "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "" << "";
QTest::newRow("BARCODE_GS1_128_CC") << false << 0.0f << ""
<< BARCODE_GS1_128_CC << UNICODE_MODE // symbology-inputMode
<< "[01]12345678901231[15]121212" << "[11]901222[99]ABCDE" // text-primary
<< 71.142f << 3 << 0 << 0 << 3.5f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< false << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 131 --compliantheight -d '[11]901222[99]ABCDE' --height=71.142 --mode=3 --notext"
" --primary='[01]12345678901231[15]121212' --quietzones --scale=3.5"
<< "zint.exe -b 131 --compliantheight -d \"[11]901222[99]ABCDE\" --height=71.142 --mode=3 --notext"
" --primary=\"[01]12345678901231[15]121212\" --quietzones --scale=3.5"
<< "" << "";
QTest::newRow("BARCODE_CODE16K") << false << 11.7f << ""
<< BARCODE_CODE16K << (UNICODE_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "12345678901234567890123456789012" << "" // text-primary
<< 0.0f << 4 << 0 << 2 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 1 << 1 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 23 --bind --border=1 --compliantheight -d '12345678901234567890123456789012'"
" --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
<< "zint.exe -b 23 --bind --border=1 --compliantheight -d \"12345678901234567890123456789012\""
" --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
<< "" << "";
QTest::newRow("BARCODE_CODABLOCKF") << true << 0.0f << ""
<< BARCODE_CODABLOCKF << (DATA_MODE | ESCAPE_MODE) // symbology-inputMode
<< "T\\n\\xA0t\\\"" << "" // text-primary
<< 0.0f << 2 << 5 << 3 << 3.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 2 << 4 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << true << WARN_DEFAULT << false // eci-debug
<< "zint -b 74 --binary --border=4 --box --cols=5 --compliantheight -d 'T\\n\\xA0t\\\"' --esc --init"
" --rows=2 --scale=3 --separator=3"
<< "zint.exe -b 74 --binary --border=4 --box --cols=5 --compliantheight -d \"T\\n\\xA0t\\\\\"\" --esc --init"
" --rows=2 --scale=3 --separator=3"
<< "" << "";
QTest::newRow("BARCODE_DAFT") << false << 0.0f << ""
<< BARCODE_DAFT << UNICODE_MODE // symbology-inputMode
<< "daft" << "" // text-primary
<< 9.2f << -1 << 251 << 0 << 1.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(0x30, 0x31, 0x32, 0x33) << QColor(0xBF, 0xBE, 0xBD, 0xBC) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 93 --bg=BFBEBDBC -d 'daft' --fg=30313233 --height=9.2 --vers=251"
<< "zint.exe -b 93 --bg=BFBEBDBC -d \"daft\" --fg=30313233 --height=9.2 --vers=251"
<< "" << "";
QTest::newRow("BARCODE_DATAMATRIX") << true << 0.0f << ""
<< BARCODE_DATAMATRIX << GS1_MODE // symbology-inputMode
<< "[20]12" << "" // text-primary
<< 0.0f << -1 << 0 << DM_SQUARE << 1.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 71 -d '[20]12' --gs1 --gssep --square"
<< "zint.exe -b 71 -d \"[20]12\" --gs1 --gssep --square"
<< "" << "";
QTest::newRow("BARCODE_DBAR_EXPSTK_CC") << false << 40.8f << ""
<< BARCODE_DBAR_EXPSTK_CC << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "[91]ABCDEFGHIJKL" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 2 << 1.0f << true << 0.9f // height-dotSize
<< 3.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 139 --binary --compliantheight -d '[11]901222[99]ABCDE' --height=40.8 --heightperrow"
" --primary='[91]ABCDEFGHIJKL' --rows=2"
<< "zint.exe -b 139 --binary --compliantheight -d \"[11]901222[99]ABCDE\" --height=40.8 --heightperrow"
" --primary=\"[91]ABCDEFGHIJKL\" --rows=2"
<< "" << "";
QTest::newRow("BARCODE_DOTCODE") << false << 1.0f << ""
<< BARCODE_DOTCODE << GS1_MODE // symbology-inputMode
<< "[20]01" << "" // text-primary
<< 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << false << 0.7f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 115 --cols=8 -d '[20]01' --dotsize=0.7 --gs1 --mask=0"
<< "zint.exe -b 115 --cols=8 -d \"[20]01\" --dotsize=0.7 --gs1 --mask=0"
<< "" << "";
QTest::newRow("BARCODE_EANX") << true << 0.0f << ""
<< BARCODE_EANX << UNICODE_MODE // symbology-inputMode
<< "123456789012+12" << "" // text-primary
<< 0.0f << -1 << 8 << 0 << 1.0f << true << 0.8f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 13 --addongap=8 --compliantheight -d '123456789012+12' --guarddescent=0"
<< "zint.exe -b 13 --addongap=8 --compliantheight -d \"123456789012+12\" --guarddescent=0"
<< "" << "";
QTest::newRow("BARCODE_GRIDMATRIX") << false << 0.0f << ""
<< BARCODE_GRIDMATRIX << UNICODE_MODE // symbology-inputMode
<< "Your Data Here!" << "" // text-primary
<< 0.0f << 1 << 5 << 0 << 0.5f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 270 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 142 -d 'Your Data Here!' --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
<< "zint.exe -b 142 -d \"Your Data Here!\" --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
<< "" << "";
QTest::newRow("BARCODE_HANXIN") << false << 0.0f << ""
<< BARCODE_HANXIN << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
<< "éβÿ啊\\e\"'" << "" // text-primary
<< 30.0f << 2 << 5 << ((0 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 29 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 116 -d 'éβÿ啊\\e\"'\\''' --eci=29 --esc --mask=0 --secure=2 --vers=5"
<< "zint.exe -b 116 -d \"éβÿ啊\\e\\\"'\" --eci=29 --esc --mask=0 --secure=2 --vers=5"
<< "" << "";
QTest::newRow("BARCODE_HIBC_DM") << false << 10.0f << ""
<< BARCODE_HIBC_DM << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary
<< 0.0f << -1 << 8 << DM_DMRE << 1.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 102 -d '1234' --dmre --vers=8"
<< "zint.exe -b 102 -d \"1234\" --dmre --vers=8"
<< "" << "";
QTest::newRow("BARCODE_HIBC_PDF") << false << 0.0f << ""
<< BARCODE_HIBC_PDF << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "TEXT" << "" // text-primary
<< 3.5f << 3 << 4 << 10 << 10.0f << false << 0.8f // height-dotSize
<< 5.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 106 --binary --cols=4 -d 'TEXT' --height=3.5 --heightperrow --quietzones"
" --rows=10 --scale=10 --secure=3 --structapp=1,2"
<< "zint.exe -b 106 --binary --cols=4 -d \"TEXT\" --height=3.5 --heightperrow --quietzones"
" --rows=10 --scale=10 --secure=3 --structapp=1,2"
<< "" << "";
QTest::newRow("BARCODE_MAXICODE") << true << 0.0f << ""
<< BARCODE_MAXICODE << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
<< "152382802840001"
<< "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E" // text-primary
<< 0.0f << -1 << (96 + 1) << 0 << 2.5f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 57 -d '1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E'"
" --esc --primary='152382802840001' --quietzones --scale=2.5 --scmvv=96"
<< "zint.exe -b 57 -d \"1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E\""
" --esc --primary=\"152382802840001\" --quietzones --scale=2.5 --scmvv=96"
<< "" << "";
QTest::newRow("BARCODE_MICROQR") << false << 0.0f << ""
<< BARCODE_MICROQR << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary
<< 30.0f << 2 << 3 << (ZINT_FULL_MULTIBYTE | (3 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 97 -d '1234' --fullmultibyte --mask=3 --secure=2 --vers=3"
<< "zint.exe -b 97 -d \"1234\" --fullmultibyte --mask=3 --secure=2 --vers=3"
<< "" << "";
QTest::newRow("BARCODE_QRCODE") << true << 0.0f << ""
<< BARCODE_QRCODE << GS1_MODE // symbology-inputMode
<< "(01)12" << "" // text-primary
<< 0.0f << 1 << 5 << (ZINT_FULL_MULTIBYTE | (0 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << true << true << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 58 -d '(01)12' --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
" --secure=1 --vers=5"
<< "zint.exe -b 58 -d \"(01)12\" --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
" --secure=1 --vers=5"
<< "" << "";
QTest::newRow("BARCODE_RMQR") << true << 0.0f << ""
<< BARCODE_RMQR << UNICODE_MODE // symbology-inputMode
<< "" << "" // text-primary
<< 30.0f << -1 << 8 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 180 // showText-rotateAngle
<< 20 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 145 -d 'テ' --eci=20 --rotate=180 --vers=8"
<< "zint.exe -b 145 -d \"\" --eci=20 --rotate=180 --vers=8"
<< "" << "";
QTest::newRow("BARCODE_UPCE_CC") << true << 0.0f << "out.svg"
<< BARCODE_UPCE_CC << UNICODE_MODE // symbology-inputMode
<< "12345670+1234" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 6.5f << 0 << 0 << "" << QColor(0xEF, 0x29, 0x29) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // cmyk-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_FAIL_ALL << false // eci-debug
<< "zint -b 136 --bold --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror"
<< "zint.exe -b 136 --bold --compliantheight -d \"[11]901222[99]ABCDE\" --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small --werror"
<< "zint --barcode=136 --bold --compliantheight --data='[11]901222[99]ABCDE' --fg=EF2929"
" --guarddescent=6.5 --noquietzones --output='out.svg' --primary='12345670+1234' --small --werror"
<< "zint -b UPCE_CC --bold --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror";
QTest::newRow("BARCODE_VIN") << false << 2.0f << ""
<< BARCODE_VIN << UNICODE_MODE // symbology-inputMode
<< "12345678701234567" << "" // text-primary
<< 20.0f << -1 << 1 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< "zint -b 73 -d '12345678701234567' --height=20 --vers=1"
<< "zint.exe -b 73 -d \"12345678701234567\" --height=20 --vers=1"
<< "" << "";
}
void getAsCLITest()
{
Zint::QZint bc;
QString cmd;
QFETCH(bool, autoHeight);
QFETCH(float, heightPerRow);
QFETCH(QString, outfile);
QFETCH(int, symbology);
QFETCH(int, inputMode);
QFETCH(QString, text);
QFETCH(QString, primary);
QFETCH(float, height);
QFETCH(int, option1);
QFETCH(int, option2);
QFETCH(int, option3);
QFETCH(float, scale);
QFETCH(bool, dotty);
QFETCH(float, dotSize);
QFETCH(float, guardDescent);
QFETCH(int, structAppCount);
QFETCH(int, structAppIndex);
QFETCH(QString, structAppID);
QFETCH(QColor, fgColor);
QFETCH(QColor, bgColor);
QFETCH(bool, cmyk);
QFETCH(int, borderTypeIndex);
QFETCH(int, borderWidth);
QFETCH(int, whitespace);
QFETCH(int, vWhitespace);
QFETCH(int, fontSetting);
QFETCH(bool, showText);
QFETCH(bool, gsSep);
QFETCH(bool, quietZones);
QFETCH(bool, noQuietZones);
QFETCH(bool, compliantHeight);
QFETCH(int, rotateAngle);
QFETCH(int, eci);
QFETCH(bool, gs1Parens);
QFETCH(bool, gs1NoCheck);
QFETCH(bool, readerInit);
QFETCH(int, warnLevel);
QFETCH(bool, debug);
QFETCH(QString, expected_cmd);
QFETCH(QString, expected_win);
QFETCH(QString, expected_longOptOnly);
QFETCH(QString, expected_barcodeNames);
bc.setSymbol(symbology);
bc.setInputMode(inputMode);
if (primary.isEmpty()) {
bc.setText(text);
} else {
bc.setText(primary);
bc.setPrimaryMessage(text);
}
bc.setHeight(height);
bc.setOption1(option1);
bc.setOption2(option2);
bc.setOption3(option3);
bc.setScale(scale);
bc.setDotty(dotty);
bc.setDotSize(dotSize);
bc.setGuardDescent(guardDescent);
bc.setStructApp(structAppCount, structAppIndex, structAppID);
bc.setFgColor(fgColor);
bc.setBgColor(bgColor);
bc.setCMYK(cmyk);
bc.setBorderType(borderTypeIndex);
bc.setBorderWidth(borderWidth);
bc.setWhitespace(whitespace);
bc.setVWhitespace(vWhitespace);
bc.setFontSettingValue(fontSetting);
bc.setShowText(showText);
bc.setGSSep(gsSep);
bc.setQuietZones(quietZones);
bc.setNoQuietZones(noQuietZones);
bc.setCompliantHeight(compliantHeight);
bc.setRotateAngleValue(rotateAngle);
bc.setECIValue(eci);
bc.setGS1Parens(gs1Parens);
bc.setGS1NoCheck(gs1NoCheck);
bc.setReaderInit(readerInit);
bc.setWarnLevel(warnLevel);
bc.setDebug(debug);
cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, false /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_cmd);
cmd = bc.getAsCLI(true /*win*/, false /*longOptOnly*/, false /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_win);
if (!expected_longOptOnly.isEmpty()) {
cmd = bc.getAsCLI(false /*win*/, true /*longOptOnly*/, false /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_longOptOnly);
}
if (!expected_barcodeNames.isEmpty()) {
cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, true /*barcodeNames*/,
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_barcodeNames);
}
}
};
QTEST_MAIN(TestQZint)