mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
...and remove copy again!
This commit is contained in:
parent
249d33ee14
commit
ac6a92674e
@ -662,962 +662,6 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
|
|||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QZint::ustrlen(unsigned char data[]) {
|
|
||||||
/* Local replacement for strlen() with unsigned char strings */
|
|
||||||
int i;
|
|
||||||
for (i=0;data[i];i++);
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QZint::to_upper(unsigned char source[])
|
|
||||||
{ /* Converts lower case characters to upper case in a string source[] */
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ustrlen(source); i++) {
|
|
||||||
if ((source[i] >= 'a') && (source[i] <= 'z')) {
|
|
||||||
source [i] = (source[i] - 'a') + 'A'; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int QZint::ctoi(char source)
|
|
||||||
{ /* Converts a character 0-9 to its equivalent integer value */
|
|
||||||
if((source >= '0') && (source <= '9'))
|
|
||||||
return (source - '0');
|
|
||||||
return(source - 'A' + 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
int QZint::is_stackable(int symbology) {
|
|
||||||
/* Indicates which symbologies can have row binding */
|
|
||||||
if(symbology < BARCODE_PDF417) { return 1; }
|
|
||||||
if(symbology == BARCODE_CODE128B) { return 1; }
|
|
||||||
if(symbology == BARCODE_ISBNX) { return 1; }
|
|
||||||
if(symbology == BARCODE_EAN14) { return 1; }
|
|
||||||
if(symbology == BARCODE_NVE18) { return 1; }
|
|
||||||
if(symbology == BARCODE_KOREAPOST) { return 1; }
|
|
||||||
if(symbology == BARCODE_PLESSEY) { return 1; }
|
|
||||||
if(symbology == BARCODE_TELEPEN_NUM) { return 1; }
|
|
||||||
if(symbology == BARCODE_ITF14) { return 1; }
|
|
||||||
if(symbology == BARCODE_CODE32) { return 1; }
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QZint::is_extendable(int symbology) {
|
|
||||||
/* Indicates which symbols can have addon */
|
|
||||||
if(symbology == BARCODE_EANX) { return 1; }
|
|
||||||
if(symbology == BARCODE_UPCA) { return 1; }
|
|
||||||
if(symbology == BARCODE_UPCE) { return 1; }
|
|
||||||
if(symbology == BARCODE_ISBNX) { return 1; }
|
|
||||||
if(symbology == BARCODE_UPCA_CC) { return 1; }
|
|
||||||
if(symbology == BARCODE_UPCE_CC) { return 1; }
|
|
||||||
if(symbology == BARCODE_EANX_CC) { return 1; }
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QZint::roundup(float input)
|
|
||||||
{
|
|
||||||
float remainder;
|
|
||||||
int integer_part;
|
|
||||||
|
|
||||||
integer_part = (int)input;
|
|
||||||
remainder = input - integer_part;
|
|
||||||
|
|
||||||
if(remainder > 0.1) {
|
|
||||||
integer_part++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return integer_part;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QZint::copy_to_clipboard()
|
|
||||||
{
|
|
||||||
QString clipdata;
|
|
||||||
clipdata.clear();
|
|
||||||
int i, block_width, latch, r, this_row;
|
|
||||||
float textpos, large_bar_height, preset_height, row_height, row_posn = 0.0;
|
|
||||||
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
|
|
||||||
float red_ink, green_ink, blue_ink, red_paper, green_paper, blue_paper;
|
|
||||||
int textoffset, xoffset, yoffset, textdone, main_width;
|
|
||||||
char textpart[10], addon[6];
|
|
||||||
int large_bar_count, comp_offset;
|
|
||||||
float addon_text_posn;
|
|
||||||
float scaler = m_zintSymbol->scale;
|
|
||||||
float default_text_posn;
|
|
||||||
|
|
||||||
if (m_zintSymbol)
|
|
||||||
ZBarcode_Delete(m_zintSymbol);
|
|
||||||
|
|
||||||
QString fg_colour_hash = m_fgColor.name();
|
|
||||||
QString bg_colour_hash = m_bgColor.name();
|
|
||||||
|
|
||||||
m_lastError.clear();
|
|
||||||
m_zintSymbol = ZBarcode_Create();
|
|
||||||
m_zintSymbol->output_options=m_border;
|
|
||||||
m_zintSymbol->symbology=m_symbol;
|
|
||||||
m_zintSymbol->height=m_height;
|
|
||||||
m_zintSymbol->whitespace_width=m_whitespace;
|
|
||||||
m_zintSymbol->border_width=m_borderWidth;
|
|
||||||
m_zintSymbol->option_1=m_securityLevel;
|
|
||||||
m_zintSymbol->input_mode = m_input_mode;
|
|
||||||
m_zintSymbol->option_2=m_width;
|
|
||||||
m_zintSymbol->option_3=m_pdf417CodeWords;
|
|
||||||
m_zintSymbol->scale=m_scale;
|
|
||||||
QByteArray bstr=m_text.toAscii();
|
|
||||||
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
|
||||||
strcpy(m_zintSymbol->primary,pstr.data());
|
|
||||||
QByteArray fgcol=fg_colour_hash.right(6).toAscii();
|
|
||||||
QByteArray bgcol=bg_colour_hash.right(6).toAscii();
|
|
||||||
strcpy(m_zintSymbol->fgcolour,fgcol.data());
|
|
||||||
strcpy(m_zintSymbol->bgcolour,bgcol.data());
|
|
||||||
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data());
|
|
||||||
if (error > WARN_INVALID_OPTION) {
|
|
||||||
m_lastError=m_zintSymbol->errtxt;
|
|
||||||
return clipdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
row_height=0;
|
|
||||||
textdone = 0;
|
|
||||||
main_width = m_zintSymbol->width;
|
|
||||||
strcpy(addon, "");
|
|
||||||
comp_offset = 0;
|
|
||||||
addon_text_posn = 0.0;
|
|
||||||
|
|
||||||
/* sort out colour options */
|
|
||||||
to_upper((unsigned char*)m_zintSymbol->fgcolour);
|
|
||||||
to_upper((unsigned char*)m_zintSymbol->bgcolour);
|
|
||||||
|
|
||||||
fgred = (16 * ctoi(m_zintSymbol->fgcolour[0])) + ctoi(m_zintSymbol->fgcolour[1]);
|
|
||||||
fggrn = (16 * ctoi(m_zintSymbol->fgcolour[2])) + ctoi(m_zintSymbol->fgcolour[3]);
|
|
||||||
fgblu = (16 * ctoi(m_zintSymbol->fgcolour[4])) + ctoi(m_zintSymbol->fgcolour[5]);
|
|
||||||
bgred = (16 * ctoi(m_zintSymbol->bgcolour[0])) + ctoi(m_zintSymbol->bgcolour[1]);
|
|
||||||
bggrn = (16 * ctoi(m_zintSymbol->bgcolour[2])) + ctoi(m_zintSymbol->bgcolour[3]);
|
|
||||||
bgblu = (16 * ctoi(m_zintSymbol->bgcolour[4])) + ctoi(m_zintSymbol->bgcolour[5]);
|
|
||||||
red_ink = fgred / 256.0;
|
|
||||||
green_ink = fggrn / 256.0;
|
|
||||||
blue_ink = fgblu / 256.0;
|
|
||||||
red_paper = bgred / 256.0;
|
|
||||||
green_paper = bggrn / 256.0;
|
|
||||||
blue_paper = bgblu / 256.0;
|
|
||||||
|
|
||||||
if (m_zintSymbol->height == 0) {
|
|
||||||
m_zintSymbol->height = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
large_bar_count = 0;
|
|
||||||
preset_height = 0.0;
|
|
||||||
for(i = 0; i < m_zintSymbol->rows; i++) {
|
|
||||||
preset_height += m_zintSymbol->row_height[i];
|
|
||||||
if(m_zintSymbol->row_height[i] == 0) {
|
|
||||||
large_bar_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
large_bar_height = (m_zintSymbol->height - preset_height) / large_bar_count;
|
|
||||||
|
|
||||||
if (large_bar_count == 0) {
|
|
||||||
m_zintSymbol->height = preset_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!(module_set(m_zintSymbol->rows - 1, comp_offset))) {
|
|
||||||
comp_offset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Certain symbols need whitespace otherwise characters get chopped off the sides */
|
|
||||||
if ((((m_zintSymbol->symbology == BARCODE_EANX) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_EANX_CC))
|
|
||||||
|| (m_zintSymbol->symbology == BARCODE_ISBNX)) {
|
|
||||||
switch(ustrlen(m_zintSymbol->text)) {
|
|
||||||
case 13: /* EAN 13 */
|
|
||||||
case 16:
|
|
||||||
case 19:
|
|
||||||
if(m_zintSymbol->whitespace_width == 0) {
|
|
||||||
m_zintSymbol->whitespace_width = 10;
|
|
||||||
}
|
|
||||||
main_width = 96 + comp_offset;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
main_width = 68 + comp_offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((m_zintSymbol->symbology == BARCODE_UPCA) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
|
|
||||||
if(m_zintSymbol->whitespace_width == 0) {
|
|
||||||
m_zintSymbol->whitespace_width = 10;
|
|
||||||
main_width = 96 + comp_offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((m_zintSymbol->symbology == BARCODE_UPCE) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
|
|
||||||
if(m_zintSymbol->whitespace_width == 0) {
|
|
||||||
m_zintSymbol->whitespace_width = 10;
|
|
||||||
main_width = 51 + comp_offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
latch = 0;
|
|
||||||
r = 0;
|
|
||||||
/* Isolate add-on text */
|
|
||||||
if(is_extendable(m_zintSymbol->symbology)) {
|
|
||||||
for(i = 0; i < ustrlen(m_zintSymbol->text); i++) {
|
|
||||||
if (latch == 1) {
|
|
||||||
addon[r] = m_zintSymbol->text[i];
|
|
||||||
r++;
|
|
||||||
}
|
|
||||||
if (m_zintSymbol->text[i] == '+') {
|
|
||||||
latch = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addon[r] = '\0';
|
|
||||||
|
|
||||||
if(ustrlen(m_zintSymbol->text) != 0) {
|
|
||||||
textoffset = 9;
|
|
||||||
} else {
|
|
||||||
textoffset = 0;
|
|
||||||
}
|
|
||||||
xoffset = m_zintSymbol->border_width + m_zintSymbol->whitespace_width;
|
|
||||||
yoffset = m_zintSymbol->border_width;
|
|
||||||
|
|
||||||
/* Start writing the header */
|
|
||||||
clipdata += "<?xml version=\"1.0\" standalone=\"no\"?>\n";
|
|
||||||
clipdata += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n";
|
|
||||||
clipdata += " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
|
|
||||||
if(m_zintSymbol->symbology != BARCODE_MAXICODE) {
|
|
||||||
clipdata += QString("<svg width=\"%1\" height=\"%2\" version=\"1.1\"\n")
|
|
||||||
.arg(roundup((m_zintSymbol->width + xoffset + xoffset) * scaler))
|
|
||||||
.arg(roundup((m_zintSymbol->height + textoffset + yoffset + yoffset) * scaler));
|
|
||||||
} else {
|
|
||||||
clipdata += QString("<svg width=\"%1\" height=\"%2\" version=\"1.1\"\n")
|
|
||||||
.arg(roundup((74.0 + xoffset + xoffset) * scaler))
|
|
||||||
.arg(roundup((72.0 + yoffset + yoffset) * scaler));
|
|
||||||
}
|
|
||||||
clipdata += " xmlns=\"http://www.w3.org/2000/svg\">\n";
|
|
||||||
if(ustrlen(m_zintSymbol->text) != 0) {
|
|
||||||
clipdata += " <desc>";
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->text);
|
|
||||||
clipdata += "\n";
|
|
||||||
} else {
|
|
||||||
clipdata += " <desc>Zint Generated Symbol\n";
|
|
||||||
}
|
|
||||||
clipdata += " </desc>\n";
|
|
||||||
clipdata += "\n <g id=\"barcode\" fill=\"#";
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\">\n";
|
|
||||||
|
|
||||||
if(m_zintSymbol->symbology != BARCODE_MAXICODE) {
|
|
||||||
clipdata += QString(" <rect x=\"0\" y=\"0\" width=\"%1\" height=\"%2\" fill=\"#")
|
|
||||||
.arg(roundup((m_zintSymbol->width + xoffset + xoffset) * scaler))
|
|
||||||
.arg(roundup((m_zintSymbol->height + textoffset + yoffset + yoffset) * scaler));
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->bgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
} else {
|
|
||||||
clipdata += QString(" <rect x=\"0\" y=\"0\" width=\"%1\" height=\"%2\" fill=\"#")
|
|
||||||
.arg(roundup((74.0 + xoffset + xoffset) * scaler))
|
|
||||||
.arg(roundup((72.0 + yoffset + yoffset) * scaler));
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->bgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(((m_zintSymbol->output_options & BARCODE_BOX) != 0) || ((m_zintSymbol->output_options & BARCODE_BIND) != 0)) {
|
|
||||||
default_text_posn = (m_zintSymbol->height + textoffset + m_zintSymbol->border_width + m_zintSymbol->border_width) * scaler;
|
|
||||||
} else {
|
|
||||||
default_text_posn = (m_zintSymbol->height + textoffset + m_zintSymbol->border_width) * scaler;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_zintSymbol->symbology == BARCODE_MAXICODE) {
|
|
||||||
/* Maxicode uses hexagons */
|
|
||||||
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy, mx, my;
|
|
||||||
|
|
||||||
|
|
||||||
textoffset = 0.0;
|
|
||||||
if (((m_zintSymbol->output_options & BARCODE_BOX) != 0) || ((m_zintSymbol->output_options & BARCODE_BIND) != 0)) {
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg((74.0 + xoffset + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg((72.0 + m_zintSymbol->border_width) * scaler, 0, 'f', 2)
|
|
||||||
.arg((74.0 + xoffset + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
if((m_zintSymbol->output_options & BARCODE_BOX) != 0) {
|
|
||||||
/* side bars */
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2)
|
|
||||||
.arg((72.0 + (2 * m_zintSymbol->border_width)) * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((74.0 + xoffset + xoffset - m_zintSymbol->border_width) * scaler, 0, 'f', 2)
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2)
|
|
||||||
.arg((72.0 + (2 * m_zintSymbol->border_width)) * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
clipdata += QString(" <circle cx=\"%1\" cy=\"%2\" r=\"%3\" fill=\"#")
|
|
||||||
.arg((35.76 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg((35.60 + yoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(10.85 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
clipdata += QString(" <circle cx=\"%1\" cy=\"%2\" r=\"%3\" fill=\"#")
|
|
||||||
.arg((35.76 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg((35.60 + yoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(8.97 * scaler);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->bgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
clipdata += QString(" <circle cx=\"%1\" cy=\"%2\" r=\"%3\" fill=\"#")
|
|
||||||
.arg((35.76 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg((35.60 + yoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(7.10 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
clipdata += QString(" <circle cx=\"%1\" cy=\"%2\" r=\"%3\" fill=\"#")
|
|
||||||
.arg((35.76 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg((35.60 + yoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(5.22 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->bgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
clipdata += QString(" <circle cx=\"%1\" cy=\"%2\" r=\"%3\" fill=\"#")
|
|
||||||
.arg((35.76 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg((35.60 + yoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(3.31 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
clipdata += QString(" <circle cx=\"%1\" cy=\"%2\" r=\"%3\" fill=\"#")
|
|
||||||
.arg((35.76 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg((35.60 + yoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(1.43 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->bgcolour);
|
|
||||||
clipdata += "\" />\n";
|
|
||||||
for(r = 0; r < m_zintSymbol->rows; r++) {
|
|
||||||
for(i = 0; i < m_zintSymbol->width; i++) {
|
|
||||||
if(module_set(r, i)) {
|
|
||||||
/* Dump a hexagon */
|
|
||||||
my = r * 2.135 + 1.43;
|
|
||||||
ay = my + 1.0 + yoffset;
|
|
||||||
by = my + 0.5 + yoffset;
|
|
||||||
cy = my - 0.5 + yoffset;
|
|
||||||
dy = my - 1.0 + yoffset;
|
|
||||||
ey = my - 0.5 + yoffset;
|
|
||||||
fy = my + 0.5 + yoffset;
|
|
||||||
if(r % 2 == 1) {
|
|
||||||
mx = (2.46 * i) + 1.23 + 1.23;
|
|
||||||
} else {
|
|
||||||
mx = (2.46 * i) + 1.23;
|
|
||||||
}
|
|
||||||
ax = mx + xoffset;
|
|
||||||
bx = mx + 0.86 + xoffset;
|
|
||||||
cx = mx + 0.86 + xoffset;
|
|
||||||
dx = mx + xoffset;
|
|
||||||
ex = mx - 0.86 + xoffset;
|
|
||||||
fx = mx - 0.86 + xoffset;
|
|
||||||
clipdata += QString(" <path d=\"M %1 %2 L %3 %4 L %5 %6 L %7 %8 L %9 %10 L %11 %12 Z\" />\n")
|
|
||||||
.arg(ax * scaler, 0, 'f', 2)
|
|
||||||
.arg(ay * scaler, 0, 'f', 2)
|
|
||||||
.arg(bx * scaler, 0, 'f', 2)
|
|
||||||
.arg(by * scaler, 0, 'f', 2)
|
|
||||||
.arg(cx * scaler, 0, 'f', 2)
|
|
||||||
.arg(cy * scaler, 0, 'f', 2)
|
|
||||||
.arg(dx * scaler, 0, 'f', 2)
|
|
||||||
.arg(dy * scaler, 0, 'f', 2)
|
|
||||||
.arg(ex * scaler, 0, 'f', 2)
|
|
||||||
.arg(ey * scaler, 0, 'f', 2)
|
|
||||||
.arg(fx * scaler, 0, 'f', 2)
|
|
||||||
.arg(fy * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_zintSymbol->symbology != BARCODE_MAXICODE) {
|
|
||||||
/* everything else uses rectangles (or squares) */
|
|
||||||
/* Works from the bottom of the symbol up */
|
|
||||||
int addon_latch = 0;
|
|
||||||
|
|
||||||
for(r = 0; r < m_zintSymbol->rows; r++) {
|
|
||||||
this_row = r;
|
|
||||||
if(m_zintSymbol->row_height[this_row] == 0) {
|
|
||||||
row_height = large_bar_height;
|
|
||||||
} else {
|
|
||||||
row_height = m_zintSymbol->row_height[this_row];
|
|
||||||
}
|
|
||||||
row_posn = 0;
|
|
||||||
for(i = 0; i < r; i++) {
|
|
||||||
if(m_zintSymbol->row_height[i] == 0) {
|
|
||||||
row_posn += large_bar_height;
|
|
||||||
} else {
|
|
||||||
row_posn += m_zintSymbol->row_height[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
row_posn += yoffset;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
if(module_set(this_row, 0)) {
|
|
||||||
latch = 1;
|
|
||||||
} else {
|
|
||||||
latch = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
block_width = 0;
|
|
||||||
do {
|
|
||||||
block_width++;
|
|
||||||
} while (module_set(this_row, i + block_width) == module_set(this_row, i));
|
|
||||||
if((addon_latch == 0) && (r == 0) && (i > main_width)) {
|
|
||||||
addon_text_posn = 9.0 + m_zintSymbol->border_width;
|
|
||||||
addon_latch = 1;
|
|
||||||
}
|
|
||||||
if(latch == 1) {
|
|
||||||
/* a bar */
|
|
||||||
if(addon_latch == 0) {
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((i + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn * scaler, 0, 'f', 2)
|
|
||||||
.arg(block_width * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_height * scaler, 0, 'f', 2);
|
|
||||||
} else {
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((i + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg((row_posn + 10.0) * scaler, 0, 'f', 2)
|
|
||||||
.arg(block_width * scaler, 0, 'f', 2)
|
|
||||||
.arg((row_height - 5.0) * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
latch = 0;
|
|
||||||
} else {
|
|
||||||
/* a space */
|
|
||||||
latch = 1;
|
|
||||||
}
|
|
||||||
i += block_width;
|
|
||||||
|
|
||||||
} while (i < m_zintSymbol->width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* That's done the actual data area, everything else is human-friendly */
|
|
||||||
|
|
||||||
xoffset += comp_offset;
|
|
||||||
row_posn = (row_posn + large_bar_height) * scaler;
|
|
||||||
|
|
||||||
if ((((m_zintSymbol->symbology == BARCODE_EANX) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_EANX_CC)) ||
|
|
||||||
(m_zintSymbol->symbology == BARCODE_ISBNX)) {
|
|
||||||
/* guard bar extensions and text formatting for EAN8 and EAN13 */
|
|
||||||
switch(ustrlen(m_zintSymbol->text)) {
|
|
||||||
case 8: /* EAN-8 */
|
|
||||||
case 11:
|
|
||||||
case 14:
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((0 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((2 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((32 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((34 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((64 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((66 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
for(i = 0; i < 4; i++) {
|
|
||||||
textpart[i] = m_zintSymbol->text[i];
|
|
||||||
}
|
|
||||||
textpart[4] = '\0';
|
|
||||||
textpos = 17;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
for(i = 0; i < 4; i++) {
|
|
||||||
textpart[i] = m_zintSymbol->text[i + 4];
|
|
||||||
}
|
|
||||||
textpart[4] = '\0';
|
|
||||||
textpos = 50;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
textdone = 1;
|
|
||||||
switch(strlen(addon)) {
|
|
||||||
case 2:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 10;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 23;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 13: /* EAN 13 */
|
|
||||||
case 16:
|
|
||||||
case 19:
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((0 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((2 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((46 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((48 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((92 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((94 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
textpart[0] = m_zintSymbol->text[0];
|
|
||||||
textpart[1] = '\0';
|
|
||||||
textpos = -7;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
for(i = 0; i < 6; i++) {
|
|
||||||
textpart[i] = m_zintSymbol->text[i + 1];
|
|
||||||
}
|
|
||||||
textpart[6] = '\0';
|
|
||||||
textpos = 24;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
for(i = 0; i < 6; i++) {
|
|
||||||
textpart[i] = m_zintSymbol->text[i + 7];
|
|
||||||
}
|
|
||||||
textpart[6] = '\0';
|
|
||||||
textpos = 71;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
textdone = 1;
|
|
||||||
switch(strlen(addon)) {
|
|
||||||
case 2:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 10;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 23;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%2\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((m_zintSymbol->symbology == BARCODE_UPCA) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
|
|
||||||
/* guard bar extensions and text formatting for UPCA */
|
|
||||||
latch = 1;
|
|
||||||
|
|
||||||
i = 0 + comp_offset;
|
|
||||||
do {
|
|
||||||
block_width = 0;
|
|
||||||
do {
|
|
||||||
block_width++;
|
|
||||||
} while (module_set(m_zintSymbol->rows - 1, i + block_width) == module_set(m_zintSymbol->rows - 1, i));
|
|
||||||
if(latch == 1) {
|
|
||||||
/* a bar */
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((i + xoffset - comp_offset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(block_width * scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
latch = 0;
|
|
||||||
} else {
|
|
||||||
/* a space */
|
|
||||||
latch = 1;
|
|
||||||
}
|
|
||||||
i += block_width;
|
|
||||||
} while (i < 11 + comp_offset);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((46 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((48 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
latch = 1;
|
|
||||||
i = 85 + comp_offset;
|
|
||||||
do {
|
|
||||||
block_width = 0;
|
|
||||||
do {
|
|
||||||
block_width++;
|
|
||||||
} while (module_set(m_zintSymbol->rows - 1, i + block_width) == module_set(m_zintSymbol->rows - 1, i));
|
|
||||||
if(latch == 1) {
|
|
||||||
/* a bar */
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((i + xoffset - comp_offset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(block_width * scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
latch = 0;
|
|
||||||
} else {
|
|
||||||
/* a space */
|
|
||||||
latch = 1;
|
|
||||||
}
|
|
||||||
i += block_width;
|
|
||||||
} while (i < 96 + comp_offset);
|
|
||||||
textpart[0] = m_zintSymbol->text[0];
|
|
||||||
textpart[1] = '\0';
|
|
||||||
textpos = -5;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(8.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
for(i = 0; i < 5; i++) {
|
|
||||||
textpart[i] = m_zintSymbol->text[i + 1];
|
|
||||||
}
|
|
||||||
textpart[5] = '\0';
|
|
||||||
textpos = 27;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
for(i = 0; i < 5; i++) {
|
|
||||||
textpart[i] = m_zintSymbol->text[i + 6];
|
|
||||||
}
|
|
||||||
textpart[6] = '\0';
|
|
||||||
textpos = 68;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
textpart[0] = m_zintSymbol->text[11];
|
|
||||||
textpart[1] = '\0';
|
|
||||||
textpos = 100;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(8.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
textdone = 1;
|
|
||||||
switch(strlen(addon)) {
|
|
||||||
case 2:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 10;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 23;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((m_zintSymbol->symbology == BARCODE_UPCE) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
|
|
||||||
/* guard bar extensions and text formatting for UPCE */
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((0 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((2 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((46 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((48 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((50 + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(row_posn, 0, 'f', 2)
|
|
||||||
.arg(scaler, 0, 'f', 2)
|
|
||||||
.arg(5.0 * scaler, 0, 'f', 2);
|
|
||||||
textpart[0] = m_zintSymbol->text[0];
|
|
||||||
textpart[1] = '\0';
|
|
||||||
textpos = -5;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(8.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
for(i = 0; i < 6; i++) {
|
|
||||||
textpart[i] = m_zintSymbol->text[i + 1];
|
|
||||||
}
|
|
||||||
textpart[6] = '\0';
|
|
||||||
textpos = 24;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
textpart[0] = m_zintSymbol->text[7];
|
|
||||||
textpart[1] = '\0';
|
|
||||||
textpos = 55;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(8.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)textpart);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
textdone = 1;
|
|
||||||
switch(strlen(addon)) {
|
|
||||||
case 2:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 10;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
textpos = m_zintSymbol->width + xoffset - 23;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg(textpos * scaler, 0, 'f', 2)
|
|
||||||
.arg(addon_text_posn * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(11.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)addon);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
xoffset -= comp_offset;
|
|
||||||
|
|
||||||
switch(m_zintSymbol->symbology) {
|
|
||||||
case BARCODE_CODABLOCKF:
|
|
||||||
case BARCODE_HIBC_BLOCKF:
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(xoffset * scaler, 0, 'f', 2)
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->width * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(xoffset * scaler, 0, 'f', 2)
|
|
||||||
.arg((m_zintSymbol->height + m_zintSymbol->border_width) * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->width * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2);
|
|
||||||
if(m_zintSymbol->rows > 1) {
|
|
||||||
/* row binding */
|
|
||||||
for(r = 1; r < m_zintSymbol->rows; r++) {
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((xoffset + 11) * scaler, 0, 'f', 2)
|
|
||||||
.arg(((r * row_height) + yoffset - 1) * scaler, 0, 'f', 2)
|
|
||||||
.arg((m_zintSymbol->width - 24) * scaler, 0, 'f', 2)
|
|
||||||
.arg(2.0 * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BARCODE_MAXICODE:
|
|
||||||
/* Do nothing! (It's already been done) */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if((m_zintSymbol->output_options & BARCODE_BIND) != 0) {
|
|
||||||
if((m_zintSymbol->rows > 1) && (is_stackable(m_zintSymbol->symbology) == 1)) {
|
|
||||||
/* row binding */
|
|
||||||
for(r = 1; r < m_zintSymbol->rows; r++) {
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(xoffset * scaler, 0, 'f', 2)
|
|
||||||
.arg(((r * row_height) + yoffset - 1) * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->width * scaler, 0, 'f', 2)
|
|
||||||
.arg(2.0 * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (((m_zintSymbol->output_options & BARCODE_BOX) != 0) || ((m_zintSymbol->output_options & BARCODE_BIND) != 0)) {
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg((m_zintSymbol->width + xoffset + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg((m_zintSymbol->height + m_zintSymbol->border_width) * scaler, 0, 'f', 2)
|
|
||||||
.arg((m_zintSymbol->width + xoffset + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
if((m_zintSymbol->output_options & BARCODE_BOX) != 0) {
|
|
||||||
/* side bars */
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%5\" />\n")
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2)
|
|
||||||
.arg((m_zintSymbol->height + (2 * m_zintSymbol->border_width)) * scaler, 0, 'f', 2);
|
|
||||||
clipdata += QString(" <rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />\n")
|
|
||||||
.arg((m_zintSymbol->width + xoffset + xoffset - m_zintSymbol->border_width) * scaler, 0, 'f', 2)
|
|
||||||
.arg(0.0, 0, 'f', 2)
|
|
||||||
.arg(m_zintSymbol->border_width * scaler, 0, 'f', 2)
|
|
||||||
.arg((m_zintSymbol->height + (2 * m_zintSymbol->border_width)) * scaler, 0, 'f', 2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put the human readable text at the bottom */
|
|
||||||
if((textdone == 0) && (ustrlen(m_zintSymbol->text) != 0)) {
|
|
||||||
textpos = m_zintSymbol->width / 2.0;
|
|
||||||
clipdata += QString(" <text x=\"%1\" y=\"%2\" text-anchor=\"middle\"\n")
|
|
||||||
.arg((textpos + xoffset) * scaler, 0, 'f', 2)
|
|
||||||
.arg(default_text_posn, 0, 'f', 2);
|
|
||||||
clipdata += QString(" font-family=\"Helvetica\" font-size=\"%1\" fill=\"#")
|
|
||||||
.arg(8.0 * scaler, 0, 'f', 1);
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->fgcolour);
|
|
||||||
clipdata += "\" >\n ";
|
|
||||||
clipdata += QString((const char *)m_zintSymbol->text);
|
|
||||||
clipdata += "\n </text>\n";
|
|
||||||
}
|
|
||||||
clipdata += " </g>\n";
|
|
||||||
clipdata += "</svg>\n";
|
|
||||||
|
|
||||||
return clipdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString & QZint::lastError()
|
const QString & QZint::lastError()
|
||||||
{
|
{
|
||||||
return m_lastError;
|
return m_lastError;
|
||||||
|
@ -87,16 +87,10 @@ public:
|
|||||||
bool hasErrors();
|
bool hasErrors();
|
||||||
|
|
||||||
bool save_to_file(QString filename);
|
bool save_to_file(QString filename);
|
||||||
QString copy_to_clipboard();
|
|
||||||
private:
|
private:
|
||||||
void encode();
|
void encode();
|
||||||
int module_set(int y_coord, int x_coord);
|
int module_set(int y_coord, int x_coord);
|
||||||
void to_upper(unsigned char source[]);
|
|
||||||
int ustrlen(unsigned char data[]);
|
|
||||||
int ctoi(char source);
|
|
||||||
int is_stackable(int symbology);
|
|
||||||
int is_extendable(int symbology);
|
|
||||||
int roundup(float input);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_symbol;
|
int m_symbol;
|
||||||
|
@ -565,16 +565,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btnCopy" >
|
|
||||||
<property name="enabled" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Copy</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnExit" >
|
<widget class="QPushButton" name="btnExit" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QUiLoader>
|
#include <QUiLoader>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QClipboard>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -126,7 +125,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
|||||||
connect(btnSave, SIGNAL(clicked( bool )), SLOT(save()));
|
connect(btnSave, SIGNAL(clicked( bool )), SLOT(save()));
|
||||||
connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale()));
|
connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale()));
|
||||||
connect(btnExit, SIGNAL(clicked( bool )), SLOT(quit_now()));
|
connect(btnExit, SIGNAL(clicked( bool )), SLOT(quit_now()));
|
||||||
connect(btnCopy, SIGNAL(clicked( bool )), SLOT(copy_to_clipboard()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -158,18 +156,6 @@ bool MainWindow::save()
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::copy_to_clipboard()
|
|
||||||
{
|
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
|
||||||
QString clip_data_str = m_bc.bc.copy_to_clipboard();
|
|
||||||
QByteArray clip_data_ba = clip_data_str.toUtf8();
|
|
||||||
QMimeData *clip_data_mime = new QMimeData;
|
|
||||||
clip_data_mime->setData("image/svg+xml", clip_data_ba);
|
|
||||||
clipboard->setMimeData(clip_data_mime, QClipboard::Clipboard);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::about()
|
void MainWindow::about()
|
||||||
{
|
{
|
||||||
QMessageBox::about(this, tr("About Zint"),
|
QMessageBox::about(this, tr("About Zint"),
|
||||||
|
@ -122,7 +122,6 @@ private slots:
|
|||||||
bool save();
|
bool save();
|
||||||
void about();
|
void about();
|
||||||
void quit_now();
|
void quit_now();
|
||||||
void copy_to_clipboard();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* void createActions();
|
/* void createActions();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user