mcc2 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +5 -3
- data/lib/mcc2/dataman/base.rb +0 -44
- data/lib/mcc2/dataman/csv.rb +0 -1
- data/lib/mcc2/dataman/database.rb +0 -2
- data/lib/mcc2/dataman/dbf.rb +0 -1
- data/lib/mcc2/dataman/none.rb +0 -2
- data/lib/mcc2/{cc_dialogbox.rb → fxselection_dialog.rb} +2 -2
- data/lib/mcc2/gui/layoutview_dlg.pp +1067 -1146
- data/lib/mcc2/layout.rb +0 -7
- data/lib/mcc2/layout_file.rb +1 -30
- data/lib/mcc2/layout_object/barcode.rb +0 -2
- data/lib/mcc2/layout_object/box.rb +0 -2
- data/lib/mcc2/layout_object/chip.rb +0 -3
- data/lib/mcc2/layout_object/embed.rb +0 -2
- data/lib/mcc2/layout_object/graphic.rb +0 -2
- data/lib/mcc2/layout_object/picture.rb +0 -2
- data/lib/mcc2/layout_object/text.rb +1 -3
- data/lib/mcc2/layoutview.rb +5 -3
- data/lib/mcc2/layoutview_dlg.rb +573 -607
- data/lib/mcc2/mcc2gui.rb +2 -8
- data/lib/mcc2/printer/card_printer.rb +0 -2
- data/lib/mcc2/printer/file_printer.rb +2 -2
- data/lib/mcc2/printer/gdi_card_printer.rb +0 -3
- data/lib/mcc2/printer/gdi_printer.rb +0 -3
- data/lib/mcc2/printer/linux_cups_printer.rb +2 -2
- data/lib/mcc2/printer/preview.rb +2 -9
- data/lib/mcc2/printer/printer_cab.rb +2 -2
- data/lib/mcc2/printer/printer_cx320_direct.rb +0 -2
- data/lib/mcc2/printer/printer_epl.rb +2 -2
- data/lib/mcc2/printer/printer_ttp34x.rb +2 -2
- data/lib/mcc2/printer/printer_zebra.rb +0 -1
- data/lib/mcc2/printer/svg_drawer.rb +111 -109
- data/lib/mcc2/version.rb +1 -1
- data/lib/mcc2.rb +242 -7
- data/locales/en.yml +5 -0
- data/locales/rs.yml +5 -0
- data/mcc2.gemspec +1 -0
- data.tar.gz.sig +0 -0
- metadata +16 -3
- metadata.gz.sig +0 -0
- data/lib/mcc2/constants.rb +0 -154
data/lib/mcc2/mcc2gui.rb
CHANGED
|
@@ -8,6 +8,7 @@ require "fox16/responder"
|
|
|
8
8
|
require "libguib16"
|
|
9
9
|
require "optparse"
|
|
10
10
|
require "i18n"
|
|
11
|
+
require "tempfile"
|
|
11
12
|
|
|
12
13
|
# convert relative image file path to absolute one
|
|
13
14
|
# based on dir of this file.
|
|
@@ -20,14 +21,7 @@ def loadImage(file)
|
|
|
20
21
|
i
|
|
21
22
|
end
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
require "mcc2/mcc2_mainwin" # das Main-GUI
|
|
25
|
-
require "mcc2/cc_dialogbox"
|
|
26
|
-
|
|
27
|
-
require "mcc2/layout" # das Kartenlayout
|
|
28
|
-
require "mcc2/debug_tools"
|
|
29
|
-
|
|
30
|
-
require "tempfile"
|
|
24
|
+
require "mcc2/mcc2_mainwin"
|
|
31
25
|
|
|
32
26
|
# *****************************************************************************
|
|
33
27
|
module Mcc2
|
data/lib/mcc2/printer/preview.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require "mcc2/printer/svg_drawer"
|
|
4
|
-
require 'nokogiri'
|
|
1
|
+
require 'rsvg2'
|
|
2
|
+
require 'cairo'
|
|
5
3
|
|
|
6
4
|
module Mcc2
|
|
7
5
|
module Printer
|
|
@@ -195,11 +193,6 @@ module Mcc2
|
|
|
195
193
|
attr_reader :font_map
|
|
196
194
|
|
|
197
195
|
def draw_preview_now(row = nil)
|
|
198
|
-
require 'rsvg2'
|
|
199
|
-
require 'cairo'
|
|
200
|
-
require 'pango'
|
|
201
|
-
require 'ttfunk'
|
|
202
|
-
|
|
203
196
|
@font_map = {}
|
|
204
197
|
|
|
205
198
|
# allgemeine Einstellungen des Image vornehmen
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require "mcc2/dataman/base"
|
|
2
1
|
require "i18n"
|
|
3
2
|
require "ttfunk"
|
|
4
3
|
require "pango"
|
|
5
4
|
|
|
6
5
|
module Mcc2
|
|
6
|
+
module Printer
|
|
7
7
|
module SvgDrawer
|
|
8
8
|
class ObjRectangle
|
|
9
9
|
def initialize(v1, v2, v3, v4, obj_id)
|
|
@@ -250,22 +250,18 @@ module Mcc2
|
|
|
250
250
|
drawing.g transform: "rotate(#{rec.a})" do
|
|
251
251
|
opos = rec.inverse
|
|
252
252
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
go_width, go_height
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
draw_embedobject(drawing, opos, go, go_width, go_height, data, row ? row["row_number"] : "1", barcode_dpi)
|
|
266
|
-
end
|
|
267
|
-
rescue => err
|
|
268
|
-
raise err, "#{go[GOA_NAME]}: #{err}"
|
|
253
|
+
# die Objekt-spezifischen Attribute ermitteln
|
|
254
|
+
go_width, go_height = if typ == TEXTOBJECT
|
|
255
|
+
draw_textobject(drawing, opos, go, go_width, go_height, data.empty? ? data_nosub : data)
|
|
256
|
+
elsif typ == PICTUREOBJECT
|
|
257
|
+
draw_pictureobject(drawing, opos, go, go_width, go_height, data)
|
|
258
|
+
elsif typ == BARCODEOBJECT
|
|
259
|
+
data = data.gsub(/\\x([0-9a-f][0-9a-f])/i) { [$1.hex].pack("C") }
|
|
260
|
+
draw_barcode(drawing, opos, go, go_width, go_height, data, barcode_dpi)
|
|
261
|
+
elsif typ == BOXOBJECT
|
|
262
|
+
draw_boxobject(drawing, opos, go, go_width, go_height)
|
|
263
|
+
elsif typ == EMBEDOBJECT
|
|
264
|
+
draw_embedobject(drawing, opos, go, go_width, go_height, data, row ? row["row_number"] : "1", barcode_dpi)
|
|
269
265
|
end
|
|
270
266
|
|
|
271
267
|
rec2 = rec.translate(mm(go_width), 0)
|
|
@@ -286,6 +282,8 @@ module Mcc2
|
|
|
286
282
|
end
|
|
287
283
|
end
|
|
288
284
|
end
|
|
285
|
+
rescue => err
|
|
286
|
+
raise err, "#{go[GOA_NAME] if go}: #{err}"
|
|
289
287
|
end
|
|
290
288
|
|
|
291
289
|
if preview
|
|
@@ -345,6 +343,7 @@ module Mcc2
|
|
|
345
343
|
pjust = Pango::Alignment::LEFT
|
|
346
344
|
end
|
|
347
345
|
just_block = go[GOA_JUSTIFICATION_BLOCK] == "true"
|
|
346
|
+
line_spacing = go[GOA_LINE_SPACING]
|
|
348
347
|
|
|
349
348
|
if data && !data.empty?
|
|
350
349
|
font_info = get_font_info(font, go)
|
|
@@ -360,7 +359,8 @@ module Mcc2
|
|
|
360
359
|
layout.wrap = Pango::WrapMode::WORD_CHAR
|
|
361
360
|
layout.justify = just_block
|
|
362
361
|
layout.alignment = pjust
|
|
363
|
-
layout.
|
|
362
|
+
layout.line_spacing = line_spacing.to_f unless line_spacing.to_s.empty?
|
|
363
|
+
layout.ellipsize = Pango::EllipsizeMode::END if go_width && go_height
|
|
364
364
|
layout.text = data # set the text to render
|
|
365
365
|
|
|
366
366
|
drawing.text_(fill: font_color,
|
|
@@ -479,102 +479,103 @@ module Mcc2
|
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
def draw_barcode(drawing, tra, go, go_width, go_height, data, barcode_dpi)
|
|
482
|
-
|
|
482
|
+
unless data.nil? || data.empty?
|
|
483
483
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
484
|
+
barcode_typ = go[GOA_BARCODE_TYP]
|
|
485
|
+
option1 = go[GOA_BARCODE_OPTION_1].to_i
|
|
486
|
+
option2 = go[GOA_BARCODE_OPTION_2].to_i
|
|
487
|
+
option3 = go[GOA_BARCODE_OPTION_3].to_i
|
|
488
|
+
font = go[GOA_FONT_TYP]
|
|
489
|
+
if font == "from_file"
|
|
490
|
+
font = go.layout_file.expand_path(go[GOA_FONT_FILE])
|
|
491
|
+
end
|
|
492
|
+
fontsize = go[GOA_FONT_HEIGHT].to_f
|
|
493
|
+
font_color = ["#", go[GOA_FONT_COLOR]].join
|
|
494
494
|
|
|
495
|
-
|
|
495
|
+
font_info = get_font_info(font, go)
|
|
496
496
|
|
|
497
|
-
begin
|
|
498
|
-
barcode = Zint.const_get(BARCODE_ALIAS[barcode_typ.to_sym] || barcode_typ).new(value: data)
|
|
499
|
-
rescue => e
|
|
500
|
-
raise Printer::Base::InvalidBarcodeData, I18n.t(:error_generating_barcode, default: "Fehler beim Generieren des Barcodes %{data}: %{e}", data: data.inspect, e: )
|
|
501
|
-
else
|
|
502
|
-
# TODO: bar_ratio wird nicht gesetzt
|
|
503
|
-
# barcode.narrow_width = 1
|
|
504
|
-
# barcode.wide_width = bar_ratio
|
|
505
|
-
barcode.input_mode = Zint::DATA_MODE # Zint::UNICODE_MODE | Zint::ESCAPE_MODE
|
|
506
|
-
# barcode.output_options = Zint::SMALL_TEXT
|
|
507
|
-
|
|
508
|
-
# 50 is the default x-dimension for most of the 1D barcodes:
|
|
509
|
-
barcode.height = go[GOA_BARCODE_HEIGHT].to_f if go[GOA_BARCODE_HEIGHT].to_f.round(3) != 0
|
|
510
|
-
barcode.show_hrt = 0 if fontsize == 0
|
|
511
|
-
barcode.option_1 = option1
|
|
512
|
-
barcode.option_2 = option2
|
|
513
|
-
barcode.option_3 = option3
|
|
514
|
-
# barcode.fontsize = fontsize # not used in zint
|
|
515
|
-
# p [go_height, go_width, barcode.height]
|
|
516
|
-
barcode.whitespace_width = 0
|
|
517
497
|
begin
|
|
518
|
-
|
|
519
|
-
rescue
|
|
520
|
-
raise
|
|
521
|
-
|
|
498
|
+
barcode = Zint.const_get(BARCODE_ALIAS[barcode_typ.to_sym] || barcode_typ).new(value: data)
|
|
499
|
+
rescue => e
|
|
500
|
+
raise Printer::Base::InvalidBarcodeData, I18n.t(:error_generating_barcode, default: "Fehler beim Generieren des Barcodes %{data}: %{e}", data: data.inspect, e: )
|
|
501
|
+
else
|
|
502
|
+
# TODO: bar_ratio wird nicht gesetzt
|
|
503
|
+
# barcode.narrow_width = 1
|
|
504
|
+
# barcode.wide_width = bar_ratio
|
|
505
|
+
barcode.input_mode = Zint::DATA_MODE # Zint::UNICODE_MODE | Zint::ESCAPE_MODE
|
|
506
|
+
# barcode.output_options = Zint::SMALL_TEXT
|
|
507
|
+
|
|
508
|
+
# 50 is the default x-dimension for most of the 1D barcodes:
|
|
509
|
+
barcode.height = go[GOA_BARCODE_HEIGHT].to_f if go[GOA_BARCODE_HEIGHT].to_f.round(3) != 0
|
|
510
|
+
barcode.show_hrt = 0 if fontsize == 0
|
|
511
|
+
barcode.option_1 = option1
|
|
512
|
+
barcode.option_2 = option2
|
|
513
|
+
barcode.option_3 = option3
|
|
514
|
+
# barcode.fontsize = fontsize # not used in zint
|
|
515
|
+
# p [go_height, go_width, barcode.height]
|
|
516
|
+
barcode.whitespace_width = 0
|
|
517
|
+
begin
|
|
518
|
+
bcvector = barcode.to_vector
|
|
519
|
+
rescue Zint::ErrorInvalidData => err
|
|
520
|
+
raise err, "#{err.message} Barcode text: #{data.inspect}"
|
|
521
|
+
end
|
|
522
522
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
523
|
+
%w[EAN13 EAN8].include?(barcode_typ)
|
|
524
|
+
|
|
525
|
+
# bcvector values are always a multiple of 2 or more, but we need a multiple of 1 for to_i below.
|
|
526
|
+
# So all bcvector measurements are divided by 2 or more.
|
|
527
|
+
xgran = bcvector.width.round / barcode.width
|
|
528
|
+
ygran = bcvector.height.round / barcode.rows
|
|
529
|
+
xbars, ybars = bcvector.width / xgran, bcvector.height / ygran
|
|
530
|
+
# p vector_width: bcvector.width, vector_height: bcvector.height
|
|
531
|
+
|
|
532
|
+
optimized = (go[GOA_BARCODE_OPTIMIZED] || true).to_s == "true"
|
|
533
|
+
px_width, px_height = barcode_mm_to_px(go_width, barcode_dpi), barcode_mm_to_px(go_height, barcode_dpi)
|
|
534
|
+
xdim, ydim = px_width / xbars, px_height / ybars
|
|
535
|
+
if optimized
|
|
536
|
+
xdim = xdim.to_i
|
|
537
|
+
ydim = ydim.to_i if barcode.rows > 1 # optimize y dimension only on 2D codes
|
|
538
|
+
end
|
|
539
|
+
go_width, go_height = barcode_px_to_mm(xdim * xbars, barcode_dpi), barcode_px_to_mm(ydim * ybars, barcode_dpi)
|
|
540
|
+
px_width, px_height = mm(go_width), mm(go_height)
|
|
541
|
+
xdim = px_width / xbars / xgran
|
|
542
|
+
ydim = px_height / ybars / ygran
|
|
543
|
+
|
|
544
|
+
pathd = +""
|
|
545
|
+
bcvector.each_rectangle do |bar|
|
|
546
|
+
# p [bar.x, bar.y, bar.width, bar.height]
|
|
547
|
+
# p [xdim*bar.width, ydim*bar.height, xdim*bar.x, ydim*bar.y]
|
|
548
|
+
x = tra.x + xdim * bar.x
|
|
549
|
+
y = tra.y + ydim * bar.y
|
|
550
|
+
# drawing.rectangle(
|
|
551
|
+
# x,
|
|
552
|
+
# y,
|
|
553
|
+
# x + [xdim * bar.width - 1, 0].max,
|
|
554
|
+
# y + [ydim * bar.height - 1, 0].max
|
|
555
|
+
# )
|
|
556
|
+
# drawing.rect(x: x, y: y, width: xdim * bar.width, height: ydim * bar.height, fill: font_color, stroke: "none")
|
|
557
|
+
# body.rect([xdim * bar.width / 2 - 1, 0].max, [ydim * bar.height / 2 - 1, 0].max, xdim * bar.x / 2, ydim * bar.y / 2)
|
|
558
|
+
w = xdim * bar.width
|
|
559
|
+
h = ydim * bar.height
|
|
560
|
+
pathd << "M#{x} #{y}h#{w}v#{h}h-#{w}Z"
|
|
561
|
+
end
|
|
562
|
+
drawing.path(d: pathd, stroke: "none", fill: font_color)
|
|
563
|
+
bcvector.each_string do |str|
|
|
564
|
+
# p [str.x, str.y, str.text, str.halign, str.fsize]
|
|
565
|
+
# drawing.text_anchor(HALIGNMENT[str.halign])
|
|
566
|
+
# apos = tra.translate(xdim * str.x / xgran, )
|
|
567
|
+
# drawing.text(tra.x + xdim * str.x, tra.y + ydim * str.y, str.text)
|
|
568
|
+
# body.text(xdim * str.x / 2, ydim * str.y / 2, str.text).styles(text_anchor: HALIGNMENT[str.halign])
|
|
569
|
+
drawing.text_(str.text, x: tra.x + xdim * str.x, y: tra.y + ydim * str.y,
|
|
570
|
+
'text-anchor': HALIGNMENT[str.halign],
|
|
571
|
+
fill: font_color,
|
|
572
|
+
'font-size': pt(fontsize),
|
|
573
|
+
'font-family': font_info.font_family,
|
|
574
|
+
'font-weight': font_info.font_weight,
|
|
575
|
+
'font-style': font_info.font_style,
|
|
576
|
+
'font-stretch': font_info.font_stretch,
|
|
577
|
+
'xml:space': "preserve")
|
|
578
|
+
end
|
|
578
579
|
end
|
|
579
580
|
end
|
|
580
581
|
return go_width, go_height
|
|
@@ -697,4 +698,5 @@ module Mcc2
|
|
|
697
698
|
desc
|
|
698
699
|
end
|
|
699
700
|
end
|
|
701
|
+
end
|
|
700
702
|
end
|
data/lib/mcc2/version.rb
CHANGED